summaryrefslogtreecommitdiff
path: root/src/ui/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/util.c')
-rw-r--r--src/ui/util.c71
1 files changed, 36 insertions, 35 deletions
diff --git a/src/ui/util.c b/src/ui/util.c
index 16dea8d9..3c40d4a5 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -319,7 +319,7 @@ iWidget *makePadding_Widget(int size) {
319} 319}
320 320
321iLabelWidget *makeHeading_Widget(const char *text) { 321iLabelWidget *makeHeading_Widget(const char *text) {
322 iLabelWidget *heading = new_LabelWidget(text, 0, 0, NULL); 322 iLabelWidget *heading = new_LabelWidget(text, NULL);
323 setFlags_Widget(as_Widget(heading), frameless_WidgetFlag | fixedSize_WidgetFlag, iTrue); 323 setFlags_Widget(as_Widget(heading), frameless_WidgetFlag | fixedSize_WidgetFlag, iTrue);
324 setBackgroundColor_Widget(as_Widget(heading), none_ColorId); 324 setBackgroundColor_Widget(as_Widget(heading), none_ColorId);
325 return heading; 325 return heading;
@@ -338,7 +338,7 @@ iWidget *makeHDiv_Widget(void) {
338} 338}
339 339
340iWidget *addAction_Widget(iWidget *parent, int key, int kmods, const char *command) { 340iWidget *addAction_Widget(iWidget *parent, int key, int kmods, const char *command) {
341 iLabelWidget *action = new_LabelWidget("", key, kmods, command); 341 iLabelWidget *action = newKeyMods_LabelWidget("", key, kmods, command);
342 setSize_Widget(as_Widget(action), zero_I2()); 342 setSize_Widget(as_Widget(action), zero_I2());
343 addChildFlags_Widget(parent, iClob(action), hidden_WidgetFlag); 343 addChildFlags_Widget(parent, iClob(action), hidden_WidgetFlag);
344 return as_Widget(action); 344 return as_Widget(action);
@@ -394,7 +394,7 @@ iWidget *makeMenu_Widget(iWidget *parent, const iMenuItem *items, size_t n) {
394 else { 394 else {
395 iLabelWidget *label = addChildFlags_Widget( 395 iLabelWidget *label = addChildFlags_Widget(
396 menu, 396 menu,
397 iClob(new_LabelWidget(item->label, item->key, item->kmods, item->command)), 397 iClob(newKeyMods_LabelWidget(item->label, item->key, item->kmods, item->command)),
398 frameless_WidgetFlag | alignLeft_WidgetFlag | drawKey_WidgetFlag); 398 frameless_WidgetFlag | alignLeft_WidgetFlag | drawKey_WidgetFlag);
399 updateSize_LabelWidget(label); /* drawKey was set */ 399 updateSize_LabelWidget(label); /* drawKey was set */
400 } 400 }
@@ -462,7 +462,7 @@ int checkContextMenu_Widget(iWidget *menu, const SDL_Event *ev) {
462} 462}
463 463
464iLabelWidget *makeMenuButton_LabelWidget(const char *label, const iMenuItem *items, size_t n) { 464iLabelWidget *makeMenuButton_LabelWidget(const char *label, const iMenuItem *items, size_t n) {
465 iLabelWidget *button = new_LabelWidget(label, 0, 0, "menu.open"); 465 iLabelWidget *button = new_LabelWidget(label, "menu.open");
466 iWidget *menu = makeMenu_Widget(as_Widget(button), items, n); 466 iWidget *menu = makeMenu_Widget(as_Widget(button), items, n);
467 setId_Widget(menu, "menu"); 467 setId_Widget(menu, "menu");
468 return button; 468 return button;
@@ -538,7 +538,7 @@ static void addTabPage_Widget_(iWidget *tabs, enum iWidgetAddPos addPos, iWidget
538 iWidget * buttons = findChild_Widget(tabs, "tabs.buttons"); 538 iWidget * buttons = findChild_Widget(tabs, "tabs.buttons");
539 iWidget * button = addChildPos_Widget( 539 iWidget * button = addChildPos_Widget(
540 buttons, 540 buttons,
541 iClob(new_LabelWidget(label, key, kmods, format_CStr("tabs.switch page:%p", page))), 541 iClob(newKeyMods_LabelWidget(label, key, kmods, format_CStr("tabs.switch page:%p", page))),
542 addPos); 542 addPos);
543 setFlags_Widget(buttons, hidden_WidgetFlag, iFalse); 543 setFlags_Widget(buttons, hidden_WidgetFlag, iFalse);
544 setFlags_Widget(button, selected_WidgetFlag, isSel); 544 setFlags_Widget(button, selected_WidgetFlag, isSel);
@@ -732,7 +732,7 @@ void makeFilePath_Widget(iWidget * parent,
732 iWidget *dlg = makeSheet_Widget(command); 732 iWidget *dlg = makeSheet_Widget(command);
733 setCommandHandler_Widget(dlg, filePathHandler_); 733 setCommandHandler_Widget(dlg, filePathHandler_);
734 addChild_Widget(parent, iClob(dlg)); 734 addChild_Widget(parent, iClob(dlg));
735 addChildFlags_Widget(dlg, iClob(new_LabelWidget(title, 0, 0, NULL)), frameless_WidgetFlag); 735 addChildFlags_Widget(dlg, iClob(new_LabelWidget(title, NULL)), frameless_WidgetFlag);
736 iInputWidget *input = addChild_Widget(dlg, iClob(new_InputWidget(0))); 736 iInputWidget *input = addChild_Widget(dlg, iClob(new_InputWidget(0)));
737 if (initialPath) { 737 if (initialPath) {
738 setText_InputWidget(input, collect_String(makeRelative_Path(initialPath))); 738 setText_InputWidget(input, collect_String(makeRelative_Path(initialPath)));
@@ -742,8 +742,8 @@ void makeFilePath_Widget(iWidget * parent,
742 addChild_Widget(dlg, iClob(makePadding_Widget(gap_UI))); 742 addChild_Widget(dlg, iClob(makePadding_Widget(gap_UI)));
743 iWidget *div = new_Widget(); { 743 iWidget *div = new_Widget(); {
744 setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); 744 setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue);
745 addChild_Widget(div, iClob(new_LabelWidget("Cancel", SDLK_ESCAPE, 0, "filepath.cancel"))); 745 addChild_Widget(div, iClob(newKeyMods_LabelWidget("Cancel", SDLK_ESCAPE, 0, "filepath.cancel")));
746 addChild_Widget(div, iClob(new_LabelWidget(acceptLabel, SDLK_RETURN, 0, "filepath.accept"))); 746 addChild_Widget(div, iClob(newKeyMods_LabelWidget(acceptLabel, SDLK_RETURN, 0, "filepath.accept")));
747 } 747 }
748 addChild_Widget(dlg, iClob(div)); 748 addChild_Widget(dlg, iClob(div));
749 centerSheet_Widget(dlg); 749 centerSheet_Widget(dlg);
@@ -818,10 +818,10 @@ iWidget *makeValueInput_Widget(iWidget *parent, const iString *initialValue, con
818 addChild_Widget(parent, iClob(dlg)); 818 addChild_Widget(parent, iClob(dlg));
819 } 819 }
820 setId_Widget( 820 setId_Widget(
821 addChildFlags_Widget(dlg, iClob(new_LabelWidget(title, 0, 0, NULL)), frameless_WidgetFlag), 821 addChildFlags_Widget(dlg, iClob(new_LabelWidget(title, NULL)), frameless_WidgetFlag),
822 "valueinput.title"); 822 "valueinput.title");
823 setId_Widget( 823 setId_Widget(
824 addChildFlags_Widget(dlg, iClob(new_LabelWidget(prompt, 0, 0, NULL)), frameless_WidgetFlag), 824 addChildFlags_Widget(dlg, iClob(new_LabelWidget(prompt, NULL)), frameless_WidgetFlag),
825 "valueinput.prompt"); 825 "valueinput.prompt");
826 iInputWidget *input = addChild_Widget(dlg, iClob(new_InputWidget(0))); 826 iInputWidget *input = addChild_Widget(dlg, iClob(new_InputWidget(0)));
827 if (initialValue) { 827 if (initialValue) {
@@ -832,12 +832,13 @@ iWidget *makeValueInput_Widget(iWidget *parent, const iString *initialValue, con
832 addChild_Widget(dlg, iClob(makePadding_Widget(gap_UI))); 832 addChild_Widget(dlg, iClob(makePadding_Widget(gap_UI)));
833 iWidget *div = new_Widget(); { 833 iWidget *div = new_Widget(); {
834 setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); 834 setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue);
835 addChild_Widget(div, iClob(new_LabelWidget("Cancel", SDLK_ESCAPE, 0, "cancel"))); 835 addChild_Widget(div, iClob(newKeyMods_LabelWidget("Cancel", SDLK_ESCAPE, 0, "cancel")));
836 addChild_Widget(div, 836 addChild_Widget(
837 iClob(new_LabelWidget(acceptLabel ? acceptLabel : uiTextAction_ColorEscape "OK", 837 div,
838 SDLK_RETURN, 838 iClob(newKeyMods_LabelWidget(acceptLabel ? acceptLabel : uiTextAction_ColorEscape "OK",
839 0, 839 SDLK_RETURN,
840 "valueinput.accept"))); 840 0,
841 "valueinput.accept")));
841 } 842 }
842 addChild_Widget(dlg, iClob(div)); 843 addChild_Widget(dlg, iClob(div));
843 centerSheet_Widget(dlg); 844 centerSheet_Widget(dlg);
@@ -874,15 +875,15 @@ iWidget *makeQuestion_Widget(const char *title, const char *msg, const char *lab
874 processEvents_App(postedEventsOnly_AppEventMode); 875 processEvents_App(postedEventsOnly_AppEventMode);
875 iWidget *dlg = makeSheet_Widget(""); 876 iWidget *dlg = makeSheet_Widget("");
876 setCommandHandler_Widget(dlg, messageHandler_); 877 setCommandHandler_Widget(dlg, messageHandler_);
877 addChildFlags_Widget(dlg, iClob(new_LabelWidget(title, 0, 0, NULL)), frameless_WidgetFlag); 878 addChildFlags_Widget(dlg, iClob(new_LabelWidget(title, NULL)), frameless_WidgetFlag);
878 addChildFlags_Widget(dlg, iClob(new_LabelWidget(msg, 0, 0, NULL)), frameless_WidgetFlag); 879 addChildFlags_Widget(dlg, iClob(new_LabelWidget(msg, NULL)), frameless_WidgetFlag);
879 addChild_Widget(dlg, iClob(makePadding_Widget(gap_UI))); 880 addChild_Widget(dlg, iClob(makePadding_Widget(gap_UI)));
880 iWidget *div = new_Widget(); { 881 iWidget *div = new_Widget(); {
881 setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); 882 setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue);
882 for (size_t i = 0; i < count; ++i) { 883 for (size_t i = 0; i < count; ++i) {
883 /* The last one is the default option. */ 884 /* The last one is the default option. */
884 const int key = (i == count - 1 ? SDLK_RETURN : 0); 885 const int key = (i == count - 1 ? SDLK_RETURN : 0);
885 addChild_Widget(div, iClob(new_LabelWidget(labels[i], key, 0, commands[i]))); 886 addChild_Widget(div, iClob(newKeyMods_LabelWidget(labels[i], key, 0, commands[i])));
886 } 887 }
887 } 888 }
888 addChild_Widget(dlg, iClob(div)); 889 addChild_Widget(dlg, iClob(div));
@@ -912,7 +913,7 @@ static iBool toggleHandler_(iWidget *d, const char *cmd) {
912} 913}
913 914
914iWidget *makeToggle_Widget(const char *id) { 915iWidget *makeToggle_Widget(const char *id) {
915 iWidget *toggle = as_Widget(new_LabelWidget("YES", 0, 0, "toggle")); /* "YES" for sizing */ 916 iWidget *toggle = as_Widget(new_LabelWidget("YES", "toggle")); /* "YES" for sizing */
916 setId_Widget(toggle, id); 917 setId_Widget(toggle, id);
917 updateTextCStr_LabelWidget((iLabelWidget *) toggle, "NO"); /* actual initial value */ 918 updateTextCStr_LabelWidget((iLabelWidget *) toggle, "NO"); /* actual initial value */
918 setCommandHandler_Widget(toggle, toggleHandler_); 919 setCommandHandler_Widget(toggle, toggleHandler_);
@@ -950,7 +951,7 @@ static void expandInputFieldWidth_(iInputWidget *input) {
950 951
951static void addRadioButton_(iWidget *parent, const char *id, const char *label, const char *cmd) { 952static void addRadioButton_(iWidget *parent, const char *id, const char *label, const char *cmd) {
952 setId_Widget( 953 setId_Widget(
953 addChildFlags_Widget(parent, iClob(new_LabelWidget(label, 0, 0, cmd)), radio_WidgetFlag), 954 addChildFlags_Widget(parent, iClob(new_LabelWidget(label, cmd)), radio_WidgetFlag),
954 id); 955 id);
955} 956}
956 957
@@ -969,7 +970,7 @@ static void addFontButtons_(iWidget *parent, const char *id) {
969iWidget *makePreferences_Widget(void) { 970iWidget *makePreferences_Widget(void) {
970 iWidget *dlg = makeSheet_Widget("prefs"); 971 iWidget *dlg = makeSheet_Widget("prefs");
971 addChildFlags_Widget(dlg, 972 addChildFlags_Widget(dlg,
972 iClob(new_LabelWidget(uiHeading_ColorEscape "PREFERENCES", 0, 0, NULL)), 973 iClob(new_LabelWidget(uiHeading_ColorEscape "PREFERENCES", NULL)),
973 frameless_WidgetFlag); 974 frameless_WidgetFlag);
974 iWidget *tabs = makeTabs_Widget(dlg); 975 iWidget *tabs = makeTabs_Widget(dlg);
975 setId_Widget(tabs, "prefs.tabs"); 976 setId_Widget(tabs, "prefs.tabs");
@@ -988,10 +989,10 @@ iWidget *makePreferences_Widget(void) {
988 addChild_Widget(headings, iClob(makeHeading_Widget("Theme:"))); 989 addChild_Widget(headings, iClob(makeHeading_Widget("Theme:")));
989 iWidget *themes = new_Widget(); 990 iWidget *themes = new_Widget();
990 /* Themes. */ { 991 /* Themes. */ {
991 setId_Widget(addChild_Widget(themes, iClob(new_LabelWidget("Pure Black", 0, 0, "theme.set arg:0"))), "prefs.theme.0"); 992 setId_Widget(addChild_Widget(themes, iClob(new_LabelWidget("Pure Black", "theme.set arg:0"))), "prefs.theme.0");
992 setId_Widget(addChild_Widget(themes, iClob(new_LabelWidget("Dark", 0, 0, "theme.set arg:1"))), "prefs.theme.1"); 993 setId_Widget(addChild_Widget(themes, iClob(new_LabelWidget("Dark", "theme.set arg:1"))), "prefs.theme.1");
993 setId_Widget(addChild_Widget(themes, iClob(new_LabelWidget("Light", 0, 0, "theme.set arg:2"))), "prefs.theme.2"); 994 setId_Widget(addChild_Widget(themes, iClob(new_LabelWidget("Light", "theme.set arg:2"))), "prefs.theme.2");
994 setId_Widget(addChild_Widget(themes, iClob(new_LabelWidget("Pure White", 0, 0, "theme.set arg:3"))), "prefs.theme.3"); 995 setId_Widget(addChild_Widget(themes, iClob(new_LabelWidget("Pure White", "theme.set arg:3"))), "prefs.theme.3");
995 } 996 }
996 addChildFlags_Widget(values, iClob(themes), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); 997 addChildFlags_Widget(values, iClob(themes), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag);
997 addChild_Widget(headings, iClob(makeHeading_Widget("Retain window size:"))); 998 addChild_Widget(headings, iClob(makeHeading_Widget("Retain window size:")));
@@ -1084,7 +1085,7 @@ iWidget *makePreferences_Widget(void) {
1084 } 1085 }
1085 iWidget *div = new_Widget(); { 1086 iWidget *div = new_Widget(); {
1086 setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); 1087 setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue);
1087 addChild_Widget(div, iClob(new_LabelWidget("Dismiss", SDLK_ESCAPE, 0, "prefs.dismiss"))); 1088 addChild_Widget(div, iClob(newKeyMods_LabelWidget("Dismiss", SDLK_ESCAPE, 0, "prefs.dismiss")));
1088 } 1089 }
1089 addChild_Widget(dlg, iClob(div)); 1090 addChild_Widget(dlg, iClob(div));
1090 addAction_Widget(dlg, prevTab_KeyShortcut, "tabs.prev"); 1091 addAction_Widget(dlg, prevTab_KeyShortcut, "tabs.prev");
@@ -1098,7 +1099,7 @@ iWidget *makeBookmarkEditor_Widget(void) {
1098 iWidget *dlg = makeSheet_Widget("bmed"); 1099 iWidget *dlg = makeSheet_Widget("bmed");
1099 setId_Widget(addChildFlags_Widget( 1100 setId_Widget(addChildFlags_Widget(
1100 dlg, 1101 dlg,
1101 iClob(new_LabelWidget(uiHeading_ColorEscape "EDIT BOOKMARK", 0, 0, NULL)), 1102 iClob(new_LabelWidget(uiHeading_ColorEscape "EDIT BOOKMARK", NULL)),
1102 frameless_WidgetFlag), 1103 frameless_WidgetFlag),
1103 "bmed.heading"); 1104 "bmed.heading");
1104 iWidget *page = new_Widget(); 1105 iWidget *page = new_Widget();
@@ -1121,10 +1122,10 @@ iWidget *makeBookmarkEditor_Widget(void) {
1121 } 1122 }
1122 iWidget *div = new_Widget(); { 1123 iWidget *div = new_Widget(); {
1123 setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); 1124 setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue);
1124 addChild_Widget(div, iClob(new_LabelWidget("Cancel", SDLK_ESCAPE, 0, "cancel"))); 1125 addChild_Widget(div, iClob(newKeyMods_LabelWidget("Cancel", SDLK_ESCAPE, 0, "cancel")));
1125 addChild_Widget( 1126 addChild_Widget(
1126 div, 1127 div,
1127 iClob(new_LabelWidget( 1128 iClob(newKeyMods_LabelWidget(
1128 uiTextCaution_ColorEscape "Save Bookmark", SDLK_RETURN, KMOD_PRIMARY, "bmed.accept"))); 1129 uiTextCaution_ColorEscape "Save Bookmark", SDLK_RETURN, KMOD_PRIMARY, "bmed.accept")));
1129 } 1130 }
1130 addChild_Widget(dlg, iClob(div)); 1131 addChild_Widget(dlg, iClob(div));
@@ -1165,7 +1166,7 @@ iWidget *makeBookmarkCreation_Widget(const iString *url, const iString *title, i
1165 setId_Widget( 1166 setId_Widget(
1166 addChildFlags_Widget( 1167 addChildFlags_Widget(
1167 dlg, 1168 dlg,
1168 iClob(new_LabelWidget(cstrCollect_String(newUnicodeN_String(&icon, 1)), 0, 0, NULL)), 1169 iClob(new_LabelWidget(cstrCollect_String(newUnicodeN_String(&icon, 1)), NULL)),
1169 collapse_WidgetFlag | hidden_WidgetFlag | disabled_WidgetFlag), 1170 collapse_WidgetFlag | hidden_WidgetFlag | disabled_WidgetFlag),
1170 "bmed.icon"); 1171 "bmed.icon");
1171 setCommandHandler_Widget(dlg, handleBookmarkCreationCommands_SidebarWidget_); 1172 setCommandHandler_Widget(dlg, handleBookmarkCreationCommands_SidebarWidget_);
@@ -1176,14 +1177,14 @@ iWidget *makeIdentityCreation_Widget(void) {
1176 iWidget *dlg = makeSheet_Widget("ident"); 1177 iWidget *dlg = makeSheet_Widget("ident");
1177 setId_Widget(addChildFlags_Widget( 1178 setId_Widget(addChildFlags_Widget(
1178 dlg, 1179 dlg,
1179 iClob(new_LabelWidget(uiHeading_ColorEscape "NEW IDENTITY", 0, 0, NULL)), 1180 iClob(new_LabelWidget(uiHeading_ColorEscape "NEW IDENTITY", NULL)),
1180 frameless_WidgetFlag), 1181 frameless_WidgetFlag),
1181 "ident.heading"); 1182 "ident.heading");
1182 iWidget *page = new_Widget(); 1183 iWidget *page = new_Widget();
1183 addChildFlags_Widget( 1184 addChildFlags_Widget(
1184 dlg, 1185 dlg,
1185 iClob( 1186 iClob(
1186 new_LabelWidget("Creating a 2048-bit self-signed RSA certificate.", 0, 0, NULL)), 1187 new_LabelWidget("Creating a 2048-bit self-signed RSA certificate.", NULL)),
1187 frameless_WidgetFlag); 1188 frameless_WidgetFlag);
1188 addChild_Widget(dlg, iClob(page)); 1189 addChild_Widget(dlg, iClob(page));
1189 setFlags_Widget(page, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); 1190 setFlags_Widget(page, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue);
@@ -1214,10 +1215,10 @@ iWidget *makeIdentityCreation_Widget(void) {
1214 } 1215 }
1215 iWidget *div = new_Widget(); { 1216 iWidget *div = new_Widget(); {
1216 setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); 1217 setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue);
1217 addChild_Widget(div, iClob(new_LabelWidget("Cancel", SDLK_ESCAPE, 0, "cancel"))); 1218 addChild_Widget(div, iClob(newKeyMods_LabelWidget("Cancel", SDLK_ESCAPE, 0, "cancel")));
1218 addChild_Widget( 1219 addChild_Widget(
1219 div, 1220 div,
1220 iClob(new_LabelWidget( 1221 iClob(newKeyMods_LabelWidget(
1221 uiTextAction_ColorEscape "Create Identity", SDLK_RETURN, KMOD_PRIMARY, "ident.accept"))); 1222 uiTextAction_ColorEscape "Create Identity", SDLK_RETURN, KMOD_PRIMARY, "ident.accept")));
1222 } 1223 }
1223 addChild_Widget(dlg, iClob(div)); 1224 addChild_Widget(dlg, iClob(div));