Debian Codegraph @

Source/exehead/bgbg.c

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