- Added wxDC::StretchBlit() for wxMac and wxMSW (Vince Harron)
- Added support for drop down toolbar buttons (Tim Kosse)
- Added support for labels for toolbar controls (Vince Harron)
+- Added wxMessageDialog::SetMessage() and SetExtendedMessage()
- Added wxEventBlocker class (Francesco Montorsi).
- Added wxFile/DirPickerCtrl::Get/SetFile/DirName() (Francesco Montorsi).
- Added wxSizerFlags::Top() and Bottom().
wxMac:
- Better IconRef support (Alan Shouls)
+- Added support for changing button labels in wxMessageDialog (Gareth Simpson)
- Fix duplicate (empty) help menu in non-English programs (Andreas Jacobs)
- Allow accelerators to be used with buttons too (Ryan Wilcox)
- Support resource forks in wxCopyFile() (Hank Schultz)
\latexignore{\rtfignore{\wxheading{Members}}}
+
\membersection{wxMessageDialog::wxMessageDialog}\label{wxmessagedialogctor}
\func{}{wxMessageDialog}{\param{wxWindow* }{parent}, \param{const wxString\& }{message},\rtfsp
\docparam{pos}{Dialog position. Not Windows.}
+
\membersection{wxMessageDialog::\destruct{wxMessageDialog}}\label{wxmessagedialogdtor}
\func{}{\destruct{wxMessageDialog}}{\void}
Destructor.
+
\membersection{wxMessageDialog::ShowModal}\label{wxmessagedialogshowmodal}
\func{int}{ShowModal}{\void}
Shows the dialog, returning one of wxID\_OK, wxID\_CANCEL, wxID\_YES, wxID\_NO.
+
+\membersection{wxMessageDialog::SetYesNoLabels}\label{wxmessagedialogsetyesnolabels}
+
+\func{bool}{SetYesNoLabels}{\param{const wxString&}{yes},\param{const wxString&}{no}}
+
+Overrides the default labels of the Yes and No buttons.
+
+Notice that this function is not currently available on all platforms, so it
+may return \false to indicate that the labels couldn't be changed. If it
+returns \true (currently only under wxMac), the labels were set successfully.
+Typically, if the function was used successfully, the main dialog message may
+need to be changed, e.g.:
+\begin{verbatim}
+ wxMessageDialog dlg(...);
+ if ( dlg.SetYesNoLabels(_("&Quit"), _("&Don't quit")) )
+ dlg.SetMessage(_("What do you want to do?"));
+ else // buttons have standard "Yes"/"No" values, so rephrase the question
+ dlg.SetMessage(_("Do you really want to quit?"));
+\end{verbatim}
+
+
+\membersection{wxMessageDialog::SetYesNoCancelLabels}\label{wxmessagedialogsetyesnocancellabels}
+
+\func{bool}{SetYesNoCancelLabels}{\param{const wxString&}{yes},\param{const wxString&}{no},\param{const wxString&}{cancel}}
+
+Overrides the default labels of the Yes, No and Cancel buttons.
+
+Please see the remarks in
+\helpref{SetYesNoLabels}{wxmessagedialogsetyesnolabels} documentation.
+
+
+\membersection{wxMessageDialog::SetOKLabel}\label{wxmessagedialogsetyesoklabel}
+
+\func{bool}{SetOKLabel}{\param{const wxString&}{ok}}
+
+Overrides the default label of the OK button.
+
+Please see the remarks in
+\helpref{SetYesNoLabels}{wxmessagedialogsetyesnolabels} documentation.
+
+
+\membersection{wxMessageDialog::SetOKCancelLabels}\label{wxmessagedialogsetokcancellabels}
+
+\func{bool}{SetOKCancelLabels}{\param{const wxString&}{ok},\param{const wxString&}{cancel}}
+
+Overrides the default labels of the OK and Cancel buttons.
+
+Please see the remarks in
+\helpref{SetYesNoLabels}{wxmessagedialogsetyesnolabels} documentation.
+
+
+\membersection{wxMessageDialog::SetMessage}\label{wxmessagedialogsetmessage}
+
+\func{void}{SetMessage}{\param{const wxString&}{msg}}
+
+Sets the message shown by the dialog.
+
+
+\membersection{wxMessageDialog::SetExtendedMessage}\label{wxmessagedialogsetextendedmessage}
+
+\func{void}{SetExtendedMessage}{\param{const wxString&}{exMsg}
+
+Sets the extended message for the dialog: this message is usually an extension
+of the short message specified in the constructor or set with
+\helpref{SetMessage}{wxmessagedialogsetmessage}. If it is set, the main message
+appears highlighted -- if supported -- and this message appears beneath it in
+normal font. On the platforms which don't support extended messages, it is
+simply appended to the normal message with a new line separating them.
+
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifndef __MSGDLGH_G__
-#define __MSGDLGH_G__
+#ifndef _WX_GENERIC_MSGDLGG_H_
+#define _WX_GENERIC_MSGDLGG_H_
-#include "wx/defs.h"
-#include "wx/dialog.h"
-
-// type is an 'or' (|) of wxOK, wxCANCEL, wxYES_NO
-// Returns wxYES/NO/OK/CANCEL
-
-extern WXDLLEXPORT_DATA(const wxChar) wxMessageBoxCaptionStr[];
-
-class WXDLLEXPORT wxGenericMessageDialog: public wxDialog, public wxMessageDialogBase
+class WXDLLEXPORT wxGenericMessageDialog : public wxMessageDialogBase
{
-DECLARE_DYNAMIC_CLASS(wxGenericMessageDialog)
-
public:
- wxGenericMessageDialog(wxWindow *parent, const wxString& message,
- const wxString& caption = wxMessageBoxCaptionStr,
- long style = wxOK|wxCENTRE, const wxPoint& pos = wxDefaultPosition);
+ wxGenericMessageDialog(wxWindow *parent,
+ const wxString& message,
+ const wxString& caption = wxMessageBoxCaptionStr,
+ long style = wxOK|wxCENTRE,
+ const wxPoint& pos = wxDefaultPosition);
+ virtual int ShowModal();
+
+protected:
void OnYes(wxCommandEvent& event);
void OnNo(wxCommandEvent& event);
void OnCancel(wxCommandEvent& event);
private:
+ void DoCreateMsgdialog();
+
+ wxPoint m_pos;
+ bool m_created;
+
DECLARE_EVENT_TABLE()
+ DECLARE_DYNAMIC_CLASS(wxGenericMessageDialog)
};
-#if (!defined( __WXMSW__ ) && !defined( __WXMAC__) && !defined(__WXPM__)) || defined(__WXUNIVERSAL__)
-#define wxMessageDialog wxGenericMessageDialog
-#endif
-
-#endif // __MSGDLGH_G__
+#endif // _WX_GENERIC_MSGDLGG_H_
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifndef __MSGDLG_H__
-#define __MSGDLG_H__
+#ifndef _WX_GTK_MSGDLG_H_
+#define _WX_GTK_MSGDLG_H_
-#include "wx/defs.h"
-#include "wx/dialog.h"
-
-// type is an 'or' (|) of wxOK, wxCANCEL, wxYES_NO
-// Returns wxYES/NO/OK/CANCEL
-
-WXDLLEXPORT_DATA(extern const wxChar) wxMessageBoxCaptionStr[];
-
-class WXDLLEXPORT wxMessageDialog: public wxDialog, public wxMessageDialogBase
+class WXDLLEXPORT wxMessageDialog : public wxMessageDialogBase
{
public:
wxMessageDialog(wxWindow *parent, const wxString& message,
const wxString& caption = wxMessageBoxCaptionStr,
long style = wxOK|wxCENTRE,
const wxPoint& pos = wxDefaultPosition);
- virtual ~wxMessageDialog();
- int ShowModal();
+ virtual int ShowModal();
virtual bool Show( bool WXUNUSED(show) = true ) { return false; };
protected:
int WXUNUSED(width), int WXUNUSED(height)) {}
private:
- wxString m_caption;
- wxString m_message;
+ // create the real GTK+ dialog: this is done from ShowModal() to allow
+ // changing the message between constructing the dialog and showing it
+ void GTKCreateMsgDialog();
DECLARE_DYNAMIC_CLASS(wxMessageDialog)
};
-#endif
+#endif // _WX_GTK_MSGDLG_H_
#ifndef _WX_MSGBOXDLG_H_
#define _WX_MSGBOXDLG_H_
-#include "wx/defs.h"
-#include "wx/dialog.h"
-
-/*
- * Message box dialog
- */
-
-WXDLLEXPORT_DATA(extern const wxChar) wxMessageBoxCaptionStr[];
-
-class WXDLLEXPORT wxMessageDialog: public wxDialog, public wxMessageDialogBase
+class WXDLLEXPORT wxMessageDialog : public wxMessageDialogBase
{
- DECLARE_DYNAMIC_CLASS(wxMessageDialog)
-
-protected:
- wxString m_caption;
- wxString m_message;
- wxWindow * m_parent;
public:
wxMessageDialog(wxWindow *parent,
const wxString& message,
long style = wxOK|wxCENTRE,
const wxPoint& pos = wxDefaultPosition);
- int ShowModal();
+ virtual int ShowModal();
+
+ // customization of the message box
+ virtual bool SetYesNoLabels(const wxString& yes,const wxString& no);
+ virtual bool SetYesNoCancelLabels(const wxString& yes, const wxString& no, const wxString& cancel);
+ virtual bool SetOKLabel(const wxString& ok);
+ virtual bool SetOKCancelLabels(const wxString& ok, const wxString& cancel);
protected:
- // not supported for message dialog, RR
+ // not supported for message dialog
virtual void DoSetSize(int WXUNUSED(x), int WXUNUSED(y),
int WXUNUSED(width), int WXUNUSED(height),
int WXUNUSED(sizeFlags) = wxSIZE_AUTO) {}
+ // labels for the buttons
+ wxString m_yes,
+ m_no,
+ m_ok,
+ m_cancel;
+
+ DECLARE_DYNAMIC_CLASS(wxMessageDialog)
};
-#endif
- // _WX_MSGBOXDLG_H_
+#endif // _WX_MSGBOXDLG_H_
#ifndef _WX_MSGBOXDLG_H_
#define _WX_MSGBOXDLG_H_
-#include "wx/defs.h"
-#include "wx/dialog.h"
-
// ----------------------------------------------------------------------------
// Message box dialog
// ----------------------------------------------------------------------------
-WXDLLEXPORT_DATA(extern const wxChar) wxMessageBoxCaptionStr[];
-
-class WXDLLEXPORT wxMessageDialog: public wxDialog, public wxMessageDialogBase
+class WXDLLEXPORT wxMessageDialog : public wxMessageDialogBase
{
- DECLARE_DYNAMIC_CLASS(wxMessageDialog)
-
public:
wxMessageDialog(wxWindow *parent,
- const wxString& message,
- const wxString& caption = wxMessageBoxCaptionStr,
- long style = wxOK | wxCENTRE,
- const wxPoint& pos = wxDefaultPosition);
+ const wxString& message,
+ const wxString& caption = wxMessageBoxCaptionStr,
+ long style = wxOK | wxCENTRE,
+ const wxPoint& WXUNUSED(pos) = wxDefaultPosition)
+ : wxMessageDialogBase(parent, message, caption, style)
+ {
+ }
- int ShowModal();
+ virtual int ShowModal();
// implementation only from now on
// called by the Motif callback
void SetResult(long result) { m_result = result; }
protected:
- wxString m_caption;
- wxString m_message;
- wxWindow * m_parent;
long m_result;
+
+ DECLARE_DYNAMIC_CLASS(wxMessageDialog)
};
-#endif
-// _WX_MSGBOXDLG_H_
+#endif // _WX_MSGBOXDLG_H_
#if wxUSE_MSGDLG
-class WXDLLEXPORT wxMessageDialogBase
+#include "wx/dialog.h"
+
+WXDLLEXPORT_DATA(extern const wxChar) wxMessageBoxCaptionStr[];
+
+class WXDLLEXPORT wxMessageDialogBase : public wxDialog
{
+public:
+ // ctors
+ wxMessageDialogBase() { m_dialogStyle = 0; }
+ wxMessageDialogBase(wxWindow *parent,
+ const wxString& message,
+ const wxString& caption,
+ long style)
+ : m_message(message),
+ m_caption(caption)
+ {
+ m_parent = parent;
+ SetMessageDialogStyle(style);
+ }
+
+ // virtual dtor for the base class
+ virtual ~wxMessageDialogBase() { }
+
+
+ // methods for setting up more custom message dialogs -- all functions
+ // return false if they're not implemented
+ virtual bool SetYesNoLabels(const wxString& WXUNUSED(yes),
+ const wxString& WXUNUSED(no))
+ {
+ return false;
+ }
+
+ virtual bool SetYesNoCancelLabels(const wxString& WXUNUSED(yes),
+ const wxString& WXUNUSED(no),
+ const wxString& WXUNUSED(cancel))
+ {
+ return false;
+ }
+
+ virtual bool SetOKLabel(const wxString& WXUNUSED(ok))
+ {
+ return false;
+ }
+
+ virtual bool SetOKCancelLabels(const wxString& WXUNUSED(ok),
+ const wxString& WXUNUSED(cancel))
+ {
+ return false;
+ }
+
+ virtual void SetMessage(const wxString& message)
+ {
+ m_message = message;
+ }
+
+ virtual void SetExtendedMessage(const wxString& extendedMessage)
+ {
+ m_extendedMessage = extendedMessage;
+ }
+
protected:
// common validation of wxMessageDialog style
void SetMessageDialogStyle(long style)
m_dialogStyle = style;
}
- inline long GetMessageDialogStyle() const
+
+ long GetMessageDialogStyle() const { return m_dialogStyle; }
+
+
+ // for the platforms not supporting separate main and extended messages
+ // this function should be used to combine both of them in a single string
+ wxString GetFullMessage() const
{
- return m_dialogStyle;
+ wxString msg = m_message;
+ if ( !m_extendedMessage.empty() )
+ msg << "\n\n" << m_extendedMessage;
+
+ return msg;
}
-private:
+ wxString m_message,
+ m_extendedMessage,
+ m_caption;
long m_dialogStyle;
};
-#if defined(__WX_COMPILING_MSGDLGG_CPP__)
-#include "wx/generic/msgdlgg.h"
-#elif defined(__WXUNIVERSAL__) || defined(__WXGPE__)
-#include "wx/generic/msgdlgg.h"
+#if defined(__WX_COMPILING_MSGDLGG_CPP__) || \
+ defined(__WXUNIVERSAL__) || defined(__WXGPE__) || \
+ defined(__WXCOCOA__) || \
+ (defined(__WXGTK__) && !defined(__WXGTK20__))
+ #include "wx/generic/msgdlgg.h"
+
+ #define wxMessageDialog wxGenericMessageDialog
#elif defined(__WXPALMOS__)
-#include "wx/palmos/msgdlg.h"
+ #include "wx/palmos/msgdlg.h"
#elif defined(__WXMSW__)
-#include "wx/msw/msgdlg.h"
+ #include "wx/msw/msgdlg.h"
#elif defined(__WXMOTIF__)
-#include "wx/motif/msgdlg.h"
+ #include "wx/motif/msgdlg.h"
#elif defined(__WXGTK20__)
-#include "wx/gtk/msgdlg.h"
-#elif defined(__WXGTK__)
-#include "wx/generic/msgdlgg.h"
-#elif defined(__WXGTK__)
-#include "wx/generic/msgdlgg.h"
+ #include "wx/gtk/msgdlg.h"
#elif defined(__WXMAC__)
-#include "wx/mac/msgdlg.h"
-#elif defined(__WXCOCOA__)
-#include "wx/generic/msgdlgg.h"
+ #include "wx/mac/msgdlg.h"
#elif defined(__WXPM__)
-#include "wx/os2/msgdlg.h"
+ #include "wx/os2/msgdlg.h"
#endif
// ----------------------------------------------------------------------------
#endif // wxUSE_MSGDLG
-#endif
- // _WX_MSGDLG_H_BASE_
+#endif // _WX_MSGDLG_H_BASE_
#ifndef _WX_MSGBOXDLG_H_
#define _WX_MSGBOXDLG_H_
-#include "wx/defs.h"
-#include "wx/dialog.h"
-
-/*
- * Message box dialog
- */
-
-extern WXDLLEXPORT_DATA(const wxChar) wxMessageBoxCaptionStr[];
-
-class WXDLLEXPORT wxMessageDialog: public wxDialog, public wxMessageDialogBase
+class WXDLLEXPORT wxMessageDialog : public wxMessageDialogBase
{
-DECLARE_DYNAMIC_CLASS(wxMessageDialog)
-protected:
- wxString m_caption;
- wxString m_message;
- wxWindow * m_parent;
public:
- wxMessageDialog(wxWindow *parent, const wxString& message, const wxString& caption = wxMessageBoxCaptionStr,
- long style = wxOK|wxCENTRE, const wxPoint& pos = wxDefaultPosition);
+ wxMessageDialog(wxWindow *parent,
+ const wxString& message,
+ const wxString& caption = wxMessageBoxCaptionStr,
+ long style = wxOK|wxCENTRE,
+ const wxPoint& WXUNUSED(pos) = wxDefaultPosition)
+ : wxMessageDialogBase(parent, message, caption, style)
+ {
+ }
+
- int ShowModal(void);
+ virtual int ShowModal();
+protected:
+ DECLARE_DYNAMIC_CLASS(wxMessageDialog)
DECLARE_NO_COPY_CLASS(wxMessageDialog)
};
-#endif
- // _WX_MSGBOXDLG_H_
+#endif // _WX_MSGBOXDLG_H_
#ifndef _WX_MSGBOXDLG_H_
#define _WX_MSGBOXDLG_H_
-#include "wx/defs.h"
-#include "wx/dialog.h"
-
-/*
- * Message box dialog
- */
-
-class WXDLLEXPORT wxMessageDialog : public wxDialog, public wxMessageDialogBase
+class WXDLLEXPORT wxMessageDialog : public wxMessageDialogBase
{
-DECLARE_DYNAMIC_CLASS(wxMessageDialog)
public:
wxMessageDialog( wxWindow* pParent
,const wxString& rsMessage
,const wxString& rsCaption = wxMessageBoxCaptionStr
,long lStyle = wxOK|wxCENTRE
- ,const wxPoint& rPos = wxDefaultPosition
- );
+ ,const wxPoint& WXUNUSED(rPos) = wxDefaultPosition
+ )
+ : wxMessageDialogBase(pParent, rsMessage, rsCaption, lStyle)
+ {
+ }
int ShowModal(void);
protected:
- wxString m_sCaption;
- wxString m_sMessage;
- wxWindow* m_pParent;
+ DECLARE_DYNAMIC_CLASS(wxMessageDialog)
}; // end of CLASS wxMessageDialog
-#endif
- // _WX_MSGBOXDLG_H_
+#endif // _WX_MSGBOXDLG_H_
#ifndef _WX_MSGBOXDLG_H_
#define _WX_MSGBOXDLG_H_
-#include "wx/defs.h"
-#include "wx/dialog.h"
-
-/*
- * Message box dialog
- */
-
-WXDLLEXPORT_DATA(extern const wxChar) wxMessageBoxCaptionStr[];
-
-class WXDLLEXPORT wxMessageDialog: public wxDialog, public wxMessageDialogBase
+class WXDLLEXPORT wxMessageDialog : public wxMessageDialogBase
{
-DECLARE_DYNAMIC_CLASS(wxMessageDialog)
-protected:
- wxString m_caption;
- wxString m_message;
- wxWindow * m_parent;
public:
- wxMessageDialog(wxWindow *parent, const wxString& message, const wxString& caption = wxMessageBoxCaptionStr,
- long style = wxOK|wxCENTRE, const wxPoint& pos = wxDefaultPosition);
-
- int ShowModal(void);
-
+ wxMessageDialog(wxWindow *parent,
+ const wxString& message,
+ const wxString& caption = wxMessageBoxCaptionStr,
+ long style = wxOK|wxCENTRE,
+ const wxPoint& WXUNUSED(pos) = wxDefaultPosition)
+ : wxMessageDialogBase(parent, message, caption, style)
+ {
+ }
+
+ virtual int ShowModal(void);
+
+ DECLARE_DYNAMIC_CLASS(wxMessageDialog)
DECLARE_NO_COPY_CLASS(wxMessageDialog)
};
void MyFrame::MessageBox(wxCommandEvent& WXUNUSED(event) )
{
- wxMessageDialog dialog( NULL, _T("This is a message box\nA long, long string to test out the message box properly"),
- _T("Message box text"), wxNO_DEFAULT|wxYES_NO|wxCANCEL|wxICON_INFORMATION);
+ wxMessageDialog dialog(NULL,
+ _T("This is a message box\nA long, long string to test out the message box properly"),
+ _T("Message box text"),
+ wxNO_DEFAULT | wxYES_NO | wxCANCEL | wxICON_INFORMATION);
+
+ if ( dialog.SetYesNoLabels(_T("Answer &Yes"),_T("Answer &No")) )
+ {
+ dialog.SetExtendedMessage(_T("This platform supports custom button labels"));
+ }
+ else
+ {
+ dialog.SetExtendedMessage(_T("Custom button labels are not supported."));
+ }
switch ( dialog.ShowModal() )
{
const wxString& caption,
long style,
const wxPoint& pos)
- : wxDialog( parent, wxID_ANY, caption, pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE )
+ : wxMessageDialogBase(GetParentForModalDialog(parent),
+ message,
+ caption,
+ style),
+ m_pos(pos)
{
- SetMessageDialogStyle(style);
+ m_created = false;
+}
- parent = GetParentForModalDialog(parent);
+void wxGenericMessageDialog::DoCreateMsgdialog()
+{
+ wxDialog::Create(m_parent, wxID_ANY, m_caption, m_pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE);
bool is_pda = (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA);
#if wxUSE_STATBMP
// 1) icon
- if (style & wxICON_MASK)
+ if (m_dialogStyle & wxICON_MASK)
{
wxBitmap bitmap;
- switch ( style & wxICON_MASK )
+ switch ( m_dialogStyle & wxICON_MASK )
{
default:
wxFAIL_MSG(_T("incorrect log style"));
#if wxUSE_STATTEXT
// 2) text
- icon_text->Add( CreateTextSizer( message ), 0, wxALIGN_CENTER | wxLEFT, 10 );
+ icon_text->Add( CreateTextSizer( GetFullMessage() ), 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)
+ if (m_dialogStyle & wxYES_NO)
center_flag = wxALIGN_CENTRE;
- wxSizer *sizerBtn = CreateSeparatedButtonSizer(style & ButtonSizerFlags);
+ wxSizer *sizerBtn = CreateSeparatedButtonSizer(m_dialogStyle & ButtonSizerFlags);
if ( sizerBtn )
topsizer->Add(sizerBtn, 0, center_flag | wxALL, 10 );
}
}
+int wxGenericMessageDialog::ShowModal()
+{
+ if ( !m_created )
+ {
+ m_created = true;
+ DoCreateMsgdialog();
+ }
+
+ return wxMessageDialogBase::ShowModal();
+}
+
#endif // wxUSE_MSGDLG && !defined(__WXGTK20__)
const wxString& caption,
long style,
const wxPoint& WXUNUSED(pos))
+ : wxMessageDialogBase(GetParentForModalDialog(parent),
+ message,
+ caption,
+ style)
{
- m_caption = caption;
- m_message = message;
- SetMessageDialogStyle(style);
-
- m_parent = GetParentForModalDialog(parent);
+}
+void wxMessageDialog::GTKCreateMsgDialog()
+{
GtkMessageType type = GTK_MESSAGE_ERROR;
GtkButtonsType buttons = GTK_BUTTONS_OK;
- if (style & wxYES_NO)
+ if (m_dialogStyle & wxYES_NO)
{
- if (style & wxCANCEL)
+ if (m_dialogStyle & wxCANCEL)
buttons = GTK_BUTTONS_NONE;
else
buttons = GTK_BUTTONS_YES_NO;
}
- if (style & wxOK)
+ if (m_dialogStyle & wxOK)
{
- if (style & wxCANCEL)
+ if (m_dialogStyle & wxCANCEL)
buttons = GTK_BUTTONS_OK_CANCEL;
else
buttons = GTK_BUTTONS_OK;
}
- if (style & wxICON_EXCLAMATION)
+ if (m_dialogStyle & wxICON_EXCLAMATION)
type = GTK_MESSAGE_WARNING;
- else if (style & wxICON_ERROR)
+ else if (m_dialogStyle & wxICON_ERROR)
type = GTK_MESSAGE_ERROR;
- else if (style & wxICON_INFORMATION)
+ else if (m_dialogStyle & wxICON_INFORMATION)
type = GTK_MESSAGE_INFO;
- else if (style & wxICON_QUESTION)
+ else if (m_dialogStyle & 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;
+ type = m_dialogStyle & wxYES ? GTK_MESSAGE_QUESTION : GTK_MESSAGE_INFO;
}
- m_widget = gtk_message_dialog_new(m_parent ?
- GTK_WINDOW(m_parent->m_widget) : NULL,
+ wxString message;
+#if GTK_CHECK_VERSION(2, 4, 0)
+ bool needsExtMessage = false;
+ if ( gtk_check_version(2, 4, 0) == NULL && !m_extendedMessage.empty() )
+ {
+ message = m_message;
+ needsExtMessage = true;
+ }
+ else // extended message not needed or not supported
+#endif // GTK+ 2.4+
+ {
+ message = GetFullMessage();
+ }
+
+ 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));
+ type,
+ buttons,
+ "%s",
+ (const char*)wxGTK_CONV(message));
+
+#if GTK_CHECK_VERSION(2, 4, 0)
+ if ( needsExtMessage )
+ {
+ gtk_message_dialog_format_secondary_text
+ (
+ (GtkMessageDialog *)m_widget,
+ "%s",
+ (const char *)wxGTK_CONV(m_extendedMessage)
+ );
+ }
+#endif // GTK+ 2.4+
+
if (m_caption != wxMessageBoxCaptionStr)
gtk_window_set_title(GTK_WINDOW(m_widget), wxGTK_CONV(m_caption));
- if (style & wxYES_NO)
+ if (m_dialogStyle & wxYES_NO)
{
- if (style & wxCANCEL)
+ if (m_dialogStyle & wxCANCEL)
{
gtk_dialog_add_button(GTK_DIALOG(m_widget), GTK_STOCK_NO,
GTK_RESPONSE_NO);
gtk_dialog_add_button(GTK_DIALOG(m_widget), GTK_STOCK_YES,
GTK_RESPONSE_YES);
}
- if (style & wxNO_DEFAULT)
+ if (m_dialogStyle & 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);
GTK_WINDOW(m_parent->m_widget));
}
-wxMessageDialog::~wxMessageDialog()
-{
-}
-
int wxMessageDialog::ShowModal()
{
+ if ( !m_widget )
+ {
+ GTKCreateMsgDialog();
+ wxCHECK_MSG( m_widget, wxID_CANCEL,
+ _T("failed to create GtkMessageDialog") );
+ }
+
// This should be necessary, but otherwise the
// parent TLW will disappear..
if (m_parent)
IMPLEMENT_CLASS(wxMessageDialog, wxDialog)
-wxMessageDialog::wxMessageDialog(
- wxWindow *parent, const wxString& message, const wxString& caption,
- long style, const wxPoint& pos )
+wxMessageDialog::wxMessageDialog(wxWindow *parent,
+ const wxString& message,
+ const wxString& caption,
+ long style,
+ const wxPoint& pos)
+ : wxMessageDialogBase(parent, message, caption, style)
{
- m_caption = caption;
- m_message = message;
- m_parent = parent;
- SetMessageDialogStyle(style);
+ m_yes = _("Yes");
+ m_no = _("No");
+ m_ok = _("OK");
+ m_cancel = _("Cancel");
+}
+
+bool wxMessageDialog::SetYesNoLabels(const wxString& yes,const wxString& no)
+{
+ m_yes = yes;
+ m_no = no;
+ return true;
+}
+
+bool wxMessageDialog::SetYesNoCancelLabels(const wxString& yes, const wxString& no, const wxString& cancel)
+{
+ m_yes = yes;
+ m_no = no;
+ m_cancel = cancel;
+ return true;
+}
+
+bool wxMessageDialog::SetOKLabel(const wxString& ok)
+{
+ m_ok = ok;
+ return true;
+}
+
+bool wxMessageDialog::SetOKCancelLabels(const wxString& ok, const wxString& cancel)
+{
+ m_ok = ok;
+ m_cancel = cancel;
+ return true;
}
int wxMessageDialog::ShowModal()
else if (style & wxICON_QUESTION)
alertType = kAlertCautionAlert;
+
+ // work out what to display
+ // if the extended text is empty then we use the caption as the title
+ // and the message as the text (for backwards compatibility)
+ // but if the extended message is not empty then we use the message as the title
+ // and the extended message as the text because that makes more sense
+
+ wxString msgtitle,msgtext;
+ if(m_extendedMessage.IsEmpty())
+ {
+ msgtitle = m_caption;
+ msgtext = m_message;
+ }
+ else
+ {
+ msgtitle = m_message;
+ msgtext = m_extendedMessage;
+ }
+
+
#if TARGET_API_MAC_OSX
if ( !wxIsMainThread() )
{
CFStringRef alternateButtonTitle = NULL;
CFStringRef otherButtonTitle = NULL;
- wxMacCFStringHolder cfTitle( m_caption, m_font.GetEncoding() );
- wxMacCFStringHolder cfText( m_message, m_font.GetEncoding() );
+ wxMacCFStringHolder cfTitle( msgtitle, m_font.GetEncoding() );
+ wxMacCFStringHolder cfText( msgtext, m_font.GetEncoding() );
- wxMacCFStringHolder cfNoString( _("No"), m_font.GetEncoding() );
- wxMacCFStringHolder cfYesString( _("Yes"), m_font.GetEncoding() );
- wxMacCFStringHolder cfOKString( _("OK") , m_font.GetEncoding()) ;
- wxMacCFStringHolder cfCancelString( _("Cancel"), m_font.GetEncoding() );
+ wxMacCFStringHolder cfNoString( m_no.c_str(), m_font.GetEncoding() );
+ wxMacCFStringHolder cfYesString( m_yes.c_str(), m_font.GetEncoding() );
+ wxMacCFStringHolder cfOKString( m_ok.c_str() , m_font.GetEncoding()) ;
+ wxMacCFStringHolder cfCancelString( m_cancel.c_str(), m_font.GetEncoding() );
int buttonId[4] = { 0, 0, 0, wxID_CANCEL /* time-out */ };
short result;
AlertStdCFStringAlertParamRec param;
- wxMacCFStringHolder cfNoString( _("No"), m_font.GetEncoding() );
- wxMacCFStringHolder cfYesString( _("Yes"), m_font.GetEncoding() );
+ wxMacCFStringHolder cfNoString( m_no.c_str(), m_font.GetEncoding() );
+ wxMacCFStringHolder cfYesString( m_yes.c_str(), m_font.GetEncoding() );
+ wxMacCFStringHolder cfOKString( m_ok.c_str(), m_font.GetEncoding() );
+ wxMacCFStringHolder cfCancelString( m_cancel.c_str(), m_font.GetEncoding() );
- wxMacCFStringHolder cfTitle( m_caption, m_font.GetEncoding() );
- wxMacCFStringHolder cfText( m_message, m_font.GetEncoding() );
+ wxMacCFStringHolder cfTitle( msgtitle, m_font.GetEncoding() );
+ wxMacCFStringHolder cfText( msgtext, m_font.GetEncoding() );
param.movable = true;
param.flags = 0;
if (style & wxCANCEL)
{
param.defaultText = cfYesString;
- param.cancelText = (CFStringRef) kAlertDefaultCancelText;
+ param.cancelText = cfCancelString;
param.otherText = cfNoString;
param.helpButton = false;
param.defaultButton = style & wxNO_DEFAULT ? kAlertStdAlertOtherButton : kAlertStdAlertOKButton;
if (style & wxCANCEL)
{
// that's a cancel missing
- param.defaultText = (CFStringRef) kAlertDefaultOKText;
- param.cancelText = (CFStringRef) kAlertDefaultCancelText;
+ param.defaultText = cfOKString;
+ param.cancelText = cfCancelString;
param.otherText = NULL;
param.helpButton = false;
param.defaultButton = kAlertStdAlertOKButton;
}
else
{
- param.defaultText = (CFStringRef) kAlertDefaultOKText;
+ param.defaultText = cfOKString;
param.cancelText = NULL;
param.otherText = NULL;
param.helpButton = false;
// wxMessageDialog
// ----------------------------------------------------------------------------
-wxMessageDialog::wxMessageDialog(wxWindow *parent,
- const wxString& message,
- const wxString& caption,
- long style,
- const wxPoint& WXUNUSED(pos))
-{
- m_caption = caption;
- m_message = message;
- m_parent = parent;
- SetMessageDialogStyle(style);
-}
-
extern "C"
{
typedef Widget (*DialogCreateFunction)(Widget, String, ArgList, Cardinal);
Arg args[10];
int ac = 0;
- wxXmString text(m_message);
+ wxXmString text(GetFullMessage());
wxXmString title(m_caption);
XtSetArg(args[ac], XmNmessageString, text()); ac++;
XtSetArg(args[ac], XmNdialogTitle, title()); ac++;
IMPLEMENT_CLASS(wxMessageDialog, wxDialog)
-wxMessageDialog::wxMessageDialog(wxWindow *parent,
- const wxString& message,
- const wxString& caption,
- long style,
- const wxPoint& WXUNUSED(pos))
-{
- m_caption = caption;
- m_message = message;
- m_parent = parent;
- SetMessageDialogStyle(style);
-}
-
int wxMessageDialog::ShowModal()
{
if ( !wxTheApp->GetTopWindow() )
// per MSDN documentation for MessageBox() we can prefix the message with 2
// right-to-left mark characters to tell the function to use RTL layout
// (unfortunately this only works in Unicode builds)
- wxString message = m_message;
+ wxString message = GetFullMessage();
#if wxUSE_UNICODE
if ( wxTheApp->GetLayoutDirection() == wxLayout_RightToLeft )
{
IMPLEMENT_CLASS(wxMessageDialog, wxDialog)
-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
-
int wxMessageDialog::ShowModal()
{
HWND hWnd = 0;
wxTheApp->Dispatch();
}
- if (m_pParent)
- hWnd = (HWND) m_pParent->GetHWND();
+ if (m_parent)
+ hWnd = (HWND) m_parent->GetHWND();
else
hWnd = HWND_DESKTOP;
if (lStyle & wxYES_NO)
ULONG ulAns = ::WinMessageBox( hWnd
,hWnd
- ,m_sMessage.c_str()
- ,m_sCaption.c_str()
+ ,GetFullMessage().c_str()
+ ,m_caption.c_str()
,0L
,ulStyle);
switch (ulAns)
IMPLEMENT_CLASS(wxMessageDialog, wxDialog)
-wxMessageDialog::wxMessageDialog(wxWindow *parent,
- const wxString& message,
- const wxString& caption,
- long style,
- const wxPoint& WXUNUSED(pos))
-{
- m_caption = caption;
- m_message = message;
- m_parent = parent;
- SetMessageDialogStyle(style);
-}
-
int wxMessageDialog::ShowModal()
{
int AlertID=1000;
DmReleaseResource(AlertHandle);
// Display the dialog
- Result=FrmCustomAlert(AppDB,AlertID,m_message.c_str(),"","");
+ Result=FrmCustomAlert(AppDB,AlertID,GetFullMessage().c_str(),"","");
// Convert the Palm OS result to wxResult
if(AlertID<1100)