nsDialogs: the next InstallOptions
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@5199 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
edd3c299f7
commit
74bf17be17
15 changed files with 1832 additions and 0 deletions
77
Contrib/nsDialogs/input.c
Normal file
77
Contrib/nsDialogs/input.c
Normal file
|
@ -0,0 +1,77 @@
|
|||
#include <windows.h>
|
||||
|
||||
#include "input.h"
|
||||
#include "defs.h"
|
||||
#include "nsis.h"
|
||||
|
||||
extern struct nsDialog g_dialog;
|
||||
|
||||
static int NSDFUNC ConvertPlacement(char *str, int total, int height)
|
||||
{
|
||||
char unit = *CharPrev(str, str + lstrlen(str));
|
||||
int x = myatoi(str);
|
||||
|
||||
if (unit == '%')
|
||||
{
|
||||
if (x < 0)
|
||||
{
|
||||
return MulDiv(total, 100 + x, 100);
|
||||
}
|
||||
|
||||
return MulDiv(total, x, 100);
|
||||
}
|
||||
else if (unit == 'u')
|
||||
{
|
||||
RECT r;
|
||||
|
||||
r.left = r.top = x;
|
||||
|
||||
MapDialogRect(g_dialog.hwParent, &r);
|
||||
|
||||
if (height)
|
||||
return x >= 0 ? r.top : total + r.top;
|
||||
else
|
||||
return x >= 0 ? r.left : total + r.left;
|
||||
}
|
||||
|
||||
if (x < 0)
|
||||
{
|
||||
return total + x;
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
int NSDFUNC PopPlacement(int *x, int *y, int *width, int *height)
|
||||
{
|
||||
RECT dialogRect;
|
||||
int dialogWidth;
|
||||
int dialogHeight;
|
||||
char buf[1024];
|
||||
|
||||
GetClientRect(g_dialog.hwDialog, &dialogRect);
|
||||
dialogWidth = dialogRect.right;
|
||||
dialogHeight = dialogRect.bottom;
|
||||
|
||||
if (popstring(buf, 1024))
|
||||
return 1;
|
||||
|
||||
*x = ConvertPlacement(buf, dialogWidth, 0);
|
||||
|
||||
if (popstring(buf, 1024))
|
||||
return 1;
|
||||
|
||||
*y = ConvertPlacement(buf, dialogHeight, 1);
|
||||
|
||||
if (popstring(buf, 1024))
|
||||
return 1;
|
||||
|
||||
*width = ConvertPlacement(buf, dialogWidth, 0);
|
||||
|
||||
if (popstring(buf, 1024))
|
||||
return 1;
|
||||
|
||||
*height = ConvertPlacement(buf, dialogHeight, 1);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue