X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ede7b01760e920b31520b15c919445db882a8012..ca77701441e39245dcbfce903049e76f166979e5:/include/wx/msgdlg.h diff --git a/include/wx/msgdlg.h b/include/wx/msgdlg.h index 7e2eb5c80c..4dbd2d5ac2 100644 --- a/include/wx/msgdlg.h +++ b/include/wx/msgdlg.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wx/msgdlgg.h +// Name: wx/msgdlg.h // Purpose: common header and base class for wxMessageDialog // Author: Julian Smart // Modified by: @@ -19,7 +19,7 @@ #include "wx/dialog.h" #include "wx/stockitem.h" -WXDLLIMPEXP_DATA_CORE(extern const char) wxMessageBoxCaptionStr[]; +extern WXDLLIMPEXP_DATA_CORE(const char) wxMessageBoxCaptionStr[]; // ---------------------------------------------------------------------------- // wxMessageDialogBase: base class defining wxMessageDialog interface @@ -125,8 +125,12 @@ public: wxASSERT_MSG( !(style & wxYES) || !(style & wxOK), "wxOK and wxYES/wxNO can't be used together" ); - wxASSERT_MSG( (style & wxYES) || (style & wxOK), - "one of wxOK and wxYES/wxNO must be used" ); + // It is common to specify just the icon, without wxOK, in the existing + // code, especially one written by Windows programmers as MB_OK is 0 + // and so they're used to omitting wxOK. Don't complain about it but + // just add wxOK implicitly for compatibility. + if ( !(style & wxYES) && !(style & wxOK) ) + style |= wxOK; wxASSERT_MSG( (style & wxID_OK) != wxID_OK, "wxMessageBox: Did you mean wxOK (and not wxID_OK)?" ); @@ -177,10 +181,16 @@ public: return true; } + virtual bool SetHelpLabel(const ButtonLabel& help) + { + DoSetCustomLabel(m_help, help); + return true; + } + // test if any custom labels were set bool HasCustomLabels() const { - return !(m_ok.empty() && m_cancel.empty() && + return !(m_ok.empty() && m_cancel.empty() && m_help.empty() && m_yes.empty() && m_no.empty()); } @@ -195,6 +205,8 @@ public: { return m_ok.empty() ? GetDefaultOKLabel() : m_ok; } wxString GetCancelLabel() const { return m_cancel.empty() ? GetDefaultCancelLabel() : m_cancel; } + wxString GetHelpLabel() const + { return m_help.empty() ? GetDefaultHelpLabel() : m_help; } // based on message dialog style, returns exactly one of: wxICON_NONE, // wxICON_ERROR, wxICON_WARNING, wxICON_QUESTION, wxICON_INFORMATION @@ -242,6 +254,17 @@ protected: var = label.GetAsString(); } + // these functions return the custom label or empty string and should be + // used only in specific circumstances such as creating the buttons with + // these labels (in which case it makes sense to only use a custom label if + // it was really given and fall back on stock label otherwise), use the + // Get{Yes,No,OK,Cancel}Label() methods above otherwise + const wxString& GetCustomYesLabel() const { return m_yes; } + const wxString& GetCustomNoLabel() const { return m_no; } + const wxString& GetCustomOKLabel() const { return m_ok; } + const wxString& GetCustomHelpLabel() const { return m_help; } + const wxString& GetCustomCancelLabel() const { return m_cancel; } + private: // these functions may be overridden to provide different defaults for the // default button labels (this is used by wxGTK) @@ -249,13 +272,15 @@ private: virtual wxString GetDefaultNoLabel() const { return wxGetTranslation("No"); } virtual wxString GetDefaultOKLabel() const { return wxGetTranslation("OK"); } virtual wxString GetDefaultCancelLabel() const { return wxGetTranslation("Cancel"); } + virtual wxString GetDefaultHelpLabel() const { return wxGetTranslation("Help"); } // labels for the buttons, initially empty meaning that the defaults should // be used, use GetYes/No/OK/CancelLabel() to access them wxString m_yes, m_no, m_ok, - m_cancel; + m_cancel, + m_help; wxDECLARE_NO_COPY_CLASS(wxMessageDialogBase); }; @@ -269,8 +294,6 @@ private: #define wxMessageDialog wxGenericMessageDialog #elif defined(__WXCOCOA__) #include "wx/cocoa/msgdlg.h" -#elif defined(__WXPALMOS__) - #include "wx/palmos/msgdlg.h" #elif defined(__WXMSW__) #include "wx/msw/msgdlg.h" #elif defined(__WXMOTIF__)