X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0e320a79f187558effb04d92020b470372bbe456..1cd9779fce63b081d875de7a901c8eb6120d0b8a:/src/os2/msgdlg.cpp?ds=sidebyside diff --git a/src/os2/msgdlg.cpp b/src/os2/msgdlg.cpp index aeaa9bac7a..90d433a089 100644 --- a/src/os2/msgdlg.cpp +++ b/src/os2/msgdlg.cpp @@ -1,36 +1,134 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: msgdlg.cpp +// Name: src/os2/msgdlg.cpp // Purpose: wxMessageDialog -// Author: AUTHOR +// Author: David Webster // Modified by: -// Created: 04/01/98 -// RCS-ID: $$ -// Copyright: (c) AUTHOR -// Licence: wxWindows licence +// Created: 10/10/99 +// RCS-ID: $Id$ +// Copyright: (c) David Webster +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ -#pragma implementation "msgdlg.h" +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#include "wx/msgdlg.h" + +#ifndef WX_PRECOMP + #include + #include "wx/utils.h" + #include "wx/dialog.h" + #include "wx/app.h" + #include "wx/math.h" #endif -#include "wx/stubs/msgdlg.h" +#include "wx/os2/private.h" + +#include +#include + +#define wxDIALOG_DEFAULT_X 300 +#define wxDIALOG_DEFAULT_Y 300 -#if !USE_SHARED_LIBRARY IMPLEMENT_CLASS(wxMessageDialog, wxDialog) -#endif -wxMessageDialog::wxMessageDialog(wxWindow *parent, const wxString& message, const wxString& caption, - long style, const wxPoint& pos) +wxMessageDialog::wxMessageDialog( wxWindow* WXUNUSED(pParent), + const wxString& rsMessage, + const wxString& rsCaption, + long lStyle, + const wxPoint& WXUNUSED(pPos) ) { - m_caption = caption; - m_message = message; - m_dialogStyle = style; - m_parent = parent; -} + m_sCaption = rsCaption; + m_sMessage = rsMessage; + m_pParent = NULL; // pParent; + SetMessageDialogStyle(lStyle); +} // end of wxMessageDialog::wxMessageDialog int wxMessageDialog::ShowModal() { - // TODO - return wxID_CANCEL; -} + HWND hWnd = 0; + ULONG ulStyle = MB_OK; + int nAns = wxOK; + const long lStyle = GetMessageDialogStyle(); + + if (!wxTheApp->GetTopWindow()) + { + // + // when the message box is shown from wxApp::OnInit() (i.e. before the + // message loop is entered), this must be done or the next message box + // will never be shown - just try putting 2 calls to wxMessageBox() in + // OnInit() to see it + // + while (wxTheApp->Pending()) + wxTheApp->Dispatch(); + } + + if (m_pParent) + hWnd = (HWND) m_pParent->GetHWND(); + else + hWnd = HWND_DESKTOP; + if (lStyle & wxYES_NO) + { + if (lStyle & wxCANCEL) + ulStyle = MB_YESNOCANCEL; + else + ulStyle = MB_YESNO; + + if (lStyle & wxNO_DEFAULT) + ulStyle |= MB_DEFBUTTON2; + } + + if (lStyle & wxOK) + { + if (lStyle & wxCANCEL) + ulStyle = MB_OKCANCEL; + else + ulStyle = MB_OK; + } + if (lStyle & wxICON_EXCLAMATION) + ulStyle |= MB_ICONEXCLAMATION; + else if (lStyle & wxICON_HAND) + ulStyle |= MB_ICONHAND; + else if (lStyle & wxICON_INFORMATION) + ulStyle |= MB_ICONEXCLAMATION; + else if (lStyle & wxICON_QUESTION) + ulStyle |= MB_ICONQUESTION; + + if (hWnd != HWND_DESKTOP) + ulStyle |= MB_APPLMODAL; + else + ulStyle |= MB_SYSTEMMODAL; + + // + // This little line of code is get message boxes under OS/2 to + // behve like the other ports. In OS/2 if the parent is a window + // it displays, clipped, in the window. This centers it on the + // desktop, like the other ports but still allows control over modality + // + hWnd = HWND_DESKTOP; + ULONG ulAns = ::WinMessageBox( hWnd + ,hWnd + ,(PSZ)m_sMessage.c_str() + ,(PSZ)m_sCaption.c_str() + ,0L + ,ulStyle); + switch (ulAns) + { + case MBID_CANCEL: + nAns = wxID_CANCEL; + break; + case MBID_OK: + nAns = wxID_OK; + break; + case MBID_YES: + nAns = wxID_YES; + break; + case MBID_NO: + nAns = wxID_NO; + break; + default: + nAns = wxID_CANCEL; + } + return nAns; +} // end of wxMessageDialog::ShowModal