]>
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"
34 //-----------------------------------------------------------------------------
35 // wxPropertySheetDialog
36 //-----------------------------------------------------------------------------
38 IMPLEMENT_DYNAMIC_CLASS(wxPropertySheetDialog
, wxDialog
)
40 BEGIN_EVENT_TABLE(wxPropertySheetDialog
, wxDialog
)
41 EVT_ACTIVATE(wxPropertySheetDialog::OnActivate
)
44 bool wxPropertySheetDialog::Create(wxWindow
* parent
, wxWindowID id
, const wxString
& title
,
45 const wxPoint
& pos
, const wxSize
& sz
, long style
,
48 if (!wxDialog::Create(parent
, id
, title
, pos
, sz
, style
|wxCLIP_CHILDREN
, name
))
51 wxBoxSizer
*topSizer
= new wxBoxSizer( wxVERTICAL
);
54 // This gives more space around the edges
55 m_innerSizer
= new wxBoxSizer( wxVERTICAL
);
58 #if defined(__SMARTPHONE__) || defined(__POCKETPC__)
61 topSizer
->Add(m_innerSizer
, 1, wxGROW
|wxALL
, extraSpace
);
63 m_bookCtrl
= CreateBookCtrl();
64 AddBookCtrl(m_innerSizer
);
69 void wxPropertySheetDialog::Init()
75 // Layout the dialog, to be called after pages have been created
76 void wxPropertySheetDialog::LayoutDialog()
78 #if !defined(__SMARTPHONE__) && !defined(__POCKETPC__)
79 GetSizer()->Fit(this);
80 GetSizer()->SetSizeHints(this);
83 #if defined(__SMARTPHONE__)
85 m_bookCtrl
->SetFocus();
89 // Creates the buttons, if any
90 void wxPropertySheetDialog::CreateButtons(int flags
)
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
);
98 #elif defined(__POCKETPC__)
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);
108 // Creates the book control
109 wxBookCtrlBase
* wxPropertySheetDialog::CreateBookCtrl()
111 int style
= wxCLIP_CHILDREN
;
112 #if defined(__POCKETPC__) && wxUSE_NOTEBOOK
113 style
|= wxBK_BOTTOM
|wxNB_FLAT
;
115 style
|= wxBK_DEFAULT
;
117 return new wxBookCtrl(this, wxID_ANY
, wxDefaultPosition
, wxDefaultSize
, style
);
120 // Adds the book control to the inner sizer.
121 void wxPropertySheetDialog::AddBookCtrl(wxSizer
* sizer
)
123 #if defined(__POCKETPC__) && wxUSE_NOTEBOOK
124 // The book control has to be sized larger than the dialog because of a border bug
127 sizer
->Add( m_bookCtrl
, 1, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxLEFT
|wxTOP
|wxRIGHT
, borderSize
);
129 sizer
->Add( m_bookCtrl
, 1, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5 );
133 void wxPropertySheetDialog::OnActivate(wxActivateEvent
& event
)
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())
142 wxChoicebook
* choiceBook
= wxDynamicCast(GetBookCtrl(), wxChoicebook
);
144 choiceBook
->SetFocus();
151 #endif // wxUSE_BOOKCTRL