OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
notetab.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 TNoteTab
7// Added Scroll handling. Contributed by Jogy
8// Added Font setting. Contributed by Jogy
9// Added support for tab image. Contributed by Jogy
10//----------------------------------------------------------------------------
11
12#if !defined(OWL_NOTETAB_H)
13#define OWL_NOTETAB_H
14
15#include <owl/private/defs.h>
16#if defined(BI_HAS_PRAGMA_ONCE)
17# pragma once
18#endif
19
20// Macro defining class name (usable in resource definition)
21//
22#if !defined(OWL_NOTETAB)
23# if defined(UNICODE) // for Resource Workshop
24# define OWL_NOTETAB L"OWL_Notetab"
25# else
26# define OWL_NOTETAB "OWL_Notetab"
27# endif
28#endif
29
30#if !defined(RC_INVOKED)
31
32#include <owl/control.h>
33#include <owl/commctrl.h>
34#include <owl/celarray.h>
35#include <owl/gdiobjec.h>
36#include <vector>
37#include <memory>
38
39namespace owl {
40
41#include <owl/preclass.h>
42
43class _OWLCLASS TUpDown;
44
45/// \addtogroup ctrl
46/// @{
47/// \class TNoteTabItem
48// ~~~~~ ~~~~~~~~~~~~
49/// TNoteTabItem holds information about each tab in a notetab control. For example,
50/// the structure contains information about the title and size of each tab item.
51//
55
56 TRect Rect; ///< Location of tab [client-area base coords]
57 tstring Label; ///< Label of tab
58 TSize LabelSize; ///< Width and height of label
59 INT_PTR ClientData; ///< User-defined data associated with item
60 int ImageIdx; ///< Index of tab image
61 TAbsLocation ImageLoc; ///< Placement of tab image
62};
63
64//
65/// \class TNoteTab
66// ~~~~~ ~~~~~~~~
67/// TNoteTab encapsulates a tab control with each tab item along the bottom
68/// of the window.
69//
70class _OWLCLASS TNoteTab : public TControl {
71 public:
72 TNoteTab(TWindow* parent,
73 int id,
74 int x, int y, int w, int h,
75 TWindow* buddy = 0,
76 bool dialogBuddy = true,
77 TModule* module = 0);
78
79 TNoteTab(TWindow* parent,
80 int resourceId,
81 TWindow* buddy = 0,
82 bool dialogBuddy = true,
83 TModule* module = 0);
84
85 // Add/remove tab items
86 //
87 int Add(
90 int imageIdx = -1,
92 bool shouldSelect = true);
93
94 int Add(
95 const tstring& txt,
97 int imageIdx = -1,
98 TAbsLocation imageLoc = alLeft,
99 bool shouldSelect = true)
100 {
101 return Add(txt.c_str(), clientData, imageIdx, imageLoc, shouldSelect);
102 }
103
104 int Insert(
105 LPCTSTR txt,
106 int index,
108 int imageIdx = -1,
109 TAbsLocation imageLoc = alLeft,
110 bool shouldSelect = true);
111
113 const tstring& txt,
114 int index,
116 int imageIdx = -1,
117 TAbsLocation imageLoc = alLeft,
118 bool shouldSelect = true)
119 {
120 return Insert(txt.c_str(), index, clientData, imageIdx, imageLoc, shouldSelect);
121 }
122
123 bool Delete(int index);
124 bool DeleteAll();
125
126 // Set/Query attributes of TabControl
127 //
128 int GetCount() const;
129 int GetSel() const;
130 int SetSel(int index);
131 void SetWindowFace(bool);
132 bool GetWindowFace() const;
133 void SetStyle3d(bool);
134 bool GetStyle3d() const;
135 void EnableThemes(bool);
136 bool AreThemesEnabled() const {return ShouldUseThemes;}
137 int GetFirstVisibleTab() const;
138 void SetFirstVisibleTab(int index);
139 bool EnsureVisible(int index);
140
141 //
142 /// Returns the minimal control height for which tabs are not clipped.
143 //
144 int GetMinimalHeight();
145
146 //
147 /// Returns the amount of vertical space above the tabs.
148 //
149 TSize GetMargin() const {return Margin;}
150 void SetMargin(const TSize&);
151
152 //
153 /// Returns the amount of padding around the tab label.
154 //
155 TSize GetLabelMargin() const {return LabelMargin;}
156 void SetLabelMargin(const TSize&);
157
158 //
159 /// Returns the horizontal spacing between image and text in the label.
160 //
161 int GetLabelImageMargin() const {return LabelImageMargin;}
162 void SetLabelImageMargin(int);
163
164 //
165 /// Returns the margin around the focus rectangle for the selected tab.
166 //
167 TSize GetFocusMargin() const {return FocusMargin;}
168 void SetFocusMargin(const TSize&);
169
170 //
171 /// Returns the horizontal distance between two tabs.
172 //
173 int GetTabSpacing() const {return TabSpacing;}
174 void SetTabSpacing(int);
175
176 //
177 /// Returns the amount of narrowing on each side of the tab towards the bottom.
178 //
179 int GetTabTapering() const {return TabTapering;}
180 void SetTabTapering(int);
181
182 //
183 /// Returns the amount of extra height of the selected tab.
184 //
185 int GetSelectedTabProtrusion() const {return SelectedTabProtrusion;}
186 void SetSelectedTabProtrusion(int);
187
188 const TFont& GetTabFont() const;
189 void SetTabFont(const TFont&);
190
191 const TFont& GetSelectedTabFont() const;
192 void SetSelectedTabFont(const TFont&);
193
194 //
195 /// Returns the fill color used to paint the tabs.
196 //
197 TColor GetTabColor() const {return TabColor;}
198 void SetTabColor(const TColor&);
199
200 //
201 /// Returns the fill color used to paint the selected tab.
202 /// This color is only used when WindowFace mode is selected.
203 //
204 TColor GetSelectedTabColor() const {return SelectedTabColor;}
205 void SetSelectedTabColor(const TColor&);
206
207 //
208 /// Returns the pen color used to draw the edges of the tabs.
209 //
210 TColor GetEdgeColor() const {return EdgeColor;}
211 void SetEdgeColor(const TColor&);
212
213 // Set/Query attributes of Tab Items
214 //
215 bool GetItem(int index, TNoteTabItem& item) const;
216 TNoteTabItem GetItem(int index) const;
217 bool SetItem(int index, const TNoteTabItem& item);
218 bool IsVisible(int index) const;
219 bool IsFullyVisible(int index) const;
220 TAbsLocation GetScrollLocation() const;
221 void SetScrollLocation(TAbsLocation pos);
222 void SetCelArray(TCelArray* array, TAutoDelete = AutoDelete);
223 TCelArray* GetCelArray();
224 void SetCelArrayTransparentColor(const TColor&);
225 TColor GetCelArrayTransparentColor() const;
226
227 // Set/Query buddy window
228 //
229 HWND GetBuddy() const;
230 void SetBuddy(HWND buddy);
231
232 // Override TWindow virtual member function to handle transfers
233 //
234 auto Transfer(void* buffer, TTransferDirection) -> uint override;
235
236 protected:
237
238 // Override TWindow virtual member functions
239 //
240 auto GetWindowClassName() -> TWindowClassName override;
241 void SetupWindow() override;
242 void Paint(TDC&, bool erase, TRect&) override;
243
244 // Message Handlers
245 //
246 void EvSize(uint sizeType, const TSize& size);
247 void EvLButtonDown(uint modKeys, const TPoint& point);
248 uint EvGetDlgCode(const MSG* msg);
249 void EvKeyDown(uint key, uint repeatCount, uint flags);
250 void EvSetFocus(THandle hWndLostFocus);
251 void EvKillFocus(THandle hwndGetFocus);
252 void EvHScroll(uint scrollCode, uint thumbPos, HWND hWndCtl);
253 void EvPaint();
254 bool EvEraseBkgnd(HDC);
255
256 // Routines handling underlying implementation
257 //
258 void InitCtrl();
259 void SetTabRects(int firstTab);
260 void InvalidateTab(int index);
261 void SetTabSize(int index);
262 int TabFromPoint(const TPoint& pt) const;
263 TRect GetScrollingTabsArea() const;
264 TRect GetScrollerArea() const;
265 bool NotifyAndSelect(int index);
266 void Update();
267
269 bool WindowFace;
270 bool Style3d;
271 bool ShouldUseThemes;
272 TSize Margin;
273 TSize LabelMargin;
274 int LabelImageMargin;
275 TSize FocusMargin;
276 int TabSpacing;
277 int TabTapering;
278 int SelectedTabProtrusion;
279 std::unique_ptr<TFont> TabFont;
280 std::unique_ptr<TFont> SelectedTabFont;
281 TColor TabColor;
282 TColor SelectedTabColor;
283 TColor EdgeColor;
284
285 private:
286 // Hidden to prevent accidental copying or assignment
287 //
288 TNoteTab(const TNoteTab&);
290
291 TWindow* Buddy;
292 THandle BuddyHandle;
293 int FirstVisibleTab;
294 int SelectedTab;
295 typedef std::vector<TNoteTabItem> TNoteTabItemArray;
296 TNoteTabItemArray TabList;
297 TUpDown* ScrollButtons;
298 TAbsLocation ScrollLoc;
299 TCelArray* CelArray;
300 std::unique_ptr<TCelArray> OwnedCelArray;
301 TColor TransparentColor;
302 TRect LastClientRectPainted;
303 TRect EffectiveTabsArea;
304
305 TRect GetBoundingRect(const TRect& tabRect) const;
306 TRect CalculateTabRect(const TNoteTabItem& tab, const TPoint& p, bool isSelected) const;
307 typedef std::vector<TRect> TRects;
308 TRects CalculateTabRects(int firstTab, const TRect& area) const;
309 void AssignTabRect(TNoteTabItem&, const TRect& newRect);
310
311 template <class TPartRenderer>
312 void PaintTabs(TDC& dc, const TRect& rect);
313
315};
316
317//@}
318
319#include <owl/posclass.h>
320
321//----------------------------------------------------------------------------
322// Inline implementations
323
324//
325/// Constructor of Notetab Item object. Initializes object with specified
326/// string label and optional user-defined data.
327//
328inline
331:
332 Label(label),
333 ClientData(clientData),
334 ImageIdx(imageIdx),
335 ImageLoc(imageLoc)
336{
337}
338
339//
340/// Default constructor of Notetab Item object.
341//
342inline
344:
345 ClientData(0),
346 ImageIdx(-1),
347 ImageLoc(alLeft)
348{
349}
350
351//
352/// Specifies whether active tab should use the system's window color. If the 'wf'
353/// parameter is true, the system's window color is used.
354//
355inline void
357{
358 WindowFace = wf;
359 Update();
360}
361
362//
363/// Returns the flag specifying whether the active tab should use the system's
364/// window color.
365//
366inline bool
368{
369 return WindowFace;
370}
371
372//
373/// Specifies whether the note tab should draw a 3D edge. If 'st' is true, the
374/// control displays a 3D edge.
375//
376inline void
378{
379 Style3d = st;
380 Update();
381}
382
383//
384/// Returns the flag specifying whether the notetab control should draw a 3D border.
385//
386inline bool
388{
389 return Style3d;
390}
391
392//
393/// Specifies whether the note tab should use Windows visual styles (themes).
394//
395inline void
397{
398 ShouldUseThemes = st;
399 Update();
400}
401
402//
403/// Returns FirstVisibleTab.
404//
405inline int
407{
408 return FirstVisibleTab;
409}
410
411//
412/// Get the scroller location.
413//
414inline TAbsLocation
416{
417 return ScrollLoc;
418}
419//
420/// Get a pointer to the array of bitmaps used for the tabs.
421//
422inline TCelArray*
424{
425 return CelArray;
426}
427//
428/// Returns the color assigned to denote transparency in the bitmaps used for the
429/// tabs (see SetCelArray).
430//
431inline TColor
433{
434 return TransparentColor;
435}
436
437} // OWL namespace
438
439#endif // !RC_INVOKED
440
441#endif // OWL_NOTETAB_H
Definition of a bitmap Cel array class.
TCelArray is a horizontal array of cels (a unit of animation) created by slicing a portion of or an e...
Definition celarray.h:35
Class wrapper for management of color values.
Definition color.h:245
TControl unifies its derived control classes, such as TScrollBar, TControlGadget, and TButton.
Definition control.h:38
TDC is the root class for GDI DC wrappers.
Definition dc.h:64
TFont derived from TGdiObject provides constructors for creating font objects from explicit informati...
Definition gdiobjec.h:296
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:75
TNoteTab encapsulates a tab control with each tab item along the bottom of the window.
Definition notetab.h:70
TPoint is a support class, derived from tagPOINT.
Definition geometry.h:87
TRect is a mathematical class derived from tagRect.
Definition geometry.h:308
The tagSIZE struct is defined as.
Definition geometry.h:234
TUpDown encapsulates an up-down control, which is a window with a pair of arrow buttons that the user...
Definition updown.h:40
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
Definition of classes for CommonControl encapsulation.
Definition of class TControl.
#define DECLARE_RESPONSE_TABLE(cls)
Definition eventhan.h:436
Definition of abstract GDI object class and derived classes.
TAutoDelete
Flag for Handle ctors to control Handle deletion in dtor.
Definition gdibase.h:70
TRect Rect
Location of tab [client-area base coords].
Definition notetab.h:56
TSize LabelSize
Width and height of label.
Definition notetab.h:58
int GetLabelImageMargin() const
Returns the horizontal spacing between image and text in the label.
Definition notetab.h:161
TNoteTabItem()
Default constructor of Notetab Item object.
Definition notetab.h:343
INT_PTR ClientData
User-defined data associated with item.
Definition notetab.h:59
void SetWindowFace(bool)
Specifies whether active tab should use the system's window color.
Definition notetab.h:356
TSize GetLabelMargin() const
Returns the amount of padding around the tab label.
Definition notetab.h:155
TColor GetCelArrayTransparentColor() const
Returns the color assigned to denote transparency in the bitmaps used for the tabs (see SetCelArray).
Definition notetab.h:432
int Add(const tstring &txt, INT_PTR clientData=0, int imageIdx=-1, TAbsLocation imageLoc=alLeft, bool shouldSelect=true)
Definition notetab.h:94
int ImageIdx
Index of tab image.
Definition notetab.h:60
TColor GetEdgeColor() const
Returns the pen color used to draw the edges of the tabs.
Definition notetab.h:210
TSize GetFocusMargin() const
Returns the margin around the focus rectangle for the selected tab.
Definition notetab.h:167
TSize GetMargin() const
Returns the amount of vertical space above the tabs.
Definition notetab.h:149
TAbsLocation GetScrollLocation() const
Get the scroller location.
Definition notetab.h:415
bool GetStyle3d() const
Returns the flag specifying whether the notetab control should draw a 3D border.
Definition notetab.h:387
bool AreThemesEnabled() const
Definition notetab.h:136
int GetTabTapering() const
Returns the amount of narrowing on each side of the tab towards the bottom.
Definition notetab.h:179
void SetStyle3d(bool)
Specifies whether the note tab should draw a 3D edge.
Definition notetab.h:377
TColor GetTabColor() const
Returns the fill color used to paint the tabs.
Definition notetab.h:197
int GetSelectedTabProtrusion() const
Returns the amount of extra height of the selected tab.
Definition notetab.h:185
int GetTabSpacing() const
Returns the horizontal distance between two tabs.
Definition notetab.h:173
bool GetWindowFace() const
Returns the flag specifying whether the active tab should use the system's window color.
Definition notetab.h:367
TAbsLocation ImageLoc
Placement of tab image.
Definition notetab.h:61
TCelArray * GetCelArray()
Get a pointer to the array of bitmaps used for the tabs.
Definition notetab.h:423
int GetFirstVisibleTab() const
Returns FirstVisibleTab.
Definition notetab.h:406
void EnableThemes(bool)
Specifies whether the note tab should use Windows visual styles (themes).
Definition notetab.h:396
int Insert(const tstring &txt, int index, INT_PTR clientData=0, int imageIdx=-1, TAbsLocation imageLoc=alLeft, bool shouldSelect=true)
Definition notetab.h:112
tstring Label
Label of tab.
Definition notetab.h:57
TColor GetSelectedTabColor() const
Returns the fill color used to paint the selected tab.
Definition notetab.h:204
TAbsLocation
General use absolute 2-D rectangular location enum.
Definition geometry.h:62
@ alLeft
Refers to left edge of frame.
Definition geometry.h:66
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
std::string tstring
Definition defs.h:79
unsigned int uint
Definition number.h:25
#define protected_data
Definition defs.h:208
#define _OWLCLASS
Definition defs.h:338
TNoteTabItem holds information about each tab in a notetab control.
Definition notetab.h:52