1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxTabCtrl class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_TABCTRL_H_
13 #define _WX_TABCTRL_H_
15 class WXDLLIMPEXP_FWD_CORE wxImageList
;
18 * Flags returned by HitTest
21 #define wxTAB_HITTEST_NOWHERE 1
22 #define wxTAB_HITTEST_ONICON 2
23 #define wxTAB_HITTEST_ONLABEL 4
24 #define wxTAB_HITTEST_ONITEM 6
26 class WXDLLIMPEXP_CORE wxTabCtrl
: public wxControl
28 DECLARE_DYNAMIC_CLASS(wxTabCtrl
)
36 inline wxTabCtrl(wxWindow
*parent
, wxWindowID id
, const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
,
37 long style
= 0, const wxString
& name
= wxT("tabCtrl"))
39 Create(parent
, id
, pos
, size
, style
, name
);
46 int GetSelection() const;
48 // Get the tab with the current keyboard focus
49 int GetCurFocus() const;
51 // Get the associated image list
52 wxImageList
* GetImageList() const;
54 // Get the number of items
55 int GetItemCount() const;
57 // Get the rect corresponding to the tab
58 bool GetItemRect(int item
, wxRect
& rect
) const;
60 // Get the number of rows
61 int GetRowCount() const;
64 wxString
GetItemText(int item
) const ;
67 int GetItemImage(int item
) const;
70 void* GetItemData(int item
) const;
73 int SetSelection(int item
);
76 void SetImageList(wxImageList
* imageList
);
78 // Set the text for an item
79 bool SetItemText(int item
, const wxString
& text
);
81 // Set the image for an item
82 bool SetItemImage(int item
, int image
);
84 // Set the data for an item
85 bool SetItemData(int item
, void* data
);
87 // Set the size for a fixed-width tab control
88 void SetItemSize(const wxSize
& size
);
90 // Set the padding between tabs
91 void SetPadding(const wxSize
& padding
);
95 bool Create(wxWindow
*parent
, wxWindowID id
, const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
,
96 long style
= 0, const wxString
& name
= wxT("tabCtrl"));
99 bool DeleteAllItems();
102 bool DeleteItem(int item
);
105 int HitTest(const wxPoint
& pt
, long& flags
);
108 bool InsertItem(int item
, const wxString
& text
, int imageId
= -1, void* data
= NULL
);
112 virtual bool MSWOnNotify(int idCtrl
, WXLPARAM lParam
, WXLPARAM
*result
);
114 // Responds to colour changes
115 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
118 wxImageList
* m_imageList
;
120 DECLARE_EVENT_TABLE()
121 DECLARE_NO_COPY_CLASS(wxTabCtrl
)
124 class WXDLLIMPEXP_CORE wxTabEvent
: public wxNotifyEvent
127 wxTabEvent(wxEventType commandType
= wxEVT_NULL
, int id
= 0,
128 int nSel
= -1, int nOldSel
= -1)
129 : wxNotifyEvent(commandType
, id
)
136 // the currently selected page (-1 if none)
137 int GetSelection() const { return m_nSel
; }
138 void SetSelection(int nSel
) { m_nSel
= nSel
; }
139 // the page that was selected before the change (-1 if none)
140 int GetOldSelection() const { return m_nOldSel
; }
141 void SetOldSelection(int nOldSel
) { m_nOldSel
= nOldSel
; }
144 int m_nSel
, // currently selected page
145 m_nOldSel
; // previously selected page
147 DECLARE_DYNAMIC_CLASS_NO_COPY(wxTabEvent
)
150 typedef void (wxEvtHandler::*wxTabEventFunction
)(wxTabEvent
&);
152 #define EVT_TAB_SEL_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_COMMAND_TAB_SEL_CHANGED, \
153 id, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxTabEventFunction, & fn ), NULL),
154 #define EVT_TAB_SEL_CHANGING(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_COMMAND_TAB_SEL_CHANGING, \
155 id, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxTabEventFunction, & fn ), NULL),