| 1 |
// Unicode support by Jim Park -- 08/24/2007 |
| 2 |
|
| 3 |
#include <windows.h> |
| 4 |
|
| 5 |
#include <nsis/pluginapi.h> // nsis plugin |
| 6 |
|
| 7 |
#include "input.h" |
| 8 |
#include "defs.h" |
| 9 |
#include "rtl.h" |
| 10 |
|
| 11 |
extern struct nsDialog g_dialog; |
| 12 |
|
| 13 |
static int NSDFUNC ConvertPlacement(TCHAR *str, int total, int height) |
| 14 |
{ |
| 15 |
TCHAR unit = *CharPrev(str, str + lstrlen(str)); |
| 16 |
int x = myatoi(str); |
| 17 |
|
| 18 |
if (unit == _T('%')) |
| 19 |
{ |
| 20 |
if (x < 0) |
| 21 |
{ |
| 22 |
return MulDiv(total, 100 + x, 100); |
| 23 |
} |
| 24 |
|
| 25 |
return MulDiv(total, x, 100); |
| 26 |
} |
| 27 |
else if (unit == _T('u')) |
| 28 |
{ |
| 29 |
RECT r; |
| 30 |
|
| 31 |
r.left = r.top = x; |
| 32 |
r.right = r.bottom = 0; |
| 33 |
|
| 34 |
MapDialogRect(g_dialog.hwParent, &r); |
| 35 |
|
| 36 |
if (height) |
| 37 |
return x >= 0 ? r.top : total + r.top; |
| 38 |
else |
| 39 |
return x >= 0 ? r.left : total + r.left; |
| 40 |
} |
| 41 |
|
| 42 |
if (x < 0) |
| 43 |
{ |
| 44 |
return total + x; |
| 45 |
} |
| 46 |
|
| 47 |
return x; |
| 48 |
} |
| 49 |
|
| 50 |
int NSDFUNC PopPlacement(int *x, int *y, int *width, int *height) |
| 51 |
{ |
| 52 |
RECT dialogRect; |
| 53 |
int dialogWidth; |
| 54 |
int dialogHeight; |
| 55 |
TCHAR buf[1024]; |
| 56 |
|
| 57 |
GetClientRect(g_dialog.hwDialog, &dialogRect); |
| 58 |
dialogWidth = dialogRect.right; |
| 59 |
dialogHeight = dialogRect.bottom; |
| 60 |
|
| 61 |
if (popstringn(buf, 1024)) |
| 62 |
return 1; |
| 63 |
|
| 64 |
*x = ConvertPlacement(buf, dialogWidth, 0); |
| 65 |
|
| 66 |
if (popstringn(buf, 1024)) |
| 67 |
return 1; |
| 68 |
|
| 69 |
*y = ConvertPlacement(buf, dialogHeight, 1); |
| 70 |
|
| 71 |
if (popstringn(buf, 1024)) |
| 72 |
return 1; |
| 73 |
|
| 74 |
*width = ConvertPlacement(buf, dialogWidth, 0); |
| 75 |
|
| 76 |
if (popstringn(buf, 1024)) |
| 77 |
return 1; |
| 78 |
|
| 79 |
*height = ConvertPlacement(buf, dialogHeight, 1); |
| 80 |
|
| 81 |
ConvertPosToRTL(x, *width, dialogWidth); |
| 82 |
|
| 83 |
return 0; |
| 84 |
} |