]>
git.saurik.com Git - wxWidgets.git/blob - src/palmos/msgdlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxMessageDialog
4 // Author: William Osborne
8 // Copyright: (c) William Osborne
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "msgdlg.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
27 #include "wx/dialog.h"
28 #include "wx/msgdlg.h"
31 IMPLEMENT_CLASS(wxMessageDialog
, wxDialog
)
33 wxMessageDialog::wxMessageDialog(wxWindow
*parent
,
34 const wxString
& message
,
35 const wxString
& caption
,
37 const wxPoint
& WXUNUSED(pos
))
40 // check for common programming errors
41 if ( (style
& wxID_OK
) == wxID_OK
)
43 // programmer probably confused wxID_OK with wxOK. Correct one is wxOK.
44 wxFAIL_MSG( _T("wxMessageBox: Did you mean wxOK (and not wxID_OK)?") );
50 m_dialogStyle
= style
;
54 int wxMessageDialog::ShowModal()
60 // Handle to the currently running application database
62 SysGetModuleDatabase(SysGetRefNum(), NULL
, &AppDB
);
64 // Translate wx styles into Palm OS styles
65 if (m_dialogStyle
& wxYES_NO
)
67 if (m_dialogStyle
& wxCANCEL
)
68 AlertID
=1300; // Yes No Cancel
70 AlertID
=1200; // Yes No
72 if (m_dialogStyle
& wxOK
)
74 if (m_dialogStyle
& wxCANCEL
)
75 AlertID
=1100; // Ok Cancel
80 // Add the icon styles
81 if (m_dialogStyle
& wxICON_EXCLAMATION
)
82 AlertID
=AlertID
+0; // Warning
83 else if (m_dialogStyle
& wxICON_HAND
)
84 AlertID
=AlertID
+1; // Error
85 else if (m_dialogStyle
& wxICON_INFORMATION
)
86 AlertID
=AlertID
+2; // Information
87 else if (m_dialogStyle
& wxICON_QUESTION
)
88 AlertID
=AlertID
+3; // Confirmation
90 // The Palm OS Dialog API does not support custom titles in a dialog box.
91 // So we have to set the title by manipulating the resource.
93 // Get the alert resource
95 MemHandle AlertHandle
;
96 AlertHandle
=DmGetResource(AppDB
,'Talt',AlertID
);
98 AlertPtr
=(char *)MemHandleLock(AlertHandle
);
101 // Clear out any old title. This must be done with a static array of chars
102 // because using MemSet is not supported on resources and could result in
103 // crashes or unpredictable behaviour.
104 char ClearTitle
[25]={' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '};
105 MemMove(AlertPtr
,&ClearTitle
,25);
107 // Get the title length and make sure it is not too long
108 int TitleLength
=m_caption
.length();
112 // Center the title in the window
113 int BufferLength
=(25-TitleLength
)/2;
114 AlertPtr
+=BufferLength
;
117 MemMove(AlertPtr
,m_caption
.c_str(),TitleLength
);
119 // Release the resource
120 MemHandleUnlock(AlertHandle
);
121 DmReleaseResource(AlertHandle
);
123 // Display the dialog
124 Result
=FrmCustomAlert(AppDB
,AlertID
,m_message
.c_str(),"","");
126 // Convert the Palm OS result to wxResult
132 else if(AlertID
<1200)
138 wxResult
=wxID_CANCEL
;
140 else if(AlertID
<1300)
156 wxResult
=wxID_CANCEL
;