GtkWidget *ok_validate_button (GtkWidget *hbox, int *retptr, int *valptr) { GtkWidget *button = ok_button(hbox); g_object_set_data(G_OBJECT(button), "retptr", retptr); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(set_valid_response), valptr); return button; }
//------- Begin of function Box::msg ----------// // // Popup a message box and ask user to press the 'Ok' button // // Syntax :: msg( <char*> ) // // <char*> msgStr = pointer to the message, use '\n' to // seperate lines. // [int] enableTimeOut = enable time out or not (default: 1) // [int] x1, y1 = the left corner of the box, if not given // center the box on the screen. // void Box::msg(const char* msgStr, int enableTimeOut, int x1, int y1) { calc_size(msgStr,BOX_TOP_MARGIN+BOX_BOTTOM_MARGIN,x1,y1); // calculate x1, y1, x2, y2 depended on the msgStr down_centre = 1; opened_flag = 1; paint(); font_bld.put_paragraph( box_x1+BOX_X_MARGIN, box_y1+BOX_TOP_MARGIN, box_x2-BOX_X_MARGIN, box_y2-BOX_BOTTOM_MARGIN, msgStr, BOX_LINE_SPACE ); ok_button(enableTimeOut); close(); }
bool dlgTextEntryKeyboardShowModal(TCHAR *text, size_t width, const TCHAR* caption, AllowedCharacters accb) { if (width == 0) width = MAX_TEXTENTRY; max_width = std::min(MAX_TEXTENTRY, width); const DialogLook &look = UIGlobals::GetDialogLook(); WndForm form(look); form.Create(UIGlobals::GetMainWindow(), caption); form.SetKeyDownFunction(FormKeyDown); form.SetCharacterFunction(FormCharacter); ContainerWindow &client_area = form.GetClientAreaWindow(); const PixelRect rc = client_area.GetClientRect(); const PixelScalar client_height = rc.bottom - rc.top; const PixelScalar padding = Layout::Scale(2); const PixelScalar backspace_width = Layout::Scale(36); const PixelScalar backspace_left = rc.right - padding - backspace_width; const PixelScalar editor_height = Layout::Scale(22); const PixelScalar editor_bottom = padding + editor_height; const PixelScalar button_height = Layout::Scale(40); constexpr unsigned keyboard_rows = 5; const PixelScalar keyboard_top = editor_bottom + padding; const PixelScalar keyboard_height = keyboard_rows * button_height; const PixelScalar keyboard_bottom = keyboard_top + keyboard_height; const bool vertical = client_height >= keyboard_bottom + button_height; const PixelScalar button_top = vertical ? rc.bottom - button_height : keyboard_bottom - button_height; const PixelScalar button_bottom = vertical ? rc.bottom : keyboard_bottom; const PixelScalar ok_left = vertical ? 0 : padding; const PixelScalar ok_right = vertical ? rc.right / 3 : ok_left + Layout::Scale(80); const PixelScalar cancel_left = vertical ? ok_right : Layout::Scale(175); const PixelScalar cancel_right = vertical ? rc.right * 2 / 3 : cancel_left + Layout::Scale(60); const PixelScalar clear_left = vertical ? cancel_right : Layout::Scale(235); const PixelScalar clear_right = vertical ? rc.right : clear_left + Layout::Scale(50); WndProperty _editor(client_area, look, _T(""), { 0, padding, backspace_left - padding, editor_bottom }, 0, WindowStyle()); _editor.SetReadOnly(); editor = &_editor; ButtonWindowStyle button_style; button_style.TabStop(); WndButton backspace_button(client_area, look, _T("<-"), { backspace_left, padding, rc.right - padding, editor_bottom }, button_style, OnBackspace); WndButton ok_button(client_area, look, _("OK"), { ok_left, button_top, ok_right, button_bottom }, button_style, form, mrOK); WndButton cancel_button(client_area, look, _("Cancel"), { cancel_left, button_top, cancel_right, button_bottom }, button_style, form, mrCancel); WndButton clear_button(client_area, look, _("Clear"), { clear_left, button_top, clear_right, button_bottom }, button_style, ClearText); KeyboardControl keyboard(client_area, look, { padding, keyboard_top, rc.right - padding, keyboard_bottom }, OnCharacter); kb = &keyboard; AllowedCharactersCallback = accb; cursor = 0; ClearText(); if (!StringIsEmpty(text)) { CopyString(edittext, text, width); cursor = _tcslen(text); } UpdateTextboxProp(); bool result = form.ShowModal() == mrOK; if (result) { CopyString(text, edittext, width); } return result; }
void blocking_edit_dialog (int ci, const char *title, const char *info, const char *deflt, void (*okfunc)(), void *okptr, Varclick click, GtkWidget *parent, int *canceled) { dialog_t *d; GtkWidget *w; MODEL *pmod = NULL; int helpcode; int clear = 0; if (open_edit_dialog != NULL && ci != MINIBUF) { gtk_window_present(GTK_WINDOW(open_edit_dialog)); return; } helpcode = edit_dialog_help_code(ci, okptr); d = edit_dialog_new(ci, title, okfunc, okptr, helpcode, parent, canceled); if (d == NULL) return; open_edit_dialog = d->dialog; set_dialog_border_widths(d->vbox, d->bbox); gretl_dialog_set_resizeable(d->dialog, FALSE); gtk_button_box_set_layout(GTK_BUTTON_BOX(d->bbox), GTK_BUTTONBOX_END); if (ci == ESTIMATE) { /* estimating saved equation system */ dlg_display_sys(d); } else if (ci == SYSTEM && d->data != NULL) { /* respecifying equation system */ edit_dialog_add_note(info, d->vbox); dlg_display_sys(d); clear = 1; } else if (ci == NLS || ci == MLE || ci == GMM || ci == SYSTEM || ci == RESTRICT) { int hsize = 62; edit_dialog_add_note(info, d->vbox); d->edit = dlg_text_edit_new(&hsize, TRUE); dialog_table_setup(d, hsize); gretl_dialog_set_resizeable(d->dialog, TRUE); if (ci != RESTRICT && deflt != NULL) { /* re-specifying a nonlinear model */ textview_set_text(d->edit, deflt); if (ci == NLS || ci == MLE || ci == GMM) { pmod = okptr; } } else if (dlg_text_set_previous(d) || dlg_text_set_gmm_skel(d)) { /* insert previous text, if any and if the command is the same as previously -- or insert skeleton of command */ clear = 1; } if (ci != RESTRICT && ci != GMM) { g_signal_connect(G_OBJECT(d->edit), "button-press-event", G_CALLBACK(edit_dialog_popup_handler), d); } } else { if (info != NULL) { w = gtk_label_new(info); gtk_label_set_justify(GTK_LABEL(w), GTK_JUSTIFY_LEFT); gtk_box_pack_start(GTK_BOX(d->vbox), w, TRUE, TRUE, 5); gtk_widget_show(w); } d->edit = gtk_entry_new(); gtk_box_pack_start(GTK_BOX(d->vbox), d->edit, TRUE, TRUE, 5); /* make the Enter key do the business */ if (okfunc != NULL) { gtk_entry_set_activates_default(GTK_ENTRY(d->edit), TRUE); } if (deflt != NULL && *deflt != '\0') { gtk_entry_set_text(GTK_ENTRY(d->edit), deflt); gtk_editable_select_region(GTK_EDITABLE(d->edit), 0, strlen(deflt)); } g_signal_connect(G_OBJECT(GTK_EDITABLE(d->edit)), "changed", G_CALLBACK(raise_and_focus_dialog), d->dialog); } if (ci == SYSTEM || ci == ESTIMATE) { GtkWidget *bt, *bv; bt = dialog_option_switch(d->vbox, d, OPT_T, NULL); bv = dialog_option_switch(d->vbox, d, OPT_V, NULL); system_estimator_list(d->vbox, d, bt, bv); } else if (ci == NLS || ci == MLE) { dialog_option_switch(d->vbox, d, OPT_V, pmod); dialog_option_switch(d->vbox, d, OPT_R, pmod); if (ci == MLE) { iter_control_button(d->vbox, d, pmod); } } else if (ci == GMM) { dialog_option_switch(d->vbox, d, OPT_V, pmod); build_gmm_combo(d->vbox, d, pmod); } else if (ci == RESTRICT && ols_model_window(okptr)) { dialog_option_switch(d->vbox, d, OPT_B, NULL); } else if (ci == RESTRICT && vecm_model_window(okptr)) { dialog_option_switch(d->vbox, d, OPT_F, NULL); } else if (ci == GR_BOX) { dialog_option_switch(d->vbox, d, OPT_O, NULL); } if (click == VARCLICK_INSERT_ID) { active_edit_id = d->edit; } else if (click == VARCLICK_INSERT_NAME) { active_edit_name = d->edit; } else if (click == VARCLICK_INSERT_TEXT) { active_edit_text = d->edit; } if (click != VARCLICK_NONE || helpcode > 0) { gtk_window_set_keep_above(GTK_WINDOW(d->dialog), FALSE); } else { gtk_window_set_keep_above(GTK_WINDOW(d->dialog), TRUE); } gtk_widget_grab_focus(d->edit); /* "Clear" button? */ if (clear) { w = gtk_button_new_from_stock(GTK_STOCK_CLEAR); gtk_container_add(GTK_CONTAINER(d->bbox), w); g_signal_connect(G_OBJECT(w), "clicked", G_CALLBACK(clear_dlg_previous), d); } /* "Cancel" button */ cancel_delete_button(d->bbox, d->dialog); /* "OK" button */ if (canceled != NULL) { w = ok_validate_button(d->bbox, canceled, NULL); } else { w = ok_button(d->bbox); } g_signal_connect(G_OBJECT(w), "clicked", G_CALLBACK(edit_dialog_ok), d); gtk_widget_grab_default(w); /* "Help" button, if wanted */ if (helpcode > 0) { context_help_button(d->bbox, helpcode); } if (ci == GENR) { gtk_widget_set_size_request(GTK_WIDGET(d->dialog), 400, -1); } gtk_widget_show_all(d->dialog); }
static void real_view_format_dialog (windata_t *vwin, series_view *sview) { struct view_toggler vt; GtkWidget *dlg, *vbox; GtkWidget *tmp, *hbox; GtkWidget *b1, *b2; GSList *group; int std; dlg = gretl_dialog_new(_("gretl: data format"), vwin->main, GRETL_DLG_BLOCK); vbox = gtk_dialog_get_content_area(GTK_DIALOG(dlg)); std = (sview->view == VIEW_STANDARD); vt.view = sview->view; vt.digits = sview->digits; vt.format = sview->format; vt.target_vwin = vwin; vt.sview = sview; hbox = gtk_hbox_new(FALSE, 5); tmp = gtk_label_new(_("Select data format")); gtk_box_pack_start(GTK_BOX(hbox), tmp, FALSE, FALSE, 5); gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 5); /* standard format radio option */ hbox = gtk_hbox_new(FALSE, 5); b1 = gtk_radio_button_new_with_label(NULL, _("Standard format")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b1), std); gtk_box_pack_start(GTK_BOX(hbox), b1, TRUE, TRUE, 5); gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 5); /* custom format radio option */ hbox = gtk_hbox_new(FALSE, 5); group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(b1)); b2 = gtk_radio_button_new_with_label(group, _("Show")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b2), !std); gtk_box_pack_start(GTK_BOX(hbox), b2, FALSE, FALSE, 5); /* with spinner for number of digits */ vt.spin = gtk_spin_button_new_with_range(1, 15, 1); gtk_spin_button_set_value(GTK_SPIN_BUTTON(vt.spin), sview->digits); g_signal_connect(G_OBJECT(vt.spin), "value-changed", G_CALLBACK(series_view_set_digits), &vt.digits); gtk_widget_set_sensitive(vt.spin, !std); gtk_box_pack_start(GTK_BOX(hbox), vt.spin, FALSE, FALSE, 0); /* and selector for digits / decimal places */ vt.combo = gtk_combo_box_text_new(); combo_box_append_text(vt.combo, _("significant figures")); combo_box_append_text(vt.combo, _("decimal places")); if (sview->format == 'g') { gtk_combo_box_set_active(GTK_COMBO_BOX(vt.combo), 0); } else { gtk_combo_box_set_active(GTK_COMBO_BOX(vt.combo), 1); } g_signal_connect(G_OBJECT(GTK_COMBO_BOX(vt.combo)), "changed", G_CALLBACK(series_view_set_fmt), &vt.format); gtk_widget_set_sensitive(vt.combo, !std); gtk_box_pack_start(GTK_BOX(hbox), vt.combo, FALSE, FALSE, 5); /* connect toggle signal */ g_signal_connect(G_OBJECT(b1), "toggled", G_CALLBACK(series_view_toggle_view), &vt); /* pack the custom line */ gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 5); hbox = gtk_dialog_get_action_area(GTK_DIALOG(dlg)); /* Cancel button */ cancel_delete_button(hbox, dlg); /* OK button */ tmp = ok_button(hbox); g_signal_connect(G_OBJECT(tmp), "clicked", G_CALLBACK(reformat_callback), &vt); g_signal_connect(G_OBJECT(tmp), "clicked", G_CALLBACK(delete_widget), dlg); gtk_widget_grab_default(tmp); gtk_widget_show_all(dlg); }
bool gui_show_text_entry_dialog(const std::string& title, const std::string& message, const std::string& sec_message, std::string& result, const std::string& default_str, Gtk::Window* parent, bool sec_msg_markup) { int response = 0; std::string input_str; { // the dialog hides at the end of scope Gtk::Dialog dialog(title, true); // modal dialog.set_resizable(false); dialog.set_skip_taskbar_hint(true); dialog.set_border_width(5); if (parent) { dialog.set_transient_for(*parent); dialog.set_position(Gtk::WIN_POS_CENTER_ON_PARENT); } else { dialog.set_position(Gtk::WIN_POS_MOUSE); } Gtk::Label main_label; main_label.set_markup("<big><b>" + Glib::Markup::escape_text(message) + (sec_message.empty() ? "\n" : "") + "</b></big>"); main_label.set_line_wrap(true); main_label.set_selectable(true); main_label.set_alignment(0.0, 0.0); Gtk::Label sec_label; if (sec_msg_markup) { sec_label.set_markup(sec_message); } else { sec_label.set_text(sec_message); } sec_label.set_line_wrap(true); sec_label.set_selectable(true); sec_label.set_alignment(0.0, 0.0); Gtk::Entry input_entry; input_entry.set_activates_default(true); Gtk::VBox vbox; vbox.set_spacing(12); vbox.pack_start(main_label, false, false, 0); vbox.pack_start(sec_label, true, true, 0); vbox.pack_start(input_entry, true, true, 0); vbox.show_all(); dialog.get_action_area()->set_border_width(5); dialog.get_action_area()->set_spacing(6); dialog.get_vbox()->set_spacing(14); // as in MessageDialog dialog.get_vbox()->pack_start(vbox, false, false, 0); dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); Gtk::Button ok_button(Gtk::Stock::OK); ok_button.set_flags(ok_button.get_flags() | Gtk::CAN_DEFAULT); ok_button.show_all(); dialog.add_action_widget(ok_button, Gtk::RESPONSE_OK); ok_button.grab_default(); // make it the default widget response = dialog.run(); // blocks until the dialog is closed input_str = input_entry.get_text(); } if (response == Gtk::RESPONSE_OK) { result = input_str; return true; } return false; }
EMessageBoxReturn gtk_MessageBox (GtkWidget *parent, const char* text, const char* title, EMessageBoxType type, EMessageBoxIcon icon) { ModalDialog dialog; ModalDialogButton ok_button(dialog, eIDOK); ModalDialogButton cancel_button(dialog, eIDCANCEL); ModalDialogButton yes_button(dialog, eIDYES); ModalDialogButton no_button(dialog, eIDNO); GtkWindow* parentWindow = parent != 0 ? GTK_WINDOW(parent) : 0; GtkWindow* window = create_fixedsize_modal_dialog_window(parentWindow, title, dialog, 400, 100); if(parentWindow != 0) { //g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(floating_window_delete_present), parent); gtk_window_deiconify(parentWindow); } GtkAccelGroup* accel = gtk_accel_group_new(); gtk_window_add_accel_group(window, accel); GtkVBox* vbox = create_dialog_vbox(8, 8); gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(vbox)); GtkHBox* hboxDummy = create_dialog_hbox(0, 0); gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(hboxDummy), FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hboxDummy), create_padding(0, 50), FALSE, FALSE, 0); // HACK to force minimum height GtkHBox* iconBox = create_dialog_hbox(16, 0); gtk_box_pack_start(GTK_BOX(hboxDummy), GTK_WIDGET(iconBox), FALSE, FALSE, 0); GtkImage* image = GTK_IMAGE(gtk_image_new_from_stock(messagebox_stock_icon(icon), GTK_ICON_SIZE_DIALOG)); gtk_widget_show(GTK_WIDGET(image)); gtk_box_pack_start(GTK_BOX(iconBox), GTK_WIDGET(image), FALSE, FALSE, 0); GtkLabel* label = GTK_LABEL(gtk_label_new(text)); gtk_widget_show(GTK_WIDGET(label)); gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); gtk_label_set_justify(label, GTK_JUSTIFY_LEFT); gtk_label_set_line_wrap(label, TRUE); gtk_box_pack_start(GTK_BOX(iconBox), GTK_WIDGET(label), TRUE, TRUE, 0); GtkVBox* vboxDummy = create_dialog_vbox(0, 0); gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(vboxDummy), FALSE, FALSE, 0); GtkAlignment* alignment = GTK_ALIGNMENT(gtk_alignment_new(0.5, 0.0, 0.0, 0.0)); gtk_widget_show(GTK_WIDGET(alignment)); gtk_box_pack_start(GTK_BOX(vboxDummy), GTK_WIDGET(alignment), FALSE, FALSE, 0); GtkHBox* hbox = create_dialog_hbox(8, 0); gtk_container_add(GTK_CONTAINER(alignment), GTK_WIDGET(hbox)); gtk_box_pack_start(GTK_BOX(vboxDummy), create_padding(400, 0), FALSE, FALSE, 0); // HACK to force minimum width if (type == eMB_OK) { GtkButton* button = create_modal_dialog_button("OK", ok_button); gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(button), TRUE, FALSE, 0); gtk_widget_add_accelerator(GTK_WIDGET(button), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0); gtk_widget_add_accelerator(GTK_WIDGET(button), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0); widget_make_default(GTK_WIDGET(button)); gtk_widget_show(GTK_WIDGET(button)); dialog.ret = eIDOK; } else if (type == eMB_OKCANCEL) { { GtkButton* button = create_modal_dialog_button("OK", ok_button); gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(button), TRUE, FALSE, 0); gtk_widget_add_accelerator(GTK_WIDGET(button), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0); widget_make_default(GTK_WIDGET(button)); gtk_widget_show(GTK_WIDGET(button)); } { GtkButton* button = create_modal_dialog_button("OK", cancel_button); gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(button), TRUE, FALSE, 0); gtk_widget_add_accelerator(GTK_WIDGET(button), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0); gtk_widget_show(GTK_WIDGET(button)); } dialog.ret = eIDCANCEL; } else if (type == eMB_YESNOCANCEL) { { GtkButton* button = create_modal_dialog_button("Yes", yes_button); gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(button), TRUE, FALSE, 0); widget_make_default(GTK_WIDGET(button)); gtk_widget_show(GTK_WIDGET(button)); } { GtkButton* button = create_modal_dialog_button("No", no_button); gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(button), TRUE, FALSE, 0); gtk_widget_show(GTK_WIDGET(button)); } { GtkButton* button = create_modal_dialog_button("Cancel", cancel_button); gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(button), TRUE, FALSE, 0); gtk_widget_show(GTK_WIDGET(button)); } dialog.ret = eIDCANCEL; } else if (type == eMB_NOYES) { { GtkButton* button = create_modal_dialog_button("No", no_button); gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(button), TRUE, FALSE, 0); widget_make_default(GTK_WIDGET(button)); gtk_widget_show(GTK_WIDGET(button)); } { GtkButton* button = create_modal_dialog_button("Yes", yes_button); gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(button), TRUE, FALSE, 0); gtk_widget_show(GTK_WIDGET(button)); } dialog.ret = eIDNO; } else /* if (type == eMB_YESNO) */ { { GtkButton* button = create_modal_dialog_button("Yes", yes_button); gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(button), TRUE, FALSE, 0); widget_make_default(GTK_WIDGET(button)); gtk_widget_show(GTK_WIDGET(button)); } { GtkButton* button = create_modal_dialog_button("No", no_button); gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(button), TRUE, FALSE, 0); gtk_widget_show(GTK_WIDGET(button)); } dialog.ret = eIDNO; } modal_dialog_show(window, dialog); gtk_widget_destroy(GTK_WIDGET(window)); return dialog.ret; }
bool TouchTextEntry(TCHAR *text, size_t width, const TCHAR *caption, AllowedCharacters accb, bool default_shift_state) { if (width == 0) width = MAX_TEXTENTRY; max_width = std::min(MAX_TEXTENTRY, width); const DialogLook &look = UIGlobals::GetDialogLook(); WndForm form(look); form.Create(UIGlobals::GetMainWindow(), caption); form.SetKeyDownFunction(FormKeyDown); form.SetCharacterFunction(FormCharacter); ContainerWindow &client_area = form.GetClientAreaWindow(); const PixelRect rc = client_area.GetClientRect(); const int client_height = rc.GetHeight(); const int padding = Layout::Scale(2); const int backspace_width = Layout::Scale(36); const int backspace_left = rc.right - padding - backspace_width; const int editor_height = Layout::Scale(22); const int editor_bottom = padding + editor_height; const int button_height = Layout::Scale(40); constexpr unsigned keyboard_rows = 5; const int keyboard_top = editor_bottom + padding; const int keyboard_height = keyboard_rows * button_height; const int keyboard_bottom = keyboard_top + keyboard_height; const bool vertical = client_height >= keyboard_bottom + button_height; const int button_top = vertical ? rc.bottom - button_height : keyboard_bottom - button_height; const int button_bottom = vertical ? rc.bottom : keyboard_bottom; const int ok_left = vertical ? 0 : padding; const int ok_right = vertical ? rc.right / 3 : ok_left + Layout::Scale(80); const int cancel_left = vertical ? ok_right : Layout::Scale(175); const int cancel_right = vertical ? rc.right * 2 / 3 : cancel_left + Layout::Scale(60); const int clear_left = vertical ? cancel_right : Layout::Scale(235); const int clear_right = vertical ? rc.right : clear_left + Layout::Scale(50); WndProperty _editor(client_area, look, _T(""), { 0, padding, backspace_left - padding, editor_bottom }, 0, WindowStyle()); _editor.SetReadOnly(); editor = &_editor; WindowStyle button_style; button_style.TabStop(); Button ok_button(client_area, look.button, _("OK"), { ok_left, button_top, ok_right, button_bottom }, button_style, form, mrOK); Button cancel_button(client_area, look.button, _("Cancel"), { cancel_left, button_top, cancel_right, button_bottom }, button_style, form, mrCancel); auto clear_listener = MakeLambdaActionListener([](unsigned id){ ClearText(); }); Button clear_button(client_area, look.button, _("Clear"), { clear_left, button_top, clear_right, button_bottom }, button_style, clear_listener, 0); KeyboardWidget keyboard(look.button, FormCharacter, !accb, default_shift_state); const PixelRect keyboard_rc = { padding, keyboard_top, rc.right - padding, keyboard_bottom }; keyboard.Initialise(client_area, keyboard_rc); keyboard.Prepare(client_area, keyboard_rc); keyboard.Show(keyboard_rc); kb = &keyboard; auto backspace_listener = MakeLambdaActionListener([](unsigned id){ OnBackspace(); }); Button backspace_button(client_area, look.button, _T("<-"), { backspace_left, padding, rc.right - padding, editor_bottom }, button_style, backspace_listener, 0); AllowedCharactersCallback = accb; cursor = 0; ClearText(); if (!StringIsEmpty(text)) { CopyTruncateString(edittext, width, text); cursor = _tcslen(text); } UpdateTextboxProp(); bool result = form.ShowModal() == mrOK; keyboard.Hide(); keyboard.Unprepare(); if (result) { CopyTruncateString(text, width, edittext); } return result; }