OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
owl::TImageList Class Reference

TImageList is a wrapper class for the ImageList common "control". More...

#include <owl/imagelst.h>

Public Member Functions

 TImageList (const TSize &imageSize, uint flags, int initCapacity, int growBy)
 Constructs an empty ImageList of a given size.
 
 TImageList (const TBitmap &bmp, uint flags, int imageCount, int growBy)
 Constructs a TImageList from a bitmap, slicing it up into a horizontal array of the given number of evenly sized images.
 
 TImageList (const TDib &dib, uint flags, int imageCount, int growBy)
 Constructs a TImageList from a DIB, slicing the bitmap up into a horizontal array of the given number of evenly sized images.
 
 TImageList (HINSTANCE, TResId, int imageWidth, int growBy, const TColor &mask, uint type=IMAGE_BITMAP, uint flags=LR_CREATEDIBSECTION)
 Constructs an ImageList from a bitmap resource.
 
 TImageList (HIMAGELIST imageList)
 Constructs a C++ alias for an existing imagelist.
 
 TImageList (TPoint &pt, TPoint &hotspot)
 Constructs a wrapper for the current drag imagelist and specifies the location and hotspot of the imagelist.
 
 TImageList (const TImageList &src)
 Creates a duplicate of the given image list.
 
 ~TImageList ()
 Destructs the ImageList and cleans up the image list handle.
 
TImageListoperator= (const TImageList &)
 Replaces the image list by a duplicate of the given image list.
 
 operator TBitmap & ()
 Returns the image bitmap used by this ImageList.
 
 operator HIMAGELIST () const
 Converts to the HIMAGELIST structure.
 
int GetImageCount () const
 Returns number of images currently in this ImageList.
 
TSize GetImageSize () const
 Returns the size each image.
 
TPoint GetImageOffset (int cel) const
 Returns the offset of a given image in the ImageList's bitmap.
 
TRect GetImageRect (int cel) const
 Returns the bounding rect of a given image in the ImageList's bitmap.
 
TRect operator[] (int cel) const
 Returns the rectangle of the image at index 'index'.
 
int Add (const TBitmap &image)
 Adds new image(s) to the ImageList.
 
int Add (const TBitmap &image, const TBitmap &mask)
 Adds new image/mask pair(s) to the ImageList. Returns index of new addition.
 
int Add (const TBitmap &image, const TColor &mask)
 Adds new image(s) to ImageList, specifying a mask color to generate a mask.
 
int Add (const TIcon &)
 Adds an icon to the ImageList. Returns index of new addition.
 
bool Remove (int index)
 Removes an image (or all images if index is -1) from this ImageList.
 
bool RemoveAll ()
 Removes all images from the list.
 
bool Replace (int index, const TBitmap &image)
 Replaces an image in this ImageList.
 
bool Replace (int index, const TBitmap &image, const TBitmap &mask)
 Replaces an image and mask in the ImageList.
 
int ReplaceIcon (int index, HICON hicon)
 Replaces the image at index 'index' with the icon or cursor.
 
HICON GetIcon (int index, uint flags) const
 Creates and retrieves an icon from an image and mask in the ImageList.
 
bool GetIconSize (int &cx, int &cy)
 Returns the icon size.
 
bool GetImageInfo (int index, TImageInfo &celInfo) const
 Gets general information about a given image.
 
TImageInfo GetImageInfo (int index) const
 Functional-style overload.
 
TColor GetBkColor () const
 Gets the current background color for this ImageList.
 
TColor SetBkColor (const TColor &newColor)
 Sets the current background color for this ImageList, returning the previous color.
 
bool Draw (int index, TDC &, int x, int y, uint style=ILD_NORMAL, int overlay=0)
 Draws an image onto a target DC at a given coordinate and with a given style.
 
bool Draw (int index, TDC &dc, const TPoint &p, uint style=ILD_NORMAL, int overlay=0)
 
bool Draw (int index, TDC &, int x, int y, int dx, int dy, const TColor &bgClr, const TColor &fgClr, uint style=ILD_NORMAL, int overlay=0)
 Extended version of draw that takes a foreground color and background color.
 
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)
 
bool SetOverlayImage (int index, int overlay)
 Selects an image for use as an overlay. Up to four can be selected.
 
bool SetDragCursorImage (int drag, int dxHotspot, int dyHotspot)
 Combines the current drag image with another image in the list.
 
bool BeginDrag (int index, int dxHotspot, int dyHotspot)
 BeginDrag sets this imagelist to be the drag imagelist.
 
bool Copy (TImageList &imgsrc, int ifrom, int ito, uint flags=ILCF_MOVE)
 
bool DrawIndirect (const TImageListDrawParam &imldp)
 
TImageListDuplicate ()
 
bool SetImageCount (uint newcount)
 

Static Public Member Functions

static bool DragEnter (HWND hwndLock, int x, int y)
 Typically, this function is called in response to a WM_LBUTTONDOWN message.
 
static bool DragMove (int x, int y)
 DragMove is typically called when receiving a WM_MOUSEMOVE message.
 
static bool DragLeave (HWND hwndLock)
 DragLeave is typically called when receiving a WM_LBUTTONUP message.
 
static void EndDrag ()
 EndDrag removes the current drag imagelist from the system.
 
static bool DragShowNolock (bool show)
 Locks or unlocks the window from updates.
 

Protected Member Functions

void CheckValid ()
 Throws an exception if this image list handle is invalid.
 

Detailed Description

TImageList is a wrapper class for the ImageList common "control".

Definition at line 64 of file imagelst.h.

Constructor & Destructor Documentation

◆ TImageList() [1/7]

owl::TImageList::TImageList ( const TSize & imageSize,
uint flags,
int initCapacity,
int growBy )

Constructs an empty ImageList of a given size.

The imageSize is the individual image size, not the total size of the list. The initCapacity parameter describes the initial capacity of the list, i.e. how many images it can hold before it needs to grow (perform a reallocation). Note that the list remains empty after construction, regardless of capacity. The growBy parameter specifies how much the capacity will grow when needed.

Definition at line 38 of file imagelst.cpp.

References CheckValid(), and WARNX.

◆ TImageList() [2/7]

owl::TImageList::TImageList ( const TBitmap & bmp,
uint flags,
int imageCount,
int growBy )

Constructs a TImageList from a bitmap, slicing it up into a horizontal array of the given number of evenly sized images.

Definition at line 53 of file imagelst.cpp.

References Add(), CheckValid(), owl::TColor::Sys3dFace, and WARNX.

◆ TImageList() [3/7]

owl::TImageList::TImageList ( const TDib & dib,
uint flags,
int imageCount,
int growBy )

Constructs a TImageList from a DIB, slicing the bitmap up into a horizontal array of the given number of evenly sized images.

Definition at line 72 of file imagelst.cpp.

References Add(), CheckValid(), owl::TColor::Sys3dFace, and WARNX.

◆ TImageList() [4/7]

owl::TImageList::TImageList ( HINSTANCE h,
TResId id,
int imageWidth,
int growBy,
const TColor & mask,
uint type = IMAGE_BITMAP,
uint flags = LR_CREATEDIBSECTION )

Constructs an ImageList from a bitmap resource.

type must be IMAGE_BITMAP. flags can be one of the flags specified for the ImageList_LoadImage function in the Windows API. The default is LR_CREATEDIBSECTION which will load the bitmap as a device-independent bitmap (DIB) with no colour mapping performed.

See also
http://msdn.microsoft.com/en-us/library/windows/desktop/bb761557.aspx

Definition at line 96 of file imagelst.cpp.

References CheckValid(), and WARNX.

◆ TImageList() [5/7]

owl::TImageList::TImageList ( HIMAGELIST imageList)

Constructs a C++ alias for an existing imagelist.

The object takes ownership of the given handle, i.e. it will be destroyed in the destructor at the end of the object's lifetime.

Definition at line 111 of file imagelst.cpp.

References CheckValid(), and WARNX.

◆ TImageList() [6/7]

owl::TImageList::TImageList ( TPoint & pt,
TPoint & hotspot )

Constructs a wrapper for the current drag imagelist and specifies the location and hotspot of the imagelist.

Definition at line 128 of file imagelst.cpp.

References CheckValid(), and WARNX.

◆ TImageList() [7/7]

owl::TImageList::TImageList ( const TImageList & src)

Creates a duplicate of the given image list.

See also
ImageList_Duplicate in the Windows API.

Definition at line 142 of file imagelst.cpp.

References _T, CheckValid(), and WARNX.

◆ ~TImageList()

owl::TImageList::~TImageList ( )

Destructs the ImageList and cleans up the image list handle.

Definition at line 152 of file imagelst.cpp.

Member Function Documentation

◆ Add() [1/4]

int owl::TImageList::Add ( const TBitmap & image)

Adds new image(s) to the ImageList.

Returns index of new addition. No mask bitmap is added.

Definition at line 259 of file imagelst.cpp.

References PRECONDITION.

◆ Add() [2/4]

int owl::TImageList::Add ( const TBitmap & image,
const TBitmap & mask )

Adds new image/mask pair(s) to the ImageList. Returns index of new addition.

Definition at line 270 of file imagelst.cpp.

References PRECONDITION.

◆ Add() [3/4]

int owl::TImageList::Add ( const TBitmap & image,
const TColor & mskColor )

Adds new image(s) to ImageList, specifying a mask color to generate a mask.

Returns index of the new addition.

Definition at line 282 of file imagelst.cpp.

References PRECONDITION.

◆ Add() [4/4]

int owl::TImageList::Add ( const TIcon & icon)

Adds an icon to the ImageList. Returns index of new addition.

Definition at line 292 of file imagelst.cpp.

References PRECONDITION.

◆ BeginDrag()

bool owl::TImageList::BeginDrag ( int index,
int dxHotspot,
int dyHotspot )

BeginDrag sets this imagelist to be the drag imagelist.

There can only be one drag imagelist at any time.

Definition at line 429 of file imagelst.cpp.

References PRECONDITION.

◆ CheckValid()

void owl::TImageList::CheckValid ( )
protected

Throws an exception if this image list handle is invalid.

Definition at line 163 of file imagelst.cpp.

References owl::TXCommCtrl::Raise().

◆ Copy()

bool owl::TImageList::Copy ( TImageList & imgsrc,
int ifrom,
int ito,
uint flags = ILCF_MOVE )

Definition at line 489 of file imagelst.cpp.

References PRECONDITION.

◆ DragEnter()

bool owl::TImageList::DragEnter ( HWND hWndLock,
int x,
int y )
static

Typically, this function is called in response to a WM_LBUTTONDOWN message.

The 'x' and 'y' parameters are relative to the upper-left corner of the window's rectangle and NOT the client area. The window 'hWndLock' is locked from further updates.

Definition at line 442 of file imagelst.cpp.

◆ DragLeave()

bool owl::TImageList::DragLeave ( HWND hWndLock)
static

DragLeave is typically called when receiving a WM_LBUTTONUP message.

The 'hWndLock' window is unlocked from updates.

Definition at line 462 of file imagelst.cpp.

◆ DragMove()

bool owl::TImageList::DragMove ( int x,
int y )
static

DragMove is typically called when receiving a WM_MOUSEMOVE message.

The 'x' and 'y' parameters are generally passed from the message to this function.

Definition at line 452 of file imagelst.cpp.

◆ DragShowNolock()

bool owl::TImageList::DragShowNolock ( bool show)
static

Locks or unlocks the window from updates.

Definition at line 480 of file imagelst.cpp.

◆ Draw() [1/4]

bool owl::TImageList::Draw ( int index,
TDC & dc,
int x,
int y,
int dx,
int dy,
const TColor & bgClr,
const TColor & fgClr,
uint style = ILD_NORMAL,
int overlay = 0 )

Extended version of draw that takes a foreground color and background color.

Definition at line 231 of file imagelst.cpp.

References owl::TColor::None, and PRECONDITION.

◆ Draw() [2/4]

bool owl::TImageList::Draw ( int index,
TDC & dc,
int x,
int y,
uint style = ILD_NORMAL,
int overlay = 0 )

Draws an image onto a target DC at a given coordinate and with a given style.

Definition at line 218 of file imagelst.cpp.

References PRECONDITION.

◆ Draw() [3/4]

bool owl::TImageList::Draw ( int index,
TDC & dc,
const TPoint & p,
uint style = ILD_NORMAL,
int overlay = 0 )
inline

Definition at line 127 of file imagelst.h.

◆ Draw() [4/4]

bool owl::TImageList::Draw ( int index,
TDC dc,
const TPoint & p,
const TSize & s,
const TColor & bgClr,
const TColor & fgClr,
uint style = ILD_NORMAL,
int overlay = 0 )
inline

Definition at line 134 of file imagelst.h.

◆ DrawIndirect()

bool owl::TImageList::DrawIndirect ( const TImageListDrawParam & imldp)

Definition at line 499 of file imagelst.cpp.

◆ Duplicate()

TImageList * owl::TImageList::Duplicate ( )

Definition at line 509 of file imagelst.cpp.

References TImageList(), and PRECONDITION.

◆ EndDrag()

void owl::TImageList::EndDrag ( )
static

EndDrag removes the current drag imagelist from the system.

Definition at line 471 of file imagelst.cpp.

◆ GetBkColor()

TColor owl::TImageList::GetBkColor ( ) const

Gets the current background color for this ImageList.

Definition at line 384 of file imagelst.cpp.

References PRECONDITION.

◆ GetIcon()

HICON owl::TImageList::GetIcon ( int index,
uint flags ) const

Creates and retrieves an icon from an image and mask in the ImageList.

Definition at line 332 of file imagelst.cpp.

References PRECONDITION.

◆ GetIconSize()

bool owl::TImageList::GetIconSize ( int & cx,
int & cy )

Returns the icon size.

Todo
What about a TSize TImageList::GetIconSize() version?

Definition at line 352 of file imagelst.cpp.

References PRECONDITION.

◆ GetImageCount()

int owl::TImageList::GetImageCount ( ) const

Returns number of images currently in this ImageList.

Definition at line 248 of file imagelst.cpp.

References PRECONDITION.

◆ GetImageInfo() [1/2]

TImageInfo owl::TImageList::GetImageInfo ( int index) const

Functional-style overload.

Definition at line 372 of file imagelst.cpp.

References _T, and GetImageInfo().

◆ GetImageInfo() [2/2]

bool owl::TImageList::GetImageInfo ( int index,
TImageInfo & celInfo ) const

Gets general information about a given image.

Definition at line 362 of file imagelst.cpp.

References PRECONDITION.

◆ GetImageOffset()

TPoint owl::TImageList::GetImageOffset ( int cel) const
inline

Returns the offset of a given image in the ImageList's bitmap.

Definition at line 226 of file imagelst.h.

◆ GetImageRect()

TRect owl::TImageList::GetImageRect ( int cel) const
inline

Returns the bounding rect of a given image in the ImageList's bitmap.

Definition at line 233 of file imagelst.h.

◆ GetImageSize()

TSize owl::TImageList::GetImageSize ( ) const
inline

Returns the size each image.

Each image of the list must be the same size.

Definition at line 219 of file imagelst.h.

◆ operator HIMAGELIST()

owl::TImageList::operator HIMAGELIST ( ) const
inline

Converts to the HIMAGELIST structure.

Definition at line 254 of file imagelst.h.

◆ operator TBitmap &()

owl::TImageList::operator TBitmap & ( )

Returns the image bitmap used by this ImageList.

Definition at line 199 of file imagelst.cpp.

◆ operator=()

TImageList & owl::TImageList::operator= ( const TImageList & src)

Replaces the image list by a duplicate of the given image list.

See also
ImageList_Duplicate in the Windows API.

Definition at line 175 of file imagelst.cpp.

References _T, and WARNX.

◆ operator[]()

TRect owl::TImageList::operator[] ( int cel) const
inline

Returns the rectangle of the image at index 'index'.

Definition at line 240 of file imagelst.h.

References GetImageRect().

◆ Remove()

bool owl::TImageList::Remove ( int index)

Removes an image (or all images if index is -1) from this ImageList.

Definition at line 302 of file imagelst.cpp.

References PRECONDITION.

◆ RemoveAll()

bool owl::TImageList::RemoveAll ( )
inline

Removes all images from the list.

Definition at line 247 of file imagelst.h.

References Remove().

◆ Replace() [1/2]

bool owl::TImageList::Replace ( int index,
const TBitmap & image )

Replaces an image in this ImageList.

Definition at line 312 of file imagelst.cpp.

References PRECONDITION.

◆ Replace() [2/2]

bool owl::TImageList::Replace ( int index,
const TBitmap & image,
const TBitmap & mask )

Replaces an image and mask in the ImageList.

Definition at line 322 of file imagelst.cpp.

References PRECONDITION.

◆ ReplaceIcon()

int owl::TImageList::ReplaceIcon ( int index,
HICON hicon )

Replaces the image at index 'index' with the icon or cursor.

Definition at line 342 of file imagelst.cpp.

References PRECONDITION.

◆ SetBkColor()

TColor owl::TImageList::SetBkColor ( const TColor & newColor)

Sets the current background color for this ImageList, returning the previous color.

Definition at line 395 of file imagelst.cpp.

References PRECONDITION.

◆ SetDragCursorImage()

bool owl::TImageList::SetDragCursorImage ( int drag,
int dxHotspot,
int dyHotspot )

Combines the current drag image with another image in the list.

Typically, a mouse cursor would be added to the image list and merged with the drag image list.

Definition at line 418 of file imagelst.cpp.

References PRECONDITION.

◆ SetImageCount()

bool owl::TImageList::SetImageCount ( uint newcount)

Definition at line 520 of file imagelst.cpp.

◆ SetOverlayImage()

bool owl::TImageList::SetOverlayImage ( int index,
int overlay )

Selects an image for use as an overlay. Up to four can be selected.

Definition at line 405 of file imagelst.cpp.

References PRECONDITION.


The documentation for this class was generated from the following files: