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