]> git.saurik.com Git - wxWidgets.git/blame - src/osx/iphone/msgdlg.mm
moving value setting conformance to impl
[wxWidgets.git] / src / osx / iphone / msgdlg.mm
CommitLineData
0c2dc57d
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/osx/iphone/msgdlg.mm
3// Purpose: wxMessageDialog
4// Author: Stefan Csomor
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id: msgdlg.cpp 54129 2008-06-11 19:30:52Z SC $
8// Copyright: (c) Stefan Csomor
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#include "wx/wxprec.h"
13
14#include "wx/msgdlg.h"
15
16#ifndef WX_PRECOMP
17 #include "wx/intl.h"
18 #include "wx/app.h"
19#endif
20
21#include "wx/thread.h"
22#include "wx/osx/private.h"
23
24
25IMPLEMENT_CLASS(wxMessageDialog, wxDialog)
26
27
28wxMessageDialog::wxMessageDialog(wxWindow *parent,
29 const wxString& message,
30 const wxString& caption,
31 long style,
32 const wxPoint& WXUNUSED(pos))
33 : wxMessageDialogWithCustomLabels(parent, message, caption, style)
34{
35}
36
37int wxMessageDialog::ShowModal()
38{
39 int resultbutton = wxID_CANCEL;
40
41 const long style = GetMessageDialogStyle();
42
43 // work out what to display
44 // if the extended text is empty then we use the caption as the title
45 // and the message as the text (for backwards compatibility)
46 // but if the extended message is not empty then we use the message as the title
47 // and the extended message as the text because that makes more sense
48
49 wxString msgtitle,msgtext;
50 if(m_extendedMessage.IsEmpty())
51 {
52 msgtitle = m_caption;
53 msgtext = m_message;
54 }
55 else
56 {
57 msgtitle = m_message;
58 msgtext = m_extendedMessage;
59 }
03647350 60
0c2dc57d
SC
61 wxCFStringRef cfNoString( GetNoLabel(), GetFont().GetEncoding() );
62 wxCFStringRef cfYesString( GetYesLabel(), GetFont().GetEncoding() );
63 wxCFStringRef cfOKString( GetOKLabel(), GetFont().GetEncoding() );
64 wxCFStringRef cfCancelString( GetCancelLabel(), GetFont().GetEncoding() );
65
66 wxCFStringRef cfTitle( msgtitle, GetFont().GetEncoding() );
67 wxCFStringRef cfText( msgtext, GetFont().GetEncoding() );
68
69 UIAlertView* alert = [[UIAlertView alloc] initWithTitle:cfTitle.AsNSString() message:cfText.AsNSString() delegate:nil cancelButtonTitle:nil otherButtonTitles:nil];
03647350 70
0c2dc57d
SC
71 int buttonId[3] = { 0, 0, 0 };
72 int buttonCount = 0;
73
74 if (style & wxYES_NO)
75 {
76 if ( style & wxNO_DEFAULT )
77 {
78 [alert addButtonWithTitle:cfNoString.AsNSString()];
79 buttonId[ buttonCount++ ] = wxID_NO;
80 [alert addButtonWithTitle:cfYesString.AsNSString()];
81 buttonId[ buttonCount++ ] = wxID_YES;
82 }
83 else
84 {
85 [alert addButtonWithTitle:cfYesString.AsNSString()];
86 buttonId[ buttonCount++ ] = wxID_YES;
87 [alert addButtonWithTitle:cfNoString.AsNSString()];
88 buttonId[ buttonCount++ ] = wxID_NO;
89 }
90
91 if (style & wxCANCEL)
92 {
93 [alert addButtonWithTitle:cfCancelString.AsNSString()];
94 buttonId[ buttonCount++ ] = wxID_CANCEL;
95 }
96 }
97 // the MSW implementation even shows an OK button if it is not specified, we'll do the same
98 else
99 {
100 [alert addButtonWithTitle:cfOKString.AsNSString()];
101 buttonId[ buttonCount++ ] = wxID_OK;
102 if (style & wxCANCEL)
103 {
104 [alert addButtonWithTitle:cfCancelString.AsNSString()];
105 buttonId[ buttonCount++ ] = wxID_CANCEL;
106 }
107 }
108
109
110 wxNonOwnedWindow* parentWindow = NULL;
111 int button = -1;
03647350
VZ
112
113 if (GetParent())
0c2dc57d
SC
114 {
115 parentWindow = dynamic_cast<wxNonOwnedWindow*>(wxGetTopLevelParent(GetParent()));
116 }
117
118/*
119 if (parentWindow)
120 {
121 NSWindow* nativeParent = parentWindow->GetWXWindow();
03647350
VZ
122 ModalDialogDelegate* sheetDelegate = [[ModalDialogDelegate alloc] init];
123 [alert beginSheetModalForWindow: nativeParent modalDelegate: sheetDelegate
124 didEndSelector: @selector(sheetDidEnd:returnCode:contextInfo:)
0c2dc57d
SC
125 contextInfo: nil];
126 [sheetDelegate waitForSheetToFinish];
127 button = [sheetDelegate code];
128 [sheetDelegate release];
129 }
130 else
131*/
132 {
133 [alert show];
134 }
135 // [alert release];
03647350 136
0c2dc57d
SC
137 return wxID_CANCEL;
138}