]>
git.saurik.com Git - wxWidgets.git/blob - src/generic/propdlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxPropertySheetDialog
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "propdlg.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
28 #include "wx/button.h"
32 #include "wx/msgdlg.h"
35 #include "wx/bookctrl.h"
36 #include "wx/generic/propdlg.h"
38 //-----------------------------------------------------------------------------
39 // wxPropertySheetDialog
40 //-----------------------------------------------------------------------------
42 IMPLEMENT_DYNAMIC_CLASS(wxPropertySheetDialog
, wxDialog
)
44 BEGIN_EVENT_TABLE(wxPropertySheetDialog
, wxDialog
)
45 EVT_ACTIVATE(wxPropertySheetDialog::OnActivate
)
48 bool wxPropertySheetDialog::Create(wxWindow
* parent
, wxWindowID id
, const wxString
& title
,
49 const wxPoint
& pos
, const wxSize
& sz
, long style
,
52 if (!wxDialog::Create(parent
, id
, title
, pos
, sz
, style
|wxCLIP_CHILDREN
, name
))
55 wxBoxSizer
*topSizer
= new wxBoxSizer( wxVERTICAL
);
58 // This gives more space around the edges
59 m_innerSizer
= new wxBoxSizer( wxVERTICAL
);
62 #if defined(__SMARTPHONE__) || defined(__POCKETPC__)
65 topSizer
->Add(m_innerSizer
, 1, wxGROW
|wxALL
, extraSpace
);
67 m_bookCtrl
= CreateBookCtrl();
68 AddBookCtrl(m_innerSizer
);
73 void wxPropertySheetDialog::Init()
79 // Layout the dialog, to be called after pages have been created
80 void wxPropertySheetDialog::LayoutDialog()
82 #if !defined(__SMARTPHONE__) && !defined(__POCKETPC__)
83 GetSizer()->Fit(this);
84 GetSizer()->SetSizeHints(this);
87 #if defined(__SMARTPHONE__)
89 m_bookCtrl
->SetFocus();
93 // Creates the buttons, if any
94 void wxPropertySheetDialog::CreateButtons(int flags
)
96 #if defined(__SMARTPHONE__)
97 // TODO: create a right-click menu with all the other IDs available.
98 // Perhaps that could be embedded in CreateButtonSizer() directly.
99 SetRightMenu(wxID_CANCEL
);
100 SetLeftMenu(wxID_OK
);
102 #elif defined(__POCKETPC__)
106 wxSizer
* sizer
= CreateButtonSizer(flags
);
107 m_innerSizer
->Add( sizer
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
|wxLEFT
|wxRIGHT
, 2);
108 m_innerSizer
->AddSpacer(2);
112 // Creates the book control
113 wxBookCtrlBase
* wxPropertySheetDialog::CreateBookCtrl()
115 int style
= wxCLIP_CHILDREN
;
116 #if defined(__POCKETPC__) && wxUSE_NOTEBOOK
117 style
|= wxNB_BOTTOM
|wxNB_FLAT
;
119 style
|= wxBC_DEFAULT
;
121 return new wxBookCtrl(this, wxID_ANY
, wxDefaultPosition
, wxDefaultSize
, style
);
124 // Adds the book control to the inner sizer.
125 void wxPropertySheetDialog::AddBookCtrl(wxSizer
* sizer
)
127 #if defined(__POCKETPC__) && wxUSE_NOTEBOOK
128 // The book control has to be sized larger than the dialog because of a border bug
131 sizer
->Add( m_bookCtrl
, 1, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxLEFT
|wxTOP
|wxRIGHT
, borderSize
);
133 sizer
->Add( m_bookCtrl
, 1, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5 );
137 void wxPropertySheetDialog::OnActivate(wxActivateEvent
& event
)
139 #if defined(__SMARTPHONE__)
140 // Attempt to focus the choice control: not yet working, but might
141 // be a step in the right direction. OnActivate overrides the default
142 // handler in toplevel.cpp that sets the focus for the first child of
143 // of the dialog (the choicebook).
144 if (event
.GetActive())
146 wxChoicebook
* choiceBook
= wxDynamicCast(GetBookCtrl(), wxChoicebook
);
148 choiceBook
->SetFocus();
155 #endif // wxUSE_BOOKCTRL