]> git.saurik.com Git - wxWidgets.git/blob - include/wx/notebook.h
cancel dragging if Esc is pressed (patch 1733657)
[wxWidgets.git] / include / wx / notebook.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/notebook.h
3 // Purpose: wxNotebook interface
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 01.02.01
7 // RCS-ID: $Id$
8 // Copyright: (c) 1996-2000 Vadim Zeitlin
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_NOTEBOOK_H_BASE_
13 #define _WX_NOTEBOOK_H_BASE_
14
15 // ----------------------------------------------------------------------------
16 // headers
17 // ----------------------------------------------------------------------------
18
19 #include "wx/defs.h"
20
21 #if wxUSE_NOTEBOOK
22
23 #include "wx/bookctrl.h"
24
25 // ----------------------------------------------------------------------------
26 // constants
27 // ----------------------------------------------------------------------------
28
29 // wxNotebook hit results, use wxBK_HITTEST so other book controls can share them
30 // if wxUSE_NOTEBOOK is disabled
31 enum
32 {
33 wxNB_HITTEST_NOWHERE = wxBK_HITTEST_NOWHERE,
34 wxNB_HITTEST_ONICON = wxBK_HITTEST_ONICON,
35 wxNB_HITTEST_ONLABEL = wxBK_HITTEST_ONLABEL,
36 wxNB_HITTEST_ONITEM = wxBK_HITTEST_ONITEM,
37 wxNB_HITTEST_ONPAGE = wxBK_HITTEST_ONPAGE
38 };
39
40 // wxNotebook flags
41
42 // use common book wxBK_* flags for describing alignment
43 #define wxNB_DEFAULT wxBK_DEFAULT
44 #define wxNB_TOP wxBK_TOP
45 #define wxNB_BOTTOM wxBK_BOTTOM
46 #define wxNB_LEFT wxBK_LEFT
47 #define wxNB_RIGHT wxBK_RIGHT
48
49 #define wxNB_FIXEDWIDTH 0x0100
50 #define wxNB_MULTILINE 0x0200
51 #define wxNB_NOPAGETHEME 0x0400
52 #define wxNB_FLAT 0x0800
53
54
55 typedef wxWindow wxNotebookPage; // so far, any window can be a page
56
57 extern WXDLLEXPORT_DATA(const wxChar) wxNotebookNameStr[];
58
59 // ----------------------------------------------------------------------------
60 // wxNotebookBase: define wxNotebook interface
61 // ----------------------------------------------------------------------------
62
63 class WXDLLEXPORT wxNotebookBase : public wxBookCtrlBase
64 {
65 public:
66 // ctors
67 // -----
68
69 wxNotebookBase() { }
70
71 wxNotebookBase(wxWindow *parent,
72 wxWindowID winid,
73 const wxPoint& pos = wxDefaultPosition,
74 const wxSize& size = wxDefaultSize,
75 long style = 0,
76 const wxString& name = wxNotebookNameStr) ;
77
78 // wxNotebook-specific additions to wxBookCtrlBase interface
79 // ---------------------------------------------------------
80
81 // get the number of rows for a control with wxNB_MULTILINE style (not all
82 // versions support it - they will always return 1 then)
83 virtual int GetRowCount() const { return 1; }
84
85 // set the padding between tabs (in pixels)
86 virtual void SetPadding(const wxSize& padding) = 0;
87
88 // set the size of the tabs for wxNB_FIXEDWIDTH controls
89 virtual void SetTabSize(const wxSize& sz) = 0;
90
91
92
93 // implement some base class functions
94 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
95
96 // On platforms that support it, get the theme page background colour, else invalid colour
97 virtual wxColour GetThemeBackgroundColour() const { return wxNullColour; }
98
99
100 // send wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING/ED events
101
102 // returns false if the change to nPage is vetoed by the program
103 bool SendPageChangingEvent(int nPage);
104
105 // sends the event about page change from old to new (or GetSelection() if
106 // new is -1)
107 void SendPageChangedEvent(int nPageOld, int nPageNew = -1);
108
109 // wxBookCtrlBase overrides this method to return false but we do need
110 // focus because we have tabs
111 virtual bool AcceptsFocus() const { return wxControl::AcceptsFocus(); }
112
113 protected:
114 DECLARE_NO_COPY_CLASS(wxNotebookBase)
115 };
116
117 // ----------------------------------------------------------------------------
118 // notebook event class and related stuff
119 // ----------------------------------------------------------------------------
120
121 class WXDLLEXPORT wxNotebookEvent : public wxBookCtrlBaseEvent
122 {
123 public:
124 wxNotebookEvent(wxEventType commandType = wxEVT_NULL, int winid = 0,
125 int nSel = -1, int nOldSel = -1)
126 : wxBookCtrlBaseEvent(commandType, winid, nSel, nOldSel)
127 {
128 }
129
130 wxNotebookEvent(const wxNotebookEvent& event)
131 : wxBookCtrlBaseEvent(event)
132 {
133 }
134
135 virtual wxEvent *Clone() const { return new wxNotebookEvent(*this); }
136
137 private:
138 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxNotebookEvent)
139 };
140
141 BEGIN_DECLARE_EVENT_TYPES()
142 DECLARE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, 802)
143 DECLARE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, 803)
144 END_DECLARE_EVENT_TYPES()
145
146 typedef void (wxEvtHandler::*wxNotebookEventFunction)(wxNotebookEvent&);
147
148 #define wxNotebookEventHandler(func) \
149 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxNotebookEventFunction, &func)
150
151 #define EVT_NOTEBOOK_PAGE_CHANGED(winid, fn) \
152 wx__DECLARE_EVT1(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, winid, wxNotebookEventHandler(fn))
153
154 #define EVT_NOTEBOOK_PAGE_CHANGING(winid, fn) \
155 wx__DECLARE_EVT1(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, winid, wxNotebookEventHandler(fn))
156
157 // ----------------------------------------------------------------------------
158 // wxNotebook class itself
159 // ----------------------------------------------------------------------------
160
161 #if defined(__WXUNIVERSAL__)
162 #include "wx/univ/notebook.h"
163 #elif defined(__WXMSW__)
164 #include "wx/msw/notebook.h"
165 #elif defined(__WXMOTIF__)
166 #include "wx/generic/notebook.h"
167 #elif defined(__WXGTK20__)
168 #include "wx/gtk/notebook.h"
169 #elif defined(__WXGTK__)
170 #include "wx/gtk1/notebook.h"
171 #elif defined(__WXMAC__)
172 #include "wx/mac/notebook.h"
173 #elif defined(__WXCOCOA__)
174 #include "wx/cocoa/notebook.h"
175 #elif defined(__WXPM__)
176 #include "wx/os2/notebook.h"
177 #endif
178
179 #endif // wxUSE_NOTEBOOK
180
181 #endif
182 // _WX_NOTEBOOK_H_BASE_