ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

NT5design.c
Go to the documentation of this file.
00001 /*
00002  * COPYRIGHT:   See COPYING in the top level directory
00003  * PROJECT:     ReactOS Logon User Interface Host
00004  * FILE:        subsys/system/logonui/NT5design.c
00005  * PROGRAMMERS: Ged Murphy (gedmurphy@reactos.org)
00006  */
00007 
00008 #include "logonui.h"
00009 
00010 
00011 /* GLOBALS ******************************************************************/
00012 
00013 #define NT5_TOP_BORDER_HEIGHT       80
00014 #define NT5_BOTTOM_BORDER_HEIGHT    96
00015 
00016 
00017 /* FUNCTIONS ****************************************************************/
00018 
00019 static VOID
00020 NT5_DrawLogoffCaptionText(LPWSTR lpText,
00021                           HDC hdcMem)
00022 {
00023     HFONT hFont;
00024     LOGFONTW LogFont;
00025     RECT TextRect;
00026     INT PrevBkMode;
00027 
00028     /* Setup the font we'll use */
00029     ZeroMemory(&LogFont, sizeof(LOGFONTW));
00030     LogFont.lfCharSet = DEFAULT_CHARSET;
00031     LogFont.lfHeight = 22;
00032     LogFont.lfWeight = 109; // From WinXP disassembly
00033     wcscpy_s(LogFont.lfFaceName, LF_FACESIZE, L"Arial");
00034 
00035     /* Create it */
00036     hFont = CreateFontIndirectW(&LogFont);
00037     if (hFont)
00038     {
00039         /* Set the font and font colour */
00040         SelectObject(hdcMem, hFont);
00041         SetTextColor(hdcMem, RGB(255, 255, 255));
00042 
00043         /* Create the text rect */
00044         TextRect.top = (g_pInfo->cy / 2) + 34;
00045         TextRect.bottom = (g_pInfo->cy / 2) + 34 + (GetDeviceCaps(hdcMem, LOGPIXELSY));
00046         TextRect.left = g_pInfo->cx / 3;
00047         TextRect.right = (g_pInfo->cx / 2) + 35 + 137;
00048 
00049         /* Set the background mode to transparent */
00050         PrevBkMode = SetBkMode(hdcMem, TRANSPARENT);
00051 
00052         /* Draw the text to the mem DC */
00053         DrawTextW(hdcMem,
00054                   lpText,
00055                   -1,
00056                   &TextRect,
00057                   DT_NOPREFIX | DT_WORDBREAK | DT_RIGHT); // WinXP disassembly uses 0x812
00058 
00059         /* Set the previous background mode */
00060         SetBkMode(hdcMem, PrevBkMode);
00061 
00062         /* Delete the font */
00063         DeleteObject(hFont);
00064     }
00065 }
00066 
00067 static VOID
00068 NT5_DrawLogoffIcon(HDC hdcMem)
00069 {
00070     HBITMAP hBitmap;
00071     BITMAP bitmap;
00072     HDC hTempDC;
00073 
00074     /* Load the XP logo */
00075     hBitmap = (HBITMAP)LoadImageW(g_pInfo->hInstance,
00076                                   MAKEINTRESOURCEW(IDB_MAIN_ROS_LOGO),
00077                                   IMAGE_BITMAP,
00078                                   0,
00079                                   0,
00080                                   LR_DEFAULTCOLOR);
00081     if (hBitmap)
00082     {
00083         /* Get the bitmap dimensions */
00084         GetObjectW(hBitmap, sizeof(BITMAP), &bitmap);
00085 
00086         /* Create a temp DC for the bitmap */
00087         hTempDC = CreateCompatibleDC(hdcMem);
00088         if (hTempDC)
00089         {
00090             /* Select the bitmap onto the temp DC */
00091             SelectObject(hTempDC, hBitmap);
00092 
00093             /* Paint it onto the centre block */
00094             BitBlt(hdcMem,
00095                    (g_pInfo->cx / 2) + 35,
00096                    (g_pInfo->cy / 2) - 72,
00097                    bitmap.bmWidth,
00098                    bitmap.bmHeight,
00099                    hTempDC,
00100                    0,
00101                    0,
00102                    SRCCOPY);
00103 
00104             /* Delete the DC */
00105             DeleteDC(hTempDC);
00106         }
00107 
00108         /* Delete the bitmap */
00109         DeleteObject(hBitmap);
00110     }
00111 }
00112 
00113 VOID
00114 NT5_RefreshLogoffScreenText(LPWSTR lpText,
00115                             HDC hdcMem)
00116 {
00117     /* FIXME: clear previous text */
00118 
00119     /* Draw the new text */
00120     NT5_DrawLogoffCaptionText(lpText, hdcMem);
00121 }
00122 
00123 VOID
00124 NT5_CreateLogoffScreen(LPWSTR lpText,
00125                        HDC hdcMem)
00126 {
00127     /* Draw the reactos logo */
00128     NT5_DrawLogoffIcon(hdcMem);
00129 
00130     /* Draw the first text string */
00131     NT5_DrawLogoffCaptionText(lpText, hdcMem);
00132 }
00133 
00134 HDC
00135 NT5_DrawBaseBackground(HDC hdcDesktop)
00136 {
00137     HBITMAP hBitmap = NULL;
00138     HDC hdcMem = NULL;
00139     BOOL bRet = FALSE;
00140 
00141 
00142     /* Create an an off screen DC to match the desktop DC */
00143     hdcMem = CreateCompatibleDC(hdcDesktop);
00144     if (hdcMem)
00145     {
00146         /* Create a bitmap to draw the logoff screen onto */
00147         hBitmap = CreateCompatibleBitmap(hdcDesktop, g_pInfo->cx, g_pInfo->cy);
00148         if (hBitmap)
00149         {
00150             /* Select it onto our off screen DC*/
00151             SelectObject(hdcMem, hBitmap);
00152 
00153             /* Draw the centre block */
00154             {
00155                 HBITMAP hTempBitmap;
00156                 HBRUSH hBrush;
00157                 BITMAP bitmap;
00158                 HDC hTempDC;
00159 
00160                 /* Paint the blue centre block */
00161                 hBrush = CreateSolidBrush(RGB(90, 126, 220));
00162                 SelectObject(hdcMem, hBrush);
00163                 PatBlt(hdcMem,
00164                         0,
00165                         NT5_TOP_BORDER_HEIGHT,
00166                         g_pInfo->cx,
00167                         g_pInfo->cy - NT5_TOP_BORDER_HEIGHT - NT5_BOTTOM_BORDER_HEIGHT,
00168                         PATCOPY);
00169                 DeleteObject(hBrush);
00170 
00171                 /* Load the shine effect */
00172                 hTempBitmap = (HBITMAP)LoadImageW(g_pInfo->hInstance,
00173                                                     MAKEINTRESOURCEW(IDB_MAIN_PANEL_SHINE),
00174                                                     IMAGE_BITMAP,
00175                                                     0,
00176                                                     0,
00177                                                     LR_DEFAULTCOLOR);
00178                 if (hTempBitmap)
00179                 {
00180                     /* Get the bitmap dimensions */
00181                     GetObjectW(hTempBitmap, sizeof(BITMAP), &bitmap);
00182 
00183                     /* Create a temp DC for the bitmap */
00184                     hTempDC = CreateCompatibleDC(hdcDesktop);
00185                     if (hTempDC)
00186                     {
00187                         /* Select the bitmap onto the temp DC */
00188                         SelectObject(hTempDC, hTempBitmap);
00189 
00190                         /* Paint it onto the top left of the centre block */
00191                         BitBlt(hdcMem,
00192                                 0,
00193                                 NT5_TOP_BORDER_HEIGHT,
00194                                 bitmap.bmWidth,
00195                                 bitmap.bmHeight,
00196                                 hTempDC,
00197                                 0,
00198                                 0,
00199                                 SRCCOPY);
00200 
00201                         /* Delete the DC */
00202                         DeleteDC(hTempDC);
00203                     }
00204 
00205                     /* Delete the bitmap */
00206                     DeleteObject(hTempBitmap);
00207                 }
00208             }
00209 
00210             /* Draw the top border */
00211             {
00212                 HBITMAP hTempBitmap;
00213                 HBRUSH hBrush;
00214                 BITMAP bitmap;
00215                 HDC hTempDC;
00216 
00217                 /* Create the blue brush and paint the top bar */
00218                 hBrush = CreateSolidBrush(RGB(0, 48, 156));
00219                 SelectObject(hdcMem, hBrush);
00220                 PatBlt(hdcMem, 0, 0, g_pInfo->cx, NT5_TOP_BORDER_HEIGHT, PATCOPY);
00221                 DeleteObject(hBrush);
00222 
00223                 /* Load the top divider strip */
00224                 hTempBitmap = (HBITMAP)LoadImageW(g_pInfo->hInstance,
00225                                                     MAKEINTRESOURCEW(IDB_TOP_DIVIDER_STRIP),
00226                                                     IMAGE_BITMAP,
00227                                                     0,
00228                                                     0,
00229                                                     LR_DEFAULTCOLOR);
00230                 if (hTempBitmap)
00231                 {
00232                     /* Get the bitmap dimensions */
00233                     GetObjectW(hTempBitmap, sizeof(BITMAP), &bitmap);
00234 
00235                     /* Create a temp DC for the bitmap */
00236                     hTempDC = CreateCompatibleDC(hdcDesktop);
00237                     if (hTempDC)
00238                     {
00239                         /* Select the bitmap onto the temp DC */
00240                         SelectObject(hTempDC, hTempBitmap);
00241 
00242                         /* Paint the bitmap */
00243                         StretchBlt(hdcMem,
00244                                     0,
00245                                     NT5_TOP_BORDER_HEIGHT - bitmap.bmHeight,
00246                                     g_pInfo->cx,
00247                                     NT5_TOP_BORDER_HEIGHT,
00248                                     hTempDC,
00249                                     0,
00250                                     0,
00251                                     bitmap.bmWidth,
00252                                     NT5_TOP_BORDER_HEIGHT,
00253                                     SRCCOPY);
00254 
00255                         /* Delete the DC */
00256                         DeleteDC(hTempDC);
00257                     }
00258 
00259                     /* Delete the bitmap */
00260                     DeleteObject(hTempBitmap);
00261                 }
00262             }
00263 
00264             /* Draw the bottom border */
00265             {
00266                 HBITMAP hTempBitmap;
00267                 TRIVERTEX vertex[2];
00268                 GRADIENT_RECT gRect;
00269                 BITMAP bitmap;
00270                 HDC hTempDC;
00271 
00272                 /*
00273                  * We paint the divider strip first as it's 3
00274                  * pixels high but MS only show 2 of them.
00275                  */
00276 
00277                 /* Load the bottom divider strip */
00278                 hTempBitmap = (HBITMAP)LoadImage(g_pInfo->hInstance,
00279                                                     MAKEINTRESOURCE(IDB_BOTTOM_DIVIDER_STRIP),
00280                                                     IMAGE_BITMAP,
00281                                                     0,
00282                                                     0,
00283                                                     LR_DEFAULTCOLOR);
00284                 if (hTempBitmap)
00285                 {
00286                     /* Get the bitmap dimensions */
00287                     GetObjectW(hTempBitmap, sizeof(BITMAP), &bitmap);
00288 
00289                     /* Create a temp DC for the bitmap */
00290                     hTempDC = CreateCompatibleDC(hdcDesktop);
00291                     if (hTempDC)
00292                     {
00293                         /* Select the bitmap onto the temp DC */
00294                         SelectObject(hTempDC, hTempBitmap);
00295 
00296                         /* Paint the bitmap */
00297                         StretchBlt(hdcMem,
00298                                     0,
00299                                     g_pInfo->cy - NT5_BOTTOM_BORDER_HEIGHT,
00300                                     g_pInfo->cx,
00301                                     g_pInfo->cy - NT5_BOTTOM_BORDER_HEIGHT + bitmap.bmHeight,
00302                                     hTempDC,
00303                                     0,
00304                                     0,
00305                                     bitmap.bmWidth,
00306                                     g_pInfo->cy - NT5_BOTTOM_BORDER_HEIGHT + bitmap.bmHeight,
00307                                     SRCCOPY);
00308 
00309                         /* Delete the DC */
00310                         DeleteDC(hTempDC);
00311                     }
00312 
00313                     /* Delete the bitmap */
00314                     DeleteObject(hTempBitmap);
00315                 }
00316 
00317                 /* Setup the left hand vertex */
00318                 vertex[0].x     = 0;
00319                 vertex[0].y     = g_pInfo->cy - NT5_BOTTOM_BORDER_HEIGHT + 2; // paint over 1 pixel of the bitmap
00320                 vertex[0].Red   = 0x3900;
00321                 vertex[0].Green = 0x3400;
00322                 vertex[0].Blue  = 0xAE00;
00323                 vertex[0].Alpha = 0x0000;
00324 
00325                 /* Setup the right hand vertex */
00326                 vertex[1].x     = g_pInfo->cx;
00327                 vertex[1].y     = g_pInfo->cy;
00328                 vertex[1].Red   = 0x0000;
00329                 vertex[1].Green = 0x3000;
00330                 vertex[1].Blue  = 0x9600;
00331                 vertex[1].Alpha = 0x0000;
00332 
00333                 /* Set the vertex structs */
00334                 gRect.UpperLeft  = 0;
00335                 gRect.LowerRight = 1;
00336 
00337                 /* Paint the gradient across the bottom */
00338                 GradientFill(hdcMem,
00339                                 vertex,
00340                                 2,
00341                                 &gRect,
00342                                 1,
00343                                 GRADIENT_FILL_RECT_H);
00344             }
00345 
00346             /* Delete the bitmap */
00347             DeleteObject(hBitmap);
00348         }
00349     }
00350 
00351     return hdcMem;
00352 }
00353 
00354 /* EOF */

Generated on Wed May 23 2012 04:16:47 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.