Cafu Engine
ElementsList.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_ELEMENTS_LIST_HPP_INCLUDED
8 #define CAFU_MODELEDITOR_ELEMENTS_LIST_HPP_INCLUDED
9 
10 #include "ObserverPattern.hpp"
11 #include "wx/listctrl.h"
12 #include "wx/panel.h"
13 
14 
15 namespace ModelEditor
16 {
17  class ChildFrameT;
18  class ModelDocumentT;
19 
20 
21  /// A control for displaying a list of the elements of the model.
22  class ElementsListT : public wxListView, public ObserverT
23  {
24  public:
25 
26  /// The constructor.
27  ElementsListT(ChildFrameT* MainFrame, wxWindow* Parent, const wxSize& Size, ModelElementTypeT Type);
28 
29  /// The destructor.
31 
32  /// Returns whether one or more "default" elements are selected in the list.
33  bool AreDefaultItemsSelected() const;
34 
35  // ObserverT implementation.
36  void Notify_SelectionChanged(SubjectT* Subject, ModelElementTypeT Type, const ArrayT<unsigned int>& OldSel, const ArrayT<unsigned int>& NewSel);
37  void Notify_Created(SubjectT* Subject, ModelElementTypeT Type, const ArrayT<unsigned int>& Indices);
38  void Notify_Deleted(SubjectT* Subject, ModelElementTypeT Type, const ArrayT<unsigned int>& Indices);
39  void Notify_MeshChanged(SubjectT* Subject, unsigned int MeshNr);
40  void Notify_SkinChanged(SubjectT* Subject, unsigned int SkinNr);
41  void Notify_GuiFixtureChanged(SubjectT* Subject, unsigned int GuiFixtureNr);
42  void Notify_AnimChanged(SubjectT* Subject, unsigned int AnimNr);
43  void Notify_ChannelChanged(SubjectT* Subject, unsigned int ChannelNr);
44  void Notify_SubjectDies(SubjectT* dyingSubject);
45 
46 
47  private:
48 
49  void InitListItems();
50 
51  void OnFocus (wxFocusEvent& FE);
52  void OnContextMenu (wxContextMenuEvent& CE);
53  void OnKeyDown (wxListEvent& LE);
54  void OnItemActivated (wxListEvent& LE); ///< A list item has been activated (ENTER or double click).
55  void OnSelectionChanged(wxListEvent& LE);
56  void OnEndLabelEdit (wxListEvent& LE);
57 
58  DECLARE_EVENT_TABLE()
59 
60  const ModelElementTypeT m_TYPE;
61  const int m_NUM_DEFAULT_ITEMS;
62  ModelDocumentT* m_ModelDoc;
63  ChildFrameT* m_MainFrame;
64  bool m_IsRecursiveSelfNotify;
65  };
66 
67 
68  class ElementsPanelT : public wxPanel
69  {
70  public:
71 
72  ElementsPanelT(ChildFrameT* MainFrame, const wxSize& Size, ModelElementTypeT Type);
73 
74 
75  private:
76 
77  /// IDs for the controls whose events we are interested in.
78  enum
79  {
80  ID_LISTVIEW=wxID_HIGHEST+1,
81  ID_BUTTON_ADD,
82  ID_BUTTON_UP,
83  ID_BUTTON_DOWN,
84  ID_BUTTON_DELETE
85  };
86 
87  void OnButton(wxCommandEvent& Event);
88  void OnButtonUpdate(wxUpdateUIEvent& UE);
89 
90  const ModelElementTypeT m_TYPE;
91  ModelDocumentT* m_ModelDoc;
92  ChildFrameT* m_MainFrame;
93  ElementsListT* m_List;
94 
95  DECLARE_EVENT_TABLE()
96  };
97 }
98 
99 #endif
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: ElementsList.cpp:109
Definition: ChildFrame.hpp:35
Definition: ElementsList.hpp:68
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: ElementsList.cpp:77
void Notify_ChannelChanged(SubjectT *Subject, unsigned int ChannelNr)
Notifies the observer that an animation channel has changed.
Definition: ElementsList.cpp:157
This class represents a child frame.
Definition: ChildFrame.hpp:55
ElementsListT(ChildFrameT *MainFrame, wxWindow *Parent, const wxSize &Size, ModelElementTypeT Type)
The constructor.
Definition: ElementsList.cpp:37
void Notify_AnimChanged(SubjectT *Subject, unsigned int AnimNr)
Notifies the observer that an animation sequence has changed.
Definition: ElementsList.cpp:148
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: ElementsList.cpp:100
void Notify_SubjectDies(SubjectT *dyingSubject)
This method is called whenever a subject is about the be destroyed (and become unavailable).
Definition: ElementsList.cpp:166
Definition: ObserverPattern.hpp:104
This file provides the classes for the Observer pattern as described in the book by the GoF...
void Notify_MeshChanged(SubjectT *Subject, unsigned int MeshNr)
Notifies the observer that a mesh has changed.
Definition: ElementsList.cpp:118
A control for displaying a list of the elements of the model.
Definition: ElementsList.hpp:22
bool AreDefaultItemsSelected() const
Returns whether one or more "default" elements are selected in the list.
Definition: ElementsList.cpp:67
void Notify_SkinChanged(SubjectT *Subject, unsigned int SkinNr)
Notifies the observer that a skin has changed.
Definition: ElementsList.cpp:127
~ElementsListT()
The destructor.
Definition: ElementsList.cpp:60
Definition: ObserverPattern.hpp:28
void Notify_GuiFixtureChanged(SubjectT *Subject, unsigned int GuiFixtureNr)
Notifies the observer that a GUI fixture has changed.
Definition: ElementsList.cpp:139
Definition: ModelDocument.hpp:30