]>
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
)
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 // Slightly less bogus, at least under Windows.
106 // We need to make getting tab size part of the wxWindows API.
108 wxSize
tabSize(0, 0);
109 if (GetPageCount() > 0)
112 TabCtrl_GetItemRect((HWND
) GetHWND(), 0, & rect
);
113 tabSize
.x
= rect
.right
- rect
.left
;
114 tabSize
.y
= rect
.bottom
- rect
.top
;
116 if ( HasFlag(wxNB_LEFT
) || HasFlag(wxNB_RIGHT
) )
118 sizeTotal
.x
+= tabSize
.x
+ 7;
124 sizeTotal
.y
+= tabSize
.y
+ 7;
127 if ( HasFlag(wxNB_LEFT
) || HasFlag(wxNB_RIGHT
) )
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