#endif // wxUSE_INFOBAR
#if wxUSE_TEXTDLG
+ EVT_MENU(DIALOGS_LINE_ENTRY, MyFrame::LineEntry)
EVT_MENU(DIALOGS_TEXT_ENTRY, MyFrame::TextEntry)
EVT_MENU(DIALOGS_PASSWORD_ENTRY, MyFrame::PasswordEntry)
#endif // wxUSE_TEXTDLG
wxMenu *entry_menu = new wxMenu;
#if wxUSE_TEXTDLG
- entry_menu->Append(DIALOGS_TEXT_ENTRY, wxT("Text &entry\tCtrl-E"));
+ entry_menu->Append(DIALOGS_LINE_ENTRY, wxT("Single line &entry\tCtrl-E"));
+ entry_menu->Append(DIALOGS_TEXT_ENTRY, wxT("Multi line text &entry\tShift-Ctrl-E"));
entry_menu->Append(DIALOGS_PASSWORD_ENTRY, wxT("&Password entry\tCtrl-P"));
#endif // wxUSE_TEXTDLG
menuHelp->Append(DIALOGS_ABOUTDLG_CUSTOM, wxT("About (&custom)...\tCtrl-Shift-F1"));
#endif // wxUSE_ABOUTDLG
+ wxMenu* editMenu = new wxMenu;
+ editMenu->Append(wxID_UNDO, _("&Undo\tCtrl+Z"));
+ editMenu->Append(wxID_REDO, _("&Redo\tCtrl+Y"));
+ editMenu->AppendSeparator();
+ editMenu->Append(wxID_CUT, _("Cu&t\tCtrl+X"));
+ editMenu->Append(wxID_COPY, _("&Copy\tCtrl+C"));
+ editMenu->Append(wxID_PASTE, _("&Paste\tCtrl+V"));
+ editMenu->Append(wxID_CLEAR, _("&Delete"));
+
+ editMenu->AppendSeparator();
+ editMenu->Append(wxID_SELECTALL, _("Select All\tCtrl+A"));
+
wxMenuBar *menubar = new wxMenuBar;
menubar->Append(menuDlg, wxT("&Dialogs"));
+
+ menubar->Append(editMenu, wxT("&Edit"));
+
#if wxUSE_ABOUTDLG
menubar->Append(menuHelp, wxT("&Help"));
#endif // wxUSE_ABOUTDLG
// covers our entire client area to avoid jarring colour jumps
SetOwnBackgroundColour(m_canvas->GetBackgroundColour());
#endif // wxUSE_INFOBAR
+
+#ifdef __WXMSW__
+ // Test MSW-specific function allowing to access the "system" menu.
+ wxMenu * const menu = MSWGetSystemMenu();
+ if ( menu )
+ {
+ menu->AppendSeparator();
+
+ // The ids of the menu commands in MSW system menu must be multiple of
+ // 16 so we can't use DIALOGS_ABOUTDLG_SIMPLE here because it might not
+ // satisfy this condition and need to define and connect a separate id.
+ static const int DIALOGS_SYSTEM_ABOUT = 0x4010;
+
+ menu->Append(DIALOGS_SYSTEM_ABOUT, "&About...");
+ Connect(DIALOGS_SYSTEM_ABOUT, wxEVT_COMMAND_MENU_SELECTED,
+ wxCommandEventHandler(MyFrame::ShowSimpleAboutDialog));
+ }
+#endif // __WXMSW__
}
MyFrame::~MyFrame()
wxCENTER |
wxNO_DEFAULT | wxYES_NO | wxCANCEL |
wxICON_INFORMATION);
-
+
wxString extmsg;
if ( dialog.SetYesNoCancelLabels
(
"so the default \"Yes\"/\"No\"/\"Cancel\" buttons are used.";
}
dialog.SetExtendedMessage(extmsg);
-
+
switch ( dialog.ShowModal() )
{
case wxID_YES:
wxLogStatus(wxT("You pressed \"Yes\""));
break;
-
+
case wxID_NO:
wxLogStatus(wxT("You pressed \"No\""));
break;
-
+
case wxID_CANCEL:
wxLogStatus(wxT("You pressed \"Cancel\""));
break;
-
+
default:
wxLogError(wxT("Unexpected wxMessageDialog return code!"));
}
}
}
-void MyFrame::TextEntry(wxCommandEvent& WXUNUSED(event))
+void MyFrame::LineEntry(wxCommandEvent& WXUNUSED(event))
{
wxTextEntryDialog dialog(this,
wxT("This is a small sample\n")
wxMessageBox(dialog.GetValue(), wxT("Got string"), wxOK | wxICON_INFORMATION, this);
}
}
+
+void MyFrame::TextEntry(wxCommandEvent& WXUNUSED(event))
+{
+ wxTextEntryDialog dialog(this, "You can enter a multiline string here.",
+ "Please enter some text",
+ "First line\nSecond one\nAnd another one too",
+ wxOK | wxCANCEL | wxTE_MULTILINE);
+
+ if (dialog.ShowModal() == wxID_OK)
+ {
+ wxMessageBox(dialog.GetValue(), wxT("Got text"), wxOK | wxICON_INFORMATION, this);
+ }
+}
#endif // wxUSE_TEXTDLG
#if wxUSE_CHOICEDLG
#define ID_CATCH_LISTBOX_DCLICK 100
#define ID_LISTBOX 101
+#define ID_DISABLE_OK 102
+#define ID_DISABLE_CANCEL 103
BEGIN_EVENT_TABLE(TestDefaultActionDialog, wxDialog)
EVT_CHECKBOX(ID_CATCH_LISTBOX_DCLICK, TestDefaultActionDialog::OnCatchListBoxDClick)
+ EVT_CHECKBOX(ID_DISABLE_OK, TestDefaultActionDialog::OnDisableOK)
+ EVT_CHECKBOX(ID_DISABLE_CANCEL, TestDefaultActionDialog::OnDisableCancel)
EVT_LISTBOX_DCLICK(ID_LISTBOX, TestDefaultActionDialog::OnListBoxDClick)
+ EVT_TEXT_ENTER(wxID_ANY, TestDefaultActionDialog::OnTextEnter)
END_EVENT_TABLE()
TestDefaultActionDialog::TestDefaultActionDialog( wxWindow *parent ) :
grid_sizer->Add( new wxTextCtrl( this, -1, "", wxDefaultPosition, wxSize(80,-1), wxTE_PROCESS_ENTER ), 0, wxALIGN_CENTRE_VERTICAL );
grid_sizer->Add( new wxStaticText( this, -1, "wxTextCtrl with wxTE_PROCESS_ENTER" ), 0, wxALIGN_CENTRE_VERTICAL );
+ grid_sizer->Add( new wxCheckBox(this, ID_DISABLE_OK, "Disable \"OK\""), 0, wxALIGN_CENTRE_VERTICAL );
+ grid_sizer->Add( new wxCheckBox(this, ID_DISABLE_CANCEL, "Disable \"Cancel\""), 0, wxALIGN_CENTRE_VERTICAL );
+
main_sizer->Add( grid_sizer, 0, wxALL, 10 );
wxSizer *button_sizer = CreateSeparatedButtonSizer( wxOK|wxCANCEL );
SetSizerAndFit( main_sizer );
}
+void TestDefaultActionDialog::OnDisableOK(wxCommandEvent& event)
+{
+ FindWindow(wxID_OK)->Enable(!event.IsChecked());
+}
+
+void TestDefaultActionDialog::OnDisableCancel(wxCommandEvent& event)
+{
+ FindWindow(wxID_CANCEL)->Enable(!event.IsChecked());
+}
+
void TestDefaultActionDialog::OnListBoxDClick(wxCommandEvent& event)
{
event.Skip( !m_catchListBoxDClick );
m_catchListBoxDClick = !m_catchListBoxDClick;
}
+void TestDefaultActionDialog::OnTextEnter(wxCommandEvent& event)
+{
+ wxLogMessage("Text \"%s\" entered.", event.GetString());
+}
+
void MyFrame::OnTestDefaultActionDialog(wxCommandEvent& WXUNUSED(event))
{
TestDefaultActionDialog dialog( this );
{ wxNO, "&No" },
{ wxOK, "&Ok" },
{ wxCANCEL, "&Cancel" },
+ { wxHELP, "&Help" },
};
BEGIN_EVENT_TABLE(TestMessageBoxDialog, wxDialog)
};
wxCOMPILE_TIME_ASSERT( WXSIZEOF(icons) == MsgDlgIcon_Max, IconMismatch );
-
+
m_icons = new wxRadioBox(this, wxID_ANY, "&Icon style",
wxDefaultPosition, wxDefaultSize,
WXSIZEOF(icons), icons,
dlg.SetOKLabel(m_labels[Btn_Ok]->GetValue());
}
}
+
+ if ( style & wxHELP )
+ {
+ dlg.SetHelpLabel(m_labels[Btn_Help]->GetValue());
+ }
}
void TestMessageBoxDialog::OnApply(wxCommandEvent& WXUNUSED(event))
wxMessageDialog dlg(this, GetMessage(), "Test Message Box", GetStyle());
PrepareMessageDialog(dlg);
- dlg.ShowModal();
+ wxString btnName;
+ switch ( dlg.ShowModal() )
+ {
+ case wxID_OK:
+ btnName = "OK";
+ break;
+
+ case wxID_CANCEL:
+ // Avoid the extra message box if the dialog was cancelled.
+ return;
+
+ case wxID_YES:
+ btnName = "Yes";
+ break;
+
+ case wxID_NO:
+ btnName = "No";
+ break;
+
+ case wxID_HELP:
+ btnName = "Help";
+ break;
+
+ default:
+ btnName = "Unknown";
+ }
+
+ wxLogMessage("Dialog was closed with the \"%s\" button.", btnName);
}
void TestMessageBoxDialog::OnClose(wxCommandEvent& WXUNUSED(event))