Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
672a1e4e
Commit
672a1e4e
authored
Feb 20, 2006
by
Rein Klazes
Committed by
Alexandre Julliard
Feb 20, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user: Move drawing of pop menu arrows to a subroutine reduces nesting
level of some large if statements in the drawing code. Some updates to the comments.
parent
4be3d64d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
43 deletions
+63
-43
menu.c
dlls/user/menu.c
+63
-43
No files found.
dlls/user/menu.c
View file @
672a1e4e
...
...
@@ -27,6 +27,11 @@
* have been selected, i.e. their popup menu is currently displayed.
* This is probably not the meaning this style has in MS-Windows.
*
* Note 2: where there is a difference, these menu API's are according
* the behavior of Windows 2k and Windows XP. Known differences with
* Windows 9x/ME are documented in the comments, in case an application
* is found to depend on the old behavior.
*
* TODO:
* implements styles :
* - MNS_AUTODISMISS
...
...
@@ -104,7 +109,7 @@ typedef struct {
DWORD
dwContextHelpID
;
DWORD
dwMenuData
;
/* application defined value */
HMENU
hSysMenuOwner
;
/* Handle to the dummy sys menu holder */
SIZE
maxBmpSize
;
/* Maximum size of the bitmap items
in MIIM_BITMAP state
*/
SIZE
maxBmpSize
;
/* Maximum size of the bitmap items */
}
POPUPMENU
,
*
LPPOPUPMENU
;
/* internal flags for menu tracking */
...
...
@@ -155,6 +160,7 @@ typedef struct
#define MENU_ITEM_TYPE(flags) \
((flags) & (MF_STRING | MF_BITMAP | MF_OWNERDRAW | MF_SEPARATOR))
/* macro to test that flags do not indicate bitmap, ownerdraw or separator */
#define IS_STRING_ITEM(flags) (MENU_ITEM_TYPE ((flags)) == MF_STRING)
#define IS_MAGIC_BITMAP(id) ((id) && ((INT_PTR)(id) < 12) && ((INT_PTR)(id) >= -1))
...
...
@@ -1258,6 +1264,25 @@ MENU_DrawScrollArrows(LPPOPUPMENU lppop, HDC hdc)
/***********************************************************************
* draw_popup_arrow
*
* Draws the popup-menu arrow.
*/
static
void
draw_popup_arrow
(
HDC
hdc
,
RECT
rect
,
UINT
arrow_bitmap_width
,
UINT
arrow_bitmap_height
)
{
HDC
hdcMem
=
CreateCompatibleDC
(
hdc
);
HBITMAP
hOrigBitmap
;
hOrigBitmap
=
SelectObject
(
hdcMem
,
get_arrow_bitmap
()
);
BitBlt
(
hdc
,
rect
.
right
-
arrow_bitmap_width
-
1
,
(
rect
.
top
+
rect
.
bottom
-
arrow_bitmap_height
)
/
2
,
arrow_bitmap_width
,
arrow_bitmap_height
,
hdcMem
,
0
,
0
,
SRCCOPY
);
SelectObject
(
hdcMem
,
hOrigBitmap
);
DeleteDC
(
hdcMem
);
}
/***********************************************************************
* MENU_DrawMenuItem
*
* Draw a single menu item.
...
...
@@ -1268,9 +1293,17 @@ static void MENU_DrawMenuItem( HWND hwnd, HMENU hmenu, HWND hwndOwner, HDC hdc,
RECT
rect
;
BOOL
flat_menu
=
FALSE
;
int
bkgnd
;
UINT
arrow_bitmap_width
=
0
,
arrow_bitmap_height
=
0
;
debug_print_menuitem
(
"MENU_DrawMenuItem: "
,
lpitem
,
""
);
if
(
!
menuBar
)
{
BITMAP
bmp
;
GetObjectW
(
get_arrow_bitmap
(),
sizeof
(
bmp
),
&
bmp
);
arrow_bitmap_width
=
bmp
.
bmWidth
;
arrow_bitmap_height
=
bmp
.
bmHeight
;
}
if
(
lpitem
->
fType
&
MF_SYSMENU
)
{
if
(
!
IsIconic
(
hwnd
)
)
...
...
@@ -1336,7 +1369,11 @@ static void MENU_DrawMenuItem( HWND hwnd, HMENU hmenu, HWND hwndOwner, HDC hdc,
dis
.
itemID
,
dis
.
itemState
,
dis
.
itemAction
,
dis
.
hwndItem
,
dis
.
hDC
,
wine_dbgstr_rect
(
&
dis
.
rcItem
));
SendMessageW
(
hwndOwner
,
WM_DRAWITEM
,
0
,
(
LPARAM
)
&
dis
);
/* Fall through to draw popup-menu arrow */
/* Draw the popup-menu arrow */
if
(
lpitem
->
fType
&
MF_POPUP
)
draw_popup_arrow
(
hdc
,
rect
,
arrow_bitmap_width
,
arrow_bitmap_height
);
return
;
}
TRACE
(
"rect=%s
\n
"
,
wine_dbgstr_rect
(
&
lpitem
->
rect
));
...
...
@@ -1346,8 +1383,6 @@ static void MENU_DrawMenuItem( HWND hwnd, HMENU hmenu, HWND hwndOwner, HDC hdc,
rect
=
lpitem
->
rect
;
MENU_AdjustMenuItemRect
(
MENU_GetMenu
(
hmenu
),
&
rect
);
if
(
!
(
lpitem
->
fType
&
MF_OWNERDRAW
))
{
if
(
lpitem
->
fState
&
MF_HILITE
)
{
if
(
flat_menu
)
...
...
@@ -1367,18 +1402,15 @@ static void MENU_DrawMenuItem( HWND hwnd, HMENU hmenu, HWND hwndOwner, HDC hdc,
}
else
FillRect
(
hdc
,
&
rect
,
GetSysColorBrush
(
bkgnd
)
);
}
SetBkMode
(
hdc
,
TRANSPARENT
);
if
(
!
(
lpitem
->
fType
&
MF_OWNERDRAW
))
{
HPEN
oldPen
;
/* vertical separator */
if
(
!
menuBar
&&
(
lpitem
->
fType
&
MF_MENUBARBREAK
))
{
HPEN
oldPen
;
RECT
rc
=
rect
;
rc
.
top
=
3
;
rc
.
bottom
=
height
-
3
;
if
(
flat_menu
)
...
...
@@ -1395,7 +1427,9 @@ static void MENU_DrawMenuItem( HWND hwnd, HMENU hmenu, HWND hwndOwner, HDC hdc,
/* horizontal separator */
if
(
lpitem
->
fType
&
MF_SEPARATOR
)
{
HPEN
oldPen
;
RECT
rc
=
rect
;
rc
.
left
++
;
rc
.
right
--
;
rc
.
top
+=
SEPARATOR_HEIGHT
/
2
;
...
...
@@ -1410,7 +1444,6 @@ static void MENU_DrawMenuItem( HWND hwnd, HMENU hmenu, HWND hwndOwner, HDC hdc,
DrawEdge
(
hdc
,
&
rc
,
EDGE_ETCHED
,
BF_TOP
);
return
;
}
}
/* helper lines for debugging */
/* FrameRect(hdc, &rect, GetStockObject(BLACK_BRUSH));
...
...
@@ -1423,19 +1456,10 @@ static void MENU_DrawMenuItem( HWND hwnd, HMENU hmenu, HWND hwndOwner, HDC hdc,
{
HBITMAP
bm
;
INT
y
=
rect
.
top
+
rect
.
bottom
;
RECT
rc
=
rect
;
UINT
check_bitmap_width
=
GetSystemMetrics
(
SM_CXMENUCHECK
);
UINT
check_bitmap_height
=
GetSystemMetrics
(
SM_CYMENUCHECK
);
UINT
arrow_bitmap_width
,
arrow_bitmap_height
;
BITMAP
bmp
;
GetObjectW
(
get_arrow_bitmap
(),
sizeof
(
bmp
),
&
bmp
);
arrow_bitmap_width
=
bmp
.
bmWidth
;
arrow_bitmap_height
=
bmp
.
bmHeight
;
if
(
!
(
lpitem
->
fType
&
MF_OWNERDRAW
))
{
RECT
rc
;
rc
=
rect
;
if
(
lpitem
->
hbmpItem
)
{
POPUPMENU
*
menu
=
MENU_GetMenu
(
hmenu
);
...
...
@@ -1505,33 +1529,18 @@ static void MENU_DrawMenuItem( HWND hwnd, HMENU hmenu, HWND hwndOwner, HDC hdc,
MENU_DrawBitmapItem
(
hdc
,
lpitem
,
&
rect
,
FALSE
);
}
}
}
/* Draw the popup-menu arrow */
if
(
lpitem
->
fType
&
MF_POPUP
)
{
HDC
hdcMem
=
CreateCompatibleDC
(
hdc
);
HBITMAP
hOrigBitmap
;
hOrigBitmap
=
SelectObject
(
hdcMem
,
get_arrow_bitmap
()
);
BitBlt
(
hdc
,
rect
.
right
-
arrow_bitmap_width
-
1
,
(
y
-
arrow_bitmap_height
)
/
2
,
arrow_bitmap_width
,
arrow_bitmap_height
,
hdcMem
,
0
,
0
,
SRCCOPY
);
SelectObject
(
hdcMem
,
hOrigBitmap
);
DeleteDC
(
hdcMem
);
}
draw_popup_arrow
(
hdc
,
rect
,
arrow_bitmap_width
,
arrow_bitmap_height
);
rect
.
left
+=
check_bitmap_width
;
rect
.
right
-=
arrow_bitmap_width
;
}
else
if
(
lpitem
->
hbmpItem
&&
!
(
lpitem
->
fType
&
MF_OWNERDRAW
)
)
else
if
(
lpitem
->
hbmpItem
)
{
/* Draw the bitmap */
MENU_DrawBitmapItem
(
hdc
,
lpitem
,
&
rect
,
menuBar
);
}
/* Done for owner-drawn */
if
(
lpitem
->
fType
&
MF_OWNERDRAW
)
return
;
/* process text if present */
if
(
lpitem
->
text
)
{
...
...
@@ -4279,16 +4288,19 @@ static BOOL GetMenuItemInfo_common ( HMENU hmenu, UINT item, BOOL bypos,
if
(
lpmii
->
fMask
&
MIIM_TYPE
)
{
if
(
lpmii
->
fMask
&
(
MIIM_STRING
|
MIIM_FTYPE
|
MIIM_BITMAP
))
{
WARN
(
"invalid combination of fMask bits used
\n
"
);
/* this does not happen on Win9x/ME */
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
lpmii
->
fType
=
menu
->
fType
&
~
MF_POPUP
;
if
(
menu
->
hbmpItem
)
lpmii
->
fType
|=
MFT_BITMAP
;
lpmii
->
hbmpItem
=
menu
->
hbmpItem
;
lpmii
->
hbmpItem
=
menu
->
hbmpItem
;
/* not on Win9x/ME */
if
(
lpmii
->
fType
&
MFT_BITMAP
)
{
lpmii
->
dwTypeData
=
(
LPWSTR
)
menu
->
hbmpItem
;
lpmii
->
cch
=
0
;
}
else
if
(
lpmii
->
fType
&
(
MFT_OWNERDRAW
|
MFT_SEPARATOR
))
{
/* this does not happen on Win9x/ME */
lpmii
->
dwTypeData
=
0
;
lpmii
->
cch
=
0
;
}
...
...
@@ -4327,10 +4339,13 @@ static BOOL GetMenuItemInfo_common ( HMENU hmenu, UINT item, BOOL bypos,
lpmii
->
cch
--
;
else
lpmii
->
cch
=
len
;
else
/* return length of string */
else
{
/* return length of string */
/* not on Win9x/ME if fType & MFT_BITMAP */
lpmii
->
cch
=
len
;
}
}
}
if
(
lpmii
->
fMask
&
MIIM_FTYPE
)
lpmii
->
fType
=
menu
->
fType
&
~
MF_POPUP
;
...
...
@@ -4346,8 +4361,11 @@ static BOOL GetMenuItemInfo_common ( HMENU hmenu, UINT item, BOOL bypos,
if
(
lpmii
->
fMask
&
MIIM_SUBMENU
)
lpmii
->
hSubMenu
=
menu
->
hSubMenu
;
else
lpmii
->
hSubMenu
=
0
;
/* hSubMenu is always cleared */
else
{
/* hSubMenu is always cleared
* (not on Win9x/ME ) */
lpmii
->
hSubMenu
=
0
;
}
if
(
lpmii
->
fMask
&
MIIM_CHECKMARKS
)
{
lpmii
->
hbmpChecked
=
menu
->
hCheckBit
;
...
...
@@ -4433,10 +4451,12 @@ static BOOL SetMenuItemInfo_common(MENUITEM * menu,
{
if
(
!
menu
)
return
FALSE
;
debug_print_menuitem
(
"
MENU_Set
ItemInfo_common from: "
,
menu
,
""
);
debug_print_menuitem
(
"
Setmenu
ItemInfo_common from: "
,
menu
,
""
);
if
(
lpmii
->
fMask
&
MIIM_TYPE
)
{
if
(
lpmii
->
fMask
&
(
MIIM_STRING
|
MIIM_FTYPE
|
MIIM_BITMAP
))
{
WARN
(
"invalid combination of fMask bits used
\n
"
);
/* this does not happen on Win9x/ME */
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment