Cafu Engine
ToolbarMaterials.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_TOOLBAR_MATERIALS_HPP_INCLUDED
8 #define CAFU_TOOLBAR_MATERIALS_HPP_INCLUDED
9 
10 #include "ObserverPattern.hpp"
11 #include "Templates/Array.hpp"
12 #include "wx/wx.h"
13 
14 
15 class MapDocumentT;
16 class EditorMaterialI;
17 class EditorMatManT;
18 
19 
20 /// The Materials toolbar (actually, a dialog).
21 class MaterialsToolbarT : public wxPanel, public ObserverT
22 {
23  public:
24 
25  /// The constructor.
26  MaterialsToolbarT(wxWindow* Parent, MapDocumentT* MapDoc);
27 
28  /// The destructor.
30 
31  // Implementation of the ObserverT interface.
32  void NotifySubjectDies(SubjectT* Subject);
33 
34  /// Overridden wxDialog::Show() function, because we also want to update the toolbar on Show(true).
35  bool Show(bool show=true);
36 
37  /// Returns the current list of MRU materials (the first element is the selected material).
39 
40 
41  private:
42 
43  /// Pointer to the currently active document, or NULL when no document active.
44  MapDocumentT* m_MapDoc;
45  EditorMatManT& m_MatMan;
46 
47  /// The controls.
48  wxChoice* ChoiceCurrentMat;
49  wxStaticText* StaticTextCurrentMatSize;
50  wxStaticBitmap* m_BitmapCurrentMat;
51 
52  /// The event handlers.
53  void OnSelChangeCurrentMat(wxCommandEvent& Event);
54  void OnButtonBrowse (wxCommandEvent& Event);
55  void OnButtonApply (wxCommandEvent& Event);
56  void OnButtonReplace (wxCommandEvent& Event);
57  void OnUpdateUI (wxUpdateUIEvent& Event);
58 
59  /// IDs for the controls in whose events we are interested.
60  enum
61  {
62  ID_CHOICE_CURRENT_MAT=wxID_HIGHEST+1,
63  ID_BUTTON_BROWSE_MATS,
64  ID_BUTTON_APPLY,
65  ID_BUTTON_REPLACE_MATS
66  };
67 
68  DECLARE_EVENT_TABLE()
69 };
70 
71 #endif
This class represents a CaWE "map" document.
Definition: MapDocument.hpp:45
The Materials toolbar (actually, a dialog).
Definition: ToolbarMaterials.hpp:21
MaterialsToolbarT(wxWindow *Parent, MapDocumentT *MapDoc)
The constructor.
Definition: ToolbarMaterials.cpp:40
ArrayT< EditorMaterialI * > GetMRUMaterials() const
Returns the current list of MRU materials (the first element is the selected material).
Definition: ToolbarMaterials.cpp:171
This class manages the editor materials for a game configuration.
Definition: EditorMaterialManager.hpp:20
Definition: ObserverPattern.hpp:64
bool Show(bool show=true)
Overridden wxDialog::Show() function, because we also want to update the toolbar on Show(true)...
Definition: ToolbarMaterials.cpp:145
void NotifySubjectDies(SubjectT *Subject)
This method is called whenever a subject is about the be destroyed (and become unavailable).
Definition: ToolbarMaterials.cpp:137
Definition: EditorMaterial.hpp:21
Definition: ObserverPattern.hpp:158
~MaterialsToolbarT()
The destructor.
Definition: ToolbarMaterials.cpp:126
This file provides the classes for the Observer pattern as described in the book by the GoF...