]>
Commit | Line | Data |
---|---|---|
3c9287bb | 1 | ///////////////////////////////////////////////////////////////////////////// |
2ddb4d13 | 2 | // Name: src/generic/propdlg.cpp |
3c9287bb JS |
3 | // Purpose: wxPropertySheetDialog |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 2005-03-12 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
3c9287bb JS |
12 | // For compilers that support precompilation, includes "wx.h". |
13 | #include "wx/wxprec.h" | |
14 | ||
15 | #ifdef __BORLANDC__ | |
16 | #pragma hdrstop | |
17 | #endif | |
18 | ||
19 | #include "wx/defs.h" | |
20 | ||
532d575b WS |
21 | #if wxUSE_BOOKCTRL |
22 | ||
3c9287bb JS |
23 | #ifndef WX_PRECOMP |
24 | #include "wx/button.h" | |
25 | #include "wx/sizer.h" | |
26 | #include "wx/intl.h" | |
27 | #include "wx/log.h" | |
28 | #include "wx/msgdlg.h" | |
29 | #endif | |
30 | ||
3be8026d | 31 | #include "wx/bookctrl.h" |
3c9287bb | 32 | #include "wx/generic/propdlg.h" |
897b24cf | 33 | #include "wx/sysopt.h" |
3c9287bb JS |
34 | |
35 | //----------------------------------------------------------------------------- | |
36 | // wxPropertySheetDialog | |
37 | //----------------------------------------------------------------------------- | |
38 | ||
39 | IMPLEMENT_DYNAMIC_CLASS(wxPropertySheetDialog, wxDialog) | |
40 | ||
c9ab63f4 JS |
41 | BEGIN_EVENT_TABLE(wxPropertySheetDialog, wxDialog) |
42 | EVT_ACTIVATE(wxPropertySheetDialog::OnActivate) | |
43 | END_EVENT_TABLE() | |
44 | ||
532d575b | 45 | bool wxPropertySheetDialog::Create(wxWindow* parent, wxWindowID id, const wxString& title, |
3c9287bb JS |
46 | const wxPoint& pos, const wxSize& sz, long style, |
47 | const wxString& name) | |
48 | { | |
ac5f5c9e | 49 | if (!wxDialog::Create(parent, id, title, pos, sz, style|wxCLIP_CHILDREN, name)) |
3c9287bb | 50 | return false; |
532d575b | 51 | |
3c9287bb JS |
52 | wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL ); |
53 | SetSizer(topSizer); | |
54 | ||
55 | // This gives more space around the edges | |
56 | m_innerSizer = new wxBoxSizer( wxVERTICAL ); | |
57 | ||
95ba86d7 | 58 | int extraSpace = 2; |
0906c58d | 59 | #if defined(__SMARTPHONE__) || defined(__POCKETPC__) |
3c9287bb JS |
60 | extraSpace=0; |
61 | #endif | |
62 | topSizer->Add(m_innerSizer, 1, wxGROW|wxALL, extraSpace); | |
63 | ||
64 | m_bookCtrl = CreateBookCtrl(); | |
65 | AddBookCtrl(m_innerSizer); | |
66 | ||
67 | return true; | |
68 | } | |
69 | ||
70 | void wxPropertySheetDialog::Init() | |
71 | { | |
72 | m_innerSizer = NULL; | |
73 | m_bookCtrl = NULL; | |
74 | } | |
75 | ||
76 | // Layout the dialog, to be called after pages have been created | |
77 | void wxPropertySheetDialog::LayoutDialog() | |
78 | { | |
0906c58d | 79 | #if !defined(__SMARTPHONE__) && !defined(__POCKETPC__) |
3c9287bb | 80 | GetSizer()->Fit(this); |
95ba86d7 | 81 | GetSizer()->SetSizeHints(this); |
3c9287bb JS |
82 | Centre(wxBOTH); |
83 | #endif | |
c9ab63f4 JS |
84 | #if defined(__SMARTPHONE__) |
85 | if (m_bookCtrl) | |
86 | m_bookCtrl->SetFocus(); | |
87 | #endif | |
3c9287bb JS |
88 | } |
89 | ||
90 | // Creates the buttons, if any | |
91 | void wxPropertySheetDialog::CreateButtons(int flags) | |
92 | { | |
897b24cf WS |
93 | #ifdef __POCKETPC__ |
94 | // keep system option status | |
95 | const wxChar *optionName = wxT("wince.dialog.real-ok-cancel"); | |
96 | const int status = wxSystemOptions::GetOptionInt(optionName); | |
97 | wxSystemOptions::SetOption(optionName,0); | |
98 | #endif | |
99 | ||
100 | wxSizer *buttonSizer = CreateButtonSizer( flags & ButtonSizerFlags ); | |
101 | if(buttonSizer->GetChildren().GetCount() > 0 ) | |
102 | { | |
103 | m_innerSizer->Add( buttonSizer, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT|wxRIGHT, 2); | |
104 | m_innerSizer->AddSpacer(2); | |
105 | } | |
106 | else | |
107 | { | |
108 | delete buttonSizer; | |
109 | } | |
110 | ||
111 | #ifdef __POCKETPC__ | |
112 | // restore system option | |
113 | wxSystemOptions::SetOption(optionName,status); | |
3c9287bb JS |
114 | #endif |
115 | } | |
116 | ||
117 | // Creates the book control | |
118 | wxBookCtrlBase* wxPropertySheetDialog::CreateBookCtrl() | |
119 | { | |
ac5f5c9e | 120 | int style = wxCLIP_CHILDREN; |
3be8026d | 121 | #if defined(__POCKETPC__) && wxUSE_NOTEBOOK |
2ddb4d13 | 122 | style |= wxBK_BOTTOM|wxNB_FLAT; |
3be8026d | 123 | #else |
2ddb4d13 | 124 | style |= wxBK_DEFAULT; |
3c9287bb | 125 | #endif |
3be8026d | 126 | return new wxBookCtrl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style ); |
3c9287bb JS |
127 | } |
128 | ||
129 | // Adds the book control to the inner sizer. | |
130 | void wxPropertySheetDialog::AddBookCtrl(wxSizer* sizer) | |
131 | { | |
3be8026d | 132 | #if defined(__POCKETPC__) && wxUSE_NOTEBOOK |
3c9287bb JS |
133 | // The book control has to be sized larger than the dialog because of a border bug |
134 | // in WinCE | |
0906c58d JS |
135 | int borderSize = -2; |
136 | sizer->Add( m_bookCtrl, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP|wxRIGHT, borderSize ); | |
3c9287bb JS |
137 | #else |
138 | sizer->Add( m_bookCtrl, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 ); | |
139 | #endif | |
140 | } | |
141 | ||
c9ab63f4 JS |
142 | void wxPropertySheetDialog::OnActivate(wxActivateEvent& event) |
143 | { | |
144 | #if defined(__SMARTPHONE__) | |
145 | // Attempt to focus the choice control: not yet working, but might | |
146 | // be a step in the right direction. OnActivate overrides the default | |
147 | // handler in toplevel.cpp that sets the focus for the first child of | |
148 | // of the dialog (the choicebook). | |
149 | if (event.GetActive()) | |
150 | { | |
532d575b | 151 | wxChoicebook* choiceBook = wxDynamicCast(GetBookCtrl(), wxChoicebook); |
c9ab63f4 JS |
152 | if (choiceBook) |
153 | choiceBook->SetFocus(); | |
154 | } | |
155 | else | |
156 | #endif | |
157 | event.Skip(); | |
158 | } | |
159 | ||
532d575b | 160 | #endif // wxUSE_BOOKCTRL |