]>
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
;
94 if ( HasFlag(wxNB_LEFT
) || HasFlag(wxNB_RIGHT
) )
102 // ----------------------------------------------------------------------------
104 // ----------------------------------------------------------------------------
106 bool wxNotebookBase::DeletePage(int nPage
)
108 wxNotebookPage
*page
= DoRemovePage(nPage
);
117 wxNotebookPage
*wxNotebookBase::DoRemovePage(int nPage
)
119 wxCHECK_MSG( nPage
>= 0 && (size_t)nPage
< m_pages
.GetCount(), NULL
,
120 _T("invalid page index in wxNotebookBase::DoRemovePage()") );
122 wxNotebookPage
*pageRemoved
= m_pages
[nPage
];
123 m_pages
.Remove(nPage
);
128 int wxNotebookBase::GetNextPage(bool forward
) const
132 int nMax
= GetPageCount();
133 if ( nMax
-- ) // decrement it to get the last valid index
135 int nSel
= GetSelection();
137 // change selection wrapping if it becomes invalid
138 nPage
= forward
? nSel
== nMax
? 0
143 else // notebook is empty, no next page
151 #endif // wxUSE_NOTEBOOK