]>
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 is, of course, totally bogus -- but we must do something by
102 // default because not all ports implement this
103 wxSize sizeTotal
= sizePage
;
105 if ( HasFlag(wxNB_LEFT
) || HasFlag(wxNB_RIGHT
) )
110 else // tabs on top/bottom side
119 wxSize
wxNotebookBase::DoGetBestSize() const
123 // iterate over all pages, get the largest width and height
124 const size_t nCount
= m_pages
.Count();
125 for ( size_t nPage
= 0; nPage
< nCount
; nPage
++ )
127 wxNotebookPage
*pPage
= m_pages
[nPage
];
128 wxSize
childBestSize(pPage
->GetBestSize());
130 if ( childBestSize
.x
> bestSize
.x
)
131 bestSize
.x
= childBestSize
.x
;
133 if ( childBestSize
.y
> bestSize
.y
)
134 bestSize
.y
= childBestSize
.y
;
137 // convert display area to window area, adding the size neccessary for the
139 return CalcSizeFromPage(bestSize
);
142 // ----------------------------------------------------------------------------
144 // ----------------------------------------------------------------------------
146 bool wxNotebookBase::DeletePage(int nPage
)
148 wxNotebookPage
*page
= DoRemovePage(nPage
);
157 wxNotebookPage
*wxNotebookBase::DoRemovePage(int nPage
)
159 wxCHECK_MSG( nPage
>= 0 && (size_t)nPage
< m_pages
.GetCount(), NULL
,
160 _T("invalid page index in wxNotebookBase::DoRemovePage()") );
162 wxNotebookPage
*pageRemoved
= m_pages
[nPage
];
163 m_pages
.RemoveAt(nPage
);
168 int wxNotebookBase::GetNextPage(bool forward
) const
172 int nMax
= GetPageCount();
173 if ( nMax
-- ) // decrement it to get the last valid index
175 int nSel
= GetSelection();
177 // change selection wrapping if it becomes invalid
178 nPage
= forward
? nSel
== nMax
? 0
183 else // notebook is empty, no next page
191 #endif // wxUSE_NOTEBOOK