]>
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 #if defined(__WXMSW__) && !((defined(__GNUWIN32_OLD__) || defined(__TWIN32__)) && !defined(__CYGWIN10__))
40 #include "wx/msw/private.h"
42 #include "wx/msw/winundef.h"
45 // ============================================================================
47 // ============================================================================
49 // ----------------------------------------------------------------------------
50 // constructors and destructors
51 // ----------------------------------------------------------------------------
53 void wxNotebookBase::Init()
56 m_ownsImageList
= FALSE
;
59 wxNotebookBase::~wxNotebookBase()
61 if ( m_ownsImageList
)
68 // ----------------------------------------------------------------------------
70 // ----------------------------------------------------------------------------
72 void wxNotebookBase::SetImageList(wxImageList
* imageList
)
74 if ( m_ownsImageList
)
79 m_ownsImageList
= FALSE
;
82 m_imageList
= imageList
;
85 void wxNotebookBase::AssignImageList(wxImageList
* imageList
)
87 SetImageList(imageList
);
88 m_ownsImageList
= TRUE
;
91 // ----------------------------------------------------------------------------
93 // ----------------------------------------------------------------------------
95 wxSize
wxNotebookBase::CalcSizeFromPage(const wxSize
& sizePage
)
97 // this was just taken from wxNotebookSizer::CalcMin() and is, of
98 // course, totally bogus - just like the original code was
99 wxSize sizeTotal
= sizePage
;
101 // Slightly less bogus, at least under Windows.
102 // We need to make getting tab size part of the wxWindows API.
104 wxSize
tabSize(0, 0);
105 if (GetPageCount() > 0)
108 TabCtrl_GetItemRect((HWND
) GetHWND(), 0, & rect
);
109 tabSize
.x
= rect
.right
- rect
.left
;
110 tabSize
.y
= rect
.bottom
- rect
.top
;
112 if ( HasFlag(wxNB_LEFT
) || HasFlag(wxNB_RIGHT
) )
114 sizeTotal
.x
+= tabSize
.x
+ 7;
120 sizeTotal
.y
+= tabSize
.y
+ 7;
123 if ( HasFlag(wxNB_LEFT
) || HasFlag(wxNB_RIGHT
) )
138 // ----------------------------------------------------------------------------
140 // ----------------------------------------------------------------------------
142 bool wxNotebookBase::DeletePage(int nPage
)
144 wxNotebookPage
*page
= DoRemovePage(nPage
);
153 wxNotebookPage
*wxNotebookBase::DoRemovePage(int nPage
)
155 wxCHECK_MSG( nPage
>= 0 && (size_t)nPage
< m_pages
.GetCount(), NULL
,
156 _T("invalid page index in wxNotebookBase::DoRemovePage()") );
158 wxNotebookPage
*pageRemoved
= m_pages
[nPage
];
159 m_pages
.RemoveAt(nPage
);
164 int wxNotebookBase::GetNextPage(bool forward
) const
168 int nMax
= GetPageCount();
169 if ( nMax
-- ) // decrement it to get the last valid index
171 int nSel
= GetSelection();
173 // change selection wrapping if it becomes invalid
174 nPage
= forward
? nSel
== nMax
? 0
179 else // notebook is empty, no next page
187 #endif // wxUSE_NOTEBOOK