~ubuntu-branches/ubuntu/lucid/nsis/lucid

« back to all changes in this revision

Viewing changes to Source/exehead/bgbg.c

  • Committer: Bazaar Package Importer
  • Author(s): Paul Wise
  • Date: 2008-09-01 07:20:44 UTC
  • mfrom: (3.1.9 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080901072044-mjev9xfej6i2d63t
Tags: 2.37-3
Add nsDialogs stack corruption fix from nsis 2.38

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
        r.bottom=0;
41
 
 
42
 
        // JF: made slower, reduced to 4 pixels high, because I like how it looks better/
43
 
        while (r.top < ry)
44
 
        {
45
 
          int rv,gv,bv;
46
 
          HBRUSH brush;
47
 
          rv = (GetRValue(c2) * r.top + GetRValue(c1) * (ry-r.top)) / ry;
48
 
          gv = (GetGValue(c2) * r.top + GetGValue(c1) * (ry-r.top)) / ry;
49
 
          bv = (GetBValue(c2) * r.top + GetBValue(c1) * (ry-r.top)) / ry;
50
 
          lh.lbColor = RGB(rv,gv,bv);
51
 
          brush = CreateBrushIndirect(&lh);
52
 
          // note that we don't need to do "SelectObject(hdc, brush)"
53
 
          // because FillRect lets us specify the brush as a parameter.
54
 
          r.bottom+=4;
55
 
          FillRect(hdc, &r, brush);
56
 
          DeleteObject(brush);
57
 
          r.top+=4;
58
 
        }
59
 
 
60
 
        if (header->bg_textcolor != -1)
61
 
        {
62
 
          HFONT newFont = CreateFontIndirect((LOGFONT *) header->blocks[NB_BGFONT].offset);
63
 
          if (newFont)
64
 
          {
65
 
            HFONT oldFont;
66
 
            r.left=16;
67
 
            r.top=8;
68
 
            SetBkMode(hdc,TRANSPARENT);
69
 
            SetTextColor(hdc,header->bg_textcolor);
70
 
            oldFont = SelectObject(hdc,newFont);
71
 
            DrawText(hdc,g_caption,-1,&r,DT_TOP|DT_LEFT|DT_SINGLELINE|DT_NOPREFIX);
72
 
            SelectObject(hdc,oldFont);
73
 
            DeleteObject(newFont);
74
 
          }
75
 
        }
76
 
        EndPaint(hwnd,&ps);
77
 
      }
78
 
      return 0;
79
 
  }
80
 
  return DefWindowProc(hwnd,uMsg,wParam,lParam);
81
 
}
82
 
 
83
 
#endif //NSIS_SUPPORT_BGBG
 
1
/*
 
2
 * bgbg.c
 
3
 * 
 
4
 * This file is a part of NSIS.
 
5
 * 
 
6
 * Copyright (C) 1999-2008 Nullsoft and Contributors
 
7
 * 
 
8
 * Licensed under the zlib/libpng license (the "License");
 
9
 * you may not use this file except in compliance with the License.
 
10
 * 
 
11
 * Licence details can be found in the file COPYING.
 
12
 * 
 
13
 * This software is provided 'as-is', without any express or implied
 
14
 * warranty.
 
15
 */
 
16
 
 
17
#include "../Platform.h"
 
18
#include "resource.h"
 
19
#include "config.h"
 
20
#include "fileform.h"
 
21
#include "state.h"
 
22
#include "ui.h"
 
23
#include "util.h"
 
24
 
 
25
#ifdef NSIS_SUPPORT_BGBG
 
26
 
 
27
#define c1 header->bg_color1
 
28
#define c2 header->bg_color2
 
29
 
 
30
LRESULT CALLBACK BG_WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
31
{
 
32
  switch (uMsg)
 
33
  {
 
34
    case WM_WINDOWPOSCHANGING:
 
35
      {
 
36
        LPWINDOWPOS wp = (LPWINDOWPOS) lParam;
 
37
        wp->flags |= SWP_NOACTIVATE;
 
38
        wp->hwndInsertAfter = g_hwnd;
 
39
        break;
 
40
      }
 
41
    case WM_PAINT:
 
42
      {
 
43
        header *header = g_header;
 
44
 
 
45
        PAINTSTRUCT ps;
 
46
        HDC hdc=BeginPaint(hwnd,&ps);
 
47
        RECT r;
 
48
        LOGBRUSH lh;
 
49
        int ry;
 
50
 
 
51
        lh.lbStyle = BS_SOLID;
 
52
 
 
53
        GetClientRect(hwnd,&r);
 
54
        // this portion by Drew Davidson, drewdavidson@mindspring.com
 
55
        ry=r.bottom;
 
56
        r.bottom=0;
 
57
 
 
58
        // JF: made slower, reduced to 4 pixels high, because I like how it looks better/
 
59
        while (r.top < ry)
 
60
        {
 
61
          int rv,gv,bv;
 
62
          HBRUSH brush;
 
63
          rv = (GetRValue(c2) * r.top + GetRValue(c1) * (ry-r.top)) / ry;
 
64
          gv = (GetGValue(c2) * r.top + GetGValue(c1) * (ry-r.top)) / ry;
 
65
          bv = (GetBValue(c2) * r.top + GetBValue(c1) * (ry-r.top)) / ry;
 
66
          lh.lbColor = RGB(rv,gv,bv);
 
67
          brush = CreateBrushIndirect(&lh);
 
68
          // note that we don't need to do "SelectObject(hdc, brush)"
 
69
          // because FillRect lets us specify the brush as a parameter.
 
70
          r.bottom+=4;
 
71
          FillRect(hdc, &r, brush);
 
72
          DeleteObject(brush);
 
73
          r.top+=4;
 
74
        }
 
75
 
 
76
        if (header->bg_textcolor != -1)
 
77
        {
 
78
          HFONT newFont = CreateFontIndirect((LOGFONT *) header->blocks[NB_BGFONT].offset);
 
79
          if (newFont)
 
80
          {
 
81
            HFONT oldFont;
 
82
            r.left=16;
 
83
            r.top=8;
 
84
            SetBkMode(hdc,TRANSPARENT);
 
85
            SetTextColor(hdc,header->bg_textcolor);
 
86
            oldFont = SelectObject(hdc,newFont);
 
87
            DrawText(hdc,g_caption,-1,&r,DT_TOP|DT_LEFT|DT_SINGLELINE|DT_NOPREFIX);
 
88
            SelectObject(hdc,oldFont);
 
89
            DeleteObject(newFont);
 
90
          }
 
91
        }
 
92
        EndPaint(hwnd,&ps);
 
93
      }
 
94
      return 0;
 
95
  }
 
96
  return DefWindowProc(hwnd,uMsg,wParam,lParam);
 
97
}
 
98
 
 
99
#endif //NSIS_SUPPORT_BGBG