OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
colmnhdr.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 TColumnHeader and helper classes
7//----------------------------------------------------------------------------
8
9#if !defined(OWL_COLMNHDR_H)
10#define OWL_COLMNHDR_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/template.h>
20
21
22namespace owl {
23
24class _OWLCLASS THdrItem;
25class _OWLCLASS THdrNotify;
26class _OWLCLASS TColumnHeader;
27
28#if !defined(HDI_ALL) // Mentioned in docs. but missing from headers
29# define HDI_ALL (HDI_BITMAP|HDI_FORMAT|HDI_HEIGHT|HDI_LPARAM|HDI_TEXT|HDI_WIDTH)
30#endif
31
32#include <owl/preclass.h>
33
34/// \addtogroup commctrl
35/// @{
36/// \class THdrItem
37// ~~~~~ ~~~~~~~~
38/// THdrItem contains information about an item in a header control.
39//
40class _OWLCLASS THdrItem : public HD_ITEM {
41 public:
42
43 //
44 /// Format flags that determines how the contents (text and/or bitmap) will be layed out.
45 //
46 enum TAlign
47 {
48 aLeft = HDF_LEFT, ///< Aligns the contents at the left edge of the item.
49 aCenter = HDF_CENTER, ///< Aligns the contents horizontally at the center of the item.
50 aRight = HDF_RIGHT ///< Aligns the contens at the right edge of the item.
51 };
52
53 /// \name Constructors to be used for adding, inserting or updating a header control's item.
54 /// 'str' specifies the title of the item. Note: The string pointed to must outlive the object!
55 /// 'hbm' specifies a handle to a bitmap to be used in the item.
56 /// @{
57
58 explicit THdrItem(LPCTSTR str, TAlign = aLeft);
59 THdrItem(LPCTSTR str, HBITMAP hbm, TAlign = aLeft);
60 explicit THdrItem(HBITMAP hbm, TAlign = aLeft);
61
62 /// @}
63
64 /// Constructors used primarily to construct a 'THdrItem' structure
65 /// which will be used to retrieve information about an item within
66 /// a header control. 'buffer' specifies the location to receive the
67 /// item's title and 'len' indicates the size of that buffer. The 'msk'
68 /// flags indicates which members of the structure should be updated.
69 /// @{
70
72 explicit THdrItem(uint msk = 0);
73
74 /// @}
75
76 /// Methods to set the data members of the HD_ITEM structure.
77 ///
78 void SetAlignment(TAlign);
79 void SetText(LPCTSTR str);
80 void SetBitmap(HBITMAP hbm);
81 void SetWidth(int cx);
82 void SetHeight(int cy);
83 void SetItemData(TParam2 data);
84 void SetMask(int msk);
85 // new Version 4.0
86 void SetImage(int item);
87 void SetOrder(int order);
88
89 static void SetDefStringSize(int size);
90 static void SetDefBitmapSize(int size);
91
92 protected:
95};
96
97
98//
99/// \class THeaderHitTestInfo
100// ~~~~~ ~~~~~~~~~~~~~~~~~~
101/// THeaderHitTestInfo contains hittest information for the header control.
102/// It is used with the TColumnHeader::HitTest method.
103//
104class THeaderHitTestInfo : public HD_HITTESTINFO {
105 public:
107 THeaderHitTestInfo(int x, int y);
108};
109
110//
111/// \class TColumnHeader
112// ~~~~~ ~~~~~~~~~~~~~
113/// TColumnHeader encapsulates the 'header control', a window
114/// usually positioned above columns of text or numbers.
115//
117 public:
118 TColumnHeader(TWindow* parent,
119 int id,
120 int x, int y, int w, int h,
121 TModule* module = 0);
122
123 TColumnHeader(TWindow* parent, int resourceId, TModule* module = 0);
125
126 // Position Column Header
127 //
128 bool Layout(TRect& boundingRect, WINDOWPOS& winPos);
129 bool Layout(uint swpFlags = 0);
130
131 // Column Header attributes
132 //
133 int GetCount() const;
134
135 // Operations on individual column header items
136 //
137 int Add(const THdrItem& item);
138 int Insert(const THdrItem& item, int index);
139 bool Delete(int index);
140 bool GetItem(THdrItem&, int index, uint mask = 0);
141 bool SetItem(const THdrItem& itemInfo, int index);
142
143 // Hit-testing
144 //
145 int HitTest(THeaderHitTestInfo& ht);
146
147 // New IE 4.0 functionality
148 //
149 // Image List manipulation
150 //
151 HIMAGELIST CreateDragImage(int index) const;
152 HIMAGELIST GetImageList() const;
153 HIMAGELIST SetImageList(HIMAGELIST iml);
154
155 bool GetItemRect(TRect& rect, int index) const;
156
157 //
158 // Order array manipulation
159 //
160 bool SetOrderArray(int size, int* array);
161 bool GetOrderArray(int size, int* array) const;
162 TResult OrderToIndex(int order);
163
164 int SetHotDivider(uint32 value, bool flag = true);
165
166 // Override virtual method to save/restore contents of columnHeader
167 //
168 uint Transfer(void* buffer, TTransferDirection direction);
169
170 protected:
171 // Override TWindow virtual member functions
172 //
173 virtual auto GetWindowClassName() -> TWindowClassName;
174
175 private:
176 // Hidden to prevent accidental copying or assignment
177 //
180
181};
182/// @}
183
184#include <owl/posclass.h>
185
186
187
188//----------------------------------------------------------------------------
189// Inline implementations
190//
191
192//
193/// Version 4.70 functionality.
194///
195/// Creates a semi-transparent version of an item's image for use as a dragging
196/// image. Returns a handle to an image list that contains the new image as its only
197/// element. The
198/// image assigned to this item is the basis for the transparent image.
199/// \param index is a zero-based index of the item within the header control.
200//
205
206//
207/// Version 4.70 functionality.
208///
209/// Retrieves the handle to the image list that has been set for an existing header
210/// control.
211//
215
216//
217/// Version 4.70 functionality.
218///
219/// Assigns an image list to an existing header control. Returns the handle to the
220/// image list previously associated with the control. Returns NULL upon failure or
221/// if no image list was set previously.
222//
226
227
228//
229/// Version 4.70 functionality.
230///
231/// Retrieves the bounding rectangle for a given item in a header control. Returns
232/// nonzero if successful, or zero otherwise.
233//
234inline bool TColumnHeader::GetItemRect(TRect& rect, int index) const{
236 TParam1(index), TParam2(&rect)));
237}
238
239//
240/// Version 4.70 functionality.
241///
242/// Sets the left-to-right order of header items. Returns nonzero if successful, or
243/// zero otherwise.
244///
245/// \param size Size of the buffer at lpiArray, in elements. This value must equal the
246/// value returned by GetItemCount().
247/// \param array Address of an array that specifies the order in which items should be
248/// displayed, from left to right. For example, if the contents of the array are
249/// { 2,0,1}, the control displays item 2, item 0, and item 1, from left to right.
250//
251inline bool TColumnHeader::SetOrderArray(int size, int* array){
252 return ToBool(SendMessage(HDM_SETORDERARRAY, TParam1(size), TParam2(array)));
253}
254
255//
256/// Version 4.70 functionality.
257///
258/// Retrieves the current left-to-right order of items in a header control. Returns
259/// nonzero if successful, and the buffer at lpiArray receives the item number for
260/// each item in the header control in the order in which they appear from left to
261/// right. Otherwise, the message returns zero.
262///
263/// \param size Number of integer elements that array can hold. This value must be equal
264/// to the number of items in the control (see GetCount().
265/// \param array Address of an array of integers that receive the index values for items
266/// in the header. The number of elements in this array is specified in size and
267/// must be equal to or greater than the number of items in the control. For
268/// example, the following code fragment will reserve enough memory to hold the
269/// index values.
270/// \code
271/// int items;
272/// int *array;
273///
274/// // Get memory for buffer.
275/// items = GetCount();
276/// if(!(array = calloc(items,sizeof(int))))
277/// MessageBox("Out of memory.","Error", MB_OK);
278/// \endcode
279//
280inline bool TColumnHeader::GetOrderArray(int size, int* array) const{
282 TParam1(size), TParam2(array)));
283}
284
285//
286/// Version 4.70 functionality.
287///
288/// Retrieves an index value for an item based on its order in the header control.
289/// Returns int that indicates the item index. If order is invalid (negative or too
290/// large), the return equals order.
291///
292/// \param order Order in which the item appears within the header control, from left to
293/// right. For example, the index value of the item in the far left column would be
294/// 0. The value for the next item to the right would be 1, and so on.
295//
299
300//
301/// Version 4.70 functionality.
302///
303/// Changes the color of a divider between header items to indicate the destination
304/// of an external drag-and-drop operation. Returns a value equal to the index of
305/// the divider that the control highlighted.
306///
307/// \param flag Value specifying the type of value represented by dwInputValue. This value
308/// can be one of the following:
309/// - \c \b true Indicates that value holds the client coordinates of the pointer.
310/// - \c \b false Indicates that value holds a divider index value.
311/// \param value Value held in dwInputValue is interpreted depending on the value of
312/// flag.
313/// If flag is true, dwInputValue represents the x- and y-coordinates of the
314/// pointer. The x-coordinate is in the low word, and the y-coordinate is in the
315/// high word. When the header control receives the message, it highlights the
316/// appropriate divider based on the dwInputValue coordinates.
317/// If flag is false, dwInputValue represents the integer index of the divider to be
318/// highlighted.
319///
320/// This message creates an effect that a header control automatically produces when
321/// it has the HDS_DRAGDROP style. This function is intended to be used when the
322/// owner of the control handles drag-and-drop operations manually.
323//
325 return static_cast<int>(SendMessage(HDM_SETHOTDIVIDER,TParam1(flag),TParam2(value)));
326}
327
328
329//
330/// Updates the mask member of the structure. The latter indicates
331/// which other members of the structure contain valid data.
332//
333inline void THdrItem::SetMask(int msk)
334{
335 mask = msk;
336}
337
338//
339/// Initializes the client ooordinates being hit-tested with the
340/// specified TPoint parameter.
341//
343{
344 pt.x = point.x;
345 pt.y = point.y;
346}
347
348//
349/// Initializes the client ooordinates being hit-tested with the
350/// specified 'x' and 'y' locations.
351//
353{
354 pt.x = x;
355 pt.y = y;
356}
357
358
359} // OWL namespace
360
361
362#endif // OWL_COLMNHDR_H
TColumnHeader encapsulates the 'header control', a window usually positioned above columns of text or...
Definition colmnhdr.h:116
HIMAGELIST SetImageList(HIMAGELIST iml)
Version 4.70 functionality.
Definition colmnhdr.h:223
int SetHotDivider(uint32 value, bool flag=true)
Version 4.70 functionality.
Definition colmnhdr.h:324
bool GetItemRect(TRect &rect, int index) const
Version 4.70 functionality.
Definition colmnhdr.h:234
TResult OrderToIndex(int order)
Version 4.70 functionality.
Definition colmnhdr.h:296
bool SetOrderArray(int size, int *array)
Version 4.70 functionality.
Definition colmnhdr.h:251
HIMAGELIST CreateDragImage(int index) const
Version 4.70 functionality.
Definition colmnhdr.h:201
bool GetOrderArray(int size, int *array) const
Version 4.70 functionality.
Definition colmnhdr.h:280
HIMAGELIST GetImageList() const
Version 4.70 functionality.
Definition colmnhdr.h:212
TControl unifies its derived control classes, such as TScrollBar, TControlGadget, and TButton.
Definition control.h:38
THdrItem contains information about an item in a header control.
Definition colmnhdr.h:40
static int DefStringItemSize
Default size of string item.
Definition colmnhdr.h:93
TAlign
Format flags that determines how the contents (text and/or bitmap) will be layed out.
Definition colmnhdr.h:47
static int DefBitmapItemSize
Default size of bitmap item.
Definition colmnhdr.h:94
void SetMask(int msk)
Updates the mask member of the structure.
Definition colmnhdr.h:333
THeaderHitTestInfo contains hittest information for the header control.
Definition colmnhdr.h:104
THeaderHitTestInfo(const TPoint &pt)
Initializes the client ooordinates being hit-tested with the specified TPoint parameter.
Definition colmnhdr.h:342
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:75
TPoint is a support class, derived from tagPOINT.
Definition geometry.h:87
TRect is a mathematical class derived from tagRect.
Definition geometry.h:308
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
Definition of classes for CommonControl encapsulation.
Definition of container classes used and made available by OWL.
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
unsigned long uint32
Definition number.h:34
LPARAM TParam2
Second parameter type.
Definition dispatch.h:55
bool ToBool(const T &t)
Definition defs.h:291
WPARAM TParam1
First parameter type.
Definition dispatch.h:54
unsigned int uint
Definition number.h:25
#define CONST_CAST(targetType, object)
Definition defs.h:273
#define _OWLCLASS
Definition defs.h:338
Definition of container classes used and made available by OWL.