Caption parameter for custom pages

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@1662 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2002-11-11 15:11:49 +00:00
parent 10d868f72b
commit fdd5119f75
5 changed files with 42 additions and 20 deletions

View file

@ -1058,7 +1058,8 @@ int CEXEBuild::resolve_coderefs(const char *str)
int i = 0; int i = 0;
while (i < build_uninst.common.num_pages) { 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","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 (p->id != NSIS_PAGE_CUSTOM)
if (resolve_call_int("uninstall pages","post-page function",p->postfunc,&p->postfunc)) return 1;
p++; p++;
i++; i++;
} }
@ -1089,7 +1090,8 @@ int CEXEBuild::resolve_coderefs(const char *str)
int i = 0; int i = 0;
while (i < build_header.common.num_pages) { 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","pre-page function",p->prefunc,&p->prefunc)) return 1;
if (resolve_call_int("pages","post-page function",p->postfunc,&p->postfunc)) return 1; if (p->id != NSIS_PAGE_CUSTOM)
if (resolve_call_int("pages","post-page function",p->postfunc,&p->postfunc)) return 1;
p++; p++;
i++; i++;
} }

View file

@ -518,6 +518,17 @@ nextPage:
if (this_page->id!=NSIS_PAGE_COMPLETED) DestroyWindow(m_curwnd); if (this_page->id!=NSIS_PAGE_COMPLETED) DestroyWindow(m_curwnd);
else if (g_autoclose) goto nextPage; else if (g_autoclose) goto nextPage;
if (this_page->id==NSIS_PAGE_CUSTOM) // custom page
{
mystrcpy(g_tmp,g_caption);
process_string_fromtab(
g_tmp+mystrlen(g_tmp),
this_page->caption // post_func contains the caption for custom functions
);
SetWindowText(hwndDlg,g_tmp);
}
#ifdef NSIS_SUPPORT_CODECALLBACKS #ifdef NSIS_SUPPORT_CODECALLBACKS
if (ExecuteCodeSegment(this_page->prefunc,NULL) || this_page->id<0) if (ExecuteCodeSegment(this_page->prefunc,NULL) || this_page->id<0)
goto nextPage; goto nextPage;

View file

@ -460,7 +460,13 @@ typedef struct
int id; // index in the pages array int id; // index in the pages array
#ifdef NSIS_SUPPORT_CODECALLBACKS #ifdef NSIS_SUPPORT_CODECALLBACKS
int prefunc; // function to use Abort in, or show the custom page if id == NSIS_PAGE_CUSTOM 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 union
{
int postfunc; // function to do stuff after the page is shown
#endif //NSIS_SUPPORT_CODECALLBACKS
int caption; // caption for custom pages
#ifdef NSIS_SUPPORT_CODECALLBACKS
};
#endif //NSIS_SUPPORT_CODECALLBACKS #endif //NSIS_SUPPORT_CODECALLBACKS
int next; int next;
int back; int back;

View file

@ -534,11 +534,10 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
if (*line.gettoken_str(2)) if (*line.gettoken_str(2))
p.prefunc = ns_func.add(line.gettoken_str(2),0); p.prefunc = ns_func.add(line.gettoken_str(2),0);
if (line.getnumtokens()>3) { if (line.getnumtokens()>3) {
if (k==0) { if (k)
ERROR_MSG("\nError: custom page don't need post creation functions!\n"); p.postfunc = ns_func.add(line.gettoken_str(3),0);
PRINTHELP(); else
} p.caption = add_string_main(line.gettoken_str(3),0);
p.postfunc = ns_func.add(line.gettoken_str(3),0);
} }
#else #else
ERROR_MSG("Error: Page callback specified, NSIS_CONFIG_LICENSEPAGE not defined.\n"); ERROR_MSG("Error: Page callback specified, NSIS_CONFIG_LICENSEPAGE not defined.\n");
@ -584,8 +583,10 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
#ifdef NSIS_SUPPORT_CODECALLBACKS #ifdef NSIS_SUPPORT_CODECALLBACKS
if (p.prefunc>=0) if (p.prefunc>=0)
SCRIPT_MSG(" (%s:%s)", k?"pre":"creator", line.gettoken_str(2)); SCRIPT_MSG(" (%s:%s)", k?"pre":"creator", line.gettoken_str(2));
if (p.postfunc>=0) if (p.postfunc>=0 && k)
SCRIPT_MSG(" (post:%s)", line.gettoken_str(3)); SCRIPT_MSG(" (post:%s)", line.gettoken_str(3));
else if (p.caption && !k)
SCRIPT_MSG(" (caption:%s)", line.gettoken_str(3));
#endif #endif
SCRIPT_MSG("\n"); SCRIPT_MSG("\n");
@ -626,15 +627,15 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
p.prefunc = ns_func.add(line.gettoken_str(2),0); p.prefunc = ns_func.add(line.gettoken_str(2),0);
} }
if (line.getnumtokens()>3) { if (line.getnumtokens()>3) {
if (k==0) { if (k) {
ERROR_MSG("\nError: custom page don't need post creation functions!\n"); if (strnicmp(line.gettoken_str(3),"un.",3)) {
PRINTHELP(); ERROR_MSG("\nError: function must have a un. prefix!\n");
return PS_ERROR;
}
p.postfunc = ns_func.add(line.gettoken_str(3),0);
} }
if (strnicmp(line.gettoken_str(3),"un.",3)) { else
ERROR_MSG("\nError: function must have a un. prefix!\n"); p.caption = add_string_uninst(line.gettoken_str(3),0);
return PS_ERROR;
}
p.postfunc = ns_func.add(line.gettoken_str(3),0);
} }
#else #else
ERROR_MSG("Error: UninstPage callback specified, NSIS_CONFIG_LICENSEPAGE not defined.\n"); ERROR_MSG("Error: UninstPage callback specified, NSIS_CONFIG_LICENSEPAGE not defined.\n");
@ -664,8 +665,10 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char
#ifdef NSIS_SUPPORT_CODECALLBACKS #ifdef NSIS_SUPPORT_CODECALLBACKS
if (p.prefunc>=0) if (p.prefunc>=0)
SCRIPT_MSG(" (%s:%s)", k?"pre":"creator", line.gettoken_str(2)); SCRIPT_MSG(" (%s:%s)", k?"pre":"creator", line.gettoken_str(2));
if (p.postfunc>=0) if (p.postfunc>=0 && k)
SCRIPT_MSG(" (post:%s)", line.gettoken_str(3)); SCRIPT_MSG(" (post:%s)", line.gettoken_str(3));
else if (p.caption && !k)
SCRIPT_MSG(" (caption:%s)", line.gettoken_str(3));
#endif #endif
SCRIPT_MSG("\n"); SCRIPT_MSG("\n");

View file

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