[Classes] [Prev] [Next] [Methods]

CTreeEvent

Methods Index

Heritage
Description
Usage
Enum
Protected Data Members
Constructor Methods
Access Methods
Mouse Click Methods
Private Methods

CTreeEvent


Heritage

Superclass: None

Subclass: None


Description

Encapsulates events sent by CTreeView, or on behalf of CTreeView, up the chain of command. All events are associated with the TreeEventCmd command.


Usage

To receive tree events, you must implement the DoCommand() method at some level of your chain of command: view, window, document, or application. If the command equals TreeEventCmd, the data pointer will point to a CTreeEvent object, which contains the type of tree event and any data associated with the event. The DoCommand() method below, implemented at the window level, intercepts mouse clicks on a particular field of a tree item and changes the value of that field.

void CTreeWin::DoCommand(long theCommand,void* theData)
{
// Is this a tree event?
if(theCommand == TreeEventCmd)
{
CTreeEvent* anEvent = (CTreeEvent*)theData;
CTreeItem* anItem = anEvent->GetTreeItem();

// Was there an item associated with the event?
if(anItem != NULL)
{
switch(anEvent->GetType())
{
case CTreeEvent::MouseClick:
// If we hit the second tab, toggle
// the check mark
// using field manipulation routines
// from CTabSet.
if(anEvent->GetTabHit() ==
kCheckTab)
{
anItem->
SetString(CTabSet::ToggleField(
anItem->GetString(), kCheckTab,
"check", "")
);
anEvent->GetTree()->
InvalidateItem(anItem);
}
break;
}
}
}
else CWindow::DoCommand(theCommand, theData);
}

Enum

EventType

FocusIn,
FocusOut,
SelectionChanged,
Expand,
Collapse,
MouseClick,
TitleMouseClick,
MouseDoubleClick, /*Only on leaf*/
MouseClickUp,
MouseMove,

EventType gives the type of tree event.


Protected Data Members

EventType itsType; Type of tree event
CTreeView* itsTree; CTreeView sending the event
CTreeItem* itsTreeItem; Associated tree item, NULL if none

CPoint itsPoint; Global mouse coordinates of event
short itsButton; Mouse button clicked by the user
BOOLEAN itsIsShift; Shift key status
BOOLEAN itsIsControl; Control key status
size_t itsTabHit; Tab field within an item.

Valid for CTreeEvent::MouseClick or CTreeEvent::TitleMouseClick only.

Constructor Methods

CTreeEvent(EventType theType, CTreeView* theTree, 
CTreeItem* theTreeItem);
CTreeEvent(EventType theType, CTreeView* theTree, 
const CPoint& thePoint, short theButton,
BOOLEAN theIsShift, BOOLEAN theIsControl);

Access Methods

EventType GetType() const;
const CTreeView* GetTree() const;
CTreeView* GetTree();
const CTreeItem* GetTreeItem();
CTreeItem* GetTreeItem();

Mouse Click Methods

The following methods are valid only for MouseClicks.

CPoint GetPoint() const;
short GetButton() const;
BOOLEAN GetIsShift() const;
BOOLEAN GetIsControl() const;
size_t GetTabHit() const;

Private Methods



[Classes] [Prev] [Next] [Methods]

support@xvt.com


Visit our online help desk for tech support

Copyright © 2009, Providence Software Solutions Inc. All rights reserved.