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