]> git.saurik.com Git - wxWidgets.git/blame - src/palmos/msgdlg.cpp
bug fix for vista in multi-selection tree
[wxWidgets.git] / src / palmos / msgdlg.cpp
CommitLineData
ffecfa5a 1/////////////////////////////////////////////////////////////////////////////
e2731512 2// Name: src/palmos/msgdlg.cpp
ffecfa5a 3// Purpose: wxMessageDialog
e2731512 4// Author: William Osborne - minimal working wxPalmOS port
ffecfa5a
JS
5// Modified by:
6// Created: 10/13/04
e2731512 7// RCS-ID: $Id$
ffecfa5a
JS
8// Copyright: (c) William Osborne
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
ffecfa5a
JS
12// For compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
14
15#ifdef __BORLANDC__
7520f3da 16 #pragma hdrstop
ffecfa5a
JS
17#endif
18
19#ifndef WX_PRECOMP
20 #include "wx/app.h"
ffecfa5a
JS
21 #include "wx/utils.h"
22 #include "wx/dialog.h"
23 #include "wx/msgdlg.h"
24#endif
25
20bc5ad8
WS
26#include <Loader.h>
27#include <Form.h>
28
ffecfa5a
JS
29IMPLEMENT_CLASS(wxMessageDialog, wxDialog)
30
ffecfa5a
JS
31int wxMessageDialog::ShowModal()
32{
33 int AlertID=1000;
34 int Result=0;
35 int wxResult=wxID_OK;
e5b50758 36 const long style = GetMessageDialogStyle();
e2731512 37
ffecfa5a
JS
38 // Handle to the currently running application database
39 DmOpenRef AppDB;
40 SysGetModuleDatabase(SysGetRefNum(), NULL, &AppDB);
41
42 // Translate wx styles into Palm OS styles
e5b50758 43 if (style & wxYES_NO)
ffecfa5a 44 {
e5b50758 45 if (style & wxCANCEL)
ffecfa5a
JS
46 AlertID=1300; // Yes No Cancel
47 else
48 AlertID=1200; // Yes No
49 }
e5b50758 50 if (style & wxOK)
ffecfa5a 51 {
e5b50758 52 if (style & wxCANCEL)
ffecfa5a
JS
53 AlertID=1100; // Ok Cancel
54 else
55 AlertID=1000; // Ok
56 }
57
58 // Add the icon styles
e5b50758 59 if (style & wxICON_EXCLAMATION)
ffecfa5a 60 AlertID=AlertID+0; // Warning
e5b50758 61 else if (style & wxICON_HAND)
ffecfa5a 62 AlertID=AlertID+1; // Error
e5b50758 63 else if (style & wxICON_INFORMATION)
ffecfa5a 64 AlertID=AlertID+2; // Information
e5b50758 65 else if (style & wxICON_QUESTION)
ffecfa5a
JS
66 AlertID=AlertID+3; // Confirmation
67
68 // The Palm OS Dialog API does not support custom titles in a dialog box.
69 // So we have to set the title by manipulating the resource.
70
71 // Get the alert resource
72 char *AlertPtr;
73 MemHandle AlertHandle;
74 AlertHandle=DmGetResource(AppDB,'Talt',AlertID);
75
76 AlertPtr=(char *)MemHandleLock(AlertHandle);
77 AlertPtr+=8;
78
79 // Clear out any old title. This must be done with a static array of chars
e2731512 80 // because using MemSet is not supported on resources and could result in
ffecfa5a
JS
81 // crashes or unpredictable behaviour.
82 char ClearTitle[25]={' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '};
83 MemMove(AlertPtr,&ClearTitle,25);
84
85 // Get the title length and make sure it is not too long
86 int TitleLength=m_caption.length();
87 if(TitleLength>25)
88 TitleLength=25;
e2731512 89
ffecfa5a
JS
90 // Center the title in the window
91 int BufferLength=(25-TitleLength)/2;
92 AlertPtr+=BufferLength;
93
94 // Copy the title
95 MemMove(AlertPtr,m_caption.c_str(),TitleLength);
e2731512 96
ffecfa5a
JS
97 // Release the resource
98 MemHandleUnlock(AlertHandle);
99 DmReleaseResource(AlertHandle);
100
101 // Display the dialog
2afb9e16 102 Result=FrmCustomAlert(AppDB,AlertID,GetFullMessage().c_str(),"","");
ffecfa5a
JS
103
104 // Convert the Palm OS result to wxResult
105 if(AlertID<1100)
106 {
107 // Ok
108 wxResult=wxID_OK;
109 }
110 else if(AlertID<1200)
111 {
112 // Ok Cancel
113 if(Result==0)
114 wxResult=wxID_OK;
115 else
116 wxResult=wxID_CANCEL;
117 }
118 else if(AlertID<1300)
119 {
120 // Yes No
121 if(Result==0)
122 wxResult=wxID_YES;
123 else
124 wxResult=wxID_NO;
125 }
126 else
127 {
128 // Yes No Cancel
129 if(Result==0)
130 wxResult=wxID_YES;
131 else if(Result==1)
132 wxResult=wxID_NO;
133 else
134 wxResult=wxID_CANCEL;
135 }
136
e2731512 137 return wxResult;
ffecfa5a 138}