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