]>
git.saurik.com Git - wxWidgets.git/blob - src/palmos/msgdlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/palmos/msgdlg.cpp
3 // Purpose: wxMessageDialog
4 // Author: William Osborne - minimal working wxPalmOS port
8 // Copyright: (c) William Osborne
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
22 #include "wx/dialog.h"
23 #include "wx/msgdlg.h"
28 #else // __WXPALMOS5__
29 #include <UIResources.h> // alertRscType
34 IMPLEMENT_CLASS(wxMessageDialog
, wxDialog
)
36 int wxMessageDialog::ShowModal()
41 const long style
= GetMessageDialogStyle();
44 // Handle to the currently running application database
46 SysGetModuleDatabase(SysGetRefNum(), NULL
, &AppDB
);
47 #endif // __WXPALMOS6__
49 // Translate wx styles into Palm OS styles
53 AlertID
=1300; // Yes No Cancel
55 AlertID
=1200; // Yes No
60 AlertID
=1100; // Ok Cancel
65 // Add the icon styles
66 switch ( GetEffectiveIcon() )
69 AlertID
= AlertID
+ 1;
73 AlertID
= AlertID
+ 0;
77 AlertID
= AlertID
+ 3;
81 case wxICON_INFORMATION
:
82 AlertID
= AlertID
+ 2;
86 // The Palm OS Dialog API does not support custom titles in a dialog box.
87 // So we have to set the title by manipulating the resource.
89 // Get the alert resource
91 MemHandle AlertHandle
;
92 AlertHandle
= POS_DmGetResource (AppDB
, alertRscType
, AlertID
);
94 AlertPtr
=(char *)MemHandleLock(AlertHandle
);
97 // Clear out any old title. This must be done with a static array of chars
98 // because using MemSet is not supported on resources and could result in
99 // crashes or unpredictable behaviour.
100 char ClearTitle
[25]={' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '};
101 MemMove(AlertPtr
,&ClearTitle
,25);
103 // Get the title length and make sure it is not too long
104 int TitleLength
=m_caption
.length();
108 // Center the title in the window
109 int BufferLength
=(25-TitleLength
)/2;
110 AlertPtr
+=BufferLength
;
113 MemMove(AlertPtr
,m_caption
.c_str(),TitleLength
);
115 // Release the resource
116 MemHandleUnlock(AlertHandle
);
117 DmReleaseResource(AlertHandle
);
119 // Display the dialog
120 Result
= POS_FrmCustomAlert (AppDB
, AlertID
, m_message
.c_str(), "", "");
122 // Convert the Palm OS result to wxResult
128 else if(AlertID
<1200)
134 wxResult
=wxID_CANCEL
;
136 else if(AlertID
<1300)
152 wxResult
=wxID_CANCEL
;