1 /******************************************************************************
5 * Windows 95 style interface tweaks.
6 * Copyright (c) 1997 Dave Cuthbert.
8 * FIXME: This file is, unfortunately, aptly named: the method of
9 * displaying Win95 style windows is a tweak. Lots of stuff does not yet
10 * work -- and probably never will unless some of this code is
11 * incorporated into the mainstream Wine code.
13 * DEVELOPERS, PLEASE NOTE: Before delving into the mainstream code and
14 * altering it, consider how your changes will affect the Win3.1 interface
15 * (which has taken a major effort to create!). After you make any sort of
16 * non-trivial change, *test* the Wine code running in Win3.1 mode! The
17 * object here is to make it so that the person who tests the latest version
18 * of Wine without adding the tweaks into wine.conf notices nothing out of
22 * 03-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
23 * Original implementation.
25 *****************************************************************************/
34 #include "stackframe.h"
38 /* Parameters for windows/nonclient.c */
39 extern int NC_CaptionLeftNudge
;
40 extern int NC_CaptionTopNudge
;
41 extern int NC_SysControlNudge
;
42 extern int NC_MaxControlNudge
;
43 extern int NC_MinControlNudge
;
44 extern UINT32 NC_CaptionTextFlags
;
45 extern HBRUSH32 NC_WinHighlight95
;
46 extern HBRUSH32 NC_WinShadow95
;
48 /* Parameters for controls/menu.c */
49 extern UINT32 MENU_BarItemTopNudge
;
50 extern UINT32 MENU_BarItemLeftNudge
;
51 extern UINT32 MENU_ItemTopNudge
;
52 extern UINT32 MENU_ItemLeftNudge
;
53 extern UINT32 MENU_HighlightTopNudge
;
54 extern UINT32 MENU_HighlightLeftNudge
;
55 extern UINT32 MENU_HighlightBottomNudge
;
56 extern UINT32 MENU_HighlightRightNudge
;
65 #if defined(WIN_95_LOOK)
66 int TWEAK_Win95Look
= 1;
68 int TWEAK_Win95Look
= 0;
71 int TWEAK_WineInitialized
= 0;
74 /******************************************************************************
76 * int TWEAK_MenuInit()
78 * Initializes the Win95 tweaks to the menu code. See controls/menu.c.
79 * Return value indicates success (non-zero) or failure.
82 * 06-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
83 * Original implementation.
85 *****************************************************************************/
87 static int TWEAK_MenuInit()
89 MENU_BarItemTopNudge
=
90 PROFILE_GetWineIniInt("Tweak.Layout", "MenuBarItemTopNudge", 0);
91 MENU_BarItemLeftNudge
=
92 PROFILE_GetWineIniInt("Tweak.Layout", "MenuBarItemLeftNudge", 0);
94 PROFILE_GetWineIniInt("Tweak.Layout", "MenuItemTopNudge", 0);
96 PROFILE_GetWineIniInt("Tweak.Layout", "MenuItemLeftNudge", 0);
97 MENU_HighlightTopNudge
=
98 PROFILE_GetWineIniInt("Tweak.Layout", "MenuHighlightTopNudge", 0);
99 MENU_HighlightLeftNudge
=
100 PROFILE_GetWineIniInt("Tweak.Layout", "MenuHighlightLeftNudge", 0);
101 MENU_HighlightBottomNudge
=
102 PROFILE_GetWineIniInt("Tweak.Layout", "MenuHighlightBottomNudge", 0);
103 MENU_HighlightRightNudge
=
104 PROFILE_GetWineIniInt("Tweak.Layout", "MenuHighlightRightNudge", 0);
110 /******************************************************************************
112 * int TWEAK_NonClientInit()
114 * Initializes the Win95 tweaks to the non-client drawing functions. See
115 * windows/nonclient.c. Return value indicates success (non-zero) or
119 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
120 * Original implementation.
122 *****************************************************************************/
124 static int TWEAK_NonClientInit()
128 NC_CaptionLeftNudge
=
129 PROFILE_GetWineIniInt("Tweak.Layout", "CaptionLeftNudge", 0);
131 PROFILE_GetWineIniInt("Tweak.Layout", "CaptionTopNudge", 0);
133 PROFILE_GetWineIniInt("Tweak.Layout", "SysControlNudge", 0);
135 PROFILE_GetWineIniInt("Tweak.Layout", "MaxControlNudge", 0);
137 PROFILE_GetWineIniInt("Tweak.Layout", "MinControlNudge", 0);
139 NC_WinHighlight95
= CreateSolidBrush32(RGB(0xc0, 0xc0, 0xc0));
140 NC_WinShadow95
= CreateSolidBrush32(RGB(0x00, 0x00, 0x00));
142 NC_CaptionTextFlags
= DT_SINGLELINE
| DT_VCENTER
| DT_NOPREFIX
;
144 PROFILE_GetWineIniString("Tweak.Layout", "CaptionAlignment",
145 TWEAK_Win95Look
? "l" : "c", key_value
, 2);
147 switch(key_value
[0]) {
150 NC_CaptionTextFlags
|= DT_LEFT
;
155 NC_CaptionTextFlags
|= DT_RIGHT
;
159 NC_CaptionTextFlags
|= DT_CENTER
;
166 /******************************************************************************
168 * int TWEAK_VarInit()
170 * Initializes the miscellaneous variables which are used in the tweak
171 * routines. Return value is non-zero on success.
174 * 07-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
175 * Original implementation.
177 *****************************************************************************/
179 static int TWEAK_VarInit()
181 TWEAK_Win95Look
= PROFILE_GetWineIniBool("Tweak.Layout", "Win95Look", 0);
183 /* FIXME: Each color should really occupy a single entry in the wine.conf
184 file, but I couldn't settle on a good (intuitive!) format. */
186 TWEAK_PenFF95
= CreatePen32(
188 RGB(PROFILE_GetWineIniInt("Tweak.Colors", "PenFF95.Red", 0xff),
189 PROFILE_GetWineIniInt("Tweak.Colors", "PenFF95.Grn", 0xff),
190 PROFILE_GetWineIniInt("Tweak.Colors", "PenFF95.Blu", 0xff)));
191 TWEAK_PenE095
= CreatePen32(
193 RGB(PROFILE_GetWineIniInt("Tweak.Colors", "PenE095.Red", 0xe0),
194 PROFILE_GetWineIniInt("Tweak.Colors", "PenE095.Grn", 0xe0),
195 PROFILE_GetWineIniInt("Tweak.Colors", "PenE095.Blu", 0xe0)));
196 TWEAK_PenC095
= CreatePen32(
198 RGB(PROFILE_GetWineIniInt("Tweak.Colors", "PenC095.Red", 0xc0),
199 PROFILE_GetWineIniInt("Tweak.Colors", "PenC095.Grn", 0xc0),
200 PROFILE_GetWineIniInt("Tweak.Colors", "PenC095.Blu", 0xc0)));
201 TWEAK_Pen8095
= CreatePen32(
203 RGB(PROFILE_GetWineIniInt("Tweak.Colors", "Pen8095.Red", 0x80),
204 PROFILE_GetWineIniInt("Tweak.Colors", "Pen8095.Grn", 0x80),
205 PROFILE_GetWineIniInt("Tweak.Colors", "Pen8095.Blu", 0x80)));
206 TWEAK_Pen0095
= CreatePen32(
208 RGB(PROFILE_GetWineIniInt("Tweak.Colors", "Pen0095.Red", 0x00),
209 PROFILE_GetWineIniInt("Tweak.Colors", "Pen0095.Grn", 0x00),
210 PROFILE_GetWineIniInt("Tweak.Colors", "Pen0095.Blu", 0x00)));
212 TRACE(tweak
, "Using %s look and feel.\n",
213 TWEAK_Win95Look
? "Win95" : "Win3.1");
218 /******************************************************************************
222 * Does the full initialization of the Win95 tweak subsystem. Return value
223 * indicates success. Called by loader/main.c's MAIN_Init().
226 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
227 * Original implementation.
229 *****************************************************************************/
234 TWEAK_NonClientInit();
240 /******************************************************************************
242 * int TWEAK_CheckConfiguration()
244 * Examines wine.conf for old/bad entries and recommends changes to the user.
247 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
248 * Original implementation.
250 *****************************************************************************/
252 int TWEAK_CheckConfiguration()
258 /******************************************************************************
260 * Tweak graphic subsystem.
262 *****************************************************************************/
264 /******************************************************************************
266 * void TWEAK_DrawReliefRect95(
267 * HDC32 hdc, // Device context on which to draw
268 * RECT32 const *rect ) // Rectangle to use
270 * Draws the double-bordered Win95-style relief rectangle.
273 * There are some checks missing from this function. Perhaps the
274 * SelectObject32 calls should be examined? Hasn't failed on me (yet).
276 * Should I really be calling X functions directly from here? It is
277 * an optimization, but should I be optimizing alpha code? Probably
281 * 08-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
282 * Original implementation.
284 *****************************************************************************/
286 void TWEAK_DrawReliefRect95(
293 if((dc
= (DC
*)GDI_GetObjPtr(hdc
, DC_MAGIC
))) {
295 /* Draw the top/left lines first */
296 prevpen
= SelectObject32(hdc
, TWEAK_PenE095
);
297 DC_SetupGCForPen(dc
);
298 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, rect
->left
, rect
->top
,
299 rect
->right
- 1, rect
->top
);
300 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, rect
->left
, rect
->top
,
301 rect
->left
, rect
->bottom
- 1);
303 SelectObject32(hdc
, TWEAK_PenFF95
);
304 DC_SetupGCForPen(dc
);
305 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, rect
->left
+ 1,
306 rect
->top
+ 1, rect
->right
- 2, rect
->top
+ 1);
307 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, rect
->left
+ 1,
308 rect
->top
+ 1, rect
->left
+ 1, rect
->bottom
- 2);
311 /* Now the bottom/right lines */
312 SelectObject32(hdc
, TWEAK_Pen0095
);
313 DC_SetupGCForPen(dc
);
314 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, rect
->left
,
315 rect
->bottom
- 1, rect
->right
- 1, rect
->bottom
- 1);
316 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, rect
->right
- 1,
317 rect
->top
, rect
->right
- 1, rect
->bottom
- 1);
319 SelectObject32(hdc
, TWEAK_Pen8095
);
320 DC_SetupGCForPen(dc
);
321 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, rect
->left
+ 1,
322 rect
->bottom
- 2, rect
->right
- 2, rect
->bottom
- 2);
323 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, rect
->right
- 2,
324 rect
->top
+ 1, rect
->right
- 2, rect
->bottom
- 2);
326 SelectObject32(hdc
, prevpen
);
333 /******************************************************************************
335 * void TWEAK_DrawRevReliefRect95(
336 * HDC32 hdc, // Device context on which to draw
337 * RECT32 const *rect ) // Rectangle to use
339 * Draws the double-bordered Win95-style relief rectangle.
342 * There are some checks missing from this function. Perhaps the
343 * SelectObject32 calls should be examined? Hasn't failed on me (yet).
345 * Should I really be calling X functions directly from here? It is
346 * an optimization, but should I be optimizing alpha code? Probably
350 * 08-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
351 * Original implementation.
353 *****************************************************************************/
355 void TWEAK_DrawRevReliefRect95(
362 if((dc
= (DC
*)GDI_GetObjPtr(hdc
, DC_MAGIC
))) {
364 /* Draw the top/left lines first */
365 prevpen
= SelectObject32(hdc
, TWEAK_Pen8095
);
366 DC_SetupGCForPen(dc
);
367 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, rect
->left
, rect
->top
,
368 rect
->right
- 1, rect
->top
);
369 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, rect
->left
, rect
->top
,
370 rect
->left
, rect
->bottom
- 1);
372 SelectObject32(hdc
, TWEAK_Pen0095
);
373 DC_SetupGCForPen(dc
);
374 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, rect
->left
+ 1,
375 rect
->top
+ 1, rect
->right
- 2, rect
->top
+ 1);
376 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, rect
->left
+ 1,
377 rect
->top
+ 1, rect
->left
+ 1, rect
->bottom
- 2);
380 /* Now the bottom/right lines */
381 SelectObject32(hdc
, TWEAK_PenFF95
);
382 DC_SetupGCForPen(dc
);
383 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, rect
->left
,
384 rect
->bottom
- 1, rect
->right
- 1, rect
->bottom
- 1);
385 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, rect
->right
- 1,
386 rect
->top
, rect
->right
- 1, rect
->bottom
- 1);
388 SelectObject32(hdc
, TWEAK_PenE095
);
389 DC_SetupGCForPen(dc
);
390 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, rect
->left
+ 1,
391 rect
->bottom
- 2, rect
->right
- 2, rect
->bottom
- 2);
392 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, rect
->right
- 2,
393 rect
->top
+ 1, rect
->right
- 2, rect
->bottom
- 2);
395 SelectObject32(hdc
, prevpen
);
403 /******************************************************************************
405 * void TWEAK_DrawMenuSeparatorHoriz95(
406 * HDC32 hdc, // Device context on which to draw
407 * UINT32 xc1, // Left x-coordinate
408 * UINT32 yc, // Y-coordinate of the LOWER line
409 * UINT32 xc2 ) // Right x-coordinate
411 * Draws a horizontal menu separator bar Win 95 style.
414 * Same as those for DrawReliefRect95.
417 * 08-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
418 * Original implementation.
419 * 11-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
420 * Changed name from DrawMenuSeparator95
422 *****************************************************************************/
424 void TWEAK_DrawMenuSeparatorHoriz95(
433 if((dc
= (DC
*)GDI_GetObjPtr(hdc
, DC_MAGIC
))) {
435 /* Draw the top line */
436 prevpen
= SelectObject32(hdc
, TWEAK_Pen8095
);
437 DC_SetupGCForPen(dc
);
438 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, xc1
, yc
- 1, xc2
,
441 /* And the bottom line */
442 SelectObject32(hdc
, TWEAK_PenFF95
);
443 DC_SetupGCForPen(dc
);
444 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, xc1
, yc
, xc2
, yc
);
446 SelectObject32(hdc
, prevpen
);
453 /******************************************************************************
455 * void TWEAK_DrawMenuSeparatorVert95(
456 * HDC32 hdc, // Device context on which to draw
457 * UINT32 xc, // X-coordinate of the RIGHT line
458 * UINT32 yc1, // top Y-coordinate
459 * UINT32 yc2 ) // bottom Y-coordinate
461 * Draws a vertical menu separator bar Win 95 style.
464 * Same as those for DrawReliefRect95.
467 * 11-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
468 * Original implementation.
470 *****************************************************************************/
472 void TWEAK_DrawMenuSeparatorVert95(
481 if((dc
= (DC
*)GDI_GetObjPtr(hdc
, DC_MAGIC
))) {
483 /* Draw the top line */
484 prevpen
= SelectObject32(hdc
, TWEAK_Pen8095
);
485 DC_SetupGCForPen(dc
);
486 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, xc
, yc1
, xc
,
489 /* And the bottom line */
490 SelectObject32(hdc
, TWEAK_PenFF95
);
491 DC_SetupGCForPen(dc
);
492 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, xc
+ 1, yc1
, xc
+ 1,
495 SelectObject32(hdc
, prevpen
);