Cafu Engine
JointsHierarchy.hpp
1 /*
2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
5 */
6 
7 #ifndef CAFU_MODELEDITOR_JOINTS_HIERARCHY_HPP_INCLUDED
8 #define CAFU_MODELEDITOR_JOINTS_HIERARCHY_HPP_INCLUDED
9 
10 #include "ObserverPattern.hpp"
11 #include "Templates/Array.hpp"
12 #include "wx/treectrl.h"
13 
14 
15 namespace ModelEditor
16 {
17  class ChildFrameT;
18  class ModelDocumentT;
19 
20 
21  class JointsHierarchyT : public wxTreeCtrl, public ObserverT
22  {
23  public:
24 
25  JointsHierarchyT(ChildFrameT* Parent, const wxSize& Size);
27 
28  // ObserverT implementation.
29  void Notify_SelectionChanged(SubjectT* Subject, ModelElementTypeT Type, const ArrayT<unsigned int>& OldSel, const ArrayT<unsigned int>& NewSel);
30  void Notify_Created(SubjectT* Subject, ModelElementTypeT Type, const ArrayT<unsigned int>& Indices);
31  void Notify_Deleted(SubjectT* Subject, ModelElementTypeT Type, const ArrayT<unsigned int>& Indices);
32  void Notify_JointChanged(SubjectT* Subject, unsigned int JointNr);
33  void Notify_SubjectDies(SubjectT* dyingSubject);
34 
35 
36  private:
37 
38  /// Redraws/re-inits the whole tree.
39  void RefreshTree();
40 
41  /// Recursively searches the tree for an item associated with a specified WindowT.
42  /// @param StartingItem Item to start the recursive search at.
43  /// @param JointNr The number of the joint whose tree item we are interested in.
44  const wxTreeItemId FindTreeItem(const wxTreeItemId& StartingItem, unsigned int JointNr) const;
45 
46  /// Recursively gets all tree items, beginning with the passed tree item.
47  void GetTreeItems(const wxTreeItemId& StartingItem, ArrayT<wxTreeItemId>& Items);
48 
49  void OnFocus (wxFocusEvent& FE);
50  void OnKeyDown (wxKeyEvent& KE);
51  // void OnTreeLeftClick (wxMouseEvent& ME);
52  void OnItemActivated (wxTreeEvent& TE); ///< The item has been activated (ENTER or double click).
53  void OnSelectionChanged (wxTreeEvent& TE);
54  void OnLabelChanged (wxTreeEvent& TE);
55  void OnTreeItemRightClick(wxTreeEvent& TE);
56 
57  DECLARE_EVENT_TABLE()
58 
59  ModelDocumentT* m_ModelDoc;
60  ChildFrameT* m_Parent;
61  bool m_IsRecursiveSelfNotify;
62  };
63 }
64 
65 #endif
Definition: ChildFrame.hpp:35
void Notify_JointChanged(SubjectT *Subject, unsigned int JointNr)
Notifies the observer that a joint has changed.
Definition: JointsHierarchy.cpp:172
void Notify_Deleted(SubjectT *Subject, ModelElementTypeT Type, const ArrayT< unsigned int > &Indices)
This method is called when new elements were deleted from the model.
Definition: JointsHierarchy.cpp:163
This class represents a child frame.
Definition: ChildFrame.hpp:55
void Notify_SubjectDies(SubjectT *dyingSubject)
This method is called whenever a subject is about the be destroyed (and become unavailable).
Definition: JointsHierarchy.cpp:189
void Notify_SelectionChanged(SubjectT *Subject, ModelElementTypeT Type, const ArrayT< unsigned int > &OldSel, const ArrayT< unsigned int > &NewSel)
This method is called whenever the selection of a model changed.
Definition: JointsHierarchy.cpp:126
Definition: JointsHierarchy.hpp:21
Definition: ObserverPattern.hpp:104
This file provides the classes for the Observer pattern as described in the book by the GoF...
void Notify_Created(SubjectT *Subject, ModelElementTypeT Type, const ArrayT< unsigned int > &Indices)
This method is called when new elements have been created and were added to the model.
Definition: JointsHierarchy.cpp:154
Definition: ObserverPattern.hpp:28
Definition: ModelDocument.hpp:30