Added LoadAndSetImage instruction
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@7078 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
b9c8d57bb2
commit
797e745de5
8 changed files with 76 additions and 29 deletions
|
@ -6,6 +6,10 @@ Released on ? ?th, 201?
|
|||
|
||||
\S1{v3.05-cl} Changelog
|
||||
|
||||
\S2{} Minor Changes
|
||||
|
||||
\b Added \R{loadandsetimage}{LoadAndSetImage}
|
||||
|
||||
\S2{} Translations
|
||||
|
||||
\b Updated Hindi (\W{http://sf.net/p/nsis/patches/291}{patch #291}) and Portuguese (\W{http://sf.net/p/nsis/bugs/1219}{bug #1219})
|
||||
|
|
|
@ -71,6 +71,15 @@ If HWND is a window, Gotos jump_if_window, otherwise, Gotos jump_if_not_window (
|
|||
\c Goto +2
|
||||
\c MessageBox MB_OK "no window"
|
||||
|
||||
\S2{loadandsetimage} LoadAndSetImage
|
||||
|
||||
\c [/EXERESOURCE] [/STRINGID] [/RESIZETOFIT[WIDTH|HEIGHT]] ctrl imagetype lrflags image
|
||||
|
||||
Loads and sets a image on a static control. \cw{ctrl} is the handle of the control. \cw{imagetype} must 0 for bitmaps and 1 for icons (and the control style must match the image type). \cw{lrflags} must be 0x10 to load from a file or 0 to load from a resource. \cw{image} specifies the file path or resource name. Use \cw{/EXERESOURCE} to load a resource from the installer .EXE. Use \cw{/STRINGID} if \cw{image} is a string, otherwise it is interpreted as a number. Use \cw{/RESIZETOFIT[WIDTH|HEIGHT]} to resize the image to the dimensions of the control.
|
||||
|
||||
\c LoadAndSetImage /EXERESOURCE $hIconStatic 1 0 103
|
||||
\c LoadAndSetImage /STRINGID /RESIZETOFITWIDTH $hBmpStatic 0 0x10 "$PluginsDir\myimg.bmp"
|
||||
|
||||
\S2{lockwindow} LockWindow
|
||||
|
||||
\c on|off
|
||||
|
|
|
@ -831,28 +831,17 @@ static int NSISCALL ExecuteEntry(entry *entry_)
|
|||
SetWindowLongPtr(GetHwndFromParm(0), GWLP_USERDATA, (LONG_PTR) c);
|
||||
}
|
||||
break;
|
||||
case EW_SETBRANDINGIMAGE:
|
||||
case EW_LOADANDSETIMAGE:
|
||||
{
|
||||
RECT r;
|
||||
HANDLE hImage;
|
||||
HWND hwImage=GetDlgItem(g_hwnd, parm1);
|
||||
GetClientRect(hwImage, &r);
|
||||
hImage=LoadImage(
|
||||
0,
|
||||
GetStringFromParm(0x00),
|
||||
IMAGE_BITMAP,
|
||||
parm2*r.right,
|
||||
parm2*r.bottom,
|
||||
LR_LOADFROMFILE
|
||||
);
|
||||
hImage = (HANDLE)SendMessage(
|
||||
hwImage,
|
||||
STM_SETIMAGE,
|
||||
IMAGE_BITMAP,
|
||||
(LPARAM)hImage
|
||||
);
|
||||
// delete old image
|
||||
if (hImage) DeleteObject(hImage);
|
||||
HWND hCtl=(parm2 & LASIF_HWND) ? GetHwndFromParm(1) : GetDlgItem(g_hwnd, parm1);
|
||||
UINT it=parm2 & LASIM_IMAGE, exeres=parm2 & LASIF_EXERES, fitw=(UINT)parm2 >> LASIS_FITCTLW, fith=(parm2 & LASIF_FITCTLH) != 0;
|
||||
LPCTSTR imgname = (parm2 & LASIF_STRID) ? GetStringFromParm(0x00) : MAKEINTRESOURCE(parm0);
|
||||
GetClientRect(hCtl, &r);
|
||||
hImage=LoadImage(exeres ? g_hInstance : NULL, imgname, it, fitw*r.right, fith*r.bottom, parm2 & LASIM_LR);
|
||||
hImage=(HANDLE)SendMessage(hCtl, STM_SETIMAGE, it, (LPARAM)hImage);
|
||||
if (hImage && IMAGE_BITMAP == it) DeleteObject(hImage); // Delete the old image
|
||||
}
|
||||
break;
|
||||
case EW_CREATEFONT:
|
||||
|
|
|
@ -174,6 +174,8 @@ const TCHAR * NSISCALL loadHeaders(int cl_flags)
|
|||
#ifdef C_ASSERT
|
||||
{C_ASSERT(sizeof(firstheader) == sizeof(int) * 7);}
|
||||
{C_ASSERT(sizeof(struct block_header) == sizeof(UINT_PTR) + sizeof(int));}
|
||||
{C_ASSERT(LASIF_FITCTLW >> LASIS_FITCTLW == 1);}
|
||||
{C_ASSERT(LASIF_LR_LOADFROMFILE == LR_LOADFROMFILE);}
|
||||
#endif
|
||||
|
||||
#ifdef NSIS_CONFIG_CRC_SUPPORT
|
||||
|
|
|
@ -112,7 +112,7 @@ enum
|
|||
#ifdef NSIS_CONFIG_ENHANCEDUI_SUPPORT
|
||||
EW_GETDLGITEM, // GetDlgItem: 3: [outputvar, dialog, item_id]
|
||||
EW_SETCTLCOLORS, // SerCtlColors: 3: [hwnd, pointer to struct colors]
|
||||
EW_SETBRANDINGIMAGE, // SetBrandingImage: 1: [Bitmap file]
|
||||
EW_LOADANDSETIMAGE, // SetBrandingImage/LoadAndSetImage: 3: [imgid ctl flags]
|
||||
EW_CREATEFONT, // CreateFont: 5: [handle output, face name, height, weight, flags]
|
||||
EW_SHOWWINDOW, // ShowWindow: 2: [hwnd, show state]
|
||||
#endif
|
||||
|
@ -467,6 +467,19 @@ typedef struct
|
|||
int parms[5];
|
||||
} page;
|
||||
|
||||
|
||||
// EW_LOADANDSETIMAGE flags, masks and shifts
|
||||
#define LASIS_FITCTLW 31 // Top bit because it MUST shift to a value of 0 or 1
|
||||
#define LASIF_FITCTLW ( (unsigned int)1 << LASIS_FITCTLW )
|
||||
#define LASIF_FITCTLH ( (unsigned int)1 << 30 )
|
||||
#define LASIM_IMAGE 0x00000003 // IMAGE_*
|
||||
#define LASIF_EXERES 0x00000004 // GetModuleHandle(NULL).
|
||||
#define LASIF_HWND 0x00000100 // Don't call GetDlgItem.
|
||||
#define LASIF_STRID 0x00010000
|
||||
#define LASIM_LR ( 0x0000fff0 & ~(LASIM_IMAGE|LASIF_EXERES|LASIF_HWND|LASIF_STRID) )
|
||||
#define LASIF_LR_LOADFROMFILE 0x00000010
|
||||
|
||||
|
||||
// ctlcolors text/bg color flags
|
||||
#define CC_TEXT 1
|
||||
#define CC_TEXT_SYS 2
|
||||
|
|
|
@ -4822,18 +4822,14 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
|||
case TOK_SETBRANDINGIMAGE:
|
||||
{
|
||||
SCRIPT_MSG(_T("SetBrandingImage: "));
|
||||
if (!branding_image_found) {
|
||||
ERROR_MSG(_T("\nError: no branding image found in chosen UI!\n"));
|
||||
return PS_ERROR;
|
||||
}
|
||||
ent.which=EW_SETBRANDINGIMAGE;
|
||||
ent.which=EW_LOADANDSETIMAGE;
|
||||
for (int i = 1; i < line.getnumtokens(); i++)
|
||||
if (!_tcsnicmp(line.gettoken_str(i),_T("/IMGID="),7)) {
|
||||
ent.offsets[1]=_ttoi(line.gettoken_str(i)+7);
|
||||
SCRIPT_MSG(_T("/IMGID=%d "),ent.offsets[1]);
|
||||
}
|
||||
else if (!_tcsicmp(line.gettoken_str(i),_T("/RESIZETOFIT"))) {
|
||||
ent.offsets[2]=1; // must be 1 or 0
|
||||
ent.offsets[2]=LASIF_FITCTLW|LASIF_FITCTLH;
|
||||
SCRIPT_MSG(_T("/RESIZETOFIT "));
|
||||
}
|
||||
else if (!ent.offsets[0]) {
|
||||
|
@ -4844,14 +4840,46 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
|||
SCRIPT_MSG(_T("\n"));
|
||||
PRINTHELP();
|
||||
}
|
||||
|
||||
if (!ent.offsets[1])
|
||||
ent.offsets[1]=branding_image_id;
|
||||
SCRIPT_MSG(_T("\n"));
|
||||
if (!ent.offsets[1])
|
||||
{
|
||||
ent.offsets[1]=branding_image_id;
|
||||
if (!branding_image_found) {
|
||||
ERROR_MSG(_T("\nError: no branding image found in chosen UI!\n"));
|
||||
return PS_ERROR;
|
||||
}
|
||||
}
|
||||
ent.offsets[2]|=LASIF_LR_LOADFROMFILE|LASIF_STRID;
|
||||
}
|
||||
return add_entry(&ent);
|
||||
case TOK_LOADANDSETIMAGE:
|
||||
{
|
||||
SCRIPT_MSG(_T("LoadAndSetImage: "));
|
||||
ent.which=EW_LOADANDSETIMAGE;
|
||||
int tidx = 1, conv = 1, fail = 0;
|
||||
unsigned int flags = LASIF_HWND;
|
||||
for (; tidx < line.getnumtokens(); tidx++)
|
||||
{
|
||||
if (!_tcsicmp(line.gettoken_str(tidx),_T("/EXERESOURCE"))) flags |= LASIF_EXERES;
|
||||
else if (!_tcsicmp(line.gettoken_str(tidx),_T("/STRINGID"))) flags |= LASIF_STRID;
|
||||
else if (!_tcsicmp(line.gettoken_str(tidx),_T("/RESIZETOFIT"))) flags |= LASIF_FITCTLW|LASIF_FITCTLH;
|
||||
else if (!_tcsicmp(line.gettoken_str(tidx),_T("/RESIZETOFITWIDTH"))) flags |= LASIF_FITCTLW;
|
||||
else if (!_tcsicmp(line.gettoken_str(tidx),_T("/RESIZETOFITHEIGHT"))) flags |= LASIF_FITCTLH;
|
||||
else if (!_tcsicmp(line.gettoken_str(tidx),_T("/GETDLGITEM"))) flags &= ~LASIF_HWND; // Reuses TOK_SETBRANDINGIMAGE functionality
|
||||
else { if (line.gettoken_str(tidx)[0] == '/') ++fail; break; }
|
||||
}
|
||||
ent.offsets[1]=(flags & LASIF_HWND) ? add_string(line.gettoken_str(tidx+0)) : line.gettoken_int(tidx+0, &conv); fail += !conv; // HWND/CtrlId
|
||||
flags |= (line.gettoken_int(tidx+1, &conv) & LASIM_IMAGE); fail += !conv;
|
||||
flags |= (line.gettoken_int(tidx+2, &conv) & LASIM_LR); fail += !conv;
|
||||
ent.offsets[0]=(flags & LASIF_STRID) ? add_string(line.gettoken_str(tidx+3)) : line.gettoken_int(tidx+3, &conv); fail += !conv; // Image path/resid
|
||||
ent.offsets[2]=flags;
|
||||
SCRIPT_MSG(_T("%") NPRIs _T(" %#x \"%") NPRIs _T("\" \n"), line.gettoken_str(tidx+0), flags, line.gettoken_str(tidx+3));
|
||||
if (fail) PRINTHELP();
|
||||
}
|
||||
return add_entry(&ent);
|
||||
#else
|
||||
case TOK_SETBRANDINGIMAGE:
|
||||
case TOK_LOADANDSETIMAGE:
|
||||
ERROR_MSG(_T("Error: %") NPRIs _T(" specified, NSIS_CONFIG_ENHANCEDUI_SUPPORT not defined.\n"),line.gettoken_str(0));
|
||||
return PS_ERROR;
|
||||
#endif //~ NSIS_SUPPORT_CREATEFONT
|
||||
|
|
|
@ -193,6 +193,7 @@ static tokenType tokenlist[TOK__LAST] =
|
|||
{TOK_SETAUTOCLOSE,_T("SetAutoClose"),1,0,_T("(false|true)"),TP_CODE},
|
||||
{TOK_SETCTLCOLORS,_T("SetCtlColors"),2,2,_T("hwnd [/BRANDING] [text_color] [transparent|bg_color]"),TP_CODE},
|
||||
{TOK_SETBRANDINGIMAGE,_T("SetBrandingImage"),1,2,_T("[/IMGID=image_item_id_in_dialog] [/RESIZETOFIT] bitmap.bmp"),TP_CODE},
|
||||
{TOK_LOADANDSETIMAGE,_T("LoadAndSetImage"),4,3,_T("[/EXERESOURCE] [/STRINGID] [/RESIZETOFIT[WIDTH|HEIGHT]] ctrl imagetype lrflags image"),TP_CODE},
|
||||
{TOK_SETCOMPRESS,_T("SetCompress"),1,0,_T("(off|auto|force)"),TP_ALL},
|
||||
{TOK_SETCOMPRESSOR,_T("SetCompressor"),1,2,_T("[/FINAL] [/SOLID] (zlib|bzip2|lzma)"),TP_GLOBAL},
|
||||
{TOK_SETCOMPRESSORDICTSIZE,_T("SetCompressorDictSize"),1,0,_T("dict_size_mb"),TP_ALL},
|
||||
|
|
|
@ -282,6 +282,7 @@ enum
|
|||
TOK_LOGSET,
|
||||
TOK_LOGTEXT,
|
||||
TOK_SETBRANDINGIMAGE,
|
||||
TOK_LOADANDSETIMAGE,
|
||||
TOK_SECTIONSETTEXT,
|
||||
TOK_SECTIONGETTEXT,
|
||||
TOK_SECTIONSETFLAGS,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue