wxMessageDialog::wxMessageDialog(wxWindow *parent, const wxString& message, const wxString& caption, long style, const wxPoint& pos) { m_caption = caption; m_message = message; m_parent = parent; SetMessageDialogStyle(style); }
wxMessageDialog::wxMessageDialog( wxWindow* WXUNUSED(pParent), const wxString& rsMessage, const wxString& rsCaption, long lStyle, const wxPoint& WXUNUSED(pPos) ) { m_sCaption = rsCaption; m_sMessage = rsMessage; m_pParent = NULL; // pParent; SetMessageDialogStyle(lStyle); } // end of wxMessageDialog::wxMessageDialog
wxMessageDialog::wxMessageDialog(wxWindow *parent, const wxString& message, const wxString& caption, long style, const wxPoint& WXUNUSED(pos)) { m_caption = caption; m_message = message; SetMessageDialogStyle(style); m_parent = wxGetTopLevelParent(parent); GtkMessageType type = GTK_MESSAGE_ERROR; GtkButtonsType buttons = GTK_BUTTONS_OK; if (style & wxYES_NO) { buttons = GTK_BUTTONS_YES_NO; } if (style & wxOK) { if (style & wxCANCEL) buttons = GTK_BUTTONS_OK_CANCEL; else buttons = GTK_BUTTONS_OK; } if (style & wxICON_EXCLAMATION) type = GTK_MESSAGE_WARNING; else if (style & wxICON_ERROR) type = GTK_MESSAGE_ERROR; else if (style & wxICON_INFORMATION) type = GTK_MESSAGE_INFO; else if (style & wxICON_QUESTION) type = GTK_MESSAGE_QUESTION; else { // GTK+ doesn't have a "typeless" msg box, so try to auto detect... type = style & wxYES ? GTK_MESSAGE_QUESTION : GTK_MESSAGE_INFO; } m_widget = gtk_message_dialog_new(m_parent ? GTK_WINDOW(m_parent->m_widget) : NULL, GTK_DIALOG_MODAL, type, buttons, "%s", (const char*)wxGTK_CONV(m_message)); if (m_caption != wxMessageBoxCaptionStr) gtk_window_set_title(GTK_WINDOW(m_widget), wxGTK_CONV(m_caption)); if (style & wxYES_NO) { if (style & wxCANCEL) gtk_dialog_add_button(GTK_DIALOG(m_widget), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); if (style & wxNO_DEFAULT) gtk_dialog_set_default_response(GTK_DIALOG(m_widget), GTK_RESPONSE_NO); else gtk_dialog_set_default_response(GTK_DIALOG(m_widget), GTK_RESPONSE_YES); } if (m_parent) gtk_window_set_transient_for(GTK_WINDOW(m_widget), GTK_WINDOW(m_parent->m_widget)); }
wxGenericMessageDialog::wxGenericMessageDialog( wxWindow *parent, const wxString& message, const wxString& caption, long style, const wxPoint& pos) : wxDialog( parent, wxID_ANY, caption, pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE ) { SetMessageDialogStyle(style); bool is_pda = (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA); wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer *icon_text = new wxBoxSizer( wxHORIZONTAL ); #if wxUSE_STATBMP // 1) icon if (style & wxICON_MASK) { wxBitmap bitmap; switch ( style & wxICON_MASK ) { default: wxFAIL_MSG(_T("incorrect log style")); // fall through case wxICON_ERROR: bitmap = wxArtProvider::GetIcon(wxART_ERROR, wxART_MESSAGE_BOX); break; case wxICON_INFORMATION: bitmap = wxArtProvider::GetIcon(wxART_INFORMATION, wxART_MESSAGE_BOX); break; case wxICON_WARNING: bitmap = wxArtProvider::GetIcon(wxART_WARNING, wxART_MESSAGE_BOX); break; case wxICON_QUESTION: bitmap = wxArtProvider::GetIcon(wxART_QUESTION, wxART_MESSAGE_BOX); break; } wxStaticBitmap *icon = new wxStaticBitmap(this, wxID_ANY, bitmap); if (is_pda) topsizer->Add( icon, 0, wxTOP|wxLEFT|wxRIGHT | wxALIGN_LEFT, 10 ); else icon_text->Add( icon, 0, wxCENTER ); } #endif // wxUSE_STATBMP #if wxUSE_STATTEXT // 2) text icon_text->Add( CreateTextSizer( message ), 0, wxALIGN_CENTER | wxLEFT, 10 ); topsizer->Add( icon_text, 1, wxCENTER | wxLEFT|wxRIGHT|wxTOP, 10 ); #endif // wxUSE_STATTEXT // 3) buttons int center_flag = wxEXPAND; if (style & wxYES_NO) center_flag = wxALIGN_CENTRE; wxSizer *sizerBtn = CreateSeparatedButtonSizer(style & ButtonSizerFlags); if ( sizerBtn ) topsizer->Add(sizerBtn, 0, center_flag | wxALL, 10 ); SetAutoLayout( true ); SetSizer( topsizer ); topsizer->SetSizeHints( this ); topsizer->Fit( this ); wxSize size( GetSize() ); if (size.x < size.y*3/2) { size.x = size.y*3/2; SetSize( size ); } Centre( wxBOTH | wxCENTER_FRAME); }