fixed branding text background color not updating when the system's color change
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@3329 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
9241c66c5e
commit
8a85e1c0dd
9 changed files with 62 additions and 61 deletions
|
@ -32,17 +32,6 @@ static int WINAPI popstring(char *str)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CC_TEXT 1
|
|
||||||
#define CC_BK 4
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
COLORREF text;
|
|
||||||
LOGBRUSH bk;
|
|
||||||
HBRUSH bkb;
|
|
||||||
int bkmode;
|
|
||||||
int flags;
|
|
||||||
} ctlcolors;
|
|
||||||
|
|
||||||
#define strcpy(x,y) lstrcpy(x,y)
|
#define strcpy(x,y) lstrcpy(x,y)
|
||||||
//#define strncpy(x,y,z) lstrcpyn(x,y,z)
|
//#define strncpy(x,y,z) lstrcpyn(x,y,z)
|
||||||
#define strdup(x) STRDUP(x)
|
#define strdup(x) STRDUP(x)
|
||||||
|
@ -761,19 +750,8 @@ BOOL CALLBACK cfgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
case WM_CTLCOLORDLG:
|
case WM_CTLCOLORDLG:
|
||||||
case WM_CTLCOLORBTN:
|
case WM_CTLCOLORBTN:
|
||||||
case WM_CTLCOLORLISTBOX:
|
case WM_CTLCOLORLISTBOX:
|
||||||
{
|
// let the NSIS window handle colors, it knows best
|
||||||
ctlcolors *c = (ctlcolors *) GetWindowLong((HWND) lParam, GWL_USERDATA);
|
return mySendMessage(hMainWindow, WM_CTLCOLORSTATIC, wParam, lParam);
|
||||||
|
|
||||||
if (c) {
|
|
||||||
SetBkMode((HDC)wParam, c->bkmode);
|
|
||||||
if (c->flags & CC_BK)
|
|
||||||
SetBkColor((HDC)wParam, c->bk.lbColor);
|
|
||||||
if (c->flags & CC_TEXT)
|
|
||||||
SetTextColor((HDC)wParam, c->text);
|
|
||||||
|
|
||||||
return (BOOL)c->bkb;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
|
@ -104,13 +104,32 @@ static BOOL NSISCALL _HandleStaticBkColor(UINT uMsg, WPARAM wParam, LPARAM lPara
|
||||||
case WM_CTLCOLORBTN:
|
case WM_CTLCOLORBTN:
|
||||||
{
|
{
|
||||||
ctlcolors *c = (ctlcolors *)GetWindowLong((HWND)lParam, GWL_USERDATA);
|
ctlcolors *c = (ctlcolors *)GetWindowLong((HWND)lParam, GWL_USERDATA);
|
||||||
|
|
||||||
if (c) {
|
if (c) {
|
||||||
SetBkMode((HDC)wParam, c->bkmode);
|
COLORREF text;
|
||||||
if (c->flags & CC_BK)
|
LOGBRUSH lh;
|
||||||
SetBkColor((HDC)wParam, c->bk.lbColor);
|
|
||||||
|
text = c->text;
|
||||||
|
if (c->flags & CC_TEXT_SYS)
|
||||||
|
text = GetSysColor(text);
|
||||||
if (c->flags & CC_TEXT)
|
if (c->flags & CC_TEXT)
|
||||||
SetTextColor((HDC)wParam, c->text);
|
SetTextColor((HDC)wParam, text);
|
||||||
|
|
||||||
|
SetBkMode((HDC)wParam, c->bkmode);
|
||||||
|
|
||||||
|
lh.lbColor = c->bkc;
|
||||||
|
if (c->flags & CC_BK_SYS)
|
||||||
|
lh.lbColor = GetSysColor(lh.lbColor);
|
||||||
|
if (c->flags & CC_BK)
|
||||||
|
SetBkColor((HDC)wParam, lh.lbColor);
|
||||||
|
|
||||||
|
if (c->flags & CC_BKB)
|
||||||
|
{
|
||||||
|
lh.lbStyle = c->lbStyle;
|
||||||
|
if (c->bkb)
|
||||||
|
DeleteObject(c->bkb);
|
||||||
|
c->bkb = CreateBrushIndirect(&lh);
|
||||||
|
}
|
||||||
|
|
||||||
return (BOOL)c->bkb;
|
return (BOOL)c->bkb;
|
||||||
}
|
}
|
||||||
|
@ -364,7 +383,6 @@ static int CALLBACK WINAPI BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lPara
|
||||||
|
|
||||||
BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
BOOL bNextPage=FALSE;
|
|
||||||
if (uMsg == WM_INITDIALOG || uMsg == WM_NOTIFY_OUTER_NEXT)
|
if (uMsg == WM_INITDIALOG || uMsg == WM_NOTIFY_OUTER_NEXT)
|
||||||
{
|
{
|
||||||
page *this_page;
|
page *this_page;
|
||||||
|
@ -414,7 +432,6 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
SendMessage(m_curwnd, WM_NOTIFY_INIGO_MONTOYA, 0, 0);
|
SendMessage(m_curwnd, WM_NOTIFY_INIGO_MONTOYA, 0, 0);
|
||||||
|
|
||||||
nextPage:
|
nextPage:
|
||||||
bNextPage=FALSE;
|
|
||||||
m_page+=m_delta;
|
m_page+=m_delta;
|
||||||
this_page+=m_delta;
|
this_page+=m_delta;
|
||||||
|
|
||||||
|
@ -459,8 +476,8 @@ nextPage:
|
||||||
my_SetWindowText(hwndDlg,g_tmp);
|
my_SetWindowText(hwndDlg,g_tmp);
|
||||||
|
|
||||||
#ifdef NSIS_SUPPORT_CODECALLBACKS
|
#ifdef NSIS_SUPPORT_CODECALLBACKS
|
||||||
|
// custom page or user used abort in prefunc
|
||||||
if (ExecuteCodeSegment(this_page->prefunc, NULL) || !this_page->dlg_id) {
|
if (ExecuteCodeSegment(this_page->prefunc, NULL) || !this_page->dlg_id) {
|
||||||
bNextPage=TRUE;
|
|
||||||
goto nextPage;
|
goto nextPage;
|
||||||
}
|
}
|
||||||
#endif //NSIS_SUPPORT_CODECALLBACKS
|
#endif //NSIS_SUPPORT_CODECALLBACKS
|
||||||
|
@ -516,9 +533,6 @@ skipPage:
|
||||||
ui_dlg_visible = 1;
|
ui_dlg_visible = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bNextPage)
|
|
||||||
goto nextPage;
|
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,11 @@ LRESULT CALLBACK BG_WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
PAINTSTRUCT ps;
|
PAINTSTRUCT ps;
|
||||||
HDC hdc=BeginPaint(hwnd,&ps);
|
HDC hdc=BeginPaint(hwnd,&ps);
|
||||||
RECT r;
|
RECT r;
|
||||||
|
LOGBRUSH lh;
|
||||||
int ry;
|
int ry;
|
||||||
|
|
||||||
|
lh.lbStyle = BS_SOLID;
|
||||||
|
|
||||||
GetClientRect(hwnd,&r);
|
GetClientRect(hwnd,&r);
|
||||||
// this portion by Drew Davidson, drewdavidson@mindspring.com
|
// this portion by Drew Davidson, drewdavidson@mindspring.com
|
||||||
ry=r.bottom;
|
ry=r.bottom;
|
||||||
|
@ -42,7 +46,8 @@ LRESULT CALLBACK BG_WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
rv = (GetRValue(c2) * r.top + GetRValue(c1) * (ry-r.top)) / ry;
|
rv = (GetRValue(c2) * r.top + GetRValue(c1) * (ry-r.top)) / ry;
|
||||||
gv = (GetGValue(c2) * r.top + GetGValue(c1) * (ry-r.top)) / ry;
|
gv = (GetGValue(c2) * r.top + GetGValue(c1) * (ry-r.top)) / ry;
|
||||||
bv = (GetBValue(c2) * r.top + GetBValue(c1) * (ry-r.top)) / ry;
|
bv = (GetBValue(c2) * r.top + GetBValue(c1) * (ry-r.top)) / ry;
|
||||||
brush = CreateSolidBrush(RGB(rv,gv,bv));
|
lh.lbColor = RGB(rv,gv,bv);
|
||||||
|
brush = CreateBrushIndirect(&lh);
|
||||||
// note that we don't need to do "SelectObject(hdc, brush)"
|
// note that we don't need to do "SelectObject(hdc, brush)"
|
||||||
// because FillRect lets us specify the brush as a parameter.
|
// because FillRect lets us specify the brush as a parameter.
|
||||||
FillRect(hdc, &r, brush);
|
FillRect(hdc, &r, brush);
|
||||||
|
@ -53,18 +58,31 @@ LRESULT CALLBACK BG_WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
|
|
||||||
if (header->bg_textcolor != -1)
|
if (header->bg_textcolor != -1)
|
||||||
{
|
{
|
||||||
HFONT newFont, oldFont;
|
HFONT oldFont;
|
||||||
newFont = CreateFont(40,0,0,0,FW_BOLD,TRUE,FALSE,FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH,"Garamond");
|
HFONT newFont = CreateFont(
|
||||||
|
40,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
FW_BOLD,
|
||||||
|
TRUE,
|
||||||
|
FALSE,
|
||||||
|
FALSE,
|
||||||
|
DEFAULT_CHARSET,
|
||||||
|
OUT_DEFAULT_PRECIS,
|
||||||
|
CLIP_DEFAULT_PRECIS,
|
||||||
|
DEFAULT_QUALITY,
|
||||||
|
DEFAULT_PITCH,
|
||||||
|
"Garamond"
|
||||||
|
);
|
||||||
if (newFont)
|
if (newFont)
|
||||||
{
|
{
|
||||||
static char buf[256];
|
|
||||||
r.left=16;
|
r.left=16;
|
||||||
r.top=8;
|
r.top=8;
|
||||||
my_GetWindowText(hwnd,buf,sizeof(buf));
|
|
||||||
SetBkMode(hdc,TRANSPARENT);
|
SetBkMode(hdc,TRANSPARENT);
|
||||||
SetTextColor(hdc,header->bg_textcolor);
|
SetTextColor(hdc,header->bg_textcolor);
|
||||||
oldFont = SelectObject(hdc,newFont);
|
oldFont = SelectObject(hdc,newFont);
|
||||||
DrawText(hdc,buf,-1,&r,DT_TOP|DT_LEFT|DT_SINGLELINE|DT_NOPREFIX);
|
DrawText(hdc,g_caption,-1,&r,DT_TOP|DT_LEFT|DT_SINGLELINE|DT_NOPREFIX);
|
||||||
SelectObject(hdc,oldFont);
|
SelectObject(hdc,oldFont);
|
||||||
DeleteObject(newFont);
|
DeleteObject(newFont);
|
||||||
}
|
}
|
||||||
|
|
|
@ -739,16 +739,6 @@ static int NSISCALL ExecuteEntry(entry *entry_)
|
||||||
case EW_SETCTLCOLORS:
|
case EW_SETCTLCOLORS:
|
||||||
{
|
{
|
||||||
ctlcolors *c = (ctlcolors *)(g_blocks[NB_CTLCOLORS].offset + parm1);
|
ctlcolors *c = (ctlcolors *)(g_blocks[NB_CTLCOLORS].offset + parm1);
|
||||||
|
|
||||||
if (c->flags & CC_TEXT_SYS)
|
|
||||||
c->text = GetSysColor(c->text);
|
|
||||||
if (c->flags & CC_BK_SYS)
|
|
||||||
c->bk.lbColor = GetSysColor(c->bk.lbColor);
|
|
||||||
if (c->flags & CC_BKB)
|
|
||||||
c->bkb = CreateBrushIndirect(&c->bk);
|
|
||||||
|
|
||||||
c->flags &= ~(CC_BK_SYS|CC_TEXT_SYS|CC_BKB);
|
|
||||||
|
|
||||||
SetWindowLong((HWND) GetIntFromParm(0), GWL_USERDATA, (long) c);
|
SetWindowLong((HWND) GetIntFromParm(0), GWL_USERDATA, (long) c);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -397,7 +397,8 @@ typedef struct
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
COLORREF text;
|
COLORREF text;
|
||||||
LOGBRUSH bk;
|
COLORREF bkc;
|
||||||
|
UINT lbStyle;
|
||||||
HBRUSH bkb;
|
HBRUSH bkb;
|
||||||
int bkmode;
|
int bkmode;
|
||||||
int flags;
|
int flags;
|
||||||
|
|
|
@ -58,10 +58,10 @@ HANDLE NSISCALL myCreateProcess(char *cmd, char *dir)
|
||||||
return ProcInfo.hProcess;
|
return ProcInfo.hProcess;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL NSISCALL my_SetWindowText(HWND hWnd, const char *val)
|
/*BOOL NSISCALL my_SetWindowText(HWND hWnd, const char *val)
|
||||||
{
|
{
|
||||||
return SendMessage(hWnd,WM_SETTEXT,0,(LPARAM)val);
|
return SendMessage(hWnd,WM_SETTEXT,0,(LPARAM)val);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
BOOL NSISCALL my_SetDialogItemText(HWND dlg, UINT idx, const char *val)
|
BOOL NSISCALL my_SetDialogItemText(HWND dlg, UINT idx, const char *val)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,8 +16,8 @@ WIN32_FIND_DATA * NSISCALL file_exists(char *buf);
|
||||||
char * NSISCALL my_GetTempFileName(char *buf, const char *dir);
|
char * NSISCALL my_GetTempFileName(char *buf, const char *dir);
|
||||||
int NSISCALL my_PIDL2Path(char *out, LPITEMIDLIST idl);
|
int NSISCALL my_PIDL2Path(char *out, LPITEMIDLIST idl);
|
||||||
|
|
||||||
BOOL NSISCALL my_SetWindowText(HWND hWnd, const char *val);
|
//BOOL NSISCALL my_SetWindowText(HWND hWnd, const char *val);
|
||||||
//#define my_SetWindowText SetWindowText
|
#define my_SetWindowText SetWindowText
|
||||||
BOOL NSISCALL my_SetDialogItemText(HWND dlg, UINT idx, const char *val);
|
BOOL NSISCALL my_SetDialogItemText(HWND dlg, UINT idx, const char *val);
|
||||||
//int NSISCALL my_GetWindowText(HWND hWnd, char *val, int size);
|
//int NSISCALL my_GetWindowText(HWND hWnd, char *val, int size);
|
||||||
#define my_GetWindowText GetWindowText
|
#define my_GetWindowText GetWindowText
|
||||||
|
|
|
@ -3573,18 +3573,18 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
|
|
||||||
if (!strcmpi(line.gettoken_str(a+1),"transparent")) {
|
if (!strcmpi(line.gettoken_str(a+1),"transparent")) {
|
||||||
c.flags|=CC_BKB;
|
c.flags|=CC_BKB;
|
||||||
c.bk.lbStyle=BS_NULL;
|
c.lbStyle=BS_NULL;
|
||||||
c.bkmode=TRANSPARENT;
|
c.bkmode=TRANSPARENT;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
p=line.gettoken_str(a+1);
|
p=line.gettoken_str(a+1);
|
||||||
if (*p) {
|
if (*p) {
|
||||||
int v=strtoul(p,&p,16);
|
int v=strtoul(p,&p,16);
|
||||||
c.bk.lbColor=((v&0xff)<<16)|(v&0xff00)|((v&0xff0000)>>16);
|
c.bkc=((v&0xff)<<16)|(v&0xff00)|((v&0xff0000)>>16);
|
||||||
c.flags|=CC_BK|CC_BKB;
|
c.flags|=CC_BK|CC_BKB;
|
||||||
}
|
}
|
||||||
|
|
||||||
c.bk.lbStyle=BS_SOLID;
|
c.lbStyle=BS_SOLID;
|
||||||
c.bkmode=OPAQUE;
|
c.bkmode=OPAQUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3599,10 +3599,10 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
if (a == 3)
|
if (a == 3)
|
||||||
{
|
{
|
||||||
c.flags|=CC_BK|CC_BKB;
|
c.flags|=CC_BK|CC_BKB;
|
||||||
c.bk.lbStyle=BS_NULL;
|
c.lbStyle=BS_NULL;
|
||||||
if (!*line.gettoken_str(a))
|
if (!*line.gettoken_str(a))
|
||||||
{
|
{
|
||||||
c.bk.lbColor=COLOR_BTNFACE;
|
c.bkc=COLOR_BTNFACE;
|
||||||
c.flags|=CC_BK_SYS;
|
c.flags|=CC_BK_SYS;
|
||||||
}
|
}
|
||||||
c.flags|=CC_TEXT;
|
c.flags|=CC_TEXT;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue