Added MULTILINE support for edit box, better tab order between ReqFile, DirReq and it's browse button
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@2626 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
397234a5bd
commit
8270d8bdca
7 changed files with 150 additions and 18 deletions
|
@ -1,3 +1,9 @@
|
|||
DLL version 2.2 (6/10/2003)
|
||||
* \r\n converts to newline in Multiline edit box
|
||||
* Support for multiline edit box
|
||||
* Better tab order in DirRequest and FileRequest
|
||||
* Minor fixes
|
||||
|
||||
DLL version 2.1 (3/15/2003)
|
||||
* \r\n converts to newline in both label Text and ValidateText
|
||||
* New browse dialog style (modern)
|
||||
|
|
|
@ -71,7 +71,7 @@ char *STRDUP(const char *c)
|
|||
// text box flags
|
||||
#define FLAG_PASSWORD 0x00000040
|
||||
#define FLAG_ONLYNUMBERS 0x00000080
|
||||
//#define FLAG_MULTILINE 0x00000100
|
||||
#define FLAG_MULTILINE 0x00000100
|
||||
|
||||
// listbox flags
|
||||
#define FLAG_MULTISELECT 0x00000200
|
||||
|
@ -89,6 +89,11 @@ char *STRDUP(const char *c)
|
|||
|
||||
// OFN_EXPLORER 0x00080000
|
||||
|
||||
// more text box flags
|
||||
#define FLAG_WANTRETURN 0x00100000
|
||||
#define FLAG_VSCROLL 0x00200000
|
||||
#define FLAG_HSCROLL 0x00400000
|
||||
|
||||
struct TableEntry {
|
||||
char *pszName;
|
||||
int nValue;
|
||||
|
@ -310,9 +315,13 @@ bool SaveSettings(void) {
|
|||
char *pszBuffer = (char*)MALLOC(nBufLen);
|
||||
if (!pszBuffer) return false;
|
||||
|
||||
int CurrField = 1;
|
||||
for(nIdx = 0; nIdx < nNumFields; nIdx++) {
|
||||
if ( pFields[nIdx].nType == FIELD_BROWSEBUTTON )
|
||||
continue;
|
||||
|
||||
hwnd = pFields[nIdx].hwnd;
|
||||
wsprintf(szField, "Field %d", nIdx + 1);
|
||||
wsprintf(szField, "Field %d", CurrField);
|
||||
switch(pFields[nIdx].nType) {
|
||||
case FIELD_CHECKBOX:
|
||||
case FIELD_RADIOBUTTON:
|
||||
|
@ -363,11 +372,40 @@ bool SaveSettings(void) {
|
|||
pszBuffer = (char*)MALLOC(nBufLen);
|
||||
if (!pszBuffer) return false;
|
||||
}
|
||||
GetWindowText(hwnd, pszBuffer, nBufLen);
|
||||
*pszBuffer='"';
|
||||
GetWindowText(hwnd, pszBuffer+1, nBufLen-1);
|
||||
pszBuffer[nLength+1]='"';
|
||||
pszBuffer[nLength+2]='\0';
|
||||
if ( pFields[nIdx].nType == FIELD_TEXT && pFields[nIdx].nFlags & FLAG_MULTILINE )
|
||||
{
|
||||
char *pszBuf2 = (char*)MALLOC(nBufLen*2); // double the size, consider the worst case, all chars are \r\n
|
||||
char *p1, *p2;
|
||||
for (p1=pszBuffer,p2=pszBuf2; *p1; p1++, p2++) {
|
||||
if (*p1 == '\r') {
|
||||
*p2++ = '\\';
|
||||
*p2 = 'r';
|
||||
}
|
||||
else if (*p1 == '\n') {
|
||||
*p2++ = '\\';
|
||||
*p2 = 'n';
|
||||
}
|
||||
else if (*p1 == '\t') {
|
||||
*p2++ = '\\';
|
||||
*p2 = 't';
|
||||
}
|
||||
else
|
||||
*p2=*p1;
|
||||
}
|
||||
*p2 = 0;
|
||||
nBufLen = nBufLen*2;
|
||||
FREE(pszBuffer);
|
||||
pszBuffer=pszBuf2;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
WritePrivateProfileString(szField, "STATE", pszBuffer, pszFilename);
|
||||
CurrField++;
|
||||
}
|
||||
|
||||
FREE(pszBuffer);
|
||||
|
@ -389,8 +427,20 @@ void AddBrowseButtons() {
|
|||
switch (pFields[nIdx].nType) {
|
||||
case FIELD_FILEREQUEST:
|
||||
case FIELD_DIRREQUEST:
|
||||
pNewField = &pFields[nNumFields];
|
||||
// nNumFields functions as the index of the new control, increment at *end* of loop
|
||||
// Insert button after edit, tabstop depends in creation order,
|
||||
// with this trick browse button get tabstop after parent edit
|
||||
if ( nIdx < nNumFields - 1 )
|
||||
{
|
||||
CopyMemory(&pFields[nIdx+2], &pFields[nIdx+1], (nNumFields-nIdx-1)*sizeof(FieldType) );
|
||||
for ( int i = nIdx+2; i < nNumFields; i++ )
|
||||
{
|
||||
if ( pFields[i].nType == FIELD_BROWSEBUTTON )
|
||||
pFields[i].nParentIdx++; // Ohh! where is your dady :)
|
||||
}
|
||||
}
|
||||
// After moving controls 1 position, don't forget to increment nNumFields at *end* of loop
|
||||
pNewField = &pFields[nIdx+1];
|
||||
ZeroMemory(pNewField, sizeof(FieldType)); // don't use settings from other control
|
||||
pNewField->nControlID = 1200 + nNumFields;
|
||||
pNewField->nParentIdx = nIdx;
|
||||
pNewField->nType = FIELD_BROWSEBUTTON;
|
||||
|
@ -398,7 +448,7 @@ void AddBrowseButtons() {
|
|||
//pNewField->pszListItems = NULL;
|
||||
//pNewField->nMaxLength = 0;
|
||||
//pNewField->nMinLength = 0;
|
||||
pNewField->pszText = szBrowseButtonCaption; //STRDUP("...");
|
||||
pNewField->pszText = STRDUP(szBrowseButtonCaption); // needed for generic FREE
|
||||
//pNewField->pszValidateText = NULL;
|
||||
|
||||
pNewField->rect.right = pFields[nIdx].rect.right;
|
||||
|
@ -491,7 +541,10 @@ bool ReadSettings(void) {
|
|||
{ "DISABLED", FLAG_DISABLED },
|
||||
{ "NOTABSTOP", FLAG_NOTABSTOP },
|
||||
{ "ONLY_NUMBERS", FLAG_ONLYNUMBERS },
|
||||
//{ "MULTILINE", FLAG_MULTILINE },
|
||||
{ "MULTILINE", FLAG_MULTILINE },
|
||||
{ "VSCROLL", FLAG_VSCROLL },
|
||||
{ "HSCROLL", FLAG_HSCROLL },
|
||||
{ "WANTRETURN", FLAG_WANTRETURN },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
|
@ -858,8 +911,17 @@ int createCfgDlg()
|
|||
dwStyle |= ES_PASSWORD;
|
||||
if (pFields[nIdx].nFlags & FLAG_ONLYNUMBERS)
|
||||
dwStyle |= ES_NUMBER;
|
||||
/*if (pFields[nIdx].nFlags & FLAG_MULTILINE)
|
||||
dwStyle |= ES_WANTRETURN | ES_MULTILINE;*/
|
||||
if (pFields[nIdx].nFlags & FLAG_MULTILINE)
|
||||
{
|
||||
dwStyle |= ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL;
|
||||
ConvertNewLines(pFields[nIdx].pszState);
|
||||
}
|
||||
if ( pFields[nIdx].nFlags & FLAG_WANTRETURN )
|
||||
dwStyle |= ES_WANTRETURN;
|
||||
if (pFields[nIdx].nFlags & FLAG_VSCROLL)
|
||||
dwStyle |= WS_VSCROLL;
|
||||
if (pFields[nIdx].nFlags & FLAG_HSCROLL)
|
||||
dwStyle |= WS_HSCROLL;
|
||||
title = pFields[nIdx].pszState;
|
||||
break;
|
||||
case FIELD_COMBOBOX:
|
||||
|
|
|
@ -394,7 +394,7 @@ numbers from 1 to NumFields. Each Field section can contain the following values
|
|||
<td class="righttable">Add this flag to the first control of a group
|
||||
of controls to group them. Grouping controls allows you to create multiple
|
||||
groups of radio button and makes keyboard navigation using arrow keys
|
||||
easier.</td></tr>
|
||||
easier.</td></tr>
|
||||
<tr>
|
||||
<td class="righttable">NOTABSTOP</td>
|
||||
<td class="righttable">Do not stop on the control when the user pressed
|
||||
|
@ -455,6 +455,50 @@ value of a Field using ReadINIStr:</p>
|
|||
<pre class="margin">
|
||||
ReadINIStr $R0 "$PLUGINSDIR\test.ini" "Field 1" "State"
|
||||
</pre>
|
||||
<p class="text"> Important Note:</p>
|
||||
<p class="text"> For Multiline edit
|
||||
boxe's the output "State" comes with "\r\n" if text as more
|
||||
than one line and is your responsiblity to convert it inside script to
|
||||
"$\r$\n" if needed! example macro:</p>
|
||||
<pre class="margin">NORMALIZE_CRCF VALUE
|
||||
push $1 ; Index
|
||||
push $2 ; Output char by char
|
||||
push $3 ; Output char by char next
|
||||
push $4 ; Text Accumulator
|
||||
|
||||
StrCpy $1 "0"
|
||||
DONEXT:
|
||||
StrCpy $2 ${VALUE} 1 $1
|
||||
IntOp $1 $1 + 1
|
||||
StrCpy $3 ${VALUE} 1 $1
|
||||
StrCmp $3 "" EOT
|
||||
StrCmp $2 "\" 0 NORMAL_CHAR
|
||||
StrCmp $3 "r" FOUND_CR
|
||||
StrCmp $3 "n" 0 NORMAL_CHAR
|
||||
;FOUND_LF:
|
||||
StrCpy $4 "$4$\r"
|
||||
IntOp $1 $1 + 1
|
||||
goto DONEXT
|
||||
|
||||
FOUND_CR:
|
||||
StrCpy $4 "$4$\n"
|
||||
IntOp $1 $1 + 1
|
||||
goto DONEXT
|
||||
|
||||
NORMAL_CHAR:
|
||||
StrCpy $4 "$4$2"
|
||||
goto DONEXT
|
||||
|
||||
EOT:
|
||||
StrCpy ${VALUE} $4
|
||||
pop $4
|
||||
pop $3
|
||||
pop $2
|
||||
pop $1
|
||||
|
||||
!macroend
|
||||
</pre>
|
||||
<pre class="margin"> </pre>
|
||||
<p class="subheader">Validate the input</p>
|
||||
<p class="text">If you want to validate the input on the page,
|
||||
for example, you want to check whether the user has filled in
|
||||
|
@ -535,6 +579,15 @@ FunctionEnd
|
|||
</pre>
|
||||
<p class="header">Version history</p>
|
||||
<ul>
|
||||
<li>DLL version 2.2 (6/10/2003)
|
||||
<ul>
|
||||
<li>\r\n converts to newline in Multiline edit box</li>
|
||||
<li>Support for multiline edit box</li>
|
||||
<li>Better tab order in DirRequest and FileRequest</li>
|
||||
<li>Minor fixes</li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li>DLL version 2.1 (3/15/2003)
|
||||
<ul>
|
||||
<li>\r\n converts to newline in both label Text and ValidateText</li>
|
||||
|
|
|
@ -44,7 +44,7 @@ RSC=rc.exe
|
|||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "INSTOPTDLL_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "INSTOPTDLL_EXPORTS" /D "WIN32_LEAN_AND_MEAN" /FD /c
|
||||
# SUBTRACT CPP /FA<none> /YX
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
|
@ -54,8 +54,8 @@ BSC32=bscmake.exe
|
|||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /map /machine:I386 /nodefaultlib /out:"../../Plugins/InstallOptions.dll" /opt:nowin98
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /map /machine:I386 /out:"../../Plugins/InstallOptions.dll" /opt:nowin98
|
||||
# SUBTRACT LINK32 /pdb:none /nodefaultlib
|
||||
|
||||
!ELSEIF "$(CFG)" == "io - Win32 Debug"
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[Settings]
|
||||
NumFields=7
|
||||
NumFields=8
|
||||
|
||||
[Field 1]
|
||||
Type=GroupBox
|
||||
|
@ -7,7 +7,7 @@ Left=0
|
|||
Right=-1
|
||||
Top=0
|
||||
Bottom=-5
|
||||
Text=This is a group box...
|
||||
Text=" This is a group box... "
|
||||
|
||||
[Field 2]
|
||||
Type=checkbox
|
||||
|
@ -64,4 +64,13 @@ Left=10
|
|||
Right=-10
|
||||
Top=90
|
||||
Bottom=98
|
||||
Text=This is a label...
|
||||
Text=This is a label...
|
||||
|
||||
[Field 8]
|
||||
Type=Text
|
||||
Left=10
|
||||
Right=-10
|
||||
Top=98
|
||||
Bottom=120
|
||||
State="Multiline\r\nedit..."
|
||||
Flags=MULTILINE|VSCROLL|WANTRETURN
|
|
@ -38,6 +38,8 @@ Section "Components"
|
|||
DetailPrint "File=${TEMP1}"
|
||||
ReadINIStr ${TEMP1} "$PLUGINSDIR\test.ini" "Field 6" "State"
|
||||
DetailPrint "Dir=${TEMP1}"
|
||||
ReadINIStr ${TEMP1} "$PLUGINSDIR\test.ini" "Field 8" "State"
|
||||
DetailPrint "Info=${TEMP1}"
|
||||
|
||||
SectionEnd
|
||||
|
||||
|
@ -54,7 +56,7 @@ FunctionEnd
|
|||
Function SetCustom
|
||||
|
||||
;Display the InstallOptions dialog
|
||||
|
||||
|
||||
Push ${TEMP1}
|
||||
|
||||
InstallOptions::dialog "$PLUGINSDIR\test.ini"
|
||||
|
@ -79,4 +81,4 @@ Function ValidateCustom
|
|||
|
||||
done:
|
||||
|
||||
FunctionEnd
|
||||
FunctionEnd
|
||||
|
|
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue