From 302e341409d918a232cd2ec25f2c533c27eb9011 Mon Sep 17 00:00:00 2001 From: guigues Date: Fri, 28 Mar 2008 13:42:17 +0000 Subject: [PATCH] Started the devel of a wx package browser --- kernel/src/CMakeLists.txt | 4 +- .../wx/treemultictrl/TreeMultiItemBase.cpp | 76 + .../wx/treemultictrl/TreeMultiItemBase.h | 217 ++ .../wx/treemultictrl/TreeMultiItemNode.cpp | 187 ++ .../wx/treemultictrl/TreeMultiItemNode.h | 106 + .../wx/treemultictrl/TreeMultiItemRoot.cpp | 46 + .../wx/treemultictrl/TreeMultiItemRoot.h | 42 + .../wx/treemultictrl/TreeMultiItemWindow.cpp | 97 + .../wx/treemultictrl/TreeMultiItemWindow.h | 95 + .../wx/treemultictrl/default_checked_icon.xpm | 273 +++ .../wx/treemultictrl/default_collapse.xpm | 31 + .../wx/treemultictrl/default_expand.xpm | 31 + .../treemultictrl/default_tristate_icon.xpm | 273 +++ .../treemultictrl/default_unchecked_icon.xpm | 273 +++ .../wx/treemultictrl/linux_collapse.xpm | 31 + .../wx/treemultictrl/linux_expand.xpm | 31 + .../wx/treemultictrl/mac_collapse.xpm | 25 + .../wx/treemultictrl/mac_expand.xpm | 25 + .../ThirdParty/wx/treemultictrl/tmcimages.h | 42 + .../wx/treemultictrl/win_checked_icon.xpm | 273 +++ .../wx/treemultictrl/win_tristate_icon.xpm | 273 +++ .../wx/treemultictrl/win_unchecked_icon.xpm | 273 +++ .../wx/treemultictrl/wxTreeMultiCtrl.cpp | 1985 +++++++++++++++++ .../wx/treemultictrl/wxTreeMultiCtrl.h | 1218 ++++++++++ .../wx/treemultictrl/wxTreeMultiEvent.cpp | 40 + .../wx/treemultictrl/wxTreeMultiEvent.h | 114 + kernel/src/bbtkFactory.h | 9 +- kernel/src/bbtkWxGUIPackageBrowser.cxx | 199 ++ kernel/src/bbtkWxGUIPackageBrowser.h | 125 ++ 29 files changed, 6411 insertions(+), 3 deletions(-) create mode 100644 kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemBase.cpp create mode 100644 kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemBase.h create mode 100644 kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemNode.cpp create mode 100644 kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemNode.h create mode 100644 kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemRoot.cpp create mode 100644 kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemRoot.h create mode 100644 kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemWindow.cpp create mode 100644 kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemWindow.h create mode 100644 kernel/src/ThirdParty/wx/treemultictrl/default_checked_icon.xpm create mode 100644 kernel/src/ThirdParty/wx/treemultictrl/default_collapse.xpm create mode 100644 kernel/src/ThirdParty/wx/treemultictrl/default_expand.xpm create mode 100644 kernel/src/ThirdParty/wx/treemultictrl/default_tristate_icon.xpm create mode 100644 kernel/src/ThirdParty/wx/treemultictrl/default_unchecked_icon.xpm create mode 100644 kernel/src/ThirdParty/wx/treemultictrl/linux_collapse.xpm create mode 100644 kernel/src/ThirdParty/wx/treemultictrl/linux_expand.xpm create mode 100644 kernel/src/ThirdParty/wx/treemultictrl/mac_collapse.xpm create mode 100644 kernel/src/ThirdParty/wx/treemultictrl/mac_expand.xpm create mode 100644 kernel/src/ThirdParty/wx/treemultictrl/tmcimages.h create mode 100644 kernel/src/ThirdParty/wx/treemultictrl/win_checked_icon.xpm create mode 100644 kernel/src/ThirdParty/wx/treemultictrl/win_tristate_icon.xpm create mode 100644 kernel/src/ThirdParty/wx/treemultictrl/win_unchecked_icon.xpm create mode 100644 kernel/src/ThirdParty/wx/treemultictrl/wxTreeMultiCtrl.cpp create mode 100644 kernel/src/ThirdParty/wx/treemultictrl/wxTreeMultiCtrl.h create mode 100644 kernel/src/ThirdParty/wx/treemultictrl/wxTreeMultiEvent.cpp create mode 100644 kernel/src/ThirdParty/wx/treemultictrl/wxTreeMultiEvent.h create mode 100644 kernel/src/bbtkWxGUIPackageBrowser.cxx create mode 100644 kernel/src/bbtkWxGUIPackageBrowser.h diff --git a/kernel/src/CMakeLists.txt b/kernel/src/CMakeLists.txt index 0038ad9..23d4dd5 100644 --- a/kernel/src/CMakeLists.txt +++ b/kernel/src/CMakeLists.txt @@ -151,9 +151,11 @@ ENDIF(NOT BBTK_INSTALL_NO_DEVELOPMENT) # Symbols must be exported (Windows) ADD_DEF(BBTK_EXPORT_SYMBOLS) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty) + #----------------------------------------------------------------------------- # Sources files -FILE(GLOB SOURCES "." "*.cxx" "*.cpp") +FILE(GLOB SOURCES "." "*.cxx" "*.cpp" "ThirdParty/wx/treemultictrl/*.cpp") FILE(GLOB SOURCES_H "." "*.h" ) #----------------------------------------------------------------------------- # lib definition diff --git a/kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemBase.cpp b/kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemBase.cpp new file mode 100644 index 0000000..edbeac0 --- /dev/null +++ b/kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemBase.cpp @@ -0,0 +1,76 @@ +//--------------------------------------------------------------------------- +// $RCSfile: TreeMultiItemBase.cpp,v $ +// $Source: /cvs/creatis/bbtk/kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemBase.cpp,v $ +// $Revision: 1.1 $ +// $Date: 2008/03/28 13:42:18 $ +//--------------------------------------------------------------------------- +// Author: Jorgen Bodde +// Copyright: (c) Jorgen Bodde +// License: wxWidgets License +//--------------------------------------------------------------------------- + +#ifdef __GNUG__ + #pragma implementation "TreeMultiItemBase.cpp" +#endif + +/* for compilers that support precompilation + includes "wx/wx.h" */ + +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/treemultictrl/TreeMultiItemBase.h" +#include "wx/treemultictrl/TreeMultiItemNode.h" + +/** TreeMultiItemBase + * This class is the node of the whole tree. All the other classes in the + * tree descend from this node. It contains the type of the class without + * using RTTI. NOTE: this class cannot be constructed directly + */ + +TreeMultiItemBase::TreeMultiItemBase(TreeMultiItemNode *parent) + : _excluded(false) + + , _x(0) + , _y(0) + , _width(0) + , _height(0) + , _parent(parent) + , m_Selected(false) +#if(CHECKBOXVIEW) + , _checkbox(false) + , _checkboxState(0) +#endif +{ + // TODO: Enter your constructor code here +} + +TreeMultiItemBase::~TreeMultiItemBase() +{ + // TODO: Enter your destructor code here +} + +bool TreeMultiItemBase::IsVisible() +{ + // are we excluded? then we are not visible as well + + if(IsExcluded()) + return false; + + // check every parent up until the last and if one of them is collapsed + // we are not visible + + TreeMultiItemNode *p = GetParent(); + while(p) + { + if(!p->IsExpanded()) + return false; + else + p = p->GetParent(); + } + + return true; +} diff --git a/kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemBase.h b/kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemBase.h new file mode 100644 index 0000000..8855ba6 --- /dev/null +++ b/kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemBase.h @@ -0,0 +1,217 @@ +//--------------------------------------------------------------------------- +// $RCSfile: TreeMultiItemBase.h,v $ +// $Source: /cvs/creatis/bbtk/kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemBase.h,v $ +// $Revision: 1.1 $ +// $Date: 2008/03/28 13:42:18 $ +//--------------------------------------------------------------------------- +// Author: Jorgen Bodde +// Copyright: (c) Jorgen Bodde +// License: wxWidgets License +//--------------------------------------------------------------------------- + +#ifndef __TREEMULTIITEMBASE_HPP_ +#define __TREEMULTIITEMBASE_HPP_ + +#ifdef __GNUG__ + #pragma interface "TreeMultiItemBase.cpp" +#endif + +#ifndef WX_PRECOMP + #include "wx/wx.h" +#endif + +// forward definitions +class TreeMultiItemRoot; +class TreeMultiItemWindow; +class TreeMultiItemNode; + +class TreeMultiItemBase +{ +protected: + TreeMultiItemBase(TreeMultiItemNode *parent); + + /** Name property of this item, useful for assigning / coupling + external variable reference to this item. It is not mandatory */ + wxString _name; + + /** Flag to indicate that this node is visible or not. The Node can be + temporarily excluded by flagging it. This has also consequences for all + the children of this node (if any) */ + bool _excluded; + + /** Type of instanced class */ + int _type; + + /** Calculated X, Y position */ + int _x, _y; + + /** Calculated width, height */ + int _width, _height; + +#if(CHECKBOXVIEW) + /** Checkbox flag (draw one or not) */ + bool _checkbox; + + /** Internal draw state. This is a unintelligent state, and should be + updated when this node has some checked and some unchecked children + then this should become a tri-stated item */ + int _checkboxState; +#endif + +public: + virtual ~TreeMultiItemBase(); + + // type of tree item + + int GetType() const { return _type; }; + TreeMultiItemNode *GetParent() const { return _parent; }; + + /** Get name of this node */ + wxString GetName() const { + return _name; + }; + /** Set name of the item */ + void SetName(wxString const& NewName) + { + this->_name = NewName; + } + + /** returns the instance pointer if the current node is + a TreeMultiItemRoot, and NULL when it's not. + */ + virtual TreeMultiItemRoot *IsTreeMultiItemRoot() const { + return 0; + }; + + /** returns the instance pointer if the current node is + a TreeMultiItemWindow, and NULL when it's not. + */ + virtual TreeMultiItemWindow *IsTreeMultiItemWindow() const { + return 0; + }; + + /** returns the instance pointer if the current node is + a TreeMultiItemNode, and NULL when it's not. + */ + virtual TreeMultiItemNode *IsTreeMultiItemNode() const { + return 0; + }; + + /** Sets or resets the excluded flag. When excluded node is not visible */ + void SetExcluded(bool excluded) { + _excluded = excluded; + }; + + /** Get / Set routine for X */ + void SetX(int x) { + _x = x; + }; + + int GetX() const { + return _x; + }; + + /** Get / Set routine for Y */ + void SetY(int y) { + _y = y; + }; + + int GetY() const { + return _y; + }; + + /** Get / Set routine for height */ + void SetHeight(int height) { + _height = height; + }; + + int GetHeight() const { + return _height; + }; + + /** Get / Set routine for width */ + void SetWidth(int width) { + _width = width; + }; + + int GetWidth() const { + return _width; + }; + + /** Returns true when this item is drawn somewhere in the + tree. Whenever a parent of this node is collapsed, it + is not visible and it is not necessary to perform i.e. + redraw actions. + + It also returns false when this node is excluded from the + tree. + + \sa wxTreeMultiCtrl::Exclude(), wxTreeMultiCtrl::Include()) + */ + bool IsVisible(); + + /* Returns if this node is excluded from the tree. If this item + is a Node, then all kids are excluded as well */ + bool IsExcluded() const { + return _excluded; + }; + + // + // item selection status handling + + /** checks if the item is selected */ + bool IsSelected(void) const + { + return this->m_Selected; + } + + /** mark the current item as selected */ + void Select(void) + { + this->m_Selected = true; + } + + /** toggle the selection status */ + void ToggleSelection(void) + { + this->m_Selected = !(this->m_Selected); + } + + /** unmark the item */ + void Unselect(void) + { + this->m_Selected = false; + } + +#if(CHECKBOXVIEW) + /** Sets checkbox or not. This does not influence the state of the checkbox */ + void SetCheckbox(bool value) { + _checkbox = value; + }; + + /** Returns current state of the checkbox view */ + bool GetCheckbox() const { + return _checkbox; + }; + + /** Sets checkbox state. If 0 it's unchecked, 1 = checked and 2 = tristate */ + virtual void SetCheckboxState(int state) { + wxCHECK2(state < 3 && state >= 0, return); + _checkboxState = state; + }; + + /** Returns current state of checkbox */ + int GetCheckboxState() const { + return _checkboxState; + }; +#endif + +private: + TreeMultiItemNode *_parent; + + // flags to indicate the status of the item: + bool m_Selected; +}; + +#endif + diff --git a/kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemNode.cpp b/kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemNode.cpp new file mode 100644 index 0000000..6c62872 --- /dev/null +++ b/kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemNode.cpp @@ -0,0 +1,187 @@ +//--------------------------------------------------------------------------- +// $RCSfile: TreeMultiItemNode.cpp,v $ +// $Source: /cvs/creatis/bbtk/kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemNode.cpp,v $ +// $Revision: 1.1 $ +// $Date: 2008/03/28 13:42:18 $ +//--------------------------------------------------------------------------- +// Author: Jorgen Bodde +// Copyright: (c) Jorgen Bodde +// License: wxWidgets License +//--------------------------------------------------------------------------- + +#ifdef __GNUG__ + #pragma implementation "TreeMultiItemNode.cpp" +#endif + +/* for compilers that support precompilation + includes "wx/wx.h" */ + +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/treemultictrl/TreeMultiItemNode.h" + +#include "wx/arrimpl.cpp" +WX_DEFINE_OBJARRAY(TreeMultiItemBaseArray); + +/** TreeMultiItemNode + * This class is a container holder for multiple TreeMultiItemBase classes. + * Since both a TreeMultiItemNode and a TreeMultiItemWindow are a descendant + * from a TreeMultiItemBase class, it can hold multiple of these. + * In the case of a directory tree structure, it can hold multiple + * directories, and leafs (files). + */ + +// default constructor for container composite +TreeMultiItemNode::TreeMultiItemNode(TreeMultiItemNode *parent, const wxString &caption, const wxString &name) + : TreeMultiItemBase(parent) + , _caption(caption) + , _nodeExpanded(true) + +{ + _name = name; + Clear(); +} + +//------------------------------------------------------------ + +TreeMultiItemNode::~TreeMultiItemNode() +{ + // delete all items on this level + Clear(); +} + +//------------------------------------------------------------ + +void TreeMultiItemNode::AddNode(TreeMultiItemBase *node) +{ + if(node) + _items.Add(node); +} + +void TreeMultiItemNode::InsertNode(TreeMultiItemBase* NodePtr, size_t Position) +{ + if (NodePtr != NULL) + this->_items.Insert(NodePtr,Position); +} + +//------------------------------------------------------------ + +void TreeMultiItemNode::DeleteNode(TreeMultiItemBase *node) +{ + // this is wrong. The RemoveAt and Remove should delete + // the object + if(node) + { + _items.Detach(Index(node)); + delete node; + } + +} + +//------------------------------------------------------------ + +void TreeMultiItemNode::DeleteNode(int index) +{ + // this is wrong. The RemoveAt and Remove should delete + // the object + if(index < (int)_items.Count() && index >= 0) + _items.RemoveAt(index); +} + +//------------------------------------------------------------ + +int TreeMultiItemNode::GetNodeCount() const +{ + return _items.Count(); +} + +//------------------------------------------------------------ + +TreeMultiItemBase *TreeMultiItemNode::GetNode(int index) const +{ + TreeMultiItemBase *value = 0; + + if(index < (int)_items.Count() && index >= 0) + value = &_items.Item(index); + + return value; +} + +//------------------------------------------------------------ + +TreeMultiItemBase *TreeMultiItemNode::RemoveNode(TreeMultiItemBase *node) +{ + if(node) + _items.Detach(_items.Index(*node)); + + return node; +} + +//------------------------------------------------------------ + +TreeMultiItemBase * TreeMultiItemNode::RemoveNode(int index) +{ + TreeMultiItemBase *value = 0; + + if(index < (int)_items.Count() && index > 0) + { + value = &_items.Item(index); + _items.Detach(index); + } + + return value; +} + +//------------------------------------------------------------ + +int TreeMultiItemNode::Index(TreeMultiItemBase *node, bool searchFromEnd) const +{ + wxCHECK(node, -1); + + return _items.Index(*node, searchFromEnd); +} + +//------------------------------------------------------------ + +void TreeMultiItemNode::Clear() +{ + _items.Clear(); +} + +//------------------------------------------------------------ + +TreeMultiItemBase * TreeMultiItemNode::GetNodeNext(int &cookie) const +{ + TreeMultiItemBase *value = 0; + + if(cookie >= 0 && cookie < (int)_items.Count()) + { + value = &_items[cookie]; + cookie++; + } + + return value; +} + +//------------------------------------------------------------ + +TreeMultiItemBase* TreeMultiItemNode::First() const +{ + if (this->_items.GetCount() > 0) + return &(this->_items[0]); + else + return NULL; +} /* TreeMultiItemNode::First() const */ + +TreeMultiItemBase* TreeMultiItemNode::Last() const +{ + if(this->_items.GetCount() > 0) + return &(this->_items.Last()); + else + return NULL; +} /* TreeMultiItemNode::Last() const */ + diff --git a/kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemNode.h b/kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemNode.h new file mode 100644 index 0000000..c8754f1 --- /dev/null +++ b/kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemNode.h @@ -0,0 +1,106 @@ +//--------------------------------------------------------------------------- +// $RCSfile: TreeMultiItemNode.h,v $ +// $Source: /cvs/creatis/bbtk/kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemNode.h,v $ +// $Revision: 1.1 $ +// $Date: 2008/03/28 13:42:18 $ +//--------------------------------------------------------------------------- +// Author: Jorgen Bodde +// Copyright: (c) Jorgen Bodde +// License: wxWidgets License +//--------------------------------------------------------------------------- + +#ifndef __TREEMULTIITEMNODE_HPP_ +#define __TREEMULTIITEMNODE_HPP_ + +#ifdef __GNUG__ + #pragma interface "TreeMultiItemNode.cpp" +#endif + +#ifndef WX_PRECOMP + #include "wx/wx.h" +#endif +#include "wx/treebase.h" + + +#include +#include "TreeMultiItemBase.h" +#include "TreeMultiItemWindow.h" + +/** TreeMultiItemNode + * This class is the element class for WX_OBJ_ARRAY and it + * should be filled with the member variables and methods to + * manipulate each object inside the object array. + * + * See wxArray for all base methods manipulating the array + * Clear() can be used to safely delete all objects. + */ + +// declare the array class here + +WX_DECLARE_OBJARRAY(TreeMultiItemBase, TreeMultiItemBaseArray); + +class TreeMultiItemNode : public TreeMultiItemBase +{ +private: + TreeMultiItemBaseArray _items; + + /** Caption of this node. */ + wxString _caption; + + /** Indicates if this node is expanded (true) or collapsed (false) */ + bool _nodeExpanded; + + /** visual attributes of the node */ + wxTreeItemAttr m_Attributes; + +public: + TreeMultiItemNode(TreeMultiItemNode *parent, const wxString &caption = wxEmptyString, const wxString &name = wxEmptyString); + virtual ~TreeMultiItemNode(); + + // isClass method + virtual TreeMultiItemNode *IsTreeMultiItemNode() const { + return (TreeMultiItemNode *)this; + }; + + // add methods + void AddNode(TreeMultiItemBase *node); + void InsertNode(TreeMultiItemBase* NodePtr, size_t Position); + + // delete methods + void Clear(); + void DeleteNode(TreeMultiItemBase *node); + void DeleteNode(int index); + TreeMultiItemBase *RemoveNode(TreeMultiItemBase *node); + TreeMultiItemBase *RemoveNode(int index); + + // get methods + int GetNodeCount() const; + TreeMultiItemBase *GetNode(int index) const; + int Index(TreeMultiItemBase *node, bool searchFromEnd = false) const; + TreeMultiItemBase *GetNodeNext(int &cookie) const; + + TreeMultiItemBase* First() const; + TreeMultiItemBase* Last() const; + + /** Fold function sets or clears the expanded flag. Note when excluded from drawing, this + will have no effect on redraw */ + void Fold(bool expand) { + if(_nodeExpanded != expand) + _nodeExpanded = expand; + }; + + /** Return caption */ + const wxString &GetCaption() const { + return _caption; + }; + + /** Returns true if the node is expanded. Subnodes can still be collapsed though */ + bool IsExpanded() const { + return _nodeExpanded; + }; + + +}; + +#endif + diff --git a/kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemRoot.cpp b/kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemRoot.cpp new file mode 100644 index 0000000..5879434 --- /dev/null +++ b/kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemRoot.cpp @@ -0,0 +1,46 @@ +//--------------------------------------------------------------------------- +// $RCSfile: TreeMultiItemRoot.cpp,v $ +// $Source: /cvs/creatis/bbtk/kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemRoot.cpp,v $ +// $Revision: 1.1 $ +// $Date: 2008/03/28 13:42:18 $ +//--------------------------------------------------------------------------- +// Author: Jorgen Bodde +// Copyright: (c) Jorgen Bodde +// License: wxWidgets License +//--------------------------------------------------------------------------- + +#ifdef __GNUG__ + #pragma implementation "TreeMultiItemRoot.cpp" +#endif + +/* for compilers that support precompilation + includes "wx/wx.h" */ + +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/treemultictrl/TreeMultiItemRoot.h" + +/** TreeMultiItemRoot + * This class is the class you use to create a tree. It contains all the + * public methods from a TreeMultiItemNode, but you can add more to it + * because it is the root. A typical addition is the load entry for a + * directory, or other type of enumeration. You could store the base path + * of a relative tree in this class. + */ + +TreeMultiItemRoot::TreeMultiItemRoot() + : TreeMultiItemNode(0, _T(""), _T("")) +{ + // TODO: Enter your constructor code here +} + +TreeMultiItemRoot::~TreeMultiItemRoot() +{ + // TODO: Enter your destructor code here +} + + diff --git a/kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemRoot.h b/kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemRoot.h new file mode 100644 index 0000000..c5f8e2c --- /dev/null +++ b/kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemRoot.h @@ -0,0 +1,42 @@ +//--------------------------------------------------------------------------- +// $RCSfile: TreeMultiItemRoot.h,v $ +// $Source: /cvs/creatis/bbtk/kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemRoot.h,v $ +// $Revision: 1.1 $ +// $Date: 2008/03/28 13:42:18 $ +//--------------------------------------------------------------------------- +// Author: Jorgen Bodde +// Copyright: (c) Jorgen Bodde +// License: wxWidgets License +//--------------------------------------------------------------------------- + +#ifndef __TREEMULTIITEMROOT_HPP_ +#define __TREEMULTIITEMROOT_HPP_ + +#ifdef __GNUG__ + #pragma interface "TreeMultiItemRoot.cpp" +#endif + +#ifndef WX_PRECOMP + #include "wx/wx.h" +#endif + +#include "TreeMultiItemBase.h" +#include "TreeMultiItemNode.h" + +/** This class is the root class. It can hold many of the TreeMultiItemWindow and + * TreeMultiItemNode classes. + */ +class TreeMultiItemRoot : public TreeMultiItemNode +{ +public: + TreeMultiItemRoot(); + virtual ~TreeMultiItemRoot(); + + // IsClass method + virtual TreeMultiItemRoot *IsTreeMultiItemRoot() const { + return (TreeMultiItemRoot *)this; + }; +}; + +#endif + diff --git a/kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemWindow.cpp b/kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemWindow.cpp new file mode 100644 index 0000000..dfa9b0d --- /dev/null +++ b/kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemWindow.cpp @@ -0,0 +1,97 @@ +//--------------------------------------------------------------------------- +// $RCSfile: TreeMultiItemWindow.cpp,v $ +// $Source: /cvs/creatis/bbtk/kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemWindow.cpp,v $ +// $Revision: 1.1 $ +// $Date: 2008/03/28 13:42:18 $ +//--------------------------------------------------------------------------- +// Author: Jorgen Bodde +// Copyright: (c) Jorgen Bodde +// License: wxWidgets License +//--------------------------------------------------------------------------- + +#ifdef __GNUG__ + #pragma implementation "TreeMultiItemWindow.cpp" +#endif + +/* for compilers that support precompilation + includes "wx/wx.h" */ + +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/treemultictrl/TreeMultiItemWindow.h" + +/** TreeMultiItemWindow + * This class is a possible end node for the tree. If you want multiple + * types of end-nodes you should copy this file and adjust it with a + * different class name. + */ + +TreeMultiItemWindow::TreeMultiItemWindow(TreeMultiItemNode *parent, const wxString &name) + : TreeMultiItemBase(parent) + , _window(0) + , _topSpacing(0) + , _frontSpacing(0) + , _span(false) +{ + _name = name; + + // TODO: Enter your constructor code here +} + +TreeMultiItemWindow::~TreeMultiItemWindow() +{ + if(_window) + _window->Destroy(); +} + +void TreeMultiItemWindow::AssignWindow(wxWindow *wnd) +{ + // delete previous, assign new (even if zero) + if(_window) + _window->Destroy(); + + _window = wnd; + + // recalculate the size + if(wnd) + { + wxSize size; + + // resize the sized control by sizer or + // by single window. For a sizer handled window + // GetBestSize returns the optimal size + + /// \todo This might need rivision for retaining the sizer size + /// maybe we need to check whether size is <> 0,0 before get best size + + if(wnd->GetSizer()) + size = wnd->GetBestSize(); + else + size = wnd->GetSize(); + + _height = size.GetHeight(); + _width = size.GetWidth(); + + } + else + { + _height = 0; + _width = 0; + } +} + +#if(CHECKBOXVIEW) + +void TreeMultiItemWindow::SetCheckboxState(int state) { + TreeMultiItemBase::SetCheckboxState(state); + + // enable or disable the window + if(GetCheckbox() && GetWindow() && state != 2) + GetWindow()->Enable(state == 1); +}; + +#endif // #if(CHECKBOXVIEW) diff --git a/kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemWindow.h b/kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemWindow.h new file mode 100644 index 0000000..92de588 --- /dev/null +++ b/kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemWindow.h @@ -0,0 +1,95 @@ +//--------------------------------------------------------------------------- +// $RCSfile: TreeMultiItemWindow.h,v $ +// $Source: /cvs/creatis/bbtk/kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemWindow.h,v $ +// $Revision: 1.1 $ +// $Date: 2008/03/28 13:42:18 $ +//--------------------------------------------------------------------------- +// Author: Jorgen Bodde +// Copyright: (c) Jorgen Bodde +// License: wxWidgets License +//--------------------------------------------------------------------------- + +#ifndef __TREEMULTIITEMWINDOW_HPP_ +#define __TREEMULTIITEMWINDOW_HPP_ + +#ifdef __GNUG__ + #pragma interface "TreeMultiItemWindow.cpp" +#endif + +#ifndef WX_PRECOMP + #include "wx/wx.h" +#endif + +#include + +#include "TreeMultiItemBase.h" + +class TreeMultiItemWindow : public TreeMultiItemBase +{ +private: + /** The simple control, or complex sizer that represents this window + in the TreeMultiCtrl */ + wxWindow *_window; + + /** Top and front extra spacings, added to X, Y */ + int _topSpacing, _frontSpacing; + + /** Spanning flag */ + bool _span; + +public: + TreeMultiItemWindow(TreeMultiItemNode *parent, const wxString &name = wxEmptyString); + virtual ~TreeMultiItemWindow(); + + // IsClass method + virtual TreeMultiItemWindow *IsTreeMultiItemWindow() const { + return (TreeMultiItemWindow *)this; + }; + + /** Assigns the given window to this TreeMultiItemWindow, and also destroys the + present window. If the assigned window is 0, this item is not drawn + and removed from the tree visually */ + void AssignWindow(wxWindow *wnd); + + /** Get window method */ + wxWindow *GetWindow() { + return _window; + }; + + /* Sets front spacing */ + void SetFrontSpacing(int frontSpacing) { + _frontSpacing = frontSpacing; + }; + /* Gets front spacing */ + int GetFrontSpacing() const { + return _frontSpacing; + }; + /* Sets top spacing */ + void SetTopSpacing(int topSpacing) { + _topSpacing = topSpacing; + }; + /* Gets top spacing */ + int GetTopSpacing() const { + return _topSpacing; + }; + + /* Sets horizontal span, meaning when this is set the window + attached may be resized horizontally when the window is resized */ + void SetHorizontalSpan(bool span) { + _span = span; + }; + + /* Sets horizontal span, meaning when this is set the window + attached may be resized horizontally when the window is resized */ + bool GetHorizontalSpan() const { + return _span; + }; + +#if(CHECKBOXVIEW) + /** Inherited from base, to enable or disable window */ + virtual void SetCheckboxState(int state); +#endif +}; + +#endif + diff --git a/kernel/src/ThirdParty/wx/treemultictrl/default_checked_icon.xpm b/kernel/src/ThirdParty/wx/treemultictrl/default_checked_icon.xpm new file mode 100644 index 0000000..f1d550f --- /dev/null +++ b/kernel/src/ThirdParty/wx/treemultictrl/default_checked_icon.xpm @@ -0,0 +1,273 @@ +/* XPM */ +static char *checked_icon[] = { +"13 13 256 3", +"000 c #1C5180", +"001 c #21A121", +"002 c #E2E2DD", +"003 c #E3E3DF", +"004 c #E5E5E1", +"005 c #E7E7E3", +"006 c #EAEAE6", +"007 c #ECECE9", +"008 c #EFEFEC", +"009 c #F1F1EF", +"010 c #F3F3F1", +"011 c #F5F5F3", +"012 c #F7F7F6", +"013 c #F9F9F8", +"014 c #FAFAF9", +"015 c #FCFCFB", +"016 c #FDFDFD", +"017 c #FEFEFE", +"018 c gray100", +"019 c black", +"020 c black", +"021 c black", +"022 c black", +"023 c black", +"024 c black", +"025 c black", +"026 c black", +"027 c black", +"028 c black", +"029 c black", +"030 c black", +"031 c black", +"032 c black", +"033 c black", +"034 c black", +"035 c black", +"036 c black", +"037 c black", +"038 c black", +"039 c black", +"040 c black", +"041 c black", +"042 c black", +"043 c black", +"044 c black", +"045 c black", +"046 c black", +"047 c black", +"048 c black", +"049 c black", +"050 c black", +"051 c black", +"052 c black", +"053 c black", +"054 c black", +"055 c black", +"056 c black", +"057 c black", +"058 c black", +"059 c black", +"060 c black", +"061 c black", +"062 c black", +"063 c black", +"064 c black", +"065 c black", +"066 c black", +"067 c black", +"068 c black", +"069 c black", +"070 c black", +"071 c black", +"072 c black", +"073 c black", +"074 c black", +"075 c black", +"076 c black", +"077 c black", +"078 c black", +"079 c black", +"080 c black", +"081 c black", +"082 c black", +"083 c black", +"084 c black", +"085 c black", +"086 c black", +"087 c black", +"088 c black", +"089 c black", +"090 c black", +"091 c black", +"092 c black", +"093 c black", +"094 c black", +"095 c black", +"096 c black", +"097 c black", +"098 c black", +"099 c black", +"100 c black", +"101 c black", +"102 c black", +"103 c black", +"104 c black", +"105 c black", +"106 c black", +"107 c black", +"108 c black", +"109 c black", +"110 c black", +"111 c black", +"112 c black", +"113 c black", +"114 c black", +"115 c black", +"116 c black", +"117 c black", +"118 c black", +"119 c black", +"120 c black", +"121 c black", +"122 c black", +"123 c black", +"124 c black", +"125 c black", +"126 c black", +"127 c black", +"128 c black", +"129 c black", +"130 c black", +"131 c black", +"132 c black", +"133 c black", +"134 c black", +"135 c black", +"136 c black", +"137 c black", +"138 c black", +"139 c black", +"140 c black", +"141 c black", +"142 c black", +"143 c black", +"144 c black", +"145 c black", +"146 c black", +"147 c black", +"148 c black", +"149 c black", +"150 c black", +"151 c black", +"152 c black", +"153 c black", +"154 c black", +"155 c black", +"156 c black", +"157 c black", +"158 c black", +"159 c black", +"160 c black", +"161 c black", +"162 c black", +"163 c black", +"164 c black", +"165 c black", +"166 c black", +"167 c black", +"168 c black", +"169 c black", +"170 c black", +"171 c black", +"172 c black", +"173 c black", +"174 c black", +"175 c black", +"176 c black", +"177 c black", +"178 c black", +"179 c black", +"180 c black", +"181 c black", +"182 c black", +"183 c black", +"184 c black", +"185 c black", +"186 c black", +"187 c black", +"188 c black", +"189 c black", +"190 c black", +"191 c black", +"192 c black", +"193 c black", +"194 c black", +"195 c black", +"196 c black", +"197 c black", +"198 c black", +"199 c black", +"200 c black", +"201 c black", +"202 c black", +"203 c black", +"204 c black", +"205 c black", +"206 c black", +"207 c black", +"208 c black", +"209 c black", +"210 c black", +"211 c black", +"212 c black", +"213 c black", +"214 c black", +"215 c black", +"216 c black", +"217 c black", +"218 c black", +"219 c black", +"220 c black", +"221 c black", +"222 c black", +"223 c black", +"224 c black", +"225 c black", +"226 c black", +"227 c black", +"228 c black", +"229 c black", +"230 c black", +"231 c black", +"232 c black", +"233 c black", +"234 c black", +"235 c black", +"236 c black", +"237 c black", +"238 c black", +"239 c black", +"240 c black", +"241 c black", +"242 c black", +"243 c black", +"244 c black", +"245 c black", +"246 c black", +"247 c black", +"248 c black", +"249 c black", +"250 c black", +"251 c black", +"252 c black", +"253 c black", +"254 c black", +"255 c black", +"000000000000000000000000000000000000000", +"000002002002003004005006007008009010000", +"000002002003004005006007008009010011000", +"000002003004005006007008009001011012000", +"000003004005006007008009001001012013000", +"000004005001007008009001001001013014000", +"000005006001001009001001001013014015000", +"000006007001001001001001013014015016000", +"000007008009001001001013014015016017000", +"000008009010011001013014015016017018000", +"000009010011012013014015016017018018000", +"000010011012013014015016017018018018000", +"000000000000000000000000000000000000000" +}; diff --git a/kernel/src/ThirdParty/wx/treemultictrl/default_collapse.xpm b/kernel/src/ThirdParty/wx/treemultictrl/default_collapse.xpm new file mode 100644 index 0000000..dc10f2f --- /dev/null +++ b/kernel/src/ThirdParty/wx/treemultictrl/default_collapse.xpm @@ -0,0 +1,31 @@ +/* XPM */ +static char *collapse_xpm[] = { +"11 11 16 2", +"00 c black", +"01 c #7B9CB5", +"02 c #B5C6D6", +"03 c #C6B5A5", +"04 c #C6BDA5", +"05 c #C6BDAD", +"06 c #CECEBD", +"07 c #D6D0C3", +"08 c #DED6CE", +"09 c #DEDECE", +"10 c #DEDED6", +"11 c #E7E7DE", +"12 c #EFEFE7", +"13 c #F7F7EF", +"14 c gray97", +"15 c gray100", +"1515151515151515151515", +"1502010101010101010215", +"1501151515151515150115", +"1501151515001515130115", +"1501141414001412110115", +"1501130000000000090115", +"1501131212001110080115", +"1501100807000706060115", +"1501060503030303050115", +"1502010101010101010215", +"1515151515151515151515" +}; diff --git a/kernel/src/ThirdParty/wx/treemultictrl/default_expand.xpm b/kernel/src/ThirdParty/wx/treemultictrl/default_expand.xpm new file mode 100644 index 0000000..fa65765 --- /dev/null +++ b/kernel/src/ThirdParty/wx/treemultictrl/default_expand.xpm @@ -0,0 +1,31 @@ +/* XPM */ +static char *expand_xpm[] = { +"11 11 16 2", +"00 c black", +"01 c #7B9CB5", +"02 c #B5C6D6", +"03 c #C6B5A5", +"04 c #C6BDA5", +"05 c #C6BDAD", +"06 c #D2CEBD", +"07 c #D6D2C6", +"08 c #DED6CE", +"09 c #DEDECE", +"10 c #DEDED6", +"11 c #E7E7DE", +"12 c #EFEFE7", +"13 c #F7F7EF", +"14 c gray97", +"15 c gray100", +"1515151515151515151515", +"1502010101010101010215", +"1501151515151515150115", +"1501151515151515130115", +"1501141414141412110115", +"1501130000000000090115", +"1501131212121110080115", +"1501100807070706060115", +"1501060503030303050115", +"1502010101010101010215", +"1515151515151515151515" +}; diff --git a/kernel/src/ThirdParty/wx/treemultictrl/default_tristate_icon.xpm b/kernel/src/ThirdParty/wx/treemultictrl/default_tristate_icon.xpm new file mode 100644 index 0000000..1731cb9 --- /dev/null +++ b/kernel/src/ThirdParty/wx/treemultictrl/default_tristate_icon.xpm @@ -0,0 +1,273 @@ +/* XPM */ +static char *tristate_icon[] = { +"13 13 256 3", +"000 c #1C5180", +"001 c #6DBB6C", +"002 c #6EBC6C", +"003 c #6FBD6D", +"004 c #70BE6F", +"005 c #71BF70", +"006 c #72C071", +"007 c #73C172", +"008 c #73C273", +"009 c #74C274", +"010 c #75C374", +"011 c #75C475", +"012 c #76C476", +"013 c #76C576", +"014 c #E2E2DD", +"015 c #E3E3DF", +"016 c #E5E5E1", +"017 c #E7E7E3", +"018 c #EAEAE6", +"019 c #ECECE9", +"020 c #EFEFEC", +"021 c #F1F1EF", +"022 c #F3F3F1", +"023 c #F5F5F3", +"024 c #F7F7F6", +"025 c #F9F9F8", +"026 c #FAFAF9", +"027 c #FCFCFB", +"028 c #FDFDFD", +"029 c #FEFEFE", +"030 c gray100", +"031 c black", +"032 c black", +"033 c black", +"034 c black", +"035 c black", +"036 c black", +"037 c black", +"038 c black", +"039 c black", +"040 c black", +"041 c black", +"042 c black", +"043 c black", +"044 c black", +"045 c black", +"046 c black", +"047 c black", +"048 c black", +"049 c black", +"050 c black", +"051 c black", +"052 c black", +"053 c black", +"054 c black", +"055 c black", +"056 c black", +"057 c black", +"058 c black", +"059 c black", +"060 c black", +"061 c black", +"062 c black", +"063 c black", +"064 c black", +"065 c black", +"066 c black", +"067 c black", +"068 c black", +"069 c black", +"070 c black", +"071 c black", +"072 c black", +"073 c black", +"074 c black", +"075 c black", +"076 c black", +"077 c black", +"078 c black", +"079 c black", +"080 c black", +"081 c black", +"082 c black", +"083 c black", +"084 c black", +"085 c black", +"086 c black", +"087 c black", +"088 c black", +"089 c black", +"090 c black", +"091 c black", +"092 c black", +"093 c black", +"094 c black", +"095 c black", +"096 c black", +"097 c black", +"098 c black", +"099 c black", +"100 c black", +"101 c black", +"102 c black", +"103 c black", +"104 c black", +"105 c black", +"106 c black", +"107 c black", +"108 c black", +"109 c black", +"110 c black", +"111 c black", +"112 c black", +"113 c black", +"114 c black", +"115 c black", +"116 c black", +"117 c black", +"118 c black", +"119 c black", +"120 c black", +"121 c black", +"122 c black", +"123 c black", +"124 c black", +"125 c black", +"126 c black", +"127 c black", +"128 c black", +"129 c black", +"130 c black", +"131 c black", +"132 c black", +"133 c black", +"134 c black", +"135 c black", +"136 c black", +"137 c black", +"138 c black", +"139 c black", +"140 c black", +"141 c black", +"142 c black", +"143 c black", +"144 c black", +"145 c black", +"146 c black", +"147 c black", +"148 c black", +"149 c black", +"150 c black", +"151 c black", +"152 c black", +"153 c black", +"154 c black", +"155 c black", +"156 c black", +"157 c black", +"158 c black", +"159 c black", +"160 c black", +"161 c black", +"162 c black", +"163 c black", +"164 c black", +"165 c black", +"166 c black", +"167 c black", +"168 c black", +"169 c black", +"170 c black", +"171 c black", +"172 c black", +"173 c black", +"174 c black", +"175 c black", +"176 c black", +"177 c black", +"178 c black", +"179 c black", +"180 c black", +"181 c black", +"182 c black", +"183 c black", +"184 c black", +"185 c black", +"186 c black", +"187 c black", +"188 c black", +"189 c black", +"190 c black", +"191 c black", +"192 c black", +"193 c black", +"194 c black", +"195 c black", +"196 c black", +"197 c black", +"198 c black", +"199 c black", +"200 c black", +"201 c black", +"202 c black", +"203 c black", +"204 c black", +"205 c black", +"206 c black", +"207 c black", +"208 c black", +"209 c black", +"210 c black", +"211 c black", +"212 c black", +"213 c black", +"214 c black", +"215 c black", +"216 c black", +"217 c black", +"218 c black", +"219 c black", +"220 c black", +"221 c black", +"222 c black", +"223 c black", +"224 c black", +"225 c black", +"226 c black", +"227 c black", +"228 c black", +"229 c black", +"230 c black", +"231 c black", +"232 c black", +"233 c black", +"234 c black", +"235 c black", +"236 c black", +"237 c black", +"238 c black", +"239 c black", +"240 c black", +"241 c black", +"242 c black", +"243 c black", +"244 c black", +"245 c black", +"246 c black", +"247 c black", +"248 c black", +"249 c black", +"250 c black", +"251 c black", +"252 c black", +"253 c black", +"254 c black", +"255 c black", +"000000000000000000000000000000000000000", +"000014014014015016017018019020021022000", +"000014014015016017018019020021022023000", +"000014015001002003004005006007023024000", +"000015016002003004005006007008024025000", +"000016017003004005006007008009025026000", +"000017018004005006007008009010026027000", +"000018019005006007008009010011027028000", +"000019020006007008009010011012028029000", +"000020021007008009010011012013029030000", +"000021022023024025026027028029030030000", +"000022023024025026027028029030030030000", +"000000000000000000000000000000000000000" +}; diff --git a/kernel/src/ThirdParty/wx/treemultictrl/default_unchecked_icon.xpm b/kernel/src/ThirdParty/wx/treemultictrl/default_unchecked_icon.xpm new file mode 100644 index 0000000..4a61e61 --- /dev/null +++ b/kernel/src/ThirdParty/wx/treemultictrl/default_unchecked_icon.xpm @@ -0,0 +1,273 @@ +/* XPM */ +static char *unchecked_icon[] = { +"13 13 256 3", +"000 c #1C5180", +"001 c #DCDCD7", +"002 c #DEDED9", +"003 c #E0E0DB", +"004 c #E2E2DE", +"005 c #E5E5E2", +"006 c #E8E8E5", +"007 c #ECECE9", +"008 c #EFEFEC", +"009 c #F1F1EF", +"010 c #F3F3F1", +"011 c #F5F5F4", +"012 c #F7F7F6", +"013 c #F9F9F8", +"014 c #FBFBFA", +"015 c #FDFDFC", +"016 c #FEFEFE", +"017 c gray100", +"018 c black", +"019 c black", +"020 c black", +"021 c black", +"022 c black", +"023 c black", +"024 c black", +"025 c black", +"026 c black", +"027 c black", +"028 c black", +"029 c black", +"030 c black", +"031 c black", +"032 c black", +"033 c black", +"034 c black", +"035 c black", +"036 c black", +"037 c black", +"038 c black", +"039 c black", +"040 c black", +"041 c black", +"042 c black", +"043 c black", +"044 c black", +"045 c black", +"046 c black", +"047 c black", +"048 c black", +"049 c black", +"050 c black", +"051 c black", +"052 c black", +"053 c black", +"054 c black", +"055 c black", +"056 c black", +"057 c black", +"058 c black", +"059 c black", +"060 c black", +"061 c black", +"062 c black", +"063 c black", +"064 c black", +"065 c black", +"066 c black", +"067 c black", +"068 c black", +"069 c black", +"070 c black", +"071 c black", +"072 c black", +"073 c black", +"074 c black", +"075 c black", +"076 c black", +"077 c black", +"078 c black", +"079 c black", +"080 c black", +"081 c black", +"082 c black", +"083 c black", +"084 c black", +"085 c black", +"086 c black", +"087 c black", +"088 c black", +"089 c black", +"090 c black", +"091 c black", +"092 c black", +"093 c black", +"094 c black", +"095 c black", +"096 c black", +"097 c black", +"098 c black", +"099 c black", +"100 c black", +"101 c black", +"102 c black", +"103 c black", +"104 c black", +"105 c black", +"106 c black", +"107 c black", +"108 c black", +"109 c black", +"110 c black", +"111 c black", +"112 c black", +"113 c black", +"114 c black", +"115 c black", +"116 c black", +"117 c black", +"118 c black", +"119 c black", +"120 c black", +"121 c black", +"122 c black", +"123 c black", +"124 c black", +"125 c black", +"126 c black", +"127 c black", +"128 c black", +"129 c black", +"130 c black", +"131 c black", +"132 c black", +"133 c black", +"134 c black", +"135 c black", +"136 c black", +"137 c black", +"138 c black", +"139 c black", +"140 c black", +"141 c black", +"142 c black", +"143 c black", +"144 c black", +"145 c black", +"146 c black", +"147 c black", +"148 c black", +"149 c black", +"150 c black", +"151 c black", +"152 c black", +"153 c black", +"154 c black", +"155 c black", +"156 c black", +"157 c black", +"158 c black", +"159 c black", +"160 c black", +"161 c black", +"162 c black", +"163 c black", +"164 c black", +"165 c black", +"166 c black", +"167 c black", +"168 c black", +"169 c black", +"170 c black", +"171 c black", +"172 c black", +"173 c black", +"174 c black", +"175 c black", +"176 c black", +"177 c black", +"178 c black", +"179 c black", +"180 c black", +"181 c black", +"182 c black", +"183 c black", +"184 c black", +"185 c black", +"186 c black", +"187 c black", +"188 c black", +"189 c black", +"190 c black", +"191 c black", +"192 c black", +"193 c black", +"194 c black", +"195 c black", +"196 c black", +"197 c black", +"198 c black", +"199 c black", +"200 c black", +"201 c black", +"202 c black", +"203 c black", +"204 c black", +"205 c black", +"206 c black", +"207 c black", +"208 c black", +"209 c black", +"210 c black", +"211 c black", +"212 c black", +"213 c black", +"214 c black", +"215 c black", +"216 c black", +"217 c black", +"218 c black", +"219 c black", +"220 c black", +"221 c black", +"222 c black", +"223 c black", +"224 c black", +"225 c black", +"226 c black", +"227 c black", +"228 c black", +"229 c black", +"230 c black", +"231 c black", +"232 c black", +"233 c black", +"234 c black", +"235 c black", +"236 c black", +"237 c black", +"238 c black", +"239 c black", +"240 c black", +"241 c black", +"242 c black", +"243 c black", +"244 c black", +"245 c black", +"246 c black", +"247 c black", +"248 c black", +"249 c black", +"250 c black", +"251 c black", +"252 c black", +"253 c black", +"254 c black", +"255 c black", +"000000000000000000000000000000000000000", +"000001001001002003004005006007008009000", +"000001001002003004005006007008009010000", +"000001002003004005006007008009010011000", +"000002003004005006007008009010011012000", +"000003004005006007008009010011012013000", +"000004005006007008009010011012013014000", +"000005006007008009010011012013014015000", +"000006007008009010011012013014015016000", +"000007008009010011012013014015016017000", +"000008009010011012013014015016017017000", +"000009010011012013014015016017017017000", +"000000000000000000000000000000000000000" +}; diff --git a/kernel/src/ThirdParty/wx/treemultictrl/linux_collapse.xpm b/kernel/src/ThirdParty/wx/treemultictrl/linux_collapse.xpm new file mode 100644 index 0000000..6546dc5 --- /dev/null +++ b/kernel/src/ThirdParty/wx/treemultictrl/linux_collapse.xpm @@ -0,0 +1,31 @@ +/* XPM */ +static char *collapse_xpm[] = { +"11 11 16 2", +"00 c black", +"01 c #848484", +"02 c none", +"03 c gray100", +"04 c gray100", +"05 c gray100", +"06 c gray100", +"07 c gray100", +"08 c gray100", +"09 c gray100", +"10 c gray100", +"11 c gray100", +"12 c gray100", +"13 c gray100", +"14 c gray100", +"15 c gray100", +"0202020202020202020202", +"0101010101010101010101", +"0103030303030303030301", +"0103030303000303030301", +"0103030303000303030301", +"0103030000000000030301", +"0103030303000303030301", +"0103030303000303030301", +"0103030303030303030301", +"0101010101010101010101", +"0202020202020202020202" +}; diff --git a/kernel/src/ThirdParty/wx/treemultictrl/linux_expand.xpm b/kernel/src/ThirdParty/wx/treemultictrl/linux_expand.xpm new file mode 100644 index 0000000..38f8b1b --- /dev/null +++ b/kernel/src/ThirdParty/wx/treemultictrl/linux_expand.xpm @@ -0,0 +1,31 @@ +/* XPM */ +static char *expand_xpm[] = { +"11 11 16 2", +"00 c black", +"01 c #848484", +"02 c none", +"03 c gray100", +"04 c gray100", +"05 c gray100", +"06 c gray100", +"07 c gray100", +"08 c gray100", +"09 c gray100", +"10 c gray100", +"11 c gray100", +"12 c gray100", +"13 c gray100", +"14 c gray100", +"15 c gray100", +"0202020202020202020202", +"0101010101010101010101", +"0103030303030303030301", +"0103030303030303030301", +"0103030303030303030301", +"0103030000000000030301", +"0103030303030303030301", +"0103030303030303030301", +"0103030303030303030301", +"0101010101010101010101", +"0202020202020202020202" +}; diff --git a/kernel/src/ThirdParty/wx/treemultictrl/mac_collapse.xpm b/kernel/src/ThirdParty/wx/treemultictrl/mac_collapse.xpm new file mode 100644 index 0000000..d100ef6 --- /dev/null +++ b/kernel/src/ThirdParty/wx/treemultictrl/mac_collapse.xpm @@ -0,0 +1,25 @@ +/* XPM */ +static char *collapse_xpm[] = +{ +/* width height ncolors chars_per_pixel */ +"11 11 6 1", +/* colors */ +"A c None", +"B c #CCCCCCCCCCCC", +"C c #EEEEEEEEEEEE", +"D c #DDDDDDDDDDDD", +"E c #BBBBBBBBBBBB", +"F c #AAAAAAAAAAAA", +/* pixels */ +"ACAAAAAAAAA", +"ABEAAAAAAAA", +"AFEEBAAAAAA", +"AEEFEEDAAAA", +"AEFEFEFBCAA", +"AFEFEFEFEBA", +"AEEEFEFBCAA", +"AEFFEEDAAAA", +"AFEEDAAAAAA", +"ABBCAAAAAAA", +"ACAAAAAAAAA", +}; diff --git a/kernel/src/ThirdParty/wx/treemultictrl/mac_expand.xpm b/kernel/src/ThirdParty/wx/treemultictrl/mac_expand.xpm new file mode 100644 index 0000000..d2a09e8 --- /dev/null +++ b/kernel/src/ThirdParty/wx/treemultictrl/mac_expand.xpm @@ -0,0 +1,25 @@ +/* XPM */ +static char *expand_xpm[] = +{ +/* width height ncolors chars_per_pixel */ +"11 11 6 1", +/* colors */ +"A c None", +"B c #CCCCCCCCCCCC", +"C c #EEEEEEEEEEEE", +"D c #DDDDDDDDDDDD", +"E c #BBBBBBBBBBBB", +"F c #AAAAAAAAAAAA", +/* pixels */ +"AAAAAAAAAAA", +"CBFEEFEEFBC", +"ABEFEEFEEEA", +"ACEFEFEFEAA", +"AADEFEFEBAA", +"AAAEEFEEAAA", +"AAADFEFDAAA", +"AAAABFBAAAA", +"AAAACECAAAA", +"AAAAABAAAAA", +"AAAAAAAAAAA", +}; diff --git a/kernel/src/ThirdParty/wx/treemultictrl/tmcimages.h b/kernel/src/ThirdParty/wx/treemultictrl/tmcimages.h new file mode 100644 index 0000000..ed94b73 --- /dev/null +++ b/kernel/src/ThirdParty/wx/treemultictrl/tmcimages.h @@ -0,0 +1,42 @@ +//--------------------------------------------------------------------------- +// $RCSfile: tmcimages.h,v $ +// $Source: /cvs/creatis/bbtk/kernel/src/ThirdParty/wx/treemultictrl/tmcimages.h,v $ +// $Revision: 1.1 $ +// $Date: 2008/03/28 13:42:19 $ +//--------------------------------------------------------------------------- +// Author: Jorgen Bodde +// Copyright: (c) Jorgen Bodde +// License: wxWidgets License +//--------------------------------------------------------------------------- + +#ifndef _TMCIMAGES_H_ +#define _TMCIMAGES_H_ + +// pics for the expand / collapse buttons +#ifdef __APPLE__ + #include "mac_collapse.xpm" + #include "mac_expand.xpm" +#else + #ifdef LINUX + #include "linux_collapse.xpm" + #include "linux_expand.xpm" + #else + #include "default_collapse.xpm" + #include "default_expand.xpm" + #endif +#endif + +#if(CHECKBOXVIEW) + // icons for checkbox states + #ifdef WINDOWS + #include "win_unchecked_icon.xpm" + #include "win_checked_icon.xpm" + #include "win_tristate_icon.xpm" + #else + #include "default_unchecked_icon.xpm" + #include "default_checked_icon.xpm" + #include "default_tristate_icon.xpm" + #endif // WINDOWS +#endif // #if(CHECKBOXVIEW) + +#endif // _TMCIMAGES_H_ diff --git a/kernel/src/ThirdParty/wx/treemultictrl/win_checked_icon.xpm b/kernel/src/ThirdParty/wx/treemultictrl/win_checked_icon.xpm new file mode 100644 index 0000000..f1d550f --- /dev/null +++ b/kernel/src/ThirdParty/wx/treemultictrl/win_checked_icon.xpm @@ -0,0 +1,273 @@ +/* XPM */ +static char *checked_icon[] = { +"13 13 256 3", +"000 c #1C5180", +"001 c #21A121", +"002 c #E2E2DD", +"003 c #E3E3DF", +"004 c #E5E5E1", +"005 c #E7E7E3", +"006 c #EAEAE6", +"007 c #ECECE9", +"008 c #EFEFEC", +"009 c #F1F1EF", +"010 c #F3F3F1", +"011 c #F5F5F3", +"012 c #F7F7F6", +"013 c #F9F9F8", +"014 c #FAFAF9", +"015 c #FCFCFB", +"016 c #FDFDFD", +"017 c #FEFEFE", +"018 c gray100", +"019 c black", +"020 c black", +"021 c black", +"022 c black", +"023 c black", +"024 c black", +"025 c black", +"026 c black", +"027 c black", +"028 c black", +"029 c black", +"030 c black", +"031 c black", +"032 c black", +"033 c black", +"034 c black", +"035 c black", +"036 c black", +"037 c black", +"038 c black", +"039 c black", +"040 c black", +"041 c black", +"042 c black", +"043 c black", +"044 c black", +"045 c black", +"046 c black", +"047 c black", +"048 c black", +"049 c black", +"050 c black", +"051 c black", +"052 c black", +"053 c black", +"054 c black", +"055 c black", +"056 c black", +"057 c black", +"058 c black", +"059 c black", +"060 c black", +"061 c black", +"062 c black", +"063 c black", +"064 c black", +"065 c black", +"066 c black", +"067 c black", +"068 c black", +"069 c black", +"070 c black", +"071 c black", +"072 c black", +"073 c black", +"074 c black", +"075 c black", +"076 c black", +"077 c black", +"078 c black", +"079 c black", +"080 c black", +"081 c black", +"082 c black", +"083 c black", +"084 c black", +"085 c black", +"086 c black", +"087 c black", +"088 c black", +"089 c black", +"090 c black", +"091 c black", +"092 c black", +"093 c black", +"094 c black", +"095 c black", +"096 c black", +"097 c black", +"098 c black", +"099 c black", +"100 c black", +"101 c black", +"102 c black", +"103 c black", +"104 c black", +"105 c black", +"106 c black", +"107 c black", +"108 c black", +"109 c black", +"110 c black", +"111 c black", +"112 c black", +"113 c black", +"114 c black", +"115 c black", +"116 c black", +"117 c black", +"118 c black", +"119 c black", +"120 c black", +"121 c black", +"122 c black", +"123 c black", +"124 c black", +"125 c black", +"126 c black", +"127 c black", +"128 c black", +"129 c black", +"130 c black", +"131 c black", +"132 c black", +"133 c black", +"134 c black", +"135 c black", +"136 c black", +"137 c black", +"138 c black", +"139 c black", +"140 c black", +"141 c black", +"142 c black", +"143 c black", +"144 c black", +"145 c black", +"146 c black", +"147 c black", +"148 c black", +"149 c black", +"150 c black", +"151 c black", +"152 c black", +"153 c black", +"154 c black", +"155 c black", +"156 c black", +"157 c black", +"158 c black", +"159 c black", +"160 c black", +"161 c black", +"162 c black", +"163 c black", +"164 c black", +"165 c black", +"166 c black", +"167 c black", +"168 c black", +"169 c black", +"170 c black", +"171 c black", +"172 c black", +"173 c black", +"174 c black", +"175 c black", +"176 c black", +"177 c black", +"178 c black", +"179 c black", +"180 c black", +"181 c black", +"182 c black", +"183 c black", +"184 c black", +"185 c black", +"186 c black", +"187 c black", +"188 c black", +"189 c black", +"190 c black", +"191 c black", +"192 c black", +"193 c black", +"194 c black", +"195 c black", +"196 c black", +"197 c black", +"198 c black", +"199 c black", +"200 c black", +"201 c black", +"202 c black", +"203 c black", +"204 c black", +"205 c black", +"206 c black", +"207 c black", +"208 c black", +"209 c black", +"210 c black", +"211 c black", +"212 c black", +"213 c black", +"214 c black", +"215 c black", +"216 c black", +"217 c black", +"218 c black", +"219 c black", +"220 c black", +"221 c black", +"222 c black", +"223 c black", +"224 c black", +"225 c black", +"226 c black", +"227 c black", +"228 c black", +"229 c black", +"230 c black", +"231 c black", +"232 c black", +"233 c black", +"234 c black", +"235 c black", +"236 c black", +"237 c black", +"238 c black", +"239 c black", +"240 c black", +"241 c black", +"242 c black", +"243 c black", +"244 c black", +"245 c black", +"246 c black", +"247 c black", +"248 c black", +"249 c black", +"250 c black", +"251 c black", +"252 c black", +"253 c black", +"254 c black", +"255 c black", +"000000000000000000000000000000000000000", +"000002002002003004005006007008009010000", +"000002002003004005006007008009010011000", +"000002003004005006007008009001011012000", +"000003004005006007008009001001012013000", +"000004005001007008009001001001013014000", +"000005006001001009001001001013014015000", +"000006007001001001001001013014015016000", +"000007008009001001001013014015016017000", +"000008009010011001013014015016017018000", +"000009010011012013014015016017018018000", +"000010011012013014015016017018018018000", +"000000000000000000000000000000000000000" +}; diff --git a/kernel/src/ThirdParty/wx/treemultictrl/win_tristate_icon.xpm b/kernel/src/ThirdParty/wx/treemultictrl/win_tristate_icon.xpm new file mode 100644 index 0000000..1731cb9 --- /dev/null +++ b/kernel/src/ThirdParty/wx/treemultictrl/win_tristate_icon.xpm @@ -0,0 +1,273 @@ +/* XPM */ +static char *tristate_icon[] = { +"13 13 256 3", +"000 c #1C5180", +"001 c #6DBB6C", +"002 c #6EBC6C", +"003 c #6FBD6D", +"004 c #70BE6F", +"005 c #71BF70", +"006 c #72C071", +"007 c #73C172", +"008 c #73C273", +"009 c #74C274", +"010 c #75C374", +"011 c #75C475", +"012 c #76C476", +"013 c #76C576", +"014 c #E2E2DD", +"015 c #E3E3DF", +"016 c #E5E5E1", +"017 c #E7E7E3", +"018 c #EAEAE6", +"019 c #ECECE9", +"020 c #EFEFEC", +"021 c #F1F1EF", +"022 c #F3F3F1", +"023 c #F5F5F3", +"024 c #F7F7F6", +"025 c #F9F9F8", +"026 c #FAFAF9", +"027 c #FCFCFB", +"028 c #FDFDFD", +"029 c #FEFEFE", +"030 c gray100", +"031 c black", +"032 c black", +"033 c black", +"034 c black", +"035 c black", +"036 c black", +"037 c black", +"038 c black", +"039 c black", +"040 c black", +"041 c black", +"042 c black", +"043 c black", +"044 c black", +"045 c black", +"046 c black", +"047 c black", +"048 c black", +"049 c black", +"050 c black", +"051 c black", +"052 c black", +"053 c black", +"054 c black", +"055 c black", +"056 c black", +"057 c black", +"058 c black", +"059 c black", +"060 c black", +"061 c black", +"062 c black", +"063 c black", +"064 c black", +"065 c black", +"066 c black", +"067 c black", +"068 c black", +"069 c black", +"070 c black", +"071 c black", +"072 c black", +"073 c black", +"074 c black", +"075 c black", +"076 c black", +"077 c black", +"078 c black", +"079 c black", +"080 c black", +"081 c black", +"082 c black", +"083 c black", +"084 c black", +"085 c black", +"086 c black", +"087 c black", +"088 c black", +"089 c black", +"090 c black", +"091 c black", +"092 c black", +"093 c black", +"094 c black", +"095 c black", +"096 c black", +"097 c black", +"098 c black", +"099 c black", +"100 c black", +"101 c black", +"102 c black", +"103 c black", +"104 c black", +"105 c black", +"106 c black", +"107 c black", +"108 c black", +"109 c black", +"110 c black", +"111 c black", +"112 c black", +"113 c black", +"114 c black", +"115 c black", +"116 c black", +"117 c black", +"118 c black", +"119 c black", +"120 c black", +"121 c black", +"122 c black", +"123 c black", +"124 c black", +"125 c black", +"126 c black", +"127 c black", +"128 c black", +"129 c black", +"130 c black", +"131 c black", +"132 c black", +"133 c black", +"134 c black", +"135 c black", +"136 c black", +"137 c black", +"138 c black", +"139 c black", +"140 c black", +"141 c black", +"142 c black", +"143 c black", +"144 c black", +"145 c black", +"146 c black", +"147 c black", +"148 c black", +"149 c black", +"150 c black", +"151 c black", +"152 c black", +"153 c black", +"154 c black", +"155 c black", +"156 c black", +"157 c black", +"158 c black", +"159 c black", +"160 c black", +"161 c black", +"162 c black", +"163 c black", +"164 c black", +"165 c black", +"166 c black", +"167 c black", +"168 c black", +"169 c black", +"170 c black", +"171 c black", +"172 c black", +"173 c black", +"174 c black", +"175 c black", +"176 c black", +"177 c black", +"178 c black", +"179 c black", +"180 c black", +"181 c black", +"182 c black", +"183 c black", +"184 c black", +"185 c black", +"186 c black", +"187 c black", +"188 c black", +"189 c black", +"190 c black", +"191 c black", +"192 c black", +"193 c black", +"194 c black", +"195 c black", +"196 c black", +"197 c black", +"198 c black", +"199 c black", +"200 c black", +"201 c black", +"202 c black", +"203 c black", +"204 c black", +"205 c black", +"206 c black", +"207 c black", +"208 c black", +"209 c black", +"210 c black", +"211 c black", +"212 c black", +"213 c black", +"214 c black", +"215 c black", +"216 c black", +"217 c black", +"218 c black", +"219 c black", +"220 c black", +"221 c black", +"222 c black", +"223 c black", +"224 c black", +"225 c black", +"226 c black", +"227 c black", +"228 c black", +"229 c black", +"230 c black", +"231 c black", +"232 c black", +"233 c black", +"234 c black", +"235 c black", +"236 c black", +"237 c black", +"238 c black", +"239 c black", +"240 c black", +"241 c black", +"242 c black", +"243 c black", +"244 c black", +"245 c black", +"246 c black", +"247 c black", +"248 c black", +"249 c black", +"250 c black", +"251 c black", +"252 c black", +"253 c black", +"254 c black", +"255 c black", +"000000000000000000000000000000000000000", +"000014014014015016017018019020021022000", +"000014014015016017018019020021022023000", +"000014015001002003004005006007023024000", +"000015016002003004005006007008024025000", +"000016017003004005006007008009025026000", +"000017018004005006007008009010026027000", +"000018019005006007008009010011027028000", +"000019020006007008009010011012028029000", +"000020021007008009010011012013029030000", +"000021022023024025026027028029030030000", +"000022023024025026027028029030030030000", +"000000000000000000000000000000000000000" +}; diff --git a/kernel/src/ThirdParty/wx/treemultictrl/win_unchecked_icon.xpm b/kernel/src/ThirdParty/wx/treemultictrl/win_unchecked_icon.xpm new file mode 100644 index 0000000..4a61e61 --- /dev/null +++ b/kernel/src/ThirdParty/wx/treemultictrl/win_unchecked_icon.xpm @@ -0,0 +1,273 @@ +/* XPM */ +static char *unchecked_icon[] = { +"13 13 256 3", +"000 c #1C5180", +"001 c #DCDCD7", +"002 c #DEDED9", +"003 c #E0E0DB", +"004 c #E2E2DE", +"005 c #E5E5E2", +"006 c #E8E8E5", +"007 c #ECECE9", +"008 c #EFEFEC", +"009 c #F1F1EF", +"010 c #F3F3F1", +"011 c #F5F5F4", +"012 c #F7F7F6", +"013 c #F9F9F8", +"014 c #FBFBFA", +"015 c #FDFDFC", +"016 c #FEFEFE", +"017 c gray100", +"018 c black", +"019 c black", +"020 c black", +"021 c black", +"022 c black", +"023 c black", +"024 c black", +"025 c black", +"026 c black", +"027 c black", +"028 c black", +"029 c black", +"030 c black", +"031 c black", +"032 c black", +"033 c black", +"034 c black", +"035 c black", +"036 c black", +"037 c black", +"038 c black", +"039 c black", +"040 c black", +"041 c black", +"042 c black", +"043 c black", +"044 c black", +"045 c black", +"046 c black", +"047 c black", +"048 c black", +"049 c black", +"050 c black", +"051 c black", +"052 c black", +"053 c black", +"054 c black", +"055 c black", +"056 c black", +"057 c black", +"058 c black", +"059 c black", +"060 c black", +"061 c black", +"062 c black", +"063 c black", +"064 c black", +"065 c black", +"066 c black", +"067 c black", +"068 c black", +"069 c black", +"070 c black", +"071 c black", +"072 c black", +"073 c black", +"074 c black", +"075 c black", +"076 c black", +"077 c black", +"078 c black", +"079 c black", +"080 c black", +"081 c black", +"082 c black", +"083 c black", +"084 c black", +"085 c black", +"086 c black", +"087 c black", +"088 c black", +"089 c black", +"090 c black", +"091 c black", +"092 c black", +"093 c black", +"094 c black", +"095 c black", +"096 c black", +"097 c black", +"098 c black", +"099 c black", +"100 c black", +"101 c black", +"102 c black", +"103 c black", +"104 c black", +"105 c black", +"106 c black", +"107 c black", +"108 c black", +"109 c black", +"110 c black", +"111 c black", +"112 c black", +"113 c black", +"114 c black", +"115 c black", +"116 c black", +"117 c black", +"118 c black", +"119 c black", +"120 c black", +"121 c black", +"122 c black", +"123 c black", +"124 c black", +"125 c black", +"126 c black", +"127 c black", +"128 c black", +"129 c black", +"130 c black", +"131 c black", +"132 c black", +"133 c black", +"134 c black", +"135 c black", +"136 c black", +"137 c black", +"138 c black", +"139 c black", +"140 c black", +"141 c black", +"142 c black", +"143 c black", +"144 c black", +"145 c black", +"146 c black", +"147 c black", +"148 c black", +"149 c black", +"150 c black", +"151 c black", +"152 c black", +"153 c black", +"154 c black", +"155 c black", +"156 c black", +"157 c black", +"158 c black", +"159 c black", +"160 c black", +"161 c black", +"162 c black", +"163 c black", +"164 c black", +"165 c black", +"166 c black", +"167 c black", +"168 c black", +"169 c black", +"170 c black", +"171 c black", +"172 c black", +"173 c black", +"174 c black", +"175 c black", +"176 c black", +"177 c black", +"178 c black", +"179 c black", +"180 c black", +"181 c black", +"182 c black", +"183 c black", +"184 c black", +"185 c black", +"186 c black", +"187 c black", +"188 c black", +"189 c black", +"190 c black", +"191 c black", +"192 c black", +"193 c black", +"194 c black", +"195 c black", +"196 c black", +"197 c black", +"198 c black", +"199 c black", +"200 c black", +"201 c black", +"202 c black", +"203 c black", +"204 c black", +"205 c black", +"206 c black", +"207 c black", +"208 c black", +"209 c black", +"210 c black", +"211 c black", +"212 c black", +"213 c black", +"214 c black", +"215 c black", +"216 c black", +"217 c black", +"218 c black", +"219 c black", +"220 c black", +"221 c black", +"222 c black", +"223 c black", +"224 c black", +"225 c black", +"226 c black", +"227 c black", +"228 c black", +"229 c black", +"230 c black", +"231 c black", +"232 c black", +"233 c black", +"234 c black", +"235 c black", +"236 c black", +"237 c black", +"238 c black", +"239 c black", +"240 c black", +"241 c black", +"242 c black", +"243 c black", +"244 c black", +"245 c black", +"246 c black", +"247 c black", +"248 c black", +"249 c black", +"250 c black", +"251 c black", +"252 c black", +"253 c black", +"254 c black", +"255 c black", +"000000000000000000000000000000000000000", +"000001001001002003004005006007008009000", +"000001001002003004005006007008009010000", +"000001002003004005006007008009010011000", +"000002003004005006007008009010011012000", +"000003004005006007008009010011012013000", +"000004005006007008009010011012013014000", +"000005006007008009010011012013014015000", +"000006007008009010011012013014015016000", +"000007008009010011012013014015016017000", +"000008009010011012013014015016017017000", +"000009010011012013014015016017017017000", +"000000000000000000000000000000000000000" +}; diff --git a/kernel/src/ThirdParty/wx/treemultictrl/wxTreeMultiCtrl.cpp b/kernel/src/ThirdParty/wx/treemultictrl/wxTreeMultiCtrl.cpp new file mode 100644 index 0000000..00cb190 --- /dev/null +++ b/kernel/src/ThirdParty/wx/treemultictrl/wxTreeMultiCtrl.cpp @@ -0,0 +1,1985 @@ +//--------------------------------------------------------------------------- +// $RCSfile: wxTreeMultiCtrl.cpp,v $ +// $Source: /cvs/creatis/bbtk/kernel/src/ThirdParty/wx/treemultictrl/wxTreeMultiCtrl.cpp,v $ +// $Revision: 1.1 $ +// $Date: 2008/03/28 13:42:19 $ +//--------------------------------------------------------------------------- +// Author: Jorgen Bodde +// Copyright: (c) Jorgen Bodde +// License: wxWidgets License +//--------------------------------------------------------------------------- + +#ifdef __GNUG__ + #pragma implementation "wxTreeMultiCtrl.h" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" +#include "wx/treebase.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/arrimpl.cpp" + +#include "wx/treemultictrl/wxTreeMultiCtrl.h" +#include "wx/treemultictrl/wxTreeMultiEvent.h" +#include "tmcimages.h" + + + +//---------------------------------------------------------------------------- +// wxTreeMultiItem +//---------------------------------------------------------------------------- + +WX_DEFINE_OBJARRAY(wxArrayTreeMultiItem); + +//---------------------------------------------------------------------------- +// wxTreeMultiCtrl +//---------------------------------------------------------------------------- + +IMPLEMENT_DYNAMIC_CLASS(wxTreeMultiCtrl, wxScrolledWindow) + +// WDR: event table for wxTreeMultiCtrl +BEGIN_EVENT_TABLE(wxTreeMultiCtrl, wxScrolledWindow) + EVT_LEFT_DOWN (wxTreeMultiCtrl::OnMouseClick) + EVT_LEFT_DCLICK(wxTreeMultiCtrl::OnMouseClick) + EVT_RIGHT_DOWN (wxTreeMultiCtrl::OnRightMouseClick) + EVT_PAINT(wxTreeMultiCtrl::OnPaint) + EVT_SIZE(wxTreeMultiCtrl::OnSize) +// EVT_KEY_UP(wxTreeMultiCtrl::OnKey) +END_EVENT_TABLE() + +bool wxTreeMultiCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, + const wxSize& size, long style, const wxValidator & WXUNUSED(validator), + const wxString& name ) +{ + wxScrolledWindow::Create( parent, id, pos, size, style | wxTAB_TRAVERSAL, name); + + _create_called = true; + + // do the init + Init(); + + return TRUE; +} + +void wxTreeMultiCtrl::Init() +{ + _root.Clear(); + + _expandBmp = 0; + _collBmp = 0; + +#if(CHECKBOXVIEW) + _checkBmp = 0; + _uncheckBmp = 0; + _tristateBmp = 0; + + _checkHeight = 11; + _checkWidth = 11; + + _checkboxView = false; +#endif + + _gutterWidth = WXTMC_GUTTER_DEFAULT; + _iconWidth = 11; + _iconHeight = 11; + _maxHeight = 1;; + _iconDeltaY = 2; + _spacingY = WXTMC_YSPACING_DEFAULT; + _captionHeight = 13; + + // create two bitmap nodes for drawing + + _expandBmp = new wxBitmap(expand_xpm); + _collBmp = new wxBitmap(collapse_xpm); + + // calculate average font height for bitmap centering + + _iconWidth = _expandBmp->GetWidth(); + _iconHeight = _expandBmp->GetHeight(); + +#if(CHECKBOXVIEW) + // create bitmaps for checkboxes + _checkBmp = new wxBitmap(checked_icon); + _uncheckBmp = new wxBitmap(unchecked_icon); + _tristateBmp = new wxBitmap(tristate_icon); + + // adjust the height if the checkboxes are higher + // so that everything is alligned properly + _checkHeight = _checkBmp->GetHeight(); + _checkWidth = _checkBmp->GetWidth(); +#endif + + // remember the highest of the two bitmaps so there is + // always enough room + _maxHeight = _iconHeight; + +#if(CHECKBOXVIEW) + if(_maxHeight < _checkHeight) + _maxHeight = _checkHeight; +#endif + + // set standard highlighting brush + this->m_HilightBrush = new wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT),wxSOLID); + + // set standard DC font + _captionFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); + + // adjust bitmap icon y position so they are centered + AdjustIconsDeltaY(); + + // set virtual size to this window size + if (_create_called) { + wxSize wndsize = GetSize(); + SetVirtualSize(wndsize.GetWidth(), wndsize.GetWidth()); + } +} + +void wxTreeMultiCtrl::SetCaptionFont(const wxFont &font) +{ + _captionFont = font; + + // adjust the icons so that they are in the middle + AdjustIconsDeltaY(); + + RedrawFromNode(0); +}; + +void wxTreeMultiCtrl::AdjustIconsDeltaY() +{ + int x = 0, y = 0; + + if(_captionFont.Ok()) + GetTextExtent(wxT("jG"), &x, &y, 0, 0, &_captionFont); + _captionHeight = y; + + if(_maxHeight < _captionHeight) + _maxHeight = _captionHeight; + + // determine the center pos for the [+] + _iconDeltaY = abs(_maxHeight - _iconHeight) / 2 + 1; + if(_iconDeltaY < 1) + _iconDeltaY = 1; + +#if(CHECKBOXVIEW) + // determine the center pos for the checkbox + _checkDeltaY = abs(_maxHeight - _checkHeight) / 2 + 1; + if(_checkDeltaY < 1) + _checkDeltaY = 1; +#endif +} + +wxTreeMultiCtrl::~wxTreeMultiCtrl() +{ + // delete the bitmap resources + delete _expandBmp; + delete _collBmp; + +#if(CHECKBOXVIEW) + delete _checkBmp; + delete _uncheckBmp; + delete _tristateBmp; +#endif +} + +wxTreeMultiItem wxTreeMultiCtrl::AddRoot(const wxString &caption, const wxString &name) +{ + wxTreeMultiItem result((TreeMultiItemBase *)&_root); + result = AppendNode(result, caption, name); + + return result; +} + +wxTreeMultiItem wxTreeMultiCtrl::AppendWindow(const wxTreeMultiItem &ParentItem, wxWindow *window, const wxString &name, const wxTreeMultiWindowInfo &info, int flags) +{ + // add window only if the parent item is valid and... + wxCHECK(ParentItem.IsOk(), wxTreeMultiItem(0)); + + TreeMultiItemNode* parent = ParentItem.GetItem()->IsTreeMultiItemNode(); // also roots are nodes + + // ... is a node + wxCHECK(parent != NULL, wxTreeMultiItem(0)); + + // now, append node to the tree control: + wxTreeMultiItem NewWindowItem(this->InsertWindow(parent,wx_static_cast(size_t,parent->GetNodeCount()),window,name,info,flags)); + // redraw the stucture: + this->RedrawFromNode(parent); + // return the new window + return NewWindowItem; +} + +wxTreeMultiItem wxTreeMultiCtrl::InsertWindow(wxTreeMultiItem const& ParentItem, size_t Position, wxWindow *window, wxString const& name, wxTreeMultiWindowInfo const& info, int flags) +{ + // add window only if the parent item is valid and... + wxCHECK(ParentItem.IsOk(), wxTreeMultiItem(0)); + + TreeMultiItemNode* parent = ParentItem.GetItem()->IsTreeMultiItemNode(); // also roots are nodes + + // ... is a node + wxCHECK(parent != NULL, wxTreeMultiItem(0)); + + // now, append node to the tree control: + wxTreeMultiItem NewWindowItem(this->InsertWindow(parent,Position,window,name,info,flags)); + // redraw the stucture: + this->RedrawFromNode(parent); + // return the new window + return NewWindowItem; +} /* wxTreeMultiCtrl::InsertWindow(wxTreeMultiItem const&, size_t, wxWindow*, wxString const&, wxTreeMultiWindowInfo const&, int) */ + +wxTreeMultiItem wxTreeMultiCtrl::PrependWindow(wxTreeMultiItem const& ParentItem, wxWindow *window, const wxString &name, wxTreeMultiWindowInfo const& info, int flags) +{ + // add window only if the parent item is valid and... + wxCHECK(ParentItem.IsOk(), wxTreeMultiItem(0)); + + TreeMultiItemNode* parent = ParentItem.GetItem()->IsTreeMultiItemNode(); // also roots are nodes + + // ... is a node + wxCHECK(parent != NULL, wxTreeMultiItem(0)); + + // now, append node to the tree control: + wxTreeMultiItem NewWindowItem(this->InsertWindow(parent,0,window,name,info,flags)); + // redraw the stucture: + this->RedrawFromNode(parent); + // return the new window + return NewWindowItem; +} /* wxTreeMultiCtrl::PrependWindow(wxTreeMultiItem const&, wxWindow*, const wxString &, wxTreeMultiWindowInfo const&, int) */ + +wxTreeMultiItem wxTreeMultiCtrl::AppendNode(wxTreeMultiItem const& ParentItem, const wxString &caption, const wxString &name) +{ + // add window only if the parent item is valid and... + wxCHECK(ParentItem.IsOk(), wxTreeMultiItem(0)); + + TreeMultiItemNode* parent = ParentItem.GetItem()->IsTreeMultiItemNode(); // also roots are nodes + + // ... is a node + wxCHECK(parent != NULL, wxTreeMultiItem(0)); + + // now, append node to the tree control: + wxTreeMultiItem NewNodeItem(this->InsertNode(parent,wx_static_cast(size_t,parent->GetNodeCount()),caption,name)); + // redraw the structure: + this->RedrawFromNode(parent); + // return the new node: + return NewNodeItem; +} /* wxTreeMultiCtrl::AppendNode(wxTreeMultiItem const&, const wxString &, const wxString&) */ + +wxTreeMultiItem wxTreeMultiCtrl::InsertNode(wxTreeMultiItem const& ParentItem, size_t Position, wxString const& caption, wxString const& name) +{ + // add window only if the parent item is valid and... + wxCHECK(ParentItem.IsOk(), wxTreeMultiItem(0)); + + TreeMultiItemNode* parent = ParentItem.GetItem()->IsTreeMultiItemNode(); // also roots are nodes + + // ... is a node + wxCHECK(parent != NULL, wxTreeMultiItem(0)); + + // now, append node to the tree control: + wxTreeMultiItem NewNodeItem(this->InsertNode(parent,Position,caption,name)); + // redraw the structure: + this->RedrawFromNode(parent); + // return the new node: + return NewNodeItem; +} /* wxTreeMultiCtrl::InsertNode(wxTreeMultiItem const&, size_t, wxString const&, wxString const&) */ + +wxTreeMultiItem wxTreeMultiCtrl::PrependNode(wxTreeMultiItem const& ParentItem, wxString const& caption, wxString const& name) +{ + // add window only if the parent item is valid and... + wxCHECK(ParentItem.IsOk(), wxTreeMultiItem(0)); + + TreeMultiItemNode* parent = ParentItem.GetItem()->IsTreeMultiItemNode(); // also roots are nodes + + // ... is a node + wxCHECK(parent != NULL, wxTreeMultiItem(0)); + + // now, append node to the tree control: + wxTreeMultiItem NewNodeItem(this->InsertNode(parent,0,caption,name)); + // redraw the structure: + this->RedrawFromNode(parent); + // return the new node: + return NewNodeItem; +} /* wxTreeMultiCtrl::PrependNode(wxTreeMultiItem const&, wxString const&, wxString const&) */ + +bool wxTreeMultiCtrl::Delete(wxTreeMultiItem &item) +{ + bool redraw = true; + wxCHECK(item.IsOk(), false); + + wxTreeMultiItem nullItem(0); + + + // if item has been selected, remove it from the selected list: + size_t ItemIndex(this->GetSelectedItemIndex(item)); + + if (ItemIndex != this->GetSelectedItemCount()) + this->m_SelectedItems.RemoveAt(ItemIndex); + + // get parent, to delete item from + TreeMultiItemNode *p = item.GetItem()->GetParent(); + + // first check if it was visible, if so from the parent off + // it needs redrawing + redraw = item.GetItem()->IsVisible(); + if(p) + p->DeleteNode(item.GetItem()); + else + _root.DeleteNode(item.GetItem()); + + item = nullItem; + + // do redraw when node was visible + if(redraw) + RedrawFromNode(p); + + return true; +} + +void wxTreeMultiCtrl::DeleteChildren(const wxTreeMultiItem &item) +{ + if(item.IsNodeItem()) + { + TreeMultiItemNode *n = (TreeMultiItemNode *)item.GetItem(); + + // remove all children from the selected item list: + if (n->GetNodeCount() > 0) + { + // variable definitions and initializations: + int Cookie; + wxTreeMultiItem FirstItemIterator(this->GetFirstChild(item,Cookie)), LastItemIterator(this->GetLastChild(item)); + + for (;;) + { + size_t ItemIndex(this->GetSelectedItemIndex(item)); // variable definition and initialization + + if (ItemIndex != this->GetSelectedItemCount()) + this->m_SelectedItems.RemoveAt(ItemIndex); + if (FirstItemIterator == LastItemIterator) + break; // all children checked + else + FirstItemIterator = this->GetNext(FirstItemIterator); + } /* for */ + } /* if */ + // delete children: + n->Clear(); + // redraw: + RedrawFromNode(n); + } +} + +void wxTreeMultiCtrl::Expand(const wxTreeMultiItem &item, bool recursive) +{ + if(item.IsOk()) + { + TreeMultiItemNode *n = item.GetItem()->IsTreeMultiItemNode(); + if(!n) + n = item.GetItem()->GetParent(); + DoFold(n, true, recursive); + RedrawFromNode(item.GetItem()->IsTreeMultiItemNode()); + } +} + +void wxTreeMultiCtrl::Collapse(const wxTreeMultiItem &item, bool recursive) +{ + if(item.IsOk()) + { + TreeMultiItemNode *n = item.GetItem()->IsTreeMultiItemNode(); + if(!n) + n = item.GetItem()->GetParent(); + DoFold(n, false, recursive); + RedrawFromNode(item.GetItem()->IsTreeMultiItemNode()); + } +} + + +void wxTreeMultiCtrl::ExpandNodes(bool recursive) +{ + // go through all children and call DoFold recursively + for(int i = 0; i < _root.GetNodeCount(); i++) + DoFold(_root.GetNode(i), true, recursive); + RedrawFromNode(0); +} + +void wxTreeMultiCtrl::CollapseNodes(bool recursive) +{ + // go through all children and call DoFold recursively + for(int i = 0; i < _root.GetNodeCount(); i++) + DoFold(_root.GetNode(i), false, recursive); + RedrawFromNode(0); +} + +void wxTreeMultiCtrl::CollapseAndReset(const wxTreeMultiItem &item) +{ + if(item.IsNodeItem()) + { + TreeMultiItemNode *n = (TreeMultiItemNode *)item.GetItem(); + + // delete all kids + n->Clear(); + Collapse(item, false); + } +} + +// Selection manipulation +wxTreeMultiItem wxTreeMultiCtrl::GetFirstSelectedItem(void) const +{ + if (this->GetSelectedItemCount() > 0) + return this->m_SelectedItems[0]; + else + return wxTreeMultiItem(); +} /* wxTreeMultiCtrl::GetFirstSelectedItem(void) const */ + +wxTreeMultiItem wxTreeMultiCtrl::GetLastSelectedItem(void) const +{ + if (this->GetSelectedItemCount() > 0) + return this->m_SelectedItems[this->GetSelectedItemCount()-1]; + else + return wxTreeMultiItem(); +} /* wxTreeMultiCtrl::GetLastSelectedItem(void) const */ + +wxTreeMultiItem wxTreeMultiCtrl::GetSelectedItem(size_t Index) const +{ + if (Index < this->GetSelectedItemCount()) + return this->m_SelectedItems[Index]; + else + return wxTreeMultiItem(); +} /* wxTreeMultiCtrl::GetSelectedItem(size_t Index) const */ + +size_t wxTreeMultiCtrl::GetSelectedItemIndex(wxTreeMultiItem const& Item) const +{ + // attention: the function wxArray::Index() can NOT be used in a save manner as it only checks the address of an item + // element but it is not guaranteed that Item may not be a copy of the originally inserted item + const size_t NoOfSelectedItems = this->GetSelectedItemCount(); + + size_t Index(0); + + + while ((Index < NoOfSelectedItems) && (this->m_SelectedItems[Index] != Item)) + ++Index; + return Index; +} /* wxTreeMultiCtrl::GetSelectedItemIndex(wxTreeMultiItem const&) const */ + +void wxTreeMultiCtrl::SelectItem(wxTreeMultiItem const& Item, bool UnselectOthers, bool ExpandSelection) +{ + TreeMultiItemNode* NodePtr(Item.GetItem()->IsTreeMultiItemNode()); + + + // only nodes can be selected and they can only be selected if they are not already selected: + if ((NodePtr == NULL) || NodePtr->IsSelected()) + return; + + // inform that we are about to change: + wxTreeMultiEvent Event(wxEVT_COMMAND_TREE_MULTI_SEL_CHANGING,Item); // variable definition and initialization + + if (this->m_SelectedItems.GetCount() > 0) // the last item in the array is always the latest inserted item + Event.SetOldItem(this->m_SelectedItems.Last()); + Event.SetEventObject(this); + if (this->GetEventHandler()->ProcessEvent(Event) && !(Event.IsAllowed())) + return; // vetoed + + // make sure that the to be selected item can be seen: + this->Include(Item); + + // variable definition and initialization: + wxTreeMultiItem ExcludedParent(this->GetExcludedParent(Item)); + + while (ExcludedParent.IsOk()) + { + this->Include(ExcludedParent); + ExcludedParent = this->GetExcludedParent(Item); + } /* while */ + + // unselect items if necessary: + if (UnselectOthers) + this->UnselectAll(); + // expand selection if necessary: + if (ExpandSelection) + { + // variable definition: + wxTreeMultiItem FirstItemIterator, LastItemIterator; + wxTreeMultiItem LastSelectedItem; + + // determine the last selected item or the first item in case nothing has been selected before: + if (this->m_SelectedItems.GetCount() > 0) + LastSelectedItem = this->m_SelectedItems.Last(); + else + LastSelectedItem = this->GetFirstRoot(); + // determine the item from which to start and the one with which to end the selection: + if (Item.GetItem()->GetY() > LastSelectedItem.GetItem()->GetY()) + { + FirstItemIterator = LastSelectedItem; + LastItemIterator = Item; + } /* if */ + else + { + FirstItemIterator = Item; + LastItemIterator = LastSelectedItem; + } /* if */ + // select all items that are a node and are placed between the two limiting iterators (included the limits): + for (;;) + { + if (!(FirstItemIterator.IsSelected()) && FirstItemIterator.IsNodeItem()) + { + FirstItemIterator.GetItem()->Select(); + this->m_SelectedItems.Add(FirstItemIterator); + this->RefreshRect(wxRect(FirstItemIterator.GetItem()->GetX(), FirstItemIterator.GetItem()->GetY(), + FirstItemIterator.GetItem()->GetWidth(),FirstItemIterator.GetItem()->GetHeight())); + } /* if */ + if (FirstItemIterator == LastItemIterator) + break; // done + // continue iterating: + FirstItemIterator = this->GetNext(FirstItemIterator); + } /* for */ + } /* if */ + else // select passed item only + { + NodePtr->Select(); + this->m_SelectedItems.Add(NodePtr); + this->RefreshRect(wxRect(NodePtr->GetX(),NodePtr->GetY(),NodePtr->GetWidth(),NodePtr->GetHeight())); + } /* if */ + + // inform that we have selected the item: + Event.SetEventType(wxEVT_COMMAND_TREE_MULTI_SEL_CHANGED); + this->GetEventHandler()->ProcessEvent(Event); +} /* wxTreeMultiCtrl::SelectItem(wxTreeMultiItem const&, bool, bool) */ + +void wxTreeMultiCtrl::UnselectAll(void) +{ + const size_t NoOfSelectedItems = this->m_SelectedItems.GetCount(); + + + for (size_t i=0; iRefreshRect(wxRect(this->m_SelectedItems[i].GetItem()->GetX(), this->m_SelectedItems[i].GetItem()->GetY(), + this->m_SelectedItems[i].GetItem()->GetWidth(),this->m_SelectedItems[i].GetItem()->GetHeight())); + this->m_SelectedItems[i].GetItem()->Unselect(); + } /* for */ + this->m_SelectedItems.Clear(); +} /* wxTreeMultiCtrl::UnselectAll(void) */ + +void wxTreeMultiCtrl::Unselect(wxTreeMultiItem const& Item) +{ + size_t ItemIndex(this->GetSelectedItemIndex(Item)); + + + if (ItemIndex != this->GetSelectedItemCount()) + { + Item.GetItem()->Unselect(); + this->m_SelectedItems.RemoveAt(ItemIndex); + this->RefreshRect(wxRect(Item.GetItem()->GetX(),Item.GetItem()->GetY(),Item.GetItem()->GetWidth(),Item.GetItem()->GetHeight())); + } /* if */ +} /* wxTreeMultiCtrl::Unselect(wxTreeMultiItem const&) */ + +void wxTreeMultiCtrl::DoFold(TreeMultiItemBase *item, bool expand, bool recursive) +{ + + // go through all node objects on this level, and expand or + // collapse them + + if(item == 0) + return; + + // if this is a node, use it to go through all the subnodes (if needed) + // if not, then just exit. + + TreeMultiItemNode *node = item->IsTreeMultiItemNode(); + if(node) + { + node->Fold(expand); + + // go recursive + if(recursive) + { + TreeMultiItemNode *p; + for(int i = 0; i < node->GetNodeCount(); i++) + { + // get node, and if a real node, then call fold + p = node->GetNode(i)->IsTreeMultiItemNode(); + if(p) + p->Fold(expand); + + // go recursive for every node + DoFold(p, expand, recursive); + } + } + } +} + +void wxTreeMultiCtrl::Exclude(const wxTreeMultiItem &item) +{ + wxCHECK2(item.IsOk(), return); + + // exclude the item, and refresh + // if already excluded, skip + + if(!item.GetItem()->IsExcluded()) + { + item.GetItem()->SetExcluded(true); + RedrawFromParentNode(item.GetItem()); + } +} + +void wxTreeMultiCtrl::Include(const wxTreeMultiItem &item) +{ + wxCHECK2(item.IsOk(), return); + + // include the item, and refresh. If not + // excluded, do nothing + + if(item.GetItem()->IsExcluded()) + { + item.GetItem()->SetExcluded(false); + RedrawFromParentNode(item.GetItem()); + } +} + +wxTreeMultiItem wxTreeMultiCtrl::GetExcludedParent(const wxTreeMultiItem &item) +{ + wxCHECK(item.IsOk(), wxTreeMultiItem(0)); + + // go find the parent (including this one) that + // can be the excluded one + + TreeMultiItemNode *n = item.GetItem()->IsTreeMultiItemNode(); + if(n && n->IsExcluded()) + return wxTreeMultiItem(n); + + n = item.GetItem()->GetParent(); + while(n) + { + if(n->IsExcluded()) + return wxTreeMultiItem(n); + else + n = n->GetParent(); + } + + return wxTreeMultiItem(0); +} + +void wxTreeMultiCtrl::OnSize(wxSizeEvent &WXUNUSED(event)) +{ + RecalculateSpanSizes(); +} + +void wxTreeMultiCtrl::OnPaint(wxPaintEvent& WXUNUSED(event) ) +{ + wxPaintDC dc(this); + + PrepareDC(dc); + + // go recursive and draw the whole visible tree. + dc.SetFont(_captionFont); + for(int i = 0; i < _root.GetNodeCount(); i++) + DrawNode(_root.GetNode(i), dc); +} + +void wxTreeMultiCtrl::DrawNode(TreeMultiItemBase *b, wxDC &dc) +{ + // go through this item .. if it is a node, draw + // the caption, else reposition the window. + + if(!b) + return; + + // forget it if this node is not visible + if(b->IsVisible()) + { + int bmpOffsetX = b->GetX() - (_gutterWidth + _iconWidth); + +#if(CHECKBOXVIEW) + // now draw the checkbox if there is any, in the proper state + if(b->GetCheckbox()) + { + DrawCheckbox(b, dc); + + // adjust the bmpOffset because we also have a checkbox + bmpOffsetX -= _checkWidth; + } +#endif + + if(b->IsTreeMultiItemNode()) + { + // draw the node icon and the caption + TreeMultiItemNode *n = (TreeMultiItemNode *)b; + + // set background of caption item + if (n->IsSelected()) + { + dc.SetBrush(*(this->m_HilightBrush)); + dc.SetPen(wxPen(this->m_HilightBrush->GetColour(),1,wxSOLID)); + } /* if */ + else + { + dc.SetBrush(wxBrush(*wxWHITE,wxSOLID)); + dc.SetPen(wxPen(*wxWHITE,1,wxSOLID)); + } /* if */ + dc.DrawRectangle(n->GetX(),n->GetY(),n->GetWidth(),n->GetHeight()); + // draw caption + dc.DrawText(n->GetCaption(), n->GetX(), n->GetY()); + + // draw the bitmap for the state + if(n->IsExpanded()) + dc.DrawBitmap(*_expandBmp, bmpOffsetX, n->GetY() + _iconDeltaY, true); + else + dc.DrawBitmap(*_collBmp, bmpOffsetX, n->GetY() + _iconDeltaY, true); + + // now go through all the subnodes + for(int i = 0; i < n->GetNodeCount(); i++) + DrawNode(n->GetNode(i), dc); + + } + } +} + +#if(CHECKBOXVIEW) + +void wxTreeMultiCtrl::DrawCheckbox(TreeMultiItemBase *b, wxDC &dc, bool convertScrolled) +{ + wxCHECK2(b, return); + + wxBitmap *bmp; + int bmpOffsetX = b->GetX() - (_gutterWidth + _iconWidth); + + switch(b->GetCheckboxState()) + { + case 0: + bmp = _uncheckBmp; + break; + case 1: + bmp = _checkBmp; + break; + default: + bmp = _tristateBmp; + break; + } + + int x, xx, y, yy; + + if(b->IsTreeMultiItemWindow()) + { + xx = x = bmpOffsetX - ((TreeMultiItemWindow *)b)->GetFrontSpacing() + _checkWidth; + yy = y = b->GetY() + _checkDeltaY; + } + else + { + xx = x = bmpOffsetX; + yy = y = b->GetY() + _checkDeltaY; + } + + if(convertScrolled) + CalcScrolledPosition(x, y, &xx, &yy); + + dc.DrawBitmap(*bmp, xx, yy, true); +} + +#endif // #if(CHECKBOXVIEW) + +void wxTreeMultiCtrl::OnKey(wxKeyEvent &event) +{ + // check if we need to traverse to upper or lower + // control in the list + if(event.GetKeyCode() == WXK_TAB) + { + wxTreeMultiItem item = GetFocus(); + if(item.IsOk()) + { + // traverse down direction + if(!event.ShiftDown()) + item = FindNextVisibleWindowItem(item.GetItem()); + //else // traverse in up direction + // item = FindPreviousVisibleWindowItem(item); + + if(item.IsOk()) + { + TreeMultiItemWindow *w = item.GetItem()->IsTreeMultiItemWindow(); + if(w) + { + wxWindow *wnd = w->GetWindow(); + wnd->SetFocus(); + } + } + } + } + else + event.Skip(); +} + +void wxTreeMultiCtrl::OnMouseClick( wxMouseEvent &event ) +{ + // react on double click and left mouse down + if(event.LeftDown() || event.LeftDClick()) + { + // get translation point + wxPoint pt( event.GetPosition() ); + + int x = 0, y = 0; + CalcUnscrolledPosition( pt.x, pt.y, &x, &y ); + + // go check if we clicked a treenode + int flags; + wxPoint p(x,y); + wxTreeMultiItem id = HitTest(p, flags); + +#if(CHECKBOXVIEW) + if(flags == wxTMC_HITTEST_CHECKBOX) + { + // toggle the checkbox, and redraw + if(id.IsOk()) + { + TreeMultiItemBase *b = id.GetItem(); + b->SetCheckboxState((b->GetCheckboxState()+1) & 0x1); + + TreeMultiItemWindow *w = b->IsTreeMultiItemWindow(); + if(w) + { + // try to force a focus on the window. This could + // be extended by searching for the first edit control + // class but for now, just a focus is tried. + w->GetWindow()->Enable(b->GetCheckboxState() == 1); + w->GetWindow()->SetFocus(); + + // draw the checkbox in the state needed + wxClientDC dc(this); + DrawCheckbox(b, dc, true); + + // TODO: determine if the upper parents should be + // tristated or not + + ScanTristateCheckstates(b); + + } + else if(b->IsTreeMultiItemNode()) + { + // descend to all the children and set the state of the parent + SetRecursiveCheckState((TreeMultiItemNode *)b, b->GetCheckboxState() == 1); + RedrawFromNode((TreeMultiItemNode *)b); + } + } + } + else +#endif // #if(CHECKBOXVIEW) + { + // react on left mouse button, to fold and on + // right for caption doubleclick + int area = -1; + +// adjust behaviour for Linux (single click = always fold) +#ifndef LINUX + if(event.LeftDClick()) + area = wxTMC_HITTEST_CAPTION; + else + area = wxTMC_HITTEST_GUTTER; +#else + area = flags; +#endif + +// Linux (single or double click -> always fold + if (id.IsOk()) + { +#ifdef LINUX + // we have a valid item, if it is a node, then fold + TreeMultiItemNode *n = id.GetItem()->IsTreeMultiItemNode(); + if(n) + { + this->SelectItem(id); + Fold(n, !n->IsExpanded()); + } /* if */ +#else + if (event.LeftDown()) + if (flags == wxTMC_HITTEST_GUTTER) + { + TreeMultiItemNode *n = id.GetItem()->IsTreeMultiItemNode(); // for some reasons also windows may have set the flag + + if (n != NULL) + Fold(n, !n->IsExpanded()); + } /* if */ + else if (flags == wxTMC_HITTEST_CAPTION) + { + TreeMultiItemNode *n = id.GetItem()->IsTreeMultiItemNode(); // for some reasons also windows may have set the flag + + if (n != NULL) + { + this->SelectItem(id); + this->RedrawFromNode(n); + } /* if */ + } /* if */ +#endif + } /* if */ + else + this->UnselectAll(); + } + } +} + +void wxTreeMultiCtrl::OnRightMouseClick(wxMouseEvent& Event) +{ + if (Event.RightDown()) + if (Event.Dragging()) + this->UnselectAll(); + else + { + // variable definitions: + int Flags; + wxPoint Point; + + // translate mouse coordinates: + CalcUnscrolledPosition(Event.GetPosition().x,Event.GetPosition().y,&(Point.x),&(Point.y)); + // check if the mouse is above the caption of an item: + wxTreeMultiItem Item(this->HitTest(Point,Flags)); // variable definition and initialization + + if (Item.IsOk() && (Flags == wxTMC_HITTEST_CAPTION)) + { + this->SelectItem(Item); + this->RedrawFromNode(Item.GetItem()->IsTreeMultiItemNode()); + Event.Skip(); // window will convert right mouse click to a context menu event or proceed with + // a right mouse click event if the context menu event cannot be processed + } /* if */ + else + this->UnselectAll(); + } /* if */ + else + this->UnselectAll(); +} /* wxTreeMultiCtrl::OnRightMouseClick(wxMouseEvent&) */ + +wxTreeMultiItem wxTreeMultiCtrl::HitTest(wxPoint const& pt, int &flags) +{ + // scan all nodes to see which one matches + TreeMultiItemBase *b = 0; + for(int i = 0; i < _root.GetNodeCount() && !b; i++) + b = FindNodeByPoint(_root.GetNode(i), pt, flags); + + if(!b) + { + // none found, reset + flags = 0; + return wxTreeMultiItem(0); + } + + // return an item + return wxTreeMultiItem(b); +} + +TreeMultiItemBase *wxTreeMultiCtrl::FindNodeByPoint(TreeMultiItemBase *b, wxPoint const& pt, int &area) +{ + wxCHECK(b, 0); + + // if this layer is not visible, return with nothing. + if(!b->IsVisible()) + return 0; + + area = 0; + + // now see if our y is matching the mouse + if(pt.y >= b->GetY() && pt.y < (b->GetY() + b->GetHeight())) + { +#if(CHECKBOXVIEW) + // if we are checkboxed, calculate the checkbox position + if(b->GetCheckbox()) + { + int extraSpacing = 0, extraWidth = 0; + + // now for a windows item, this is minus the gutter. For a normal node it is X minus checkbox + if(b->IsTreeMultiItemWindow()) + { + extraWidth = _checkWidth; + extraSpacing = ((TreeMultiItemWindow *)b)->GetFrontSpacing(); + } + else + extraSpacing = 4; + + if(pt.x > (b->GetX() - extraSpacing - _checkWidth) && pt.x < (b->GetX() - extraSpacing + extraWidth)) + { + area = wxTMC_HITTEST_CHECKBOX; + return b; + } + } +#endif + + // allrighty we have something, now where and what is it (look with x) + if(pt.x < b->GetX()) + area = wxTMC_HITTEST_GUTTER; + + /** \todo Match only the real part of the caption, window (we assume x > GetX() which is the rest) + HOWEVER the window probably doesn't propagate the click event back to the parent, so we might + leave it like this so the use can click behind a window so it will be selected. + */ + else + { + // inside area, return proper flag + if(b->IsTreeMultiItemNode()) + area = wxTMC_HITTEST_CAPTION; + else + area = wxTMC_HITTEST_WINDOW; + } + + return b; + } + else + { + // not found, let's try our children if we have some + TreeMultiItemNode *n = b->IsTreeMultiItemNode(); + if(n) + { + TreeMultiItemBase *bb = 0; + for(int i = 0; i < n->GetNodeCount() && !bb; i++) + bb = FindNodeByPoint(n->GetNode(i), pt, area); + + // keep returning result to caller + return bb; + } + } + + return 0; +} + +wxTreeMultiItem wxTreeMultiCtrl::GetFocus() +{ + wxWindow *wnd = wxWindow::FindFocus(); + + // now find window that holds this item. if not + // visible it cannot have focus (should not have) + + wxTreeMultiItem item = FindWindowNode(wnd); + if(item.IsOk() && item.GetItem()->IsVisible()) + return item; + + return wxTreeMultiItem(0); +} + +#if(CHECKBOXVIEW) + +void wxTreeMultiCtrl::SetRecursiveCheckState(TreeMultiItemNode *n, bool check) +{ + int state = 0; + if(check) + state++; + + // go check all kids on this level + for(int i = 0; i < n->GetNodeCount(); i++) + { + // check all the nodes, and go deeper + n->GetNode(i)->SetCheckboxState(state); + if(n->GetNode(i)->IsTreeMultiItemNode()) + SetRecursiveCheckState((TreeMultiItemNode *)n->GetNode(i), check); + } +} + +void wxTreeMultiCtrl::ScanTristateCheckstates(TreeMultiItemBase *b) +{ + // check from the parent on, all node entries and see if they are + // checked or cleared or scattered + TreeMultiItemNode *p = b->GetParent(); + + if(p && p->GetCheckbox()) + { + bool foundcheck = false, foundclear = false; + for(size_t i = 0; i < (size_t)p->GetNodeCount(); ++i) + { + // only evaluate when checkboxed + if(p->GetNode(i)->IsTreeMultiItemWindow() && p->GetNode(i)->GetCheckbox()) + { + // record instance of a cleared checkbox + if(!p->GetNode(i)->GetCheckboxState()) + foundclear = true; + // record instance of checked checkbox + if(p->GetNode(i)->GetCheckboxState() == 1) + foundcheck = true; + } + } + + // if we have both check and clear, go tristate + // if all clear, clear parent and if all set, then set parent + if(foundclear && !foundcheck) + p->SetCheckboxState(0); + else if(!foundclear && foundcheck) + p->SetCheckboxState(1); + else if(foundclear && foundcheck) + p->SetCheckboxState(2); + + //wxClientDC dc; + //DrawCheckbox(p, dc, false); + RedrawFromNode(p); + } +} + +#endif // #if(CHECKBOXVIEW) + +wxTreeMultiItem wxTreeMultiCtrl::InsertNode(TreeMultiItemNode* ParentPtr, size_t Position, wxString const& Caption, wxString const& Name) +{ + int extX, extY; + + TreeMultiItemNode* NodePtr(new TreeMultiItemNode(ParentPtr,Caption,Name)); // generate new node pointer + + + // continue with initializing the new node: +#if(CHECKBOXVIEW) + // if checkbox view is desired, tag this item as a checkbox + // and set the state as 'false' + NodePtr->SetCheckbox(_checkboxView); + NodePtr->SetCheckboxState(0); +#endif + // calculate the height and width + this->GetTextExtent(Caption,&extX,&extY,0,0,&(this->_captionFont)); + NodePtr->SetHeight(extY); + NodePtr->SetWidth(extX); + // finally, insert node: + if (Position < (size_t)ParentPtr->GetNodeCount()) + ParentPtr->InsertNode(NodePtr,Position); + else + ParentPtr->AddNode(NodePtr); + // return the newly created node: + return wxTreeMultiItem(NodePtr); +} /* wxTreeMultiCtrl::InsertNode(TreeMultiItemNode*, size_t, wxString const&, wxString const&) */ + +wxTreeMultiItem wxTreeMultiCtrl::InsertWindow(TreeMultiItemNode* ParentPtr, size_t Position, wxWindow* WindowPtr, wxString const& Name, wxTreeMultiWindowInfo const& Info, int Flags) +{ + int WindowFlags; + + TreeMultiItemWindow* NewWindowPtr = new TreeMultiItemWindow(ParentPtr,Name); // generate new window pointer + + + // get flags from passed variable "Flags"; in case this variable does not contain any flags use the window's information flags: + if (Flags != 0) + WindowFlags = Flags; + else + WindowFlags = Info.GetFlags(); + + // continue with initializing the new window: +#if(CHECKBOXVIEW) + // if checkbox view is desired, tag this item as a checkbox + // and set the state as 'false' + NewWindowPtr->SetCheckbox(_checkboxView); +#endif + // if style wants us to change background, set it to our background + if (WindowFlags & wxTMC_BG_ADJUST_ALL) + { + // go through all children of this window, and set the + // background of it (recursively) + this->SetWindowBackgroundColour(WindowPtr,this->GetBackgroundColour(),WindowFlags); + } /* if */ + + // set the spacing: + NewWindowPtr->SetTopSpacing(Info.GetTopSpacing()); +#if(CHECKBOXVIEW) + // make sure that the checkboxes are at least indented enough + if (this->_checkboxView) + NewWindowPtr->SetFrontSpacing(Info.GetFrontSpacing() + this->_checkWidth); + else +#endif + NewWindowPtr->SetFrontSpacing(Info.GetFrontSpacing()); + // assign finally the window: + NewWindowPtr->AssignWindow(WindowPtr); + +#if(CHECKBOXVIEW) + // set the checkbox state after the window is assigned + NewWindowPtr->SetCheckboxState(Info.GetDefaultCheckState()); +#endif + + // if the window is not visible, set hide flag + this->ShowTreeMultiWindow(NewWindowPtr,NewWindowPtr->IsVisible()); + + // finally, insert the newly constructed window: + if (Position < (size_t)ParentPtr->GetNodeCount()) + ParentPtr->InsertNode(NewWindowPtr,Position); + else + ParentPtr->AddNode(NewWindowPtr); + // return the newly created window: + return wxTreeMultiItem(NewWindowPtr); +} /* wxTreeMultiCtrl::InsertWindow(TreeMultiItemNode*, size_t, wxWindow*, wxString const&, wxTreeMultiWindowInfo const&, int) */ + +void wxTreeMultiCtrl::RedrawFromParentNode(TreeMultiItemBase *n) +{ + TreeMultiItemNode *p = 0; + if(n) + p = n->GetParent(); + + RedrawFromNode(p); +} + +void wxTreeMultiCtrl::RedrawFromNode(TreeMultiItemNode *n) +{ + static int recalcMutex = 0; + bool visible = true; + + if(recalcMutex > 0) + return; + + recalcMutex ++; + + // when node is not visible or excluded + // then don't redraw. + + if(n) + visible = n->IsVisible(); + + if(visible) + { + int h, h1,w, w1; + GetVirtualSize(&w, &h); + + UpdateAllWindowVisibility(); + RecalculateNodePositions(); + RecalculateVirtualSize(); + + // why is this needed? Because folding or collapsing can change + // the state. When the virtual area gets smaller, we need to keep + // the largest one and the other way atound. And since we do not + // know here we are folding or collapsing, we remember the biggest + GetVirtualSize(&w1, &h1); + + if(h1 > h) + h = h1; + + // only refresh the part from x,y down + if(n) + { + int x, y; + CalcScrolledPosition(n->GetX(), n->GetY(), &x, &y); + if(h - y > 0) + { + wxRect rect(0, y, w, h - y); + RefreshRect(rect); + } + else + Refresh(); + } + else + Refresh(); // do a full refresh + } + + recalcMutex --; +} + +void wxTreeMultiCtrl::RecalculateNodePositions() +{ + int currentY = _spacingY; + // go recursive on every node, and store the information in the node + + for(int i = 0; i < _root.GetNodeCount(); i++) + currentY += CalculateNodeDimensions(_root.GetNode(i), currentY, 0); +} + +int wxTreeMultiCtrl::CalculateNodeDimensions(TreeMultiItemBase *b, int currentY, int level) +{ + int gutter = (_gutterWidth * 2) + _iconWidth; + int y = 0, topSpacing = 0; + + // return same if no proper object + wxCHECK(b, 0); + +#if(CHECKBOXVIEW) + if(b->GetCheckbox()) + gutter += _checkWidth; +#endif + + // if we are not visible, skip recalculation and descending + if(b->IsVisible()) + { + b->SetY(currentY); + + // if level is 0, calculate with front gutter, else without + y = currentY + b->GetHeight(); + if(b->IsTreeMultiItemNode()) + { + TreeMultiItemNode *n = (TreeMultiItemNode *)b; + + if(level == 0) + b->SetX(gutter); + else + b->SetX(gutter + (level * (_gutterWidth + _iconWidth))); + + // now do children of this node + + for(int i = 0; i < n->GetNodeCount(); i++) + y += CalculateNodeDimensions(n->GetNode(i), y + _spacingY, level+1); + } + else if(b->IsTreeMultiItemWindow()) + { + TreeMultiItemWindow *w = (TreeMultiItemWindow *)b; + + if(level == 0) + b->SetX(gutter + w->GetFrontSpacing()); + else + b->SetX(_gutterWidth + (level * (_gutterWidth + _iconWidth)) + w->GetFrontSpacing()); + + topSpacing = w->GetTopSpacing(); + + // reposition the window + + wxWindow *wnd = w->GetWindow(); + if(wnd) + { + int x = 0, y = 0; + CalcScrolledPosition(w->GetX(), w->GetY(), &x, &y); + wnd->SetSize(x, y, w->GetWidth(), w->GetHeight()); + } + } + + if(y > 0) + return (y - currentY) + _spacingY + topSpacing; // return delta + else + return 0; + } + + return 0; // not visible, thus we skip calculations +} + +void wxTreeMultiCtrl::RecalculateSpanSizes() +{ + for(int i = 0; i < _root.GetNodeCount(); i++) + CalculateNodeSpanning(_root.GetNode(i)); +} + +void wxTreeMultiCtrl::CalculateNodeSpanning(TreeMultiItemBase *b) +{ + // return same if no proper object + wxCHECK2(b, return); + + if(b->IsTreeMultiItemNode()) + { + TreeMultiItemNode *n = (TreeMultiItemNode *)b; + + // now do children of this node + + for(int i = 0; i < n->GetNodeCount(); i++) + CalculateNodeSpanning(n->GetNode(i)); + } + else if(b->IsTreeMultiItemWindow()) + { + TreeMultiItemWindow *w = (TreeMultiItemWindow *)b; + wxWindow *wnd = w->GetWindow(); + if(wnd) + { + // if the window is spanning, we adjust the width to the max width of the control + if(w->GetHorizontalSpan()) + { + wxSize tmcsize = GetClientSize(); + int maxwidth = tmcsize.GetWidth() - w->GetX() - 8; // extract 3 for border + + wxSizer *sz = wnd->GetSizer(); + if(sz) + { + if(maxwidth < sz->GetMinSize().GetWidth()) + maxwidth = sz->GetMinSize().GetWidth(); + } + + // prevent a size of 0 + if(maxwidth < 1) + maxwidth = 1; + + // set the size + w->SetWidth(maxwidth); + wnd->SetSize(w->GetWidth(), w->GetHeight()); + + // layout by sizer (not sure if this is needed) + if(wnd->GetSizer()) + wnd->GetSizer()->Layout(); + } + } + } +} + +void wxTreeMultiCtrl::RecalculateVirtualSize() +{ + // go through all the nodes, and store the largest x and largest y + + int x = 0, y = 0; + RecalculateVirtualSizeFromNode(&_root, x, y); + + // now adjust virtual size + SetVirtualSize(x, y); + AdjustScrollbars(x, y); +} + +void wxTreeMultiCtrl::AdjustScrollbars(int x, int y) +{ + // adjust scrollbars + // courtesy of treectrlg.cpp + + y += WXTMC_PIXELS_PER_UNIT+2; // one more scrollbar unit + 2 pixels + x += WXTMC_PIXELS_PER_UNIT+2; // one more scrollbar unit + 2 pixels + int x_pos = GetScrollPos( wxHORIZONTAL ); + int y_pos = GetScrollPos( wxVERTICAL ); + SetScrollbars( WXTMC_PIXELS_PER_UNIT, WXTMC_PIXELS_PER_UNIT, x/WXTMC_PIXELS_PER_UNIT, + y/WXTMC_PIXELS_PER_UNIT, x_pos, y_pos, true ); +} + +void wxTreeMultiCtrl::RecalculateVirtualSizeFromNode(const TreeMultiItemNode *node, int &x, int &y) +{ + if(node->IsExcluded()) + return; + + // if calulate this node's dimensions + if(x < (node->GetWidth() + node->GetX())) + x = node->GetWidth() + node->GetX(); + + y = node->GetY() + node->GetHeight(); + + // if this node is collapsed, no subnodes are visible, else + // go through all subnodes as well, node needs to be included as well + if(node->IsExpanded()) + { + TreeMultiItemBase *b; + for(int i = 0; i < node->GetNodeCount(); i++) + { + b = node->GetNode(i); + + // calculate x and y + if(x < (b->GetWidth() + b->GetX())) + x = b->GetWidth() + b->GetX(); + + y = b->GetY() + b->GetHeight(); + + if(b->IsTreeMultiItemNode()) + RecalculateVirtualSizeFromNode((TreeMultiItemNode *)b, x, y); + } + } +} + +void wxTreeMultiCtrl::SetWindowBackgroundColour(wxWindow *wnd, const wxColour &col, int flags) +{ + if(wnd) + { + // if we cannot change a button, make sure all button + // classes are not changed + + wxButton *btn = wxDynamicCast(wnd, wxButton); + if(!btn || ((flags & wxTMC_BG_ADJUST_BTN) != 0)) + wnd->SetBackgroundColour(col); + + // get every window, and make the background equal to the given one + wxWindowListNode *node = wnd->GetChildren().GetFirst(); + while (node) + { + SetWindowBackgroundColour(node->GetData(), col, flags); + node = node->GetNext(); + } + } +} + +void wxTreeMultiCtrl::ShowTreeMultiWindow(TreeMultiItemWindow *window, bool show) +{ + // show or hide window + if(window && window->GetWindow()) + window->GetWindow()->Show(show); +} + +void wxTreeMultiCtrl::UpdateAllWindowVisibility() +{ + // all roots are visible, but what lies beneath ... who knows + for(int i = 0; i < _root.GetNodeCount(); i++) + UpdateTreeMultiWindowVisibility(_root.GetNode(i), true); +} + +void wxTreeMultiCtrl::UpdateTreeMultiWindowVisibility(TreeMultiItemBase *b, bool show) +{ + if(b) + { + // this is done for performance issues. IsVisible can go all + // the way up the tree to check. However if show is already + // false, there is no need to check (some higher one is collapsed) + bool showMe = show; + + if(showMe) + showMe = b->IsVisible(); + + if(b->IsTreeMultiItemWindow()) + { + // if this level must be hidden, hide + ShowTreeMultiWindow((TreeMultiItemWindow*)b, showMe); + } + else if(b->IsTreeMultiItemNode()) + { + TreeMultiItemNode *node = (TreeMultiItemNode *)b; + + // if hidden, descend and hide all windows + for(int i = 0; i < node->GetNodeCount(); i++) + UpdateTreeMultiWindowVisibility(node->GetNode(i), showMe); + } + } +} + +wxTreeMultiItem wxTreeMultiCtrl::FindItem(const wxTreeMultiItem &item, const wxString &name, bool ignoreCase, bool skipFirst) +{ + if(item.IsOk()) + { + TreeMultiItemBase *b = item.GetItem(); + + // check this item first (or not) + + if(!skipFirst) + { + if(b->GetName().IsSameAs(name, !ignoreCase)) + return wxTreeMultiItem(b); + } + + if(b->IsTreeMultiItemNode()) + { + // now check whether we are a node, then go check children + + TreeMultiItemNode *n = (TreeMultiItemNode *)b; + wxTreeMultiItem result(0); + for(int i = 0; i < n->GetNodeCount() && !result.IsOk(); i++) + result = FindItem(wxTreeMultiItem(n->GetNode(i)), name, ignoreCase, false); + + return result; + } + } + + return wxTreeMultiItem(0); +} + +wxTreeMultiItem wxTreeMultiCtrl::FindWindowNode(wxWindow *wnd, TreeMultiItemNode *n) +{ + wxCHECK(wnd, wxTreeMultiItem(0)); + + // take root node if not assigned one + + if(!n) + n = (TreeMultiItemNode *)&_root; + + // check on this level for the wxWindow pointer + + TreeMultiItemWindow *w; + wxTreeMultiItem result(0); + for(int i = 0; i < n->GetNodeCount() && !result.IsOk(); i++) + { + // if window node + w = n->GetNode(i)->IsTreeMultiItemWindow(); + if(w && w->GetWindow() == wnd) + return wxTreeMultiItem(n); + + // if node, go deeper + if(n->GetNode(i)->IsTreeMultiItemNode()) + result = FindWindowNode(wnd, (TreeMultiItemNode*)n->GetNode(i)); + } + + return result; +} + +TreeMultiItemWindow *wxTreeMultiCtrl::FindNextVisibleWindowItem(TreeMultiItemBase *b, int index) +{ + wxCHECK(b, 0); + + // check on this level, go deeper with every node we got. When a node is not + // visible anymore, skip the node. + + TreeMultiItemWindow *value = 0; + if(b->IsVisible()) + { + // if we are already searching on a node with an index + + TreeMultiItemBase *bn = 0; + TreeMultiItemNode *n = b->IsTreeMultiItemNode(); + if(n) + { + for(int i = index + 1; i < n->GetNodeCount() && !value; i++) + { + bn = n->GetNode(i); + value = bn->IsTreeMultiItemWindow(); + + // assume a node, root when not a a window + if(!value) + value = FindNextVisibleWindowItem(bn, -1); + } + + } + else + { + if(b->IsTreeMultiItemWindow()) + { + // get parent first, and locate child as ptr + TreeMultiItemNode *p = b->GetParent(); + wxCHECK(p, 0); + + // go scan the parent from the given index, if + // the index is valid else there is no child with that index + + int idx = p->Index(b); + wxCHECK(idx >= 0, 0); + + value = FindNextVisibleWindowItem(p, idx); + } + } + } + + return value; + +} + +bool wxTreeMultiCtrl::GetBooleanValue(int wndId) +{ + wxWindow *wnd = wxWindow::FindWindow(wndId); + wxCHECK(wnd, false); + + // try a radio button + wxRadioButton *b = wxDynamicCast(wnd, wxRadioButton); + if(b) + return b->GetValue(); + + // try a check box + wxCheckBox *c = wxDynamicCast(wnd, wxCheckBox); + if(c) + return c->GetValue(); + + /** \todo For custom controls we should put something in wxMultiTreeItemData class + which can be overridden to retrieve the boolean value. It will also be passed + the pointer to the window, so the derived class can figure out how to get a boolean + value. + */ + + // generate assert or just return with false + wxCHECK(0, false); +} + +void wxTreeMultiCtrl::SetBooleanValue(int wndId, bool value) +{ + wxWindow *wnd = wxWindow::FindWindow(wndId); + wxCHECK2(wnd, return); + + // try a radio button + wxRadioButton *b = wxDynamicCast(wnd, wxRadioButton); + if(b) + { + b->SetValue(value); + return; + } + + // try a check box + wxCheckBox *c = wxDynamicCast(wnd, wxCheckBox); + if(c) + { + c->SetValue(value); + return; + } + + /** \todo For custom controls we should put something in wxMultiTreeItemData class + which can be overridden to retrieve the boolean value. It will also be passed + the pointer to the window, so the derived class can figure out how to get a boolean + value. + */ + + // generate assert + wxCHECK2(0, return); +} + +void wxTreeMultiCtrl::SetTextValue(int wndId, const wxString &value) +{ + wxWindow *wnd = wxWindow::FindWindow(wndId); + wxCHECK2(wnd, return); + + // try a radio button + wxTextCtrl *t = wxDynamicCast(wnd, wxTextCtrl); + if(t) + { + t->SetValue(value); + return; + } + + /** \todo For custom controls we should put something in wxMultiTreeItemData class + which can be overridden to retrieve the boolean value. It will also be passed + the pointer to the window, so the derived class can figure out how to get a boolean + value. + */ + + // generate assert + wxCHECK2(0, return); +} + +wxString wxTreeMultiCtrl::GetTextValue(int wndId) +{ + wxWindow *wnd = wxWindow::FindWindow(wndId); + wxCHECK(wnd, wxEmptyString); + + // try a radio button + wxTextCtrl *t = wxDynamicCast(wnd, wxTextCtrl); + if(t) + return t->GetValue(); + + // try a choice box + wxChoice *c1 = wxDynamicCast(wnd, wxChoice); + if(c1) + return c1->GetStringSelection(); + + // try a combo box + wxComboBox *c2 = wxDynamicCast(wnd, wxComboBox); + if(c2) + return c2->GetStringSelection(); + + // try a listbox + wxListBox *l = wxDynamicCast(wnd, wxListBox); + if(l) + return l->GetStringSelection(); + + /** \todo For custom controls we should put something in wxMultiTreeItemData class + which can be overridden to retrieve the boolean value. It will also be passed + the pointer to the window, so the derived class can figure out how to get a boolean + value. + */ + + // generate assert or just return with string + wxCHECK(0, wxEmptyString); +} + +int wxTreeMultiCtrl::GetSelectionValue(int wndId) +{ + wxWindow *wnd = wxWindow::FindWindow(wndId); + wxCHECK(wnd, -1); + + // try a choice box + wxChoice *c1 = wxDynamicCast(wnd, wxChoice); + if(c1) + return c1->GetSelection(); + + // try a combo box + wxComboBox *c2 = wxDynamicCast(wnd, wxComboBox); + if(c2) + return c2->GetSelection(); + + // try a listbox + wxListBox *l = wxDynamicCast(wnd, wxListBox); + if(l) + return l->GetSelection(); + + /** \todo For custom controls we should put something in wxMultiTreeItemData class + which can be overridden to retrieve the boolean value. It will also be passed + the pointer to the window, so the derived class can figure out how to get a boolean + value. + */ + + // generate assert or just return with string + wxCHECK(0, -1); +} + +void wxTreeMultiCtrl::GetSelectionValues(int wndId, wxArrayInt &sels) +{ + sels.Clear(); + + wxWindow *wnd = wxWindow::FindWindow(wndId); + wxCHECK2(wnd, return); + + // try a listbox + wxListBox *l = wxDynamicCast(wnd, wxListBox); + if(l) + { + l->GetSelections(sels); + return; + } + + /** \todo For custom controls we should put something in wxMultiTreeItemData class + which can be overridden to retrieve the boolean value. It will also be passed + the pointer to the window, so the derived class can figure out how to get a boolean + value. + */ + + // generate assert or just return with string + wxCHECK2(0, return); +} + +void wxTreeMultiCtrl::SetSelectionValue(int wndId, int sel) +{ + wxWindow *wnd = wxWindow::FindWindow(wndId); + wxCHECK2(wnd, return); + + // try a choice box + wxChoice *c1 = wxDynamicCast(wnd, wxChoice); + if(c1) + { + c1->SetSelection(sel); + return; + } + + // try a combo box + wxComboBox *c2 = wxDynamicCast(wnd, wxComboBox); + if(c2) + { + c2->SetSelection(sel); + return; + } + + // try a listbox + wxListBox *l = wxDynamicCast(wnd, wxListBox); + if(l) + { + l->SetSelection(sel); + return; + } + + /** \todo For custom controls we should put something in wxMultiTreeItemData class + which can be overridden to retrieve the boolean value. It will also be passed + the pointer to the window, so the derived class can figure out how to get a boolean + value. + */ + + // generate assert or just return with string + wxCHECK2(0, return); +} + + +wxTreeMultiItem wxTreeMultiCtrl::GetParent(wxTreeMultiItem const& item) const +{ + // check if valid or root item has been passed, both do not have parents: + if (!(item.IsOk()) || item.GetItem()->IsTreeMultiItemRoot()) + return wxTreeMultiItem(); + else + return wxTreeMultiItem(item.GetItem()->GetParent()); // GetParent() returns a valid pointer in case of a root item!! + // therefore, the check if the passed item is a root item is necessary +} /* wxTreeMultiCtrl::GetParent(wxTreeMultiItem const& item) const */ + +wxTreeMultiItem wxTreeMultiCtrl::GetFirstChild(const wxTreeMultiItem &item, int &cookie) const +{ + if(item.IsNodeItem()) + { + TreeMultiItemNode *n = (TreeMultiItemNode *)item.GetItem(); + + if(n->GetNodeCount() > 0) + { + cookie = 0; + return wxTreeMultiItem(n->GetNode(0)); + } + } + + // no children or no valid node + cookie = -1; + return wxTreeMultiItem(0); +} + +wxTreeMultiItem wxTreeMultiCtrl::GetNextChild(const wxTreeMultiItem &item, int &cookie) const +{ + if(item.IsNodeItem()) + { + TreeMultiItemNode *n = (TreeMultiItemNode *)item.GetItem(); + + if(cookie >= 0 && cookie < (n->GetNodeCount()-1)) + { + // increment cookie, return node + cookie ++; + return wxTreeMultiItem(n->GetNode(cookie)); + } + } + + // end of query, or no valid node + cookie = -1; + return wxTreeMultiItem(0); +} + +wxTreeMultiItem wxTreeMultiCtrl::GetLastChild(const wxTreeMultiItem &item) const +{ + if(item.IsNodeItem()) + { + TreeMultiItemNode *n = (TreeMultiItemNode *)item.GetItem(); + + if(n->GetNodeCount() > 0) + return wxTreeMultiItem(n->GetNode(n->GetNodeCount()-1)); + } + + return wxTreeMultiItem(0); +} + +wxTreeMultiItem wxTreeMultiCtrl::GetNextSibling(wxTreeMultiItem const& item) const +{ + // check if a valid item has been passed: + if (!(item.IsOk())) + return wxTreeMultiItem(); + + TreeMultiItemNode* ParentPtr(item.GetItem()->GetParent()); + + + if (ParentPtr != NULL) // the parent pointer is only null if the passed item is the root + { + // find the current item in the parent's list; the next sibling has an index that is one higher than the one of the current item: + int NextItemIndex(ParentPtr->Index(item.GetItem())+1); // variable definition and initialization + + if (NextItemIndex < ParentPtr->GetNodeCount()) + return ParentPtr->GetNode(NextItemIndex); + else + return wxTreeMultiItem(); + } /* if */ + else + return wxTreeMultiItem(); +} /* wxTreeMultiCtrl::GetNextSibling(wxTreeMultiItem const&) const */ + +wxTreeMultiItem wxTreeMultiCtrl::GetPrevSibling(wxTreeMultiItem const& item) const +{ + // check if a valid item has been passed: + if (!(item.IsOk())) + return wxTreeMultiItem(); + + TreeMultiItemNode* ParentPtr(item.GetItem()->GetParent()); + + + if (ParentPtr != NULL) + { + // find the current item in the parent's list; the next sibling has an index that is one higher than the one of the current item: + int PrevItemIndex(ParentPtr->Index(item.GetItem())-1); // variable definition and initialization + + if (PrevItemIndex >= 0) + return ParentPtr->GetNode(PrevItemIndex); + else + return wxTreeMultiItem(); + } /* if */ + else + return wxTreeMultiItem(); +} /* wxTreeMultiCtrl::GetPrevSibling(wxTreeMultiItem const&) const */ + +wxTreeMultiItem wxTreeMultiCtrl::GetNext(wxTreeMultiItem const& item) const +{ + // check if a valid item has been passed: + if (!(item.IsOk())) + return wxTreeMultiItem(); + + TreeMultiItemNode* NodePtr(item.GetItem()->IsTreeMultiItemNode()); // variable definition and initialization + + if ((NodePtr != NULL) && (NodePtr->GetNodeCount() > 0)) + return wxTreeMultiItem(NodePtr->First()); + else + { + // variable definitions and initializations: + wxTreeMultiItem Parent(item); + wxTreeMultiItem Sibling; + + do + { + Sibling = this->GetNextSibling(Parent); // try to find next sibling + Parent = this->GetParent(Parent); // get next ancestor + } while (!(Sibling.IsOk()) && Parent.IsOk()); + // in case the loop ended with Sibling.IsOk() "Sibling" contains a valid sibling otherwise an invalid + return Sibling; + } /* if */ +} /* wxTreeMultiCtrl::GetNextSibling(wxTreeMultiItem const&) const */ + +wxTreeMultiItem wxTreeMultiCtrl::GetPrevious(wxTreeMultiItem const& item) const +{ + // check if a valid item has been passed: + if (!(item.IsOk())) + return wxTreeMultiItem(); + + TreeMultiItemNode* NodePtr(item.GetItem()->IsTreeMultiItemNode()); // variable definition and initialization + + if ((NodePtr != NULL) && (NodePtr->GetNodeCount() > 0)) + return wxTreeMultiItem(NodePtr->Last()); + else + { + // variable definitions and initializations: + wxTreeMultiItem Parent(item); + wxTreeMultiItem Sibling; + + do + { + Sibling = this->GetPrevSibling(Parent); // try to find next sibling + Parent = this->GetParent(Parent); // get next ancestor + } while (!(Sibling.IsOk()) && Parent.IsOk()); + // in case the loop ended with Sibling.IsOk() "Sibling" contains a valid sibling otherwise an invalid + return Sibling; + } /* if */ +} /* wxTreeMultiCtrl::GetPrevious(wxTreeMultiItem const&) const */ + +// WDR: handler implementations for wxTreeMultiCtrl + +void wxTreeMultiCtrl::OnDraw(wxDC& dc) +{ + // go recursive and draw the whole visible tree. + dc.SetFont(_captionFont); + for(int i = 0; i < _root.GetNodeCount(); i++) + DrawNode(_root.GetNode(i), dc); +} /* */ diff --git a/kernel/src/ThirdParty/wx/treemultictrl/wxTreeMultiCtrl.h b/kernel/src/ThirdParty/wx/treemultictrl/wxTreeMultiCtrl.h new file mode 100644 index 0000000..d997e3e --- /dev/null +++ b/kernel/src/ThirdParty/wx/treemultictrl/wxTreeMultiCtrl.h @@ -0,0 +1,1218 @@ +//--------------------------------------------------------------------------- +// $RCSfile: wxTreeMultiCtrl.h,v $ +// $Source: /cvs/creatis/bbtk/kernel/src/ThirdParty/wx/treemultictrl/wxTreeMultiCtrl.h,v $ +// $Revision: 1.1 $ +// $Date: 2008/03/28 13:42:19 $ +//--------------------------------------------------------------------------- +// Author: Jorgen Bodde +// Copyright: (c) Jorgen Bodde +// License: wxWidgets License +//--------------------------------------------------------------------------- + +#ifndef __WXTREEMULTICTRL_H__ +#define __WXTREEMULTICTRL_H__ + +/** \author Jorgen Bodde + \mainpage + + This is the wxTreeMultiCtrl documentation guide. For the upcoming CodeShop project I am working on, I've + created a new control for wxWidgets (http://www.wxwidgets.com), with similar functionality as + the wxTreeCtrl. This control allows you to add multiple wxWindow based components in a tree shaped form, + with multiple root entries, which can contain multiple sub nodes, which can contain the visual controls + in the tree. The tree behaves very much like a wxTreeCtrl, showing all controls in a more structured way. + + wxTreeMultiCtrl is freeware and distributed under the wxWidgets license. wxWidgets is THE toolkit for + (cross platform) C++ / Python programming! + + \section how_work How does it work? + + The internals of the wxTreeMultiCtrl are built up from a composite pattern. This pattern forms a recursive + tree where each end node can consist of a Window or a Node type. The Node type can consist out of multiple + Window or Node types, and the Window type is an end node which contains an assigned wxWindow to be displayed + on the current level. + + The wxTreeMultiCtrl communicates to the developer by using the wxTreeMultiItem class, which is about the same + as a wxTreeItemId. The wxTreeMultiItem class can be used in add or delete operations, fold operations, find + operations, data get and set methods, and more. It helps the developer build up the tree, and later on, + get and set data from it. + + \section what_dp What can it do and what not? + + What it can do: + + - Run-time addition / deletion of nodes, with an unlimited level depth + - Inheriting the control makes it possible to respond to the events of the added wxWindow based components + - Since all structured controls are owned by the wxTreeMultiCtrl, FindWindow will work, and all events can be captured + - Collapsing and expanding of a (or all) sub nodes from a specific location by method or by mouse click + - Typesafe getting or setting boolean, text or selection values by simply passing the window ID + - Run-time adjustment of spacing between controls + - Easy indenting of Window nodes + - Contain complex controls per Window node by putting them on a wxPanel, allowing custom behavior of those controls on the wxPanel + - Automatic deep background color adjustment of every window added, which means that every control on a wxPanel will be + automatically set to the proper background. There is also an exception flag for wxButton controls, so that they remain + their original color (if desired). + + What it cannot do: + + - Drag and drop support of individual nodes. Since the purpose was creating a tree shaped / property sheet kind of window, + dragging and dropping is not really desired behavior. + - No selection possible. Click on the controls to edit, double click on a container node to collapse and expand. + - Draw a selection border. Since there is no selection possible, no selection will be drawn + - Editing of captions like point and click in wxTreeCtrl. Again this is not desired behavior, because the (sub) + items are not really the same as wxTreeCtrl items. + + Special thanks to Phil for testing, Julian Smart et al. for making this great toolkit! +*/ + +#ifdef __GNUG__ + #pragma interface "wxTreeMultiCtrl.cpp" +#endif + +#ifndef WX_PRECOMP + #include "wx/wx.h" +#endif + +#include + + +// classes for internal tree structure +#include "TreeMultiItemRoot.h" + +// Flags for wxTreeMultCtrl use +#define wxTMC_DEFAULT_STYLE wxSIMPLE_BORDER + +/** @defgroup wndflags wxTreeMultiWindowItem flags + These flags can be used in wxTreeMultiCtrl::AppendWindow as enforced flags, or in wxTreeMultiWindowInfo to set the flags + for repetetive adding of Window nodes with the same (or near same) properties. + @{ +*/ +/** When set, this flag will change the background of all the panels + and subwindows added to the wxTreeMultiCtrl. */ +#define wxTMC_BG_ADJUST_CNT 0x000000001 +/** When set, the background of the wxButton windows will also be changed. + This needs wxTMC_ADJUST_BACKGROUND to be set as well. */ +#define wxTMC_BG_ADJUST_BTN 0x000000002 +/** When set, all backgrounds from windows and buttons will be adjusted + to match the control background */ +#define wxTMC_BG_ADJUST_ALL (wxTMC_BG_ADJUST_CNT | wxTMC_BG_ADJUST_BTN) +/** When set, the control added is resized horizontally over the complete + length. When the user resizes the window, the control is resized as well */ +#define wxTMC_SPAN_WIDTH 0x000000004 +/** @} +*/ + + +#define wxTreeMultiCtrlNameStr wxT("wxTreeMultiCtrl") + +#define WXTMC_GUTTER_DEFAULT 6 // gutter before and after image of [+] or [-] +#define WXTMC_YSPACING_DEFAULT 10 // per item 10 pixels spacing extra for every item +#define WXTMC_PIXELS_PER_UNIT 10 + +/** \defgroup hitflags wxTreeMultiCtrl HitTest flags + @{ +*/ + +enum +{ + /// wxCoord was found in the gutter of the node (in front of the [+]) + wxTMC_HITTEST_GUTTER = 1, + /// wxCoord was found inside a window, or behind it, on a Window node + wxTMC_HITTEST_WINDOW, + /// wxCoord was found on a caption of a Node or Root item + wxTMC_HITTEST_CAPTION, + /// wxCoord was found on a checkbox (only when item really has a checkbox) + wxTMC_HITTEST_CHECKBOX +}; + +/** @} +*/ + +/** @defgroup classes wxTreeMultiCtrl Classes + These classes are all the available classes in the wxTreeMultiCtrl you should know about. + @{ + + @} +*/ + +/** \class wxTreeMultiItem + \ingroup classes + \brief An intermediate class which is used to return as 'item' value for the wxTreeMultiCtrl. This class + is comparable with wxTreeItemId. + + The wxTreeMultiItem is used to pass information to the user about the tree node in question. It can also be used point out where the + subnodes should be added. + + For example: + \code + + wxTreeMultiItem item = MyMultiTreeCtrl->AddRoot("This is the first root"); + + // now add a node to the root + if(item.IsOk()) + MyMultiTreeCtrl->AppendWindow(item, new wxStaticText(MyMultiTreeCtrl, -1, "This is a static text"); + + + \endcode + + The wxTreeMultiItem comes in three internal types which are used in the wxTreeMultiCtrl. For functions such as + wxTreeMultiCtrl::AddRoot, a Root item is returned. For functions such as wxTreeMultiCtrl::AppendWindow, a + Window node is returned. For functions such as wxTreeMultiCtrl::AppendNode, a Node item is returned. + + \li A Root item represents a top level item. Special operations on this item is adding multiple nodes to it from a + top level. + + \li A Node item represents a container item which has multiple sub items which can both be Window items, or Node items. + A root item is a special type of Node item, so all operations which are only for Node items, are also for Root items. + + \li A Window node represents an end node, which points to a wxWindow which represents the visual contents of this node. + This type of node can hold any wxWindow derived class. + +*/ + +class wxTreeMultiItem +{ +private: + TreeMultiItemBase *_item; +public: + /** Default declaration constructor, and should be used when declaring an item which gets assigned a new + value by e.g. wxTreeMultiCtrl::AppendNode. */ + wxTreeMultiItem() { + _item = 0; + }; + +#ifndef _NO_DOXYGEN_ + + wxTreeMultiItem(TreeMultiItemBase *ptr) { + _item = ptr; + }; + + // Returns the TreeMultiItemBase class. This shoult *NOT* be + // used if you don't know what you are doing! This means never use it. */ + TreeMultiItemBase *GetItem() const { + return _item; + }; + +#endif // _NO_DOXYGEN_ + + /** The copy operator. Used in assigning one wxTreeMultiItem to another, usually in returning wxTreeMultiItem + classes from the wxTreeMultiCtrl. + */ + void operator=(const wxTreeMultiItem &item) { + _item = item._item; + }; + + /** Equality operator. It returns true if the items are identical or if both items are invalid. */ + bool operator==(wxTreeMultiItem const& item) const {return (this->GetItem() == item.GetItem());} + + /** Inequality operator. It returns true if the items are different or one of them is invalid. */ + bool operator!=(wxTreeMultiItem const& item) const {return (this->GetItem() != item.GetItem());} + + /** Returns the parent of the current wxTreeMultiItem. This means the wxTreeMultiNode is returned. It can + be useful to check or clear the checkbox at this level. */ + wxTreeMultiItem GetParent() const{ + wxCHECK(IsOk(), wxTreeMultiItem(0)); + return wxTreeMultiItem(_item->GetParent()); + }; + + /** Validates if the wxTreeMultiItem is a valid instance to use in the wxTreeMultiCtrl. Returns TRUE when there + is a member value is associated with it, or FALSE when not. This value can also be checked when this class is returned from a wxTreeMultiCtrl operation. For example: + + \code + + wxTreeMultiItem item = MyTreeMultiCtrl->FindNode("NAME"); + if(item.IsOk()) + { + // Found the node, now do something with it + } + else + { + // Sorry, not found + } + + \endcode + + */ + bool IsOk() const { + return _item != 0; + }; + + /** Returns TRUE when the wxTreeMultiItem is a Window item. This means the item is both valid, and points to a + window node. This means it can be used in functions that expect a Window node. If the item is invalid or a Window + item, FALSE is returned + \sa wxTreeMultiCtrl::AppendWindow + */ + bool IsWindowItem() const { + if(_item && _item->IsTreeMultiItemWindow()) + return true; + return false; + }; + + /** Returns TRUE when the wxTreeMultiItem is a Node item. This means the item is both valid, and points to a + node element (i.e. setting the caption, counting node children, etc). If the item is invalid or not a Node + item, FALSE is returned. + When the item is actually a root item (specialised node type), this also returns TRUE. + \sa wxTreeMultiCtrl::AppendNode wxTreeMultiCtrl::AddRoot + */ + bool IsNodeItem() const { + if(_item && (_item->IsTreeMultiItemNode() || _item->IsTreeMultiItemRoot())) + return true; + return false; + }; + + /** Returns True when the wxTreeMultiItem is a Root (top node) item. This means the item is both valid, + and points to a root element (this item is always shown as first node in the tree). A root node is + always visible, but can contain other collapsed children. If the item is invalid or not a Root node, + FALSE is returned. + */ + bool IsRootItem() const { + if(_item && _item->IsTreeMultiItemRoot()) + return true; + return false; + }; + + /** Returns TRUE if the node is expanded, else FALSE if it is collapsed. If the item is not a Root or Node + item, an assertion failure is generated (in debug mode) or FALSE is returned (in release mode). + + \sa wxTreeMultiCtrl::Expand, wxTreeMultiCtrl::Collapse, wxTreeMultiCtrl::CollapseAndReset + */ + bool IsExpanded() const { + wxCHECK(_item, false); + TreeMultiItemNode *n = _item->IsTreeMultiItemNode(); + wxCHECK(n, false); + + return n->IsExpanded(); + }; + + /** Returns true if this node is excluded from drawing. Please note that when this node is not visible + due to a higher excluded parent node but not literally excluded itself, it will return false (not excluded). + Use wxTreeMultiCtrl::GetExcludedParent() to get the node that hides this one. */ + bool IsExcluded() { + wxCHECK(_item, false); + return _item->IsExcluded(); + } + + /** Returns true if the item is selected. + Please note that currently only nodes can be selected. + */ + bool IsSelected(void) const + { + wxCHECK(this->GetItem(),false); + return this->GetItem()->IsSelected(); + } + /** Returns true if this node is visible. Please note that when this node is a child node of a collapsed + node, it is not visible. Also if this node is a child node of an excluded node, it is also not visible. + It does NOT return false when it's drawn somewhere outside of the visible area. */ + bool IsVisible() { + wxCHECK(_item, false); + return _item->IsVisible(); + } + +}; + +WX_DECLARE_OBJARRAY(wxTreeMultiItem,wxArrayTreeMultiItem); + +/** \class wxTreeMultiWindowInfo + \ingroup classes + \brief This class contains information for every Window node to be added. + + This class can be used to modify the behaviour of the Window node to be added, and can be reused to pass along + upon every wxTreeMultiCtrl::AppendWindow call. For example: + + \code + + wxTreeMultiWindowInfo wndinfo; + + MyTreeMultiCtrl->AppendWindow(item, new wxStaticText(MyTreeMultiCtrl, + -1, "Press this button"), "", wndinfo)); + + // now adjust the spacing of our next window to add, by indenting + // 4 times the indent size + + wndinfo.Indent(4); + MyTreeMultiCtrl->AppendWindow(item, new wxButton(MyTreeMultiCtrl, + -1, "Apply"), "", wndinfo); + + \endcode + + The class is created to prevent long parameter lists in the functions. Other ways to manipulate a newly added + Window node are; + + \li Change top spacing of the Window node to be added + \li Change front spacing (indent) of the Window node + \li Set extra flags for this Window node +*/ + +//------------------------------------------------------------------------------------------------------------------- + +class wxTreeMultiWindowInfo +{ +private: + /** Flag that indicates that every window background in the assigned wxWindow needs te be overriden with the + current colour of the TreeMultiCtrl. This is a deep adjustment and will do every subwindow until none are + left. If 'false' no adjustment is done. For AppendWindow only */ + int _flags; + /** Extra indent for every item that is added. This will add front spacing to the item's x calculation. + For AppendNode and AppendWindow. Spacing is added behind the collapse image not in front. */ + int _frontSpacing, + _frontSpacingOrg; + + /** Extra top spacing for every item that is added. This will add top spacing to the item's y calculation */ + int _topSpacing; + +#if(CHECKBOXVIEW) + /** Checkstate for checkboxed property sheets */ + bool _checkState; +#endif + +public: +#if(CHECKBOXVIEW) + wxTreeMultiWindowInfo(int flags, int frontSpacing, int topSpacing, bool checkState = false) + : _flags(flags) + , _frontSpacing(frontSpacing) + , _frontSpacingOrg(frontSpacing) + , _topSpacing(topSpacing) + , _checkState(checkState) +#else + wxTreeMultiWindowInfo(int flags, int frontSpacing, int topSpacing) + : _flags(flags) + , _frontSpacing(frontSpacing) + , _frontSpacingOrg(frontSpacing) + , _topSpacing(topSpacing) +#endif + { + // constructor + } + /** Adds indent to original front spacing and increments it with that value (quick extra indent). + The original value of FrontSpacing (see SetFrontSpacing() gets indented by multiplying + the 'num' factor (default = 1) times the indent value. So if the FrontSpacing was set to 10, + and Indent(2) is called, the new indent will be 30. (10 + 2 * 10). The original FrontSpacing + value is remembered, so calling Outdent(2) will bring it back to 10 (30 - (2*10). Calling + SetFrontSpacing with a new value, deletes the old indent. + + \sa Outdent, SetFrontSpacing + */ + int Indent(int num = 1) { + if(num > 0) + _frontSpacing += (_frontSpacingOrg * num); + return _frontSpacing; + }; + /** Reduces indent a number of times, by subtracting 'num' times the original FrontSpacing value from + the current FrontSpacing value (quick extra indent). Thus if the original FrontSpacing was set to + 10, and the current indent value is 40, Outdent(2) will do 40 - (2 * 10) = 20 + + \sa Indent, SetFrontSpacing + */ + int Outdent(int num = 1) { + _frontSpacing -= (_frontSpacingOrg * num); + if(_frontSpacing < 0) + _frontSpacing = 0; + return _frontSpacing; + }; + + /** Sets FrontSpacing value. This also resets the current indent level. */ + void SetFrontSpacing(int frontSpacing) { + _frontSpacing = frontSpacing; + _frontSpacingOrg = frontSpacing; + }; + /** Gets front spacing. This will return the current indent level set. If Indent or Outdent is used, + this level represents the current Indent level.*/ + int GetFrontSpacing() const { + return _frontSpacing; + }; + + /** Sets top spacing. This means the number of pixels spacing between the last node and the next one to + be added. + */ + void SetTopSpacing(int topSpacing) { + _topSpacing = topSpacing; + if(_topSpacing < 0) + _topSpacing = 0; + }; + + /* Gets top spacing currently set. */ + int GetTopSpacing() const { + return _topSpacing; + }; + + /** Sets the current flags set, and returns previous flags state. + \sa @link wndflags wxTreeMultiWindowInfo flags@endlink + */ + int SetFlags(int flags) { + int tmp = _flags; + _flags = flags; + return tmp; + }; + + /** Gets the current flags set. + \sa @link wndflags wxTreeMultiWindowInfo flags@endlink + */ + int GetFlags() const { + return _flags; + }; + + /** Or's the given flag with the current flagset, and adds it. The + old flag set is returned before the OR is applied. + \sa @link wndflags wxTreeMultiWindowInfo flags@endlink + */ + int AddFlag(int flag_mask) { + int tmp = _flags; + _flags |= flag_mask; + return tmp; + }; + + /** And's the given flag in a negated manner and removes this flag set from + the current flags. The old flag set is returned. + \sa @link wndflags wxTreeMultiWindowInfo flags@endlink + */ + int RemoveFlag(int flag_mask) { + int tmp = _flags; + _flags &= ~(flag_mask); + return tmp; + }; + +#if(CHECKBOXVIEW) + /** Sets the default checkstate if checkboxes if SetCheckboxView is chosen. For all the + items to be added (even captions) this checkstate is chosen. The default checkstate + is false. This needs USE_CHECKBOXVIEW set to YES, or CHECKBOXVIEW=1 during compile */ + void SetDefaultCheckState(bool checkState = true) { + _checkState = checkState; + }; + + /** Gets the default checkstate of the item. This needs USE_CHECKBOXVIEW set to YES, or CHECKBOXVIEW=1 during compile + \sa SetDefaultCheckState */ + bool GetDefaultCheckState() const { + return _checkState; + }; +#endif +}; + +// Default info string +#ifndef LINUX + #define wxTreeMultiWindowInfoDefault wxTreeMultiWindowInfo(wxTMC_BG_ADJUST_CNT, 8, 0) +#else + #define wxTreeMultiWindowInfoDefault wxTreeMultiWindowInfo(wxTMC_BG_ADJUST_ALL, 8, 0) +#endif + +/** \class wxTreeMultiCtrl + \ingroup classes + \brief This is the visual control, which will contain all the logic for the tree mechanism. + + The wxTreeMultiCtrl is the container class which can be filled in to get the tree shaped structure in + which the controls are displayed. The user can add / delete new nodes at runtime, expand or collapse + nodes, perform get or set actions on the controls inside, and iterate over the items. + + A typical usage of the wxTreeCtrl is; + + \code + wxTreeMultiCtrl *tmc = new wxTreeMultiCtrl(this, -1); + + // add root + wxTreeMultiItem item = tmc->AddRoot("This is the first root"); + + // create a wxTreeMultiWindowInfo object for indenting etc + wxTreeMultiWindowInfo wndinfo; + + // add subitem to root + tmc->AppendWindow(item, new wxButton(tmc, -1, "Press this"), "", wndinfo); + + // indent a few + wndinfo.Indent(4); + + // add a new one + tmc->AddWindow(item, new wxCheckBox(tmc, ID_MYCHECK, "Check this!"), "", wndinfo); + + // now check the value of the checkbox + tmc->SetBooleanValue(ID_MYCHECK, true); + + \endcode + + IMPORTANT: Every control added to the wxTreeMultiCtrl has to be child of the wxTreeMultiCtrl. + +*/ +class wxTreeMultiCtrl: public wxScrolledWindow +{ + DECLARE_DYNAMIC_CLASS(wxTreeMultiCtrl) + + /** \todo When tab is pressed, the focus can get out of sight. This should be resolved by + catching the TAB, see what window is focussed, and scroll the window so it's visible */ +private: + TreeMultiItemRoot _root; + + long _style; + wxBitmap *_expandBmp, *_collBmp; + + /** Delta Y for bitmap, to center it on the caption */ + int _iconDeltaY, _checkDeltaY; + + /* Caption height. This is the height of the font of this window */ + int _captionHeight; + + /** The gutter spacing in front and back of the image. This determines the amount of spacing in front + of each item */ + int _gutterWidth; + + /** The image width of the [+] / [-] icon. This is also calculated in the gutter */ + int _iconWidth; + + /** The image height of the [+] / [-] icon. This is calculated as minimal size and to allign */ + int _iconHeight; + + /** Max height. This is either the [+] bitmap or the checkbox */ + int _maxHeight; + + + /** Extra Y spacing between the items. */ + int _spacingY; + + /** Two step create prevention. Something with GetWindowSize freaks out when not actually created */ + bool _create_called; + +#if(CHECKBOXVIEW) + wxBitmap *_checkBmp, *_uncheckBmp, *_tristateBmp; + + /** Toggles checkbox view. If true, every item created (caption or node) will be created with checkbox */ + bool _checkboxView; + + /** Height and weight for checkbox */ + int _checkHeight, _checkWidth; +#endif + + /** brush for highlighting nodes */ + wxBrush* m_HilightBrush; + + /** This captionFont is made equal to the font of the wxScrolledWindow. As extra the bold face + is set on it when this is wanted by the user (see flags) */ + wxFont _captionFont; + + /** list of selected items */ + wxArrayTreeMultiItem m_SelectedItems; + + /** Does the actual collapsing / expanding. So that Expand and Collapse aren't using the same code twice */ + void DoFold(TreeMultiItemBase *item, bool expand, bool recursive); + + /** Redraws and recalculates the nodes from the current node. It will also clear all 'dirty' flags when + they are recalculated */ + void RedrawFromNode(TreeMultiItemNode *n); + + /** Redraws from parent node of this node */ + void RedrawFromParentNode(TreeMultiItemBase *b); + + /** Draws checkbox belonging to this node, in the given state */ + void DrawCheckbox(TreeMultiItemBase *b, wxDC &dc, bool convertScrolled = false); + + /** Recalculate the space needed based on every node. It goes as follows. + - A foldable node (TreeMultiItemNode) is as high as the 'Jg' y-size. This type only has a caption plus a + picture which explains the state ([+] or [-]), the width will be the caption length + - A window node will be as high as the y size of the window. The X size is the total length of the + window. + - For every child node an indent will be added to the x size. + + Only visible nodes will be recalculated. Non visible (collapsed) children will be skipped */ + void RecalculateNodePositions(); + + /** Recurses into the whole tree and provides every node with the proper x and y values. All non visible items + are skipped (so when it encounters a collapsed node, it's children are not calculated). Returns the last Y */ + int CalculateNodeDimensions(TreeMultiItemBase *b, int currentY, int level); + + void DrawNode(TreeMultiItemBase *b, wxDC &dc); + + /** Sets background colour of all the windows and subwindows in this wxWindow. This is very handy + for wxPanel derived classes which need to be made equal to the background colour of the wxTreeMultiCtrl */ + void SetWindowBackgroundColour(wxWindow *wnd, const wxColour &col, int flags); + + /** Shows or hides the assigned window (if there is any) */ + void ShowTreeMultiWindow(TreeMultiItemWindow *window, bool show = true); + + /** Goes down the tree, and if a window is not visible (thus all it's children aren't too) it will hide + the window so it is not shown on the control */ + void UpdateAllWindowVisibility(); + + /** Hides tree multi window. It this is a TreeMultiItemNode, hide all subwindows as well. */ + void UpdateTreeMultiWindowVisibility(TreeMultiItemBase *b, bool show); + + /** Recalculates totally needed virtual size of the wxTreeMultiCtrl. It will scan for + the largest window, with the biggest size, and report that back */ + void RecalculateVirtualSize(); + + /** Adjusts scrollbars in window, usually done after virtual size (x,y) is recalculated */ + using wxScrolledWindow::AdjustScrollbars; + virtual void AdjustScrollbars(int x, int y); + + /** Recalculates and accumulates largest x and y */ + void RecalculateVirtualSizeFromNode(const TreeMultiItemNode *node, int &x, int &y); + + /** Scans for TreeMultiItemBase node that contains x,y and in area returns a hittest constant to + indicate what matched */ + TreeMultiItemBase *FindNodeByPoint(TreeMultiItemBase *b, wxPoint const& pt, int &area); + + /** Scans for TreeMultiItemWindow that holds the wxWindow pointer. Does not scan in panels or does + a deep search. Reason, this function is used to advance to next TreeMultiItemWindow for focus + on this wxScrolledWindow. If a sub window is found, it will skip other windows on that same level */ + wxTreeMultiItem FindWindowNode(wxWindow *wnd, TreeMultiItemNode *n = 0); + + /** Finds next visible window item in chain. If not found use FindFirstVisibleItem to start from the + beginning */ + TreeMultiItemWindow *FindNextVisibleWindowItem(TreeMultiItemBase *b, int index = -1); + + /** Adjust the centering of the bitmap icons (collapse / expand) when the caption font changes. They need to + be centered in the middle of the font, so a bit of deltaY adjustment is needed */ + void AdjustIconsDeltaY(); + + /** Calculate the spanning of the individual nodes */ + void CalculateNodeSpanning(TreeMultiItemBase *b); + +#if(CHECKBOXVIEW) + /** Recurse to all the children and set the checkbox state (even when there is no checkbox) */ + void SetRecursiveCheckState(TreeMultiItemNode *n, bool check); + + /** From current checked node, all children will be scanned and the parent node of this node + will get tristate if the checked items are scattered (some are some aren't). If all nodes in this + node are checked, the parent node gets checked all the way up to the last one that matches + criteria. If all are cleared, parent node gets cleared */ + void ScanTristateCheckstates(TreeMultiItemBase *b); +#endif + + /** \name Private add and delete methods + @{ + */ + + /** Inserts a node into the parent's node at the specified position. + As this is a private method error checking is limited. Therefore, it has to be guaranteed that this method + is only called with a valid parent node pointer. + The position is zero based. In case the position is equal or larger than the current number of + parent's elements the new node is appended. + The newly inserted node is being returned. + */ + wxTreeMultiItem InsertNode(TreeMultiItemNode* ParentPtr, size_t Position, wxString const& Caption, wxString const& Name); + + /** Inserts a window into the parent's node at the specified position. + As this is a private method error checking is limited. Therefore, it has to be guaranteed that this method + is only called with a valid parent node and window pointer. + The position is zero based. In case the position is equal or larger than the current number of + parent's elements the new node is appended. + The newly inserted window is being returned. + */ + wxTreeMultiItem InsertWindow(TreeMultiItemNode* ParentPtr, size_t Position, wxWindow* WindowPtr, wxString const& Name, + wxTreeMultiWindowInfo const& Info, int Flags); + + /** @} + */ +private: + void Init(); + + // handlers + //--------- + + //virtual void OnDraw(wxDC& dc); + void OnPaint(wxPaintEvent &event); + void OnMouseClick (wxMouseEvent& event); + void OnRightMouseClick(wxMouseEvent& Event); + void OnKey(wxKeyEvent &event); + void OnSize(wxSizeEvent &event); + + /** Recalculates the spanning controls */ + void RecalculateSpanSizes(); + +public: + /** Two step constructor. Call Create when this constructor is called to build up the + wxTreeMultiCtrl + */ + wxTreeMultiCtrl() + : _create_called(false) + { + + Init(); + } + + /** The default constructor. The style wxTAB_TRAVERSAL is enforced to make sure that the + focus handling is being done correctly. The styles to be used are styles valid for + the wxWindow and wxScrolledWindow + */ + wxTreeMultiCtrl(wxWindow *parent, wxWindowID id = -1, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxTMC_DEFAULT_STYLE, + const wxValidator &validator = wxDefaultValidator, + const wxString& name = wxTreeMultiCtrlNameStr) + : _style(style | wxTAB_TRAVERSAL) + , _create_called(false) + { + Create(parent, id, pos, size, style, validator, name); + } + + /** Destructor */ + virtual ~wxTreeMultiCtrl(); + + /** Two step creation. Whenever the control is created without any parameters, use Create to actually + create it. Don't access the control's public methods before this is called + + \sa wxTreeMultiCtrl() + */ + bool Create(wxWindow *parent, wxWindowID id = -1, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxTMC_DEFAULT_STYLE, + const wxValidator &validator = wxDefaultValidator, + const wxString& name = wxTreeMultiCtrlNameStr); + + // accessors + //---------- + + /** @name Add and delete methods + To add and delete node items like a Root item, Window item or Node item. This allows the user to + manipulate the tree, and build it up. + @{ + */ + + /** Adds a root node to the wxTreeMultiItem. There can be many root nodes. Use this wxTreeMultiNode pointer to add + more subnodes to it. */ + wxTreeMultiItem AddRoot(const wxString &caption, const wxString &name = wxEmptyString); + + /** Adds a window to the tree control. Use this wxTreeMultiItem method to add a window class to the + current wxTreeMultiItem. The wxTreeMultiItem must point to a Node class. If this is not the case + an empty wxTreeMultiItem is returned. The mask is used to override the mask settings of the + wxTreeMultiWindowInfo class. This can be handy to set or clear extra flags only needed for certain + situations */ + wxTreeMultiItem AppendWindow(const wxTreeMultiItem &ParentItem, wxWindow *window = NULL, const wxString &name = wxEmptyString, + wxTreeMultiWindowInfo const& info = wxTreeMultiWindowInfoDefault, int flags = 0); + + /** Adds a window to the tree control. Use this method to add a window class at the specified position + of the parent's wxTreeMultiItem. In case the position is smaller than the current number of children all elements + are shifted upwards, otherwise the new window is appended to the parent's wxTreeMultiItem. + The parent wxTreeMultiItem must point to a Node class. If this is not the case an + empty wxTreeMultiItem is returned. + */ + wxTreeMultiItem InsertWindow(wxTreeMultiItem const& ParentItem, size_t Position, wxWindow *window = NULL, wxString const& Name = wxEmptyString, + wxTreeMultiWindowInfo const& info = wxTreeMultiWindowInfoDefault, int flags = 0); + + /** Adds a window to the tree control. Use this method to add a window class as the first element + of the parent's wxTreeMultiItem. The parent wxTreeMultiItem must point to a Node class. If this is not the case an + empty wxTreeMultiItem is returned. + */ + wxTreeMultiItem PrependWindow(wxTreeMultiItem const& ParentItem, wxWindow *window = NULL, const wxString &name = wxEmptyString, + wxTreeMultiWindowInfo const& info = wxTreeMultiWindowInfoDefault, int flags = 0); + + /** Adds a node to the tree control. Use this wxTreeMultiItem method to add a recursive subnode class as the last element + of the parent's wxTreeMultiItem. The parent wxTreeMultiItem must point to a Node class. If this is not the case + an empty wxTreeMultiItem is returned. A node can contain multiple nodes or window classes */ + wxTreeMultiItem AppendNode(wxTreeMultiItem const& ParentItem, const wxString &caption = wxEmptyString, + const wxString &name = wxEmptyString); + + /** Adds a node to the tree control. Use this method to add a recursive subnode class at the specified position + of the parent's wxTreeMultiItem. In case the position is smaller than the current number of nodes all elements + are shifted upwards, otherwise the new node is appended to the parent's wxTreeMultiItem. + The parent wxTreeMultiItem must point to a Node class. If this is not the case an + empty wxTreeMultiItem is returned. A node can contain multiple nodes or window classes. + */ + wxTreeMultiItem InsertNode(wxTreeMultiItem const& ParentItem, size_t Position, wxString const& caption, wxString const& name); + + /** Adds a node to the tree control. Use this method to add a recursive subnode class as the first element + of the parent's wxTreeMultiItem. The parent wxTreeMultiItem must point to a Node class. If this is not the case an + empty wxTreeMultiItem is returned. A node can contain multiple nodes or window classes. + */ + wxTreeMultiItem PrependNode(wxTreeMultiItem const& ParentItem, wxString const& caption = wxEmptyString, + wxString const& name = wxEmptyString); + + /** Delete item from the tree control. Whenever it is present, delete it. If not, return false. After + deletion the wxTreeMultiItem is 0, thus IsOk will return false */ + bool Delete(wxTreeMultiItem &item); + + /** Deletes all the items from the wxTreeMultiCtrl. */ + void DeleteAllItems(void) + { + this->_root.Clear(); + this->m_SelectedItems.Clear(); + Refresh(); + }; + + /** Deletes all children of the current node. The wxTreeMultiItem needs to be of type Node to + do this. Call GetParentNode to get the parent wxTreeMultiItem which is always a node. */ + void DeleteChildren(const wxTreeMultiItem &item); + + /** @} + */ + + /** @name Expand and collapse methods + These methods are all for items of type Node. + @{ + */ + + /** Expand all nodes and subnodes. Recursive = true means all subnodes are also expanded. */ + void ExpandNodes(bool recursive = false); + + /** Collapses all nodes and subnodes. Recursive = true means all subnodes are also expanded. */ + void CollapseNodes(bool recursive = false); + + /** Expands given node, and with recursive, also the subnodes */ + void Expand(const wxTreeMultiItem &item, bool recursive); + + /** Collapses given node, and with recursive, also the subnodes. If this item is not a node, but a window. + the parent is resolved and that node is collapsed */ + void Collapse(const wxTreeMultiItem &item, bool recursive); + + /** Collapses this node and removes all children from it. This is only applicable on + wxTreeMultiItems which are of type Node / Root. */ + void CollapseAndReset(const wxTreeMultiItem &item); + + /** Folds the given node. The same as Expand and Collapse, but the state can be + given through a parameter */ + void Fold(const wxTreeMultiItem &item, bool expand = true) { + if(expand) + Expand(item, false); + else + Collapse(item, false); + }; + + /** @} + */ + + /** @name Selection manipulation + These methods allow you to select, unselect or test wxTreeMultiItems on selection. + Currently only items of type Node can be manipulated. + @{ + */ + + /** Returns the number of selected items. */ + size_t GetSelectedItemCount(void) const {return this->m_SelectedItems.GetCount();} + + /** Returns the first selected item. + If there is no selected item an invalid tree multi item is returned. + */ + wxTreeMultiItem GetFirstSelectedItem(void) const; + + /** Returns the last selected item. + If there is no selected item an invalid tree multi item is returned. + */ + wxTreeMultiItem GetLastSelectedItem(void) const; + + /** Returns a selected item with the specified index. + If there is no selected item with the passed index an invalide tree multi item is returned. + */ + wxTreeMultiItem GetSelectedItem(size_t Index) const; + + /** Returns the index of the selected item. + In case the item is not selected "GetSelectedItemCount()" - which is an invalid index - is returned. + */ + size_t GetSelectedItemIndex(wxTreeMultiItem const& Item) const; + + /** Selects the specified item AND in case + - UnselectOthers is set all other selected items are going to be unselected; + - ExpandSelection is set all items between the last selected item and the passed item + are selected, too (in case there this is the first selection all items between the first root + and the passed item are selected). + If the passed item is already selected the other parameters are ignored. + Please not that currently only nodes can be selected, therefore, if any other item is passed nothing will happen. + */ + void SelectItem(wxTreeMultiItem const& Item, bool UnselectOthers=true, bool ExpandSelection=false); + + /** Unselect all selected items. */ + void UnselectAll(void); + + /** Unselect specified item */ + void Unselect(wxTreeMultiItem const& Item); + + /** @} + */ + + + /** \name Visibility manipulation + These methods allow you to manipulate a certain wxTreeMultiItem to temporarily exclude or to include + the node from drawing. Whenever it is excluded, all operations can still be performed, however + the node may not be visible. + @{ + */ + + /** Excludes this node from drawing. When excluded, the node will dissapear from the control but is still + physically present in the tree itself. If this node is a composite node with children, they will all be + hidden from the control. */ + void Exclude(const wxTreeMultiItem &item); + + /** Includes an excluded node. If the node was already present on the drawing, nothing happens. If the + node is included after exclusion it will become visible. If the parent node is still excluded or + collapsed (not visible) this will not show, until the parent node shows */ + void Include(const wxTreeMultiItem &item); + + /** Returns the parent that is responsible for excluding this node. If there is no excluded node as parent, + the wxTreeMultiItem is zero. */ + wxTreeMultiItem GetExcludedParent(const wxTreeMultiItem &item); + + /** @} + */ + + /** Checks if the point is under one of the given areas. The returned areas can be + \li wxTMC_HITTEST_GUTTER If the front part of the item is clicked (where the node is) + \li wxTMC_HITTEST_WINDOW If located in the window area + \li wxTMC_HITTEST_CAPTION If located on the caption of the MultiTreeItemNode + + Returned is the item which is located under the mouse, or none (IsOk = false) if + no item under the mouse */ + wxTreeMultiItem HitTest(wxPoint const& pt, int &flags); + + /** @name Find methods + These methods are used for finding a node in the wxTreeMultiCtrl. + @{ + */ + + /** Searches for the given name from the given level and lower. It will return a wxTreeMultiItem which needs + to be checked with IsOk() to see if it is a correct item. IsRootItem, IsNodeItem and IsWindowItem can be + used to determine the type of item. If the search returned an item which doesn't satisfy the query, you can + restart the search from here, with skip = true to skip the passed item. */ + wxTreeMultiItem FindItem(const wxTreeMultiItem &item, const wxString &name, bool ignoreCase = false, + bool skipFirst = false); + + /** Searches all nodes for the given name and returns the one found. This is a specialised method for FindItem */ + wxTreeMultiItem FindItem(const wxString &name, bool ignoreCase = false) { + return FindItem(wxTreeMultiItem(&_root), name, ignoreCase, false); + }; + + /** @} + */ + + /** Returns the number of children in this node. If this node is not of type Node, count returns -1. */ + int GetChildrenCount(const wxTreeMultiItem &item) { + if(item.IsNodeItem()) + { + TreeMultiItemNode *n = (TreeMultiItemNode *)item.GetItem(); + return n->GetNodeCount(); + } + + return -1; + }; + + /** This method finds the current focused window, and returns the wxTreeMultiItem that has this window as pointer. + If the wxTreeMultiItem is not ok, the focused window is on a sub-panel, or not on this control. If the focus is + on a sub-panel, this panel will handle the focusing. If you are still interested in this window, try + wxWindow::FindFocus which will always return with a pointer if a wxWindow has focus */ + wxTreeMultiItem GetFocus(); + + /** @name Smart window Get/Set methods + These methods are used for quickly getting or setting primitive values, like boolean, string, or selections into + primitive wxWindow controls like a wxRadioButton, wxCheckBox, wxTextCtrl, etc. + The methods allow you to quickly set e.g. a boolean value by using the wxWindow ID of the control. A type + check is performed before the value is actually set with the appropiate method for it. If it fails, an assertion + will follow in debug mode. If you want to get values back similar get methods are present to return values. + This allows the user to quickly retrieve or set values by ID, without the fuss of remembering the pointer or + node ID of the wxTreeMultiCtrl. + @{ + */ + + /** This function calls FindWindow on the wxTreeMultiCtrl to find the window with the given ID (which is added with + AppendWindow). When it is found, it is type casted towards a wxCheckBox and wxRadioButton. Whenever + it finds a proper type it will return true or false. Whenever no proper type is found, it will return with false. + In debug mode it will cause an assertion failure as well, to notify the developer something is wrong. + + \sa SetBooleanValue + */ + bool GetBooleanValue(int wndId); + + /** This function calls FindWindow on the wxTreeMultiCtrl to find the window with the given ID (which is added with + AppendWindow). When it is found, it is type casted towards a wxTextCtrl, wxChoice and wxComboBox. + Whenever it finds a proper type it will return the (selected) text in the control. Whenever no proper type is found, + it will return with an empty string. In debug mode it will cause an exception error as well if the cast fails, to notify + the developer something is wrong. + + \sa SetTextValue + */ + wxString GetTextValue(int wndId); + + /** This function calls FindWindow on the wxTreeMultiCtrl to find the window with the given ID (which is added with + AppendWindow). When it is found, it is type casted towards a wxCheckBox and wxRadioButton. Whenever + it finds a proper type it set the control's value to the given boolean parameter. Nothing happens when no proper type + is found, however debug mode it will cause an assertion failure. + + \sa GetBooleanValue + */ + void SetBooleanValue(int wndId, bool value = true); + + /** This function calls FindWindow on the wxTreeMultiCtrl to find the window with the given ID (which is added with + AppendWindow). When it is found, it is type casted towards a wxTextCtrl. If the control is not found or + of the wrong type, an asserion failure (in debug mode) follows.
NOTE: this method + does not typecast to wxChoice or wxComboBox and the likes. If a selection in one of those needs to be set, use the + SetSelectionValue / GetSelectionValue combination. + \sa GetTextValue, GetSelectionValue, SetSelectionValue + */ + void SetTextValue(int wndId, const wxString &value = wxEmptyString); + + /** Retrieves the wxWindow * associated with the wxTreeMultiItem. This only works for Window typed wxTreeMultiItem + classes. If this type does not match or no window is associated, 0 is returned. */ + wxWindow *GetWindow(const wxTreeMultiItem &item) { + if(item.IsWindowItem()) + return ((TreeMultiItemWindow *)item.GetItem())->GetWindow(); + return 0; + }; + + /** This function calls FindWindow on the wxTreeMultiCtrl to find the window with the given ID (which is added with + AppendWindow). When it is found, it is type casted towards a wxListBox, wxChoice, wxComboBox. + If the control is not found or of the wrong type, an asserion failure (in debug mode) follows. If it is found + the selection is set in the control. + */ + void SetSelectionValue(int wndId, int sel); + + /** This function calls FindWindow on the wxTreeMultiCtrl to find the window with the given ID (which is added with + AppendWindow). When it is found, it is type casted towards a wxListBox, wxChoice, wxComboBox. + If the control is not found or of the wrong type, an asserion failure (in debug mode) follows. In release mode -1 is + returned. If it is found the selection index is returned. + */ + int GetSelectionValue(int wndId); + + /** This function calls FindWindow on the wxTreeMultiCtrl to find the window with the given ID (which is added with + AppendWindow). When it is found, it is type casted towards a wxListBox. If the control is not found or + of the wrong type, an asserion failure (in debug mode) follows. In release mode an empty wxArrayInt is returned. + If it is found the selections are stored in the wxArrayInt. This is only valid for wxListBox classes with multiple + selection flag set. + */ + void GetSelectionValues(int wndId, wxArrayInt &sels); + +#if(CHECKBOXVIEW) + /** Gets the checkbox state of the wxTreeMultiItem pointed out by "item". If the item does not have a checkbox + associated (or the item is not ok), it will return -1. If the checkbox is checked it will return 1, + unchecked is 0, and tri-state (usually only for caption nodes) it will return 2. This needs USE_CHECKBOXVIEW + set to YES, or CHECKBOXVIEW=1 during compile*/ + int GetCheckboxState(const wxTreeMultiItem &item, bool WXUNUSED(recursive)) { + wxCHECK(item.IsOk(), -1); + + // return the checkbox state + TreeMultiItemBase *b = item.GetItem(); + if(b->GetCheckbox()) + return b->GetCheckboxState(); + + return -1; + }; + + /** Sets the checkbox state of the wxTreeMultiItem pointed out by "item". If the item does not have a checkbox + associated (or the item is not ok), it will simply ignore this. This needs USE_CHECKBOXVIEW + set to YES, or CHECKBOXVIEW=1 during compile. Contributed by Thomas Enickl.*/ + void SetCheckboxState( const wxTreeMultiItem &item, int state ) { + wxCHECK2( item.IsOk(), return ); + TreeMultiItemBase *b = item.GetItem(); + if( b->GetCheckbox() ) + b->SetCheckboxState( state ); + RedrawFromNode( item.GetItem()->GetParent() ); + }; +#endif + + /** @} + */ + + /** @name Extended visibility and manipulation methods + These methods alter the wxTreeMultiCtrl appearance, or add more functionality like checkboxes before each node. + @{ + */ + + /** Sets the Y spacing of the wxTreeMultiCtrl to a new size. This can be used to give the controls some more + spacing in between */ + + void SetSpacingY(int spacingY) { + if(spacingY >= 0) + { + _spacingY = spacingY; + RedrawFromNode(0); + } + }; + + /** Gets the Y spacing of the wxTreeMultiCtrl. */ + + int GetSpacingY() const { + return _spacingY; + }; + +#if(CHECKBOXVIEW) + /** This method toggles the checkbox view mode. Whenever set to true, the next window item, or caption node item + will get a checkbox. This needs USE_CHECKBOXVIEW set to YES, or CHECKBOXVIEW=1 during compile + \sa GetCheckboxView, wxTreeMultiWindowInfo::SetDefaultCheckState + */ + void SetCheckboxView(bool value) { + _checkboxView = value; + }; + + /** This method returns the checkbox state currently used. This needs USE_CHECKBOXVIEW set to YES, or + CHECKBOXVIEW=1 during compile + \sa SetCheckboxView, wxTreeMultiWindowInfo::SetDefaultCheckState, wxTreeMultiWindowInfo::GetDefaultCheckState + */ + bool GetCheckboxView() const { + return _checkboxView; + }; +#endif + + /** @} + */ + + /** @name Iteration methods + Allows the user to iterate through a wxTreeMultiCtrl node, and get all the children or siblings. + To start an iteration from the lowest level the functions GetFirstRoot and GetLastRoot are provided. + @{ + */ + + /** Returns the first root. */ + wxTreeMultiItem GetFirstRoot(void) const {return wxTreeMultiItem(this->_root.First());} + + /** Returns the last root. */ + wxTreeMultiItem GetLastRoot(void) const {return wxTreeMultiItem(this->_root.Last());} + + /** Returns the items parent. */ + wxTreeMultiItem GetParent(wxTreeMultiItem const& item) const; + + /** Returns the first child of this node. The type of wxTreeMultiItem needs to be of Node. Whenever not succesful, + the item returned is not ok (IsOk = false). Upon success, a valid child is returned. The cookie variable doesn't + need to be initialized */ + wxTreeMultiItem GetFirstChild(const wxTreeMultiItem &item, int &cookie) const; + + /** Returns the next child in the iteration on the level of 'item'. Make sure you called GetFirstChild first + before calling this one */ + wxTreeMultiItem GetNextChild(const wxTreeMultiItem &item, int &cookie) const; + + /** Returns the last child of this node. The type of 'item' needs to be of Node. Whenever not succesful, + the item returned is not ok (IsOk = false). Upon success, a valid last child is returned. */ + wxTreeMultiItem GetLastChild(const wxTreeMultiItem &item) const; + + /** Returns the next sibling of the passed item. */ + wxTreeMultiItem GetNextSibling(wxTreeMultiItem const& item) const; + + /** Returns the previous sibling of the passed item. */ + wxTreeMultiItem GetPrevSibling(wxTreeMultiItem const& item) const; + + /** Returns the next item. "Next" is defined by the following order: + - in case the current item has a child it is the first child of the current item; + - in case the current item has a next sibling as the next sibling; + - as the parent's (or one of its ancestor's) next sibling. + */ + wxTreeMultiItem GetNext(wxTreeMultiItem const& item) const; + + /** Returns the previous item. "Previous" is defined by the following order: + - in case the current item has a child it is the last child of the current item; + - in case the current item has a previous sibling it is the previous sibling; + - as the parent's (or one of its ancestor's) previous sibling. + */ + wxTreeMultiItem GetPrevious(wxTreeMultiItem const& item) const; + + + /** @} + */ + + /** @name Get and set methods + These methods allow you to set or get certain properties of the wxTreeMultiCtrl. + @{ + */ + + /** Get the currently used font for the caption headers in the wxTreeMultiCtrl. If you want to alter this + font, simply obtain it and copy it to a local font. After that, set this font back using SetCaptionFont() + */ + const wxFont &GetCaptionFont() const { + return _captionFont; + }; + + /** Sets the font to be used for the text caption headers. This triggers a complete redraw because x,y sizes can + differ, and ofcourse all nodes need to be updated. You can call this method at any time not only at the + beginning. */ + void SetCaptionFont(const wxFont &font); + + /** @} + */ + + void OnDraw(wxDC& dc); + +private: + DECLARE_EVENT_TABLE() +}; + +#endif diff --git a/kernel/src/ThirdParty/wx/treemultictrl/wxTreeMultiEvent.cpp b/kernel/src/ThirdParty/wx/treemultictrl/wxTreeMultiEvent.cpp new file mode 100644 index 0000000..e6e8780 --- /dev/null +++ b/kernel/src/ThirdParty/wx/treemultictrl/wxTreeMultiEvent.cpp @@ -0,0 +1,40 @@ + +#include "wx/treemultictrl/wxTreeMultiEvent.h" + + +// constructors / destructor: +wxTreeMultiEvent::wxTreeMultiEvent(wxEventType InitEventType, wxTreeMultiItem const& InitItem) + :wxNotifyEvent(InitEventType), m_Item(InitItem) +{ +} /* wxTreeMultiEvent::wxTreeMultiEvent(wxEventType, wxTreeMultiItem const&) */ + +// inherited functions: +// wxEvent: +// cloning: + +// class identification: +IMPLEMENT_DYNAMIC_CLASS(wxTreeMultiEvent, wxNotifyEvent) + +// event types: +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_BEGIN_DRAG) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_BEGIN_RDRAG) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_BEGIN_LABEL_EDIT) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_END_LABEL_EDIT) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_DELETE_ITEM) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_GET_INFO) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_SET_INFO) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_ITEM_EXPANDED) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_ITEM_EXPANDING) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_ITEM_COLLAPSED) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_ITEM_COLLAPSING) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_SEL_CHANGED) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_SEL_CHANGING) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_KEY_DOWN) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_ITEM_ACTIVATED) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_ITEM_RIGHT_CLICK) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_ITEM_MIDDLE_CLICK) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_END_DRAG) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_STATE_IMAGE_CLICK) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_ITEM_GETTOOLTIP) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_ITEM_MENU) + diff --git a/kernel/src/ThirdParty/wx/treemultictrl/wxTreeMultiEvent.h b/kernel/src/ThirdParty/wx/treemultictrl/wxTreeMultiEvent.h new file mode 100644 index 0000000..1c452d7 --- /dev/null +++ b/kernel/src/ThirdParty/wx/treemultictrl/wxTreeMultiEvent.h @@ -0,0 +1,114 @@ + +#ifndef wxtreemultievent_header +#define wxtreemultievent_header + +#include "wx/event.h" + +#include "wx/treemultictrl/wxTreeMultiCtrl.h" + + +/** + \section treemultievent Event handlers for wxTreeMultiCtrl + + Event handlers for wxTreeMultiCtrl are similar to wxTreeEvents. But they are + optimized for the wxTreeMultiCtrl class. +*/ + +class WXDLLEXPORT wxTreeMultiEvent : public wxNotifyEvent +{ +public: + /// + /// The default constructor + /// + wxTreeMultiEvent(wxEventType EventType=wxEVT_NULL, wxTreeMultiItem const& InitItem=wxTreeMultiItem()); + + // inherited functions: + // wxEvent: + // cloning: + virtual wxEvent* Clone() const {return new wxTreeMultiEvent(*this);} + + // item handling: + wxTreeMultiItem GetItem(void) const + { + return this->m_Item; + } + void SetItem(wxTreeMultiItem const& NewItem) + { + this->m_Item = NewItem; + } + + // old item handling: + wxTreeMultiItem GetOldItem(void) const + { + return this->m_OldItem; + } + void SetOldItem(wxTreeMultiItem const& NewItem) + { + this->m_OldItem = NewItem; + } + +protected: +private: + // variables: + wxTreeMultiItem m_Item, m_OldItem; + + // class identification: + DECLARE_DYNAMIC_CLASS(wxTreeMultiEvent) +}; + + +// event handler function: +typedef void (wxEvtHandler::*wxTreeMultiEventFunction)(wxTreeMultiEvent&); + +// event types: +BEGIN_DECLARE_EVENT_TYPES() + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_BEGIN_DRAG, -1) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_BEGIN_RDRAG, -1) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_BEGIN_LABEL_EDIT, -1) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_END_LABEL_EDIT, -1) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_DELETE_ITEM, -1) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_GET_INFO, -1) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_SET_INFO, -1) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_ITEM_EXPANDED, -1) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_ITEM_EXPANDING, -1) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_ITEM_COLLAPSED, -1) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_ITEM_COLLAPSING, -1) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_SEL_CHANGED, -1) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_SEL_CHANGING, -1) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_KEY_DOWN, -1) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_ITEM_ACTIVATED, -1) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_ITEM_RIGHT_CLICK, -1) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_ITEM_MIDDLE_CLICK, -1) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_END_DRAG, -1) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_STATE_IMAGE_CLICK, -1) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_ITEM_GETTOOLTIP, -1) + DECLARE_EVENT_TYPE(wxEVT_COMMAND_TREE_MULTI_ITEM_MENU, -1) +END_DECLARE_EVENT_TYPES() + +#define wxTreeMultiEventHandler(func) (wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent(wxTreeMultiEventFunction, &func) + + +// standard events similar or identical to wxTreeEvent: +#define EVT_TREE_MULTI_BEGIN_DRAG (id,fn) wx__DECLARE_EVT1(wxEVT_COMMAND_TREE_BEGIN_DRAG, id,wxTreeMultiEventHandler(fn)) +#define EVT_TREE_MULTI_BEGIN_RDRAG(id,fn) wx__DECLARE_EVT1(wxEVT_COMMAND_TREE_BEGIN_RDRAG,id,wxTreeMultiEventHandler(fn)) +#define EVT_TREE_MULTI_END_DRAG (id,fn) wx__DECLARE_EVT1(wxEVT_COMMAND_TREE_END_DRAG, id,wxTreeMultiEventHandler(fn)) +#define EVT_TREE_MULTI_BEGIN_LABEL_EDIT(id, fn) wx__DECLARE_EVT1(wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT, id, wxTreeMultiEventHandler(fn)) +#define EVT_TREE_MULTI_END_LABEL_EDIT(id, fn) wx__DECLARE_EVT1(wxEVT_COMMAND_TREE_END_LABEL_EDIT, id, wxTreeMultiEventHandler(fn)) +#define EVT_TREE_MULTI_GET_INFO(id, fn) wx__DECLARE_EVT1(wxEVT_COMMAND_TREE_GET_INFO, id, wxTreeMultiEventHandler(fn)) +#define EVT_TREE_MULTI_SET_INFO(id, fn) wx__DECLARE_EVT1(wxEVT_COMMAND_TREE_SET_INFO, id, wxTreeMultiEventHandler(fn)) +#define EVT_TREE_MULTI_ITEM_EXPANDED(id, fn) wx__DECLARE_EVT1(wxEVT_COMMAND_TREE_MULTI_ITEM_EXPANDED, id, wxTreeMultiEventHandler(fn)) +#define EVT_TREE_MULTI_ITEM_EXPANDING(id, fn) wx__DECLARE_EVT1(wxEVT_COMMAND_TREE_MULTI_ITEM_EXPANDING, id, wxTreeMultiEventHandler(fn)) +#define EVT_TREE_MULTI_ITEM_COLLAPSED(id, fn) wx__DECLARE_EVT1(wxEVT_COMMAND_TREE_MULTI_ITEM_COLLAPSED, id, wxTreeMultiEventHandler(fn)) +#define EVT_TREE_MULTI_ITEM_COLLAPSING(id, fn) wx__DECLARE_EVT1(wxEVT_COMMAND_TREE_MULTI_ITEM_COLLAPSING, id, wxTreeMultiEventHandler(fn)) +#define EVT_TREE_MULTI_SEL_CHANGED(id, fn) wx__DECLARE_EVT1(wxEVT_COMMAND_TREE_SEL_CHANGED, id, wxTreeMultiEventHandler(fn)) +#define EVT_TREE_MULTI_SEL_CHANGING(id, fn) wx__DECLARE_EVT1(wxEVT_COMMAND_TREE_SEL_CHANGING, id, wxTreeMultiEventHandler(fn)) +#define EVT_TREE_MULTI_KEY_DOWN(id, fn) wx__DECLARE_EVT1(wxEVT_COMMAND_TREE_KEY_DOWN, id, wxTreeMultiEventHandler(fn)) +#define EVT_TREE_MULTI_DELETE_ITEM(id, fn) wx__DECLARE_EVT1(wxEVT_COMMAND_TREE_DELETE_ITEM, id, wxTreeMultiEventHandler(fn)) +#define EVT_TREE_MULTI_ITEM_ACTIVATED(id, fn) wx__DECLARE_EVT1(wxEVT_COMMAND_TREE_MULTI_ITEM_ACTIVATED, id, wxTreeMultiEventHandler(fn)) +#define EVT_TREE_MULTI_ITEM_MENU(id, fn) wx__DECLARE_EVT1(wxEVT_COMMAND_TREE_MULTI_ITEM_MENU, id, wxTreeMultiEventHandler(fn)) +#define EVT_TREE_MULTI_ITEM_RIGHT_CLICK(id, fn) wx__DECLARE_EVT1(wxEVT_COMMAND_TREE_MULTI_ITEM_RIGHT_CLICK, id, wxTreeMultiEventHandler(fn)) +#define EVT_TREE_MULTI_ITEM_MIDDLE_CLICK(id, fn) wx__DECLARE_EVT1(wxEVT_COMMAND_TREE_MULTI_ITEM_MIDDLE_CLICK, id, wxTreeMultiEventHandler(fn)) +#define EVT_TREE_MULTI_STATE_IMAGE_CLICK(id, fn) wx__DECLARE_EVT1(wxEVT_COMMAND_TREE_STATE_IMAGE_CLICK, id, wxTreeMultiEventHandler(fn)) +#define EVT_TREE_MULTI_ITEM_GETTOOLTIP(id, fn) wx__DECLARE_EVT1(wxEVT_COMMAND_TREE_MULTI_ITEM_GETTOOLTIP, id, wxTreeMultiEventHandler(fn)) + +#endif diff --git a/kernel/src/bbtkFactory.h b/kernel/src/bbtkFactory.h index 75acb76..3150e6e 100644 --- a/kernel/src/bbtkFactory.h +++ b/kernel/src/bbtkFactory.h @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkFactory.h,v $ Language: C++ - Date: $Date: 2008/03/07 08:40:14 $ - Version: $Revision: 1.10 $ + Date: $Date: 2008/03/28 13:42:17 $ + Version: $Revision: 1.11 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See doc/license.txt or @@ -99,6 +99,7 @@ namespace bbtk std::string pkgname, std::string path); + public: /// The structure storing info on a package class PackageInfoType { @@ -114,6 +115,10 @@ namespace bbtk }; /// The type of map of packages typedef std::map< std::string, PackageInfoType > PackageMapType; + + const PackageMapType& GetPackageMap() const { return mPackageMap; } + + private: /// The map of packages PackageMapType mPackageMap; diff --git a/kernel/src/bbtkWxGUIPackageBrowser.cxx b/kernel/src/bbtkWxGUIPackageBrowser.cxx new file mode 100644 index 0000000..2a5d0f5 --- /dev/null +++ b/kernel/src/bbtkWxGUIPackageBrowser.cxx @@ -0,0 +1,199 @@ +/*========================================================================= + + Program: bbtk + Module: $RCSfile: bbtkWxGUIPackageBrowser.cxx,v $ + Language: C++ + Date: $Date: 2008/03/28 13:42:18 $ + Version: $Revision: 1.1 $ + + Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de + l'Image). All rights reserved. See Doc/License.txt or + http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*//** + * \brief Short description in one line + * + * Long description which + * can span multiple lines + */ +/** + * \file + * \brief + */ +/** + * \class bbtk:: + * \brief + */ + + +#ifdef _USE_WXWIDGETS_ + +#include "bbtkWxGUIPackageBrowser.h" +#include "ThirdParty/wx/treemultictrl/wxTreeMultiCtrl.h" +#include "bbtkInterpreter.h" + +namespace bbtk +{ + //================================================================ + WxGUIPackageBrowserBlackBox::WxGUIPackageBrowserBlackBox(wxWindow* parent, + WxGUIPackageBrowser* browser, + BlackBoxDescriptor* descr) : + wxPanel(parent, -1), + mBrowser(browser), + mDescriptor(descr) + { + wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL); + + wxStaticText* s = new wxStaticText(this,-1, + std2wx(descr->GetTypeName())); + + sizer->Add(s,1,wxGROW); + + SetSizer(sizer); + SetAutoLayout(true); + Layout(); + } + //================================================================ + + + //================================================================ + WxGUIPackageBrowserBlackBox::~WxGUIPackageBrowserBlackBox() + { + } + //================================================================ + + + //================================================================ + WxGUIPackageBrowser::WxGUIPackageBrowser( wxWindow *parent, + WxGUIPackageBrowserUser* user ) + : wxPanel(parent, -1), + mUser(user), + mInterpreter(0) + { + std::cout << "WxGUIPackageBrowser::WxGUIPackageBrowser"<SetBackgroundColour(*wxWHITE); + sizer->Add(mTree,1,wxGROW); + +#ifndef LINUX + wxTreeMultiWindowInfo wndinfo(wxTMC_BG_ADJUST_CNT, 8, 0); +#else + wxTreeMultiWindowInfo wndinfo(wxTMC_BG_ADJUST_ALL, 8, 0); +#endif + + // make it a bit bigger + wxFont somefont; + somefont = mTree->GetCaptionFont(); + somefont.SetFamily(wxMODERN); + somefont.SetWeight(wxBOLD); + somefont.SetPointSize(somefont.GetPointSize()+1); + mTree->SetCaptionFont(somefont); + + mTree->SetSpacingY(1); + + SetSizer(sizer); + SetAutoLayout(true); + Layout(); + + } + //================================================================ + + //================================================================ + WxGUIPackageBrowser::~WxGUIPackageBrowser() + { + if (mInterpreter) delete mInterpreter; + } + //================================================================ + + //================================================================ + void WxGUIPackageBrowser::IncludeAll() + { +#ifndef LINUX + wxTreeMultiWindowInfo wndinfo(wxTMC_BG_ADJUST_CNT, 8, 0); +#else + wxTreeMultiWindowInfo wndinfo(wxTMC_BG_ADJUST_ALL, 8, 0); +#endif + + if (!mInterpreter) mInterpreter = new bbtk::Interpreter(); + mInterpreter->SetCommandLine(true); + mInterpreter->InterpretLine("include *"); + + Factory* F = mInterpreter->GetExecuter()->GetFactory(); + + const Factory::PackageMapType& M = F->GetPackageMap(); + Factory::PackageMapType::const_iterator i; + for (i=M.begin();i!=M.end();++i) + { + Package* P = i->second.mPackage; + wxString packname = std2wx(P->GetName()); + if (packname==_T("user")) continue; + wxTreeMultiItem pack = mTree->AddRoot(packname,packname); + + Package::BlackBoxMapType::iterator j; + for (j=P->GetBlackBoxMap().begin(); + j!=P->GetBlackBoxMap().end(); + ++j) + { + wxString boxname = std2wx(j->second->GetTypeName()); + wxTreeMultiItem box = mTree->AppendNode(pack,boxname,boxname); + WxGUIPackageBrowserBlackBox* boxdescr + = new WxGUIPackageBrowserBlackBox(mTree,this,j->second); + mTree->AppendWindow(box, boxdescr, _T(""), + wndinfo, wxTMC_SPAN_WIDTH); + + } + } + mTree->CollapseNodes(true); + + // Test exclude + // wxTreeMultiItem item = mTree->FindItem(_T("Add")); + // if(item.IsOk()) mTree->Exclude(item); + } + //================================================================ + + //================================================================ + WxGUIPackageBrowserWindow::WxGUIPackageBrowserWindow( wxWindow *parent, + wxString title, + wxSize size) + : wxFrame((wxFrame *)parent, -1, title, wxDefaultPosition, size) + { + + + wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL); + + mBrowser = new WxGUIPackageBrowser(this); + mBrowser->IncludeAll(); + sizer->Add(mBrowser,1,wxGROW); + + // WxGUICommand* com = new WxGUICommand(this,this); + // sizer->Add(com); + + SetSizer(sizer); + + // Creates and sets the parent window of all bbtk windows + wxWindow* top = new wxPanel(this,-1); + top->Hide(); + + Wx::SetTopWindow(top); + + SetAutoLayout(true); + Layout(); + } + //================================================================ + + //================================================================ + WxGUIPackageBrowserWindow::~WxGUIPackageBrowserWindow() + { + } + //================================================================ + +} // namespace bbtk + + +#endif //_USE_WXWIDGETS_ diff --git a/kernel/src/bbtkWxGUIPackageBrowser.h b/kernel/src/bbtkWxGUIPackageBrowser.h new file mode 100644 index 0000000..0c9346b --- /dev/null +++ b/kernel/src/bbtkWxGUIPackageBrowser.h @@ -0,0 +1,125 @@ +/*========================================================================= + + Program: bbtk + Module: $RCSfile: bbtkWxGUIPackageBrowser.h,v $ + Language: C++ + Date: $Date: 2008/03/28 13:42:18 $ + Version: $Revision: 1.1 $ + + Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de + l'Image). All rights reserved. See Doc/License.txt or + http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*//** + * \brief Short description in one line + * + * Long description which + * can span multiple lines + */ +/** + * \file + * \brief + */ +/** + * \class bbtk:: + * \brief + */ + + +#ifdef _USE_WXWIDGETS_ + + +#ifndef __bbtkWxGUIPackageBrowser_h__ +#define __bbtkWxGUIPackageBrowser_h__ + + +#include "bbtkWx.h" + +#include "bbtkInterpreter.h" + +class wxTreeMultiCtrl; + +namespace bbtk +{ + //================================================================ + class WxGUIPackageBrowser; + //================================================================ + + + //================================================================ + /// Abstract class which defines the callbacks invoked by WxGUIPackageBrowser + class BBTK_EXPORT WxGUIPackageBrowserUser + { + public: + WxGUIPackageBrowserUser() {} + ~WxGUIPackageBrowserUser() {} + /// Callback invoked when the 'run' button is pressed + virtual void WxGUIPackageBrowserRun() {} + }; + //================================================================ + + //================================================================ + class WxGUIPackageBrowserBlackBox : public wxPanel + { + public: + WxGUIPackageBrowserBlackBox(wxWindow* parent, + WxGUIPackageBrowser* browser, + BlackBoxDescriptor* descr); + ~WxGUIPackageBrowserBlackBox(); + + private: + WxGUIPackageBrowser* mBrowser; + BlackBoxDescriptor* mDescriptor; + } ; + //================================================================ + + + //================================================================ + /// A package browser panel + class BBTK_EXPORT WxGUIPackageBrowser : public wxPanel + { + public: + WxGUIPackageBrowser( wxWindow *parent, + WxGUIPackageBrowserUser* user = 0 ); + ~WxGUIPackageBrowser(); + + void IncludeAll(); + + private: + WxGUIPackageBrowserUser* mUser; + Interpreter* mInterpreter; + wxTreeMultiCtrl* mTree; + + }; + //================================================================ + + + //================================================================ + /// Browser in a frame + class BBTK_EXPORT WxGUIPackageBrowserWindow : public wxFrame + //, public WxGUICommandUser + { + public: + WxGUIPackageBrowserWindow( wxWindow *parent, wxString title, wxSize size); + ~WxGUIPackageBrowserWindow(); + // void Open(const std::string& filename) { mBrowser->Open(filename); } + // void WxGUICommandEnter(const std::string& s); + + + private : + + WxGUIPackageBrowser* mBrowser; + }; + //================================================================ + + +} // namespace bbtk + + +#endif // __bbtkWxGUIPackageBrowser_h__ + +#endif //_USE_WXWIDGETS_ -- 2.45.0