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