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