]>
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"
26 #include "wx/button.h"
30 #include "wx/msgdlg.h"
33 #include "wx/bookctrl.h"
34 #include "wx/generic/propdlg.h"
36 //-----------------------------------------------------------------------------
37 // wxPropertySheetDialog
38 //-----------------------------------------------------------------------------
40 IMPLEMENT_DYNAMIC_CLASS(wxPropertySheetDialog
, wxDialog
)
42 BEGIN_EVENT_TABLE(wxPropertySheetDialog
, wxDialog
)
43 EVT_ACTIVATE(wxPropertySheetDialog::OnActivate
)
46 bool wxPropertySheetDialog::Create(wxWindow
* parent
, wxWindowID id
, const wxString
& title
,
47 const wxPoint
& pos
, const wxSize
& sz
, long style
,
50 if (!wxDialog::Create(parent
, id
, title
, pos
, sz
, style
|wxCLIP_CHILDREN
, name
))
53 wxBoxSizer
*topSizer
= new wxBoxSizer( wxVERTICAL
);
56 // This gives more space around the edges
57 m_innerSizer
= new wxBoxSizer( wxVERTICAL
);
60 #if defined(__SMARTPHONE__) || defined(__POCKETPC__)
63 topSizer
->Add(m_innerSizer
, 1, wxGROW
|wxALL
, extraSpace
);
65 m_bookCtrl
= CreateBookCtrl();
66 AddBookCtrl(m_innerSizer
);
71 void wxPropertySheetDialog::Init()
77 // Layout the dialog, to be called after pages have been created
78 void wxPropertySheetDialog::LayoutDialog()
80 #if !defined(__SMARTPHONE__) && !defined(__POCKETPC__)
81 GetSizer()->Fit(this);
82 GetSizer()->SetSizeHints(this);
85 #if defined(__SMARTPHONE__)
87 m_bookCtrl
->SetFocus();
91 // Creates the buttons, if any
92 void wxPropertySheetDialog::CreateButtons(int flags
)
94 #if defined(__SMARTPHONE__)
95 // TODO: create a right-click menu with all the other IDs available.
96 // Perhaps that could be embedded in CreateButtonSizer() directly.
97 SetRightMenu(wxID_CANCEL
);
100 #elif defined(__POCKETPC__)
104 wxSizer
* sizer
= CreateButtonSizer(flags
);
105 m_innerSizer
->Add( sizer
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxTOP
|wxBOTTOM
|wxLEFT
|wxRIGHT
, 2);
106 m_innerSizer
->AddSpacer(2);
110 // Creates the book control
111 wxBookCtrlBase
* wxPropertySheetDialog::CreateBookCtrl()
113 int style
= wxCLIP_CHILDREN
;
114 #if defined(__POCKETPC__) && wxUSE_NOTEBOOK
115 style
|= wxNB_BOTTOM
|wxNB_FLAT
;
117 style
|= wxBC_DEFAULT
;
119 return new wxBookCtrl(this, wxID_ANY
, wxDefaultPosition
, wxDefaultSize
, style
);
122 // Adds the book control to the inner sizer.
123 void wxPropertySheetDialog::AddBookCtrl(wxSizer
* sizer
)
125 #if defined(__POCKETPC__) && wxUSE_NOTEBOOK
126 // The book control has to be sized larger than the dialog because of a border bug
129 sizer
->Add( m_bookCtrl
, 1, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxLEFT
|wxTOP
|wxRIGHT
, borderSize
);
131 sizer
->Add( m_bookCtrl
, 1, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5 );
135 void wxPropertySheetDialog::OnActivate(wxActivateEvent
& event
)
137 #if defined(__SMARTPHONE__)
138 // Attempt to focus the choice control: not yet working, but might
139 // be a step in the right direction. OnActivate overrides the default
140 // handler in toplevel.cpp that sets the focus for the first child of
141 // of the dialog (the choicebook).
142 if (event
.GetActive())
144 wxChoicebook
* choiceBook
= wxDynamicCast(GetBookCtrl(), wxChoicebook
);
146 choiceBook
->SetFocus();