OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
coolbar.h
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1998 by Yura Bidus, All Rights Reserved
4//
5/// \file
6/// Definition of class TCoolBar.
7//----------------------------------------------------------------------------
8
9#if !defined(OWL_COOLBAR_H)
10#define OWL_COOLBAR_H
11
12#include <owl/private/defs.h>
13#if defined(BI_HAS_PRAGMA_ONCE)
14# pragma once
15#endif
16
17#include <owl/control.h>
18#include <owl/commctrl.h>
19#include <owl/property.h>
20#include <owl/shellitm.h>
21#include <owl/template.h>
22
23namespace owl {
24
25
26class _OWLCLASS TImageList;
27class _OWLCLASS TCoolBar;
28
29#include <owl/preclass.h>
30
31/// \addtogroup newctrl
32/// @{
33/// \class TCoolBand
34// ~~~~~ ~~~~~~~~~
35//
37 friend class TCoolBar;
38 public:
39 TCoolBand();
40 TCoolBand(uint id, const tstring& str = tstring(), TWindow* child=0, uint style=0);
41 ~TCoolBand();
42
43 TObjProperty<tstring> Text; ///< Band text label
44 TObjProperty<TBitmap> Bitmap; ///< The band's background bitmap
45 TObjProperty<TColor> FgColor; ///< Band colors -
47 TProperty<TWindow*> Child; ///< Handle of the band's child window
48 TProperty<uint> Style; ///< Band style flags
49 TProperty<uint> Width; ///< Width of the band: don't use -1
50 TObjProperty<TSize> MinSize; ///< Minimum size of the band's child window don't use TSize(-1,-1)
51 TProperty<int> Id; ///< The band's ID number: don't use -1
52 TProperty<int> ImageIndex; ///< Band image index (into rebar image list): don't use -1
53 TProperty<uint> Mask; ///< Mask indicating which other members are valid
54
55 bool operator < (const TCoolBand& band) { return this < &band; }
56 bool operator ==(const TCoolBand& band) { return this == &band;}
57
58 // for this operations must be valid CollBar Handle
59 void BeginDrag(const TPoint& point);
60 void DragMove(const TPoint& point);
61 void EndDrag();
62 void Maximize(bool ideal);
63 void Minimize();
64 //bool Move(); //?????????????????????????
65 bool ShowBand(bool show);
66
67 void GetBorders(TRect& rect);
68 void GetRect(TRect& rect);
69
70 protected:
71 // Initialise all data members to zero
72 void Init();
73 void SetupData(TCoolBar* parent, REBARBANDINFO& info);
74
76};
77
79typedef TCoolBandArray::Iterator TCoolBandArrayIter;
80
81/// \class TCoolBar
82/// This simple implementation does no more than encapsulte the messages which
83/// can be sent to the rebar control. Possible extensions could manipulate bands
84/// directly (by constructing a TCoolBand internally).
85class _OWLCLASS TCoolBar : public TControl {
86 friend class _OWLCLASS TCoolBand; //JJH class keyword can be before or after _OWLCLASS?
87 public:
88 // Constructors and destructors
89 TCoolBar(TWindow* parent, int id, int x, int y, int w, int h, TModule* module = 0);
90 TCoolBar(TWindow* parent, int resourceId, TModule* module = 0);
91 ~TCoolBar();
92
93 // Properties
98 TFuncPropertyVarPut<TWindow*> Buddy; ///< "Parent" for notification messages
100 TFuncProperty<bool> Unicode; // needs valid HWND
102
103 // insert/delete
104 bool Insert(TCoolBand* band, uint index = -1);
105 bool Delete(uint index = 0);
106
107 // info
108 //bool GetInfo(TCoolBand& band, uint index); //????????????????????
109 //bool SetInfo(TCoolBand& band, uint index); //????????????????????
110 bool GetInfo(TRebarInfo& info);
111 bool SetInfo(TRebarInfo& info);
112
113 void SetImageList(TImageList* list, TAutoDelete = AutoDelete);
114 TImageList* GetImageList();
115
116 // Row information
117 uint GetRowCount();
118 uint GetRowHeight(int index);
119
120 // Style modifiers
121 bool ToggleBandBorders();
122 bool ToggleVarHeight();
123 bool ToggleBorder();
124
125 // Have to be valid HWND
126 uint GetBandCount();
127 uint GetHeight();
128 TDropTarget GetDropTarget();
129 HWND GetToolTips();
130 uint HitTest(TRbHitTestInfo& tst);
131 int FindBand(uint id); // return index
132 bool SetRect(const TRect& rec);
133
134 protected:
135 virtual auto GetWindowClassName() -> owl::TWindowClassName;
136 void SetupWindow();
137 void Init();
138
139 void SetPalette(TPalette* palette);
140 void SetBuddy(TWindow* buddy);
141 void SetTooltip(TTooltip* tip);
142
143 void SetBgColor(const TColor& clr);
144 TColor& GetBgColor();
145 void SetTextColor(const TColor& clr);
146 TColor& GetTextColor();
147 void SetColorScheme(const TColorScheme& clr);
148 TColorScheme& GetColorScheme();
149 void SetUnicode(bool unicode);
150 bool GetUnicode();
151 TCoolBandArray& GetBands();
152
153 // Rebar imagelist
164};
165/// @}
166
167#include <owl/posclass.h>
168
169//----------------------------------------------------------------------------
170// Inline implementations
171
172//
173//
174//
175inline void
177{
179 const auto index = Parent->FBands->Find(this);
180 if (index != Parent->FBands->NPOS)
181 Parent->SendMessage(RB_BEGINDRAG, static_cast<TParam1>(static_cast<uint>(index)), MkUint32(static_cast<uint16>(point.x),static_cast<uint16>(point.y)));
182}
183
184//
185//
186//
187inline void
189{
191 Parent->SendMessage(RB_DRAGMOVE, 0, MkUint32(static_cast<uint16>(point.x),static_cast<uint16>(point.y)));
192}
193
194//
195//
196//
197inline void
203
204// RB_GETBANDBORDERS
205// wParam = (WPARAM)(UINT) uBand;
206// lParam = (LPARAM)(LPRECT) lprc;
207inline void
209{
211 const auto index = Parent->FBands->Find(this);
212 if (index != Parent->FBands->NPOS)
213 Parent->SendMessage(RB_GETBANDBORDERS, static_cast<TParam1>(index), reinterpret_cast<TParam2>(static_cast<LPRECT>(&rect)));
214}
215
216//RB_GETRECT
217// wParam = (WPARAM)(INT) iBand;
218// lParam = (LPARAM)(LPRECT) lprc;
219inline void
221{
223 const auto index = Parent->FBands->Find(this);
224 if (index != Parent->FBands->NPOS)
225 Parent->SendMessage(RB_GETRECT, static_cast<TParam1>(index), reinterpret_cast<TParam2>(static_cast<LPRECT>(&rect)));
226}
227//
228//
229//
230inline void
232{
234 const auto index = Parent->FBands->Find(this);
235 if (index != Parent->FBands->NPOS)
236 Parent->SendMessage(RB_MAXIMIZEBAND, static_cast<TParam1>(index), static_cast<TParam2>(ideal));
237}
238//
239//
240//
241inline void
243{
245 const auto index = Parent->FBands->Find(this);
246 if (index != Parent->FBands->NPOS)
247 Parent->SendMessage(RB_MINIMIZEBAND,static_cast<TParam1>(index));
248}
249//
250//
251//
252inline bool
254{
256 const auto index = Parent->FBands->Find(this);
257 if (index != Parent->FBands->NPOS)
258 return Parent->SendMessage(RB_SHOWBAND,TParam1(index),TParam2(show)) != 0;
259 return false;
260}
261
262
263////////////////////////////////////////////////////////////////////////////////
264//
265// TCoolBar
266// ~~~~~~~~
267//
268inline void
270{
271 FBgColor = clr;
272 if (GetHandle())
273 SendMessage(RB_SETBKCOLOR, 0, TParam2(static_cast<COLORREF>(clr)));
274}
275//
276inline TColor&
278{
279 if (GetHandle())
280 FBgColor = static_cast<COLORREF>(SendMessage(RB_GETBKCOLOR,0,0));
281 return FBgColor;
282}
283//
284inline void
286{
287 FTextColor = clr;
288 if (GetHandle())
289 SendMessage(RB_SETTEXTCOLOR, 0, TParam2(static_cast<COLORREF>(clr)));
290}
291//
292inline TColor&
294{
295 if (GetHandle())
296 FTextColor = static_cast<COLORREF>(SendMessage(RB_GETTEXTCOLOR,0,0));
297 return FTextColor;
298}
299//#define RB_GETROWCOUNT (WM_USER + 13)
300//Message RB_GETROWCOUNT
301//Description Retrieves the number of rows in the rebar.
302//wParam 0 (not used)
303//lParam 0 (not used)
304//Returns UINT -the number of rows
305inline uint
307{
309 return static_cast<uint>(SendMessage(RB_GETROWCOUNT));
310}
311
312//#define RB_GETROWHEIGHT (WM_USER + 14)
313//Message RB_GETROWHEIGHT
314//Description Returns the height of the specified row in the rebar.
315//wParam UINT - the zero-based row to check
316//lParam 0 (not used)
317//Returns UINT - the height, in pixels, of the row
318inline uint
320{
321 return static_cast<uint>(SendMessage(RB_GETROWHEIGHT, index,0));
322}
323
324//
325//
326//
327inline uint
329{
331 return static_cast<uint>(SendMessage(RB_GETBARHEIGHT));
332}
333
334//RB_GETDROPTARGET
335// wParam = 0;
336// lParam = (IDropTarget**)ppDropTarget;
337//Retrieves a rebar control's IDropTarget interface pointer.
338inline TDropTarget
340{
342 SendMessage(RB_GETDROPTARGET,0,reinterpret_cast<TParam2>(&iface));
343 return TDropTarget(iface);
344}
345
346//RB_GETDROPTARGET
347// wParam = 0;
348// lParam = (IDropTarget**)ppDropTarget;
349//Retrieves a rebar control's IDropTarget interface pointer.
350inline HWND
352{
353 return reinterpret_cast<HWND>(SendMessage(RB_GETTOOLTIPS,0,0));
354}
355
356inline TImageList*
358{
359 return FBandImages;
360}
361
362//
363//
364//
365inline void
371
372//
373//
374//
375inline bool
381//
382//
383//
384inline uint
390//
391//
392//
393inline int
395{
397 return static_cast<int>(SendMessage(RB_IDTOINDEX,id));
398}
399//
400//
401//
402inline bool
404{
406 return SendMessage(RB_SIZETORECT,0,TParam2(&rec)) != 0;
407}
408//
409//
410//
411inline TCoolBandArray&
413{
415 return *FBands;
416}
417
418} // OWL namespace
419
420
421#endif // OWL_IECTRL_H
#define PRECONDITION(condition)
Definition checks.h:227
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
void GetBorders(TRect &rect)
Definition coolbar.h:208
void Maximize(bool ideal)
Definition coolbar.h:231
TProperty< uint > Width
Width of the band: don't use -1.
Definition coolbar.h:49
void GetRect(TRect &rect)
Definition coolbar.h:220
TObjProperty< TBitmap > Bitmap
The band's background bitmap.
Definition coolbar.h:44
bool ShowBand(bool show)
Definition coolbar.h:253
TObjProperty< TColor > FgColor
Band colors -.
Definition coolbar.h:45
TProperty< TWindow * > Child
Handle of the band's child window.
Definition coolbar.h:47
void DragMove(const TPoint &point)
Definition coolbar.h:188
TProperty< int > Id
The band's ID number: don't use -1.
Definition coolbar.h:51
TCoolBar * Parent
Definition coolbar.h:75
TObjProperty< TSize > MinSize
Minimum size of the band's child window don't use TSize(-1,-1)
Definition coolbar.h:50
void Minimize()
Definition coolbar.h:242
TProperty< uint > Style
Band style flags.
Definition coolbar.h:48
TObjProperty< tstring > Text
Band text label.
Definition coolbar.h:43
TProperty< uint > Mask
Mask indicating which other members are valid.
Definition coolbar.h:53
TProperty< int > ImageIndex
Band image index (into rebar image list): don't use -1.
Definition coolbar.h:52
TObjProperty< TColor > BgColor
Definition coolbar.h:46
void BeginDrag(const TPoint &point)
Definition coolbar.h:176
void EndDrag()
Definition coolbar.h:198
This simple implementation does no more than encapsulte the messages which can be sent to the rebar c...
Definition coolbar.h:85
void SetBgColor(const TColor &clr)
Definition coolbar.h:269
uint GetRowCount()
Definition coolbar.h:306
TTooltip * FTooltip
Definition coolbar.h:163
TColor & GetTextColor()
Definition coolbar.h:293
TFuncPropertyVarPut< TPalette * > Palette
Definition coolbar.h:97
int FindBand(uint id)
Definition coolbar.h:394
void SetTextColor(const TColor &clr)
Definition coolbar.h:285
TCoolBandArray * FBands
Definition coolbar.h:154
TColor FTextColor
Definition coolbar.h:158
bool GetUnicode()
Definition coolbar.h:376
TColor FBgColor
Definition coolbar.h:157
TDropTarget GetDropTarget()
Definition coolbar.h:339
TFuncProperty< bool > Unicode
Definition coolbar.h:100
TFuncObjPropertyGet< TCoolBandArray > Bands
Definition coolbar.h:101
HWND GetToolTips()
Definition coolbar.h:351
TFuncObjProperty< TColorScheme > ColorScheme
Definition coolbar.h:96
TFuncObjProperty< TColor > TextColor
Definition coolbar.h:95
void SetUnicode(bool unicode)
Definition coolbar.h:366
bool SetRect(const TRect &rec)
Definition coolbar.h:403
TRebarInfo Info
Definition coolbar.h:155
TImageList * FBandImages
Definition coolbar.h:159
TPalette * FPalette
Definition coolbar.h:162
TColorScheme * FColorScheme
Definition coolbar.h:161
uint HitTest(TRbHitTestInfo &tst)
Definition coolbar.h:385
TCoolBandArray & GetBands()
Definition coolbar.h:412
TColor & GetBgColor()
Definition coolbar.h:277
bool ShouldDelete
Definition coolbar.h:160
TImageList * GetImageList()
Definition coolbar.h:357
TFuncPropertyVarPut< TTooltip * > Tooltip
Definition coolbar.h:99
TFuncObjProperty< TColor > BgColor
Definition coolbar.h:94
TFuncPropertyVarPut< TWindow * > Buddy
"Parent" for notification messages
Definition coolbar.h:98
uint GetRowHeight(int index)
Definition coolbar.h:319
TWindow * FBuddy
Definition coolbar.h:156
uint GetHeight()
Definition coolbar.h:328
Wraps the IDropTarget interface (currently lightweight).
Definition shellitm.h:150
TImageList is a wrapper class for the ImageList common "control".
Definition imagelst.h:64
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:75
TPalette is the GDI Palette class derived from TGdiObject.
Definition gdiobjec.h:413
TPoint is a support class, derived from tagPOINT.
Definition geometry.h:87
TRect is a mathematical class derived from tagRect.
Definition geometry.h:308
TTooltip encapsulates a tooltip window - i.e.
Definition tooltip.h:175
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 GetHandle() const
Returns the handle of the window.
Definition window.h:2020
Definition of classes for CommonControl encapsulation.
Definition of class TControl.
TAutoDelete
Flag for Handle ctors to control Handle deletion in dtor.
Definition gdibase.h:70
TIPtrArray< TCoolBand * > TCoolBandArray
Definition coolbar.h:78
TCoolBandArray::Iterator TCoolBandArrayIter
Definition coolbar.h:79
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
uint32 MkUint32(uint16 lo, uint16 hi)
Definition defs.h:261
LPARAM TParam2
Second parameter type.
Definition dispatch.h:55
WPARAM TParam1
First parameter type.
Definition dispatch.h:54
std::string tstring
Definition defs.h:79
unsigned int uint
Definition number.h:25
#define _OWLCLASS
Definition defs.h:338
Credits: The Property pattern is taken from "Patterns in Practice: A Property Template for C++",...
Definitions of Win95 Shell Clases: TShellItem, TShellItemIterator, TPidl, TShellMalloc.
Definition of container classes used and made available by OWL.