OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
tabctrl.h
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1995, 1996 by Borland International, All Rights Reserved
4//
5/// \file
6/// Definition of class TTabItem and TTabControl.
7//----------------------------------------------------------------------------
8
9#if !defined(OWL_TABCTRL_H)
10#define OWL_TABCTRL_H
11
12#include <owl/private/defs.h>
13#if defined(BI_HAS_PRAGMA_ONCE)
14# pragma once
15#endif
16
17#include <owl/commctrl.h>
18#include <owl/contain.h>
19#include <owl/updown.h>
20
21
22namespace owl {
23
24// Mentioned in documentation but currently missing from system headers
25//
26#if !defined(TCIF_ALL)
27# define TCIF_ALL (TCIF_TEXT|TCIF_IMAGE|TCIF_PARAM)
28#endif
29
30// Forward ref.
31//
32class _OWLCLASS TFont;
33class _OWLCLASS TTabControl;
35
36#include <owl/preclass.h>
37
38//
39/// \class TTabItem
40// ~~~~~ ~~~~~~~~
41/// TTabItem encapsulates the attributes of a single tab within a
42/// tab control. For example, it holds a weak pointer to the string containing the
43/// tab's text.
44/// TODO: Store the tab label text, and provide string-aware overloads.
45//
46class _OWLCLASS TTabItem : public TCITEM {
47 public:
49 TTabItem(const TC_ITEM& tbItem);
50 TTabItem(const TTabControl& ctl, int index, uint mask,
51 int buffLen = 0, tchar * buffer = 0);
52
53 // Used for setting label
54 //
55 TTabItem(LPCTSTR str, int buffLen = 0, TParam2 param = 0);
56
57 // Used for setting image
58 //
60
61 // Used for setting both image and label
62 //
63 TTabItem(int imageIndex, LPCTSTR str);
64
65 void SetState(uint32 state, uint32 mask); // Version 4.70
66 void SetLabel(LPCTSTR str, int len = 0);
67 void SetIcon(int imageIndex);
68 void SetParam(TParam2 lp);
69};
70
71
72//
73/// \class TTabHitTestInfo
74// ~~~~~ ~~~~~~~~~~~~~~~
75/// TTabHitTestInfo is a thin [very thin] wrapper around
76/// the TC_HITTESTINFO structure. It's a place-holder for
77/// future ObjectWindows enhancements for tabcontrol hit
78/// testing..
79//
80class _OWLCLASS TTabHitTestInfo : public TC_HITTESTINFO {
81 public:
83};
84
85//
86/// \class TTabControl
87// ~~~~~ ~~~~~~~~~~~
88/// TTabControl encapsulates the tab control - a window that provides
89/// a user interface analogous to dividers in a notebook.
90//
92 public:
93 TTabControl(TWindow* parent,
94 int id,
95 int x, int y, int w, int h,
96 TModule* module = 0);
97
98 TTabControl(TWindow* parent, int resourceId, TModule* module = 0);
100 ~TTabControl() override;
101
102 /// \name Add/remove tab items
103 /// @{
104 int Add(const TTabItem&);
105 int Add(LPCTSTR tabText); ///< The string pointed to must outlive the control.
106 int Insert(const TTabItem&, int index);
107 int Insert(LPCTSTR tabText, int index); ///< The string pointed to must outlive the control.
108 bool Delete(int index);
109 bool DeleteAll();
110 /// @}
111
112 /// \name Set/Querry attributes of TabControl
113 /// @{
114 int GetCount() const;
115 int GetRowCount() const;
116 int GetSel() const;
117 int SetSel(int index);
118 /// @}
119
120 /// \name Set/Querry attributes of Tab Items
121 /// @{
122 bool GetItem(int index, TTabItem& item) const;
123 bool GetItemRect(int index, TRect& rect) const;
124 bool SetItem(int index, const TTabItem& item);
125 bool SetItemExtra(int extra);
126 TSize SetItemSize(const TSize& size);
127 void SetPadding(const TSize& size);
128 /// @}
129
130 /// \name Set/Querry attributes of control window
131 /// @{
132 void AdjustRect(bool clientInWindowOut, TRect& rect);
133 HIMAGELIST GetImageList() const;
134 HIMAGELIST SetImageList(HIMAGELIST);
135 void RemoveImage(int index);
136 /// @}
137
138 // Tooltip
139 //
140 HWND GetToolTips() const;
141 void SetToolTips(HWND toolTip);
142
143 int HitTest(TTabHitTestInfo&);
144
145 /// \name New messages
146 /// @{
147 void DeselectAll(bool exclFocus=true); // Version 4.70
148
149 uint32 GetExtendedStyle() const; // Version 4.71
150 uint32 SetExtendedStyle(uint32 mask, uint32 style);
151
152 bool HighLightItem(int item, bool highlight=true); //Version 4.71
153
154 void SetMinTabWidth(int width); // Version 4.71
155 /// @}
156
157 // Override TWindow virtual member function to handle transfers
158 //
159 auto Transfer(void* buffer, TTransferDirection) -> uint override;
160
161 protected:
162
163 // Override TWindow virtual member functions
164 //
165 auto GetWindowClassName() -> TWindowClassName override;
166
167 // Override TWindow handlers
168 //
169 void EvHScroll(uint scrollCode, uint thumbPos, THandle hWndCtl);
170 void EvVScroll(uint scrollCode, uint thumbPos, THandle hWndCtl);
171
172 private:
173 // Hidden to prevent accidental copying or assignment
174 //
175 TTabControl(const TTabControl&);
177
179};
180
181#include <owl/posclass.h>
182
183
184//----------------------------------------------------------------------------
185// Inlines implementations
186//
187
188//
189/// Constructor for a Tab Item:
190/// This constructor is useful when creating a TabItem (TC_ITEM) structure
191/// which will be filled with information about an existing tab in a
192/// tab control. For example,
193/// \code
194/// TTabItem item(TCIF_IMAGE|TCIF_PARAM);
195/// tabCtrl.GetItem(index, item);
196/// \endcode
198 mask = msk;
199}
200
201//
202/// Constructs a 'TTabItem' object from a 'TC_ITEM' structure using the
203/// assignment operator.
204/// \note Default assignment operator is fine even if we get a shallow copy
205/// for 'pszText' since the effective lifetime of a 'TTabItem' is
206/// rather short and the underlying control copies/caches the item's
207/// label
208//
210{
211 *(reinterpret_cast<TC_ITEM*>(this)) = tbItem;
212}
213
214//
215/// Sets the index of the image assiciated with the tab represented
216/// by this item structure.
217//
219{
221 mask |= TCIF_IMAGE;
222}
223
224//
225/// Sets the user-defined data associated with the tab represented
226/// by this item structure.
227//
229{
230 lParam = param;
231 mask |= TCIF_PARAM;
232}
233
234// Version 4.70
240
241// Version 4.71
243{
245 return static_cast<uint32>(SendMessage(TCM_GETEXTENDEDSTYLE));
246}
247
248// Version 4.71
250{
252 return static_cast<uint32>(SendMessage(TCM_SETEXTENDEDSTYLE, mask, style));
253}
254
255// Version 4.71
256inline bool TTabControl::HighLightItem(int item, bool highlight)
257{
259 return SendMessage(TCM_HIGHLIGHTITEM,item, MkUint32(static_cast<uint16>(static_cast<BOOL>(highlight)),0));
260}
261
262// Version 4.71
263inline void TTabControl::SetMinTabWidth(int width)
264{
267}
268
269} // OWL namespace
270
271
272#endif // OWL_TABCTRL_H
#define PRECONDITION(condition)
Definition checks.h:227
TControl unifies its derived control classes, such as TScrollBar, TControlGadget, and TButton.
Definition control.h:38
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:75
TRect is a mathematical class derived from tagRect.
Definition geometry.h:308
The tagSIZE struct is defined as.
Definition geometry.h:234
TTabControl encapsulates the tab control - a window that provides a user interface analogous to divid...
Definition tabctrl.h:91
uint32 SetExtendedStyle(uint32 mask, uint32 style)
Definition tabctrl.h:249
void DeselectAll(bool exclFocus=true)
Definition tabctrl.h:235
bool HighLightItem(int item, bool highlight=true)
Definition tabctrl.h:256
void SetMinTabWidth(int width)
Definition tabctrl.h:263
uint32 GetExtendedStyle() const
Definition tabctrl.h:242
TTabHitTestInfo is a thin [very thin] wrapper around the TC_HITTESTINFO structure.
Definition tabctrl.h:80
TTabItem encapsulates the attributes of a single tab within a tab control.
Definition tabctrl.h:46
TTabItem(uint mask)
Constructor for a Tab Item: This constructor is useful when creating a TabItem (TC_ITEM) structure wh...
Definition tabctrl.h:197
void SetParam(TParam2 lp)
Sets the user-defined data associated with the tab represented by this item structure.
Definition tabctrl.h:228
void SetIcon(int imageIndex)
Sets the index of the image assiciated with the tab represented by this item structure.
Definition tabctrl.h:218
Type-safe encapsulation of a Windows class name, a union between ATOM and LPCTSTR.
Definition module.h:47
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
Definition window.h:414
TResult SendMessage(TMsgId, TParam1=0, TParam2=0) const
Sends a message (msg) to a specified window or windows.
Definition window.cpp:3288
HWND THandle
TWindow encapsulates an HWND.
Definition window.h:418
HWND GetHandle() const
Returns the handle of the window.
Definition window.h:2020
Definition of classes for CommonControl encapsulation.
Definition of container classes used and made available by OWL.
#define DECLARE_RESPONSE_TABLE(cls)
Definition eventhan.h:436
TTransferDirection
The TTransferDirection enum describes the constants that the transfer function uses to determine how ...
Definition window.h:92
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
uint32 MkUint32(uint16 lo, uint16 hi)
Definition defs.h:261
unsigned long uint32
Definition number.h:34
char tchar
Definition defs.h:77
LPARAM TParam2
Second parameter type.
Definition dispatch.h:55
WPARAM TParam1
First parameter type.
Definition dispatch.h:54
unsigned int uint
Definition number.h:25
#define _OWLCLASS
Definition defs.h:338
Definition of class TUpDown.