]>
git.saurik.com Git - wxWidgets.git/blob - src/generic/propdlg.cpp
d82f8b889c834747f561782fbaf0193ba0df8ea8
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/generic/propdlg.cpp
3 // Purpose: wxPropertySheetDialog
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
24 #include "wx/button.h"
28 #include "wx/msgdlg.h"
31 #include "wx/bookctrl.h"
34 #include "wx/notebook.h"
37 #include "wx/choicebk.h"
40 #include "wx/toolbook.h"
43 #include "wx/listbook.h"
46 #include "wx/generic/propdlg.h"
47 #include "wx/sysopt.h"
49 //-----------------------------------------------------------------------------
50 // wxPropertySheetDialog
51 //-----------------------------------------------------------------------------
53 IMPLEMENT_DYNAMIC_CLASS(wxPropertySheetDialog
, wxDialog
)
55 BEGIN_EVENT_TABLE(wxPropertySheetDialog
, wxDialog
)
56 EVT_ACTIVATE(wxPropertySheetDialog::OnActivate
)
57 EVT_IDLE(wxPropertySheetDialog::OnIdle
)
60 bool wxPropertySheetDialog::Create(wxWindow
* parent
, wxWindowID id
, const wxString
& title
,
61 const wxPoint
& pos
, const wxSize
& sz
, long style
,
64 if (!wxDialog::Create(parent
, id
, title
, pos
, sz
, style
|wxCLIP_CHILDREN
, name
))
67 wxBoxSizer
*topSizer
= new wxBoxSizer( wxVERTICAL
);
70 // This gives more space around the edges
71 m_innerSizer
= new wxBoxSizer( wxVERTICAL
);
74 #if defined(__SMARTPHONE__) || defined(__POCKETPC__)
77 topSizer
->Add(m_innerSizer
, 1, wxGROW
|wxALL
, extraSpace
);
79 m_bookCtrl
= CreateBookCtrl();
80 AddBookCtrl(m_innerSizer
);
85 void wxPropertySheetDialog::Init()
87 m_sheetStyle
= wxPROPSHEET_DEFAULT
;
92 // Layout the dialog, to be called after pages have been created
93 void wxPropertySheetDialog::LayoutDialog(int centreFlags
)
95 #if !defined(__SMARTPHONE__) && !defined(__POCKETPC__)
96 GetSizer()->Fit(this);
97 GetSizer()->SetSizeHints(this);
101 #if defined(__SMARTPHONE__)
103 m_bookCtrl
->SetFocus();
107 // Creates the buttons, if any
108 void wxPropertySheetDialog::CreateButtons(int flags
)
111 // keep system option status
112 const wxChar
*optionName
= wxT("wince.dialog.real-ok-cancel");
113 const int status
= wxSystemOptions::GetOptionInt(optionName
);
114 wxSystemOptions::SetOption(optionName
,0);
117 wxSizer
*buttonSizer
= CreateButtonSizer( flags
& ButtonSizerFlags
);
118 if(buttonSizer
->GetChildren().GetCount() > 0 )
120 m_innerSizer
->Add( buttonSizer
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
|wxLEFT
|wxRIGHT
, 2);
121 m_innerSizer
->AddSpacer(2);
129 // restore system option
130 wxSystemOptions::SetOption(optionName
,status
);
134 // Creates the book control
135 wxBookCtrlBase
* wxPropertySheetDialog::CreateBookCtrl()
137 int style
= wxCLIP_CHILDREN
;
138 #if defined(__POCKETPC__) && wxUSE_NOTEBOOK
139 style
|= wxBK_BOTTOM
|wxNB_FLAT
;
141 style
|= wxBK_DEFAULT
;
144 wxBookCtrlBase
* bookCtrl
= NULL
;
147 if (GetSheetStyle() & wxPROPSHEET_NOTEBOOK
)
148 bookCtrl
= new wxNotebook(this, wxID_ANY
, wxDefaultPosition
, wxDefaultSize
, style
);
151 if (GetSheetStyle() & wxPROPSHEET_CHOICEBOOK
)
152 bookCtrl
= new wxChoicebook(this, wxID_ANY
, wxDefaultPosition
, wxDefaultSize
, style
);
155 if (GetSheetStyle() & wxPROPSHEET_TOOLBOOK
)
156 bookCtrl
= new wxToolbook(this, wxID_ANY
, wxDefaultPosition
, wxDefaultSize
, style
);
159 if (GetSheetStyle() & wxPROPSHEET_LISTBOOK
)
160 bookCtrl
= new wxListbook(this, wxID_ANY
, wxDefaultPosition
, wxDefaultSize
, style
);
163 bookCtrl
= new wxBookCtrl(this, wxID_ANY
, wxDefaultPosition
, wxDefaultSize
, style
);
165 if (GetSheetStyle() & wxPROPSHEET_SHRINKTOFIT
)
166 bookCtrl
->SetShrinkMode(true);
171 // Adds the book control to the inner sizer.
172 void wxPropertySheetDialog::AddBookCtrl(wxSizer
* sizer
)
174 #if defined(__POCKETPC__) && wxUSE_NOTEBOOK
175 // The book control has to be sized larger than the dialog because of a border bug
178 sizer
->Add( m_bookCtrl
, 1, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxLEFT
|wxTOP
|wxRIGHT
, borderSize
);
180 sizer
->Add( m_bookCtrl
, 1, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5 );
184 void wxPropertySheetDialog::OnActivate(wxActivateEvent
& event
)
186 #if defined(__SMARTPHONE__)
187 // Attempt to focus the choice control: not yet working, but might
188 // be a step in the right direction. OnActivate overrides the default
189 // handler in toplevel.cpp that sets the focus for the first child of
190 // of the dialog (the choicebook).
191 if (event
.GetActive())
193 wxChoicebook
* choiceBook
= wxDynamicCast(GetBookCtrl(), wxChoicebook
);
195 choiceBook
->SetFocus();
202 // Resize dialog if necessary
203 void wxPropertySheetDialog::OnIdle(wxIdleEvent
& event
)
207 if ((GetSheetStyle() & wxPROPSHEET_SHRINKTOFIT
) && GetBookCtrl())
209 int sel
= GetBookCtrl()->GetSelection();
210 if (sel
!= -1 && sel
!= m_selectedPage
)
212 GetBookCtrl()->InvalidateBestSize();
213 InvalidateBestSize();
214 SetSizeHints(-1, -1, -1, -1);
216 m_selectedPage
= sel
;
222 #endif // wxUSE_BOOKCTRL