]>
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 #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"
34 IMPLEMENT_CLASS(wxMessageDialog
, wxDialog
)
36 wxMessageDialog::wxMessageDialog(wxWindow
*parent
,
37 const wxString
& message
,
38 const wxString
& caption
,
40 const wxPoint
& WXUNUSED(pos
))
45 SetMessageDialogStyle(style
);
48 int wxMessageDialog::ShowModal()
53 const long style
= GetMessageDialogStyle();
55 // Handle to the currently running application database
57 SysGetModuleDatabase(SysGetRefNum(), NULL
, &AppDB
);
59 // Translate wx styles into Palm OS styles
63 AlertID
=1300; // Yes No Cancel
65 AlertID
=1200; // Yes No
70 AlertID
=1100; // Ok Cancel
75 // Add the icon styles
76 if (style
& wxICON_EXCLAMATION
)
77 AlertID
=AlertID
+0; // Warning
78 else if (style
& wxICON_HAND
)
79 AlertID
=AlertID
+1; // Error
80 else if (style
& wxICON_INFORMATION
)
81 AlertID
=AlertID
+2; // Information
82 else if (style
& wxICON_QUESTION
)
83 AlertID
=AlertID
+3; // Confirmation
85 // The Palm OS Dialog API does not support custom titles in a dialog box.
86 // So we have to set the title by manipulating the resource.
88 // Get the alert resource
90 MemHandle AlertHandle
;
91 AlertHandle
=DmGetResource(AppDB
,'Talt',AlertID
);
93 AlertPtr
=(char *)MemHandleLock(AlertHandle
);
96 // Clear out any old title. This must be done with a static array of chars
97 // because using MemSet is not supported on resources and could result in
98 // crashes or unpredictable behaviour.
99 char ClearTitle
[25]={' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '};
100 MemMove(AlertPtr
,&ClearTitle
,25);
102 // Get the title length and make sure it is not too long
103 int TitleLength
=m_caption
.length();
107 // Center the title in the window
108 int BufferLength
=(25-TitleLength
)/2;
109 AlertPtr
+=BufferLength
;
112 MemMove(AlertPtr
,m_caption
.c_str(),TitleLength
);
114 // Release the resource
115 MemHandleUnlock(AlertHandle
);
116 DmReleaseResource(AlertHandle
);
118 // Display the dialog
119 Result
=FrmCustomAlert(AppDB
,AlertID
,m_message
.c_str(),"","");
121 // Convert the Palm OS result to wxResult
127 else if(AlertID
<1200)
133 wxResult
=wxID_CANCEL
;
135 else if(AlertID
<1300)
151 wxResult
=wxID_CANCEL
;