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