]> git.saurik.com Git - wxWidgets.git/blob - src/common/nbkbase.cpp
ensure that the copies of the bitmap passed to wxMemoryDC ctor are not modified when...
[wxWidgets.git] / src / common / nbkbase.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/nbkbase.cpp
3 // Purpose: common wxNotebook methods
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 02.07.01
7 // RCS-ID: $Id$
8 // Copyright: (c) 2001 Vadim Zeitlin
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
22
23 #ifdef __BORLANDC__
24 #pragma hdrstop
25 #endif
26
27 #if wxUSE_NOTEBOOK
28
29 #ifndef WX_PRECOMP
30 #endif //WX_PRECOMP
31
32 #include "wx/notebook.h"
33
34 // ============================================================================
35 // implementation
36 // ============================================================================
37
38 DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED)
39 DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING)
40
41 // ----------------------------------------------------------------------------
42 // geometry
43 // ----------------------------------------------------------------------------
44
45 wxSize wxNotebookBase::CalcSizeFromPage(const wxSize& sizePage) const
46 {
47 // this is, of course, totally bogus -- but we must do something by
48 // default because not all ports implement this
49 wxSize sizeTotal = sizePage;
50
51 if ( HasFlag(wxBK_LEFT) || HasFlag(wxBK_RIGHT) )
52 {
53 sizeTotal.x += 90;
54 sizeTotal.y += 10;
55 }
56 else // tabs on top/bottom side
57 {
58 sizeTotal.x += 10;
59 sizeTotal.y += 40;
60 }
61
62 return sizeTotal;
63 }
64
65 // ----------------------------------------------------------------------------
66 // events
67 // ----------------------------------------------------------------------------
68
69 bool wxNotebookBase::SendPageChangingEvent(int nPage)
70 {
71 wxBookCtrlEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, GetId());
72 event.SetSelection(nPage);
73 event.SetOldSelection(GetSelection());
74 event.SetEventObject(this);
75 return !GetEventHandler()->ProcessEvent(event) || event.IsAllowed();
76 }
77
78 void wxNotebookBase::SendPageChangedEvent(int nPageOld, int nPageNew)
79 {
80 wxBookCtrlEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, GetId());
81 event.SetSelection(nPageNew == -1 ? GetSelection() : nPageNew);
82 event.SetOldSelection(nPageOld);
83 event.SetEventObject(this);
84 GetEventHandler()->ProcessEvent(event);
85 }
86
87 #endif // wxUSE_NOTEBOOK