]> git.saurik.com Git - wxWidgets.git/blame - src/common/nbkbase.cpp
skip apple options
[wxWidgets.git] / src / common / nbkbase.cpp
CommitLineData
07b8d7ec
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: src/common/nbkbase.cpp
3// Purpose: common wxNotebook methods
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 02.07.01
07b8d7ec 7// Copyright: (c) 2001 Vadim Zeitlin
65571936 8// Licence: wxWindows licence
07b8d7ec
VZ
9///////////////////////////////////////////////////////////////////////////////
10
11// ============================================================================
12// declarations
13// ============================================================================
14
15// ----------------------------------------------------------------------------
16// headers
17// ----------------------------------------------------------------------------
18
07b8d7ec
VZ
19// For compilers that support precompilation, includes "wx.h".
20#include "wx/wxprec.h"
21
22#ifdef __BORLANDC__
23 #pragma hdrstop
24#endif
25
26#if wxUSE_NOTEBOOK
27
28#ifndef WX_PRECOMP
07b8d7ec
VZ
29#endif //WX_PRECOMP
30
bd52bee1
JS
31#include "wx/notebook.h"
32
07b8d7ec
VZ
33// ============================================================================
34// implementation
35// ============================================================================
36
f313deaa
PC
37extern WXDLLEXPORT_DATA(const char) wxNotebookNameStr[] = "notebook";
38
ce7fe42e
VZ
39wxDEFINE_EVENT( wxEVT_NOTEBOOK_PAGE_CHANGED, wxBookCtrlEvent );
40wxDEFINE_EVENT( wxEVT_NOTEBOOK_PAGE_CHANGING, wxBookCtrlEvent );
1e4db450 41
28953245
SC
42// ----------------------------------------------------------------------------
43// XTI
44// ----------------------------------------------------------------------------
45
46#include "wx/listimpl.cpp"
28953245
SC
47wxDEFINE_FLAGS( wxNotebookStyle )
48wxBEGIN_FLAGS( wxNotebookStyle )
49// new style border flags, we put them first to
50// use them for streaming out
51wxFLAGS_MEMBER(wxBORDER_SIMPLE)
52wxFLAGS_MEMBER(wxBORDER_SUNKEN)
53wxFLAGS_MEMBER(wxBORDER_DOUBLE)
54wxFLAGS_MEMBER(wxBORDER_RAISED)
55wxFLAGS_MEMBER(wxBORDER_STATIC)
56wxFLAGS_MEMBER(wxBORDER_NONE)
57
58// old style border flags
59wxFLAGS_MEMBER(wxSIMPLE_BORDER)
60wxFLAGS_MEMBER(wxSUNKEN_BORDER)
61wxFLAGS_MEMBER(wxDOUBLE_BORDER)
62wxFLAGS_MEMBER(wxRAISED_BORDER)
63wxFLAGS_MEMBER(wxSTATIC_BORDER)
64wxFLAGS_MEMBER(wxBORDER)
65
66// standard window styles
67wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
68wxFLAGS_MEMBER(wxCLIP_CHILDREN)
69wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
70wxFLAGS_MEMBER(wxWANTS_CHARS)
71wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE)
72wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
73wxFLAGS_MEMBER(wxVSCROLL)
74wxFLAGS_MEMBER(wxHSCROLL)
75
76wxFLAGS_MEMBER(wxNB_FIXEDWIDTH)
77wxFLAGS_MEMBER(wxBK_DEFAULT)
78wxFLAGS_MEMBER(wxBK_TOP)
79wxFLAGS_MEMBER(wxBK_LEFT)
80wxFLAGS_MEMBER(wxBK_RIGHT)
81wxFLAGS_MEMBER(wxBK_BOTTOM)
82wxFLAGS_MEMBER(wxNB_NOPAGETHEME)
83wxFLAGS_MEMBER(wxNB_FLAT)
84wxEND_FLAGS( wxNotebookStyle )
85
a74fd546 86#if wxUSE_EXTENDED_RTTI
1f6420d8
SC
87
88WX_DEFINE_LIST( wxNotebookPageInfoList )
89
28953245
SC
90wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxNotebookPageInfo, wxObject, "wx/notebook.h" )
91
92wxCOLLECTION_TYPE_INFO( wxNotebookPageInfo *, wxNotebookPageInfoList );
93
28953245 94template<> void wxCollectionToVariantArray( wxNotebookPageInfoList const &theList,
e765d7ee 95 wxAnyList &value)
28953245 96{
e765d7ee 97 wxListCollectionToAnyList<wxNotebookPageInfoList::compatibility_iterator>( theList, value );
28953245 98}
28953245 99
28953245
SC
100wxBEGIN_PROPERTIES_TABLE(wxNotebookPageInfo)
101wxREADONLY_PROPERTY( Page, wxNotebookPage*, GetPage, wxEMPTY_PARAMETER_VALUE, \
102 0 /*flags*/, wxT("Helpstring"), wxT("group"))
103wxREADONLY_PROPERTY( Text, wxString, GetText, wxString(), 0 /*flags*/, \
104 wxT("Helpstring"), wxT("group"))
105wxREADONLY_PROPERTY( Selected, bool, GetSelected, false, 0 /*flags*/, \
106 wxT("Helpstring"), wxT("group") )
107wxREADONLY_PROPERTY( ImageId, int, GetImageId, -1, 0 /*flags*/, \
108 wxT("Helpstring"), wxT("group"))
109wxEND_PROPERTIES_TABLE()
110
111wxEMPTY_HANDLERS_TABLE(wxNotebookPageInfo)
112
113wxCONSTRUCTOR_4( wxNotebookPageInfo, wxNotebookPage*, Page, \
114 wxString, Text, bool, Selected, int, ImageId )
115
1f6420d8 116// WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl<wxNotebookPageInfo**>)
28953245
SC
117// XTI accessors:
118
119void wxNotebookBase::AddPageInfo( wxNotebookPageInfo* info )
120{
a74fd546 121 AddPage( info->GetPage(), info->GetText(), info->GetSelected(), info->GetImageId() );
28953245
SC
122}
123
124const wxNotebookPageInfoList& wxNotebookBase::GetPageInfos() const
125{
126 wxNotebookPageInfoList* list = const_cast< wxNotebookPageInfoList* >( &m_pageInfos );
127 WX_CLEAR_LIST( wxNotebookPageInfoList, *list );
128 for( size_t i = 0; i < GetPageCount(); ++i )
129 {
130 wxNotebookPageInfo *info = new wxNotebookPageInfo();
131 info->Create( const_cast<wxNotebookBase*>(this)->GetPage(i), GetPageText(i),
132 GetSelection() == int(i), GetPageImage(i) );
133 list->Append( info );
134 }
135 return m_pageInfos;
136}
137
138#endif
139
a74fd546 140wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxNotebook, wxBookCtrlBase, "wx/notebook.h")
1f6420d8 141wxBEGIN_PROPERTIES_TABLE(wxNotebook)
ce7fe42e
VZ
142wxEVENT_PROPERTY( PageChanging, wxEVT_NOTEBOOK_PAGE_CHANGING, wxNotebookEvent )
143wxEVENT_PROPERTY( PageChanged, wxEVT_NOTEBOOK_PAGE_CHANGED, wxNotebookEvent )
1f6420d8
SC
144
145wxPROPERTY_COLLECTION( PageInfos, wxNotebookPageInfoList, wxNotebookPageInfo*, \
146 AddPageInfo, GetPageInfos, 0 /*flags*/, wxT("Helpstring"), \
147 wxT("group"))
148wxPROPERTY_FLAGS( WindowStyle, wxNotebookStyle, long, SetWindowStyleFlag, \
149 GetWindowStyleFlag, wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, \
150 wxT("Helpstring"), wxT("group")) // style
151wxEND_PROPERTIES_TABLE()
152
153wxEMPTY_HANDLERS_TABLE(wxNotebook)
154
155wxCONSTRUCTOR_5( wxNotebook, wxWindow*, Parent, wxWindowID, Id, \
156 wxPoint, Position, wxSize, Size, long, WindowStyle)
157
07b8d7ec
VZ
158// ----------------------------------------------------------------------------
159// geometry
160// ----------------------------------------------------------------------------
161
2ce7af35 162wxSize wxNotebookBase::CalcSizeFromPage(const wxSize& sizePage) const
07b8d7ec 163{
550e6c01
VZ
164 // this is, of course, totally bogus -- but we must do something by
165 // default because not all ports implement this
07b8d7ec 166 wxSize sizeTotal = sizePage;
550e6c01 167
2ddb4d13 168 if ( HasFlag(wxBK_LEFT) || HasFlag(wxBK_RIGHT) )
eaf336e0 169 {
07b8d7ec 170 sizeTotal.x += 90;
eaf336e0 171 sizeTotal.y += 10;
eaf336e0 172 }
550e6c01 173 else // tabs on top/bottom side
eaf336e0 174 {
eaf336e0 175 sizeTotal.x += 10;
07b8d7ec 176 sizeTotal.y += 40;
eaf336e0 177 }
07b8d7ec
VZ
178
179 return sizeTotal;
180}
181
a570e8f8
VZ
182// ----------------------------------------------------------------------------
183// events
184// ----------------------------------------------------------------------------
185
186bool wxNotebookBase::SendPageChangingEvent(int nPage)
187{
ce7fe42e 188 wxBookCtrlEvent event(wxEVT_NOTEBOOK_PAGE_CHANGING, GetId());
a570e8f8
VZ
189 event.SetSelection(nPage);
190 event.SetOldSelection(GetSelection());
191 event.SetEventObject(this);
192 return !GetEventHandler()->ProcessEvent(event) || event.IsAllowed();
193}
194
195void wxNotebookBase::SendPageChangedEvent(int nPageOld, int nPageNew)
196{
ce7fe42e 197 wxBookCtrlEvent event(wxEVT_NOTEBOOK_PAGE_CHANGED, GetId());
a570e8f8
VZ
198 event.SetSelection(nPageNew == -1 ? GetSelection() : nPageNew);
199 event.SetOldSelection(nPageOld);
200 event.SetEventObject(this);
201 GetEventHandler()->ProcessEvent(event);
202}
203
07b8d7ec 204#endif // wxUSE_NOTEBOOK