| Version: 3.2.8

Public Member Functions | List of all members
wxListItem Class Reference
Class List by Category » Data Structures

`#include <wx/listctrl.h>`

Inheritance diagram for wxListItem:
[legend]

## Detailed Description

This class stores information about a wxListCtrl item or column.

wxListItem is a class which contains information about:

- Zero based item position; see SetId() and GetId().
- Zero based column index; see SetColumn() and GetColumn().
- The label (or header for columns); see SetText() and GetText().
- The zero based index into an image list; see GetImage() and SetImage().
- Application defined data; see SetData() and GetData().
- For columns only: the width of the column; see SetWidth() and GetWidth().
- For columns only: the format of the column; one of `wxLIST_FORMAT_LEFT`, `wxLIST_FORMAT_RIGHT`, `wxLIST_FORMAT_CENTRE`. See SetAlign() and GetAlign().
- The state of the item; see SetState() and GetState(). This is a bitlist of the following flags:
  - `wxLIST_STATE_FOCUSED:` The item has the focus.
  - `wxLIST_STATE_SELECTED:` The item is selected.
  - `wxLIST_STATE_DONTCARE:` No special flags (the value of this constant is 0).
  - `wxLIST_STATE_DROPHILITED:` The item is highlighted to receive a drop event. Win32 only.
  - `wxLIST_STATE_CUT:` The item is in the cut state. Win32 only.
- A mask indicating which state flags are valid; this is a bitlist of the flags reported above for the item state. See SetStateMask() and GetStateMask().
- A mask indicating which fields of this class are valid; see SetMask() and GetMask(). This is a bitlist of the following flags:
  - `wxLIST_MASK_STATE:` The state field is valid.
  - `wxLIST_MASK_TEXT:` The label field is valid.
  - `wxLIST_MASK_IMAGE:` The image field is valid.
  - `wxLIST_MASK_DATA:` The application-defined data field is valid.
  - `wxLIST_MASK_WIDTH:` The column width field is valid.
  - `wxLIST_MASK_FORMAT:` The column format field is valid.

The wxListItem object can also contain item-specific colour and font information: for this you need to call one of SetTextColour(), SetBackgroundColour() or SetFont() functions on it passing it the colour/font to use. If the colour/font is not specified, the default list control colour/font is used.

##

Library: wxCore
Category: Data Structures

See also
  wxListCtrl

## Public Member Functions
| wxListItem ()
| Constructor. More...
void | Clear ()
| Resets the item state to the default. More...
wxListColumnFormat | GetAlign () const
| Returns the alignment for this item. More...
wxColour | GetBackgroundColour () const
| Returns the background colour for this item. More...
int | GetColumn () const
| Returns the zero-based column; meaningful only in report mode. More...
wxUIntPtr | GetData () const
| Returns client data associated with the control. More...
wxFont | GetFont () const
| Returns the font used to display the item. More...
long | GetId () const
| Returns the zero-based item position. More...
int | GetImage () const
| Returns the zero-based index of the image associated with the item into the image list. More...
long | GetMask () const
| Returns a bit mask indicating which fields of the structure are valid. More...
long | GetState () const
| Returns a bit field representing the state of the item. More...
const wxString & | GetText () const
| Returns the label/header text. More...
wxColour | GetTextColour () const
| Returns the text colour. More...
int | GetWidth () const
| Meaningful only for column headers in report mode. More...
void | SetAlign (wxListColumnFormat align)
| Sets the alignment for the item. More...
void | SetBackgroundColour (const wxColour &colBack)
| Sets the background colour for the item. More...
void | SetColumn (int col)
| Sets the zero-based column. More...
void | SetFont (const wxFont &font)
| Sets the font for the item. More...
void | SetId (long id)
| Sets the zero-based item position. More...
void | SetImage (int image)
| Sets the zero-based index of the image associated with the item into the image list. More...
void | SetMask (long mask)
| Sets the mask of valid fields. More...
void | SetState (long state)
| Sets the item state flags (note that the valid state flags are influenced by the value of the state mask, see wxListItem::SetStateMask). More...
void | SetStateMask (long stateMask)
| Sets the bitmask that is used to determine which of the state flags are to be set. More...
void | SetText (const wxString &text)
| Sets the text label for the item. More...
void | SetTextColour (const wxColour &colText)
| Sets the text colour for the item. More...
void | SetWidth (int width)
| Meaningful only for column headers in report mode. More...
void | SetData (long data)
| Sets client data for the item. More...
void | SetData (void *data)
| Sets client data for the item. More...
Public Member Functions inherited from wxObject
| wxObject ()
| Default ctor; initializes to NULL the internal reference data. More...
| wxObject (const wxObject &other)
| Copy ctor. More...
virtual | ~wxObject ()
| Destructor. More...
virtual wxClassInfo * | GetClassInfo () const
| This virtual function is redefined for every class that requires run-time type information, when using the wxDECLARE_CLASS macro (or similar). More...
wxObjectRefData * | GetRefData () const
| Returns the wxObject::m_refData pointer, i.e. the data referenced by this object. More...
bool | IsKindOf (const wxClassInfo *info) const
| Determines whether this class is a subclass of (or the same class as) the given class. More...
bool | IsSameAs (const wxObject &obj) const
| Returns true if this object has the same data pointer as obj. More...
void | Ref (const wxObject &clone)
| Makes this object refer to the data in clone. More...
void | SetRefData (wxObjectRefData *data)
| Sets the wxObject::m_refData pointer. More...
void | UnRef ()
| Decrements the reference count in the associated data, and if it is zero, deletes the data. More...
void | UnShare ()
| This is the same of AllocExclusive() but this method is public. More...
void | operator delete (void *buf)
| The delete operator is defined for debugging versions of the library only, when the identifier `__WXDEBUG__` is defined. More...
void * | operator new (size_t size, const wxString &filename=NULL, int lineNum=0)
| The new operator is defined for debugging versions of the library only, when the identifier `__WXDEBUG__` is defined. More...

## Additional Inherited Members
Protected Member Functions inherited from wxObject
void | AllocExclusive ()
| Ensure that this object's data is not shared with any other object. More...
virtual wxObjectRefData * | CreateRefData () const
| Creates a new instance of the wxObjectRefData-derived class specific to this object and returns it. More...
virtual wxObjectRefData * | CloneRefData (const wxObjectRefData *data) const
| Creates a new instance of the wxObjectRefData-derived class specific to this object and initializes it copying data. More...
Protected Attributes inherited from wxObject
wxObjectRefData * | m_refData
| Pointer to an object which is the object's reference-counted data. More...

## Constructor & Destructor Documentation

## ◆ wxListItem()

wxListItem::wxListItem | ( |  | ) |

Constructor.

## Member Function Documentation

## ◆ Clear()

void wxListItem::Clear | ( |  | ) |

Resets the item state to the default.

## ◆ GetAlign()

wxListColumnFormat wxListItem::GetAlign | ( |  | ) | const

Returns the alignment for this item.

Can be one of `wxLIST_FORMAT_LEFT`, `wxLIST_FORMAT_RIGHT` or `wxLIST_FORMAT_CENTRE`.

## ◆ GetBackgroundColour()

wxColour wxListItem::GetBackgroundColour | ( |  | ) | const

Returns the background colour for this item.

## ◆ GetColumn()

int wxListItem::GetColumn | ( |  | ) | const

Returns the zero-based column; meaningful only in report mode.

## ◆ GetData()

wxUIntPtr wxListItem::GetData | ( |  | ) | const

Returns client data associated with the control.

Please note that client data is associated with the item and not with subitems.

## ◆ GetFont()

wxFont wxListItem::GetFont | ( |  | ) | const

Returns the font used to display the item.

## ◆ GetId()

long wxListItem::GetId | ( |  | ) | const

Returns the zero-based item position.

## ◆ GetImage()

int wxListItem::GetImage | ( |  | ) | const

Returns the zero-based index of the image associated with the item into the image list.

## ◆ GetMask()

long wxListItem::GetMask | ( |  | ) | const

Returns a bit mask indicating which fields of the structure are valid.

Can be any combination of the following values:

- wxLIST_MASK_STATE: GetState is valid.
- wxLIST_MASK_TEXT: GetText is valid.
- wxLIST_MASK_IMAGE: GetImage is valid.
- wxLIST_MASK_DATA: GetData is valid.
- wxLIST_MASK_WIDTH: GetWidth is valid.
- wxLIST_MASK_FORMAT: GetFormat is valid.

## ◆ GetState()

long wxListItem::GetState | ( |  | ) | const

Returns a bit field representing the state of the item.

Can be any combination of:

- wxLIST_STATE_DONTCARE: No special flags (the values of this constant is 0).
- wxLIST_STATE_DROPHILITED: The item is highlighted to receive a drop event. Win32 only.
- wxLIST_STATE_FOCUSED: The item has the focus.
- wxLIST_STATE_SELECTED: The item is selected.
- wxLIST_STATE_CUT: The item is in the cut state. Win32 only.

## ◆ GetText()

const wxString& wxListItem::GetText | ( |  | ) | const

Returns the label/header text.

## ◆ GetTextColour()

wxColour wxListItem::GetTextColour | ( |  | ) | const

Returns the text colour.

## ◆ GetWidth()

int wxListItem::GetWidth | ( |  | ) | const

Meaningful only for column headers in report mode.

Returns the column width.

## ◆ SetAlign()

void wxListItem::SetAlign | ( | wxListColumnFormat | align | ) |

Sets the alignment for the item.

See also GetAlign()

## ◆ SetBackgroundColour()

void wxListItem::SetBackgroundColour | ( | const wxColour & | colBack | ) |

Sets the background colour for the item.

## ◆ SetColumn()

void wxListItem::SetColumn | ( | int | col | ) |

Sets the zero-based column.

Meaningful only in report mode.

## ◆ SetData() [1/2]

void wxListItem::SetData | ( | long | data | ) |

Sets client data for the item.

Please note that client data is associated with the item and not with subitems.

## ◆ SetData() [2/2]

void wxListItem::SetData | ( | void * | data | ) |

Sets client data for the item.

Please note that client data is associated with the item and not with subitems.

## ◆ SetFont()

void wxListItem::SetFont | ( | const wxFont & | font | ) |

Sets the font for the item.

## ◆ SetId()

void wxListItem::SetId | ( | long | id | ) |

Sets the zero-based item position.

## ◆ SetImage()

void wxListItem::SetImage | ( | int | image | ) |

Sets the zero-based index of the image associated with the item into the image list.

## ◆ SetMask()

void wxListItem::SetMask | ( | long | mask | ) |

Sets the mask of valid fields.

See GetMask().

## ◆ SetState()

void wxListItem::SetState | ( | long | state | ) |

Sets the item state flags (note that the valid state flags are influenced by the value of the state mask, see wxListItem::SetStateMask).

See GetState() for valid flag values.

## ◆ SetStateMask()

void wxListItem::SetStateMask | ( | long | stateMask | ) |

Sets the bitmask that is used to determine which of the state flags are to be set.

See also SetState().

## ◆ SetText()

void wxListItem::SetText | ( | const wxString & | text | ) |

Sets the text label for the item.

## ◆ SetTextColour()

void wxListItem::SetTextColour | ( | const wxColour & | colText | ) |

Sets the text colour for the item.

## ◆ SetWidth()

void wxListItem::SetWidth | ( | int | width | ) |

Meaningful only for column headers in report mode.

Sets the column width.