]>
git.saurik.com Git - wxWidgets.git/blob - src/common/nbkbase.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/nbkbase.cpp
3 // Purpose: common wxNotebook methods
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2001 Vadim Zeitlin
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #pragma implementation "notebookbase.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
36 #include "wx/imaglist.h"
37 #include "wx/notebook.h"
39 // ============================================================================
41 // ============================================================================
43 // ----------------------------------------------------------------------------
44 // constructors and destructors
45 // ----------------------------------------------------------------------------
47 void wxNotebookBase::Init()
50 m_ownsImageList
= FALSE
;
53 wxNotebookBase::~wxNotebookBase()
55 if ( m_ownsImageList
)
62 // ----------------------------------------------------------------------------
64 // ----------------------------------------------------------------------------
66 void wxNotebookBase::SetImageList(wxImageList
* imageList
)
68 if ( m_ownsImageList
)
73 m_ownsImageList
= FALSE
;
76 m_imageList
= imageList
;
79 void wxNotebookBase::AssignImageList(wxImageList
* imageList
)
81 SetImageList(imageList
);
82 m_ownsImageList
= TRUE
;
85 // ----------------------------------------------------------------------------
87 // ----------------------------------------------------------------------------
89 wxSize
wxNotebookBase::CalcSizeFromPage(const wxSize
& sizePage
)
91 // this was just taken from wxNotebookSizer::CalcMin() and is, of
92 // course, totally bogus - just like the original code was
93 wxSize sizeTotal
= sizePage
;
95 // Mac has large notebook borders.
97 if ( HasFlag(wxNB_LEFT
) || HasFlag(wxNB_RIGHT
) )
109 sizeTotal
.x
+= 34; // This is OK for Aqua.
120 // ----------------------------------------------------------------------------
122 // ----------------------------------------------------------------------------
124 bool wxNotebookBase::DeletePage(int nPage
)
126 wxNotebookPage
*page
= DoRemovePage(nPage
);
135 wxNotebookPage
*wxNotebookBase::DoRemovePage(int nPage
)
137 wxCHECK_MSG( nPage
>= 0 && (size_t)nPage
< m_pages
.GetCount(), NULL
,
138 _T("invalid page index in wxNotebookBase::DoRemovePage()") );
140 wxNotebookPage
*pageRemoved
= m_pages
[nPage
];
141 m_pages
.RemoveAt(nPage
);
146 int wxNotebookBase::GetNextPage(bool forward
) const
150 int nMax
= GetPageCount();
151 if ( nMax
-- ) // decrement it to get the last valid index
153 int nSel
= GetSelection();
155 // change selection wrapping if it becomes invalid
156 nPage
= forward
? nSel
== nMax
? 0
161 else // notebook is empty, no next page
169 #endif // wxUSE_NOTEBOOK