AddBrandingImage doesn't depend on the UI now. Can now set the branding image on the bottom and on the right too, and set a custom padding value
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@2334 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
3ae6d897b8
commit
156648c9d5
6 changed files with 50 additions and 21 deletions
|
@ -224,6 +224,16 @@ CDialogTemplate::~CDialogTemplate() {
|
|||
// Methods
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Returns the width of the dialog
|
||||
short CDialogTemplate::GetWidth() {
|
||||
return m_sWidth;
|
||||
}
|
||||
|
||||
// Returns the height of the dialog
|
||||
short CDialogTemplate::GetHeight() {
|
||||
return m_sHeight;
|
||||
}
|
||||
|
||||
// Returns info about the item with the id wId
|
||||
DialogItemTemplate* CDialogTemplate::GetItem(WORD wId) {
|
||||
for (unsigned int i = 0; i < m_vItems.size(); i++)
|
||||
|
@ -288,14 +298,16 @@ void CDialogTemplate::AddItem(DialogItemTemplate item) {
|
|||
m_vItems.push_back(newItem);
|
||||
}
|
||||
|
||||
// Moves all of the items in the dialog by (x,y) and resizes the dialog by (x,y)
|
||||
void CDialogTemplate::MoveAllAndResize(short x, short y) {
|
||||
// Move all items
|
||||
// Moves all of the items in the dialog by (x,y)
|
||||
void CDialogTemplate::MoveAll(short x, short y) {
|
||||
for (unsigned int i = 0; i < m_vItems.size(); i++) {
|
||||
m_vItems[i]->sX += x;
|
||||
m_vItems[i]->sY += y;
|
||||
}
|
||||
// Resize
|
||||
}
|
||||
|
||||
// Resizes the dialog by (x,y)
|
||||
void CDialogTemplate::Resize(short x, short y) {
|
||||
m_sWidth += x;
|
||||
m_sHeight += y;
|
||||
}
|
||||
|
|
|
@ -92,13 +92,16 @@ public:
|
|||
CDialogTemplate(BYTE* pbData);
|
||||
virtual ~CDialogTemplate();
|
||||
|
||||
short GetWidth();
|
||||
short GetHeight();
|
||||
DialogItemTemplate* GetItem(WORD wId);
|
||||
DialogItemTemplate* GetItemByIdx(DWORD i);
|
||||
void RemoveItem(WORD wId);
|
||||
void SetFont(char* szFaceName, WORD wFontSize);
|
||||
void AddItem(DialogItemTemplate item);
|
||||
HWND CreateDummyDialog();
|
||||
void MoveAllAndResize(short x, short y);
|
||||
void MoveAll(short x, short y);
|
||||
void Resize(short x, short y);
|
||||
void PixelsToDlgUnits(short& x, short& y);
|
||||
void DlgUnitsToPixels(short& x, short& y);
|
||||
SIZE GetStringSize(WORD id, char *str);
|
||||
|
|
|
@ -1522,9 +1522,12 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
|
|||
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT
|
||||
case TOK_ADDBRANDINGIMAGE:
|
||||
try {
|
||||
int k=line.gettoken_enum(1,"top\0left\0");
|
||||
int k=line.gettoken_enum(1,"top\0left\0bottom\0right\0");
|
||||
int wh=line.gettoken_int(2);
|
||||
if (k == -1) PRINTHELP()
|
||||
if (k == -1) PRINTHELP();
|
||||
int padding = 2;
|
||||
if (line.getnumtokens() == 4)
|
||||
padding = line.gettoken_int(3);
|
||||
|
||||
init_res_editor();
|
||||
BYTE* dlg = res_editor->GetResource(RT_DIALOG, MAKEINTRESOURCE(IDD_INST), MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
|
@ -1536,8 +1539,8 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
|
|||
DialogItemTemplate brandingCtl = {0,};
|
||||
|
||||
brandingCtl.dwStyle = SS_BITMAP | WS_CHILD | WS_VISIBLE;
|
||||
brandingCtl.sX = childRect->sX;
|
||||
brandingCtl.sY = childRect->sY;
|
||||
brandingCtl.sX = padding;
|
||||
brandingCtl.sY = padding;
|
||||
brandingCtl.szClass = MAKEINTRESOURCE(0x0082);
|
||||
brandingCtl.szTitle = "";
|
||||
brandingCtl.wId = IDC_BRANDIMAGE;
|
||||
|
@ -1545,18 +1548,29 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
|
|||
brandingCtl.sHeight = wh;
|
||||
brandingCtl.sWidth = wh;
|
||||
dt.PixelsToDlgUnits(brandingCtl.sWidth, brandingCtl.sHeight);
|
||||
if (k) {
|
||||
// Left
|
||||
dt.MoveAllAndResize(brandingCtl.sWidth + childRect->sX, 0);
|
||||
if (k%2) {
|
||||
// left (1) / right (3)
|
||||
|
||||
DialogItemTemplate *okButton = dt.GetItem(IDOK);
|
||||
brandingCtl.sHeight = okButton->sY + okButton->sHeight - childRect->sY;
|
||||
if (k & 2) // right
|
||||
brandingCtl.sX += dt.GetWidth();
|
||||
else // left
|
||||
dt.MoveAll(brandingCtl.sWidth + (padding * 2), 0);
|
||||
|
||||
dt.Resize(brandingCtl.sWidth + (padding * 2), 0);
|
||||
|
||||
brandingCtl.sHeight = dt.GetHeight() - (padding * 2);
|
||||
}
|
||||
else {
|
||||
// Top
|
||||
dt.MoveAllAndResize(0, brandingCtl.sHeight + childRect->sY);
|
||||
// top (0) / bottom (2)
|
||||
|
||||
brandingCtl.sWidth = childRect->sWidth;
|
||||
if (k & 2) // bottom
|
||||
brandingCtl.sY += dt.GetHeight();
|
||||
else // top
|
||||
dt.MoveAll(0, brandingCtl.sHeight + (padding * 2));
|
||||
|
||||
dt.Resize(0, brandingCtl.sHeight + (padding * 2));
|
||||
|
||||
brandingCtl.sWidth = dt.GetWidth() - (padding * 2);
|
||||
}
|
||||
|
||||
dt.AddItem(brandingCtl);
|
||||
|
|
|
@ -18,7 +18,7 @@ typedef struct
|
|||
static tokenType tokenlist[TOK__LAST] =
|
||||
{
|
||||
{TOK_ABORT,"Abort",0,1,"[message]"},
|
||||
{TOK_ADDBRANDINGIMAGE,"AddBrandingImage",2,0,"(top|left) (height|width)"},
|
||||
{TOK_ADDBRANDINGIMAGE,"AddBrandingImage",2,1,"(top|left|bottom|right) (height|width) [padding]"},
|
||||
{TOK_ADDSIZE,"AddSize",1,0,"size_to_add_to_section_in_kb"},
|
||||
{TOK_AUTOCLOSE,"AutoCloseWindow",1,0,"(false|true)"},
|
||||
{TOK_BGGRADIENT,"BGGradient",0,3,"(off | [top_color [bottom_color [text_color]]])"},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue