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

Encapsulates structure LVITEM, used to describe an item in a TListViewCtrl. More...

#include <owl/listviewctrl.h>

Inheritance diagram for owl::TLvItem:

Public Types

enum  TListState { Unspecified = 0 , Focus = LVIS_FOCUSED , Selected = LVIS_SELECTED , Cut = LVIS_CUT , DropHilited = LVIS_DROPHILITED , Activating = LVIS_ACTIVATING , OverlayMask = LVIS_OVERLAYMASK , StateImageMask = LVIS_STATEIMAGEMASK }
 TListState is used to describe the state of an item. More...
 
enum  TMaskFlag { lvifAll = 0xFFFFFFFF }
 Flags for setting the initialisation mask. More...
 

Public Member Functions

Constructors
 TLvItem (uint mask_=lvifAll, bool allocTextBuffer=true, int bufferSize=1000)
 Constructs an empty parameter package.
 
 TLvItem (const tstring &text, int subitemIndex=0)
 Constructs a parameter package with the given text.
 
 TLvItem (const TListViewCtrl &ctl, int index, int subitemIndex, uint mask_=lvifAll, int bufferSize=1000)
 Constructs a parameter package based on the item attributes of an existing control.
 
 TLvItem (const LVITEM &item)
 Constructs a parameter package from an existing parameter package.
 
 TLvItem (const TLvItem &item)
 Constructs a parameter package from an existing parameter package.
 
Overload operations
auto operator= (const LVITEM &item) -> TLvItem &
 Overloads the assignment operator to perform a deep copy using a separate string buffer if applicable.
 
auto operator= (const TLvItem &item) -> TLvItem &
 Copies the given parameter package.
 
Text operations
auto GetText () const -> LPCTSTR
 Retrieves the current text for the column.
 
auto GetText (TCHAR *buffer, size_t bufferSize) const -> void
 Copies the current text for the column.
 
auto SetTextBuffer (TCHAR *buffer, int bufferSize) -> void
 Overrides the internal buffer and assigns an external text buffer.
 
auto SetText (const tstring &text) -> void
 Copies the given text into the internal text buffer.
 
Index is the 0-based "row"
auto GetIndex () const -> int
 Retrieves the item index.
 
auto SetIndex (int index) -> void
 Sets the item index.
 
Column number
auto GetSubItem () const -> int
 Retrieves the subitem index.
 
auto SetSubItem (int subitemIndex) -> void
 Sets the subitem index.
 
Extra data
auto GetItemData () const -> LPARAM
 Retrieves the application-defined data.
 
auto SetItemData (LPARAM param) -> void
 Sets the application-defined data.
 
ImageList index
auto GetImageIndex () const -> int
 Retrieves the current image index used for the item.
 
auto SetImageIndex (int image) -> void
 Sets the image index within the image list to use.
 
Item state
auto GetState () const -> int
 Retrieves the current state used for the item.
 
auto SetState (TListState state) -> void
 Sets the state to use.
 
ImageList index for the state image
auto GetStateImage () const -> int
 Retrieves the current state image index used for the item.
 
auto SetStateImage (int stateIndex) -> void
 Sets the state image index to use.
 
Set/Get indent (Version 4.70)
auto GetIndent () const -> int
 Retrieves the current number of image widths to indent the item.
 
auto SetIndent (int indent) -> void
 Sets the number of image widths to indent the item.
 

Protected Types

typedef std::vector< tcharTBuffer
 

Protected Member Functions

void Init ()
 Initializes member data; used by internal routines.
 

Protected Attributes

TBuffer Buffer
 

Detailed Description

Encapsulates structure LVITEM, used to describe an item in a TListViewCtrl.

Contains information about the item's icon, label, state and application-defined value. This class is a thin encapsulation used to pass or retrieve item attributes. The class manages an internal text buffer so that the user is freed from manual text buffer management.

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

Definition at line 180 of file listviewctrl.h.

Member Typedef Documentation

◆ TBuffer

typedef std::vector<tchar> owl::TLvItem::TBuffer
protected

Definition at line 288 of file listviewctrl.h.

Member Enumeration Documentation

◆ TListState

TListState is used to describe the state of an item.

Enumerator
Unspecified 

Unspecified state.

Focus 

Only one item has focus.

Selected 

Marked as selected.

Cut 

Marked for cut & paste.

DropHilited 

Marked as drop target.

Activating 

(Ver 4.71) The item is being activated in an LVN_ITEMACTIVATE notification.

OverlayMask 

Retrieve one-based overlay image index.

StateImageMask 

Retrieve one-based state image index.

Definition at line 188 of file listviewctrl.h.

◆ TMaskFlag

Flags for setting the initialisation mask.

See also
TLvItem::TLvItem, LVITEM::mask, http://msdn.microsoft.com/en-us/library/windows/desktop/bb774760.aspx
Enumerator
lvifAll 

Definition at line 204 of file listviewctrl.h.

Constructor & Destructor Documentation

◆ TLvItem() [1/5]

owl::TLvItem::TLvItem ( uint mask_ = lvifAll,
bool allocTextBuffer = true,
int bufferSize = 1000 )
explicit

Constructs an empty parameter package.

This constructor is typically used to retrieve information about an existing column. For example,

TLvItem item;
bool success = ListWindow.GetItem(item, index, subitemIndex);
if (success && item.GetText()) ShowString(item.GetText());
Encapsulates structure LVITEM, used to describe an item in a TListViewCtrl.
auto GetText() const -> LPCTSTR
Retrieves the current text for the column.
Parameters
[in]mask_is the mask to use.
[in]allocTextBufferif true, then a character buffer is allocated, and pszText is set to point to it.
[in]bufferSizeis the size of the text characters to allocate and use if allocTextBuffer is true.

Definition at line 149 of file listviewctrl.cpp.

References Buffer, CHECK, Init(), and SetTextBuffer().

◆ TLvItem() [2/5]

owl::TLvItem::TLvItem ( const tstring & text,
int subitemIndex = 0 )
explicit

Constructs a parameter package with the given text.

The given text is copied to the internal buffer, and pszText will point to the internal copy. For example,

TLvItem item("Item");
ListWindow.AddItem(item);
Parameters
[in]textis the string to use.
[in]subitemIndexis the subitem index to use.

Definition at line 175 of file listviewctrl.cpp.

References Init(), SetSubItem(), and SetText().

◆ TLvItem() [3/5]

owl::TLvItem::TLvItem ( const TListViewCtrl & ctl,
int index,
int subitemIndex,
uint mask_ = lvifAll,
int bufferSize = 1000 )

Constructs a parameter package based on the item attributes of an existing control.

Parameters
[in]ctlis an existing list-view control from which to copy.
[in]indexis the item index of the existing list-view control to use for copying.
[in]subitemIndexis the subitem index to use.
[in]mask_is the mask to use for copying.
[in]bufferSizeis the size of the text characters to allocate and use, provided the mask includes LVIF_TEXT.

Definition at line 191 of file listviewctrl.cpp.

References Buffer, CHECK, Init(), PRECONDITION, and SetTextBuffer().

◆ TLvItem() [4/5]

owl::TLvItem::TLvItem ( const LVITEM & item)

Constructs a parameter package from an existing parameter package.

A deep copy is performed; see the assignment operator for const LVITEM& for details.

Parameters
[in]itemis an existing list-view item class from which to copy.

Definition at line 212 of file listviewctrl.cpp.

◆ TLvItem() [5/5]

owl::TLvItem::TLvItem ( const TLvItem & item)

Constructs a parameter package from an existing parameter package.

A deep copy is performed; see the copy assignment operator for details.

Parameters
[in]itemis an existing list-view item class from which to copy.

Definition at line 224 of file listviewctrl.cpp.

Member Function Documentation

◆ GetImageIndex()

auto owl::TLvItem::GetImageIndex ( ) const -> int

Retrieves the current image index used for the item.

Returns
the image index, or -1 if not used.

Definition at line 439 of file listviewctrl.cpp.

◆ GetIndent()

auto owl::TLvItem::GetIndent ( ) const -> int

Retrieves the current number of image widths to indent the item.

Returns
the number of image widths, or -1 if not used.

Definition at line 516 of file listviewctrl.cpp.

◆ GetIndex()

auto owl::TLvItem::GetIndex ( ) const -> int

Retrieves the item index.

Returns
the item index.

Definition at line 366 of file listviewctrl.cpp.

◆ GetItemData()

auto owl::TLvItem::GetItemData ( ) const -> LPARAM

Retrieves the application-defined data.

Returns
the application-defined data, or 0 if not used.

Definition at line 414 of file listviewctrl.cpp.

◆ GetState()

auto owl::TLvItem::GetState ( ) const -> int

Retrieves the current state used for the item.

Returns
the state, or 0 if not used.

Definition at line 464 of file listviewctrl.cpp.

◆ GetStateImage()

auto owl::TLvItem::GetStateImage ( ) const -> int

Retrieves the current state image index used for the item.

Returns
the state image index, or -1 if not used.

Definition at line 490 of file listviewctrl.cpp.

◆ GetSubItem()

auto owl::TLvItem::GetSubItem ( ) const -> int

Retrieves the subitem index.

Returns
the subitem index.

Definition at line 390 of file listviewctrl.cpp.

◆ GetText() [1/2]

auto owl::TLvItem::GetText ( ) const -> LPCTSTR

Retrieves the current text for the column.

Note
This might point to the internal text buffer, or to an external buffer.
Returns
a pointer to the text which will be nullptr if not used.
See also
SetTextBuffer.

Definition at line 264 of file listviewctrl.cpp.

References _T, and CHECK.

◆ GetText() [2/2]

auto owl::TLvItem::GetText ( TCHAR * buffer,
size_t bufferSize ) const -> void

Copies the current text for the column.

Parameters
[out]bufferupon return will contain the text string.
[in]bufferSizespecifies the maximum number of characters to copy; to determine an adequate size use (_tcslen(GetText()) + 1).
Returns
none.

Definition at line 290 of file listviewctrl.cpp.

References _T, _tcslen, CHECK, PRECONDITION, and WARN.

◆ Init()

auto owl::TLvItem::Init ( )
protected

Initializes member data; used by internal routines.

Returns
none.

Definition at line 541 of file listviewctrl.cpp.

◆ operator=() [1/2]

auto owl::TLvItem::operator= ( const LVITEM & item) -> TLvItem&

Overloads the assignment operator to perform a deep copy using a separate string buffer if applicable.

Parameters
[in]itemis an existing list-view item class from which to copy.

Definition at line 235 of file listviewctrl.cpp.

◆ operator=() [2/2]

auto owl::TLvItem::operator= ( const TLvItem & item) -> TLvItem&

Copies the given parameter package.

A deep copy is performed; see the assignment operator for const LVITEM& for details.

Definition at line 249 of file listviewctrl.cpp.

◆ SetImageIndex()

auto owl::TLvItem::SetImageIndex ( int image) -> void

Sets the image index within the image list to use.

Parameters
[in]imageis the image index to use.
Returns
none.

Definition at line 452 of file listviewctrl.cpp.

◆ SetIndent()

auto owl::TLvItem::SetIndent ( int indent) -> void

Sets the number of image widths to indent the item.

Parameters
[in]indentthe number of image widths to use.
Returns
none.

Definition at line 529 of file listviewctrl.cpp.

◆ SetIndex()

auto owl::TLvItem::SetIndex ( int index) -> void

Sets the item index.

Parameters
[in]indexthe item index.
Returns
none.

Definition at line 379 of file listviewctrl.cpp.

◆ SetItemData()

auto owl::TLvItem::SetItemData ( LPARAM param) -> void

Sets the application-defined data.

Parameters
[in]paramthe application-defined data.
Returns
none.

Definition at line 427 of file listviewctrl.cpp.

◆ SetState()

auto owl::TLvItem::SetState ( TListState newState) -> void

Sets the state to use.

Parameters
[in]newStateis the state to use.
Returns
none.

Definition at line 477 of file listviewctrl.cpp.

◆ SetStateImage()

auto owl::TLvItem::SetStateImage ( int stateIndex) -> void

Sets the state image index to use.

Parameters
[in]stateIndexis the state image index to use.
Returns
none.

Definition at line 503 of file listviewctrl.cpp.

◆ SetSubItem()

auto owl::TLvItem::SetSubItem ( int subitemIndex) -> void

Sets the subitem index.

Parameters
[in]subitemIndexthe subitem index.
Returns
none.

Definition at line 403 of file listviewctrl.cpp.

◆ SetText()

auto owl::TLvItem::SetText ( const tstring & text) -> void

Copies the given text into the internal text buffer.

Sets the pszText and cchTextMax members of LVITEM, and enables the LVIF_TEXT flag.

Note
If the string is larger than what can be represented by the class, i.e. INT_MAX, then a TXOwl exception is thrown.
Parameters
[in]textis the string to copy.
Returns
none.

Definition at line 350 of file listviewctrl.cpp.

References _T.

◆ SetTextBuffer()

auto owl::TLvItem::SetTextBuffer ( TCHAR * buffer,
int bufferSize ) -> void

Overrides the internal buffer and assigns an external text buffer.

Sets the pszText and cchTextMax members of LVITEM, and enables the LVIF_TEXT flag.

Note
This function does not copy the text!
Parameters
[in]bufferpointer to a text string buffer to use.
[in]bufferSizespecifies the size of the text string buffer.
Returns
none.

Definition at line 330 of file listviewctrl.cpp.

Member Data Documentation

◆ Buffer

TBuffer owl::TLvItem::Buffer
protected

Definition at line 289 of file listviewctrl.h.


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