Vaca::TreeView Class Reference

#include <TreeView.h>

Inheritance diagram for Vaca::TreeView:

Vaca::Widget Vaca::Component Vaca::Referenceable Vaca::NonCopyable

List of all members.


Detailed Description

Handles a TreeView control.

A TreeView (internally) has a root TreeNode that is the parent of the first-level's nodes.

Public Types

typedef TreeViewIterator iterator
 Iterator to go through all the nodes of the tree (it does a deep scan).

Public Member Functions

 TreeView (Widget *parent, Style style=TreeViewStyle)
virtual ~TreeView ()
iterator begin ()
iterator end ()
bool isDragAndDrop ()
void setDragAndDrop (bool state)
void setNormalImageList (const ImageList &imageList)
 Sets the ImageList of icons to be used in the TreeNode.
void setStateImageList (const ImageList &imageList)
TreeNodegetRootNode ()
 Returns the root node of the tree.
void addNode (TreeNode *node)
 Adds a node in the root of the tree.
void removeNode (TreeNode *node)
 Removes the specified node whatever it's inside the tree.
TreeNodegetSelectedNode ()
 Returns the selected node of the tree.
void setSelectedNode (TreeNode *node)
 Selects the node in the tree.
virtual void setBgColor (const Color &color)
 Sets the background color.

Public Attributes

Signal1< void, TreeViewEvent & > BeforeExpand
Signal1< void, TreeViewEvent & > BeforeCollapse
Signal1< void, TreeViewEvent & > BeforeSelect
Signal1< void, TreeViewEvent & > BeforeLabelEdit
Signal1< void, TreeViewEvent & > AfterExpand
Signal1< void, TreeViewEvent & > AfterCollapse
Signal1< void, TreeViewEvent & > AfterSelect
Signal1< void, TreeViewEvent & > AfterLabelEdit

Protected Member Functions

virtual void onMouseMove (MouseEvent &ev)
 The mouse is moving inside the Widget's client area.
virtual void onMouseUp (MouseEvent &ev)
 The mouse is inside the Widget and the user release a mouse's button.
virtual void onBeforeExpand (TreeViewEvent &ev)
 You can cancel this event (Event::cancel).
virtual void onBeforeCollapse (TreeViewEvent &ev)
 You can cancel this event (Event::cancel).
virtual void onBeforeSelect (TreeViewEvent &ev)
virtual void onBeforeLabelEdit (TreeViewEvent &ev)
 You can cancel this event to cancel the label editing.
virtual void onAfterExpand (TreeViewEvent &ev)
virtual void onAfterCollapse (TreeViewEvent &ev)
virtual void onAfterSelect (TreeViewEvent &ev)
virtual void onAfterLabelEdit (TreeViewEvent &ev)
 You can cancel this event to avoid to change the item text.
virtual bool onReflectedNotify (LPNMHDR lpnmhdr, LRESULT &lResult)
 This method can be used to handle notifications (WM_NOTIFY(W32)) reflected from the parent.
virtual bool wndProc (UINT message, WPARAM wParam, LPARAM lParam, LRESULT &lResult)
 The customized window procedure for this particular widget.

Private Attributes

TreeNode m_root
bool m_deleted
bool m_isDragging
String m_tmpBuffer
ImageList m_dragImage
ImageList m_normalImageList
ImageList m_stateImageList

Friends

class TreeNode


Member Typedef Documentation

Iterator to go through all the nodes of the tree (it does a deep scan).


Constructor & Destructor Documentation

TreeView::TreeView ( Widget parent,
Style  style = TreeViewStyle 
)

TreeView::~TreeView (  )  [virtual]


Member Function Documentation

TreeView::iterator TreeView::begin (  ) 

TreeView::iterator TreeView::end (  ) 

bool TreeView::isDragAndDrop (  ) 

void TreeView::setDragAndDrop ( bool  state  ) 

void TreeView::setNormalImageList ( const ImageList imageList  ) 

Sets the ImageList of icons to be used in the TreeNode.

Parameters:
imageList The ImageList to be used. It will not be deleted.

void TreeView::setStateImageList ( const ImageList imageList  ) 

TreeNode * TreeView::getRootNode (  ) 

Returns the root node of the tree.

The root node is never displayed.

void TreeView::addNode ( TreeNode node  ) 

Adds a node in the root of the tree.

void TreeView::removeNode ( TreeNode node  ) 

Removes the specified node whatever it's inside the tree.

Warning:
The node must be inside the tree.

TreeNode * TreeView::getSelectedNode (  ) 

Returns the selected node of the tree.

Returns:
The selected node. NULL if there is no selected item in the tree.

void TreeView::setSelectedNode ( TreeNode node  ) 

Selects the node in the tree.

The node must be a children of the tree.

void TreeView::setBgColor ( const Color color  )  [virtual]

Sets the background color.

This color is used on WM_ERASEBKGND and WM_COLORCTL* messages. The default value is the System::getColor(COLOR_3DFACE).

See also:
getBgColor

Reimplemented from Vaca::Widget.

void TreeView::onMouseMove ( MouseEvent ev  )  [protected, virtual]

The mouse is moving inside the Widget's client area.

If you capture the mouse, you should use the System::getCursorPos function to get the cursor position when it's outside the widget's client area.

Reimplemented from Vaca::Widget.

void TreeView::onMouseUp ( MouseEvent ev  )  [protected, virtual]

The mouse is inside the Widget and the user release a mouse's button.

Win32 Specific:
This event is generated when WM_LBUTTONUP(W32), WM_MBUTTONUP(W32), or WM_RBUTTONUP(W32) message is received.

Reimplemented from Vaca::Widget.

void TreeView::onBeforeExpand ( TreeViewEvent ev  )  [protected, virtual]

You can cancel this event (Event::cancel).

void TreeView::onBeforeCollapse ( TreeViewEvent ev  )  [protected, virtual]

You can cancel this event (Event::cancel).

void TreeView::onBeforeSelect ( TreeViewEvent ev  )  [protected, virtual]

void TreeView::onBeforeLabelEdit ( TreeViewEvent ev  )  [protected, virtual]

You can cancel this event to cancel the label editing.

void TreeView::onAfterExpand ( TreeViewEvent ev  )  [protected, virtual]

void TreeView::onAfterCollapse ( TreeViewEvent ev  )  [protected, virtual]

void TreeView::onAfterSelect ( TreeViewEvent ev  )  [protected, virtual]

void TreeView::onAfterLabelEdit ( TreeViewEvent ev  )  [protected, virtual]

You can cancel this event to avoid to change the item text.

bool TreeView::onReflectedNotify ( LPNMHDR  lpnmhdr,
LRESULT &  lResult 
) [protected, virtual]

This method can be used to handle notifications (WM_NOTIFY(W32)) reflected from the parent.

Parameters:
lpnmhdr Information about the notification message.
lResult Result to return by the wndProc method.
Returns:
False if it doesn't use the notification.

Reimplemented from Vaca::Widget.

bool TreeView::wndProc ( UINT  message,
WPARAM  wParam,
LPARAM  lParam,
LRESULT &  lResult 
) [protected, virtual]

The customized window procedure for this particular widget.

Win32 Specific:
This is called from Widget::globalWndProc. It should returns true when the defWndProc doesn't need to be called.

This method is called to intercept any message after the creation of the widget, and before the destruction. To intercept messages outside that range (before creation, and after disposition), you should customize defWndProc().

This method mainly converts a message to a event:

For reflection, it does:

  • When WM_COMMAND is received, the onReflectedCommand() event of the child is called when it is a WM_COMMAND from a control, or the onCommand() event of this widget is called when the command come from a menu or an accelerator.
  • When WM_NOTIFY is received, the onReflectedNotify() event of the child is called.
  • When WM_DRAWITEM is received, the onReflectedDrawItem() event of the child is called.

How to extend widget::wndProc method?

 class MyWidget : public Widget {
   ...
 protected:
   virtual bool wndProc(UINT message, WPARAM wParam, LPARAM lParam, LRESULT& lResult)
   {
     if (Widget::wndProc(message, wParam, lParam, lResult))
       return true;

     // ...Your code here...

     return false;
   }
   ...
 }

Returns:
True if the message was used and lResult contains a valid value to be returned by globalWndProc.
See also:
globalWndProc, getGlobalWndProc, defWndProc

Reimplemented from Vaca::Widget.


Friends And Related Function Documentation

friend class TreeNode [friend]


Member Data Documentation

bool Vaca::TreeView::m_deleted [private]