Base for wxMessageDialog with common checks for style.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32757 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Włodzimierz Skiba
2005-03-11 15:34:42 +00:00
parent 2cdd63c6b1
commit e5b5075810
19 changed files with 236 additions and 223 deletions

View File

@@ -1,11 +1,11 @@
/////////////////////////////////////////////////////////////////////////////
// Name: msgdlgg.h
// Name: wx/generic/msgdlgg.h
// Purpose: Generic wxMessageDialog
// Author: Julian Smart
// Modified by:
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c)
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
@@ -24,7 +24,7 @@
extern WXDLLEXPORT_DATA(const wxChar*) wxMessageBoxCaptionStr;
class WXDLLEXPORT wxGenericMessageDialog: public wxDialog
class WXDLLEXPORT wxGenericMessageDialog: public wxDialog, public wxMessageDialogBase
{
DECLARE_DYNAMIC_CLASS(wxGenericMessageDialog)
@@ -38,8 +38,6 @@ public:
void OnCancel(wxCommandEvent& event);
private:
long m_dialogStyle;
DECLARE_EVENT_TABLE()
};

View File

@@ -1,12 +1,12 @@
/////////////////////////////////////////////////////////////////////////////
// Name: msgdlg.h
// Name: wx/gtk/msgdlg.h
// Purpose: wxMessageDialog for GTK+2
// Author: Vaclav Slavik
// Modified by:
// Created: 2003/02/28
// RCS-ID: $Id$
// Copyright: (c) Vaclav Slavik, 2003
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __MSGDLG_H__
@@ -24,7 +24,7 @@
WXDLLEXPORT_DATA(extern const wxChar*) wxMessageBoxCaptionStr;
class WXDLLEXPORT wxMessageDialog: public wxDialog
class WXDLLEXPORT wxMessageDialog: public wxDialog, public wxMessageDialogBase
{
public:
wxMessageDialog(wxWindow *parent, const wxString& message,
@@ -48,7 +48,6 @@ protected:
private:
wxString m_caption;
wxString m_message;
long m_dialogStyle;
DECLARE_DYNAMIC_CLASS(wxMessageDialog)
};

View File

@@ -1,12 +1,12 @@
/////////////////////////////////////////////////////////////////////////////
// Name: msgdlg.h
// Name: wx/gtk/msgdlg.h
// Purpose: wxMessageDialog for GTK+2
// Author: Vaclav Slavik
// Modified by:
// Created: 2003/02/28
// RCS-ID: $Id$
// Copyright: (c) Vaclav Slavik, 2003
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __MSGDLG_H__
@@ -24,7 +24,7 @@
WXDLLEXPORT_DATA(extern const wxChar*) wxMessageBoxCaptionStr;
class WXDLLEXPORT wxMessageDialog: public wxDialog
class WXDLLEXPORT wxMessageDialog: public wxDialog, public wxMessageDialogBase
{
public:
wxMessageDialog(wxWindow *parent, const wxString& message,
@@ -48,7 +48,6 @@ protected:
private:
wxString m_caption;
wxString m_message;
long m_dialogStyle;
DECLARE_DYNAMIC_CLASS(wxMessageDialog)
};

View File

@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////////
// Name: msgdlg.h
// Name: wx/mac/carbon/msgdlg.h
// Purpose: wxMessageDialog class. Use generic version if no
// platform-specific implementation.
// Author: Stefan Csomor
@@ -26,14 +26,13 @@
WXDLLEXPORT_DATA(extern const wxChar*) wxMessageBoxCaptionStr;
class WXDLLEXPORT wxMessageDialog: public wxDialog
class WXDLLEXPORT wxMessageDialog: public wxDialog, public wxMessageDialogBase
{
DECLARE_DYNAMIC_CLASS(wxMessageDialog)
protected:
wxString m_caption;
wxString m_message;
long m_dialogStyle;
wxWindow * m_parent;
public:
wxMessageDialog(wxWindow *parent,
@@ -43,7 +42,7 @@ public:
const wxPoint& pos = wxDefaultPosition);
int ShowModal();
// not supported for message dialog, RR
virtual void DoSetSize(int WXUNUSED(x), int WXUNUSED(y),
int WXUNUSED(width), int WXUNUSED(height),

View File

@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////////
// Name: msgdlg.h
// Name: wx/mac/classic/msgdlg.h
// Purpose: wxMessageDialog class. Use generic version if no
// platform-specific implementation.
// Author: Stefan Csomor
@@ -26,14 +26,13 @@
WXDLLEXPORT_DATA(extern const wxChar*) wxMessageBoxCaptionStr;
class WXDLLEXPORT wxMessageDialog: public wxDialog
class WXDLLEXPORT wxMessageDialog: public wxDialog, public wxMessageDialogBase
{
DECLARE_DYNAMIC_CLASS(wxMessageDialog)
protected:
wxString m_caption;
wxString m_message;
long m_dialogStyle;
wxWindow * m_parent;
public:
wxMessageDialog(wxWindow *parent,
@@ -43,7 +42,7 @@ public:
const wxPoint& pos = wxDefaultPosition);
int ShowModal();
// not supported for message dialog, RR
virtual void DoSetSize(int WXUNUSED(x), int WXUNUSED(y),
int WXUNUSED(width), int WXUNUSED(height),

View File

@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////////
// Name: msgdlg.h
// Name: wx/motif/msgdlg.h
// Purpose: wxMessageDialog class. Use generic version if no
// platform-specific implementation.
// Author: Julian Smart
@@ -26,27 +26,26 @@
WXDLLEXPORT_DATA(extern const char*) wxMessageBoxCaptionStr;
class WXDLLEXPORT wxMessageDialog: public wxDialog
class WXDLLEXPORT wxMessageDialog: public wxDialog, 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);
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;
long m_dialogStyle;
wxWindow * m_parent;
long m_result;
};

View File

@@ -1,3 +1,14 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/msgdlgg.h
// Purpose: common header and base class for wxMessageDialog
// Author: wxWidgets Team
// Modified by:
// Created:
// RCS-ID: $Id$
// Copyright: (c) wxWidgets
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MSGDLG_H_BASE_
#define _WX_MSGDLG_H_BASE_
@@ -5,6 +16,29 @@
#if wxUSE_MSGDLG
class WXDLLEXPORT wxMessageDialogBase
{
protected:
// common validation of wxMessageDialog style
void SetMessageDialogStyle(long style)
{
wxASSERT_MSG( ((style & wxYES_NO) == wxYES_NO) || ((style & wxYES_NO) == 0),
_T("wxYES and wxNO may only be used together in wxMessageDialog") );
wxASSERT_MSG( (style & wxID_OK) != wxID_OK,
_T("wxMessageBox: Did you mean wxOK (and not wxID_OK)?") );
m_dialogStyle = style;
}
inline long GetMessageDialogStyle() const
{
return m_dialogStyle;
}
private:
long m_dialogStyle;
};
#if defined(__WXUNIVERSAL__) || defined(__WXGPE__)
#include "wx/generic/msgdlgg.h"
#elif defined(__WXPALMOS__)
@@ -30,10 +64,10 @@
// ----------------------------------------------------------------------------
int WXDLLEXPORT wxMessageBox(const wxString& message,
const wxString& caption = wxMessageBoxCaptionStr,
long style = wxOK | wxCENTRE,
wxWindow *parent = NULL,
int x = wxDefaultCoord, int y = wxDefaultCoord);
const wxString& caption = wxMessageBoxCaptionStr,
long style = wxOK | wxCENTRE,
wxWindow *parent = NULL,
int x = wxDefaultCoord, int y = wxDefaultCoord);
#endif // wxUSE_MSGDLG

View File

@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////////
// Name: msgdlg.h
// Name: wx/msw/msgdlg.h
// Purpose: wxMessageDialog class
// Author: Julian Smart
// Modified by:
@@ -25,13 +25,12 @@
extern WXDLLEXPORT_DATA(const wxChar*) wxMessageBoxCaptionStr;
class WXDLLEXPORT wxMessageDialog: public wxDialog
class WXDLLEXPORT wxMessageDialog: public wxDialog, public wxMessageDialogBase
{
DECLARE_DYNAMIC_CLASS(wxMessageDialog)
protected:
wxString m_caption;
wxString m_message;
long m_dialogStyle;
wxWindow * m_parent;
public:
wxMessageDialog(wxWindow *parent, const wxString& message, const wxString& caption = wxMessageBoxCaptionStr,

View File

@@ -1,12 +1,12 @@
/////////////////////////////////////////////////////////////////////////////
// Name: msgdlg.h
// Name: wx/os2/msgdlg.h
// Purpose: wxMessageDialog class. Use generic version if no
// platform-specific implementation.
// Author: David Webster
// Modified by:
// Created: 10/12/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
@@ -20,7 +20,7 @@
* Message box dialog
*/
class WXDLLEXPORT wxMessageDialog : public wxDialog
class WXDLLEXPORT wxMessageDialog : public wxDialog, public wxMessageDialogBase
{
DECLARE_DYNAMIC_CLASS(wxMessageDialog)
public:
@@ -36,7 +36,6 @@ public:
protected:
wxString m_sCaption;
wxString m_sMessage;
long m_lDialogStyle;
wxWindow* m_pParent;
}; // end of CLASS wxMessageDialog

View File

@@ -25,13 +25,12 @@
WXDLLEXPORT_DATA(extern const wxChar*) wxMessageBoxCaptionStr;
class WXDLLEXPORT wxMessageDialog: public wxDialog
class WXDLLEXPORT wxMessageDialog: public wxDialog, public wxMessageDialogBase
{
DECLARE_DYNAMIC_CLASS(wxMessageDialog)
protected:
wxString m_caption;
wxString m_message;
long m_dialogStyle;
wxWindow * m_parent;
public:
wxMessageDialog(wxWindow *parent, const wxString& message, const wxString& caption = wxMessageBoxCaptionStr,

View File

@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////////
// Name: msgdlgg.cpp
// Name: src/generic/msgdlgg.cpp
// Purpose: wxGenericMessageDialog
// Author: Julian Smart, Robert Roebling
// Modified by:
@@ -65,7 +65,7 @@ wxGenericMessageDialog::wxGenericMessageDialog( wxWindow *parent,
const wxPoint& pos)
: wxDialog( parent, wxID_ANY, caption, pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE )
{
m_dialogStyle = style;
SetMessageDialogStyle(style);
bool is_pda = (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA);
@@ -151,7 +151,8 @@ void wxGenericMessageDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
{
// Allow cancellation via ESC/Close button except if
// only YES and NO are specified.
if ( (m_dialogStyle & wxYES_NO) != wxYES_NO || (m_dialogStyle & wxCANCEL) )
const long style = GetMessageDialogStyle();
if ( (style & wxYES_NO) != wxYES_NO || (style & wxCANCEL) )
{
EndModal( wxID_CANCEL );
}

View File

@@ -1,12 +1,12 @@
/////////////////////////////////////////////////////////////////////////////
// Name: msgdlg.cpp
// Name: src/gtk/msgdlg.cpp
// Purpose: wxMessageDialog for GTK+2
// Author: Vaclav Slavik
// Modified by:
// Created: 2003/02/28
// RCS-ID: $Id$
// Copyright: (c) Vaclav Slavik, 2003
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
@@ -38,37 +38,37 @@ wxMessageDialog::wxMessageDialog(wxWindow *parent,
{
m_caption = caption;
m_message = message;
m_dialogStyle = style;
SetMessageDialogStyle(style);
m_parent = wxGetTopLevelParent(parent);
GtkMessageType type = GTK_MESSAGE_ERROR;
GtkButtonsType buttons = GTK_BUTTONS_OK;
if (m_dialogStyle & wxYES_NO)
if (style & wxYES_NO)
{
buttons = GTK_BUTTONS_YES_NO;
}
if (m_dialogStyle & wxOK)
if (style & wxOK)
{
if (m_dialogStyle & wxCANCEL)
if (style & wxCANCEL)
buttons = GTK_BUTTONS_OK_CANCEL;
else
buttons = GTK_BUTTONS_OK;
}
if (m_dialogStyle & wxICON_EXCLAMATION)
if (style & wxICON_EXCLAMATION)
type = GTK_MESSAGE_WARNING;
else if (m_dialogStyle & wxICON_ERROR)
else if (style & wxICON_ERROR)
type = GTK_MESSAGE_ERROR;
else if (m_dialogStyle & wxICON_INFORMATION)
else if (style & wxICON_INFORMATION)
type = GTK_MESSAGE_INFO;
else if (m_dialogStyle & wxICON_QUESTION)
else if (style & wxICON_QUESTION)
type = GTK_MESSAGE_QUESTION;
else
{
// GTK+ doesn't have a "typeless" msg box, so try to auto detect...
type = m_dialogStyle & wxYES ? GTK_MESSAGE_QUESTION : GTK_MESSAGE_INFO;
type = style & wxYES ? GTK_MESSAGE_QUESTION : GTK_MESSAGE_INFO;
}
m_widget = gtk_message_dialog_new(m_parent ?
@@ -79,12 +79,12 @@ wxMessageDialog::wxMessageDialog(wxWindow *parent,
if (m_caption != wxMessageBoxCaptionStr)
gtk_window_set_title(GTK_WINDOW(m_widget), wxGTK_CONV(m_caption));
if (m_dialogStyle & wxYES_NO)
if (style & wxYES_NO)
{
if (m_dialogStyle & wxCANCEL)
if (style & wxCANCEL)
gtk_dialog_add_button(GTK_DIALOG(m_widget), GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL);
if (m_dialogStyle & wxNO_DEFAULT)
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);
@@ -94,7 +94,7 @@ wxMessageDialog::wxMessageDialog(wxWindow *parent,
gtk_window_set_transient_for(GTK_WINDOW(m_widget),
GTK_WINDOW(m_parent->m_widget));
}
wxMessageDialog::~wxMessageDialog()
{
}
@@ -105,7 +105,7 @@ int wxMessageDialog::ShowModal()
// parent TLW will disappear..
if (m_parent)
gtk_window_present( GTK_WINDOW(m_parent->m_widget) );
gint result = gtk_dialog_run(GTK_DIALOG(m_widget));
gtk_widget_destroy(m_widget);
m_widget = NULL;

View File

@@ -1,12 +1,12 @@
/////////////////////////////////////////////////////////////////////////////
// Name: msgdlg.cpp
// Name: src/gtk/msgdlg.cpp
// Purpose: wxMessageDialog for GTK+2
// Author: Vaclav Slavik
// Modified by:
// Created: 2003/02/28
// RCS-ID: $Id$
// Copyright: (c) Vaclav Slavik, 2003
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
@@ -38,37 +38,37 @@ wxMessageDialog::wxMessageDialog(wxWindow *parent,
{
m_caption = caption;
m_message = message;
m_dialogStyle = style;
SetMessageDialogStyle(style);
m_parent = wxGetTopLevelParent(parent);
GtkMessageType type = GTK_MESSAGE_ERROR;
GtkButtonsType buttons = GTK_BUTTONS_OK;
if (m_dialogStyle & wxYES_NO)
if (style & wxYES_NO)
{
buttons = GTK_BUTTONS_YES_NO;
}
if (m_dialogStyle & wxOK)
if (style & wxOK)
{
if (m_dialogStyle & wxCANCEL)
if (style & wxCANCEL)
buttons = GTK_BUTTONS_OK_CANCEL;
else
buttons = GTK_BUTTONS_OK;
}
if (m_dialogStyle & wxICON_EXCLAMATION)
if (style & wxICON_EXCLAMATION)
type = GTK_MESSAGE_WARNING;
else if (m_dialogStyle & wxICON_ERROR)
else if (style & wxICON_ERROR)
type = GTK_MESSAGE_ERROR;
else if (m_dialogStyle & wxICON_INFORMATION)
else if (style & wxICON_INFORMATION)
type = GTK_MESSAGE_INFO;
else if (m_dialogStyle & wxICON_QUESTION)
else if (style & wxICON_QUESTION)
type = GTK_MESSAGE_QUESTION;
else
{
// GTK+ doesn't have a "typeless" msg box, so try to auto detect...
type = m_dialogStyle & wxYES ? GTK_MESSAGE_QUESTION : GTK_MESSAGE_INFO;
type = style & wxYES ? GTK_MESSAGE_QUESTION : GTK_MESSAGE_INFO;
}
m_widget = gtk_message_dialog_new(m_parent ?
@@ -79,12 +79,12 @@ wxMessageDialog::wxMessageDialog(wxWindow *parent,
if (m_caption != wxMessageBoxCaptionStr)
gtk_window_set_title(GTK_WINDOW(m_widget), wxGTK_CONV(m_caption));
if (m_dialogStyle & wxYES_NO)
if (style & wxYES_NO)
{
if (m_dialogStyle & wxCANCEL)
if (style & wxCANCEL)
gtk_dialog_add_button(GTK_DIALOG(m_widget), GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL);
if (m_dialogStyle & wxNO_DEFAULT)
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);
@@ -94,7 +94,7 @@ wxMessageDialog::wxMessageDialog(wxWindow *parent,
gtk_window_set_transient_for(GTK_WINDOW(m_widget),
GTK_WINDOW(m_parent->m_widget));
}
wxMessageDialog::~wxMessageDialog()
{
}
@@ -105,7 +105,7 @@ int wxMessageDialog::ShowModal()
// parent TLW will disappear..
if (m_parent)
gtk_window_present( GTK_WINDOW(m_parent->m_widget) );
gint result = gtk_dialog_run(GTK_DIALOG(m_widget));
gtk_widget_destroy(m_widget);
m_widget = NULL;

View File

@@ -1,12 +1,12 @@
/////////////////////////////////////////////////////////////////////////////
// Name: msgdlg.cpp
// Name: src/mac/carbon/msgdlg.cpp
// Purpose: wxMessageDialog
// Author: Stefan Csomor
// Modified by:
// Created: 04/01/98
// RCS-ID: $$
// RCS-ID: $Id$
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
@@ -29,53 +29,55 @@ wxMessageDialog::wxMessageDialog(wxWindow *parent, const wxString& message, cons
{
m_caption = caption;
m_message = message;
m_dialogStyle = style;
m_parent = parent;
SetMessageDialogStyle(style);
}
int wxMessageDialog::ShowModal()
{
int resultbutton = wxID_CANCEL ;
short result ;
wxASSERT_MSG( ( m_dialogStyle & 0x3F ) != wxYES , wxT("this style is not supported on mac") ) ;
const long style = GetMessageDialogStyle();
wxASSERT_MSG( ( style & 0x3F ) != wxYES , wxT("this style is not supported on mac") ) ;
AlertType alertType = kAlertPlainAlert ;
if (m_dialogStyle & wxICON_EXCLAMATION)
if (style & wxICON_EXCLAMATION)
alertType = kAlertNoteAlert ;
else if (m_dialogStyle & wxICON_HAND)
else if (style & wxICON_HAND)
alertType = kAlertStopAlert ;
else if (m_dialogStyle & wxICON_INFORMATION)
else if (style & wxICON_INFORMATION)
alertType = kAlertNoteAlert ;
else if (m_dialogStyle & wxICON_QUESTION)
else if (style & wxICON_QUESTION)
alertType = kAlertCautionAlert ;
#if TARGET_CARBON
if ( UMAGetSystemVersion() >= 0x1000 )
{
AlertStdCFStringAlertParamRec param ;
wxMacCFStringHolder cfNoString(_("No") , m_font.GetEncoding()) ;
wxMacCFStringHolder cfYesString( _("Yes") , m_font.GetEncoding()) ;
wxMacCFStringHolder cfTitle(m_caption , m_font.GetEncoding());
wxMacCFStringHolder cfText(m_message , m_font.GetEncoding());
param.movable = true;
param.flags = 0 ;
param.version = kStdCFStringAlertVersionOne ;
bool skipDialog = false ;
if (m_dialogStyle & wxYES_NO)
if (style & wxYES_NO)
{
if (m_dialogStyle & wxCANCEL)
if (style & wxCANCEL)
{
param.defaultText = cfYesString ;
param.cancelText = (CFStringRef) kAlertDefaultCancelText;
param.otherText = cfNoString ;
param.helpButton = false ;
param.defaultButton = m_dialogStyle & wxNO_DEFAULT ? kAlertStdAlertOtherButton : kAlertStdAlertOKButton;
param.defaultButton = style & wxNO_DEFAULT ? kAlertStdAlertOtherButton : kAlertStdAlertOKButton;
param.cancelButton = kAlertStdAlertCancelButton;
}
else
@@ -84,14 +86,14 @@ int wxMessageDialog::ShowModal()
param.cancelText = NULL;
param.otherText = cfNoString ;
param.helpButton = false ;
param.defaultButton = m_dialogStyle & wxNO_DEFAULT ? kAlertStdAlertOtherButton : kAlertStdAlertOKButton;
param.defaultButton = style & wxNO_DEFAULT ? kAlertStdAlertOtherButton : kAlertStdAlertOKButton;
param.cancelButton = 0;
}
}
// the msw implementation even shows an ok button if it is not specified, we'll do the same
else
else
{
if (m_dialogStyle & wxCANCEL)
if (style & wxCANCEL)
{
// thats a cancel missing
param.defaultText = (CFStringRef) kAlertDefaultOKText ;
@@ -117,7 +119,7 @@ int wxMessageDialog::ShowModal()
skipDialog = true ;
}
*/
param.position = kWindowDefaultPosition;
if ( !skipDialog )
{
@@ -125,29 +127,29 @@ int wxMessageDialog::ShowModal()
CreateStandardAlert( alertType , cfTitle , cfText , &param , &alertRef ) ;
RunStandardAlert( alertRef , NULL , &result ) ;
}
if ( skipDialog )
if ( skipDialog )
return wxID_CANCEL ;
}
else
#endif
{
AlertStdAlertParamRec param;
Str255 yesPString ;
Str255 noPString ;
Str255 pascalTitle ;
Str255 pascalText ;
wxMacStringToPascal( m_caption , pascalTitle ) ;
wxMacStringToPascal( _("Yes") , yesPString ) ;
wxMacStringToPascal( _("No") , noPString ) ;
wxMacStringToPascal( m_message , pascalText ) ;
param.movable = true;
param.filterProc = NULL ;
if (m_dialogStyle & wxYES_NO)
if (style & wxYES_NO)
{
if (m_dialogStyle & wxCANCEL)
if (style & wxCANCEL)
{
param.defaultText = yesPString ;
param.cancelText = (StringPtr) kAlertDefaultCancelText;
@@ -166,9 +168,9 @@ int wxMessageDialog::ShowModal()
param.cancelButton = 0;
}
}
else if (m_dialogStyle & wxOK)
else if (style & wxOK)
{
if (m_dialogStyle & wxCANCEL)
if (style & wxCANCEL)
{
param.defaultText = (StringPtr) kAlertDefaultOKText ;
param.cancelText = (StringPtr) kAlertDefaultCancelText ;
@@ -191,15 +193,15 @@ int wxMessageDialog::ShowModal()
{
return resultbutton ;
}
param.position = 0;
StandardAlert( alertType, pascalTitle, pascalText, &param, &result );
}
if (m_dialogStyle & wxOK)
if (style & wxOK)
{
if (m_dialogStyle & wxCANCEL)
if (style & wxCANCEL)
{
//TODO add Cancelbutton
switch( result )
@@ -227,9 +229,9 @@ int wxMessageDialog::ShowModal()
}
}
}
else if (m_dialogStyle & wxYES_NO)
else if (style & wxYES_NO)
{
if (m_dialogStyle & wxCANCEL)
if (style & wxCANCEL)
{
switch( result )
{
@@ -258,8 +260,8 @@ int wxMessageDialog::ShowModal()
break ;
}
}
}
}
return resultbutton ;
}

View File

@@ -1,12 +1,12 @@
/////////////////////////////////////////////////////////////////////////////
// Name: msgdlg.cpp
// Name: src/mac/classic/msgdlg.cpp
// Purpose: wxMessageDialog
// Author: Stefan Csomor
// Modified by:
// Created: 04/01/98
// RCS-ID: $$
// RCS-ID: $Id$
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
@@ -27,46 +27,48 @@ wxMessageDialog::wxMessageDialog(wxWindow *parent, const wxString& message, cons
{
m_caption = caption;
m_message = message;
m_dialogStyle = style;
m_parent = parent;
SetMessageDialogStyle(style);
}
int wxMessageDialog::ShowModal()
{
int resultbutton = wxID_CANCEL ;
short result ;
wxASSERT_MSG( ( m_dialogStyle & 0x3F ) != wxYES , wxT("this style is not supported on mac") ) ;
const long style = GetMessageDialogStyle();
wxASSERT_MSG( ( style & 0x3F ) != wxYES , wxT("this style is not supported on mac") ) ;
AlertType alertType = kAlertPlainAlert ;
if (m_dialogStyle & wxICON_EXCLAMATION)
if (style & wxICON_EXCLAMATION)
alertType = kAlertNoteAlert ;
else if (m_dialogStyle & wxICON_HAND)
else if (style & wxICON_HAND)
alertType = kAlertStopAlert ;
else if (m_dialogStyle & wxICON_INFORMATION)
else if (style & wxICON_INFORMATION)
alertType = kAlertNoteAlert ;
else if (m_dialogStyle & wxICON_QUESTION)
else if (style & wxICON_QUESTION)
alertType = kAlertCautionAlert ;
#if TARGET_CARBON
if ( UMAGetSystemVersion() >= 0x1000 )
{
AlertStdCFStringAlertParamRec param ;
wxMacCFStringHolder cfNoString(_("No") , m_font.GetEncoding()) ;
wxMacCFStringHolder cfYesString( _("Yes") , m_font.GetEncoding()) ;
wxMacCFStringHolder cfTitle(m_caption , m_font.GetEncoding());
wxMacCFStringHolder cfText(m_message , m_font.GetEncoding());
param.movable = true;
param.flags = 0 ;
bool skipDialog = false ;
if (m_dialogStyle & wxYES_NO)
if (style & wxYES_NO)
{
if (m_dialogStyle & wxCANCEL)
if (style & wxCANCEL)
{
param.defaultText = cfYesString ;
param.cancelText = (CFStringRef) kAlertDefaultCancelText;
@@ -86,9 +88,9 @@ int wxMessageDialog::ShowModal()
}
}
// the msw implementation even shows an ok button if it is not specified, we'll do the same
else
else
{
if (m_dialogStyle & wxCANCEL)
if (style & wxCANCEL)
{
// thats a cancel missing
param.defaultText = (CFStringRef) kAlertDefaultOKText ;
@@ -114,7 +116,7 @@ int wxMessageDialog::ShowModal()
skipDialog = true ;
}
*/
param.position = kWindowDefaultPosition;
if ( !skipDialog )
{
@@ -122,29 +124,29 @@ int wxMessageDialog::ShowModal()
CreateStandardAlert( alertType , cfTitle , cfText , &param , &alertRef ) ;
RunStandardAlert( alertRef , NULL , &result ) ;
}
if ( skipDialog )
if ( skipDialog )
return wxID_CANCEL ;
}
else
#endif
{
AlertStdAlertParamRec param;
Str255 yesPString ;
Str255 noPString ;
Str255 pascalTitle ;
Str255 pascalText ;
wxMacStringToPascal( m_caption , pascalTitle ) ;
wxMacStringToPascal( _("Yes") , yesPString ) ;
wxMacStringToPascal( _("No") , noPString ) ;
wxMacStringToPascal( m_message , pascalText ) ;
param.movable = true;
param.filterProc = NULL ;
if (m_dialogStyle & wxYES_NO)
if (style & wxYES_NO)
{
if (m_dialogStyle & wxCANCEL)
if (style & wxCANCEL)
{
param.defaultText = yesPString ;
param.cancelText = (StringPtr) kAlertDefaultCancelText;
@@ -163,9 +165,9 @@ int wxMessageDialog::ShowModal()
param.cancelButton = 0;
}
}
else if (m_dialogStyle & wxOK)
else if (style & wxOK)
{
if (m_dialogStyle & wxCANCEL)
if (style & wxCANCEL)
{
param.defaultText = (StringPtr) kAlertDefaultOKText ;
param.cancelText = (StringPtr) kAlertDefaultCancelText ;
@@ -188,15 +190,15 @@ int wxMessageDialog::ShowModal()
{
return resultbutton ;
}
param.position = 0;
StandardAlert( alertType, pascalTitle, pascalText, &param, &result );
}
if (m_dialogStyle & wxOK)
if (style & wxOK)
{
if (m_dialogStyle & wxCANCEL)
if (style & wxCANCEL)
{
//TODO add Cancelbutton
switch( result )
@@ -224,9 +226,9 @@ int wxMessageDialog::ShowModal()
}
}
}
else if (m_dialogStyle & wxYES_NO)
else if (style & wxYES_NO)
{
if (m_dialogStyle & wxCANCEL)
if (style & wxCANCEL)
{
switch( result )
{
@@ -255,8 +257,8 @@ int wxMessageDialog::ShowModal()
break ;
}
}
}
}
return resultbutton ;
}

View File

@@ -1,10 +1,10 @@
/////////////////////////////////////////////////////////////////////////////
// Name: msgdlg.cpp
// Name: src/motif/msgdlg.cpp
// Purpose: wxMessageDialog
// Author: Julian Smart
// Modified by:
// Created: 04/01/98
// RCS-ID: $$
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
@@ -108,24 +108,26 @@ wxMessageDialog::wxMessageDialog(wxWindow *parent,
{
m_caption = caption;
m_message = message;
m_dialogStyle = style;
m_parent = parent;
SetMessageDialogStyle(style);
}
int wxMessageDialog::ShowModal()
{
Widget (*dialogCreateFunction)(Widget, String, ArgList, Cardinal) = NULL;
if ( m_dialogStyle & wxYES_NO )
const long style = GetMessageDialogStyle();
if ( style & wxYES_NO )
{
// if we have [Yes], it must be a question
dialogCreateFunction = XmCreateQuestionDialog;
}
else if ( m_dialogStyle & wxICON_STOP )
else if ( style & wxICON_STOP )
{
// error dialog is the one with error icon...
dialogCreateFunction = XmCreateErrorDialog;
}
else if ( m_dialogStyle & wxICON_EXCLAMATION )
else if ( style & wxICON_EXCLAMATION )
{
// ...and the warning dialog too
dialogCreateFunction = XmCreateWarningDialog;
@@ -180,11 +182,11 @@ int wxMessageDialog::ShowModal()
Widget wBtnHelp = XmMessageBoxGetChild(wMsgBox, XmDIALOG_HELP_BUTTON);
Widget wBtnCancel = XmMessageBoxGetChild(wMsgBox, XmDIALOG_CANCEL_BUTTON);
if ( m_dialogStyle & wxYES_NO )
if ( style & wxYES_NO )
{
wxXmString yes(_("Yes")), no(_("No")), cancel(_("Cancel"));
wxXmString yes(_("Yes")), no(_("No")), cancel(_("Cancel"));
if ( m_dialogStyle & wxCANCEL )
if ( style & wxCANCEL )
{
// use the cancel button for No and the help button for
// Cancel Yuk :-) MB
@@ -208,7 +210,7 @@ int wxMessageDialog::ShowModal()
// requested)
//
XtUnmanageChild(wBtnHelp);
if ( !(m_dialogStyle & wxCANCEL ) ) XtUnmanageChild(wBtnCancel);
if ( !(style & wxCANCEL ) ) XtUnmanageChild(wBtnCancel);
}
// set the callbacks for the message box buttons
@@ -238,7 +240,7 @@ int wxMessageDialog::ShowModal()
}
// translate the result if necessary
if ( m_dialogStyle & wxYES_NO )
if ( style & wxYES_NO )
{
if ( m_result == wxID_OK )
m_result = wxID_YES;

View File

@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////////
// Name: msgdlg.cpp
// Name: src/msw/msgdlg.cpp
// Purpose: wxMessageDialog
// Author: Julian Smart
// Modified by:
@@ -43,19 +43,10 @@ wxMessageDialog::wxMessageDialog(wxWindow *parent,
long style,
const wxPoint& WXUNUSED(pos))
{
#ifdef __WXDEBUG__
// check for common programming errors
if ( (style & wxID_OK) == wxID_OK )
{
// programmer probably confused wxID_OK with wxOK. Correct one is wxOK.
wxFAIL_MSG( _T("wxMessageBox: Did you mean wxOK (and not wxID_OK)?") );
}
#endif // __WXDEBUG__
m_caption = caption;
m_message = message;
m_dialogStyle = style;
m_parent = parent;
SetMessageDialogStyle(style);
}
int wxMessageDialog::ShowModal()
@@ -77,39 +68,37 @@ int wxMessageDialog::ShowModal()
// translate wx style in MSW
unsigned int msStyle = MB_OK;
if (m_dialogStyle & wxYES_NO)
const long wxStyle = GetMessageDialogStyle();
if (wxStyle & wxYES_NO)
{
wxASSERT_MSG( (m_dialogStyle & wxYES_NO) == wxYES_NO,
_T("wxYES and wxNO may only be used together under MSW") );
#if !(defined(__SMARTPHONE__) && defined(__WXWINCE__))
if (m_dialogStyle & wxCANCEL)
if (wxStyle & wxCANCEL)
msStyle = MB_YESNOCANCEL;
else
#endif // !(__SMARTPHONE__ && __WXWINCE__)
msStyle = MB_YESNO;
if (m_dialogStyle & wxNO_DEFAULT)
if (wxStyle & wxNO_DEFAULT)
msStyle |= MB_DEFBUTTON2;
}
if (m_dialogStyle & wxOK)
if (wxStyle & wxOK)
{
if (m_dialogStyle & wxCANCEL)
if (wxStyle & wxCANCEL)
msStyle = MB_OKCANCEL;
else
msStyle = MB_OK;
}
if (m_dialogStyle & wxICON_EXCLAMATION)
if (wxStyle & wxICON_EXCLAMATION)
msStyle |= MB_ICONEXCLAMATION;
else if (m_dialogStyle & wxICON_HAND)
else if (wxStyle & wxICON_HAND)
msStyle |= MB_ICONHAND;
else if (m_dialogStyle & wxICON_INFORMATION)
else if (wxStyle & wxICON_INFORMATION)
msStyle |= MB_ICONINFORMATION;
else if (m_dialogStyle & wxICON_QUESTION)
else if (wxStyle & wxICON_QUESTION)
msStyle |= MB_ICONQUESTION;
if ( m_dialogStyle & wxSTAY_ON_TOP )
if ( wxStyle & wxSTAY_ON_TOP )
msStyle |= MB_TOPMOST;
if (hWnd)

View File

@@ -1,10 +1,10 @@
/////////////////////////////////////////////////////////////////////////////
// Name: msgdlg.cpp
// Name: src/os2/msgdlg.cpp
// Purpose: wxMessageDialog
// Author: David Webster
// Modified by:
// Created: 10/10/99
// RCS-ID: $$
// RCS-ID: $Id$
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
@@ -46,8 +46,8 @@ wxMessageDialog::wxMessageDialog(
{
m_sCaption = rsCaption;
m_sMessage = rsMessage;
m_lDialogStyle = lStyle;
m_pParent = NULL; // pParent;
SetMessageDialogStyle(lStyle);
} // end of wxMessageDialog::wxMessageDialog
int wxMessageDialog::ShowModal()
@@ -55,6 +55,7 @@ int wxMessageDialog::ShowModal()
HWND hWnd = 0;
ULONG ulStyle = MB_OK;
int nAns = wxOK;
const long lStyle = GetMessageDialogStyle();
if (!wxTheApp->GetTopWindow())
{
@@ -72,31 +73,31 @@ int wxMessageDialog::ShowModal()
hWnd = (HWND) m_pParent->GetHWND();
else
hWnd = HWND_DESKTOP;
if (m_lDialogStyle & wxYES_NO)
if (lStyle & wxYES_NO)
{
if (m_lDialogStyle & wxCANCEL)
if (lStyle & wxCANCEL)
ulStyle = MB_YESNOCANCEL;
else
ulStyle = MB_YESNO;
if (m_lDialogStyle & wxNO_DEFAULT)
if (lStyle & wxNO_DEFAULT)
ulStyle |= MB_DEFBUTTON2;
}
if (m_lDialogStyle & wxOK)
if (lStyle & wxOK)
{
if (m_lDialogStyle & wxCANCEL)
if (lStyle & wxCANCEL)
ulStyle = MB_OKCANCEL;
else
ulStyle = MB_OK;
}
if (m_lDialogStyle & wxICON_EXCLAMATION)
if (lStyle & wxICON_EXCLAMATION)
ulStyle |= MB_ICONEXCLAMATION;
else if (m_lDialogStyle & wxICON_HAND)
else if (lStyle & wxICON_HAND)
ulStyle |= MB_ICONHAND;
else if (m_lDialogStyle & wxICON_INFORMATION)
else if (lStyle & wxICON_INFORMATION)
ulStyle |= MB_ICONEXCLAMATION;
else if (m_lDialogStyle & wxICON_QUESTION)
else if (lStyle & wxICON_QUESTION)
ulStyle |= MB_ICONQUESTION;
if (hWnd != HWND_DESKTOP)

View File

@@ -36,19 +36,10 @@ wxMessageDialog::wxMessageDialog(wxWindow *parent,
long style,
const wxPoint& WXUNUSED(pos))
{
#ifdef __WXDEBUG__
// check for common programming errors
if ( (style & wxID_OK) == wxID_OK )
{
// programmer probably confused wxID_OK with wxOK. Correct one is wxOK.
wxFAIL_MSG( _T("wxMessageBox: Did you mean wxOK (and not wxID_OK)?") );
}
#endif // __WXDEBUG__
m_caption = caption;
m_message = message;
m_dialogStyle = style;
m_parent = parent;
SetMessageDialogStyle(style);
}
int wxMessageDialog::ShowModal()
@@ -56,35 +47,36 @@ int wxMessageDialog::ShowModal()
int AlertID=1000;
int Result=0;
int wxResult=wxID_OK;
const long style = GetMessageDialogStyle();
// Handle to the currently running application database
DmOpenRef AppDB;
SysGetModuleDatabase(SysGetRefNum(), NULL, &AppDB);
// Translate wx styles into Palm OS styles
if (m_dialogStyle & wxYES_NO)
if (style & wxYES_NO)
{
if (m_dialogStyle & wxCANCEL)
if (style & wxCANCEL)
AlertID=1300; // Yes No Cancel
else
AlertID=1200; // Yes No
}
if (m_dialogStyle & wxOK)
if (style & wxOK)
{
if (m_dialogStyle & wxCANCEL)
if (style & wxCANCEL)
AlertID=1100; // Ok Cancel
else
AlertID=1000; // Ok
}
// Add the icon styles
if (m_dialogStyle & wxICON_EXCLAMATION)
if (style & wxICON_EXCLAMATION)
AlertID=AlertID+0; // Warning
else if (m_dialogStyle & wxICON_HAND)
else if (style & wxICON_HAND)
AlertID=AlertID+1; // Error
else if (m_dialogStyle & wxICON_INFORMATION)
else if (style & wxICON_INFORMATION)
AlertID=AlertID+2; // Information
else if (m_dialogStyle & wxICON_QUESTION)
else if (style & wxICON_QUESTION)
AlertID=AlertID+3; // Confirmation
// The Palm OS Dialog API does not support custom titles in a dialog box.