]>
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"
23 #include "wx/dialog.h"
24 #include "wx/msgdlg.h"
30 IMPLEMENT_CLASS(wxMessageDialog
, wxDialog
)
32 wxMessageDialog::wxMessageDialog(wxWindow
*parent
,
33 const wxString
& message
,
34 const wxString
& caption
,
36 const wxPoint
& WXUNUSED(pos
))
41 SetMessageDialogStyle(style
);
44 int wxMessageDialog::ShowModal()
49 const long style
= GetMessageDialogStyle();
51 // Handle to the currently running application database
53 SysGetModuleDatabase(SysGetRefNum(), NULL
, &AppDB
);
55 // Translate wx styles into Palm OS styles
59 AlertID
=1300; // Yes No Cancel
61 AlertID
=1200; // Yes No
66 AlertID
=1100; // Ok Cancel
71 // Add the icon styles
72 if (style
& wxICON_EXCLAMATION
)
73 AlertID
=AlertID
+0; // Warning
74 else if (style
& wxICON_HAND
)
75 AlertID
=AlertID
+1; // Error
76 else if (style
& wxICON_INFORMATION
)
77 AlertID
=AlertID
+2; // Information
78 else if (style
& wxICON_QUESTION
)
79 AlertID
=AlertID
+3; // Confirmation
81 // The Palm OS Dialog API does not support custom titles in a dialog box.
82 // So we have to set the title by manipulating the resource.
84 // Get the alert resource
86 MemHandle AlertHandle
;
87 AlertHandle
=DmGetResource(AppDB
,'Talt',AlertID
);
89 AlertPtr
=(char *)MemHandleLock(AlertHandle
);
92 // Clear out any old title. This must be done with a static array of chars
93 // because using MemSet is not supported on resources and could result in
94 // crashes or unpredictable behaviour.
95 char ClearTitle
[25]={' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '};
96 MemMove(AlertPtr
,&ClearTitle
,25);
98 // Get the title length and make sure it is not too long
99 int TitleLength
=m_caption
.length();
103 // Center the title in the window
104 int BufferLength
=(25-TitleLength
)/2;
105 AlertPtr
+=BufferLength
;
108 MemMove(AlertPtr
,m_caption
.c_str(),TitleLength
);
110 // Release the resource
111 MemHandleUnlock(AlertHandle
);
112 DmReleaseResource(AlertHandle
);
114 // Display the dialog
115 Result
=FrmCustomAlert(AppDB
,AlertID
,m_message
.c_str(),"","");
117 // Convert the Palm OS result to wxResult
123 else if(AlertID
<1200)
129 wxResult
=wxID_CANCEL
;
131 else if(AlertID
<1300)
147 wxResult
=wxID_CANCEL
;