]>
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 // ----------------------------------------------------------------------------
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
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
;
64 wxNotebookBase::Create(wxWindow
*parent
,
71 return wxControl::Create
83 wxNotebookBase::~wxNotebookBase()
85 if ( m_ownsImageList
)
92 // ----------------------------------------------------------------------------
94 // ----------------------------------------------------------------------------
96 void wxNotebookBase::SetImageList(wxImageList
* imageList
)
98 if ( m_ownsImageList
)
103 m_ownsImageList
= FALSE
;
106 m_imageList
= imageList
;
109 void wxNotebookBase::AssignImageList(wxImageList
* imageList
)
111 SetImageList(imageList
);
112 m_ownsImageList
= TRUE
;
115 // ----------------------------------------------------------------------------
117 // ----------------------------------------------------------------------------
119 wxSize
wxNotebookBase::CalcSizeFromPage(const wxSize
& sizePage
) const
121 // this is, of course, totally bogus -- but we must do something by
122 // default because not all ports implement this
123 wxSize sizeTotal
= sizePage
;
125 if ( HasFlag(wxNB_LEFT
) || HasFlag(wxNB_RIGHT
) )
130 else // tabs on top/bottom side
139 wxSize
wxNotebookBase::DoGetBestSize() const
143 // iterate over all pages, get the largest width and height
144 const size_t nCount
= m_pages
.Count();
145 for ( size_t nPage
= 0; nPage
< nCount
; nPage
++ )
147 wxNotebookPage
*pPage
= m_pages
[nPage
];
148 wxSize
childBestSize(pPage
->GetBestSize());
150 if ( childBestSize
.x
> bestSize
.x
)
151 bestSize
.x
= childBestSize
.x
;
153 if ( childBestSize
.y
> bestSize
.y
)
154 bestSize
.y
= childBestSize
.y
;
157 // convert display area to window area, adding the size neccessary for the
159 return CalcSizeFromPage(bestSize
);
162 // ----------------------------------------------------------------------------
164 // ----------------------------------------------------------------------------
166 bool wxNotebookBase::DeletePage(int nPage
)
168 wxNotebookPage
*page
= DoRemovePage(nPage
);
177 wxNotebookPage
*wxNotebookBase::DoRemovePage(int nPage
)
179 wxCHECK_MSG( nPage
>= 0 && (size_t)nPage
< m_pages
.GetCount(), NULL
,
180 _T("invalid page index in wxNotebookBase::DoRemovePage()") );
182 wxNotebookPage
*pageRemoved
= m_pages
[nPage
];
183 m_pages
.RemoveAt(nPage
);
188 int wxNotebookBase::GetNextPage(bool forward
) const
192 int nMax
= GetPageCount();
193 if ( nMax
-- ) // decrement it to get the last valid index
195 int nSel
= GetSelection();
197 // change selection wrapping if it becomes invalid
198 nPage
= forward
? nSel
== nMax
? 0
203 else // notebook is empty, no next page
211 #endif // wxUSE_NOTEBOOK