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 *****************************************************************************/
35 #include "stackframe.h"
39 /* Parameters for windows/nonclient.c */
40 extern int NC_CaptionLeftNudge
;
41 extern int NC_CaptionTopNudge
;
42 extern int NC_SysControlNudge
;
43 extern int NC_MaxControlNudge
;
44 extern int NC_MinControlNudge
;
45 extern UINT32 NC_CaptionTextFlags
;
46 extern HBRUSH32 NC_WinHighlight95
;
47 extern HBRUSH32 NC_WinShadow95
;
49 /* Parameters for controls/menu.c */
50 extern UINT32 MENU_BarItemTopNudge
;
51 extern UINT32 MENU_BarItemLeftNudge
;
52 extern UINT32 MENU_ItemTopNudge
;
53 extern UINT32 MENU_ItemLeftNudge
;
54 extern UINT32 MENU_HighlightTopNudge
;
55 extern UINT32 MENU_HighlightLeftNudge
;
56 extern UINT32 MENU_HighlightBottomNudge
;
57 extern UINT32 MENU_HighlightRightNudge
;
66 #if defined(WIN_95_LOOK)
67 int TWEAK_Win95Look
= 1;
69 int TWEAK_Win95Look
= 0;
72 int TWEAK_WineInitialized
= 0;
75 /******************************************************************************
77 * int TWEAK_MenuInit()
79 * Initializes the Win95 tweaks to the menu code. See controls/menu.c.
80 * Return value indicates success (non-zero) or failure.
83 * 06-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
84 * Original implementation.
86 *****************************************************************************/
88 static int TWEAK_MenuInit()
90 MENU_BarItemTopNudge
=
91 PROFILE_GetWineIniInt("Tweak.Layout", "MenuBarItemTopNudge", 0);
92 MENU_BarItemLeftNudge
=
93 PROFILE_GetWineIniInt("Tweak.Layout", "MenuBarItemLeftNudge", 0);
95 PROFILE_GetWineIniInt("Tweak.Layout", "MenuItemTopNudge", 0);
97 PROFILE_GetWineIniInt("Tweak.Layout", "MenuItemLeftNudge", 0);
98 MENU_HighlightTopNudge
=
99 PROFILE_GetWineIniInt("Tweak.Layout", "MenuHighlightTopNudge", 0);
100 MENU_HighlightLeftNudge
=
101 PROFILE_GetWineIniInt("Tweak.Layout", "MenuHighlightLeftNudge", 0);
102 MENU_HighlightBottomNudge
=
103 PROFILE_GetWineIniInt("Tweak.Layout", "MenuHighlightBottomNudge", 0);
104 MENU_HighlightRightNudge
=
105 PROFILE_GetWineIniInt("Tweak.Layout", "MenuHighlightRightNudge", 0);
111 /******************************************************************************
113 * int TWEAK_NonClientInit()
115 * Initializes the Win95 tweaks to the non-client drawing functions. See
116 * windows/nonclient.c. Return value indicates success (non-zero) or
120 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
121 * Original implementation.
123 *****************************************************************************/
125 static int TWEAK_NonClientInit()
129 NC_CaptionLeftNudge
=
130 PROFILE_GetWineIniInt("Tweak.Layout", "CaptionLeftNudge", 0);
132 PROFILE_GetWineIniInt("Tweak.Layout", "CaptionTopNudge", 0);
134 PROFILE_GetWineIniInt("Tweak.Layout", "SysControlNudge", 0);
136 PROFILE_GetWineIniInt("Tweak.Layout", "MaxControlNudge", 0);
138 PROFILE_GetWineIniInt("Tweak.Layout", "MinControlNudge", 0);
140 NC_WinHighlight95
= CreateSolidBrush32(RGB(0xc0, 0xc0, 0xc0));
141 NC_WinShadow95
= CreateSolidBrush32(RGB(0x00, 0x00, 0x00));
143 NC_CaptionTextFlags
= DT_SINGLELINE
| DT_VCENTER
| DT_NOPREFIX
;
145 PROFILE_GetWineIniString("Tweak.Layout", "CaptionAlignment",
146 TWEAK_Win95Look
? "l" : "c", key_value
, 2);
148 switch(key_value
[0]) {
151 NC_CaptionTextFlags
|= DT_LEFT
;
156 NC_CaptionTextFlags
|= DT_RIGHT
;
160 NC_CaptionTextFlags
|= DT_CENTER
;
167 /******************************************************************************
169 * int TWEAK_VarInit()
171 * Initializes the miscellaneous variables which are used in the tweak
172 * routines. Return value is non-zero on success.
175 * 07-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
176 * Original implementation.
178 *****************************************************************************/
180 static int TWEAK_VarInit()
182 TWEAK_Win95Look
= PROFILE_GetWineIniBool("Tweak.Layout", "Win95Look", 0);
184 /* FIXME: Each color should really occupy a single entry in the wine.conf
185 file, but I couldn't settle on a good (intuitive!) format. */
187 TWEAK_PenFF95
= CreatePen32(
189 RGB(PROFILE_GetWineIniInt("Tweak.Colors", "PenFF95.Red", 0xff),
190 PROFILE_GetWineIniInt("Tweak.Colors", "PenFF95.Grn", 0xff),
191 PROFILE_GetWineIniInt("Tweak.Colors", "PenFF95.Blu", 0xff)));
192 TWEAK_PenE095
= CreatePen32(
194 RGB(PROFILE_GetWineIniInt("Tweak.Colors", "PenE095.Red", 0xe0),
195 PROFILE_GetWineIniInt("Tweak.Colors", "PenE095.Grn", 0xe0),
196 PROFILE_GetWineIniInt("Tweak.Colors", "PenE095.Blu", 0xe0)));
197 TWEAK_PenC095
= CreatePen32(
199 RGB(PROFILE_GetWineIniInt("Tweak.Colors", "PenC095.Red", 0xc0),
200 PROFILE_GetWineIniInt("Tweak.Colors", "PenC095.Grn", 0xc0),
201 PROFILE_GetWineIniInt("Tweak.Colors", "PenC095.Blu", 0xc0)));
202 TWEAK_Pen8095
= CreatePen32(
204 RGB(PROFILE_GetWineIniInt("Tweak.Colors", "Pen8095.Red", 0x80),
205 PROFILE_GetWineIniInt("Tweak.Colors", "Pen8095.Grn", 0x80),
206 PROFILE_GetWineIniInt("Tweak.Colors", "Pen8095.Blu", 0x80)));
207 TWEAK_Pen0095
= CreatePen32(
209 RGB(PROFILE_GetWineIniInt("Tweak.Colors", "Pen0095.Red", 0x00),
210 PROFILE_GetWineIniInt("Tweak.Colors", "Pen0095.Grn", 0x00),
211 PROFILE_GetWineIniInt("Tweak.Colors", "Pen0095.Blu", 0x00)));
213 dprintf_tweak(stddeb
, "TWEAK_VarInit: Using %s look and feel.\n",
214 TWEAK_Win95Look
? "Win95" : "Win3.1");
219 /******************************************************************************
223 * Does the full initialization of the Win95 tweak subsystem. Return value
224 * indicates success. Called by loader/main.c's MAIN_Init().
227 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
228 * Original implementation.
230 *****************************************************************************/
235 TWEAK_NonClientInit();
241 /******************************************************************************
243 * int TWEAK_CheckConfiguration()
245 * Examines wine.conf for old/bad entries and recommends changes to the user.
248 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
249 * Original implementation.
251 *****************************************************************************/
253 int TWEAK_CheckConfiguration()
259 /******************************************************************************
261 * Tweak graphic subsystem.
263 *****************************************************************************/
265 /******************************************************************************
267 * void TWEAK_DrawReliefRect95(
268 * HDC32 hdc, // Device context on which to draw
269 * RECT32 const *rect ) // Rectangle to use
271 * Draws the double-bordered Win95-style relief rectangle.
274 * There are some checks missing from this function. Perhaps the
275 * SelectObject32 calls should be examined? Hasn't failed on me (yet).
277 * Should I really be calling X functions directly from here? It is
278 * an optimization, but should I be optimizing alpha code? Probably
282 * 08-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
283 * Original implementation.
285 *****************************************************************************/
287 void TWEAK_DrawReliefRect95(
294 if((dc
= (DC
*)GDI_GetObjPtr(hdc
, DC_MAGIC
))) {
296 /* Draw the top/left lines first */
297 prevpen
= SelectObject32(hdc
, TWEAK_PenE095
);
298 DC_SetupGCForPen(dc
);
299 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, rect
->left
, rect
->top
,
300 rect
->right
- 1, rect
->top
);
301 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, rect
->left
, rect
->top
,
302 rect
->left
, rect
->bottom
- 1);
304 SelectObject32(hdc
, TWEAK_PenFF95
);
305 DC_SetupGCForPen(dc
);
306 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, rect
->left
+ 1,
307 rect
->top
+ 1, rect
->right
- 2, rect
->top
+ 1);
308 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, rect
->left
+ 1,
309 rect
->top
+ 1, rect
->left
+ 1, rect
->bottom
- 2);
312 /* Now the bottom/right lines */
313 SelectObject32(hdc
, TWEAK_Pen0095
);
314 DC_SetupGCForPen(dc
);
315 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, rect
->left
,
316 rect
->bottom
- 1, rect
->right
- 1, rect
->bottom
- 1);
317 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, rect
->right
- 1,
318 rect
->top
, rect
->right
- 1, rect
->bottom
- 1);
320 SelectObject32(hdc
, TWEAK_Pen8095
);
321 DC_SetupGCForPen(dc
);
322 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, rect
->left
+ 1,
323 rect
->bottom
- 2, rect
->right
- 2, rect
->bottom
- 2);
324 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, rect
->right
- 2,
325 rect
->top
+ 1, rect
->right
- 2, rect
->bottom
- 2);
327 SelectObject32(hdc
, prevpen
);
334 /******************************************************************************
336 * void TWEAK_DrawRevReliefRect95(
337 * HDC32 hdc, // Device context on which to draw
338 * RECT32 const *rect ) // Rectangle to use
340 * Draws the double-bordered Win95-style relief rectangle.
343 * There are some checks missing from this function. Perhaps the
344 * SelectObject32 calls should be examined? Hasn't failed on me (yet).
346 * Should I really be calling X functions directly from here? It is
347 * an optimization, but should I be optimizing alpha code? Probably
351 * 08-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
352 * Original implementation.
354 *****************************************************************************/
356 void TWEAK_DrawRevReliefRect95(
363 if((dc
= (DC
*)GDI_GetObjPtr(hdc
, DC_MAGIC
))) {
365 /* Draw the top/left lines first */
366 prevpen
= SelectObject32(hdc
, TWEAK_Pen8095
);
367 DC_SetupGCForPen(dc
);
368 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, rect
->left
, rect
->top
,
369 rect
->right
- 1, rect
->top
);
370 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, rect
->left
, rect
->top
,
371 rect
->left
, rect
->bottom
- 1);
373 SelectObject32(hdc
, TWEAK_Pen0095
);
374 DC_SetupGCForPen(dc
);
375 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, rect
->left
+ 1,
376 rect
->top
+ 1, rect
->right
- 2, rect
->top
+ 1);
377 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, rect
->left
+ 1,
378 rect
->top
+ 1, rect
->left
+ 1, rect
->bottom
- 2);
381 /* Now the bottom/right lines */
382 SelectObject32(hdc
, TWEAK_PenFF95
);
383 DC_SetupGCForPen(dc
);
384 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, rect
->left
,
385 rect
->bottom
- 1, rect
->right
- 1, rect
->bottom
- 1);
386 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, rect
->right
- 1,
387 rect
->top
, rect
->right
- 1, rect
->bottom
- 1);
389 SelectObject32(hdc
, TWEAK_PenE095
);
390 DC_SetupGCForPen(dc
);
391 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, rect
->left
+ 1,
392 rect
->bottom
- 2, rect
->right
- 2, rect
->bottom
- 2);
393 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, rect
->right
- 2,
394 rect
->top
+ 1, rect
->right
- 2, rect
->bottom
- 2);
396 SelectObject32(hdc
, prevpen
);
404 /******************************************************************************
406 * void TWEAK_DrawMenuSeparatorHoriz95(
407 * HDC32 hdc, // Device context on which to draw
408 * UINT32 xc1, // Left x-coordinate
409 * UINT32 yc, // Y-coordinate of the LOWER line
410 * UINT32 xc2 ) // Right x-coordinate
412 * Draws a horizontal menu separator bar Win 95 style.
415 * Same as those for DrawReliefRect95.
418 * 08-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
419 * Original implementation.
420 * 11-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
421 * Changed name from DrawMenuSeparator95
423 *****************************************************************************/
425 void TWEAK_DrawMenuSeparatorHoriz95(
434 if((dc
= (DC
*)GDI_GetObjPtr(hdc
, DC_MAGIC
))) {
436 /* Draw the top line */
437 prevpen
= SelectObject32(hdc
, TWEAK_Pen8095
);
438 DC_SetupGCForPen(dc
);
439 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, xc1
, yc
- 1, xc2
,
442 /* And the bottom line */
443 SelectObject32(hdc
, TWEAK_PenFF95
);
444 DC_SetupGCForPen(dc
);
445 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, xc1
, yc
, xc2
, yc
);
447 SelectObject32(hdc
, prevpen
);
454 /******************************************************************************
456 * void TWEAK_DrawMenuSeparatorVert95(
457 * HDC32 hdc, // Device context on which to draw
458 * UINT32 xc, // X-coordinate of the RIGHT line
459 * UINT32 yc1, // top Y-coordinate
460 * UINT32 yc2 ) // bottom Y-coordinate
462 * Draws a vertical menu separator bar Win 95 style.
465 * Same as those for DrawReliefRect95.
468 * 11-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
469 * Original implementation.
471 *****************************************************************************/
473 void TWEAK_DrawMenuSeparatorVert95(
482 if((dc
= (DC
*)GDI_GetObjPtr(hdc
, DC_MAGIC
))) {
484 /* Draw the top line */
485 prevpen
= SelectObject32(hdc
, TWEAK_Pen8095
);
486 DC_SetupGCForPen(dc
);
487 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, xc
, yc1
, xc
,
490 /* And the bottom line */
491 SelectObject32(hdc
, TWEAK_PenFF95
);
492 DC_SetupGCForPen(dc
);
493 TSXDrawLine(display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
, xc
+ 1, yc1
, xc
+ 1,
496 SelectObject32(hdc
, prevpen
);