]>
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"
29 IMPLEMENT_CLASS(wxMessageDialog
, wxDialog
)
31 wxMessageDialog::wxMessageDialog(wxWindow
*parent
,
32 const wxString
& message
,
33 const wxString
& caption
,
35 const wxPoint
& WXUNUSED(pos
))
40 SetMessageDialogStyle(style
);
43 int wxMessageDialog::ShowModal()
48 const long style
= GetMessageDialogStyle();
50 // Handle to the currently running application database
52 SysGetModuleDatabase(SysGetRefNum(), NULL
, &AppDB
);
54 // Translate wx styles into Palm OS styles
58 AlertID
=1300; // Yes No Cancel
60 AlertID
=1200; // Yes No
65 AlertID
=1100; // Ok Cancel
70 // Add the icon styles
71 if (style
& wxICON_EXCLAMATION
)
72 AlertID
=AlertID
+0; // Warning
73 else if (style
& wxICON_HAND
)
74 AlertID
=AlertID
+1; // Error
75 else if (style
& wxICON_INFORMATION
)
76 AlertID
=AlertID
+2; // Information
77 else if (style
& wxICON_QUESTION
)
78 AlertID
=AlertID
+3; // Confirmation
80 // The Palm OS Dialog API does not support custom titles in a dialog box.
81 // So we have to set the title by manipulating the resource.
83 // Get the alert resource
85 MemHandle AlertHandle
;
86 AlertHandle
=DmGetResource(AppDB
,'Talt',AlertID
);
88 AlertPtr
=(char *)MemHandleLock(AlertHandle
);
91 // Clear out any old title. This must be done with a static array of chars
92 // because using MemSet is not supported on resources and could result in
93 // crashes or unpredictable behaviour.
94 char ClearTitle
[25]={' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '};
95 MemMove(AlertPtr
,&ClearTitle
,25);
97 // Get the title length and make sure it is not too long
98 int TitleLength
=m_caption
.length();
102 // Center the title in the window
103 int BufferLength
=(25-TitleLength
)/2;
104 AlertPtr
+=BufferLength
;
107 MemMove(AlertPtr
,m_caption
.c_str(),TitleLength
);
109 // Release the resource
110 MemHandleUnlock(AlertHandle
);
111 DmReleaseResource(AlertHandle
);
113 // Display the dialog
114 Result
=FrmCustomAlert(AppDB
,AlertID
,m_message
.c_str(),"","");
116 // Convert the Palm OS result to wxResult
122 else if(AlertID
<1200)
128 wxResult
=wxID_CANCEL
;
130 else if(AlertID
<1300)
146 wxResult
=wxID_CANCEL
;