ToolMap
|
This is the visual control, which will contain all the logic for the tree mechanism. More...
#include <wxTreeMultiCtrl.h>
Public Member Functions | |
wxTreeMultiCtrl () | |
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) | |
virtual | ~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) |
wxTreeMultiItem | HitTest (wxPoint const &pt, int &flags) |
int | GetChildrenCount (const wxTreeMultiItem &item) |
wxTreeMultiItem | GetFocus () |
void | OnDraw (wxDC &dc) |
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. | |
wxTreeMultiItem | AddRoot (const wxString &caption, const wxString &name=wxEmptyString) |
wxTreeMultiItem | AppendWindow (const wxTreeMultiItem &ParentItem, wxWindow *window=nullptr, const wxString &name=wxEmptyString, wxTreeMultiWindowInfo const &info=wxTreeMultiWindowInfoDefault, int flags=0) |
wxTreeMultiItem | InsertWindow (wxTreeMultiItem const &ParentItem, size_t Position, wxWindow *window=nullptr, wxString const &Name=wxEmptyString, wxTreeMultiWindowInfo const &info=wxTreeMultiWindowInfoDefault, int flags=0) |
wxTreeMultiItem | PrependWindow (wxTreeMultiItem const &ParentItem, wxWindow *window=nullptr, const wxString &name=wxEmptyString, wxTreeMultiWindowInfo const &info=wxTreeMultiWindowInfoDefault, int flags=0) |
wxTreeMultiItem | AppendNode (wxTreeMultiItem const &ParentItem, const wxString &caption=wxEmptyString, const wxString &name=wxEmptyString) |
wxTreeMultiItem | InsertNode (wxTreeMultiItem const &ParentItem, size_t Position, wxString const &caption, wxString const &name) |
wxTreeMultiItem | PrependNode (wxTreeMultiItem const &ParentItem, wxString const &caption=wxEmptyString, wxString const &name=wxEmptyString) |
bool | Delete (wxTreeMultiItem &item) |
void | DeleteAllItems (void) |
void | DeleteChildren (const wxTreeMultiItem &item) |
Expand and collapse methods | |
These methods are all for items of type Node. | |
void | ExpandNodes (bool recursive=false) |
void | CollapseNodes (bool recursive=false) |
void | Expand (const wxTreeMultiItem &item, bool recursive) |
void | Collapse (const wxTreeMultiItem &item, bool recursive) |
void | CollapseAndReset (const wxTreeMultiItem &item) |
void | Fold (const wxTreeMultiItem &item, bool expand=true) |
Selection manipulation | |
These methods allow you to select, unselect or test wxTreeMultiItems on selection. Currently only items of type Node can be manipulated. | |
size_t | GetSelectedItemCount (void) const |
wxTreeMultiItem | GetFirstSelectedItem (void) const |
wxTreeMultiItem | GetLastSelectedItem (void) const |
wxTreeMultiItem | GetSelectedItem (size_t Index) const |
size_t | GetSelectedItemIndex (wxTreeMultiItem const &Item) const |
void | SelectItem (wxTreeMultiItem const &Item, bool UnselectOthers=true, bool ExpandSelection=false) |
void | UnselectAll (void) |
void | Unselect (wxTreeMultiItem const &Item) |
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. | |
void | Exclude (const wxTreeMultiItem &item) |
void | Include (const wxTreeMultiItem &item) |
wxTreeMultiItem | GetExcludedParent (const wxTreeMultiItem &item) |
Find methods | |
These methods are used for finding a node in the wxTreeMultiCtrl. | |
wxTreeMultiItem | FindItem (const wxTreeMultiItem &item, const wxString &name, bool ignoreCase=false, bool skipFirst=false) |
wxTreeMultiItem | FindItem (const wxString &name, bool ignoreCase=false) |
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. | |
bool | GetBooleanValue (int wndId) |
wxString | GetTextValue (int wndId) |
void | SetBooleanValue (int wndId, bool value=true) |
void | SetTextValue (int wndId, const wxString &value=wxEmptyString) |
wxWindow * | GetWindow (const wxTreeMultiItem &item) |
void | SetSelectionValue (int wndId, int sel) |
int | GetSelectionValue (int wndId) |
void | GetSelectionValues (int wndId, wxArrayInt &sels) |
Extended visibility and manipulation methods | |
These methods alter the wxTreeMultiCtrl appearance, or add more functionality like checkboxes before each node. | |
void | SetSpacingY (int spacingY) |
int | GetSpacingY () const |
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. | |
wxTreeMultiItem | GetFirstRoot (void) const |
wxTreeMultiItem | GetLastRoot (void) const |
wxTreeMultiItem | GetParent (wxTreeMultiItem const &item) const |
wxTreeMultiItem | GetFirstChild (const wxTreeMultiItem &item, int &cookie) const |
wxTreeMultiItem | GetNextChild (const wxTreeMultiItem &item, int &cookie) const |
wxTreeMultiItem | GetLastChild (const wxTreeMultiItem &item) const |
wxTreeMultiItem | GetNextSibling (wxTreeMultiItem const &item) const |
wxTreeMultiItem | GetPrevSibling (wxTreeMultiItem const &item) const |
wxTreeMultiItem | GetNext (wxTreeMultiItem const &item) const |
wxTreeMultiItem | GetPrevious (wxTreeMultiItem const &item) const |
Get and set methods | |
These methods allow you to set or get certain properties of the wxTreeMultiCtrl. | |
const wxFont & | GetCaptionFont () const |
void | SetCaptionFont (const wxFont &font) |
void | SetCaption (wxTreeMultiItem const &item, const wxString &caption) |
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;
IMPORTANT: Every control added to the wxTreeMultiCtrl has to be child of the wxTreeMultiCtrl.
|
inline |
Two step constructor. Call Create when this constructor is called to build up the wxTreeMultiCtrl
|
inline |
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
|
virtual |
Destructor
wxTreeMultiItem wxTreeMultiCtrl::AddRoot | ( | const wxString & | caption, |
const wxString & | name = wxEmptyString |
||
) |
Adds a root node to the wxTreeMultiItem. There can be many root nodes. Use this wxTreeMultiNode pointer to add more subnodes to it.
wxTreeMultiItem wxTreeMultiCtrl::AppendNode | ( | wxTreeMultiItem const & | ParentItem, |
const wxString & | caption = wxEmptyString , |
||
const wxString & | name = wxEmptyString |
||
) |
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 wxTreeMultiCtrl::AppendWindow | ( | const wxTreeMultiItem & | ParentItem, |
wxWindow * | window = nullptr , |
||
const wxString & | name = wxEmptyString , |
||
wxTreeMultiWindowInfo const & | info = wxTreeMultiWindowInfoDefault , |
||
int | flags = 0 |
||
) |
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
void wxTreeMultiCtrl::Collapse | ( | 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 wxTreeMultiCtrl::CollapseAndReset | ( | const wxTreeMultiItem & | item | ) |
Collapses this node and removes all children from it. This is only applicable on wxTreeMultiItems which are of type Node / Root.
void wxTreeMultiCtrl::CollapseNodes | ( | bool | recursive = false | ) |
Collapses all nodes and subnodes. Recursive = true means all subnodes are also expanded.
bool wxTreeMultiCtrl::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 |
||
) |
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
bool wxTreeMultiCtrl::Delete | ( | wxTreeMultiItem & | item | ) |
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
|
inline |
Deletes all the items from the wxTreeMultiCtrl.
void wxTreeMultiCtrl::DeleteChildren | ( | const wxTreeMultiItem & | item | ) |
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 wxTreeMultiCtrl::Exclude | ( | const wxTreeMultiItem & | item | ) |
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 wxTreeMultiCtrl::Expand | ( | const wxTreeMultiItem & | item, |
bool | recursive | ||
) |
Expands given node, and with recursive, also the subnodes
void wxTreeMultiCtrl::ExpandNodes | ( | bool | recursive = false | ) |
Expand all nodes and subnodes. Recursive = true means all subnodes are also expanded.
|
inline |
Searches all nodes for the given name and returns the one found. This is a specialised method for FindItem
wxTreeMultiItem wxTreeMultiCtrl::FindItem | ( | const wxTreeMultiItem & | item, |
const wxString & | name, | ||
bool | ignoreCase = false , |
||
bool | skipFirst = false |
||
) |
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.
|
inline |
Folds the given node. The same as Expand and Collapse, but the state can be given through a parameter
bool wxTreeMultiCtrl::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 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.
|
inline |
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()
|
inline |
Returns the number of children in this node. If this node is not of type Node, count returns -1.
wxTreeMultiItem wxTreeMultiCtrl::GetExcludedParent | ( | 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 wxTreeMultiCtrl::GetFirstChild | ( | const wxTreeMultiItem & | item, |
int & | cookie | ||
) | 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
|
inline |
Returns the first root.
wxTreeMultiItem wxTreeMultiCtrl::GetFirstSelectedItem | ( | void | ) | const |
Returns the first selected item. If there is no selected item an invalid tree multi item is returned.
wxTreeMultiItem wxTreeMultiCtrl::GetFocus | ( | ) |
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 wxTreeMultiCtrl::GetLastChild | ( | const wxTreeMultiItem & | item | ) | 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.
|
inline |
Returns the last root.
wxTreeMultiItem wxTreeMultiCtrl::GetLastSelectedItem | ( | void | ) | const |
Returns the last selected item. If there is no selected item an invalid tree multi item is returned.
wxTreeMultiItem wxTreeMultiCtrl::GetNext | ( | wxTreeMultiItem const & | item | ) | const |
Returns the next item. "Next" is defined by the following order:
wxTreeMultiItem wxTreeMultiCtrl::GetNextChild | ( | 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 wxTreeMultiCtrl::GetNextSibling | ( | wxTreeMultiItem const & | item | ) | const |
Returns the next sibling of the passed item.
wxTreeMultiItem wxTreeMultiCtrl::GetParent | ( | wxTreeMultiItem const & | item | ) | const |
Returns the items parent.
wxTreeMultiItem wxTreeMultiCtrl::GetPrevious | ( | wxTreeMultiItem const & | item | ) | const |
Returns the previous item. "Previous" is defined by the following order:
wxTreeMultiItem wxTreeMultiCtrl::GetPrevSibling | ( | wxTreeMultiItem const & | item | ) | const |
Returns the previous sibling of the passed item.
wxTreeMultiItem wxTreeMultiCtrl::GetSelectedItem | ( | size_t | Index | ) | 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.
|
inline |
Returns the number of selected items.
size_t wxTreeMultiCtrl::GetSelectedItemIndex | ( | wxTreeMultiItem const & | Item | ) | const |
Returns the index of the selected item. In case the item is not selected "GetSelectedItemCount()" - which is an invalid index - is returned.
int wxTreeMultiCtrl::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, 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.
void wxTreeMultiCtrl::GetSelectionValues | ( | int | wndId, |
wxArrayInt & | sels | ||
) |
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.
|
inline |
Gets the Y spacing of the wxTreeMultiCtrl.
wxString wxTreeMultiCtrl::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 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.
|
inline |
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.
wxTreeMultiItem wxTreeMultiCtrl::HitTest | ( | wxPoint const & | pt, |
int & | flags | ||
) |
Checks if the point is under one of the given areas. The returned areas can be
Returned is the item which is located under the mouse, or none (IsOk = false) if no item under the mouse
void wxTreeMultiCtrl::Include | ( | 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
wxTreeMultiItem wxTreeMultiCtrl::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 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 wxTreeMultiCtrl::InsertWindow | ( | wxTreeMultiItem const & | ParentItem, |
size_t | Position, | ||
wxWindow * | window = nullptr , |
||
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 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 wxTreeMultiCtrl::PrependNode | ( | wxTreeMultiItem const & | ParentItem, |
wxString const & | caption = wxEmptyString , |
||
wxString const & | name = wxEmptyString |
||
) |
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 wxTreeMultiCtrl::PrependWindow | ( | wxTreeMultiItem const & | ParentItem, |
wxWindow * | window = nullptr , |
||
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 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.
void wxTreeMultiCtrl::SelectItem | ( | wxTreeMultiItem const & | Item, |
bool | UnselectOthers = true , |
||
bool | ExpandSelection = false |
||
) |
Selects the specified item AND in case
void wxTreeMultiCtrl::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 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.
void wxTreeMultiCtrl::SetCaption | ( | wxTreeMultiItem const & | item, |
const wxString & | caption | ||
) |
Sets the caption for a node referred to by item. This triggers a redraw from the current node.
void wxTreeMultiCtrl::SetCaptionFont | ( | const wxFont & | font | ) |
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 wxTreeMultiCtrl::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. If it is found the selection is set in the control.
|
inline |
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 wxTreeMultiCtrl::SetTextValue | ( | int | wndId, |
const wxString & | value = wxEmptyString |
||
) |
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.
void wxTreeMultiCtrl::Unselect | ( | wxTreeMultiItem const & | Item | ) |
Unselect specified item
void wxTreeMultiCtrl::UnselectAll | ( | void | ) |
Unselect all selected items.