+ Leave function for pages

+ Components page text always shown if Page components used


git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@2080 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2003-01-24 19:40:20 +00:00
parent c10483f967
commit 0aed08e3f7
8 changed files with 162 additions and 73 deletions

View file

@ -387,16 +387,16 @@
;Extract InstallOptions INI Files
!insertmacro MUI_INSTALLOPTIONS_EXTRACT_AS "${MUI_SPECIALINI}" "ioSpecial.ini"
!insertmacro MUI_INSTALLOPTIONS_EXTRACT_AS "${MUI_SPECIALBITMAP}" "modern-wizard.bmp"
;Write bitmap location
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 1" "Text" "$PLUGINSDIR\modern-wizard.bmp"
;Write Welcome text
!ifdef MUI_WELCOMEPAGE
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 2" "Text" "$(MUI_TEXT_WELCOME_INFO_TITLE)"
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 3" "Text" "$(MUI_TEXT_WELCOME_INFO_TEXT)"
!endif
!macroend
!macro MUI_LANGUAGE LANGUAGE
@ -533,7 +533,7 @@
!endif
!ifdef MUI_COMPONENTSPAGE
Page components SetComponents SetComponentsDialog "MUI_INSTALLBUTTON_COMPONENTS"
Page components SetComponents SetComponentsDialog "" "MUI_INSTALLBUTTON_COMPONENTS"
!endif
!ifndef MUI_NOVERBOSE
@ -553,7 +553,7 @@
!endif
!ifdef MUI_DIRECTORYPAGE
Page directory SetDirectory SetDirectoryDialog "MUI_INSTALLBUTTON_DIRECTORY"
Page directory SetDirectory SetDirectoryDialog "" "MUI_INSTALLBUTTON_DIRECTORY"
!endif
!ifndef MUI_NOVERBOSE
@ -652,7 +652,7 @@
!endif
!ifdef MUI_UNCONFIRMPAGE
UninstPage uninstConfirm un.SetUninstConfirm "" "MUI_UNINSTALLBUTTON_CONFIRM"
UninstPage uninstConfirm un.SetUninstConfirm "" "" "MUI_UNINSTALLBUTTON_CONFIRM"
!endif
!ifndef MUI_NOVERBOSE
@ -1755,7 +1755,7 @@
!ifndef MUI_BRANDINGTEXT
!define MUI_BRANDINGTEXT ""
!endif
!insertmacro MUI_LANGUAGEFILE_NSISCOMMAND "BrandingText /TRIMRIGHT" "MUI_BRANDINGTEXT"
!insertmacro MUI_LANGUAGEFILE_NSISCOMMAND "BrandingText" "MUI_BRANDINGTEXT"
!ifdef MUI_WELCOMEPAGE
!insertmacro MUI_LANGUAGEFILE_LANGSTRING "MUI_TEXT_WELCOME_INFO_TITLE"

View file

@ -1087,7 +1087,8 @@ int CEXEBuild::resolve_coderefs(const char *str)
int i = 0;
while (i < build_uninst.common.num_pages) {
if (resolve_call_int("uninstall pages","pre-page function",p->prefunc,&p->prefunc)) return 1;
if (resolve_call_int("uninstall pages","post-page function",p->postfunc,&p->postfunc)) return 1;
if (resolve_call_int("uninstall pages","show-page function",p->showfunc,&p->showfunc)) return 1;
if (resolve_call_int("uninstall pages","leave-page function",p->leavefunc,&p->leavefunc)) return 1;
p++;
i++;
}
@ -1118,7 +1119,8 @@ int CEXEBuild::resolve_coderefs(const char *str)
int i = 0;
while (i < build_header.common.num_pages) {
if (resolve_call_int("pages","pre-page function",p->prefunc,&p->prefunc)) return 1;
if (resolve_call_int("pages","post-page function",p->postfunc,&p->postfunc)) return 1;
if (resolve_call_int("pages","show-page function",p->showfunc,&p->showfunc)) return 1;
if (resolve_call_int("pages","leave-page function",p->leavefunc,&p->leavefunc)) return 1;
p++;
i++;
}
@ -1288,6 +1290,7 @@ int CEXEBuild::write_output(void)
#ifdef NSIS_SUPPORT_CODECALLBACKS
-1,
-1,
-1,
#endif
0
};

View file

@ -159,7 +159,7 @@ class CEXEBuild {
#define IsSet(s,lang) _IsSet(string_tables.size()?&(string_tables[0]->s):0,lang)
bool _IsSet(int *str, LANGID lang); // Checks if a string is set in a given string table
bool next_used, install_used;
bool next_used, install_used, comppage_used;
// a whole bunch O data.

View file

@ -124,9 +124,12 @@ static BOOL NSISCALL SetDlgItemTextFromLang_(HWND dlg, int id, int lid) {
#define GetUIItem(it) GetDlgItem(hwndDlg,it)
#ifdef NSIS_CONFIG_ENHANCEDUI_SUPPORT
#define HandleStaticBkColor() _HandleStaticBkColor(uMsg, lParam)
static BOOL NSISCALL _HandleStaticBkColor(UINT uMsg, LPARAM lParam) {
if (uMsg == WM_CTLCOLORSTATIC) return (BOOL)GetWindowLong((HWND)lParam, GWL_USERDATA);
#define HandleStaticBkColor() _HandleStaticBkColor(uMsg, wParam, lParam)
static BOOL NSISCALL _HandleStaticBkColor(UINT uMsg, WPARAM wParam, LPARAM lParam) {
if (uMsg == WM_CTLCOLORSTATIC) {
SetBkMode((HDC)wParam, TRANSPARENT);
return (BOOL)GetWindowLong((HWND)lParam, GWL_USERDATA);
}
return 0;
}
#else
@ -499,10 +502,15 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
this_page=g_inst_page+m_page;
// if the last page was a custom page, wait for it to finish by itself.
// if it doesn't, it's a BAD plugin.
// plugins should react to WM_NOTIFY_OUTER_NEXT.
if (m_page>=0&&this_page->id<0) return 0;
if (m_page>=0) {
// if the last page was a custom page, wait for it to finish by itself.
// if it doesn't, it's a BAD plugin.
// plugins should react to WM_NOTIFY_OUTER_NEXT.
if (this_page->id<0) return 0;
// Call leave function. If Abort used don't move to the next page.
if (m_delta==1) if (ExecuteCodeSegment(this_page->leavefunc,NULL)) return 0;
}
nextPage:
@ -557,7 +565,7 @@ nextPage:
ScreenToClient(hwndDlg,(LPPOINT)&r);
SetWindowPos(m_curwnd,0,r.left,r.top,0,0,SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOZORDER);
#ifdef NSIS_SUPPORT_CODECALLBACKS
ExecuteCodeSegment(this_page->postfunc,NULL);
ExecuteCodeSegment(this_page->showfunc,NULL);
#endif //NSIS_SUPPORT_CODECALLBACKS
ShowWindow(m_curwnd,SW_SHOWNA);
SendMessage(m_curwnd, WM_NOTIFY_START, 0, 0);

View file

@ -460,8 +460,9 @@ typedef struct
{
int id; // index in the pages array
#ifdef NSIS_SUPPORT_CODECALLBACKS
int prefunc; // function to use Abort in, or show the custom page if id == NSIS_PAGE_CUSTOM
int postfunc; // function to do stuff after the page is shown
int prefunc; // called before the page is created, or if custom to show the it. Allows to skip the page using Abort.
int showfunc; // function to do stuff right before page is shown
int leavefunc; // function to do stuff after the page is shown
#endif //NSIS_SUPPORT_CODECALLBACKS
int caption; // caption tab
int next;

View file

@ -360,7 +360,7 @@ void CEXEBuild::FillDefaultsIfNeeded(StringTable *table, NLF *nlf/*=0*/) {
else c=build_strlist.get()[sec->name_ptr];
if (c && c != '-' && !(sec->flags&SF_RO)) iscp++;
}
if (iscp)
if (iscp || comppage_used)
{
if (!table->installer.custom) table->installer.custom=add_string_main(str(NLF_COMP_CUSTOM),0);
if (!table->common.subcaptions[1])

View file

@ -556,33 +556,60 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
#ifdef NSIS_SUPPORT_CODECALLBACKS
-1,
-1,
-1,
#endif
0
};
if (line.getnumtokens()>2) {
#ifndef NSIS_SUPPORT_CODECALLBACKS
if (!k) {
ERROR_MSG("Error: custom page specified, NSIS_SUPPORT_CODECALLBACKS not defined.\n");
return PS_ERROR;
}
#endif//!NSIS_SUPPORT_CODECALLBACKS
if (k) {
// not custom
#ifdef NSIS_SUPPORT_CODECALLBACKS
if (*line.gettoken_str(2))
p.prefunc = ns_func.add(line.gettoken_str(2),0);
if (line.getnumtokens()>3) {
if (k) {
switch (line.getnumtokens()) {
case 6:
lstrcpy(build_last_page_define, line.gettoken_str(5));
case 5:
if (*line.gettoken_str(4))
p.leavefunc = ns_func.add(line.gettoken_str(4),0);
case 4:
if (*line.gettoken_str(3))
p.postfunc = ns_func.add(line.gettoken_str(3),0);
}
else
p.caption = add_string_main(line.gettoken_str(3),0);
if (line.getnumtokens()>4)
lstrcpy(build_last_page_define, line.gettoken_str(4));
p.showfunc = ns_func.add(line.gettoken_str(3),0);
case 3:
if (*line.gettoken_str(2))
p.prefunc = ns_func.add(line.gettoken_str(2),0);
}
#else
ERROR_MSG("Error: Page callback specified, NSIS_CONFIG_LICENSEPAGE not defined.\n");
return PS_ERROR;
#endif
if (line.getnumtokens() == 3)
lstrcpy(build_last_page_define, line.gettoken_str(2));
#endif//NSIS_SUPPORT_CODECALLBACKS
}
else if (k==0) {
ERROR_MSG("\nError: custom page must have a creator function!\n");
PRINTHELP();
#ifdef NSIS_SUPPORT_CODECALLBACKS
else {
// a custom page
switch (line.getnumtokens()) {
case 6:
ERROR_MSG("Error: custom page can not have more than the creator function.\n");
return PS_ERROR;
case 5:
lstrcpy(build_last_page_define, line.gettoken_str(4));
case 4:
p.caption = add_string_main(line.gettoken_str(3));
case 3:
if (*line.gettoken_str(2))
p.prefunc = ns_func.add(line.gettoken_str(2),0);
break;
case 2:
ERROR_MSG("\nError: custom page must have a creator function!\n");
PRINTHELP();
}
}
#endif//NSIS_SUPPORT_CODECALLBACKS
switch (k) {
case 0:
@ -602,6 +629,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
#ifdef NSIS_CONFIG_COMPONENTPAGE
p.id = NSIS_PAGE_SELCOM;
p.caption = LANG_SUBCAPTION(1);
comppage_used++;
break;
#else
ERROR_MSG("Error: %s specified, NSIS_CONFIG_COMPONENTPAGE not defined.\n", line.gettoken_str(1));
@ -623,8 +651,10 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
#ifdef NSIS_SUPPORT_CODECALLBACKS
if (p.prefunc>=0)
SCRIPT_MSG(" (%s:%s)", k?"pre":"creator", line.gettoken_str(2));
if (p.postfunc>=0 && k)
SCRIPT_MSG(" (post:%s)", line.gettoken_str(3));
if (p.showfunc>=0 && k)
SCRIPT_MSG(" (show:%s)", line.gettoken_str(3));
if (p.leavefunc>=0 && k)
SCRIPT_MSG(" (leave:%s)", line.gettoken_str(3));
else if (p.caption && !k)
SCRIPT_MSG(" (caption:%s)", line.gettoken_str(3));
#endif
@ -636,7 +666,8 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
p.id=NSIS_PAGE_COMPLETED;
#ifdef NSIS_SUPPORT_CODECALLBACKS
p.prefunc = -1;
p.postfunc = -1;
p.showfunc = -1;
p.leavefunc = -1;
#endif
p.caption = LANG_SUBCAPTION(4);
build_pages.add(&p,sizeof(page));
@ -655,45 +686,80 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
#ifdef NSIS_SUPPORT_CODECALLBACKS
-1,
-1,
-1,
#endif
0
};
if (line.getnumtokens()>2) {
#ifndef NSIS_SUPPORT_CODECALLBACKS
if (!k) {
ERROR_MSG("Error: custom page specified, NSIS_SUPPORT_CODECALLBACKS not defined.\n");
return PS_ERROR;
}
#endif//!NSIS_SUPPORT_CODECALLBACKS
if (k) {
// not custom
#ifdef NSIS_SUPPORT_CODECALLBACKS
if (*line.gettoken_str(2)) {
if (*line.gettoken_str(2)) {
if (strnicmp(line.gettoken_str(2),"un.",3)) {
ERROR_MSG("\nError: function must have a un. prefix!\n");
return PS_ERROR;
}
p.prefunc = ns_func.add(line.gettoken_str(2),0);
}
}
if (line.getnumtokens()>3) {
if (k) {
if (*line.gettoken_str(3)) {
if (strnicmp(line.gettoken_str(3),"un.",3)) {
ERROR_MSG("\nError: function must have a un. prefix!\n");
switch (line.getnumtokens()) {
case 6:
lstrcpy(ubuild_last_page_define, line.gettoken_str(5));
case 5:
if (*line.gettoken_str(4)) {
if (strnicmp(line.gettoken_str(4),"un.",3)) {
ERROR_MSG("\nError: uninstall function must have a un. prefix!\n");
return PS_ERROR;
}
p.postfunc = ns_func.add(line.gettoken_str(3),0);
p.leavefunc = ns_func.add(line.gettoken_str(4),0);
}
case 4:
if (*line.gettoken_str(3)) {
if (strnicmp(line.gettoken_str(3),"un.",3)) {
ERROR_MSG("\nError: uninstall function must have a un. prefix!\n");
return PS_ERROR;
}
p.showfunc = ns_func.add(line.gettoken_str(3),0);
}
case 3:
if (*line.gettoken_str(2)) {
if (strnicmp(line.gettoken_str(2),"un.",3)) {
ERROR_MSG("\nError: uninstall function must have a un. prefix!\n");
return PS_ERROR;
}
p.prefunc = ns_func.add(line.gettoken_str(2),0);
}
}
else
p.caption = add_string_uninst(line.gettoken_str(3),0);
if (line.getnumtokens()>4)
lstrcpy(ubuild_last_page_define, line.gettoken_str(4));
}
#else
ERROR_MSG("Error: UninstPage callback specified, NSIS_CONFIG_LICENSEPAGE not defined.\n");
return PS_ERROR;
#endif
if (line.getnumtokens() == 3)
lstrcpy(ubuild_last_page_define, line.gettoken_str(2));
#endif//NSIS_SUPPORT_CODECALLBACKS
}
else if (k==0) {
ERROR_MSG("\nError: custom page must have a creator function!\n");
PRINTHELP();
#ifdef NSIS_SUPPORT_CODECALLBACKS
else {
// a custom page
switch (line.getnumtokens()) {
case 6:
ERROR_MSG("Error: custom page can not have more than the creator function.\n");
return PS_ERROR;
case 5:
lstrcpy(ubuild_last_page_define, line.gettoken_str(4));
case 4:
p.caption = add_string_uninst(line.gettoken_str(3));
case 3:
if (*line.gettoken_str(2)) {
if (strnicmp(line.gettoken_str(2),"un.",3)) {
ERROR_MSG("\nError: uninstall function must have a un. prefix!\n");
return PS_ERROR;
}
p.prefunc = ns_func.add(line.gettoken_str(2),0);
}
break;
case 2:
ERROR_MSG("\nError: custom page must have a creator function!\n");
PRINTHELP();
}
}
#endif//NSIS_SUPPORT_CODECALLBACKS
switch (k) {
case 0:
@ -716,8 +782,10 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
#ifdef NSIS_SUPPORT_CODECALLBACKS
if (p.prefunc>=0)
SCRIPT_MSG(" (%s:%s)", k?"pre":"creator", line.gettoken_str(2));
if (p.postfunc>=0 && k)
SCRIPT_MSG(" (post:%s)", line.gettoken_str(3));
if (p.showfunc>=0 && k)
SCRIPT_MSG(" (show:%s)", line.gettoken_str(3));
if (p.showfunc>=0 && k)
SCRIPT_MSG(" (leave:%s)", line.gettoken_str(4));
else if (p.caption && !k)
SCRIPT_MSG(" (caption:%s)", line.gettoken_str(3));
#endif
@ -729,7 +797,8 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
p.id=NSIS_PAGE_COMPLETED;
#ifdef NSIS_SUPPORT_CODECALLBACKS
p.prefunc=-1;
p.postfunc=-1;
p.showfunc=-1;
p.leavefunc=-1;
#endif
p.caption=LANG_SUBCAPTION(2);
ubuild_pages.add(&p,sizeof(page));

View file

@ -105,7 +105,11 @@ static tokenType tokenlist[TOK__LAST] =
{TOK_NOP,"Nop",0,0,""},
{TOK_NAME,"Name",1,1,"[/LANG=lang_id] installer_name"},
{TOK_OUTFILE,"OutFile",1,0,"install_output.exe"},
{TOK_PAGE,"Page",1,3,"(custom function [caption]) | ((license|components|directory|instfiles) [pre_function] [post_function])"},
#ifdef NSIS_SUPPORT_CODECALLBACKS
{TOK_PAGE,"Page",1,4,"(custom function [caption]) | ((license|components|directory|instfiles) [pre_function] [show_function] [leave_function])"},
#else
{TOK_PAGE,"Page",1,1,"license|components|directory|instfiles"},
#endif
{TOK_POP,"Pop",1,0,"$(user_var: output)"},
{TOK_PUSH,"Push",1,0,"string"},
{TOK_QUIT,"Quit",0,0,""},
@ -159,7 +163,11 @@ static tokenType tokenlist[TOK__LAST] =
{TOK_UNINSTALLEXENAME,"UninstallExeName",0,0,"no longer supported, use WriteUninstaller from section."},
{TOK_UNINSTCAPTION,"UninstallCaption",1,1,"[/LANG=lang_id] uninstaller_caption"},
{TOK_UNINSTICON,"UninstallIcon",1,0,"icon_on_local_system.ico"},
{TOK_UNINSTPAGE,"UninstPage",1,3,"(custom function [caption]) | ((uninstConfirm|instfiles) [pre_function] [post_function])"},
#ifdef NSIS_SUPPORT_CODECALLBACKS
{TOK_UNINSTPAGE,"UninstPage",1,4,"(custom function [caption]) | ((uninstConfirm|instfiles) [pre_function] [show_function] [leave_function])"},
#else
{TOK_UNINSTPAGE,"UninstPage",1,1,"uninstConfirm|instfiles"},
#endif
{TOK_UNINSTTEXT,"UninstallText",1,2,"[/LANG=lang_id] Text_to_go_on_uninstall page [subtext]"},
{TOK_UNINSTSUBCAPTION,"UninstallSubCaption",2,1,"[/LANG=lang_id] page_number(0-2) new_subcaption"},
{TOK_UNREGDLL,"UnRegDLL",1,0,"dll_path_on_target.dll"},