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