]>
git.saurik.com Git - wxWidgets.git/blob - src/generic/msgdlgg.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxGenericMessageDialog
4 // Author: Julian Smart, Robert Roebling
8 // Copyright: (c) Julian Smart, Markus Holzem, Robert Roebling
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "msgdlgg.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
27 #include "wx/dialog.h"
28 #include "wx/button.h"
29 #include "wx/stattext.h"
30 #include "wx/statbmp.h"
31 #include "wx/layout.h"
41 #include "wx/generic/msgdlgg.h"
44 #include "wx/statline.h"
47 // ----------------------------------------------------------------------------
49 // ----------------------------------------------------------------------------
51 BEGIN_EVENT_TABLE(wxGenericMessageDialog
, wxDialog
)
52 EVT_BUTTON(wxID_YES
, wxGenericMessageDialog::OnYes
)
53 EVT_BUTTON(wxID_NO
, wxGenericMessageDialog::OnNo
)
54 EVT_BUTTON(wxID_CANCEL
, wxGenericMessageDialog::OnCancel
)
57 IMPLEMENT_CLASS(wxGenericMessageDialog
, wxDialog
)
59 wxGenericMessageDialog::wxGenericMessageDialog( wxWindow
*parent
,
60 const wxString
& message
,
61 const wxString
& caption
,
64 : wxDialog( parent
, -1, caption
, pos
, wxDefaultSize
, wxDEFAULT_DIALOG_STYLE
)
66 m_dialogStyle
= style
;
68 wxBoxSizer
*topsizer
= new wxBoxSizer( wxVERTICAL
);
70 wxBoxSizer
*icon_text
= new wxBoxSizer( wxHORIZONTAL
);
73 if (style
& wxICON_MASK
)
75 wxStaticBitmap
*icon
= new wxStaticBitmap(
76 this, -1, wxTheApp
->GetStdIcon((int)(style
& wxICON_MASK
)));
77 icon_text
->Add( icon
, 0, wxCENTER
);
81 icon_text
->Add( CreateTextSizer( message
), 0, wxCENTER
| wxLEFT
, 10 );
83 topsizer
->Add( icon_text
, 0, wxCENTER
| wxLEFT
|wxRIGHT
|wxTOP
, 10 );
87 topsizer
->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND
| wxLEFT
|wxRIGHT
|wxTOP
, 10 );
91 topsizer
->Add( CreateButtonSizer( style
), 0, wxCENTRE
| wxALL
, 10 );
93 SetAutoLayout( TRUE
);
96 topsizer
->SetSizeHints( this );
97 topsizer
->Fit( this );
98 wxSize
size( GetSize() );
99 if (size
.x
< size
.y
*3/2)
105 Centre( wxBOTH
| wxCENTER_FRAME
);
108 void wxGenericMessageDialog::OnYes(wxCommandEvent
& WXUNUSED(event
))
110 EndModal( wxID_YES
);
113 void wxGenericMessageDialog::OnNo(wxCommandEvent
& WXUNUSED(event
))
118 void wxGenericMessageDialog::OnCancel(wxCommandEvent
& WXUNUSED(event
))
120 /* Allow cancellation via ESC/Close button except if
121 only YES and NO are specified. */
122 if ( (m_dialogStyle
& wxYES_NO
) != wxYES_NO
|| (m_dialogStyle
& wxCANCEL
) )
124 EndModal( wxID_CANCEL
);
128 #endif // wxUSE_MSGDLG