Cafu Engine
WindowHierarchy.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_GUIEDITOR_WINDOW_HIERARCHY_HPP_INCLUDED
8 #define CAFU_GUIEDITOR_WINDOW_HIERARCHY_HPP_INCLUDED
9 
10 #include "ObserverPattern.hpp"
11 
12 #include "wx/treectrl.h"
13 
14 
15 namespace cf { namespace GuiSys { class GuiImplT; } }
16 namespace cf { namespace GuiSys { class WindowT; } }
17 
18 
19 namespace GuiEditor
20 {
21  class ChildFrameT;
22  class GuiDocumentT;
23 
24  class WindowHierarchyT : public wxTreeCtrl, public ObserverT
25  {
26  public:
27 
28  WindowHierarchyT(ChildFrameT* Parent, const wxSize& Size);
30 
31  // ObserverT implementation.
35  void NotifySubjectChanged_Modified(SubjectT* Subject, const ArrayT< IntrusivePtrT<cf::GuiSys::WindowT> >& Windows, WindowModDetailE Detail);
36  void Notify_Changed(SubjectT* Subject, const cf::TypeSys::VarBaseT& Var);
37  void NotifySubjectDies(SubjectT* dyingSubject);
38 
39  /// Redraws the whole tree.
40  void RefreshTree();
41 
42 
43  private:
44 
45  void AddChildren(const wxTreeItemId& Item, bool Recursive);
46 
47  /// Recusively searches the tree for an item associated with a specified WindowT.
48  /// @param StartingItem Item to start the recursive search at.
49  /// @param Window The window whose tree item we are interested in.
50  const wxTreeItemId FindTreeItem(const wxTreeItemId& StartingItem, IntrusivePtrT<cf::GuiSys::WindowT> Window) const;
51 
52  /// Recursively gets all tree items, beginning with the passed tree item.
53  void GetTreeItems(const wxTreeItemId& StartingItem, ArrayT<wxTreeItemId>& Items);
54 
55  GuiDocumentT* m_GuiDocument;
56  ChildFrameT* m_Parent;
57  bool m_IsRecursiveSelfNotify;
58  IntrusivePtrT<cf::GuiSys::WindowT> m_DraggedWindow;
59 
60  void OnKeyDown (wxKeyEvent& KE);
61  void OnTreeLeftClick (wxMouseEvent& ME);
62  void OnSelectionChanged (wxTreeEvent& TE);
63  void OnEndLabelEdit (wxTreeEvent& TE);
64  void OnTreeItemRightClick(wxTreeEvent& TE);
65  void OnBeginDrag (wxTreeEvent& TE);
66  void OnEndDrag (wxTreeEvent& TE);
67 
68  DECLARE_EVENT_TABLE()
69  };
70 }
71 
72 #endif
void NotifySubjectChanged_Created(SubjectT *Subject, const ArrayT< IntrusivePtrT< cf::GuiSys::WindowT > > &Windows)
Notifies the observer that one or more windows have been created.
Definition: WindowHierarchy.cpp:172
void NotifySubjectChanged_Modified(SubjectT *Subject, const ArrayT< IntrusivePtrT< cf::GuiSys::WindowT > > &Windows, WindowModDetailE Detail)
Definition: WindowHierarchy.cpp:188
Definition: ObserverPattern.hpp:38
This class represents a child frame.
Definition: ChildFrame.hpp:55
void NotifySubjectChanged_Selection(SubjectT *Subject, const ArrayT< IntrusivePtrT< cf::GuiSys::WindowT > > &OldSelection, const ArrayT< IntrusivePtrT< cf::GuiSys::WindowT > > &NewSelection)
This method is called whenever the window selection of a GUI subject changed.
Definition: WindowHierarchy.cpp:145
Definition: ChildFrame.hpp:35
Definition: GuiDocument.hpp:39
This is the common base class for the VarT classes.
Definition: Variables.hpp:113
Definition: WindowHierarchy.hpp:24
void NotifySubjectDies(SubjectT *dyingSubject)
This method is called whenever a subject is about the be destroyed (and become unavailable).
Definition: WindowHierarchy.cpp:302
Definition: ObserverPattern.hpp:95
void Notify_Changed(SubjectT *Subject, const cf::TypeSys::VarBaseT &Var)
Notifies the observer that a variable has changed.
Definition: WindowHierarchy.cpp:200
This file provides the classes for the Observer pattern as described in the book by the GoF...
Definition: Renderer.hpp:16
void RefreshTree()
Redraws the whole tree.
Definition: WindowHierarchy.cpp:227
void NotifySubjectChanged_Deleted(SubjectT *Subject, const ArrayT< IntrusivePtrT< cf::GuiSys::WindowT > > &Windows)
Notifies the observer that one or more windows have been deleted.
Definition: WindowHierarchy.cpp:180