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
78f9fae7
Commit
78f9fae7
authored
Aug 17, 2001
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create GDI stock objects as normal objects instead of using magic
handle values.
parent
e811f9c3
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
160 additions
and
310 deletions
+160
-310
font.c
dlls/wineps/font.c
+7
-1
objects.c
graphics/enhmetafiledrv/objects.c
+28
-34
xfont.c
graphics/x11drv/xfont.c
+6
-1
gdi.h
include/gdi.h
+4
-35
dc.c
objects/dc.c
+1
-1
gdiobj.c
objects/gdiobj.c
+114
-235
syscolor.c
windows/syscolor.c
+0
-3
No files found.
dlls/wineps/font.c
View file @
78f9fae7
...
...
@@ -18,9 +18,15 @@ DEFAULT_DEBUG_CHANNEL(psdrv);
*/
inline
static
BOOL
is_stock_font
(
HFONT
font
)
{
return
(
font
>=
FIRST_STOCK_FONT
&&
font
<=
LAST_STOCK_FONT
);
int
i
;
for
(
i
=
OEM_FIXED_FONT
;
i
<=
DEFAULT_GUI_FONT
;
i
++
)
{
if
(
i
!=
DEFAULT_PALETTE
&&
font
==
GetStockObject
(
i
))
return
TRUE
;
}
return
FALSE
;
}
/*******************************************************************************
* ScaleFont
*
...
...
graphics/enhmetafiledrv/objects.c
View file @
78f9fae7
...
...
@@ -101,25 +101,24 @@ static HBRUSH EMFDRV_BRUSH_SelectObject(DC *dc, HBRUSH hBrush )
EMRSELECTOBJECT
emr
;
DWORD
index
;
HBRUSH
hOldBrush
;
int
i
;
/* If the object is a stock brush object, do not need to create it.
* See definitions in wingdi.h for range of stock brushes.
* We do however have to handle setting the higher order bit to
* designate that this is a stock object.
*/
if
(
hBrush
>=
FIRST_STOCK_HANDLE
&&
hBrush
<=
FIRST_STOCK_HANDLE
+
HOLLOW_BRUSH
)
{
DWORD
brush_index
=
hBrush
-
FIRST_STOCK_HANDLE
;
index
=
brush_index
|
0x80000000
;
}
else
for
(
i
=
WHITE_BRUSH
;
i
<=
NULL_BRUSH
;
i
++
)
{
index
=
EMFDRV_CreateBrushIndirect
(
dc
,
hBrush
);
if
(
hBrush
==
GetStockObject
(
i
))
{
index
=
i
|
0x80000000
;
goto
found
;
}
}
if
(
!
index
)
return
FALSE
;
if
(
!
(
index
=
EMFDRV_CreateBrushIndirect
(
dc
,
hBrush
)))
return
0
;
found:
emr
.
emr
.
iType
=
EMR_SELECTOBJECT
;
emr
.
emr
.
nSize
=
sizeof
(
emr
);
emr
.
ihObject
=
index
;
...
...
@@ -180,6 +179,7 @@ static HFONT EMFDRV_FONT_SelectObject( DC * dc, HFONT hFont )
EMRSELECTOBJECT
emr
;
DWORD
index
;
HFONT
hOldFont
;
int
i
;
/* If the object is a stock font object, do not need to create it.
* See definitions in wingdi.h for range of stock fonts.
...
...
@@ -187,20 +187,16 @@ static HFONT EMFDRV_FONT_SelectObject( DC * dc, HFONT hFont )
* designate that this is a stock object.
*/
if
(
hFont
>=
STOCK_OEM_FIXED_FONT
&&
hFont
<=
STOCK_DEFAULT_GUI_FONT
&&
hFont
!=
STOCK_DEFAULT_PALETTE
)
for
(
i
=
OEM_FIXED_FONT
;
i
<=
DEFAULT_GUI_FONT
;
i
++
)
{
DWORD
font_index
=
hFont
-
FIRST_STOCK_HANDLE
;
index
=
font_index
|
0x80000000
;
if
(
i
!=
DEFAULT_PALETTE
&&
hFont
==
GetStockObject
(
i
))
{
index
=
i
|
0x80000000
;
goto
found
;
}
}
else
{
index
=
EMFDRV_CreateFontIndirect
(
dc
,
hFont
);
}
if
(
!
index
)
return
FALSE
;
if
(
!
(
index
=
EMFDRV_CreateFontIndirect
(
dc
,
hFont
)))
return
0
;
found:
emr
.
emr
.
iType
=
EMR_SELECTOBJECT
;
emr
.
emr
.
nSize
=
sizeof
(
emr
);
emr
.
ihObject
=
index
;
...
...
@@ -241,6 +237,7 @@ static HPEN EMFDRV_PEN_SelectObject(DC *dc, HPEN hPen )
EMRSELECTOBJECT
emr
;
DWORD
index
;
HPEN
hOldPen
;
int
i
;
/* If the object is a stock pen object, do not need to create it.
* See definitions in wingdi.h for range of stock pens.
...
...
@@ -248,19 +245,16 @@ static HPEN EMFDRV_PEN_SelectObject(DC *dc, HPEN hPen )
* designate that this is a stock object.
*/
if
(
hPen
>=
STOCK_WHITE_PEN
&&
hPen
<=
STOCK_NULL_PEN
)
for
(
i
=
WHITE_PEN
;
i
<=
NULL_PEN
;
i
++
)
{
DWORD
pen_index
=
hPen
-
FIRST_STOCK_HANDLE
;
index
=
pen_index
|
0x80000000
;
if
(
hPen
==
GetStockObject
(
i
))
{
index
=
i
|
0x80000000
;
goto
found
;
}
}
else
{
index
=
EMFDRV_CreatePenIndirect
(
dc
,
hPen
);
}
if
(
!
index
)
return
FALSE
;
if
(
!
(
index
=
EMFDRV_CreatePenIndirect
(
dc
,
hPen
)))
return
0
;
found:
emr
.
emr
.
iType
=
EMR_SELECTOBJECT
;
emr
.
emr
.
nSize
=
sizeof
(
emr
);
emr
.
ihObject
=
index
;
...
...
graphics/x11drv/xfont.c
View file @
78f9fae7
...
...
@@ -350,7 +350,12 @@ static Atom RAW_DESCENT;
*/
inline
static
BOOL
is_stock_font
(
HFONT
font
)
{
return
(
font
>=
FIRST_STOCK_FONT
&&
font
<=
LAST_STOCK_FONT
);
int
i
;
for
(
i
=
OEM_FIXED_FONT
;
i
<=
DEFAULT_GUI_FONT
;
i
++
)
{
if
(
i
!=
DEFAULT_PALETTE
&&
font
==
GetStockObject
(
i
))
return
TRUE
;
}
return
FALSE
;
}
...
...
include/gdi.h
View file @
78f9fae7
...
...
@@ -246,41 +246,10 @@ typedef struct tagDC_FUNCS
#define DC_DIRTY 0x0004
/* hVisRgn has to be updated */
#define DC_THUNKHOOK 0x0008
/* DC hook is in the 16-bit code */
/* Last 32 bytes are reserved for stock object handles */
#define GDI_HEAP_SIZE 0xffe0
/* First handle possible for stock objects (must be >= GDI_HEAP_SIZE) */
#define FIRST_STOCK_HANDLE GDI_HEAP_SIZE
/* Stock objects handles */
#define NB_STOCK_OBJECTS (DEFAULT_GUI_FONT + 1)
#define STOCK_WHITE_BRUSH ((HBRUSH16)(FIRST_STOCK_HANDLE+WHITE_BRUSH))
#define STOCK_LTGRAY_BRUSH ((HBRUSH16)(FIRST_STOCK_HANDLE+LTGRAY_BRUSH))
#define STOCK_GRAY_BRUSH ((HBRUSH16)(FIRST_STOCK_HANDLE+GRAY_BRUSH))
#define STOCK_DKGRAY_BRUSH ((HBRUSH16)(FIRST_STOCK_HANDLE+DKGRAY_BRUSH))
#define STOCK_BLACK_BRUSH ((HBRUSH16)(FIRST_STOCK_HANDLE+BLACK_BRUSH))
#define STOCK_NULL_BRUSH ((HBRUSH16)(FIRST_STOCK_HANDLE+NULL_BRUSH))
#define STOCK_HOLLOW_BRUSH ((HBRUSH16)(FIRST_STOCK_HANDLE+HOLLOW_BRUSH))
#define STOCK_WHITE_PEN ((HPEN16)(FIRST_STOCK_HANDLE+WHITE_PEN))
#define STOCK_BLACK_PEN ((HPEN16)(FIRST_STOCK_HANDLE+BLACK_PEN))
#define STOCK_NULL_PEN ((HPEN16)(FIRST_STOCK_HANDLE+NULL_PEN))
#define STOCK_OEM_FIXED_FONT ((HFONT16)(FIRST_STOCK_HANDLE+OEM_FIXED_FONT))
#define STOCK_ANSI_FIXED_FONT ((HFONT16)(FIRST_STOCK_HANDLE+ANSI_FIXED_FONT))
#define STOCK_ANSI_VAR_FONT ((HFONT16)(FIRST_STOCK_HANDLE+ANSI_VAR_FONT))
#define STOCK_SYSTEM_FONT ((HFONT16)(FIRST_STOCK_HANDLE+SYSTEM_FONT))
#define STOCK_DEVICE_DEFAULT_FONT ((HFONT16)(FIRST_STOCK_HANDLE+DEVICE_DEFAULT_FONT))
#define STOCK_DEFAULT_PALETTE ((HPALETTE16)(FIRST_STOCK_HANDLE+DEFAULT_PALETTE))
#define STOCK_SYSTEM_FIXED_FONT ((HFONT16)(FIRST_STOCK_HANDLE+SYSTEM_FIXED_FONT))
#define STOCK_DEFAULT_GUI_FONT ((HFONT16)(FIRST_STOCK_HANDLE+DEFAULT_GUI_FONT))
#define FIRST_STOCK_FONT STOCK_OEM_FIXED_FONT
#define LAST_STOCK_FONT STOCK_DEFAULT_GUI_FONT
#define LAST_STOCK_HANDLE ((DWORD)STOCK_DEFAULT_GUI_FONT)
extern
HBITMAP
hPseudoStockBitmap
;
#define GDI_HEAP_SIZE 0xffe0
/* extra stock object: default 1x1 bitmap for memory DCs */
#define DEFAULT_BITMAP (STOCK_LAST+1)
/* Device <-> logical coords conversion */
...
...
objects/dc.c
View file @
78f9fae7
...
...
@@ -681,7 +681,7 @@ HDC WINAPI CreateCompatibleDC( HDC hdc )
dc
->
flags
=
DC_MEMORY
;
dc
->
bitsPerPixel
=
1
;
dc
->
hBitmap
=
hPseudoStockBitmap
;
dc
->
hBitmap
=
GetStockObject
(
DEFAULT_BITMAP
)
;
/* Copy the driver-specific physical device info into
* the new DC. The driver may use this read-only info
...
...
objects/gdiobj.c
View file @
78f9fae7
...
...
@@ -34,247 +34,116 @@ DEFAULT_DEBUG_CHANNEL(gdi);
* GDI stock objects
*/
static
BRUSHOBJ
WhiteBrush
=
{
{
0
,
BRUSH_MAGIC
,
1
},
/* header */
{
BS_SOLID
,
RGB
(
255
,
255
,
255
),
0
}
/* logbrush */
};
static
BRUSHOBJ
LtGrayBrush
=
{
{
0
,
BRUSH_MAGIC
,
1
},
/* header */
/* FIXME : this should perhaps be BS_HATCHED, at least for 1 bitperpixel */
{
BS_SOLID
,
RGB
(
192
,
192
,
192
),
0
}
/* logbrush */
};
static
const
LOGBRUSH
WhiteBrush
=
{
BS_SOLID
,
RGB
(
255
,
255
,
255
),
0
};
static
const
LOGBRUSH
BlackBrush
=
{
BS_SOLID
,
RGB
(
0
,
0
,
0
),
0
};
static
const
LOGBRUSH
NullBrush
=
{
BS_NULL
,
0
,
0
};
static
BRUSHOBJ
GrayBrush
=
{
{
0
,
BRUSH_MAGIC
,
1
},
/* header */
/* FIXME : this should perhaps be BS_HATCHED, at least for 1 bitperpixel */
{
BS_SOLID
,
RGB
(
128
,
128
,
128
),
0
}
/* logbrush */
};
/* FIXME: these should perhaps be BS_HATCHED, at least for 1 bitperpixel */
static
const
LOGBRUSH
LtGrayBrush
=
{
BS_SOLID
,
RGB
(
192
,
192
,
192
),
0
};
static
const
LOGBRUSH
GrayBrush
=
{
BS_SOLID
,
RGB
(
128
,
128
,
128
),
0
};
static
BRUSHOBJ
DkGrayBrush
=
{
{
0
,
BRUSH_MAGIC
,
1
},
/* header */
/* This is BS_HATCHED, for 1 bitperpixel. This makes the spray work in pbrush */
/* NB_HATCH_STYLES is an index into HatchBrushes */
{
BS_HATCHED
,
RGB
(
0
,
0
,
0
),
NB_HATCH_STYLES
}
/* logbrush */
};
static
BRUSHOBJ
BlackBrush
=
{
{
0
,
BRUSH_MAGIC
,
1
},
/* header */
{
BS_SOLID
,
RGB
(
0
,
0
,
0
),
0
}
/* logbrush */
};
static
const
LOGBRUSH
DkGrayBrush
=
{
BS_HATCHED
,
RGB
(
0
,
0
,
0
),
NB_HATCH_STYLES
};
static
BRUSHOBJ
NullBrush
=
{
{
0
,
BRUSH_MAGIC
,
1
},
/* header */
{
BS_NULL
,
0
,
0
}
/* logbrush */
};
static
PENOBJ
WhitePen
=
{
{
0
,
PEN_MAGIC
,
1
},
/* header */
{
PS_SOLID
,
{
0
,
0
},
RGB
(
255
,
255
,
255
)
}
/* logpen */
};
static
PENOBJ
BlackPen
=
{
{
0
,
PEN_MAGIC
,
1
},
/* header */
{
PS_SOLID
,
{
0
,
0
},
RGB
(
0
,
0
,
0
)
}
/* logpen */
};
static
PENOBJ
NullPen
=
{
{
0
,
PEN_MAGIC
,
1
},
/* header */
{
PS_NULL
,
{
0
,
0
},
0
}
/* logpen */
};
static
const
LOGPEN
WhitePen
=
{
PS_SOLID
,
{
0
,
0
},
RGB
(
255
,
255
,
255
)
};
static
const
LOGPEN
BlackPen
=
{
PS_SOLID
,
{
0
,
0
},
RGB
(
0
,
0
,
0
)
};
static
const
LOGPEN
NullPen
=
{
PS_NULL
,
{
0
,
0
},
0
};
static
FONTOBJ
OEMFixedFont
=
{
{
0
,
FONT_MAGIC
,
1
},
/* header */
{
0
,
0
,
0
,
0
,
FW_NORMAL
,
FALSE
,
FALSE
,
FALSE
,
OEM_CHARSET
,
0
,
0
,
DEFAULT_QUALITY
,
FIXED_PITCH
|
FF_MODERN
,
{
'\0'
}
}
};
static
const
LOGFONTW
OEMFixedFont
=
{
12
,
0
,
0
,
0
,
FW_NORMAL
,
FALSE
,
FALSE
,
FALSE
,
OEM_CHARSET
,
0
,
0
,
DEFAULT_QUALITY
,
FIXED_PITCH
|
FF_MODERN
,
{
'\0'
}
};
static
FONTOBJ
AnsiFixedFont
=
{
{
0
,
FONT_MAGIC
,
1
},
/* header */
{
0
,
0
,
0
,
0
,
FW_NORMAL
,
FALSE
,
FALSE
,
FALSE
,
ANSI_CHARSET
,
0
,
0
,
DEFAULT_QUALITY
,
FIXED_PITCH
|
FF_MODERN
,
{
'\0'
}
}
};
static
const
LOGFONTW
AnsiFixedFont
=
{
12
,
0
,
0
,
0
,
FW_NORMAL
,
FALSE
,
FALSE
,
FALSE
,
ANSI_CHARSET
,
0
,
0
,
DEFAULT_QUALITY
,
FIXED_PITCH
|
FF_MODERN
,
{
'\0'
}
};
static
FONTOBJ
AnsiVarFont
=
{
{
0
,
FONT_MAGIC
,
1
},
/* header */
{
0
,
0
,
0
,
0
,
FW_NORMAL
,
FALSE
,
FALSE
,
FALSE
,
ANSI_CHARSET
,
0
,
0
,
DEFAULT_QUALITY
,
VARIABLE_PITCH
|
FF_SWISS
,
{
'M'
,
'S'
,
' '
,
'S'
,
'a'
,
'n'
,
's'
,
' '
,
'S'
,
'e'
,
'r'
,
'i'
,
'f'
,
'\0'
}
}
};
static
const
LOGFONTW
AnsiVarFont
=
{
12
,
0
,
0
,
0
,
FW_NORMAL
,
FALSE
,
FALSE
,
FALSE
,
ANSI_CHARSET
,
0
,
0
,
DEFAULT_QUALITY
,
VARIABLE_PITCH
|
FF_SWISS
,
{
'M'
,
'S'
,
' '
,
'S'
,
'a'
,
'n'
,
's'
,
' '
,
'S'
,
'e'
,
'r'
,
'i'
,
'f'
,
'\0'
}
};
static
FONTOBJ
SystemFont
=
{
{
0
,
FONT_MAGIC
,
1
},
{
0
,
0
,
0
,
0
,
FW_NORMAL
,
FALSE
,
FALSE
,
FALSE
,
ANSI_CHARSET
,
0
,
0
,
DEFAULT_QUALITY
,
VARIABLE_PITCH
|
FF_SWISS
,
{
'S'
,
'y'
,
's'
,
't'
,
'e'
,
'm'
,
'\0'
}
}
};
static
const
LOGFONTW
SystemFont
=
{
16
,
0
,
0
,
0
,
FW_NORMAL
,
FALSE
,
FALSE
,
FALSE
,
ANSI_CHARSET
,
0
,
0
,
DEFAULT_QUALITY
,
VARIABLE_PITCH
|
FF_SWISS
,
{
'S'
,
'y'
,
's'
,
't'
,
'e'
,
'm'
,
'\0'
}
};
static
FONTOBJ
DeviceDefaultFont
=
{
{
0
,
FONT_MAGIC
,
1
},
/* header */
{
0
,
0
,
0
,
0
,
FW_NORMAL
,
FALSE
,
FALSE
,
FALSE
,
ANSI_CHARSET
,
0
,
0
,
DEFAULT_QUALITY
,
VARIABLE_PITCH
|
FF_SWISS
,
{
'\0'
}
}
};
static
const
LOGFONTW
DeviceDefaultFont
=
{
16
,
0
,
0
,
0
,
FW_NORMAL
,
FALSE
,
FALSE
,
FALSE
,
ANSI_CHARSET
,
0
,
0
,
DEFAULT_QUALITY
,
VARIABLE_PITCH
|
FF_SWISS
,
{
'\0'
}
};
static
FONTOBJ
SystemFixedFont
=
{
{
0
,
FONT_MAGIC
,
1
},
/* header */
{
0
,
0
,
0
,
0
,
FW_NORMAL
,
FALSE
,
FALSE
,
FALSE
,
ANSI_CHARSET
,
0
,
0
,
DEFAULT_QUALITY
,
FIXED_PITCH
|
FF_MODERN
,
{
'\0'
}
}
};
static
const
LOGFONTW
SystemFixedFont
=
{
16
,
0
,
0
,
0
,
FW_NORMAL
,
FALSE
,
FALSE
,
FALSE
,
ANSI_CHARSET
,
0
,
0
,
DEFAULT_QUALITY
,
FIXED_PITCH
|
FF_MODERN
,
{
'\0'
}
};
/* FIXME: Is this correct? */
static
FONTOBJ
DefaultGuiFont
=
{
{
0
,
FONT_MAGIC
,
1
},
/* header */
{
0
,
0
,
0
,
0
,
FW_NORMAL
,
FALSE
,
FALSE
,
FALSE
,
ANSI_CHARSET
,
0
,
0
,
DEFAULT_QUALITY
,
VARIABLE_PITCH
|
FF_SWISS
,
{
'M'
,
'S'
,
' '
,
'S'
,
'a'
,
'n'
,
's'
,
' '
,
'S'
,
'e'
,
'r'
,
'i'
,
'f'
,
'\0'
}
}
};
static
const
LOGFONTW
DefaultGuiFont
=
{
-
11
,
0
,
0
,
0
,
FW_NORMAL
,
FALSE
,
FALSE
,
FALSE
,
ANSI_CHARSET
,
0
,
0
,
DEFAULT_QUALITY
,
VARIABLE_PITCH
|
FF_SWISS
,
{
'M'
,
'S'
,
' '
,
'S'
,
'a'
,
'n'
,
's'
,
' '
,
'S'
,
'e'
,
'r'
,
'i'
,
'f'
,
'\0'
}
};
/* reserve one extra entry for the stock default bitmap */
/* this is what Windows does too */
#define NB_STOCK_OBJECTS (STOCK_LAST+2)
static
GDIOBJHDR
*
StockObjects
[
NB_STOCK_OBJECTS
]
=
{
(
GDIOBJHDR
*
)
&
WhiteBrush
,
(
GDIOBJHDR
*
)
&
LtGrayBrush
,
(
GDIOBJHDR
*
)
&
GrayBrush
,
(
GDIOBJHDR
*
)
&
DkGrayBrush
,
(
GDIOBJHDR
*
)
&
BlackBrush
,
(
GDIOBJHDR
*
)
&
NullBrush
,
(
GDIOBJHDR
*
)
&
WhitePen
,
(
GDIOBJHDR
*
)
&
BlackPen
,
(
GDIOBJHDR
*
)
&
NullPen
,
NULL
,
(
GDIOBJHDR
*
)
&
OEMFixedFont
,
(
GDIOBJHDR
*
)
&
AnsiFixedFont
,
(
GDIOBJHDR
*
)
&
AnsiVarFont
,
(
GDIOBJHDR
*
)
&
SystemFont
,
(
GDIOBJHDR
*
)
&
DeviceDefaultFont
,
NULL
,
/* DEFAULT_PALETTE created by PALETTE_Init */
(
GDIOBJHDR
*
)
&
SystemFixedFont
,
(
GDIOBJHDR
*
)
&
DefaultGuiFont
};
HBITMAP
hPseudoStockBitmap
;
/* 1x1 bitmap for memory DCs */
static
HGDIOBJ
stock_objects
[
NB_STOCK_OBJECTS
];
static
SYSLEVEL
GDI_level
=
{
CRITICAL_SECTION_INIT
(
"GDI_level"
),
3
};
static
WORD
GDI_HeapSel
;
static
BOOL
get_bool
(
char
*
buffer
,
BOOL
def_value
)
inline
static
BOOL
get_bool
(
char
*
buffer
)
{
switch
(
buffer
[
0
])
{
case
'n'
:
case
'N'
:
case
'f'
:
case
'F'
:
case
'0'
:
return
FALSE
;
case
'y'
:
case
'Y'
:
case
't'
:
case
'T'
:
case
'1'
:
return
TRUE
;
default:
return
def_value
;
}
return
(
buffer
[
0
]
==
'y'
||
buffer
[
0
]
==
'Y'
||
buffer
[
0
]
==
't'
||
buffer
[
0
]
==
'T'
||
buffer
[
0
]
==
'1'
);
}
/******************************************************************************
*
* void ReadFontInformation(
* char const *fontName,
* FONTOBJ *font,
* int defHeight,
* int defBold,
* int defItalic,
* int defUnderline,
* int defStrikeOut )
*
* ReadFontInformation() checks the Wine configuration file's Tweak.Fonts
* section for entries containing fontName.Height, fontName.Bold, etc.,
* where fontName is the name specified in the call (e.g., "System"). It
* attempts to be user friendly by accepting 'n', 'N', 'f', 'F', or '0' as
* the first character in the boolean attributes (bold, italic, and
* underline).
*****************************************************************************/
static
void
ReadFontInformation
(
char
const
*
fontName
,
FONTOBJ
*
font
,
int
defHeight
,
int
defBold
,
int
defItalic
,
int
defUnderline
,
int
defStrikeOut
)
* create_stock_font
*/
static
HFONT
create_stock_font
(
char
const
*
fontName
,
const
LOGFONTW
*
font
,
HKEY
hkey
)
{
LOGFONTW
lf
;
char
key
[
256
];
char
buffer
[
MAX_PATH
];
HKEY
hkey
;
DWORD
type
,
count
;
/* In order for the stock fonts to be independent of
* mapping mode, the height (& width) must be 0
*/
/* assign defaults */
font
->
logfont
.
lfHeight
=
defHeight
;
font
->
logfont
.
lfWeight
=
defBold
;
font
->
logfont
.
lfItalic
=
defItalic
;
font
->
logfont
.
lfUnderline
=
defUnderline
;
font
->
logfont
.
lfStrikeOut
=
defStrikeOut
;
if
(
RegOpenKeyA
(
HKEY_LOCAL_MACHINE
,
"Software
\\
Wine
\\
Wine
\\
Config
\\
Tweak.Fonts"
,
&
hkey
))
return
;
if
(
!
hkey
)
return
CreateFontIndirectW
(
font
);
lf
=
*
font
;
sprintf
(
key
,
"%s.Height"
,
fontName
);
count
=
sizeof
(
buffer
);
if
(
!
RegQueryValueExA
(
hkey
,
key
,
0
,
&
type
,
buffer
,
&
count
))
font
->
logfont
.
lfHeight
=
atoi
(
buffer
);
lf
.
lfHeight
=
atoi
(
buffer
);
sprintf
(
key
,
"%s.Bold"
,
fontName
);
count
=
sizeof
(
buffer
);
if
(
!
RegQueryValueExA
(
hkey
,
key
,
0
,
&
type
,
buffer
,
&
count
))
font
->
logfont
.
lfWeight
=
get_bool
(
buffer
,
defBold
)
?
FW_BOLD
:
FW_NORMAL
;
lf
.
lfWeight
=
get_bool
(
buffer
)
?
FW_BOLD
:
FW_NORMAL
;
sprintf
(
key
,
"%s.Italic"
,
fontName
);
count
=
sizeof
(
buffer
);
if
(
!
RegQueryValueExA
(
hkey
,
key
,
0
,
&
type
,
buffer
,
&
count
))
font
->
logfont
.
lfItalic
=
get_bool
(
buffer
,
defItalic
);
lf
.
lfItalic
=
get_bool
(
buffer
);
sprintf
(
key
,
"%s.Underline"
,
fontName
);
count
=
sizeof
(
buffer
);
if
(
!
RegQueryValueExA
(
hkey
,
key
,
0
,
&
type
,
buffer
,
&
count
))
font
->
logfont
.
lfUnderline
=
get_bool
(
buffer
,
defUnderline
);
lf
.
lfUnderline
=
get_bool
(
buffer
);
sprintf
(
key
,
"%s.StrikeOut"
,
fontName
);
count
=
sizeof
(
buffer
);
if
(
!
RegQueryValueExA
(
hkey
,
key
,
0
,
&
type
,
buffer
,
&
count
))
font
->
logfont
.
lfStrikeOut
=
get_bool
(
buffer
,
defStrikeOut
);
RegCloseKey
(
hkey
);
lf
.
lfStrikeOut
=
get_bool
(
buffer
);
return
CreateFontIndirectW
(
&
lf
);
}
#define TRACE_SEC(handle,text) \
TRACE("(%04x): " text " %ld\n", (handle), GDI_level.crst.RecursionCount)
/***********************************************************************
* GDI_Init
*
...
...
@@ -282,30 +151,57 @@ static void ReadFontInformation(
*/
BOOL
GDI_Init
(
void
)
{
HPALETTE16
hpalette
;
HINSTANCE16
instance
;
HKEY
hkey
;
GDIOBJHDR
*
ptr
;
int
i
;
if
(
RegOpenKeyA
(
HKEY_LOCAL_MACHINE
,
"Software
\\
Wine
\\
Wine
\\
Config
\\
Tweak.Fonts"
,
&
hkey
))
hkey
=
0
;
/* create GDI heap */
if
((
instance
=
LoadLibrary16
(
"GDI.EXE"
))
<
32
)
return
FALSE
;
GDI_HeapSel
=
instance
|
7
;
/* TWEAK: Initialize font hints */
ReadFontInformation
(
"OEMFixed"
,
&
OEMFixedFont
,
12
,
0
,
0
,
0
,
0
);
ReadFontInformation
(
"AnsiFixed"
,
&
AnsiFixedFont
,
12
,
0
,
0
,
0
,
0
);
ReadFontInformation
(
"AnsiVar"
,
&
AnsiVarFont
,
12
,
0
,
0
,
0
,
0
);
ReadFontInformation
(
"System"
,
&
SystemFont
,
16
,
0
,
0
,
0
,
0
);
ReadFontInformation
(
"DeviceDefault"
,
&
DeviceDefaultFont
,
16
,
0
,
0
,
0
,
0
);
ReadFontInformation
(
"SystemFixed"
,
&
SystemFixedFont
,
16
,
0
,
0
,
0
,
0
);
ReadFontInformation
(
"DefaultGui"
,
&
DefaultGuiFont
,
-
11
,
0
,
0
,
0
,
0
);
/* create stock objects */
stock_objects
[
WHITE_BRUSH
]
=
CreateBrushIndirect
(
&
WhiteBrush
);
stock_objects
[
LTGRAY_BRUSH
]
=
CreateBrushIndirect
(
&
LtGrayBrush
);
stock_objects
[
GRAY_BRUSH
]
=
CreateBrushIndirect
(
&
GrayBrush
);
stock_objects
[
DKGRAY_BRUSH
]
=
CreateBrushIndirect
(
&
DkGrayBrush
);
stock_objects
[
BLACK_BRUSH
]
=
CreateBrushIndirect
(
&
BlackBrush
);
stock_objects
[
NULL_BRUSH
]
=
CreateBrushIndirect
(
&
NullBrush
);
stock_objects
[
WHITE_PEN
]
=
CreatePenIndirect
(
&
WhitePen
);
stock_objects
[
BLACK_PEN
]
=
CreatePenIndirect
(
&
BlackPen
);
stock_objects
[
NULL_PEN
]
=
CreatePenIndirect
(
&
NullPen
);
stock_objects
[
DEFAULT_PALETTE
]
=
PALETTE_Init
();
stock_objects
[
DEFAULT_BITMAP
]
=
CreateBitmap
(
1
,
1
,
1
,
1
,
NULL
);
/* Create default palette */
stock_objects
[
OEM_FIXED_FONT
]
=
create_stock_font
(
"OEMFixed"
,
&
OEMFixedFont
,
hkey
);
stock_objects
[
ANSI_FIXED_FONT
]
=
create_stock_font
(
"AnsiFixed"
,
&
AnsiFixedFont
,
hkey
);
stock_objects
[
ANSI_VAR_FONT
]
=
create_stock_font
(
"AnsiVar"
,
&
AnsiVarFont
,
hkey
);
stock_objects
[
SYSTEM_FONT
]
=
create_stock_font
(
"System"
,
&
SystemFont
,
hkey
);
stock_objects
[
DEVICE_DEFAULT_FONT
]
=
create_stock_font
(
"DeviceDefault"
,
&
DeviceDefaultFont
,
hkey
);
stock_objects
[
SYSTEM_FIXED_FONT
]
=
create_stock_font
(
"SystemFixed"
,
&
SystemFixedFont
,
hkey
);
stock_objects
[
DEFAULT_GUI_FONT
]
=
create_stock_font
(
"DefaultGui"
,
&
DefaultGuiFont
,
hkey
);
/* DR well *this* palette can't be moveable (?) */
hpalette
=
PALETTE_Init
();
if
(
!
hpalette
)
return
FALSE
;
StockObjects
[
DEFAULT_PALETTE
]
=
(
GDIOBJHDR
*
)
LOCAL_Lock
(
GDI_HeapSel
,
hpalette
);
hPseudoStockBitmap
=
CreateBitmap
(
1
,
1
,
1
,
1
,
NULL
);
/* clear the NOSYSTEM bit on all stock objects*/
for
(
i
=
0
;
i
<
NB_STOCK_OBJECTS
;
i
++
)
{
if
(
!
stock_objects
[
i
])
{
if
(
i
==
9
)
continue
;
/* there's no stock object 9 */
ERR
(
"could not create stock object %d
\n
"
,
i
);
return
FALSE
;
}
ptr
=
GDI_GetObjPtr
(
stock_objects
[
i
],
MAGIC_DONTCARE
);
ptr
->
wMagic
&=
~
OBJECT_NOSYSTEM
;
GDI_ReleaseObj
(
stock_objects
[
i
]
);
}
if
(
hkey
)
RegCloseKey
(
hkey
);
return
TRUE
;
}
...
...
@@ -415,23 +311,19 @@ BOOL GDI_FreeObject( HGDIOBJ handle, void *ptr )
{
GDIOBJHDR
*
object
=
ptr
;
/* can't free stock objects
*/
if
(
handle
<
FIRST_STOCK_HANDLE
)
object
->
wMagic
=
0
;
/* Mark it as invalid
*/
if
(
handle
&
2
)
/* GDI heap handle */
{
object
->
wMagic
=
0
;
/* Mark it as invalid */
if
(
handle
&
2
)
/* GDI heap handle */
{
LOCAL_Unlock
(
GDI_HeapSel
,
handle
);
LOCAL_Free
(
GDI_HeapSel
,
handle
);
}
else
/* large heap handle */
LOCAL_Unlock
(
GDI_HeapSel
,
handle
);
LOCAL_Free
(
GDI_HeapSel
,
handle
);
}
else
/* large heap handle */
{
int
i
=
(
handle
>>
2
)
-
FIRST_LARGE_HANDLE
;
if
(
i
>=
0
&&
large_handles
[
i
])
{
int
i
=
(
handle
>>
2
)
-
FIRST_LARGE_HANDLE
;
if
(
i
>=
0
&&
large_handles
[
i
])
{
HeapFree
(
GetProcessHeap
(),
0
,
large_handles
[
i
]
);
large_handles
[
i
]
=
NULL
;
}
HeapFree
(
GetProcessHeap
(),
0
,
large_handles
[
i
]
);
large_handles
[
i
]
=
NULL
;
}
}
TRACE_SEC
(
handle
,
"leave"
);
...
...
@@ -453,17 +345,10 @@ void *GDI_GetObjPtr( HGDIOBJ handle, WORD magic )
_EnterSysLevel
(
&
GDI_level
);
if
(
handle
>=
FIRST_STOCK_HANDLE
)
{
if
(
handle
<=
LAST_STOCK_HANDLE
)
ptr
=
StockObjects
[
handle
-
FIRST_STOCK_HANDLE
];
if
(
ptr
&&
(
magic
!=
MAGIC_DONTCARE
)
&&
(
GDIMAGIC
(
ptr
->
wMagic
)
!=
magic
))
ptr
=
NULL
;
}
else
if
(
handle
&
2
)
/* GDI heap handle */
if
(
handle
&
2
)
/* GDI heap handle */
{
ptr
=
(
GDIOBJHDR
*
)
LOCAL_Lock
(
GDI_HeapSel
,
handle
);
if
(
ptr
&&
(
magic
!=
MAGIC_DONTCARE
)
&&
(
GDIMAGIC
(
ptr
->
wMagic
)
!=
magic
))
if
(
ptr
&&
(
magic
!=
MAGIC_DONTCARE
)
&&
(
GDIMAGIC
(
ptr
->
wMagic
)
!=
magic
))
{
LOCAL_Unlock
(
GDI_HeapSel
,
handle
);
ptr
=
NULL
;
...
...
@@ -496,7 +381,7 @@ void *GDI_GetObjPtr( HGDIOBJ handle, WORD magic )
*/
void
GDI_ReleaseObj
(
HGDIOBJ
handle
)
{
if
(
handle
<
FIRST_STOCK_HANDLE
&&
(
handle
&
2
)
)
LOCAL_Unlock
(
GDI_HeapSel
,
handle
);
if
(
handle
&
2
)
LOCAL_Unlock
(
GDI_HeapSel
,
handle
);
TRACE_SEC
(
handle
,
"leave"
);
_LeaveSysLevel
(
&
GDI_level
);
}
...
...
@@ -530,12 +415,7 @@ BOOL WINAPI DeleteObject( HGDIOBJ obj )
GDIOBJHDR
*
header
;
if
(
HIWORD
(
obj
))
return
FALSE
;
if
((
obj
>=
FIRST_STOCK_HANDLE
)
&&
(
obj
<=
LAST_STOCK_HANDLE
))
{
TRACE
(
"Preserving Stock object %04x
\n
"
,
obj
);
/* NOTE: No GDI_Release is necessary */
return
TRUE
;
}
if
(
obj
==
hPseudoStockBitmap
)
return
TRUE
;
if
(
!
(
header
=
GDI_GetObjPtr
(
obj
,
MAGIC_DONTCARE
)))
return
FALSE
;
if
(
!
(
header
->
wMagic
&
OBJECT_NOSYSTEM
)
...
...
@@ -587,8 +467,7 @@ HGDIOBJ WINAPI GetStockObject( INT obj )
{
HGDIOBJ
ret
;
if
((
obj
<
0
)
||
(
obj
>=
NB_STOCK_OBJECTS
))
return
0
;
if
(
!
StockObjects
[
obj
])
return
0
;
ret
=
(
HGDIOBJ16
)(
FIRST_STOCK_HANDLE
+
obj
);
ret
=
stock_objects
[
obj
];
TRACE
(
"returning %4x
\n
"
,
ret
);
return
ret
;
}
...
...
windows/syscolor.c
View file @
78f9fae7
...
...
@@ -98,9 +98,6 @@ static COLORREF SysColors[NUM_SYS_COLORS];
static
HBRUSH
SysColorBrushes
[
NUM_SYS_COLORS
];
static
HPEN
SysColorPens
[
NUM_SYS_COLORS
];
#define MAKE_SOLID(color) \
(PALETTEINDEX(GetNearestPaletteIndex(STOCK_DEFAULT_PALETTE,(color))))
/*************************************************************************
* SYSCOLOR_MakeObjectSystem
...
...
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