home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 March / CMCD0304.ISO / Software / Freeware / Programare / nullsoft / nsis20.exe / Source / exehead / bgbg.c < prev    next >
C/C++ Source or Header  |  2004-01-30  |  3KB  |  98 lines

  1. #include "../Platform.h"
  2. #include "resource.h"
  3. #include "config.h"
  4. #include "fileform.h"
  5. #include "state.h"
  6. #include "ui.h"
  7. #include "util.h"
  8.  
  9. #ifdef NSIS_SUPPORT_BGBG
  10.  
  11. #define c1 header->bg_color1
  12. #define c2 header->bg_color2
  13.  
  14. LRESULT CALLBACK BG_WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  15. {
  16.   switch (uMsg)
  17.   {
  18.     case WM_WINDOWPOSCHANGING:
  19.       {
  20.         LPWINDOWPOS wp = (LPWINDOWPOS) lParam;
  21.         wp->flags |= SWP_NOACTIVATE;
  22.         wp->hwndInsertAfter = g_hwnd;
  23.         break;
  24.       }
  25.     case WM_PAINT:
  26.       {
  27.         header *header = g_header;
  28.  
  29.         PAINTSTRUCT ps;
  30.         HDC hdc=BeginPaint(hwnd,&ps);
  31.         RECT r;
  32.         LOGBRUSH lh;
  33.         int ry;
  34.  
  35.         lh.lbStyle = BS_SOLID;
  36.  
  37.         GetClientRect(hwnd,&r);
  38.         // this portion by Drew Davidson, drewdavidson@mindspring.com
  39.         ry=r.bottom;
  40.  
  41.         // JF: made slower, reduced to 4 pixels high, because I like how it looks better/
  42.         while (r.top < ry)
  43.         {
  44.           int rv,gv,bv;
  45.           HBRUSH brush;
  46.           rv = (GetRValue(c2) * r.top + GetRValue(c1) * (ry-r.top)) / ry;
  47.           gv = (GetGValue(c2) * r.top + GetGValue(c1) * (ry-r.top)) / ry;
  48.           bv = (GetBValue(c2) * r.top + GetBValue(c1) * (ry-r.top)) / ry;
  49.           lh.lbColor = RGB(rv,gv,bv);
  50.           brush = CreateBrushIndirect(&lh);
  51.           // note that we don't need to do "SelectObject(hdc, brush)"
  52.           // because FillRect lets us specify the brush as a parameter.
  53.           FillRect(hdc, &r, brush);
  54.           DeleteObject(brush);
  55.           r.top+=4;
  56.           r.bottom+=4;
  57.         }
  58.  
  59.         if (header->bg_textcolor != -1)
  60.         {
  61.           HFONT oldFont;
  62.           HFONT newFont = CreateFont(
  63.             40,
  64.             0,
  65.             0,
  66.             0,
  67.             FW_BOLD,
  68.             TRUE,
  69.             FALSE,
  70.             FALSE,
  71.             DEFAULT_CHARSET,
  72.             OUT_DEFAULT_PRECIS,
  73.             CLIP_DEFAULT_PRECIS,
  74.             DEFAULT_QUALITY,
  75.             DEFAULT_PITCH,
  76.             "Garamond"
  77.           );
  78.           if (newFont)
  79.           {
  80.             r.left=16;
  81.             r.top=8;
  82.             SetBkMode(hdc,TRANSPARENT);
  83.             SetTextColor(hdc,header->bg_textcolor);
  84.             oldFont = SelectObject(hdc,newFont);
  85.             DrawText(hdc,g_caption,-1,&r,DT_TOP|DT_LEFT|DT_SINGLELINE|DT_NOPREFIX);
  86.             SelectObject(hdc,oldFont);
  87.             DeleteObject(newFont);
  88.           }
  89.         }
  90.         EndPaint(hwnd,&ps);
  91.       }
  92.     return 0;
  93.   }
  94.   return DefWindowProc(hwnd,uMsg,wParam,lParam);
  95. }
  96.  
  97. #endif //NSIS_SUPPORT_BGBG
  98.