Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
3a170a17
Commit
3a170a17
authored
Jun 06, 1999
by
Slava Monich
Committed by
Alexandre Julliard
Jun 06, 1999
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented dialog units -> pixels conversion very close to how it's
actually done by Windows.
parent
aaa83069
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
87 additions
and
27 deletions
+87
-27
dialog.c
windows/dialog.c
+87
-27
No files found.
windows/dialog.c
View file @
3a170a17
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include "winuser.h"
#include "winuser.h"
#include "windowsx.h"
#include "wine/winuser16.h"
#include "wine/winuser16.h"
#include "wine/winbase16.h"
#include "wine/winbase16.h"
#include "dialog.h"
#include "dialog.h"
...
@@ -75,30 +76,97 @@ static WORD xBaseUnit = 0, yBaseUnit = 0;
...
@@ -75,30 +76,97 @@ static WORD xBaseUnit = 0, yBaseUnit = 0;
/***********************************************************************
/***********************************************************************
* DIALOG_GetCharSizeFromDC
*
*
* Calculates the *true* average size of English characters in the
* specified font as oppposed to the one returned by GetTextMetrics.
*/
static
BOOL
DIALOG_GetCharSizeFromDC
(
HDC
hDC
,
HFONT
hFont
,
SIZE
*
pSize
)
{
BOOL
Success
=
FALSE
;
HFONT
hFontPrev
=
0
;
pSize
->
cx
=
xBaseUnit
;
pSize
->
cy
=
yBaseUnit
;
if
(
hDC
)
{
/* select the font */
TEXTMETRICA
tm
;
memset
(
&
tm
,
0
,
sizeof
(
tm
));
if
(
hFont
)
hFontPrev
=
SelectFont
(
hDC
,
hFont
);
if
(
GetTextMetricsA
(
hDC
,
&
tm
))
{
pSize
->
cx
=
tm
.
tmAveCharWidth
;
pSize
->
cy
=
tm
.
tmHeight
;
/* if variable width font */
if
(
tm
.
tmPitchAndFamily
&
TMPF_FIXED_PITCH
)
{
SIZE
total
;
static
const
char
szAvgChars
[
52
]
=
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
;
/* Calculate a true average as opposed to the one returned
* by tmAveCharWidth. This works better when dealing with
* proportional spaced fonts and (more important) that's
* how Microsoft's dialog creation code calculates the size
* of the font
*/
if
(
GetTextExtentPointA
(
hDC
,
szAvgChars
,
sizeof
(
szAvgChars
),
&
total
))
{
/* round up */
pSize
->
cx
=
((
2
*
total
.
cx
/
sizeof
(
szAvgChars
))
+
1
)
/
2
;
Success
=
TRUE
;
}
}
else
{
Success
=
TRUE
;
}
}
/* select the original font */
if
(
hFontPrev
)
SelectFont
(
hDC
,
hFontPrev
);
}
return
(
Success
);
}
/***********************************************************************
* DIALOG_GetCharSize
*
*
* Calculates the *true* average size of English characters in the
* specified font as oppposed to the one returned by GetTextMetrics.
* A convenient variant of DIALOG_GetCharSizeFromDC.
*/
static
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
* DIALOG_Init
*
*
* Initialisation of the dialog manager.
* Initialisation of the dialog manager.
*/
*/
BOOL
DIALOG_Init
(
void
)
BOOL
DIALOG_Init
(
void
)
{
{
TEXTMETRIC16
tm
;
HDC16
hdc
;
HDC16
hdc
;
SIZE
size
;
/* Calculate the dialog base units */
/* Calculate the dialog base units */
if
(
!
(
hdc
=
CreateDC16
(
"DISPLAY"
,
NULL
,
NULL
,
NULL
)))
return
FALSE
;
if
(
!
(
hdc
=
CreateDC16
(
"DISPLAY"
,
NULL
,
NULL
,
NULL
)))
return
FALSE
;
GetTextMetrics16
(
hdc
,
&
tm
)
;
if
(
!
DIALOG_GetCharSizeFromDC
(
hdc
,
0
,
&
size
))
return
FALSE
;
DeleteDC
(
hdc
);
DeleteDC
(
hdc
);
xBaseUnit
=
tm
.
tmAveCharWidth
;
xBaseUnit
=
size
.
cx
;
yBaseUnit
=
tm
.
tmHeight
;
yBaseUnit
=
size
.
cy
;
/* Dialog units are based on a proportional system font */
/* so we adjust them a bit for a fixed font. */
if
(
!
(
tm
.
tmPitchAndFamily
&
TMPF_FIXED_PITCH
))
xBaseUnit
=
xBaseUnit
*
5
/
4
;
TRACE
(
dialog
,
"base units = %d,%d
\n
"
,
TRACE
(
dialog
,
"base units = %d,%d
\n
"
,
xBaseUnit
,
yBaseUnit
);
xBaseUnit
,
yBaseUnit
);
return
TRUE
;
return
TRUE
;
}
}
...
@@ -597,21 +665,13 @@ HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCSTR dlgTemplate,
...
@@ -597,21 +665,13 @@ HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCSTR dlgTemplate,
FALSE
,
FALSE
,
FALSE
,
DEFAULT_CHARSET
,
0
,
0
,
FALSE
,
FALSE
,
FALSE
,
DEFAULT_CHARSET
,
0
,
0
,
PROOF_QUALITY
,
FF_DONTCARE
,
PROOF_QUALITY
,
FF_DONTCARE
,
template
.
faceName
);
template
.
faceName
);
if
(
hFont
)
if
(
hFont
)
{
{
TEXTMETRIC16
tm
;
SIZE
charSize
;
HFONT16
oldFont
;
DIALOG_GetCharSize
(
hFont
,
&
charSize
);
xUnit
=
charSize
.
cx
;
HDC
hdc
=
GetDC
(
0
);
yUnit
=
charSize
.
cy
;
oldFont
=
SelectObject
(
hdc
,
hFont
);
}
GetTextMetrics16
(
hdc
,
&
tm
);
SelectObject
(
hdc
,
oldFont
);
ReleaseDC
(
0
,
hdc
);
xUnit
=
tm
.
tmAveCharWidth
;
yUnit
=
tm
.
tmHeight
;
if
(
!
(
tm
.
tmPitchAndFamily
&
TMPF_FIXED_PITCH
))
xBaseUnit
=
xBaseUnit
*
5
/
4
;
/* See DIALOG_Init() */
}
}
}
/* Create dialog main window */
/* Create dialog main window */
...
...
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