]>
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 #ifdef __GNUWIN32_OLD__
40 #include "wx/msw/gnuwin32/extra.h"
43 #if defined(__WIN95__) && !(defined(__GNUWIN32_OLD__) && !defined(__CYGWIN10__))
44 #include "wx/msw/private.h"
46 #include "wx/msw/winundef.h"
49 // ============================================================================
51 // ============================================================================
53 // ----------------------------------------------------------------------------
54 // constructors and destructors
55 // ----------------------------------------------------------------------------
57 void wxNotebookBase::Init()
60 m_ownsImageList
= FALSE
;
63 wxNotebookBase::~wxNotebookBase()
65 if ( m_ownsImageList
)
72 // ----------------------------------------------------------------------------
74 // ----------------------------------------------------------------------------
76 void wxNotebookBase::SetImageList(wxImageList
* imageList
)
78 if ( m_ownsImageList
)
83 m_ownsImageList
= FALSE
;
86 m_imageList
= imageList
;
89 void wxNotebookBase::AssignImageList(wxImageList
* imageList
)
91 SetImageList(imageList
);
92 m_ownsImageList
= TRUE
;
95 // ----------------------------------------------------------------------------
97 // ----------------------------------------------------------------------------
99 wxSize
wxNotebookBase::CalcSizeFromPage(const wxSize
& sizePage
) const
101 // this was just taken from wxNotebookSizer::CalcMin() and is, of
102 // course, totally bogus - just like the original code was
103 wxSize sizeTotal
= sizePage
;
105 // changed hajokirchhoff -- May, 31st, 2003
106 // moved the __WXMSW__ portion to wxNotebook::CalcSizeFromPage in src/msw/notebook.cpp
107 // where it really belongs.
108 // Question: Shouldn't we make wxNotebookBase::CalcSizeFromPage a pure virtual class.
109 // I'd like this better than this "totally bogus" code here.
110 if ( HasFlag(wxNB_LEFT
) || HasFlag(wxNB_RIGHT
) )
124 // ----------------------------------------------------------------------------
126 // ----------------------------------------------------------------------------
128 bool wxNotebookBase::DeletePage(int nPage
)
130 wxNotebookPage
*page
= DoRemovePage(nPage
);
139 wxNotebookPage
*wxNotebookBase::DoRemovePage(int nPage
)
141 wxCHECK_MSG( nPage
>= 0 && (size_t)nPage
< m_pages
.GetCount(), NULL
,
142 _T("invalid page index in wxNotebookBase::DoRemovePage()") );
144 wxNotebookPage
*pageRemoved
= m_pages
[nPage
];
145 m_pages
.RemoveAt(nPage
);
150 wxSize
wxNotebookBase::DoGetBestSize() const
152 wxSize
bestSize(0,0);
153 size_t nCount
= m_pages
.Count();
154 // iterate over all pages, get the largest width and height
155 for ( size_t nPage
= 0; nPage
< nCount
; nPage
++ ) {
156 wxNotebookPage
*pPage
= m_pages
[nPage
];
157 wxSize
childBestSize(pPage
->GetBestSize());
158 bestSize
.SetWidth(max(childBestSize
.GetWidth(), bestSize
.GetWidth()));
159 bestSize
.SetHeight(max(childBestSize
.GetHeight(), bestSize
.GetHeight()));
161 // convert display area to window area, adding the size neccessary for the tab control itself
162 return CalcSizeFromPage(bestSize
);
165 int wxNotebookBase::GetNextPage(bool forward
) const
169 int nMax
= GetPageCount();
170 if ( nMax
-- ) // decrement it to get the last valid index
172 int nSel
= GetSelection();
174 // change selection wrapping if it becomes invalid
175 nPage
= forward
? nSel
== nMax
? 0
180 else // notebook is empty, no next page
188 #endif // wxUSE_NOTEBOOK