doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ToggleListView Class Reference

A simple list view that supports a toggle button. More...

#include <ToggleListView.h>

Inheritance diagram for ToggleListView:
StageView

Public Types

enum  { TOGGLE_STATE_DISABLED = 0, TOGGLE_STATE_ON, TOGGLE_STATE_OFF }
 Enumeration that defines the possible states of the toggle button. More...
 

Public Member Functions

void SetToggleIcons (LPCSTR disabled=NULL, LPCSTR on=NULL, LPCSTR off=NULL)
 Sets the tree icons to dispay for each of the three states. More...
 
void SetToggleState (int index, int toggleState, bool notify=false)
 Sets the state of an item in the list. More...
 
int GetToggleState (int index)
 Gets the state of an item in the list. More...
 
afx_msg int OnCreate (LPCREATESTRUCT lpCreateStruct)
 Called as the window is being created and initializes icons and window styles. More...
 
afx_msg void OnSize (UINT nType, int cx, int cy)
 Called when the window is being resized. More...
 
afx_msg void MeasureItem (LPMEASUREITEMSTRUCT lpMeasureItemStruct)
 Returns the size of each item in the toggle list. More...
 
afx_msg void OnNMClick (NMHDR *pNMHDR, LRESULT *pResult)
 Toggles the state of an item when the user clicks in the window. More...
 

Protected Member Functions

 ToggleListView ()
 Protected constructor used by dynamic creation. More...
 
virtual ~ToggleListView ()
 Destructor. More...
 
virtual BOOL PreCreateWindow (CREATESTRUCT &cs)
 Sets some window styles before the window is created. More...
 
virtual void DrawItem (LPDRAWITEMSTRUCT lpDrawItemStruct)
 Responsible for drawing each list item. More...
 
virtual void OnStateChanged (int index, int toggleState)
 
void Draw3dRect (HDC hDC, RECT *rect, HBRUSH topLeft, HBRUSH bottomRight)
 Draws a 3d rectangle using the given brushes this code was taken from the gui editor. More...
 

Protected Attributes

HICON onIcon
 
HICON offIcon
 
HICON disabledIcon
 

Detailed Description

A simple list view that supports a toggle button.

ToggleListView is a simple extension to the CListView class that support a toggle button. It is limited to a single column and always uses full row select. The toggle state is stored in the data for each item so users of this class should not attempt to use the data field for storage. lparam can be used instead.

Definition at line 39 of file ToggleListView.h.

Member Enumeration Documentation

anonymous enum

Enumeration that defines the possible states of the toggle button.

Enumerator
TOGGLE_STATE_DISABLED 
TOGGLE_STATE_ON 
TOGGLE_STATE_OFF 

Definition at line 45 of file ToggleListView.h.

Constructor & Destructor Documentation

ToggleListView::ToggleListView ( )
protected

Protected constructor used by dynamic creation.

Definition at line 50 of file ToggleListView.cpp.

ToggleListView::~ToggleListView ( )
protectedvirtual

Destructor.

Definition at line 59 of file ToggleListView.cpp.

Member Function Documentation

void ToggleListView::Draw3dRect ( HDC  hDC,
RECT *  rect,
HBRUSH  topLeft,
HBRUSH  bottomRight 
)
protected

Draws a 3d rectangle using the given brushes this code was taken from the gui editor.

Definition at line 288 of file ToggleListView.cpp.

void ToggleListView::DrawItem ( LPDRAWITEMSTRUCT  lpDrawItemStruct)
protectedvirtual

Responsible for drawing each list item.

Definition at line 214 of file ToggleListView.cpp.

int ToggleListView::GetToggleState ( int  index)

Gets the state of an item in the list.

Parameters
indexIndex of the item of which to retreive the state.

Definition at line 115 of file ToggleListView.cpp.

void ToggleListView::MeasureItem ( LPMEASUREITEMSTRUCT  lpMeasureItemStruct)

Returns the size of each item in the toggle list.

Definition at line 162 of file ToggleListView.cpp.

int ToggleListView::OnCreate ( LPCREATESTRUCT  lpCreateStruct)

Called as the window is being created and initializes icons and window styles.

Definition at line 126 of file ToggleListView.cpp.

void ToggleListView::OnNMClick ( NMHDR *  pNMHDR,
LRESULT *  pResult 
)

Toggles the state of an item when the user clicks in the window.

Definition at line 169 of file ToggleListView.cpp.

void ToggleListView::OnSize ( UINT  nType,
int  cx,
int  cy 
)

Called when the window is being resized.

Definition at line 152 of file ToggleListView.cpp.

virtual void ToggleListView::OnStateChanged ( int  index,
int  toggleState 
)
inlineprotectedvirtual

Reimplemented in StageView.

Definition at line 76 of file ToggleListView.h.

BOOL ToggleListView::PreCreateWindow ( CREATESTRUCT &  cs)
protectedvirtual

Sets some window styles before the window is created.

Reimplemented in StageView.

Definition at line 203 of file ToggleListView.cpp.

void ToggleListView::SetToggleIcons ( LPCSTR  disabled = NULL,
LPCSTR  on = NULL,
LPCSTR  off = NULL 
)

Sets the tree icons to dispay for each of the three states.

Sets the icons to display for each of the three states. The values passed in are the resource name that can be generated using MAKEINTRESOUCE. If the value passed in is NULL then an icon will not be drawn for that state.

Parameters
disabledThe icon to draw when the state is TOGGLE_STATE_DISABLED.
onThe icon to draw when the state is TOGGLE_STATE_ON.
offThe icon to draw when the state is TOGGLE_STATE_OFF.

Definition at line 73 of file ToggleListView.cpp.

void ToggleListView::SetToggleState ( int  index,
int  toggleState,
bool  notify = false 
)

Sets the state of an item in the list.

Parameters
indexIndex of the item whose state should be changed.
toggleStateThe state to set
notifyDetermines if the notification method OnStateChanged should be called. OnStateChanged will also not be called if the state has not changed.

Definition at line 100 of file ToggleListView.cpp.

Member Data Documentation

HICON ToggleListView::disabledIcon
protected

Definition at line 83 of file ToggleListView.h.

HICON ToggleListView::offIcon
protected

Definition at line 82 of file ToggleListView.h.

HICON ToggleListView::onIcon
protected

Definition at line 81 of file ToggleListView.h.


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