OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
imagelst.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 TImageList, an ImageList Common Control wrapper.
7//----------------------------------------------------------------------------
8
9#if !defined(OWL_IMAGELST_H)
10#define OWL_IMAGELST_H
11
12#include <owl/private/defs.h>
13#if defined(BI_HAS_PRAGMA_ONCE)
14# pragma once
15#endif
16
17#include <owl/gdiobjec.h>
18#include <owl/commctrl.h>
19
20
21namespace owl {
22
23class _OWLCLASS TImageList;
24
25#include <owl/preclass.h>
26
27/// \addtogroup commctrl
28/// @{
29//
30/// \class TImageInfo
31// ~~~~~ ~~~~~~~~~~
32/// TImageInfo is a wrapper class for a structure that describes an image within an
33/// image list.
34//
35/// DLN made this derive from IMAGEINFO to simplify porting code
36/// using existing _IMAGEINFO structure. Of course, new code
37/// should avoid directly accessing these fields.
38//
39class _OWLCLASS TImageInfo : public _IMAGEINFO
40{
41 public:
42 TImageInfo();
43 TImageInfo(const TImageList& list, int index = 0);
44
45 HBITMAP GetImageBM() const;
46 HBITMAP GetMaskBM() const;
47 TRect GetImageRect() const;
48
49 friend class _OWLCLASS TImageList;
50};
51
52class _OWLCLASS TImageListDrawParam : public IMAGELISTDRAWPARAMS{
53 public:
55};
56
57
58
59//
60/// \class TImageList
61// ~~~~~ ~~~~~~~~~~
62/// TImageList is a wrapper class for the ImageList common "control".
63//
65 public:
66 // Constructors
67 //
68 TImageList(const TSize& imageSize, uint flags, int initCapacity, int growBy);
69 TImageList(const TBitmap& bmp, uint flags, int imageCount, int growBy);
70 TImageList(const TDib& dib, uint flags, int imageCount, int growBy);
71
74
76
78
79 /*virtual*/ ~TImageList();
80
82 operator TBitmap&();
83
84 operator HIMAGELIST() const;
85
86 // 'Get' accessors
87 //
88 int GetImageCount() const;
89 TSize GetImageSize() const;
90 TPoint GetImageOffset(int cel) const;
91 TRect GetImageRect(int cel) const;
92 TRect operator [](int cel) const;
93
94 // Add an image into the list
95 //
96 int Add(const TBitmap& image);
97 int Add(const TBitmap& image, const TBitmap& mask);
98 int Add(const TBitmap& image, const TColor& mask);
99 int Add(const TIcon&);
100
101 // Remove an image from the list
102 bool Remove(int index);
103 bool RemoveAll();
104
105 // Replace the image at an index with another
106 //
107 bool Replace(int index, const TBitmap& image);
108 bool Replace(int index, const TBitmap& image, const TBitmap& mask);
109
110 // Get an icon or cursor from an image based on masks
111 //
112 int ReplaceIcon(int index, HICON hicon);
113 HICON GetIcon(int index, uint flags) const;
114 bool GetIconSize(int& cx, int& cy);
115
116 bool GetImageInfo(int index, TImageInfo& celInfo) const;
117 TImageInfo GetImageInfo(int index) const;
118
119 TColor GetBkColor() const;
120 TColor SetBkColor(const TColor& newColor);
121
122 // Draw the image
123 //
124 bool Draw(int index, TDC&, int x, int y, uint style = ILD_NORMAL,
125 int overlay = 0);
126
127 bool Draw(int index, TDC& dc, const TPoint& p, uint style = ILD_NORMAL, int overlay = 0)
128 {return Draw(index, dc, p.x, p.y, style, overlay);}
129
130 bool Draw(int index, TDC&, int x, int y, int dx, int dy,
131 const TColor& bgClr, const TColor& fgClr,
132 uint style = ILD_NORMAL, int overlay = 0);
133
134 bool Draw(int index, TDC dc, const TPoint& p, const TSize& s, const TColor& bgClr,
135 const TColor& fgClr, uint style = ILD_NORMAL, int overlay = 0)
136 {return Draw(index, dc, p.x, p.y, s.cx, s.cy, bgClr, fgClr, style, overlay);}
137
138 bool SetOverlayImage(int index, int overlay);
139
140 // Routines related to dragging
141 //
142 bool SetDragCursorImage(int drag, int dxHotspot, int dyHotspot);
143 bool BeginDrag(int index, int dxHotspot, int dyHotspot);
144 static bool DragEnter(HWND hwndLock, int x, int y);
145 static bool DragMove(int x, int y);
146 static bool DragLeave(HWND hwndLock);
147 static void EndDrag();
148 static bool DragShowNolock(bool show);
149
150 // Version 4.70
151 bool Copy(TImageList& imgsrc, int ifrom, int ito, uint flags=ILCF_MOVE);
152 // Version 4.70
153 bool DrawIndirect(const TImageListDrawParam& imldp);
154 // Version 4.71
155 TImageList* Duplicate();
156 // Version 4.70
157 bool SetImageCount(uint newcount);
158
159 protected:
160 void CheckValid();
161
163 HIMAGELIST Handle; ///< Handle of ImageList
164
165 private:
166
167 TBitmap* Bitmap; ///< Copy of image BM to work around Win95 BUG
168 TSize ImageSize; ///< Size of images in ImageList
169};
170
171/// @}
172
173#include <owl/posclass.h>
174
175
176//------------------------------------------------------------------------
177// Inline implementations
178
179
180//
181/// Constructs an empty image info.
182//
185
186//
187/// Construct based on an image within the image list.
188//
189inline TImageInfo::TImageInfo(const TImageList& array, int index) {
190 array.GetImageInfo(index, *this);
191}
192
193//
194/// Gets the image bitmap
195//
197 return hbmImage;
198}
199
200//
201/// Gets the image's mask
202//
204 return hbmMask;
205}
206
207//
208/// Gets the area of the image
209//
211 return rcImage;
212}
213
214//
215/// Returns the size each image.
216///
217/// Each image of the list must be the same size.
218//
220 return ImageSize;
221}
222
223//
224/// Returns the offset of a given image in the ImageList's bitmap
225//
226inline TPoint TImageList::GetImageOffset(int index) const {
227 return TPoint(index*ImageSize.cx, 0);
228}
229
230//
231/// Returns the bounding rect of a given image in the ImageList's bitmap
232//
233inline TRect TImageList::GetImageRect(int index) const {
234 return TRect(TPoint(index*ImageSize.cx, 0), ImageSize);
235}
236
237//
238/// Returns the rectangle of the image at index 'index'.
239//
240inline TRect TImageList::operator [](int index) const {
241 return GetImageRect(index);
242}
243
244//
245/// Removes all images from the list.
246//
248 return Remove(-1);
249}
250
251//
252/// Converts to the HIMAGELIST structure.
253//
254inline TImageList::operator HIMAGELIST() const {
255 return Handle;
256}
257
258
259} // OWL namespace
260
261#endif // OWL_IMAGELST_H
TBitmap is the GDI bitmap class derived from TGdiObject.
Definition gdiobjec.h:510
Class wrapper for management of color values.
Definition color.h:245
TDC is the root class for GDI DC wrappers.
Definition dc.h:64
Pseudo-GDI object Device Independent Bitmap (DIB) class.
Definition gdiobjec.h:795
TIcon, derived from TGdiObject, represents the GDI object icon class.
Definition gdiobjec.h:670
TImageInfo is a wrapper class for a structure that describes an image within an image list.
Definition imagelst.h:40
HBITMAP GetMaskBM() const
Gets the image's mask.
Definition imagelst.h:203
HBITMAP GetImageBM() const
Gets the image bitmap.
Definition imagelst.h:196
TRect GetImageRect() const
Gets the area of the image.
Definition imagelst.h:210
TImageInfo()
Constructs an empty image info.
Definition imagelst.h:183
TImageList is a wrapper class for the ImageList common "control".
Definition imagelst.h:64
TSize GetImageSize() const
Returns the size each image.
Definition imagelst.h:219
TRect GetImageRect(int cel) const
Returns the bounding rect of a given image in the ImageList's bitmap.
Definition imagelst.h:233
bool RemoveAll()
Removes all images from the list.
Definition imagelst.h:247
TRect operator[](int cel) const
Returns the rectangle of the image at index 'index'.
Definition imagelst.h:240
bool Draw(int index, TDC dc, const TPoint &p, const TSize &s, const TColor &bgClr, const TColor &fgClr, uint style=ILD_NORMAL, int overlay=0)
Definition imagelst.h:134
bool Draw(int index, TDC &dc, const TPoint &p, uint style=ILD_NORMAL, int overlay=0)
Definition imagelst.h:127
TPoint GetImageOffset(int cel) const
Returns the offset of a given image in the ImageList's bitmap.
Definition imagelst.h:226
bool Remove(int index)
Removes an image (or all images if index is -1) from this ImageList.
Definition imagelst.cpp:302
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
Definition of classes for CommonControl encapsulation.
Definition of abstract GDI object class and derived classes.
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
unsigned int uint
Definition number.h:25
#define protected_data
Definition defs.h:208
#define _OWLCLASS
Definition defs.h:338