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
d9ac53f1
Commit
d9ac53f1
authored
Jun 07, 2000
by
Aric Stewart
Committed by
Alexandre Julliard
Jun 07, 2000
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added handling of TBSTYLE_AUTOSIZE.
parent
c94e0861
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
75 additions
and
28 deletions
+75
-28
toolbar.c
dlls/comctl32/toolbar.c
+75
-28
No files found.
dlls/comctl32/toolbar.c
View file @
d9ac53f1
...
...
@@ -46,6 +46,15 @@ DEFAULT_DEBUG_CHANNEL(toolbar)
#define TOOLBAR_GetInfoPtr(hwnd) ((TOOLBAR_INFO *)GetWindowLongA(hwnd,0))
static
BOOL
TOOLBAR_IsValidBitmapIndex
(
TOOLBAR_INFO
*
infoPtr
,
INT
index
)
{
if
((
index
>=
0
)
&&
(
index
<
infoPtr
->
nNumBitmaps
))
return
TRUE
;
else
return
FALSE
;
}
static
void
TOOLBAR_DrawFlatSeparator
(
LPRECT
lpRect
,
HDC
hdc
)
...
...
@@ -96,7 +105,7 @@ TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
InflateRect
(
&
rcText
,
-
3
,
-
3
);
if
(
himl
&&
btnPtr
->
iBitmap
>=
0
)
{
if
(
himl
&&
TOOLBAR_IsValidBitmapIndex
(
infoPtr
,
btnPtr
->
iBitmap
)
)
{
if
((
dwStyle
&
TBSTYLE_LIST
)
&&
((
btnPtr
->
fsStyle
&
TBSTYLE_AUTOSIZE
)
==
0
)
&&
(
btnPtr
->
iBitmap
!=
I_IMAGENONE
))
{
...
...
@@ -228,7 +237,8 @@ TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
DrawEdge
(
hdc
,
&
rc
,
EDGE_RAISED
,
BF_SOFT
|
BF_RECT
|
BF_MIDDLE
|
BF_ADJUST
);
if
(
infoPtr
->
himlDis
&&
btnPtr
->
iBitmap
>=
0
)
if
(
infoPtr
->
himlDis
&&
TOOLBAR_IsValidBitmapIndex
(
infoPtr
,
btnPtr
->
iBitmap
))
ImageList_Draw
(
infoPtr
->
himlDis
,
btnPtr
->
iBitmap
,
hdc
,
rc
.
left
+
1
,
rc
.
top
+
1
,
ILD_NORMAL
);
else
...
...
@@ -245,7 +255,7 @@ TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
DrawEdge
(
hdc
,
&
rc
,
BDR_SUNKENOUTER
,
BF_RECT
|
BF_MIDDLE
|
BF_ADJUST
);
else
DrawEdge
(
hdc
,
&
rc
,
EDGE_SUNKEN
,
BF_RECT
|
BF_MIDDLE
|
BF_ADJUST
);
if
(
btnPtr
->
iBitmap
>=
0
)
if
(
TOOLBAR_IsValidBitmapIndex
(
infoPtr
,
btnPtr
->
iBitmap
)
)
ImageList_Draw
(
infoPtr
->
himlDef
,
btnPtr
->
iBitmap
,
hdc
,
rc
.
left
+
2
,
rc
.
top
+
2
,
ILD_NORMAL
);
TOOLBAR_DrawString
(
infoPtr
,
btnPtr
,
hdc
,
btnPtr
->
fsState
,
dwStyle
,
...
...
@@ -265,7 +275,7 @@ TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
TOOLBAR_DrawPattern
(
hdc
,
&
rc
);
if
(
btnPtr
->
iBitmap
>=
0
)
if
(
TOOLBAR_IsValidBitmapIndex
(
infoPtr
,
btnPtr
->
iBitmap
)
)
ImageList_Draw
(
infoPtr
->
himlDef
,
btnPtr
->
iBitmap
,
hdc
,
rc
.
left
+
2
,
rc
.
top
+
2
,
ILD_NORMAL
);
...
...
@@ -291,10 +301,11 @@ TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
{
if
(
btnPtr
->
bHot
)
DrawEdge
(
hdc
,
&
rc
,
BDR_RAISEDINNER
,
BF_RECT
|
BF_MIDDLE
);
if
(
btnPtr
->
bHot
&&
infoPtr
->
himlHot
&&
btnPtr
->
iBitmap
>=
0
)
if
(
btnPtr
->
bHot
&&
infoPtr
->
himlHot
&&
TOOLBAR_IsValidBitmapIndex
(
infoPtr
,
btnPtr
->
iBitmap
))
ImageList_Draw
(
infoPtr
->
himlHot
,
btnPtr
->
iBitmap
,
hdc
,
rc
.
left
+
2
,
rc
.
top
+
2
,
ILD_NORMAL
);
else
if
(
btnPtr
->
iBitmap
>=
0
)
else
if
(
TOOLBAR_IsValidBitmapIndex
(
infoPtr
,
btnPtr
->
iBitmap
)
)
ImageList_Draw
(
infoPtr
->
himlDef
,
btnPtr
->
iBitmap
,
hdc
,
rc
.
left
+
2
,
rc
.
top
+
2
,
ILD_NORMAL
);
}
...
...
@@ -303,7 +314,7 @@ TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
DrawEdge
(
hdc
,
&
rc
,
EDGE_RAISED
,
BF_SOFT
|
BF_RECT
|
BF_MIDDLE
|
BF_ADJUST
);
if
(
btnPtr
->
iBitmap
>=
0
)
if
(
TOOLBAR_IsValidBitmapIndex
(
infoPtr
,
btnPtr
->
iBitmap
)
)
ImageList_Draw
(
infoPtr
->
himlDef
,
btnPtr
->
iBitmap
,
hdc
,
rc
.
left
+
1
,
rc
.
top
+
1
,
ILD_NORMAL
);
}
...
...
@@ -330,45 +341,55 @@ TOOLBAR_Refresh (HWND hwnd, HDC hdc, PAINTSTRUCT* ps)
}
}
static
void
TOOLBAR_
CalcStrings
(
HWND
hwnd
,
LPSIZE
lpSize
)
TOOLBAR_
MeasureString
(
HWND
hwnd
,
INT
index
,
LPSIZE
lpSize
)
{
TOOLBAR_INFO
*
infoPtr
=
TOOLBAR_GetInfoPtr
(
hwnd
);
TBUTTON_INFO
*
btnPtr
;
INT
i
;
HDC
hdc
;
HFONT
hOldFont
;
SIZE
sz
;
LPWSTR
lpText
=
NULL
;
lpSize
->
cx
=
0
;
lpSize
->
cy
=
0
;
hdc
=
GetDC
(
0
);
hOldFont
=
SelectObject
(
hdc
,
infoPtr
->
hFont
);
btnPtr
=
infoPtr
->
buttons
;
for
(
i
=
0
;
i
<
infoPtr
->
nNumButtons
;
i
++
,
btnPtr
++
)
{
btnPtr
=
&
infoPtr
->
buttons
[
index
]
;
if
(
!
(
btnPtr
->
fsState
&
TBSTATE_HIDDEN
)
&&
(
btnPtr
->
iString
>
-
1
)
&&
(
btnPtr
->
iString
<
infoPtr
->
nNumStrings
))
{
/* get a pointer to the text */
if
(
HIWORD
(
btnPtr
->
iString
)
!=
0
)
lpText
=
(
LPWSTR
)
btnPtr
->
iString
;
else
if
((
btnPtr
->
iString
>=
0
)
&&
(
btnPtr
->
iString
<
infoPtr
->
nNumStrings
))
lpText
=
infoPtr
->
strings
[
btnPtr
->
iString
];
(
btnPtr
->
iString
<
infoPtr
->
nNumStrings
))
{
LPWSTR
lpText
=
infoPtr
->
strings
[
btnPtr
->
iString
];
GetTextExtentPoint32W
(
hdc
,
lpText
,
lstrlenW
(
lpText
),
lpSize
);
}
SelectObject
(
hdc
,
hOldFont
);
ReleaseDC
(
0
,
hdc
);
TRACE
(
"string size %d x %d!
\n
"
,
lpSize
->
cx
,
lpSize
->
cy
);
}
static
void
TOOLBAR_CalcStrings
(
HWND
hwnd
,
LPSIZE
lpSize
)
{
TOOLBAR_INFO
*
infoPtr
=
TOOLBAR_GetInfoPtr
(
hwnd
);
TBUTTON_INFO
*
btnPtr
;
INT
i
;
SIZE
sz
;
GetTextExtentPoint32W
(
hdc
,
lpText
,
lstrlenW
(
lpText
),
&
sz
);
lpSize
->
cx
=
0
;
lpSize
->
cy
=
0
;
btnPtr
=
infoPtr
->
buttons
;
for
(
i
=
0
;
i
<
infoPtr
->
nNumButtons
;
i
++
,
btnPtr
++
)
{
TOOLBAR_MeasureString
(
hwnd
,
i
,
&
sz
);
if
(
sz
.
cx
>
lpSize
->
cx
)
lpSize
->
cx
=
sz
.
cx
;
if
(
sz
.
cy
>
lpSize
->
cy
)
lpSize
->
cy
=
sz
.
cy
;
}
}
SelectObject
(
hdc
,
hOldFont
);
ReleaseDC
(
0
,
hdc
);
TRACE
(
"string size %d x %d!
\n
"
,
lpSize
->
cx
,
lpSize
->
cy
);
}
...
...
@@ -556,7 +577,7 @@ TOOLBAR_CalcToolbar (HWND hwnd)
INT
i
;
for
(
i
=
0
;
i
<
infoPtr
->
nNumButtons
&&
!
usesBitmaps
;
i
++
)
if
(
infoPtr
->
buttons
[
i
].
iBitmap
>=
0
)
if
(
TOOLBAR_IsValidBitmapIndex
(
infoPtr
,
infoPtr
->
buttons
[
i
].
iBitmap
)
)
usesBitmaps
=
TRUE
;
if
(
sizeString
.
cy
>
0
)
{
...
...
@@ -633,6 +654,13 @@ TOOLBAR_CalcToolbar (HWND hwnd)
cx
=
(
btnPtr
->
iBitmap
>
0
)
?
btnPtr
->
iBitmap
:
SEPARATOR_WIDTH
;
else
{
if
(
btnPtr
->
fsStyle
&
TBSTYLE_AUTOSIZE
)
{
SIZE
sz
;
TOOLBAR_MeasureString
(
hwnd
,
i
,
&
sz
);
cx
=
sz
.
cx
+
6
;
}
else
cx
=
infoPtr
->
nButtonWidth
;
}
cy
=
infoPtr
->
nHeight
;
...
...
@@ -986,7 +1014,7 @@ TOOLBAR_AddBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
{
TOOLBAR_INFO
*
infoPtr
=
TOOLBAR_GetInfoPtr
(
hwnd
);
LPTBADDBITMAP
lpAddBmp
=
(
LPTBADDBITMAP
)
lParam
;
INT
nIndex
=
0
,
nButtons
;
INT
nIndex
=
0
,
nButtons
,
nCount
;
HBITMAP
hbmLoad
;
if
(
!
lpAddBmp
)
...
...
@@ -1044,6 +1072,8 @@ TOOLBAR_AddBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
infoPtr
->
himlInt
=
infoPtr
->
himlDef
;
}
nCount
=
ImageList_GetImageCount
(
infoPtr
->
himlDef
);
/* Add bitmaps to the default image list */
if
(
lpAddBmp
->
hInst
==
(
HINSTANCE
)
0
)
{
...
...
@@ -1117,7 +1147,21 @@ TOOLBAR_AddBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
DeleteObject
(
hbmLoad
);
}
if
(
nIndex
!=
-
1
)
{
INT
imagecount
=
ImageList_GetImageCount
(
infoPtr
->
himlDef
);
if
(
infoPtr
->
nNumBitmaps
+
nButtons
!=
imagecount
)
{
WARN
(
"Desired images do not match recieved images : Previous image number %s Previous images in list %i added %i expecting total %i, Images in list %i
\n
"
,
infoPtr
->
nNumBitmaps
,
nCount
,
imagecount
-
nCount
,
infoPtr
->
nNumBitmaps
+
nButtons
,
imagecount
);
infoPtr
->
nNumBitmaps
=
imagecount
;
}
else
infoPtr
->
nNumBitmaps
+=
nButtons
;
}
return
nIndex
;
}
...
...
@@ -2817,6 +2861,7 @@ TOOLBAR_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
himlTemp
=
infoPtr
->
himlDef
;
infoPtr
->
himlDef
=
(
HIMAGELIST
)
lParam
;
infoPtr
->
nNumBitmaps
=
ImageList_GetImageCount
(
infoPtr
->
himlDef
);
/* FIXME: redraw ? */
return
(
LRESULT
)
himlTemp
;
...
...
@@ -3022,6 +3067,8 @@ TOOLBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
infoPtr
->
nMaxTextRows
=
1
;
infoPtr
->
cxMin
=
-
1
;
infoPtr
->
cxMax
=
-
1
;
infoPtr
->
nNumBitmaps
=
0
;
infoPtr
->
nNumStrings
=
0
;
infoPtr
->
bCaptured
=
FALSE
;
infoPtr
->
bUnicode
=
IsWindowUnicode
(
hwnd
);
...
...
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