Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Yoann Laissus
wine
Commits
e0ab2b7f
Commit
e0ab2b7f
authored
23 years ago
by
Uwe Bonnes
Committed by
Alexandre Julliard
23 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Consistent usage of istring, use STR_[Get|Set]Ptr where appropriate.
parent
440adc19
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dlls/comctl32/toolbar.c
+68
-124
68 additions, 124 deletions
dlls/comctl32/toolbar.c
with
68 additions
and
124 deletions
dlls/comctl32/toolbar.c
+
68
−
124
View file @
e0ab2b7f
...
...
@@ -148,13 +148,28 @@ typedef struct
#define TOOLBAR_HasDropDownArrows(exStyle) ((exStyle & TBSTYLE_EX_DRAWDDARROWS) ? TRUE : FALSE)
static
LPWSTR
TOOLBAR_GetText
(
TOOLBAR_INFO
*
infoPtr
,
TBUTTON_INFO
*
btnPtr
)
{
LPWSTR
lpText
=
NULL
;
/* FIXME: iString == -1 is undocumented */
if
((
HIWORD
(
btnPtr
->
iString
)
!=
0
)
&&
(
btnPtr
->
iString
!=
-
1
))
lpText
=
(
LPWSTR
)
btnPtr
->
iString
;
else
if
((
btnPtr
->
iString
>=
0
)
&&
(
btnPtr
->
iString
<
infoPtr
->
nNumStrings
))
lpText
=
infoPtr
->
strings
[
btnPtr
->
iString
];
return
lpText
;
}
static
void
TOOLBAR_DumpButton
(
TOOLBAR_INFO
*
infoPtr
,
TBUTTON_INFO
*
bP
,
INT
btn_num
,
BOOL
internal
)
{
if
(
TRACE_ON
(
toolbar
)){
TRACE
(
"button %d id %d, bitmap=%d, state=%02x, style=%02x, data=%08lx, string=%
d
\n
"
,
TRACE
(
"button %d id %d, bitmap=%d, state=%02x, style=%02x, data=%08lx, string
id
=%
x
\n
"
,
btn_num
,
bP
->
idCommand
,
bP
->
iBitmap
,
bP
->
fsState
,
bP
->
fsStyle
,
bP
->
dwData
,
bP
->
iString
);
TRACE
(
"string %s
\n
"
,
debugstr_w
(
TOOLBAR_GetText
(
infoPtr
,
bP
)));
if
(
internal
)
TRACE
(
"button %d id %d, hot=%s, row=%d, rect=(%d,%d)-(%d,%d)
\n
"
,
btn_num
,
bP
->
idCommand
,
...
...
@@ -226,20 +241,6 @@ TOOLBAR_SendNotify (NMHDR *nmhdr, TOOLBAR_INFO *infoPtr, UINT code)
(
WPARAM
)
nmhdr
->
idFrom
,
(
LPARAM
)
nmhdr
);
}
static
LPWSTR
TOOLBAR_GetText
(
TOOLBAR_INFO
*
infoPtr
,
TBUTTON_INFO
*
btnPtr
)
{
LPWSTR
lpText
=
NULL
;
/* FIXME: iString == -1 is undocumented */
if
((
HIWORD
(
btnPtr
->
iString
)
!=
0
)
&&
(
btnPtr
->
iString
!=
-
1
))
lpText
=
(
LPWSTR
)
btnPtr
->
iString
;
else
if
((
btnPtr
->
iString
>=
0
)
&&
(
btnPtr
->
iString
<
infoPtr
->
nNumStrings
))
lpText
=
infoPtr
->
strings
[
btnPtr
->
iString
];
return
lpText
;
}
/***********************************************************************
* TOOLBAR_GetBitmapIndex
*
...
...
@@ -443,7 +444,7 @@ TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
/* get a pointer to the text */
lpText
=
TOOLBAR_GetText
(
infoPtr
,
btnPtr
);
TRACE
(
"
lpT
ext: %s
\n
"
,
debugstr_w
(
lpText
));
TRACE
(
"
Stringt
ext: %s
\n
"
,
debugstr_w
(
lpText
));
/* draw text */
if
(
lpText
)
{
...
...
@@ -814,11 +815,9 @@ TOOLBAR_MeasureString(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
lpSize
->
cx
=
0
;
lpSize
->
cy
=
0
;
if
(
!
(
btnPtr
->
fsState
&
TBSTATE_HIDDEN
)
&&
(
btnPtr
->
iString
>
-
1
)
&&
(
btnPtr
->
iString
<
infoPtr
->
nNumStrings
))
if
(
!
(
btnPtr
->
fsState
&
TBSTATE_HIDDEN
)
)
{
LPWSTR
lpText
=
infoPtr
->
strings
[
btnPtr
->
iString
]
;
LPWSTR
lpText
=
TOOLBAR_GetText
(
infoPtr
,
btnPtr
)
;
/* first get size of all the text */
GetTextExtentPoint32W
(
hdc
,
lpText
,
strlenW
(
lpText
),
lpSize
);
...
...
@@ -2154,7 +2153,7 @@ TOOLBAR_AddStringA (HWND hwnd, WPARAM wParam, LPARAM lParam)
if
((
wParam
)
&&
(
HIWORD
(
lParam
)
==
0
))
{
char
szString
[
256
];
INT
len
,
lenW
;
INT
len
;
TRACE
(
"adding string from resource!
\n
"
);
len
=
LoadStringA
((
HINSTANCE
)
wParam
,
(
UINT
)
lParam
,
...
...
@@ -2175,15 +2174,13 @@ TOOLBAR_AddStringA (HWND hwnd, WPARAM wParam, LPARAM lParam)
COMCTL32_Free
(
oldStrings
);
}
lenW
=
MultiByteToWideChar
(
CP_ACP
,
0
,
szString
,
-
1
,
NULL
,
0
);
infoPtr
->
strings
[
infoPtr
->
nNumStrings
]
=
COMCTL32_Alloc
(
sizeof
(
WCHAR
)
*
lenW
);
MultiByteToWideChar
(
CP_ACP
,
0
,
szString
,
-
1
,
infoPtr
->
strings
[
infoPtr
->
nNumStrings
],
lenW
);
/*COMCTL32_Alloc zeros out the allocated memory*/
Str_SetPtrAtoW
(
&
infoPtr
->
strings
[
infoPtr
->
nNumStrings
],
szString
);
infoPtr
->
nNumStrings
++
;
}
else
{
LPSTR
p
=
(
LPSTR
)
lParam
;
INT
len
,
lenW
;
INT
len
;
if
(
p
==
NULL
)
return
-
1
;
...
...
@@ -2207,10 +2204,7 @@ TOOLBAR_AddStringA (HWND hwnd, WPARAM wParam, LPARAM lParam)
COMCTL32_Free
(
oldStrings
);
}
lenW
=
MultiByteToWideChar
(
CP_ACP
,
0
,
p
,
-
1
,
NULL
,
0
);
infoPtr
->
strings
[
infoPtr
->
nNumStrings
]
=
COMCTL32_Alloc
(
sizeof
(
WCHAR
)
*
lenW
);
MultiByteToWideChar
(
CP_ACP
,
0
,
p
,
-
1
,
infoPtr
->
strings
[
infoPtr
->
nNumStrings
],
lenW
);
Str_SetPtrAtoW
(
&
infoPtr
->
strings
[
infoPtr
->
nNumStrings
],
p
);
infoPtr
->
nNumStrings
++
;
p
+=
(
len
+
1
);
...
...
@@ -2284,9 +2278,7 @@ TOOLBAR_AddStringW (HWND hwnd, WPARAM wParam, LPARAM lParam)
COMCTL32_Free
(
oldStrings
);
}
infoPtr
->
strings
[
infoPtr
->
nNumStrings
]
=
COMCTL32_Alloc
(
sizeof
(
WCHAR
)
*
(
len
+
1
));
strcpyW
(
infoPtr
->
strings
[
infoPtr
->
nNumStrings
],
szString
);
Str_SetPtrW
(
&
infoPtr
->
strings
[
infoPtr
->
nNumStrings
],
szString
);
infoPtr
->
nNumStrings
++
;
}
}
...
...
@@ -2315,9 +2307,7 @@ TOOLBAR_AddStringW (HWND hwnd, WPARAM wParam, LPARAM lParam)
COMCTL32_Free
(
oldStrings
);
}
infoPtr
->
strings
[
infoPtr
->
nNumStrings
]
=
COMCTL32_Alloc
(
sizeof
(
WCHAR
)
*
(
len
+
1
));
strcpyW
(
infoPtr
->
strings
[
infoPtr
->
nNumStrings
],
p
);
Str_SetPtrW
(
&
infoPtr
->
strings
[
infoPtr
->
nNumStrings
],
p
);
infoPtr
->
nNumStrings
++
;
p
+=
(
len
+
1
);
...
...
@@ -2723,14 +2713,9 @@ TOOLBAR_GetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
if
(
lpTbInfo
->
dwMask
&
TBIF_STYLE
)
lpTbInfo
->
fsStyle
=
btnPtr
->
fsStyle
;
if
(
lpTbInfo
->
dwMask
&
TBIF_TEXT
)
{
if
((
btnPtr
->
iString
>=
0
)
&&
(
btnPtr
->
iString
<
infoPtr
->
nNumStrings
))
{
if
(
!
WideCharToMultiByte
(
CP_ACP
,
0
,
(
LPWSTR
)
infoPtr
->
strings
[
btnPtr
->
iString
],
-
1
,
lpTbInfo
->
pszText
,
lpTbInfo
->
cchText
,
NULL
,
NULL
))
lpTbInfo
->
pszText
[
lpTbInfo
->
cchText
-
1
]
=
0
;
LPWSTR
lpText
=
TOOLBAR_GetText
(
infoPtr
,
btnPtr
);
Str_GetPtrWtoA
(
lpText
,
lpTbInfo
->
pszText
,
lpTbInfo
->
cchText
);
}
else
lpTbInfo
->
pszText
[
0
]
=
0
;
}
return
nIndex
;
}
...
...
@@ -2770,10 +2755,8 @@ TOOLBAR_GetButtonInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
if
(
lpTbInfo
->
dwMask
&
TBIF_STYLE
)
lpTbInfo
->
fsStyle
=
btnPtr
->
fsStyle
;
if
(
lpTbInfo
->
dwMask
&
TBIF_TEXT
)
{
if
((
btnPtr
->
iString
>=
0
)
||
(
btnPtr
->
iString
<
infoPtr
->
nNumStrings
))
lstrcpynW
(
lpTbInfo
->
pszText
,
(
LPWSTR
)
infoPtr
->
strings
[
btnPtr
->
iString
],
lpTbInfo
->
cchText
);
LPWSTR
lpText
=
TOOLBAR_GetText
(
infoPtr
,
btnPtr
);
Str_GetPtrW
(
lpText
,
lpTbInfo
->
pszText
,
lpTbInfo
->
cchText
);
}
return
nIndex
;
...
...
@@ -2797,23 +2780,19 @@ static LRESULT
TOOLBAR_GetButtonTextA
(
HWND
hwnd
,
WPARAM
wParam
,
LPARAM
lParam
)
{
TOOLBAR_INFO
*
infoPtr
=
TOOLBAR_GetInfoPtr
(
hwnd
);
INT
nIndex
,
nStringIndex
;
INT
nIndex
;
LPWSTR
lpText
;
nIndex
=
TOOLBAR_GetButtonIndex
(
infoPtr
,
(
INT
)
wParam
,
FALSE
);
if
(
nIndex
==
-
1
)
if
(
lParam
==
0
)
return
-
1
;
nStringIndex
=
infoPtr
->
buttons
[
nIndex
].
iString
;
TRACE
(
"index=%d stringIndex=%d
\n
"
,
nIndex
,
nStringIndex
);
if
((
nStringIndex
<
0
)
||
(
nStringIndex
>=
infoPtr
->
nNumStrings
))
nIndex
=
TOOLBAR_GetButtonIndex
(
infoPtr
,
(
INT
)
wParam
,
FALSE
);
if
(
nIndex
==
-
1
)
return
-
1
;
if
(
lParam
==
0
)
return
-
1
;
lpText
=
TOOLBAR_GetText
(
infoPtr
,
&
infoPtr
->
buttons
[
nIndex
]);
return
WideCharToMultiByte
(
CP_ACP
,
0
,
(
LPWSTR
)
infoPtr
->
strings
[
nStringInd
ex
]
,
-
1
,
return
WideCharToMultiByte
(
CP_ACP
,
0
,
lpT
ex
t
,
-
1
,
(
LPSTR
)
lParam
,
0x7fffffff
,
NULL
,
NULL
)
-
1
;
}
...
...
@@ -2822,25 +2801,21 @@ static LRESULT
TOOLBAR_GetButtonTextW
(
HWND
hwnd
,
WPARAM
wParam
,
LPARAM
lParam
)
{
TOOLBAR_INFO
*
infoPtr
=
TOOLBAR_GetInfoPtr
(
hwnd
);
INT
nIndex
,
nStringIndex
;
INT
nIndex
;
LPWSTR
lpText
;
nIndex
=
TOOLBAR_GetButtonIndex
(
infoPtr
,
(
INT
)
wParam
,
FALSE
);
if
(
nIndex
==
-
1
)
if
(
lParam
==
0
)
return
-
1
;
nStringIndex
=
infoPtr
->
buttons
[
nIndex
].
iString
;
TRACE
(
"index=%d stringIndex=%d
\n
"
,
nIndex
,
nStringIndex
);
if
((
nStringIndex
<
0
)
||
(
nStringIndex
>=
infoPtr
->
nNumStrings
))
nIndex
=
TOOLBAR_GetButtonIndex
(
infoPtr
,
(
INT
)
wParam
,
FALSE
);
if
(
nIndex
==
-
1
)
return
-
1
;
if
(
lParam
==
0
)
return
-
1
;
lpText
=
TOOLBAR_GetText
(
infoPtr
,
&
infoPtr
->
buttons
[
nIndex
]);
strcpyW
((
LPWSTR
)
lParam
,
(
LPWSTR
)
infoPtr
->
strings
[
nStringInd
ex
]
);
strcpyW
((
LPWSTR
)
lParam
,
lpT
ex
t
);
return
strlenW
(
(
LPWSTR
)
infoPtr
->
strings
[
nStringInd
ex
]
);
return
strlenW
(
lpT
ex
t
);
}
...
...
@@ -3163,26 +3138,18 @@ TOOLBAR_InsertButtonA (HWND hwnd, WPARAM wParam, LPARAM lParam)
nIndex
*
sizeof
(
TBUTTON_INFO
));
}
/* if passed string and not index, then add string */
if
(
HIWORD
(
lpTbb
->
iString
)
&&
lpTbb
->
iString
!=-
1
)
{
int
len
;
LPSTR
ptr
;
len
=
strlen
((
char
*
)
lpTbb
->
iString
)
+
2
;
ptr
=
COMCTL32_Alloc
(
len
*
sizeof
(
char
));
strcpy
(
ptr
,
(
char
*
)
lpTbb
->
iString
);
ptr
[
len
-
1
]
=
0
;
/* ended by two '\0' */
lpTbb
->
iString
=
TOOLBAR_AddStringA
(
hwnd
,
0
,
(
LPARAM
)
ptr
);
COMCTL32_Free
(
ptr
);
}
/* insert new button */
infoPtr
->
buttons
[
nIndex
].
iBitmap
=
lpTbb
->
iBitmap
;
infoPtr
->
buttons
[
nIndex
].
idCommand
=
lpTbb
->
idCommand
;
infoPtr
->
buttons
[
nIndex
].
fsState
=
lpTbb
->
fsState
;
infoPtr
->
buttons
[
nIndex
].
fsStyle
=
lpTbb
->
fsStyle
;
infoPtr
->
buttons
[
nIndex
].
dwData
=
lpTbb
->
dwData
;
infoPtr
->
buttons
[
nIndex
].
iString
=
lpTbb
->
iString
;
/* if passed string and not index, then add string */
if
(
HIWORD
(
lpTbb
->
iString
)
&&
lpTbb
->
iString
!=-
1
)
{
Str_SetPtrAtoW
((
LPWSTR
*
)
&
infoPtr
->
buttons
[
nIndex
].
iString
,
(
LPCSTR
)
lpTbb
->
iString
);
}
else
infoPtr
->
buttons
[
nIndex
].
iString
=
lpTbb
->
iString
;
if
((
infoPtr
->
hwndToolTip
)
&&
!
(
lpTbb
->
fsStyle
&
TBSTYLE_SEP
))
{
TTTOOLINFOA
ti
;
...
...
@@ -3242,18 +3209,6 @@ TOOLBAR_InsertButtonW (HWND hwnd, WPARAM wParam, LPARAM lParam)
nIndex
*
sizeof
(
TBUTTON_INFO
));
}
/* if passed string and not index, then add string */
if
(
HIWORD
(
lpTbb
->
iString
)
&&
lpTbb
->
iString
!=-
1
)
{
int
len
;
LPWSTR
ptr
;
len
=
strlenW
((
WCHAR
*
)
lpTbb
->
iString
)
+
2
;
ptr
=
COMCTL32_Alloc
(
len
*
sizeof
(
WCHAR
));
strcpyW
(
ptr
,
(
WCHAR
*
)
lpTbb
->
iString
);
ptr
[
len
-
1
]
=
0
;
/* ended by two '\0' */
lpTbb
->
iString
=
TOOLBAR_AddStringW
(
hwnd
,
0
,
(
LPARAM
)
ptr
);
COMCTL32_Free
(
ptr
);
}
/* insert new button */
infoPtr
->
buttons
[
nIndex
].
iBitmap
=
lpTbb
->
iBitmap
;
...
...
@@ -3261,7 +3216,12 @@ TOOLBAR_InsertButtonW (HWND hwnd, WPARAM wParam, LPARAM lParam)
infoPtr
->
buttons
[
nIndex
].
fsState
=
lpTbb
->
fsState
;
infoPtr
->
buttons
[
nIndex
].
fsStyle
=
lpTbb
->
fsStyle
;
infoPtr
->
buttons
[
nIndex
].
dwData
=
lpTbb
->
dwData
;
infoPtr
->
buttons
[
nIndex
].
iString
=
lpTbb
->
iString
;
/* if passed string and not index, then add string */
if
(
HIWORD
(
lpTbb
->
iString
)
&&
lpTbb
->
iString
!=-
1
)
{
Str_SetPtrW
((
LPWSTR
*
)
&
infoPtr
->
buttons
[
nIndex
].
iString
,
(
LPWSTR
)
lpTbb
->
iString
);
}
else
infoPtr
->
buttons
[
nIndex
].
iString
=
lpTbb
->
iString
;
if
((
infoPtr
->
hwndToolTip
)
&&
!
(
lpTbb
->
fsStyle
&
TBSTYLE_SEP
))
{
TTTOOLINFOW
ti
;
...
...
@@ -3542,21 +3502,13 @@ TOOLBAR_SetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
if
(
lptbbi
->
dwMask
&
TBIF_STYLE
)
btnPtr
->
fsStyle
=
lptbbi
->
fsStyle
;
if
(
lptbbi
->
dwMask
&
TBIF_TEXT
)
{
if
((
btnPtr
->
iString
>=
0
)
||
(
btnPtr
->
iString
<
infoPtr
->
nNumStrings
))
{
TRACE
(
"Ooooooch
\n
"
);
#if 0
WCHAR **lpString = &infoPtr->strings[btnPtr->iString];
INT len = lstrlenA (lptbbi->pszText);
*lpString = COMCTL32_ReAlloc (lpString, sizeof(WCHAR)*(len+1));
#endif
/* this is the ultimate sollution */
/* Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */
}
if
((
lptbbi
->
dwMask
&
TBIF_TEXT
)
&&
((
INT
)
lptbbi
->
pszText
!=
-
1
))
{
if
((
HIWORD
(
btnPtr
->
iString
)
==
0
)
||
(
btnPtr
->
iString
==
-
1
))
/* iString is index, zero it to make Str_SetPtr succeed */
btnPtr
->
iString
=
0
;
Str_SetPtrAtoW
((
LPWSTR
*
)
&
btnPtr
->
iString
,
lptbbi
->
pszText
);
}
return
TRUE
;
}
...
...
@@ -3593,20 +3545,12 @@ TOOLBAR_SetButtonInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
if
(
lptbbi
->
dwMask
&
TBIF_STYLE
)
btnPtr
->
fsStyle
=
lptbbi
->
fsStyle
;
if
(
lptbbi
->
dwMask
&
TBIF_TEXT
)
{
if
((
btnPtr
->
iString
>=
0
)
||
(
btnPtr
->
iString
<
infoPtr
->
nNumStrings
))
{
#if 0
WCHAR **lpString = &infoPtr->strings[btnPtr->iString];
INT len = lstrlenW (lptbbi->pszText);
*lpString = COMCTL32_ReAlloc (lpString, sizeof(WCHAR)*(len+1));
#endif
/* this is the ultimate solution */
/* Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */
}
if
((
lptbbi
->
dwMask
&
TBIF_TEXT
)
&&
((
INT
)
lptbbi
->
pszText
!=
-
1
))
{
if
((
HIWORD
(
btnPtr
->
iString
)
==
0
)
||
(
btnPtr
->
iString
==
-
1
))
/* iString is index, zero it to make Str_SetPtr succeed */
btnPtr
->
iString
=
0
;
Str_SetPtrW
((
LPWSTR
*
)
&
btnPtr
->
iString
,
lptbbi
->
pszText
);
}
return
TRUE
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment