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
Releases
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
Shaun Ren
wine
Commits
04c1f9f8
Commit
04c1f9f8
authored
21 years ago
by
Alexandre Julliard
Browse files
Options
Downloads
Patches
Plain Diff
Only compute dialog base units once we need them.
parent
c28575e0
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
dlls/user/controls.h
+1
-2
1 addition, 2 deletions
dlls/user/controls.h
dlls/user/dialog16.c
+2
-2
2 additions, 2 deletions
dlls/user/dialog16.c
dlls/user/user_main.c
+0
-3
0 additions, 3 deletions
dlls/user/user_main.c
windows/dialog.c
+22
-59
22 additions, 59 deletions
windows/dialog.c
with
25 additions
and
66 deletions
dlls/user/controls.h
+
1
−
2
View file @
04c1f9f8
...
...
@@ -138,8 +138,7 @@ inline static DIALOGINFO *DIALOG_get_info( HWND hwnd )
return
(
DIALOGINFO
*
)
GetWindowLongW
(
hwnd
,
DWL_WINE_DIALOGINFO
);
}
extern
BOOL
DIALOG_Init
(
void
);
extern
BOOL
DIALOG_GetCharSize
(
HFONT
hFont
,
SIZE
*
pSize
);
extern
BOOL
DIALOG_GetCharSize
(
HDC
hdc
,
HFONT
hFont
,
SIZE
*
pSize
);
extern
void
DIALOG_EnableOwner
(
HWND
hOwner
);
extern
BOOL
DIALOG_DisableOwner
(
HWND
hOwner
);
extern
INT
DIALOG_DoDialogBox
(
HWND
hwnd
,
HWND
owner
);
...
...
This diff is collapsed.
Click to expand it.
dlls/user/dialog16.c
+
2
−
2
View file @
04c1f9f8
...
...
@@ -324,19 +324,19 @@ static HWND DIALOG_CreateIndirect16( HINSTANCE16 hInst, LPCVOID dlgTemplate,
int
pixels
;
dc
=
GetDC
(
0
);
pixels
=
MulDiv
(
template
.
pointSize
,
GetDeviceCaps
(
dc
,
LOGPIXELSY
),
72
);
ReleaseDC
(
0
,
dc
);
dlgInfo
->
hUserFont
=
CreateFontA
(
-
pixels
,
0
,
0
,
0
,
FW_DONTCARE
,
FALSE
,
FALSE
,
FALSE
,
DEFAULT_CHARSET
,
0
,
0
,
PROOF_QUALITY
,
FF_DONTCARE
,
template
.
faceName
);
if
(
dlgInfo
->
hUserFont
)
{
SIZE
charSize
;
if
(
DIALOG_GetCharSize
(
dlgInfo
->
hUserFont
,
&
charSize
))
if
(
DIALOG_GetCharSize
(
dc
,
dlgInfo
->
hUserFont
,
&
charSize
))
{
dlgInfo
->
xBaseUnit
=
charSize
.
cx
;
dlgInfo
->
yBaseUnit
=
charSize
.
cy
;
}
}
ReleaseDC
(
0
,
dc
);
TRACE
(
"units = %d,%d
\n
"
,
dlgInfo
->
xBaseUnit
,
dlgInfo
->
yBaseUnit
);
}
...
...
This diff is collapsed.
Click to expand it.
dlls/user/user_main.c
+
0
−
3
View file @
04c1f9f8
...
...
@@ -243,9 +243,6 @@ static BOOL process_attach(void)
/* Initialize built-in window classes */
controls_init
();
/* Initialize dialog manager */
if
(
!
DIALOG_Init
())
return
FALSE
;
/* Initialize menus */
if
(
!
MENU_Init
())
return
FALSE
;
...
...
This diff is collapsed.
Click to expand it.
windows/dialog.c
+
22
−
59
View file @
04c1f9f8
...
...
@@ -89,9 +89,6 @@ typedef struct
UINT
checkID
;
}
RADIOGROUP
;
/* Dialog base units */
static
WORD
xBaseUnit
=
0
,
yBaseUnit
=
0
;
/*********************************************************************
* dialog class descriptor
...
...
@@ -146,7 +143,7 @@ BOOL DIALOG_DisableOwner( HWND hOwner )
}
/***********************************************************************
* DIALOG_GetCharSize
FromDC
* DIALOG_GetCharSize
*
* Despite most of MSDN insisting that the horizontal base unit is
* tmAveCharWidth it isn't. Knowledge base article Q145994
...
...
@@ -154,16 +151,13 @@ BOOL DIALOG_DisableOwner( HWND hOwner )
* says that we should take the average of the 52 English upper and lower
* case characters.
*/
static
BOOL
DIALOG_GetCharSize
FromDC
(
HDC
hDC
,
HFONT
hFont
,
SIZE
*
pSize
)
BOOL
DIALOG_GetCharSize
(
HDC
hDC
,
HFONT
hFont
,
SIZE
*
pSize
)
{
HFONT
hFontPrev
=
0
;
char
*
alphabet
=
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
;
SIZE
sz
;
TEXTMETRICA
tm
;
pSize
->
cx
=
xBaseUnit
;
pSize
->
cy
=
yBaseUnit
;
if
(
!
hDC
)
return
FALSE
;
if
(
hFont
)
hFontPrev
=
SelectObject
(
hDC
,
hFont
);
...
...
@@ -179,52 +173,6 @@ static BOOL DIALOG_GetCharSizeFromDC( HDC hDC, HFONT hFont, SIZE * pSize )
return
TRUE
;
}
/***********************************************************************
* DIALOG_GetCharSize
*
* A convenient variant of DIALOG_GetCharSizeFromDC.
*/
BOOL
DIALOG_GetCharSize
(
HFONT
hFont
,
SIZE
*
pSize
)
{
HDC
hDC
=
GetDC
(
0
);
BOOL
Success
=
DIALOG_GetCharSizeFromDC
(
hDC
,
hFont
,
pSize
);
ReleaseDC
(
0
,
hDC
);
return
Success
;
}
/***********************************************************************
* DIALOG_Init
*
* Initialisation of the dialog manager.
*/
BOOL
DIALOG_Init
(
void
)
{
HDC
hdc
;
SIZE
size
;
/* Calculate the dialog base units */
if
(
!
(
hdc
=
CreateDCA
(
"DISPLAY"
,
NULL
,
NULL
,
NULL
)))
{
ERR
(
"Could not create Display DC
\n
"
);
return
FALSE
;
}
if
(
!
DIALOG_GetCharSizeFromDC
(
hdc
,
0
,
&
size
))
{
DeleteDC
(
hdc
);
ERR
(
"Could not initialize base dialog units
\n
"
);
return
FALSE
;
}
DeleteDC
(
hdc
);
xBaseUnit
=
size
.
cx
;
yBaseUnit
=
size
.
cy
;
TRACE
(
"base units = %d,%d
\n
"
,
xBaseUnit
,
yBaseUnit
);
return
TRUE
;
}
/***********************************************************************
* DIALOG_GetControl32
...
...
@@ -545,6 +493,7 @@ static HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCVOID dlgTemplate,
WND
*
wndPtr
;
DLG_TEMPLATE
template
;
DIALOGINFO
*
dlgInfo
;
DWORD
units
=
GetDialogBaseUnits
();
BOOL
ownerEnabled
=
TRUE
;
/* Parse dialog template */
...
...
@@ -558,8 +507,8 @@ static HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCVOID dlgTemplate,
dlgInfo
->
hwndFocus
=
0
;
dlgInfo
->
hUserFont
=
0
;
dlgInfo
->
hMenu
=
0
;
dlgInfo
->
xBaseUnit
=
xBaseU
nit
;
dlgInfo
->
yBaseUnit
=
yBaseU
nit
;
dlgInfo
->
xBaseUnit
=
LOWORD
(
u
nit
s
)
;
dlgInfo
->
yBaseUnit
=
HIWORD
(
u
nit
s
)
;
dlgInfo
->
idResult
=
0
;
dlgInfo
->
flags
=
0
;
dlgInfo
->
hDialogHeap
=
0
;
...
...
@@ -578,7 +527,6 @@ static HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCVOID dlgTemplate,
int
pixels
;
dc
=
GetDC
(
0
);
pixels
=
MulDiv
(
template
.
pointSize
,
GetDeviceCaps
(
dc
,
LOGPIXELSY
),
72
);
ReleaseDC
(
0
,
dc
);
dlgInfo
->
hUserFont
=
CreateFontW
(
-
pixels
,
0
,
0
,
0
,
template
.
weight
,
template
.
italic
,
FALSE
,
FALSE
,
DEFAULT_CHARSET
,
0
,
0
,
PROOF_QUALITY
,
FF_DONTCARE
,
...
...
@@ -586,12 +534,13 @@ static HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCVOID dlgTemplate,
if
(
dlgInfo
->
hUserFont
)
{
SIZE
charSize
;
if
(
DIALOG_GetCharSize
(
dlgInfo
->
hUserFont
,
&
charSize
))
if
(
DIALOG_GetCharSize
(
dc
,
dlgInfo
->
hUserFont
,
&
charSize
))
{
dlgInfo
->
xBaseUnit
=
charSize
.
cx
;
dlgInfo
->
yBaseUnit
=
charSize
.
cy
;
}
}
ReleaseDC
(
0
,
dc
);
TRACE
(
"units = %d,%d
\n
"
,
dlgInfo
->
xBaseUnit
,
dlgInfo
->
yBaseUnit
);
}
...
...
@@ -1358,7 +1307,21 @@ BOOL WINAPI CheckRadioButton( HWND hwndDlg, UINT firstID,
*/
DWORD
WINAPI
GetDialogBaseUnits
(
void
)
{
return
MAKELONG
(
xBaseUnit
,
yBaseUnit
);
static
DWORD
units
;
if
(
!
units
)
{
HDC
hdc
;
SIZE
size
;
if
((
hdc
=
GetDC
(
0
)))
{
if
(
DIALOG_GetCharSize
(
hdc
,
0
,
&
size
))
units
=
MAKELONG
(
size
.
cx
,
size
.
cy
);
ReleaseDC
(
0
,
hdc
);
}
TRACE
(
"base units = %d,%d
\n
"
,
LOWORD
(
units
),
HIWORD
(
units
)
);
}
return
units
;
}
...
...
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