]> git.saurik.com Git - wxWidgets.git/blame - src/os2/msgdlg.cpp
fix for wxDateTime::SetToYearDay(last month day) (bug 816065)
[wxWidgets.git] / src / os2 / msgdlg.cpp
CommitLineData
0e320a79
DW
1/////////////////////////////////////////////////////////////////////////////
2// Name: msgdlg.cpp
3// Purpose: wxMessageDialog
cdf1e714 4// Author: David Webster
0e320a79 5// Modified by:
cdf1e714 6// Created: 10/10/99
0e320a79 7// RCS-ID: $$
cdf1e714
DW
8// Copyright: (c) David Webster
9// Licence: wxWindows licence
0e320a79
DW
10/////////////////////////////////////////////////////////////////////////////
11
aa213887
SN
12#ifdef __GNUG__
13#pragma implementation "msgdlg.h"
14#endif
15
cdf1e714
DW
16// For compilers that support precompilation, includes "wx.h".
17#include "wx/wxprec.h"
18
19#ifndef WX_PRECOMP
20#include <stdio.h>
21#include "wx/defs.h"
22#include "wx/utils.h"
23#include "wx/dialog.h"
f6bcfd97 24#include "wx/app.h"
cdf1e714 25#include "wx/msgdlg.h"
0e320a79
DW
26#endif
27
cdf1e714
DW
28#include "wx/os2/private.h"
29
30#include <math.h>
31#include <stdlib.h>
32#include <string.h>
33
34#define wxDIALOG_DEFAULT_X 300
35#define wxDIALOG_DEFAULT_Y 300
0e320a79 36
0e320a79 37IMPLEMENT_CLASS(wxMessageDialog, wxDialog)
0e320a79 38
f6bcfd97
BP
39wxMessageDialog::wxMessageDialog(
40 wxWindow* pParent
41, const wxString& rsMessage
42, const wxString& rsCaption
43, long lStyle
44, const wxPoint& pPos
45)
0e320a79 46{
f6bcfd97
BP
47 m_sCaption = rsCaption;
48 m_sMessage = rsMessage;
49 m_lDialogStyle = lStyle;
50 m_pParent = NULL; // pParent;
51} // end of wxMessageDialog::wxMessageDialog
0e320a79
DW
52
53int wxMessageDialog::ShowModal()
54{
f6bcfd97
BP
55 HWND hWnd = 0;
56 ULONG ulStyle = MB_OK;
57 int nAns = wxOK;
58
59 if (!wxTheApp->GetTopWindow())
60 {
61 //
62 // when the message box is shown from wxApp::OnInit() (i.e. before the
63 // message loop is entered), this must be done or the next message box
64 // will never be shown - just try putting 2 calls to wxMessageBox() in
65 // OnInit() to see it
66 //
67 while (wxTheApp->Pending())
68 wxTheApp->Dispatch();
69 }
70
71 if (m_pParent)
72 hWnd = (HWND) m_pParent->GetHWND();
73 else
74 hWnd = HWND_DESKTOP;
75 if (m_lDialogStyle & wxYES_NO)
76 {
77 if (m_lDialogStyle & wxCANCEL)
78 ulStyle = MB_YESNOCANCEL;
79 else
80 ulStyle = MB_YESNO;
81
82 if (m_lDialogStyle & wxNO_DEFAULT)
83 ulStyle |= MB_DEFBUTTON2;
84 }
85
86 if (m_lDialogStyle & wxOK)
87 {
88 if (m_lDialogStyle & wxCANCEL)
89 ulStyle = MB_OKCANCEL;
90 else
91 ulStyle = MB_OK;
92 }
93 if (m_lDialogStyle & wxICON_EXCLAMATION)
94 ulStyle |= MB_ICONEXCLAMATION;
95 else if (m_lDialogStyle & wxICON_HAND)
96 ulStyle |= MB_ICONHAND;
97 else if (m_lDialogStyle & wxICON_INFORMATION)
98 ulStyle |= MB_ICONEXCLAMATION;
99 else if (m_lDialogStyle & wxICON_QUESTION)
100 ulStyle |= MB_ICONQUESTION;
101
102 if (hWnd != HWND_DESKTOP)
103 ulStyle |= MB_APPLMODAL;
104 else
105 ulStyle |= MB_SYSTEMMODAL;
106
107 //
108 // This little line of code is get message boxes under OS/2 to
109 // behve like the other ports. In OS/2 if the parent is a window
110 // it displays, clipped, in the window. This centers it on the
111 // desktop, like the other ports but still allows control over modality
112 //
113 hWnd = HWND_DESKTOP;
114
115 ULONG ulAns = ::WinMessageBox( hWnd
116 ,hWnd
117 ,(PSZ)m_sMessage.c_str()
118 ,(PSZ)m_sCaption.c_str()
119 ,0L
120 ,ulStyle);
121 switch (ulAns)
122 {
123 case MBID_CANCEL:
124 nAns = wxID_CANCEL;
125 break;
126 case MBID_OK:
127 nAns = wxID_OK;
128 break;
129 case MBID_YES:
130 nAns = wxID_YES;
131 break;
132 case MBID_NO:
133 nAns = wxID_NO;
134 break;
135 default:
136 nAns = wxID_CANCEL;
137 }
138 return nAns;
139} // end of wxMessageDialog::ShowModal
0e320a79 140