MGUI::CTRL_GRID Class Reference

Grid user interface class. More...

#include <mgui/grid.h>

Inheritance diagram for MGUI::CTRL_GRID:

Inheritance graph
[legend]
List of all members.

Public Types

enum  FORMAT { FORMAT_Left = 0, FORMAT_Right = 1, FORMAT_Center = 2 }
enum  IMAGELISTTYPE { IMAGELISTTYPE_Normal = 0, IMAGELISTTYPE_Small = 1, IMAGELISTTYPE_State = 2 }
enum  STYLE {
  STYLE_AlignLeft = 0x0800, STYLE_AlignTop = 0x0000, STYLE_AutoArrange = 0x0100, STYLE_EditLabels = 0x0200,
  STYLE_NoColumnHeader = 0x4000, STYLE_NoLabelWrap = 0x0080, STYLE_NoScroll = 0x2000, STYLE_NoSortHeader = 0x8000,
  STYLE_OwnerData = 0x1000, STYLE_ShowSelAlways = 0x0008, STYLE_NoGridLines = 0x0001, STYLE_SingleSel = 0x0004,
  STYLE_SortAscending = 0x0010, STYLE_SortDescending = 0x0020
}
enum  VIEWMODE { VIEWMODE_Icon = 0, VIEWMODE_Report = 1, VIEWMODE_SmallIcon = 2, VIEWMODE_List = 3 }

Public Member Functions

void Create (MGUI::LAYOUT_PANE_BASE &ParentPane, int height=10, int width=40, VIEWMODE viewmode=VIEWMODE_Report, STYLE style=STYLE_AlignTop, MGUI::LAYOUT_SIZEALIGN sizealign=MGUI::LAYOUT_SIZEALIGN_Expand)
 CTRL_GRID ()
void DeleteAllColumns ()
void DeleteAllItems ()
void DeleteColumn (int col)
void DeleteItem (int itemnum)
void DeleteItemByData (ID id)
void DeselectAllItems ()
bool EditItem (int itemnum, int column, const UNICODE *initstr, bool selectall=true)
bool EditItem (int itemnum, int column=0, bool selectall=true)
void EnsureVisible (int itemnum, bool PartialOK=false)
int FindItemByData (ID data) const
int FindItemByData (const void *value) const
int GetBottomRow () const
bool GetCellRect (int itemnum, int col, LRECT2D &rect) const
int GetColumnCount () const
bool GetColumnLabel (int column, MISTRING &label) const
ERRVALUE GetColumnOrderArray (SIMPLE_ARRAY< INT32 > &array)
int GetColumnWidth (int column) const
int GetCountPerPage () const
int GetHeadingHeight () const
int GetItemCount () const
MGUI::ID GetItemData (int itemnum) const
int GetNextSelectedItem (int startitem=-1) const
int GetSelectedCount () const
BOOL GetSubItemRect (int item, int colnum, CRect &rect)
int GetTopRow () const
int InsertColumn (int colnum, const MISTRING &string, FORMAT format=FORMAT_Left, int width=-1)
int InsertColumn (int colnum, const UNICODE *string, FORMAT format=FORMAT_Left, int width=-1)
int InsertColumn (int colnum, const char *string, FORMAT format=FORMAT_Left, int width=-1, bool lookup=true)
int InsertItem (int pos, const UNICODE *string)
int InsertItem (int pos, const char *string, bool lookup=true)
int InsertItem (const MISTRING &string)
int InsertItem (const UNICODE *string)
int InsertItem (const char *string, bool lookup=true)
bool IsItemSelected (int itemnum) const
void Redraw (bool updatenow=true)
void RedrawItems (int firstitemnum, int lastitemnum, bool updatenow=true)
bool SetColumnLabel (int column, const UNICODE *label)
void SetColumnOrderArray (SIMPLE_ARRAY< INT32 > &array)
void SetColumnWidth (int column, int width)
void SetExtendedStyle (UINT32 exstyles, UINT32 mask=0)
void SetImageList (IMAGELIST &imagelist, IMAGELISTTYPE listtype=IMAGELISTTYPE_Small, bool shared=false)
int SetItemCount (int NumItems)
void SetItemData (int itemnum, ID value)
void SetItemImage (int itemnum, int imageindex)
void SetItemSelected (int itemnum, bool selected=true)
void SetItemText (int itemnum, int subitem, const UNICODE *string)
void SetItemText (int itemnum, int subitem, const char *string, bool lookup=true)
void SortItems (int column=0, bool bAscending=true)
void Update (int itemnum)
virtual ~CTRL_GRID ()

Protected Member Functions

STYLE GetStyle () const
virtual bool OnBeginLabelEdit (int itemnum, int subitemnum)
virtual void OnClickColumn (int itemnum, int column, KEYSTATE state)
virtual void OnClickItem (int itemnum, int column, KEYSTATE state)
virtual void OnDoubleClickItem (int itemnum, int column, KEYSTATE state)
virtual bool OnDrawItem (CUSTOMDRAW &drawinfo)
virtual bool OnEndLabelEdit (int row, int col, MISTRING &string)
virtual bool OnGetDispInfo (int row, int col, CTRL_GRID::DISPINFO &dispinfo)
virtual void OnItemActivate ()
virtual int OnItemCompare (UINT32 rowitem1, UINT32 rowitem2, int colnum, bool bAscending)
virtual int OnItemCompare (UINT32 rowitem1, UINT32 rowitem2)
virtual void OnItemSelect (int itemnum, int subitemnum)
virtual void OnItemUnselect (int itemnum, int subitemnum)
virtual void OnOwnerDataCacheHint (int from, int to)
virtual void OnRightClickItem (int itemnum, int column, const LPOINT2D &, KEYSTATE state)

Detailed Description

Grid user interface class.

There is also a MGUI::CTRL_GRID_T template which helps eliminate the need for subclassing. See the description for MGUI::CTRL for more information on using templates. There are two general ways to work with lists, "standard" and "owner-data" (virtual). In the standard configuration the list control itself contains all of the data (strings, icons, states) for each list entry. In the "owner-data" configuration, the data is stored outside the list and the OnGetDispInfo and OnOwnerDataCacheHint methods are overridden (or set when using the template) and will be called by the list control when data is needed to be displayed in the list.

Definition at line 174 of file grid.h.


Member Enumeration Documentation

enum MGUI::CTRL_GRID::FORMAT
 

Enumeration values:
FORMAT_Left  LVCFMT_LEFT,.
FORMAT_Right  LVCFMT_RIGHT.
FORMAT_Center  LVCFMT_CENTER,.

Definition at line 178 of file grid.h.

enum MGUI::CTRL_GRID::IMAGELISTTYPE
 

Enumeration values:
IMAGELISTTYPE_Normal  LVSIL_NORMAL.
IMAGELISTTYPE_Small  LVSIL_SMALL.
IMAGELISTTYPE_State  LVSIL_STATE.

Definition at line 208 of file grid.h.

enum MGUI::CTRL_GRID::STYLE
 

Enumeration values:
STYLE_AlignLeft  LVS_ALIGNLEFT,.
STYLE_AlignTop  LVS_ALIGNTOP,.
STYLE_AutoArrange  LVS_AUTOARRANGE,.
STYLE_EditLabels  LVS_EDITLABELS,.
STYLE_NoColumnHeader  LVS_NOCOLUMNHEADER,.
STYLE_NoLabelWrap  LVS_NOLABELWRAP,.
STYLE_NoScroll  LVS_NOSCROLL,.
STYLE_NoSortHeader  LVS_NOSORTHEADER,.
STYLE_OwnerData  LVS_OWNERDATA,.
STYLE_ShowSelAlways  LVS_SHOWSELALWAYS,.
STYLE_NoGridLines 
STYLE_SingleSel  LVS_SINGLESEL,.
STYLE_SortAscending  LVS_SORTASCENDING,.
STYLE_SortDescending  LVS_SORTDESCENDING.

Definition at line 184 of file grid.h.

enum MGUI::CTRL_GRID::VIEWMODE
 

Enumeration values:
VIEWMODE_Icon  LVS_ICON, NOTE: Not implemented in X case.
VIEWMODE_Report  LVS_REPORT,.
VIEWMODE_SmallIcon  LVS_SMALLICON NOTE: Not implemented in X case.
VIEWMODE_List  LVS_LIST,.

Definition at line 201 of file grid.h.


Constructor & Destructor Documentation

MGUI::CTRL_GRID::CTRL_GRID  ) 
 

Constructor.

virtual MGUI::CTRL_GRID::~CTRL_GRID  )  [virtual]
 

Destructor.


Member Function Documentation

void MGUI::CTRL_GRID::Create MGUI::LAYOUT_PANE_BASE ParentPane,
int  height = 10,
int  width = 40,
VIEWMODE  viewmode = VIEWMODE_Report,
STYLE  style = STYLE_AlignTop,
MGUI::LAYOUT_SIZEALIGN  sizealign = MGUI::LAYOUT_SIZEALIGN_Expand
 

Create the control.

Parameters:
ParentPane  Parent pane
height  Height in rows,
width  Width in 'em' characters
viewmode  Initial viewing mode
style  List style

void MGUI::CTRL_GRID::DeleteAllColumns  ) 
 

Delete all columns.

void MGUI::CTRL_GRID::DeleteAllItems  ) 
 

Delete all items.

void MGUI::CTRL_GRID::DeleteColumn int  col  ) 
 

Delete specified column.

void MGUI::CTRL_GRID::DeleteItem int  itemnum  ) 
 

Delete specified item.

void MGUI::CTRL_GRID::DeleteItemByData ID  id  ) 
 

Delete specified item given assigned data value.

void MGUI::CTRL_GRID::DeselectAllItems  ) 
 

Deselect all items.

bool MGUI::CTRL_GRID::EditItem int  itemnum,
int  column,
const UNICODE initstr,
bool  selectall = true
 

Begin editing specified item, starting with specified string.

Returns:
true if successful, false if not.
Parameters:
initstr  String to replace with prior to editing
selectall  Select all existing text so typing will replace

bool MGUI::CTRL_GRID::EditItem int  itemnum,
int  column = 0,
bool  selectall = true
 

Begin editing specified item, starting with currently displayed value.

Returns:
true if successful, false if not.
Parameters:
selectall  Select all existing text so typing will replace

void MGUI::CTRL_GRID::EnsureVisible int  itemnum,
bool  PartialOK = false
 

Ensures that an item is visible.

int MGUI::CTRL_GRID::FindItemByData ID  data  )  const [inline]
 

Find item by matching specified data value as ID.

Returns:
Item number or -1 if none found.

Definition at line 327 of file grid.h.

int MGUI::CTRL_GRID::FindItemByData const void *  value  )  const
 

Find item by matching specified data value as pointer.

Returns:
Item number or -1 if none found.

int MGUI::CTRL_GRID::GetBottomRow  )  const [inline]
 

Get the index (row number) of the bottom-most visible item.

Note: Return value may be greater than number of rows of data if more rows are visible than there are data for.

Definition at line 334 of file grid.h.

bool MGUI::CTRL_GRID::GetCellRect int  itemnum,
int  col,
LRECT2D rect
const
 

Get the bounding rectangle of a single cell.

int MGUI::CTRL_GRID::GetColumnCount  )  const
 

Get number of columns in the list.

bool MGUI::CTRL_GRID::GetColumnLabel int  column,
MISTRING label
const
 

Get the label for a column.

Returns:
true if successful, false otherwise

ERRVALUE MGUI::CTRL_GRID::GetColumnOrderArray SIMPLE_ARRAY< INT32 > &  array  ) 
 

Get the order of columns in the list.

Columns can be reordered by dragging them around if you call SetExtendedStyle() with LVS_EX_HEADERDRAGDROP

int MGUI::CTRL_GRID::GetColumnWidth int  column  )  const
 

Get the width of a column in pixels.

int MGUI::CTRL_GRID::GetCountPerPage  )  const
 

Get number of items that can fit vertically in the visible area of control (in report mode only).

int MGUI::CTRL_GRID::GetHeadingHeight  )  const
 

Get height of heading in pixels.

int MGUI::CTRL_GRID::GetItemCount  )  const
 

Get number of items in list.

MGUI::ID MGUI::CTRL_GRID::GetItemData int  itemnum  )  const
 

Get data value associated with item.

int MGUI::CTRL_GRID::GetNextSelectedItem int  startitem = -1  )  const
 

Get next selected item in list.

Returns:
Index of next item or -1 if no more items.
Parameters:
startitem  Starting item for search, starting item is excluded

int MGUI::CTRL_GRID::GetSelectedCount  )  const
 

Get number of selected items.

STYLE MGUI::CTRL_GRID::GetStyle  )  const [inline, protected]
 

Definition at line 575 of file grid.h.

BOOL MGUI::CTRL_GRID::GetSubItemRect int  item,
int  colnum,
CRect &  rect
 

Return the rectangle (in client coordinates) of a given row/column in the list Only exists in MFC version because it returns an MFC CRect.

int MGUI::CTRL_GRID::GetTopRow  )  const
 

Get the index (row number) of the top-most visible item.

int MGUI::CTRL_GRID::InsertColumn int  colnum,
const MISTRING string,
FORMAT  format = FORMAT_Left,
int  width = -1
[inline]
 

Insert new column with label from MISTRING;.

Parameters:
colnum  Column number and subitem
string  String for column heading
format  Column format
width  Width of column in PIXELS

Definition at line 426 of file grid.h.

int MGUI::CTRL_GRID::InsertColumn int  colnum,
const UNICODE string,
FORMAT  format = FORMAT_Left,
int  width = -1
 

Insert new column with label from UNICODE* string.

Parameters:
colnum  Column number and subitem
string  String for column heading
format  Column format
width  Width of column in PIXELS

int MGUI::CTRL_GRID::InsertColumn int  colnum,
const char *  string,
FORMAT  format = FORMAT_Left,
int  width = -1,
bool  lookup = true
 

Insert new column with label from resource or ASCII string.

Parameters:
colnum  Column number and subitem
string  String for resource lookup or to set
format  Column format
width  Width of column in PIXELS
lookup  'true' to perform resource lookup, false to use string as-is

int MGUI::CTRL_GRID::InsertItem int  pos,
const UNICODE string
 

Insert new item at specified position with Unicode string.

Returns:
Item number of inserted item if successful, < 0 if error.
Parameters:
pos  Item position in list
string  Item string

int MGUI::CTRL_GRID::InsertItem int  pos,
const char *  string,
bool  lookup = true
 

Insert new item at specified position from resource or ASCII string.

Returns:
Item number of inserted item if successful, < 0 if error.
Parameters:
pos  Item position in list
string  String for resource lookup or to set
lookup  'true' to perform resource lookup, false to use string as-is

int MGUI::CTRL_GRID::InsertItem const MISTRING string  )  [inline]
 

Insert new item with Unicode string.

Returns:
Item number of inserted item if successful, < 0 if error.
Parameters:
string  Item string

Definition at line 448 of file grid.h.

int MGUI::CTRL_GRID::InsertItem const UNICODE string  ) 
 

Insert new item with Unicode string.

Returns:
Item number of inserted item if successful, < 0 if error.
Parameters:
string  Item string

int MGUI::CTRL_GRID::InsertItem const char *  string,
bool  lookup = true
 

Insert new item from resource or ASCII string.

Returns:
Item number of inserted item if successful, < 0 if error.
Parameters:
string  String for resource lookup or to set
lookup  'true' to perform resource lookup, false to use string as-is

bool MGUI::CTRL_GRID::IsItemSelected int  itemnum  )  const
 

Determine if specified item is currently "selected".

Returns:
'true' if selected, 'false' if not.

virtual bool MGUI::CTRL_GRID::OnBeginLabelEdit int  itemnum,
int  subitemnum
[protected, virtual]
 

Called when user clicks on label to begin editing.

Returns:
'false' if editing is NOT allowed or 'true' if editing is allowed. Default implementation always returns 'true' if the grid was created with STYLE_EditLabels or 'false' if not.

virtual void MGUI::CTRL_GRID::OnClickColumn int  itemnum,
int  column,
KEYSTATE  state
[protected, virtual]
 

Called when user clicks on column heading.

virtual void MGUI::CTRL_GRID::OnClickItem int  itemnum,
int  column,
KEYSTATE  state
[protected, virtual]
 

Called when user left-clicks on a list item.

virtual void MGUI::CTRL_GRID::OnDoubleClickItem int  itemnum,
int  column,
KEYSTATE  state
[protected, virtual]
 

Called when user double-left-clicks on a list item.

virtual bool MGUI::CTRL_GRID::OnDrawItem CUSTOMDRAW drawinfo  )  [protected, virtual]
 

Called before an item is drawn.

Override if you want to do the drawing yourself. Should return true if you did all the drawing. Return false to let the base class draw the item.

virtual bool MGUI::CTRL_GRID::OnEndLabelEdit int  row,
int  col,
MISTRING string
[protected, virtual]
 

Called when user clicks on label to begin editing.

Returns:
'true' if to accept changes or 'false' to reject changes. Default implementation always returns 'true' if the grid was created with STYLE_EditLabels or 'false' if not.

virtual bool MGUI::CTRL_GRID::OnGetDispInfo int  row,
int  col,
CTRL_GRID::DISPINFO dispinfo
[protected, virtual]
 

Called by list to request information stored by owner rather than list.

Derived implementation should return true if it actually filled in anything. Return false to behave as if OnGetDispInfo wasn't overridden.

virtual void MGUI::CTRL_GRID::OnItemActivate  )  [protected, virtual]
 

Called when an item is "activated" (normally via a double click).

virtual int MGUI::CTRL_GRID::OnItemCompare UINT32  rowitem1,
UINT32  rowitem2,
int  colnum,
bool  bAscending
[protected, virtual]
 

Called by SortItems() to compare items.

Should return < 0 if rowitem1 should precede rowitem2 and > 0 if rowitem1 should follow rowitem2 and 0 if the two items are equivalent. if bAscending is false, you should reverse the order.

virtual int MGUI::CTRL_GRID::OnItemCompare UINT32  rowitem1,
UINT32  rowitem2
[protected, virtual]
 

Called by SortItems() to compare items.

Should return < 0 if rowitem1 should precede rowitem2 and > 0 if rowitem1 should follow rowitem2 and 0 if the two items are equivalent. XXX DEPRECATED. Don't override this, override the one that takes a column number and direction

virtual void MGUI::CTRL_GRID::OnItemSelect int  itemnum,
int  subitemnum
[protected, virtual]
 

Called when an item is "selected".

virtual void MGUI::CTRL_GRID::OnItemUnselect int  itemnum,
int  subitemnum
[protected, virtual]
 

Called when an item is "unselected".

virtual void MGUI::CTRL_GRID::OnOwnerDataCacheHint int  from,
int  to
[protected, virtual]
 

Called for owner-data list to provide hints about what to cache.

virtual void MGUI::CTRL_GRID::OnRightClickItem int  itemnum,
int  column,
const LPOINT2D ,
KEYSTATE  state
[protected, virtual]
 

Called when user right-clicks on a list item.

void MGUI::CTRL_GRID::Redraw bool  updatenow = true  ) 
 

Force the control to repaint all items.

void MGUI::CTRL_GRID::RedrawItems int  firstitemnum,
int  lastitemnum,
bool  updatenow = true
 

Force the control to repaint a range of items.

bool MGUI::CTRL_GRID::SetColumnLabel int  column,
const UNICODE label
 

Set column label.

Returns:
true if successful, false otherwise

void MGUI::CTRL_GRID::SetColumnOrderArray SIMPLE_ARRAY< INT32 > &  array  ) 
 

Set the order of columns within the list.

void MGUI::CTRL_GRID::SetColumnWidth int  column,
int  width
 

Set the width of a column.

The width can be in pixels or one of the constants LVSCW_AUTOSIZE or LVSCW_AUTOSIZE_USE_HEADER as described in LVM_SETCOLUMNWIDTH in the Platform SDK documentation.

void MGUI::CTRL_GRID::SetExtendedStyle UINT32  exstyles,
UINT32  mask = 0
 

Set extended styles. (MFC version only).

Parameters:
exstyles  LVS_EX_...
mask  Mask for styles to change, 0 to set all specified

void MGUI::CTRL_GRID::SetImageList IMAGELIST imagelist,
IMAGELISTTYPE  listtype = IMAGELISTTYPE_Small,
bool  shared = false
 

Set image list.

Parameters:
imagelist  Image list
listtype  Type of image list, IMAGELISTTYPE_Normal, IMAGELISTTYPE_Small or IMAGELISTTYPE_State
shared  'true' if image list is shared, 'false' if control should take ownership

int MGUI::CTRL_GRID::SetItemCount int  NumItems  ) 
 

Set number of items in list.

void MGUI::CTRL_GRID::SetItemData int  itemnum,
ID  value
 

Set application-specific data to associate with list item.

Parameters:
itemnum  Item number
value  Value to associate with item

void MGUI::CTRL_GRID::SetItemImage int  itemnum,
int  imageindex
 

Set the image index to use for a givem item.

This only handles column 0, and currently only for MFC Pass -1 for imageindex to have no icon imageindex is a 0-based index into the IMAGELIST set via SetImageList()

void MGUI::CTRL_GRID::SetItemSelected int  itemnum,
bool  selected = true
 

Set whether item is 'selected or not.

Parameters:
itemnum  Item number

void MGUI::CTRL_GRID::SetItemText int  itemnum,
int  subitem,
const UNICODE string
 

Set item or subitem text from Unicode string.

Parameters:
itemnum  Item number
subitem  Sub item, 0 for item
string  Item or subitem string

void MGUI::CTRL_GRID::SetItemText int  itemnum,
int  subitem,
const char *  string,
bool  lookup = true
 

Set item or subitem text from resource or ASCII string.

Parameters:
itemnum  Item number
subitem  Sub item, 0 for item
string  String for resource lookup or to set
lookup  'true' to perform resource lookup, false to use string as-is

void MGUI::CTRL_GRID::SortItems int  column = 0,
bool  bAscending = true
 

Sort the data in the list on a given column.

Parameters:
column  Column to sort on

void MGUI::CTRL_GRID::Update int  itemnum  ) 
 

Force the control to repaint a specified item.


The documentation for this class was generated from the following file:
Generated on Tue Dec 14 13:20:46 2004 for TNTsdk by  doxygen 1.3.8-20040913