]> git.saurik.com Git - wxWidgets.git/blame - src/generic/propdlg.cpp
Silence warning about truncation since the comment says it ok
[wxWidgets.git] / src / generic / propdlg.cpp
CommitLineData
3c9287bb 1/////////////////////////////////////////////////////////////////////////////
2ddb4d13 2// Name: src/generic/propdlg.cpp
3c9287bb
JS
3// Purpose: wxPropertySheetDialog
4// Author: Julian Smart
5// Modified by:
6// Created: 2005-03-12
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
3c9287bb
JS
12// For compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
14
15#ifdef __BORLANDC__
16#pragma hdrstop
17#endif
18
19#include "wx/defs.h"
20
532d575b
WS
21#if wxUSE_BOOKCTRL
22
3c9287bb
JS
23#ifndef WX_PRECOMP
24 #include "wx/button.h"
25 #include "wx/sizer.h"
26 #include "wx/intl.h"
27 #include "wx/log.h"
28 #include "wx/msgdlg.h"
29#endif
30
3be8026d 31#include "wx/bookctrl.h"
3c9287bb
JS
32#include "wx/generic/propdlg.h"
33
34//-----------------------------------------------------------------------------
35// wxPropertySheetDialog
36//-----------------------------------------------------------------------------
37
38IMPLEMENT_DYNAMIC_CLASS(wxPropertySheetDialog, wxDialog)
39
c9ab63f4
JS
40BEGIN_EVENT_TABLE(wxPropertySheetDialog, wxDialog)
41 EVT_ACTIVATE(wxPropertySheetDialog::OnActivate)
42END_EVENT_TABLE()
43
532d575b 44bool wxPropertySheetDialog::Create(wxWindow* parent, wxWindowID id, const wxString& title,
3c9287bb
JS
45 const wxPoint& pos, const wxSize& sz, long style,
46 const wxString& name)
47{
ac5f5c9e 48 if (!wxDialog::Create(parent, id, title, pos, sz, style|wxCLIP_CHILDREN, name))
3c9287bb 49 return false;
532d575b 50
3c9287bb
JS
51 wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL );
52 SetSizer(topSizer);
53
54 // This gives more space around the edges
55 m_innerSizer = new wxBoxSizer( wxVERTICAL );
56
95ba86d7 57 int extraSpace = 2;
0906c58d 58#if defined(__SMARTPHONE__) || defined(__POCKETPC__)
3c9287bb
JS
59 extraSpace=0;
60#endif
61 topSizer->Add(m_innerSizer, 1, wxGROW|wxALL, extraSpace);
62
63 m_bookCtrl = CreateBookCtrl();
64 AddBookCtrl(m_innerSizer);
65
66 return true;
67}
68
69void wxPropertySheetDialog::Init()
70{
71 m_innerSizer = NULL;
72 m_bookCtrl = NULL;
73}
74
75// Layout the dialog, to be called after pages have been created
76void wxPropertySheetDialog::LayoutDialog()
77{
0906c58d 78#if !defined(__SMARTPHONE__) && !defined(__POCKETPC__)
3c9287bb 79 GetSizer()->Fit(this);
95ba86d7 80 GetSizer()->SetSizeHints(this);
3c9287bb
JS
81 Centre(wxBOTH);
82#endif
c9ab63f4
JS
83#if defined(__SMARTPHONE__)
84 if (m_bookCtrl)
85 m_bookCtrl->SetFocus();
86#endif
3c9287bb
JS
87}
88
89// Creates the buttons, if any
90void wxPropertySheetDialog::CreateButtons(int flags)
91{
53bc3491 92#if defined(__SMARTPHONE__)
0906c58d
JS
93 // TODO: create a right-click menu with all the other IDs available.
94 // Perhaps that could be embedded in CreateButtonSizer() directly.
53bc3491 95 SetRightMenu(wxID_CANCEL);
3be8026d 96 SetLeftMenu(wxID_OK);
9e7efd53 97 wxUnusedVar(flags);
0906c58d
JS
98#elif defined(__POCKETPC__)
99 // Do nothing
9e7efd53 100 wxUnusedVar(flags);
0906c58d 101#else
3c9287bb 102 wxSizer* sizer = CreateButtonSizer(flags);
95ba86d7
JS
103 m_innerSizer->Add( sizer, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT|wxRIGHT, 2);
104 m_innerSizer->AddSpacer(2);
3c9287bb
JS
105#endif
106}
107
108// Creates the book control
109wxBookCtrlBase* wxPropertySheetDialog::CreateBookCtrl()
110{
ac5f5c9e 111 int style = wxCLIP_CHILDREN;
3be8026d 112#if defined(__POCKETPC__) && wxUSE_NOTEBOOK
2ddb4d13 113 style |= wxBK_BOTTOM|wxNB_FLAT;
3be8026d 114#else
2ddb4d13 115 style |= wxBK_DEFAULT;
3c9287bb 116#endif
3be8026d 117 return new wxBookCtrl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style );
3c9287bb
JS
118}
119
120// Adds the book control to the inner sizer.
121void wxPropertySheetDialog::AddBookCtrl(wxSizer* sizer)
122{
3be8026d 123#if defined(__POCKETPC__) && wxUSE_NOTEBOOK
3c9287bb
JS
124 // The book control has to be sized larger than the dialog because of a border bug
125 // in WinCE
0906c58d
JS
126 int borderSize = -2;
127 sizer->Add( m_bookCtrl, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP|wxRIGHT, borderSize );
3c9287bb
JS
128#else
129 sizer->Add( m_bookCtrl, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
130#endif
131}
132
c9ab63f4
JS
133void wxPropertySheetDialog::OnActivate(wxActivateEvent& event)
134{
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())
141 {
532d575b 142 wxChoicebook* choiceBook = wxDynamicCast(GetBookCtrl(), wxChoicebook);
c9ab63f4
JS
143 if (choiceBook)
144 choiceBook->SetFocus();
145 }
146 else
147#endif
148 event.Skip();
149}
150
532d575b 151#endif // wxUSE_BOOKCTRL