]>
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 if ( HasFlag(wxNB_LEFT
) || HasFlag(wxNB_RIGHT
) )
109 // ----------------------------------------------------------------------------
111 // ----------------------------------------------------------------------------
113 bool wxNotebookBase::DeletePage(int nPage
)
115 wxNotebookPage
*page
= DoRemovePage(nPage
);
124 wxNotebookPage
*wxNotebookBase::DoRemovePage(int nPage
)
126 wxCHECK_MSG( nPage
>= 0 && (size_t)nPage
< m_pages
.GetCount(), NULL
,
127 _T("invalid page index in wxNotebookBase::DoRemovePage()") );
129 wxNotebookPage
*pageRemoved
= m_pages
[nPage
];
130 m_pages
.RemoveAt(nPage
);
135 int wxNotebookBase::GetNextPage(bool forward
) const
139 int nMax
= GetPageCount();
140 if ( nMax
-- ) // decrement it to get the last valid index
142 int nSel
= GetSelection();
144 // change selection wrapping if it becomes invalid
145 nPage
= forward
? nSel
== nMax
? 0
150 else // notebook is empty, no next page
158 #endif // wxUSE_NOTEBOOK