xref: /reactos/base/system/logonui/NT5design.c (revision 8a978a17)
1 /*
2  * COPYRIGHT:   See COPYING in the top level directory
3  * PROJECT:     ReactOS Logon User Interface Host
4  * FILE:        base/system/logonui/NT5design.c
5  * PROGRAMMERS: Ged Murphy (gedmurphy@reactos.org)
6  */
7 
8 #include "logonui.h"
9 
10 
11 /* GLOBALS ******************************************************************/
12 
13 #define NT5_TOP_BORDER_HEIGHT       80
14 #define NT5_BOTTOM_BORDER_HEIGHT    96
15 
16 
17 /* FUNCTIONS ****************************************************************/
18 
19 static VOID
20 NT5_DrawLogoffCaptionText(LPWSTR lpText,
21                           HDC hdcMem)
22 {
23     HFONT hFont;
24     LOGFONTW LogFont;
25     RECT TextRect;
26     INT PrevBkMode;
27 
28     /* Setup the font we'll use */
29     ZeroMemory(&LogFont, sizeof(LOGFONTW));
30     LogFont.lfCharSet = DEFAULT_CHARSET;
31     LogFont.lfHeight = 22;
32     LogFont.lfWeight = 109; // From WinXP disassembly
33     wcscpy_s(LogFont.lfFaceName, LF_FACESIZE, L"Arial");
34 
35     /* Create it */
36     hFont = CreateFontIndirectW(&LogFont);
37     if (hFont)
38     {
39         /* Set the font and font colour */
40         SelectObject(hdcMem, hFont);
41         SetTextColor(hdcMem, RGB(255, 255, 255));
42 
43         /* Create the text rect */
44         TextRect.top = (g_pInfo->cy / 2) + 34;
45         TextRect.bottom = (g_pInfo->cy / 2) + 34 + (GetDeviceCaps(hdcMem, LOGPIXELSY));
46         TextRect.left = g_pInfo->cx / 3;
47         TextRect.right = (g_pInfo->cx / 2) + 35 + 137;
48 
49         /* Set the background mode to transparent */
50         PrevBkMode = SetBkMode(hdcMem, TRANSPARENT);
51 
52         /* Draw the text to the mem DC */
53         DrawTextW(hdcMem,
54                   lpText,
55                   -1,
56                   &TextRect,
57                   DT_NOPREFIX | DT_WORDBREAK | DT_RIGHT); // WinXP disassembly uses 0x812
58 
59         /* Set the previous background mode */
60         SetBkMode(hdcMem, PrevBkMode);
61 
62         /* Delete the font */
63         DeleteObject(hFont);
64     }
65 }
66 
67 static VOID
68 NT5_DrawLogoffIcon(HDC hdcMem)
69 {
70     HBITMAP hBitmap;
71     BITMAP bitmap;
72     HDC hTempDC;
73 
74     /* Load the XP logo */
75     hBitmap = (HBITMAP)LoadImageW(g_pInfo->hInstance,
76                                   MAKEINTRESOURCEW(IDB_MAIN_ROS_LOGO),
77                                   IMAGE_BITMAP,
78                                   0,
79                                   0,
80                                   LR_DEFAULTCOLOR);
81     if (hBitmap)
82     {
83         /* Get the bitmap dimensions */
84         GetObjectW(hBitmap, sizeof(BITMAP), &bitmap);
85 
86         /* Create a temp DC for the bitmap */
87         hTempDC = CreateCompatibleDC(hdcMem);
88         if (hTempDC)
89         {
90             /* Select the bitmap onto the temp DC */
91             SelectObject(hTempDC, hBitmap);
92 
93             /* Paint it onto the centre block */
94             BitBlt(hdcMem,
95                    (g_pInfo->cx / 2) + 35,
96                    (g_pInfo->cy / 2) - 72,
97                    bitmap.bmWidth,
98                    bitmap.bmHeight,
99                    hTempDC,
100                    0,
101                    0,
102                    SRCCOPY);
103 
104             /* Delete the DC */
105             DeleteDC(hTempDC);
106         }
107 
108         /* Delete the bitmap */
109         DeleteObject(hBitmap);
110     }
111 }
112 
113 VOID
114 NT5_RefreshLogoffScreenText(LPWSTR lpText,
115                             HDC hdcMem)
116 {
117     /* FIXME: clear previous text */
118 
119     /* Draw the new text */
120     NT5_DrawLogoffCaptionText(lpText, hdcMem);
121 }
122 
123 VOID
124 NT5_CreateLogoffScreen(LPWSTR lpText,
125                        HDC hdcMem)
126 {
127     /* Draw the reactos logo */
128     NT5_DrawLogoffIcon(hdcMem);
129 
130     /* Draw the first text string */
131     NT5_DrawLogoffCaptionText(lpText, hdcMem);
132 }
133 
134 HDC
135 NT5_DrawBaseBackground(HDC hdcDesktop)
136 {
137     HBITMAP hBitmap = NULL;
138     HDC hdcMem = NULL;
139     BOOL bRet = FALSE;
140 
141 
142     /* Create an an off screen DC to match the desktop DC */
143     hdcMem = CreateCompatibleDC(hdcDesktop);
144     if (hdcMem)
145     {
146         /* Create a bitmap to draw the logoff screen onto */
147         hBitmap = CreateCompatibleBitmap(hdcDesktop, g_pInfo->cx, g_pInfo->cy);
148         if (hBitmap)
149         {
150             /* Select it onto our off screen DC*/
151             SelectObject(hdcMem, hBitmap);
152 
153             /* Draw the centre block */
154             {
155                 HBITMAP hTempBitmap;
156                 HBRUSH hBrush;
157                 BITMAP bitmap;
158                 HDC hTempDC;
159 
160                 /* Paint the blue centre block */
161                 hBrush = CreateSolidBrush(RGB(90, 126, 220));
162                 SelectObject(hdcMem, hBrush);
163                 PatBlt(hdcMem,
164                         0,
165                         NT5_TOP_BORDER_HEIGHT,
166                         g_pInfo->cx,
167                         g_pInfo->cy - NT5_TOP_BORDER_HEIGHT - NT5_BOTTOM_BORDER_HEIGHT,
168                         PATCOPY);
169                 DeleteObject(hBrush);
170 
171                 /* Load the shine effect */
172                 hTempBitmap = (HBITMAP)LoadImageW(g_pInfo->hInstance,
173                                                     MAKEINTRESOURCEW(IDB_MAIN_PANEL_SHINE),
174                                                     IMAGE_BITMAP,
175                                                     0,
176                                                     0,
177                                                     LR_DEFAULTCOLOR);
178                 if (hTempBitmap)
179                 {
180                     /* Get the bitmap dimensions */
181                     GetObjectW(hTempBitmap, sizeof(BITMAP), &bitmap);
182 
183                     /* Create a temp DC for the bitmap */
184                     hTempDC = CreateCompatibleDC(hdcDesktop);
185                     if (hTempDC)
186                     {
187                         /* Select the bitmap onto the temp DC */
188                         SelectObject(hTempDC, hTempBitmap);
189 
190                         /* Paint it onto the top left of the centre block */
191                         BitBlt(hdcMem,
192                                 0,
193                                 NT5_TOP_BORDER_HEIGHT,
194                                 bitmap.bmWidth,
195                                 bitmap.bmHeight,
196                                 hTempDC,
197                                 0,
198                                 0,
199                                 SRCCOPY);
200 
201                         /* Delete the DC */
202                         DeleteDC(hTempDC);
203                     }
204 
205                     /* Delete the bitmap */
206                     DeleteObject(hTempBitmap);
207                 }
208             }
209 
210             /* Draw the top border */
211             {
212                 HBITMAP hTempBitmap;
213                 HBRUSH hBrush;
214                 BITMAP bitmap;
215                 HDC hTempDC;
216 
217                 /* Create the blue brush and paint the top bar */
218                 hBrush = CreateSolidBrush(RGB(0, 48, 156));
219                 SelectObject(hdcMem, hBrush);
220                 PatBlt(hdcMem, 0, 0, g_pInfo->cx, NT5_TOP_BORDER_HEIGHT, PATCOPY);
221                 DeleteObject(hBrush);
222 
223                 /* Load the top divider strip */
224                 hTempBitmap = (HBITMAP)LoadImageW(g_pInfo->hInstance,
225                                                     MAKEINTRESOURCEW(IDB_TOP_DIVIDER_STRIP),
226                                                     IMAGE_BITMAP,
227                                                     0,
228                                                     0,
229                                                     LR_DEFAULTCOLOR);
230                 if (hTempBitmap)
231                 {
232                     /* Get the bitmap dimensions */
233                     GetObjectW(hTempBitmap, sizeof(BITMAP), &bitmap);
234 
235                     /* Create a temp DC for the bitmap */
236                     hTempDC = CreateCompatibleDC(hdcDesktop);
237                     if (hTempDC)
238                     {
239                         /* Select the bitmap onto the temp DC */
240                         SelectObject(hTempDC, hTempBitmap);
241 
242                         /* Paint the bitmap */
243                         StretchBlt(hdcMem,
244                                     0,
245                                     NT5_TOP_BORDER_HEIGHT - bitmap.bmHeight,
246                                     g_pInfo->cx,
247                                     NT5_TOP_BORDER_HEIGHT,
248                                     hTempDC,
249                                     0,
250                                     0,
251                                     bitmap.bmWidth,
252                                     NT5_TOP_BORDER_HEIGHT,
253                                     SRCCOPY);
254 
255                         /* Delete the DC */
256                         DeleteDC(hTempDC);
257                     }
258 
259                     /* Delete the bitmap */
260                     DeleteObject(hTempBitmap);
261                 }
262             }
263 
264             /* Draw the bottom border */
265             {
266                 HBITMAP hTempBitmap;
267                 TRIVERTEX vertex[2];
268                 GRADIENT_RECT gRect;
269                 BITMAP bitmap;
270                 HDC hTempDC;
271 
272                 /*
273                  * We paint the divider strip first as it's 3
274                  * pixels high but MS only show 2 of them.
275                  */
276 
277                 /* Load the bottom divider strip */
278                 hTempBitmap = (HBITMAP)LoadImage(g_pInfo->hInstance,
279                                                     MAKEINTRESOURCE(IDB_BOTTOM_DIVIDER_STRIP),
280                                                     IMAGE_BITMAP,
281                                                     0,
282                                                     0,
283                                                     LR_DEFAULTCOLOR);
284                 if (hTempBitmap)
285                 {
286                     /* Get the bitmap dimensions */
287                     GetObjectW(hTempBitmap, sizeof(BITMAP), &bitmap);
288 
289                     /* Create a temp DC for the bitmap */
290                     hTempDC = CreateCompatibleDC(hdcDesktop);
291                     if (hTempDC)
292                     {
293                         /* Select the bitmap onto the temp DC */
294                         SelectObject(hTempDC, hTempBitmap);
295 
296                         /* Paint the bitmap */
297                         StretchBlt(hdcMem,
298                                     0,
299                                     g_pInfo->cy - NT5_BOTTOM_BORDER_HEIGHT,
300                                     g_pInfo->cx,
301                                     g_pInfo->cy - NT5_BOTTOM_BORDER_HEIGHT + bitmap.bmHeight,
302                                     hTempDC,
303                                     0,
304                                     0,
305                                     bitmap.bmWidth,
306                                     g_pInfo->cy - NT5_BOTTOM_BORDER_HEIGHT + bitmap.bmHeight,
307                                     SRCCOPY);
308 
309                         /* Delete the DC */
310                         DeleteDC(hTempDC);
311                     }
312 
313                     /* Delete the bitmap */
314                     DeleteObject(hTempBitmap);
315                 }
316 
317                 /* Setup the left hand vertex */
318                 vertex[0].x     = 0;
319                 vertex[0].y     = g_pInfo->cy - NT5_BOTTOM_BORDER_HEIGHT + 2; // paint over 1 pixel of the bitmap
320                 vertex[0].Red   = 0x3900;
321                 vertex[0].Green = 0x3400;
322                 vertex[0].Blue  = 0xAE00;
323                 vertex[0].Alpha = 0x0000;
324 
325                 /* Setup the right hand vertex */
326                 vertex[1].x     = g_pInfo->cx;
327                 vertex[1].y     = g_pInfo->cy;
328                 vertex[1].Red   = 0x0000;
329                 vertex[1].Green = 0x3000;
330                 vertex[1].Blue  = 0x9600;
331                 vertex[1].Alpha = 0x0000;
332 
333                 /* Set the vertex structs */
334                 gRect.UpperLeft  = 0;
335                 gRect.LowerRight = 1;
336 
337                 /* Paint the gradient across the bottom */
338                 GradientFill(hdcMem,
339                                 vertex,
340                                 2,
341                                 &gRect,
342                                 1,
343                                 GRADIENT_FILL_RECT_H);
344             }
345 
346             /* Delete the bitmap */
347             DeleteObject(hBitmap);
348         }
349     }
350 
351     return hdcMem;
352 }
353 
354 /* EOF */
355