]>
git.saurik.com Git - wxWidgets.git/blob - src/generic/propdlg.cpp
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"
32 #include "wx/generic/propdlg.h"
33 #include "wx/sysopt.h"
35 //-----------------------------------------------------------------------------
36 // wxPropertySheetDialog
37 //-----------------------------------------------------------------------------
39 IMPLEMENT_DYNAMIC_CLASS(wxPropertySheetDialog
, wxDialog
)
41 BEGIN_EVENT_TABLE(wxPropertySheetDialog
, wxDialog
)
42 EVT_ACTIVATE(wxPropertySheetDialog::OnActivate
)
45 bool wxPropertySheetDialog::Create(wxWindow
* parent
, wxWindowID id
, const wxString
& title
,
46 const wxPoint
& pos
, const wxSize
& sz
, long style
,
49 if (!wxDialog::Create(parent
, id
, title
, pos
, sz
, style
|wxCLIP_CHILDREN
, name
))
52 wxBoxSizer
*topSizer
= new wxBoxSizer( wxVERTICAL
);
55 // This gives more space around the edges
56 m_innerSizer
= new wxBoxSizer( wxVERTICAL
);
59 #if defined(__SMARTPHONE__) || defined(__POCKETPC__)
62 topSizer
->Add(m_innerSizer
, 1, wxGROW
|wxALL
, extraSpace
);
64 m_bookCtrl
= CreateBookCtrl();
65 AddBookCtrl(m_innerSizer
);
70 void wxPropertySheetDialog::Init()
76 // Layout the dialog, to be called after pages have been created
77 void wxPropertySheetDialog::LayoutDialog()
79 #if !defined(__SMARTPHONE__) && !defined(__POCKETPC__)
80 GetSizer()->Fit(this);
81 GetSizer()->SetSizeHints(this);
84 #if defined(__SMARTPHONE__)
86 m_bookCtrl
->SetFocus();
90 // Creates the buttons, if any
91 void wxPropertySheetDialog::CreateButtons(int flags
)
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);
100 wxSizer
*buttonSizer
= CreateButtonSizer( flags
& ButtonSizerFlags
);
101 if(buttonSizer
->GetChildren().GetCount() > 0 )
103 m_innerSizer
->Add( buttonSizer
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
|wxLEFT
|wxRIGHT
, 2);
104 m_innerSizer
->AddSpacer(2);
112 // restore system option
113 wxSystemOptions::SetOption(optionName
,status
);
117 // Creates the book control
118 wxBookCtrlBase
* wxPropertySheetDialog::CreateBookCtrl()
120 int style
= wxCLIP_CHILDREN
;
121 #if defined(__POCKETPC__) && wxUSE_NOTEBOOK
122 style
|= wxBK_BOTTOM
|wxNB_FLAT
;
124 style
|= wxBK_DEFAULT
;
126 return new wxBookCtrl(this, wxID_ANY
, wxDefaultPosition
, wxDefaultSize
, style
);
129 // Adds the book control to the inner sizer.
130 void wxPropertySheetDialog::AddBookCtrl(wxSizer
* sizer
)
132 #if defined(__POCKETPC__) && wxUSE_NOTEBOOK
133 // The book control has to be sized larger than the dialog because of a border bug
136 sizer
->Add( m_bookCtrl
, 1, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxLEFT
|wxTOP
|wxRIGHT
, borderSize
);
138 sizer
->Add( m_bookCtrl
, 1, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5 );
142 void wxPropertySheetDialog::OnActivate(wxActivateEvent
& event
)
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())
151 wxChoicebook
* choiceBook
= wxDynamicCast(GetBookCtrl(), wxChoicebook
);
153 choiceBook
->SetFocus();
160 #endif // wxUSE_BOOKCTRL