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