summaryrefslogtreecommitdiff
path: root/Contrib/nsDialogs
diff options
context:
space:
mode:
Diffstat (limited to 'Contrib/nsDialogs')
-rwxr-xr-xContrib/nsDialogs/InstallOptions.nsi21
-rwxr-xr-xContrib/nsDialogs/Readme.html495
-rwxr-xr-xContrib/nsDialogs/SConscript7
-rwxr-xr-xContrib/nsDialogs/defs.h5
-rwxr-xr-xContrib/nsDialogs/input.c3
-rwxr-xr-xContrib/nsDialogs/nsDialogs.c26
-rwxr-xr-xContrib/nsDialogs/nsDialogs.nsh113
-rwxr-xr-xContrib/nsDialogs/rtl.c95
-rwxr-xr-xContrib/nsDialogs/rtl.h9
-rwxr-xr-xContrib/nsDialogs/welcome.nsi14
10 files changed, 761 insertions, 27 deletions
diff --git a/Contrib/nsDialogs/InstallOptions.nsi b/Contrib/nsDialogs/InstallOptions.nsi
index d1c002b..b2bd7e5 100755
--- a/Contrib/nsDialogs/InstallOptions.nsi
+++ b/Contrib/nsDialogs/InstallOptions.nsi
@@ -4,7 +4,7 @@
Name "nsDialogs IO"
OutFile "nsDialogs IO.exe"
-Page custom nsDialogsIO
+Page custom nsDialogsIO UpdateINIState
Page instfiles
XPStyle on
@@ -12,12 +12,17 @@ XPStyle on
ShowInstDetails show
!include nsDialogs.nsh
+!insertmacro NSD_FUNCTION_INIFILE
Function nsDialogsIO
InitPluginsDir
File /oname=$PLUGINSDIR\io.ini "${NSISDIR}\Examples\InstallOptions\test.ini"
+ ${If} ${Cmd} `MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Test the right-to-left version?" IDYES`
+ WriteINIStr $PLUGINSDIR\io.ini Settings RTL 1
+ ${EndIf}
+
StrCpy $0 $PLUGINSDIR\io.ini
Call CreateDialogFromINI
@@ -25,4 +30,18 @@ Function nsDialogsIO
FunctionEnd
Section
+
+ ReadINIStr $0 "$PLUGINSDIR\io.ini" "Field 2" "State"
+ DetailPrint "Install X=$0"
+ ReadINIStr $0 "$PLUGINSDIR\io.ini" "Field 3" "State"
+ DetailPrint "Install Y=$0"
+ ReadINIStr $0 "$PLUGINSDIR\io.ini" "Field 4" "State"
+ DetailPrint "Install Z=$0"
+ ReadINIStr $0 "$PLUGINSDIR\io.ini" "Field 5" "State"
+ DetailPrint "File=$0"
+ ReadINIStr $0 "$PLUGINSDIR\io.ini" "Field 6" "State"
+ DetailPrint "Dir=$0"
+ ReadINIStr $0 "$PLUGINSDIR\io.ini" "Field 8" "State"
+ DetailPrint "Info=$0"
+
SectionEnd
diff --git a/Contrib/nsDialogs/Readme.html b/Contrib/nsDialogs/Readme.html
new file mode 100755
index 0000000..a955edd
--- /dev/null
+++ b/Contrib/nsDialogs/Readme.html
@@ -0,0 +1,495 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html>
+<head>
+<title>nsDialogs</title>
+<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
+<style>
+b
+{
+ color: red;
+}
+code
+{
+ margin-left: 20px;
+ padding: 7px;
+ background-color: rgb(240,240,240);
+}
+</style>
+</head>
+<body>
+
+<h1>NSIS nsDialogs Plug-in</h1>
+<p><i>Next generation of user interface design</i></p>
+
+<h2>Table of Contents</h2>
+
+<ul>
+<li><a href="#intro">Introduction</a></li>
+<li>
+<a href="#step">Step-by-Step Tutorial</a>
+<ul>
+<li><a href="#step-basic">Basic Script</a></li>
+<li><a href="#step-page">Custom Page</a></li>
+<li><a href="#step-create">Creating Page</a></li>
+<li><a href="#step-show">Showing Page</a></li>
+<li><a href="#step-add">Adding Controls</a></li>
+<li><a href="#step-state">Control State</a></li>
+<li><a href="#step-notify">Real-time Notification</a></li>
+</ul>
+</li>
+<li>
+<a href="#ref">Function Reference</a>
+<ul>
+<li><a href="#ref-create">Create</a></li>
+<li><a href="#ref-createcontrol">CreateControl</a></li>
+<li><a href="#ref-show">Show</a></li>
+<li><a href="#ref-selectfiledialog">SelectFileDialog</a></li>
+<li><a href="#ref-selectfolderdialog">SelectFolderDialog</a></li>
+<li><a href="#ref-setrtl">SetRTL</a></li>
+<li><a href="#ref-getuserdata">GetUserData</a></li>
+<li><a href="#ref-setuserdata">SetUserData</a></li>
+<li><a href="#ref-onback">OnBack</a></li>
+<li><a href="#ref-onchange">OnChange</a></li>
+<li><a href="#ref-onclick">OnClick</a></li>
+<li><a href="#ref-onnotify">OnNotify</a></li>
+</ul>
+</li>
+<li><a href="#faq">FAQ</a></li>
+</ul>
+
+<h2><a name="intro"></a>Introduction</h2>
+
+<p>nsDialogs allows creation of custom pages in the installer. On top of the built-in pages, nsDialogs can create pages with any type of controls in any order and arrangement. It can create everything from a simple page with one label to form which reacts to user's actions. <a href="../Modern UI 2/Readme.html">Modern UI 2</a>, for example, uses nsDialogs to create the welcome and finish pages.</p>
+
+<p>nsDialogs is a new NSIS plug-in, introduced in version 2.29 as a replacement for <a href="../InstallOptions/Readme.html">InstallOptions</a>. nsDialogs doesn't use INI files, so it's way faster than InstallOptions. Integration with the script is tighter and more natural - creating controls is done using plug-in functions and notification is done by directly calling a function in the script. Unlike InstallOptions, there isn't a predefined set of available control type and by providing a lower level access to Windows API, every type of control can be created and pages can be more customizable.</p>
+
+<p>The same thing that makes nsDialogs more flexible can also make it more complicated for users with no knowledge of Win32 API. This is solved by creating a library of predefined functions, defined in script, that allow creation and handling of controls. This way, novices get easy access to the flexibility, while advanced users still get access to the core functionality by modifying the library or simply avoid using it.</p>
+
+<h2><a name="step"></a>Step-by-Step Tutorial</h2>
+
+<h3><a name="step-basic"></a>Basic Script</h3>
+
+<p>Before using nsDialogs, lets first create a basic script as our skeleton.</p>
+
+<blockquote><pre>Name nsDialogs
+OutFile nsDialogs.exe
+
+XPStyle on
+
+Page instfiles
+
+Section
+
+ DetailPrint "hello world"
+
+SectionEnd</pre></blockquote>
+
+<h3><a name="step-page"></a>Custom Page</h3>
+
+<p>Next, we'll add a custom page where we can use nsDialogs. nsDialogs cannot be used in sections or any other function but a custom page's function.</p>
+
+<blockquote><pre>Name nsDialogs
+OutFile nsDialogs.exe
+
+XPStyle on
+
+<b>Page custom nsDialogsPage</b>
+Page instfiles
+
+<b>Function nsDialogsPage
+FunctionEnd</b>
+
+Section
+
+ DetailPrint "hello world"
+
+SectionEnd</pre></blockquote>
+
+<h3><a name="step-create"></a>Creating Page</h3>
+
+<p>Now that the foundations are laid, it's time to use nsDialogs. The first call must always be to nsDialogs::Create. It will create a new dialog in the page and return its <i>HWND</i> on the stack. The result must be popped from the stack to prevent stack corruption. If the result is <i>error</i>, the dialog couldn't be created.</p>
+
+<p>nsDialogs::Create, like every other nsDialogs function but nsDialogs::Show, must always be called with /NOUNLOAD.</p>
+
+<p>nsDialogs::Create accepts one parameter. It has a very specific function, but to keep things simple for this tutorial, it must always be 1018.</p>
+
+<p><i>HWND</i> is a number that uniquely identifies the dialog and can be used with SendMessage, SetCtlColors and Win32 API.</p>
+
+<blockquote><pre><b>!include LogicLib.nsh</b>
+
+Name nsDialogs
+OutFile nsDialogs.exe
+
+XPStyle on
+
+<b>Var Dialog</b>
+
+Page custom nsDialogsPage
+Page instfiles
+
+Function nsDialogsPage
+<b>
+ nsDialogs::Create /NOUNLOAD 1018
+ Pop $Dialog
+
+ ${If} $Dialog == error
+ Abort
+ ${EndIf}
+</b>
+FunctionEnd
+
+Section
+
+ DetailPrint "hello world"
+
+SectionEnd</pre></blockquote>
+
+<h3><a name="step-show"></a>Showing Page</h3>
+
+<p>Now that the page is created, it's time to show it. This is done with nsDialogs::Show. This function will not return until the user clicks Next, Back or Cancel.</p>
+
+<blockquote><pre>!include LogicLib.nsh
+
+Name nsDialogs
+OutFile nsDialogs.exe
+
+XPStyle on
+
+Var Dialog
+
+Page custom nsDialogsPage
+Page instfiles
+
+Function nsDialogsPage
+ nsDialogs::Create /NOUNLOAD 1018
+ Pop $Dialog
+
+ ${If} $Dialog == error
+ Abort
+ ${EndIf}
+<b>
+ nsDialogs::Show
+</b>
+FunctionEnd
+
+Section
+
+ DetailPrint "hello world"
+
+SectionEnd</pre></blockquote>
+
+<h3><a name="step-add"></a>Adding Controls</h3>
+
+<p>Compiling the last script and running it results in an empty page which is not very useful. So now we'll add some controls to it to. To do so, we'll use ${NSD_Create*} macros from nsDialogs.nsh. Each of those macros takes 5 parameters - x, y, width, height and text. Each macro also returns one value on the stack, which is the new control's HWND. Like the dialogs HWND, it must be popped from the stack and saved.</p>
+
+<p>Each of the measurements that the macros take can use one of three unit types - pixels, dialog units or percentage of the dialog's size. It can also be negative to indicate it should be measured from the end. To use dialog units, the measurement must be suffixed with the letter <i>u</i>. To use percentage, the measurement must be suffixed with the percentage sign - <i>%</i>. Any other suffix, or no suffix, means pixels.</p>
+
+<p>Dialog units allow creation of dialogs that scale well when different fonts or DPI is used. Its size in pixels is determined on runtime based on the font and the DPI. For example, standard pages in the classic NSIS user interface are 266 dialog units wide and 130 dialog units high. Pages in Modern UI are 300 dialogs units wide and 140 dialog units high. In different resolutions, using different fonts or DPI settings, the dialogs will always have the same size in dialog units, but different size in pixels.</p>
+
+<blockquote><pre><b>!include nsDialogs.nsh</b>
+!include LogicLib.nsh
+
+Name nsDialogs
+OutFile nsDialogs.exe
+
+XPStyle on
+
+Var Dialog
+<b>Var Label
+Var Text</b>
+
+Page custom nsDialogsPage
+Page instfiles
+
+Function nsDialogsPage
+
+ nsDialogs::Create /NOUNLOAD 1018
+ Pop $Dialog
+
+ ${If} $Dialog == error
+ Abort
+ ${EndIf}
+<b>
+ ${NSD_CreateLabel} 0 0 100% 12u "Hello, welcome to nsDialogs!"
+ Pop $Label
+
+ ${NSD_CreateText} 0 13u 100% -13u "Type something here..."
+ Pop $Text
+</b>
+ nsDialogs::Show
+
+FunctionEnd
+
+Section
+
+ DetailPrint "hello world"
+
+SectionEnd</pre></blockquote>
+
+<p>Available control types that can be created with ${NSD_Create*} are:</p>
+
+<ul>
+<li>HLine</li>
+<li>VLine</li>
+<li>Label</li>
+<li>Icon</li>
+<li>Bitmap</li>
+<li>BrowseButton</li>
+<li>Link</li>
+<li>Button</li>
+<li>GroupBox</li>
+<li>CheckBox</li>
+<li>RadioButton</li>
+<li>Text</li>
+<li>FileRequest</li>
+<li>DirRequest</li>
+<li>ComboBox</li>
+<li>ListBox</li>
+</ul>
+
+<h3><a name="step-state"></a>Control State</h3>
+
+<p>Now that we have some controls that the user can interact with, it's time to see what the user actually does with them. For that, we'll first add a <i>leave callback</i> function to our page. In that function, we'll query the state of the text control we've created and display it to the user. To do so, we'll use the ${NSD_GetText} macro.</p>
+
+<p>Note that not all controls support ${NSD_GetText} and some require special handling with specific messages defined in WinMessages.nsh. For example, the ListBox control requires usage of <i>LB_GETCURSEL</i> and <i>LB_GETTEXT</i>. With time, the library of macros in nsDialogs.nsh will fill with more and more macros that'll handle more cases like this.</p>
+
+<blockquote><pre>!include nsDialogs.nsh
+!include LogicLib.nsh
+
+Name nsDialogs
+OutFile nsDialogs.exe
+
+XPStyle on
+
+Var Dialog
+Var Label
+Var Text
+
+Page custom nsDialogsPage <b>nsDialogsPageLeave</b>
+Page instfiles
+
+Function nsDialogsPage
+
+ nsDialogs::Create /NOUNLOAD 1018
+ Pop $Dialog
+
+ ${If} $Dialog == error
+ Abort
+ ${EndIf}
+
+ ${NSD_CreateLabel} 0 0 100% 12u "Hello, welcome to nsDialogs!"
+ Pop $Label
+
+ ${NSD_CreateText} 0 13u 100% -13u "Type something here..."
+ Pop $Text
+
+ nsDialogs::Show
+
+FunctionEnd
+
+<b>Function nsDialogsPageLeave
+
+ ${NSD_GetText} $Text $0
+ MessageBox MB_OK "You typed:$\n$\n$0"
+
+FunctionEnd</b>
+
+Section
+
+ DetailPrint "hello world"
+
+SectionEnd</pre></blockquote>
+
+<h3><a name="step-notify"></a>Real-time Notification</h3>
+
+<p>One of the more exciting new features of nsDialogs is callback function notification of changes to the dialog. nsDialogs can call a function defined in a script in response to a user action such as changing of a text field or click of a button. To make nsDialogs notify us of events, we'll use ${NSD_OnClick} and ${NSD_OnChange}. Not every control supports both of the events. For example, there's nothing to notify about labels.</p>
+
+<p>When the callback function is called, the control's HWND will be waiting on the stack and must be popped to prevent stack corruption. In this simple example, this is not so useful. But in case of a bigger script where several controls are associated with the same callback function, the HWND can shed some light on which control originated the event.</p>
+
+<p>The new example will respond to the user type <i>hello</i> in the text box.</p>
+
+<blockquote><pre>!include nsDialogs.nsh
+!include LogicLib.nsh
+
+Name nsDialogs
+OutFile nsDialogs.exe
+
+XPStyle on
+
+Var Dialog
+Var Label
+Var Text
+
+Page custom nsDialogsPage nsDialogsPageLeave
+Page instfiles
+
+Function nsDialogsPage
+
+ nsDialogs::Create /NOUNLOAD 1018
+ Pop $Dialog
+
+ ${If} $Dialog == error
+ Abort
+ ${EndIf}
+
+ ${NSD_CreateLabel} 0 0 100% 12u "Hello, welcome to nsDialogs!"
+ Pop $Label
+
+ ${NSD_CreateText} 0 13u 100% -13u "Type something here..."
+ Pop $Text
+ <b>${NSD_OnChange} $Text nsDialogsPageTextChange</b>
+
+ nsDialogs::Show
+
+FunctionEnd
+
+Function nsDialogsPageLeave
+
+ ${NSD_GetText} $Text $0
+ MessageBox MB_OK "You typed:$\n$\n$0"
+
+FunctionEnd
+
+<b>Function nsDialogsPageTextChange
+
+ Pop $1 # $1 == $ Text
+
+ ${NSD_GetText} $Text $0
+
+ ${If} $0 == "hello"
+
+ MessageBox MB_OK "right back at ya!"
+
+ ${EndIf}
+
+FunctionEnd</b>
+
+Section
+
+ DetailPrint "hello world"
+
+SectionEnd</pre></blockquote>
+
+<h2><a name="ref"></a>Function Reference</h2>
+
+<h3><a name="ref-create"></a>Create</h3>
+
+<p><code>nsDialogs::Create /NOUNLOAD <i>rect</i></code></p>
+
+<p>Creates a new dialog. <i>rect</i> specific the identifier of the control whose location will be mimiced. This should usually be 1018, which is control mimiced for creation of built-in pages. The Modern UI also has control 1040 for the welcome and the finish page.</p>
+
+<p>Returns the new dialog's HWND on the stack or <i>error</i>.</p>
+
+<h3><a name="ref-createcontrol"></a>CreateControl</h3>
+
+<p><code>nsDialogs::CreateControl /NOUNLOAD <i>class</i> <i>style</i> <i>extended_style</i> <i>x</i> <i>y</i> <i>width</i> <i>height</i> <i>text</i> </code></p>
+
+<p>Create a new control in the current dialog. A dialog must exist for this to work, so nsDialogs::Create must be called prior to this function.</p>
+
+<p>Returns the new dialog's HWND on the stack or <i>error</i>.</p>
+
+<h3><a name="ref-show"></a>Show</h3>
+
+<p><code>nsDialogs::Show</code></p>
+
+<p>Displays the page. Call this once finished with nsDialogs::Create, nsDialogs::CreateControl and the rest.</p>
+
+<p>Returns nothing.</p>
+
+<h3><a name="ref-selectfiledialog"></a>SelectFileDialog</h3>
+
+<p><code>nsDialogs::SelectFileDialog /NOUNLOAD <i>mode</i> <i>initial_selection</i> <i>filter</i></code></p>
+
+<p>Displays a file selection dialog to the user. If <i>mode</i> is set to <i>save</i>, displays a file save dialog. If <i>mode</i> is set to <i>open</i>, displays a file open dialog. <i>filter</i> is a list of available file filters separated by pipes. If an empty string is passed, the default is used - <i>All Files|*.*</i>.</p>
+
+<p>Returns the selected file on the stack or an empty string if the user canceled the operation.</p>
+
+<h3><a name="ref-selectfolderdialog"></a>SelectFolderDialog</h3>
+
+<p><code>nsDialogs::SelectFolderDialog /NOUNLOAD <i>title</i> <i>initial_selection</i></code></p>
+
+<p>Displays a directory selection dialog to the user.</p>
+
+<p>Returns the selected directory on the stack or an empty string if the user canceled the operation.</p>
+
+<h3><a name="ref-setrtl"></a>SetRTL</h3>
+
+<p><code>nsDialogs::SetRTL /NOUNLOAD <i>rtl_setting</i></code></p>
+
+<p>Sets right-to-left mode on or off. If <i>rtl_setting</i> is 0, it's set to off. If <i>rtl_setting</i> is 1, it's set to on. This function must be called before any calls to nsDialogs::CreateControl.</p>
+
+<p>Returns nothing.</p>
+
+<h3><a name="ref-getuserdata"></a>GetUserData</h3>
+
+<p><code>nsDialogs::GetUserData /NOUNLOAD <i>control_HWND</i></code></p>
+
+<p>Returns user data associated with the control on the stack. Use nsDialogs::SetUserData to set this data.</p>
+
+<h3><a name="ref-setuserdata"></a>SetUserData</h3>
+
+<p><code>nsDialogs::SetUserData /NOUNLOAD <i>control_HWND</i> <i>data</i></code></p>
+
+<p>Associates <i>data</i> with the control. Use nsDialogs::GetUserData to get this data.</p>
+
+<p>Returns nothing.</p>
+
+<h3><a name="ref-onback"></a>OnBack</h3>
+
+<p><code>nsDialogs::OnBack /NOUNLOAD <i>function_address</i></code></p>
+
+<p>Sets the callback function for the Back button. This function will be called when the user clicks the back button. Call Abort in this function to prevent the user from going back to the last page.</p>
+
+<p>Use GetFunctionAddress to get the address of the desired callback function.</p>
+
+<p>Returns nothing.</p>
+
+<h3><a name="ref-onchange"></a>OnChange</h3>
+
+<p><code>nsDialogs::OnChange /NOUNLOAD <i>control_HWND</i> <i>function_address</i></code></p>
+
+<p>Sets a change notification callback function for the given control. Whenever the control changes, the function will be called and the control's HWND will be waiting on its stack.</p>
+
+<p>Use GetFunctionAddress to get the address of the desired callback function.</p>
+
+<p>Returns nothing.</p>
+
+<h3><a name="ref-onclick"></a>OnClick</h3>
+
+<p><code>nsDialogs::OnClick /NOUNLOAD <i>control_HWND</i> <i>function_address</i></code></p>
+
+<p>Sets a click notification callback function for the given control. Whenever the control is clicked, the function will be called and the control's HWND will be waiting on its stack.</p>
+
+<p>Use GetFunctionAddress to get the address of the desired callback function.</p>
+
+<p>Returns nothing.</p>
+
+<h3><a name="ref-onnotify"></a>OnNotify</h3>
+
+<p><code>nsDialogs::OnNotify /NOUNLOAD <i>control_HWND</i> <i>function_address</i></code></p>
+
+<p>Sets a notification callback function for the given control. Whenever the control receives the WM_NOTIFY message, the function will be called and the control's HWND, notification code and a pointer to the MNHDR structure will be waiting on its stack.</p>
+
+<p>Use GetFunctionAddress to get the address of the desired callback function.</p>
+
+<p>Returns nothing.</p>
+
+<h2><a name="faq"></a>FAQ</h2>
+
+<div>
+
+<ul>
+
+<li>
+<b>Q:</b> Can nsDialogs handle InstallOptions INI files?
+<blockquote>
+<p><b>A:</b> nsDialogs.nsh contains a function called <i>CreateDialogFromINI</i> that can create nsDialogs' dialog from an INI file. It can handle every type of control InstallOptions supports, but doesn't handle the flags or notification yet. <i>Examples\nsDialogs\InstallOptions.nsi</i> shows a usage example of this function.</p><p>In the future there'll also be a function that creates the script itself.
+
+</li>
+
+</ul>
+
+</div>
+
+</body>
+</html> \ No newline at end of file
diff --git a/Contrib/nsDialogs/SConscript b/Contrib/nsDialogs/SConscript
index cab5fc2..bd58a4b 100755
--- a/Contrib/nsDialogs/SConscript
+++ b/Contrib/nsDialogs/SConscript
@@ -5,6 +5,7 @@ files = Split("""
input.c
nsDialogs.c
nsis.c
+ rtl.c
""")
resources = Split("""
@@ -20,6 +21,10 @@ libs = Split("""
ole32
""")
+docs = Split("""
+ Readme.html
+""")
+
examples = Split("""
example.nsi
InstallOptions.nsi
@@ -32,5 +37,5 @@ includes = Split("""
Import('BuildPlugin env')
-BuildPlugin(target, files, libs, examples, res = resources)
+BuildPlugin(target, files, libs, examples, docs, res = resources)
env.DistributeInclude(includes)
diff --git a/Contrib/nsDialogs/defs.h b/Contrib/nsDialogs/defs.h
index a7cf57e..1bf3929 100755
--- a/Contrib/nsDialogs/defs.h
+++ b/Contrib/nsDialogs/defs.h
@@ -16,7 +16,8 @@ enum nsControlType
NSCTL_LISTBOX,
NSCTL_RICHEDIT,
NSCTL_RICHEDIT2,
- NSCTL_STATIC
+ NSCTL_STATIC,
+ NSCTL_TREE
};
struct nsDialogCallbacks
@@ -52,6 +53,8 @@ struct nsDialog
WNDPROC parentOriginalWndproc;
+ BOOL rtl;
+
struct nsDialogCallbacks callbacks;
unsigned controlCount;
diff --git a/Contrib/nsDialogs/input.c b/Contrib/nsDialogs/input.c
index 6ff3dba..4129e0e 100755
--- a/Contrib/nsDialogs/input.c
+++ b/Contrib/nsDialogs/input.c
@@ -3,6 +3,7 @@
#include "input.h"
#include "defs.h"
#include "nsis.h"
+#include "rtl.h"
extern struct nsDialog g_dialog;
@@ -73,5 +74,7 @@ int NSDFUNC PopPlacement(int *x, int *y, int *width, int *height)
*height = ConvertPlacement(buf, dialogHeight, 1);
+ ConvertPosToRTL(x, *width, dialogWidth);
+
return 0;
}
diff --git a/Contrib/nsDialogs/nsDialogs.c b/Contrib/nsDialogs/nsDialogs.c
index 0289140..7533c8b 100755
--- a/Contrib/nsDialogs/nsDialogs.c
+++ b/Contrib/nsDialogs/nsDialogs.c
@@ -3,6 +3,7 @@
#include "defs.h"
#include "nsis.h"
#include "input.h"
+#include "rtl.h"
HINSTANCE g_hInstance;
struct nsDialog g_dialog;
@@ -131,6 +132,12 @@ void __declspec(dllexport) Create(HWND hwndParent, int string_size, char *variab
g_dialog.hwDialog = CreateDialog(g_hInstance, MAKEINTRESOURCE(1), hwndParent, DialogProc);
+ if (g_dialog.hwDialog == NULL)
+ {
+ pushstring("error");
+ return;
+ }
+
SetWindowPos(
g_dialog.hwDialog,
0,
@@ -143,13 +150,15 @@ void __declspec(dllexport) Create(HWND hwndParent, int string_size, char *variab
g_dialog.parentOriginalWndproc = (WNDPROC) SetWindowLong(hwndParent, DWL_DLGPROC, (long) ParentProc);
+ g_dialog.rtl = FALSE;
+
g_dialog.controlCount = 0;
g_dialog.controls = (struct nsControl*) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 0);
pushint((int) g_dialog.hwDialog);
}
-void __declspec(dllexport) CreateItem(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra)
+void __declspec(dllexport) CreateControl(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra)
{
char *className;
char *text;
@@ -165,10 +174,14 @@ void __declspec(dllexport) CreateItem(HWND hwndParent, int string_size, char *va
text = &className[g_stringsize];
if (!className)
+ {
+ pushstring("error");
return;
+ }
if (popstring(className, 0))
{
+ pushstring("error");
HeapFree(GetProcessHeap(), 0, className);
return;
}
@@ -180,6 +193,7 @@ void __declspec(dllexport) CreateItem(HWND hwndParent, int string_size, char *va
if (popstring(text, 0))
{
+ pushstring("error");
HeapFree(GetProcessHeap(), 0, className);
return;
}
@@ -211,6 +225,10 @@ void __declspec(dllexport) CreateItem(HWND hwndParent, int string_size, char *va
else
g_dialog.controls[id].type = NSCTL_UNKNOWN;
+ // apply rtl to style
+
+ ConvertStyleToRTL(g_dialog.controls[id].type, &style, &exStyle);
+
// create item's window
hwItem = CreateWindowEx(
@@ -243,6 +261,12 @@ void __declspec(dllexport) CreateItem(HWND hwndParent, int string_size, char *va
HeapFree(GetProcessHeap(), 0, className);
}
+// for backward compatibility (2.29 had CreateItem)
+void __declspec(dllexport) CreateItem(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra)
+{
+ CreateControl(hwndParent, string_size, variables, stacktop, extra);
+}
+
void __declspec(dllexport) SetUserData(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra)
{
HWND hwCtl;
diff --git a/Contrib/nsDialogs/nsDialogs.nsh b/Contrib/nsDialogs/nsDialogs.nsh
index 08cbd61..cdbac8e 100755
--- a/Contrib/nsDialogs/nsDialogs.nsh
+++ b/Contrib/nsDialogs/nsDialogs.nsh
@@ -1,3 +1,10 @@
+/*
+
+nsDialogs.nsh
+Header file for creating custom installer pages with nsDialogs
+
+*/
+
!include LogicLib.nsh
!include WinMessages.nsh
@@ -109,6 +116,12 @@
!define BS_FLAT 0x00008000
!define BS_RIGHTBUTTON ${BS_LEFTTEXT}
+!define BST_CHECKED 1
+!define BST_FOCUS 8
+!define BST_INDETERMINATE 2
+!define BST_PUSHED 4
+!define BST_UNCHECKED 0
+
!define CBS_SIMPLE 0x0001
!define CBS_DROPDOWN 0x0002
!define CBS_DROPDOWNLIST 0x0003
@@ -222,12 +235,12 @@
!define __NSD_ComboBox_EXSTYLE ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE}
!define __NSD_ListBox_CLASS LISTBOX
-!define __NSD_ListBox_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${WS_VSCROLL}|${LBS_DISABLENOSCROLL}|${LBS_HASSTRINGS}|${LBS_NOINTEGRALHEIGHT}
+!define __NSD_ListBox_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${WS_VSCROLL}|${LBS_DISABLENOSCROLL}|${LBS_HASSTRINGS}|${LBS_NOINTEGRALHEIGHT}|${LBS_NOTIFY}
!define __NSD_ListBox_EXSTYLE ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE}
!macro __NSD_DefineControl NAME
- !define NSD_Create${NAME} "nsDialogs::CreateItem /NOUNLOAD ${__NSD_${Name}_CLASS} ${__NSD_${Name}_STYLE} ${__NSD_${Name}_EXSTYLE}"
+ !define NSD_Create${NAME} "nsDialogs::CreateControl /NOUNLOAD ${__NSD_${Name}_CLASS} ${__NSD_${Name}_STYLE} ${__NSD_${Name}_EXSTYLE}"
!macroend
@@ -248,6 +261,41 @@
!insertmacro __NSD_DefineControl ComboBox
!insertmacro __NSD_DefineControl ListBox
+!macro __NSD_OnEvent EVENT HWND FUNCTION
+
+ Push $0
+ Push $1
+
+ StrCpy $1 "${HWND}"
+
+ GetFunctionAddress $0 "${FUNCTION}"
+ nsDialogs::On${EVENT} /NOUNLOAD $1 $0
+
+ Pop $1
+ Pop $0
+
+!macroend
+
+!macro __NSD_DefineCallback EVENT
+
+ !define NSD_On${EVENT} `!insertmacro __NSD_OnEvent ${EVENT}`
+
+!macroend
+
+!insertmacro __NSD_DefineCallback Click
+!insertmacro __NSD_DefineCallback Change
+!insertmacro __NSD_DefineCallback Notify
+!insertmacro __NSD_DefineCallback Back
+
+!macro __NSD_GetText CONTROL VAR
+
+ System::Call user32::GetWindowText(i${CONTROL},t.s,i${NSIS_MAX_STRLEN})
+ Pop ${VAR}
+
+!macroend
+
+!define NSD_GetText `!insertmacro __NSD_GetText`
+
!define DEBUG `System::Call kernel32::OutputDebugString(ts)`
!macro __NSD_ControlCase TYPE
@@ -267,7 +315,19 @@
!macroend
-Function CreateDialogFromINI
+!macro NSD_FUNCTION_INIFILE
+ !insertmacro NSD_INIFILE ""
+!macroend
+
+!macro NSD_UNFUNCTION_INIFILE
+ !insertmacro NSD_INIFILE un.
+!macroend
+
+!macro NSD_INIFILE UNINSTALLER_FUNCPREFIX
+
+ ;Functions to create dialogs based on old InstallOptions INI files
+
+ Function ${UNINSTALLER_FUNCPREFIX}CreateDialogFromINI
# $0 = ini
@@ -279,6 +339,9 @@ Function CreateDialogFromINI
nsDialogs::Create /NOUNLOAD $R0
Pop $R9
+ ReadINIStr $R0 $0 Settings RTL
+ nsDialogs::SetRTL /NOUNLOAD $R0
+
ReadINIStr $R0 $0 Settings NumFields
${DEBUG} "NumFields = $R0"
@@ -324,9 +387,27 @@ Function CreateDialogFromINI
nsDialogs::Show
-FunctionEnd
+ FunctionEnd
+
+ Function ${UNINSTALLER_FUNCPREFIX}UpdateINIState
-Function FileRequest
+ ${DEBUG} "Updating INI state"
+
+ ReadINIStr $R0 $0 Settings NumFields
+
+ ${DEBUG} "NumField = $R0"
+
+ ${For} $R1 1 $R0
+ ReadINIStr $R2 $0 "Field $R1" HWND
+ ${DEBUG} " HWND = $R2"
+ System::Call user32::GetWindowText(iR2,t.R2,i${NSIS_MAX_STRLEN})
+ ${DEBUG} " Window text = $R2"
+ WriteINIStr $0 "Field $R1" STATE $R2
+ ${Next}
+
+ FunctionEnd
+
+ Function ${UNINSTALLER_FUNCPREFIX}FileRequest
IntOp $R5 $R5 - 15
IntOp $R8 $R3 + $R5
@@ -338,17 +419,16 @@ Function FileRequest
WriteINIStr $0 "Field $R1" HWND2 $R8
- GetFunctionAddress $R9 OnFileBrowseButton
- nsDialogs::OnClick /NOUNLOAD $R8 $R9
+ ${NSD_OnClick} $R8 OnFileBrowseButton
ReadINIStr $R9 $0 "Field $R1" State
${NSD_CreateFileRequest} $R3u $R4u $R5u $R6u $R9
Pop $R9
-FunctionEnd
+ FunctionEnd
-Function DirRequest
+ Function ${UNINSTALLER_FUNCPREFIX}DirRequest
IntOp $R5 $R5 - 15
IntOp $R8 $R3 + $R5
@@ -360,17 +440,16 @@ Function DirRequest
WriteINIStr $0 "Field $R1" HWND2 $R8
- GetFunctionAddress $R9 OnDirBrowseButton
- nsDialogs::OnClick /NOUNLOAD $R8 $R9
+ ${NSD_OnClick} $R8 OnDirBrowseButton
ReadINIStr $R9 $0 "Field $R1" State
${NSD_CreateFileRequest} $R3u $R4u $R5u $R6u $R9
Pop $R9
-FunctionEnd
+ FunctionEnd
-Function OnFileBrowseButton
+ Function ${UNINSTALLER_FUNCPREFIX}OnFileBrowseButton
Pop $R0
@@ -389,9 +468,9 @@ Function OnFileBrowseButton
SendMessage $R2 ${WM_SETTEXT} 0 STR:$R3
${EndIf}
-FunctionEnd
+ FunctionEnd
-Function OnDirBrowseButton
+ Function ${UNINSTALLER_FUNCPREFIX}OnDirBrowseButton
Pop $R0
@@ -410,4 +489,6 @@ Function OnDirBrowseButton
SendMessage $R2 ${WM_SETTEXT} 0 STR:$R3
${EndIf}
-FunctionEnd
+ FunctionEnd
+
+!macroend
diff --git a/Contrib/nsDialogs/rtl.c b/Contrib/nsDialogs/rtl.c
new file mode 100755
index 0000000..e68ba32
--- /dev/null
+++ b/Contrib/nsDialogs/rtl.c
@@ -0,0 +1,95 @@
+#include <windows.h>
+#include <commctrl.h>
+
+#include "defs.h"
+#include "nsis.h"
+
+#ifndef WS_EX_RIGHT
+# define WS_EX_RIGHT 0x1000
+#endif
+
+#ifndef WS_EX_RTLREADING
+# define WS_EX_RTLREADING 0x2000
+#endif
+
+#ifndef WS_EX_LEFTSCROLLBAR
+# define WS_EX_LEFTSCROLLBAR 0x4000
+#endif
+
+#ifndef TVS_RTLREADING
+# define TVS_RTLREADING 64
+#endif
+
+extern struct nsDialog g_dialog;
+
+void __declspec(dllexport) SetRTL(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra)
+{
+ g_dialog.rtl = (BOOL) popint();
+}
+
+void NSDFUNC ConvertStyleToRTL(enum nsControlType type, LPDWORD style, LPDWORD exStyle)
+{
+ if (!g_dialog.rtl)
+ return;
+
+ switch (type)
+ {
+ case NSCTL_BUTTON:
+ *style ^= BS_LEFTTEXT | BS_RIGHT | BS_LEFT;
+
+ if ((*style & (BS_LEFT|BS_RIGHT)) == (BS_LEFT|BS_RIGHT))
+ {
+ *style ^= BS_LEFT | BS_RIGHT;
+ if (*style & (BS_RADIOBUTTON | BS_CHECKBOX | BS_USERBUTTON))
+ {
+ *style |= BS_RIGHT;
+ }
+ }
+ break;
+
+ case NSCTL_EDIT:
+ if ((*style & ES_CENTER) == 0)
+ {
+ *style ^= ES_RIGHT;
+ }
+ break;
+
+ case NSCTL_STATIC:
+ if ((*style & SS_TYPEMASK) == SS_LEFT || (*style & SS_TYPEMASK) == SS_LEFTNOWORDWRAP)
+ {
+ *style &= ~SS_TYPEMASK;
+ *style |= SS_RIGHT;
+ }
+ else if ((*style & SS_TYPEMASK) == SS_ICON) {
+ *style |= SS_CENTERIMAGE;
+ }
+ break;
+
+ case NSCTL_RICHEDIT:
+ case NSCTL_RICHEDIT2:
+ if ((*style & ES_CENTER) == 0)
+ {
+ *style ^= ES_RIGHT;
+ }
+ break;
+
+ case NSCTL_TREE:
+ *style |= TVS_RTLREADING;
+ *exStyle |= WS_EX_RIGHT;
+ break;
+
+ default:
+ *exStyle |= WS_EX_RIGHT;
+ break;
+ }
+
+ *exStyle |= WS_EX_RTLREADING | WS_EX_LEFTSCROLLBAR;
+}
+
+void NSDFUNC ConvertPosToRTL(int *x, int width, int dialogWidth)
+{
+ if (!g_dialog.rtl)
+ return;
+
+ *x = dialogWidth - width - *x;
+}
diff --git a/Contrib/nsDialogs/rtl.h b/Contrib/nsDialogs/rtl.h
new file mode 100755
index 0000000..7c36e64
--- /dev/null
+++ b/Contrib/nsDialogs/rtl.h
@@ -0,0 +1,9 @@
+#ifndef __NS_DIALOGS__RTL_H__
+#define __NS_DIALOGS__RTL_H__
+
+#include "defs.h"
+
+void NSDFUNC ConvertStyleToRTL(enum nsControlType type, LPDWORD style, LPDWORD exStyle);
+void NSDFUNC ConvertPosToRTL(int *x, int width, int dialogWidth);
+
+#endif//__NS_DIALOGS__RTL_H__
diff --git a/Contrib/nsDialogs/welcome.nsi b/Contrib/nsDialogs/welcome.nsi
index 8fa77a4..c2d741f 100755
--- a/Contrib/nsDialogs/welcome.nsi
+++ b/Contrib/nsDialogs/welcome.nsi
@@ -200,7 +200,7 @@ Function nsDialogsWelcome
nsDialogs::Create /NOUNLOAD 1044
Pop $DIALOG
- nsDialogs::CreateItem /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${SS_BITMAP} 0 0 0 109u 193u ""
+ nsDialogs::CreateControl /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${SS_BITMAP} 0 0 0 109u 193u ""
Pop $IMAGECTL
StrCpy $0 $PLUGINSDIR\welcome.bmp
@@ -209,12 +209,12 @@ Function nsDialogsWelcome
SendMessage $IMAGECTL ${STM_SETIMAGE} ${IMAGE_BITMAP} $IMAGE
- nsDialogs::CreateItem /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 120u 10u -130u 20u "Welcome to nsDialogs!"
+ nsDialogs::CreateControl /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 120u 10u -130u 20u "Welcome to nsDialogs!"
Pop $HEADLINE
SendMessage $HEADLINE ${WM_SETFONT} $HEADLINE_FONT 0
- nsDialogs::CreateItem /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 120u 32u -130u -32u "nsDialogs is the next generation of user interfaces in NSIS. It gives the developer full control over custom pages. Some of the features include control text containing variables, callbacks directly into script functions and creation of any type of control. Create boring old edit boxes or load some external library and create custom controls with no need of creating your own plug-in.$\r$\n$\r$\nUnlike InstallOptions, nsDialogs doesn't use INI files to communicate with the script. By interacting directly with the script, nsDialogs can perform much faster without the need of costly, old and inefficient INI operations. Direct interaction also allows direct calls to functions defined in the script and removes the need of conversion functions like Io2Nsis.$\r$\n$\r$\nHit the Next button to see how it all fits into a mock directory page."
+ nsDialogs::CreateControl /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 120u 32u -130u -32u "nsDialogs is the next generation of user interfaces in NSIS. It gives the developer full control over custom pages. Some of the features include control text containing variables, callbacks directly into script functions and creation of any type of control. Create boring old edit boxes or load some external library and create custom controls with no need of creating your own plug-in.$\r$\n$\r$\nUnlike InstallOptions, nsDialogs doesn't use INI files to communicate with the script. By interacting directly with the script, nsDialogs can perform much faster without the need of costly, old and inefficient INI operations. Direct interaction also allows direct calls to functions defined in the script and removes the need of conversion functions like Io2Nsis.$\r$\n$\r$\nHit the Next button to see how it all fits into a mock directory page."
Pop $TEXT
SetCtlColors $DIALOG "" 0xffffff
@@ -243,15 +243,15 @@ Function nsDialogsDirectory
nsDialogs::Create /NOUNLOAD 1018
Pop $DIALOG
- nsDialogs::CreateItem /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${SS_CENTER} 0 0 0 100% 30 "Directory page"
+ nsDialogs::CreateControl /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${SS_CENTER} 0 0 0 100% 30 "Directory page"
Pop $HEADLINE
SendMessage $HEADLINE ${WM_SETFONT} $HEADLINE_FONT 0
- nsDialogs::CreateItem /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 0 30 100% 40 "Select the installation directory of NSIS to continue. $_CLICK"
+ nsDialogs::CreateControl /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 0 30 100% 40 "Select the installation directory of NSIS to continue. $_CLICK"
Pop $TEXT
- nsDialogs::CreateItem /NOUNLOAD EDIT ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${ES_AUTOHSCROLL}|${WS_TABSTOP} ${WS_EX_CLIENTEDGE} 0 75 100% 12u ""
+ nsDialogs::CreateControl /NOUNLOAD EDIT ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${ES_AUTOHSCROLL}|${WS_TABSTOP} ${WS_EX_CLIENTEDGE} 0 75 100% 12u ""
Pop $DIRECTORY
SendMessage $HWNDPARENT ${WM_NEXTDLGCTL} $DIRECTORY 1
@@ -261,7 +261,7 @@ Function nsDialogsDirectory
System::Call shlwapi::SHAutoComplete(i$DIRECTORY,i${SHACF_FILESYSTEM})
- nsDialogs::CreateItem /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 0 -10u 100% 10u ""
+ nsDialogs::CreateControl /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 0 -10u 100% 10u ""
Pop $FREESPACE
Call UpdateFreeSpace