Cafu Engine
MaterialBrowserDialog.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_MATERIAL_BROWSER_DIALOG_HPP_INCLUDED
8 #define CAFU_MATERIAL_BROWSER_DIALOG_HPP_INCLUDED
9 
10 #include "Templates/Array.hpp"
11 
12 #include "wx/dialog.h"
13 #include "wx/aui/framemanager.h"
14 
15 
16 class DocAdapterI;
17 class EditorMaterialI;
18 
19 
20 namespace MaterialBrowser
21 {
22  class ControlsBarT;
23  class FilterSettingsT;
24  class MaterialPropertiesT;
25  class MaterialTreeT;
26  class ScrolledMaterialWindowT;
27 
28 
29  /// This class implements the "named parameter idiom" for the MaterialBrowser::DialogT.
30  /// See http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.20 for details.
31  class ConfigT
32  {
33  public:
34 
35  ConfigT();
36 
37  ConfigT& InitialMaterial(EditorMaterialI* Mat) { m_InitialMaterial=Mat; return *this; }
38  ConfigT& InitialNameFilter(const wxString& s) { m_InitialNameFilter=s; return *this; }
39  ConfigT& OnlyShowUsed(bool b=true) { m_OnlyShowUsed=b; return *this; }
40  ConfigT& NoFilterEditorMatsOnly(bool b=true) { m_NoFilterEditorMatsOnly=b; return *this; }
41  ConfigT& NoButtonMark(bool b=true) { m_NoButtonMark=b; return *this; }
42  ConfigT& NoButtonReplace(bool b=true) { m_NoButtonReplace=b; return *this; }
43 
44 
45  private:
46 
47  friend class DialogT;
48  friend class ControlsBarT;
49  friend class FilterSettingsT;
50 
51  EditorMaterialI* m_InitialMaterial;
52  wxString m_InitialNameFilter;
53  bool m_OnlyShowUsed;
54  bool m_NoFilterEditorMatsOnly;
55  bool m_NoButtonMark;
56  bool m_NoButtonReplace;
57  };
58 
59 
60  class DialogT : public wxDialog
61  {
62  public:
63 
64  /// The constructor.
65  DialogT(wxWindow* Parent, const DocAdapterI& DocAccess, const ConfigT& Config);
66 
67  /// The destructor.
68  ~DialogT();
69 
70  /// Returns the currently selected material.
72 
73 
74  private:
75 
76  const DocAdapterI& m_DocAccess; ///< The (access interface to the) document that this dialog is for.
77  const ConfigT& m_Config;
78  wxAuiManager m_AUIManager;
79 
80  ScrolledMaterialWindowT* m_ScrolledMatWin;
81  ControlsBarT* m_ControlsBar;
82  MaterialTreeT* m_MaterialTree;
83  MaterialPropertiesT* m_MaterialProperties;
84  FilterSettingsT* m_FilterSettings;
85 
86  wxString MatFolderFilter;
87 
88  int DisplaySize; ///< Maintained by the OnChoice_DisplaySize handler.
89  EditorMaterialI* m_CurrentMaterial; ///< Currently selected material.
90  ArrayT<EditorMaterialI*>* m_UsedMaterialsList; ///< Maintained by the OnCheckbox_OnlyShowUsed handler.
91 
92 
93  const ArrayT<wxString>& GetNameFilterHistory();
94  void SelectMaterial(EditorMaterialI* Material);
95 
96 
97  // Helper functions.
98  void Init(const ArrayT<EditorMaterialI*>& Materials);
99  void SaveAndQuitDialog(int ReturnValue);
100 
101  // Event handlers.
102  void OnChoice_DisplaySize(wxCommandEvent& Event);
103  void OnButton_Mark(wxCommandEvent& Event);
104  void OnButton_Replace(wxCommandEvent& Event);
105  void OnButton_ExportDiffMaps(wxCommandEvent& Event);
106  void OnButton_Cancel(wxCommandEvent& Event);
107  void OnCombobox_NameFilterSelection(wxCommandEvent& Event);
108  void OnCombobox_NameFilterTextChange(wxCommandEvent& Event);
109  void OnCheckbox_OnlyShowUsed(wxCommandEvent& Event);
110  void OnCheckbox_OnlyShowEditor(wxCommandEvent& Event);
111 
112  // IDs for the controls in whose events we are interested.
113  enum
114  {
115  ID_SCROLLED_MaterialWindow=wxID_HIGHEST+1,
116  ID_CHOICE_DisplaySize,
117  ID_BUTTON_Mark,
118  ID_BUTTON_Replace,
119  ID_BUTTON_ExportDiffMaps,
120  ID_COMBO_NameFilter,
121  ID_COMBO_KeywordFilter,
122  ID_CHECKBOX_OnlyShowUsed,
123  ID_CHECKBOX_OnlyShowEditor,
124  };
125 
126  DECLARE_EVENT_TABLE()
127 
128  friend class ScrolledMaterialWindowT;
129  friend class ControlsBarT;
130  friend class FilterSettingsT;
131  friend class MaterialTreeT;
132  };
133 }
134 
135 #endif
This class implements the "named parameter idiom" for the MaterialBrowser::DialogT.
Definition: MaterialBrowserDialog.hpp:31
EditorMaterialI * GetCurrentMaterial() const
Returns the currently selected material.
Definition: MaterialBrowserDialog.cpp:150
Definition: ControlsBar.hpp:18
Definition: MaterialBrowserDialog.hpp:60
DialogT(wxWindow *Parent, const DocAdapterI &DocAccess, const ConfigT &Config)
The constructor.
Definition: MaterialBrowserDialog.cpp:127
Definition: ScrolledMaterialWin.hpp:22
Definition: EditorMaterial.hpp:21
Definition: MaterialProperties.hpp:24
This class provides a common interface to the documents of the map, GUI or model editor.
Definition: DocumentAdapter.hpp:25
Definition: FilterSettings.hpp:18
Definition: MaterialTree.hpp:23
~DialogT()
The destructor.
Definition: MaterialBrowserDialog.cpp:144