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