| 1 | /* |
|---|
| 2 | ================================================================================= |
|---|
| 3 | This file is part of Cafu, the open-source game engine and graphics engine |
|---|
| 4 | for multiplayer, cross-platform, real-time 3D action. |
|---|
| 5 | Copyright (C) 2002-2012 Carsten Fuchs Software. |
|---|
| 6 | |
|---|
| 7 | Cafu is free software: you can redistribute it and/or modify it under the terms |
|---|
| 8 | of the GNU General Public License as published by the Free Software Foundation, |
|---|
| 9 | either version 3 of the License, or (at your option) any later version. |
|---|
| 10 | |
|---|
| 11 | Cafu is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
|---|
| 12 | without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|---|
| 13 | PURPOSE. See the GNU General Public License for more details. |
|---|
| 14 | |
|---|
| 15 | You should have received a copy of the GNU General Public License |
|---|
| 16 | along with Cafu. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 17 | |
|---|
| 18 | For support and more information about Cafu, visit us at <http://www.cafu.de>. |
|---|
| 19 | ================================================================================= |
|---|
| 20 | */ |
|---|
| 21 | |
|---|
| 22 | #ifndef CAFU_DIALOG_INSP_ENTITY_PROPS_HPP_INCLUDED |
|---|
| 23 | #define CAFU_DIALOG_INSP_ENTITY_PROPS_HPP_INCLUDED |
|---|
| 24 | |
|---|
| 25 | #include "ObserverPattern.hpp" |
|---|
| 26 | #include "wx/panel.h" |
|---|
| 27 | |
|---|
| 28 | #include <map> |
|---|
| 29 | |
|---|
| 30 | |
|---|
| 31 | class wxPropertyGridManager; |
|---|
| 32 | class wxPropertyGridEvent; |
|---|
| 33 | class wxPropertyCategory; |
|---|
| 34 | class wxPGProperty; |
|---|
| 35 | class wxStaticText; |
|---|
| 36 | class MapDocumentT; |
|---|
| 37 | class MapEntityBaseT; |
|---|
| 38 | struct PropInfoT; |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | /// This class displays the properties of all currently selected entities. |
|---|
| 42 | /// It is implemented as an observer of the map document, and therefore acts just like the 2D and 3D views as another "view" of the "model". |
|---|
| 43 | /// As the user can also change the values of the properties (and thus modify the document), this class also acts as a "controller". |
|---|
| 44 | /// While the presentation of the properties of exactly one entity is straightforward, presenting the properties of multiple entities |
|---|
| 45 | /// all at the same time in a manner that is clear both for the user as well as in the implementation is not. |
|---|
| 46 | /// This has been solved by cleverly "overlaying" properties that occur in multiple entities. |
|---|
| 47 | /// (See the notes in the implementation for more details.) |
|---|
| 48 | class InspDlgEntityPropsT : public wxPanel, public ObserverT |
|---|
| 49 | { |
|---|
| 50 | public: |
|---|
| 51 | |
|---|
| 52 | InspDlgEntityPropsT(wxWindow* Parent_, MapDocumentT* MapDoc_); |
|---|
| 53 | ~InspDlgEntityPropsT(); |
|---|
| 54 | |
|---|
| 55 | // Implementation of the ObserverT interface. |
|---|
| 56 | void NotifySubjectChanged_Selection(SubjectT* Subject, const ArrayT<MapElementT*>& OldSelection, const ArrayT<MapElementT*>& NewSelection); |
|---|
| 57 | void NotifySubjectChanged_Deleted(SubjectT* Subject, const ArrayT<MapElementT*>& MapElements); |
|---|
| 58 | void NotifySubjectChanged_Modified(SubjectT* Subject, const ArrayT<MapElementT*>& MapElements, MapElemModDetailE Detail, const wxString& Key); |
|---|
| 59 | void NotifySubjectChanged_Modified(SubjectT* Subject, const ArrayT<MapElementT*>& MapElements, MapElemModDetailE Detail); |
|---|
| 60 | void NotifySubjectDies(SubjectT* dyingSubject); |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | private: |
|---|
| 64 | |
|---|
| 65 | wxSizer* InspectorEntityPropsInit(wxWindow* parent, bool call_fit=true, bool set_sizer=true); |
|---|
| 66 | |
|---|
| 67 | // Helper. |
|---|
| 68 | void UpdatePropertyGrid(); |
|---|
| 69 | |
|---|
| 70 | // Event handler methods. |
|---|
| 71 | void OnPropertyGridChanged(wxPropertyGridEvent& event); |
|---|
| 72 | void OnPropertyGridItemRightClick(wxPropertyGridEvent& event); |
|---|
| 73 | void OnContextMenuItemAdd(wxCommandEvent& event); |
|---|
| 74 | void OnContextMenuItemDelete(wxCommandEvent& event); |
|---|
| 75 | |
|---|
| 76 | MapDocumentT* MapDoc; |
|---|
| 77 | wxPropertyGridManager* PropMan; |
|---|
| 78 | wxPropertyCategory* ClassKeys; ///< PropertyGrid category for keys of an entity class. |
|---|
| 79 | wxPropertyCategory* MixedKeys; ///< PropertyGrid category for keys that belong to more than one entity class. |
|---|
| 80 | wxPropertyCategory* UnDefKeys; ///< PropertyGrid category for keys that are not defined by any entity class. |
|---|
| 81 | wxMenu* PopUpMenu; ///< Context menu used to add or delete properties. |
|---|
| 82 | wxStaticText* SelectionText; ///< Text that is displayed above the property grid. It shows the number of selected entities. |
|---|
| 83 | |
|---|
| 84 | std::map<wxString, PropInfoT> CombinedPropInfos; ///< The property infos of all selected entities combined. |
|---|
| 85 | wxPGProperty* LastRightClickedProperty; ///< The last property on which the user made a right click. Needed to process context menu events to the right property. |
|---|
| 86 | ArrayT<MapEntityBaseT*> SelectedEntities; ///< All currently selected entities in the map. |
|---|
| 87 | |
|---|
| 88 | bool IsRecursiveSelfNotify; |
|---|
| 89 | |
|---|
| 90 | |
|---|
| 91 | // IDs for the controls whose events we are interested in. |
|---|
| 92 | enum |
|---|
| 93 | { |
|---|
| 94 | ID_PROPERTY_GRID_MAN=wxID_HIGHEST+1, |
|---|
| 95 | ID_MENU_CONTEXT_ADD, |
|---|
| 96 | ID_MENU_CONTEXT_DELETE |
|---|
| 97 | }; |
|---|
| 98 | |
|---|
| 99 | DECLARE_EVENT_TABLE() |
|---|
| 100 | }; |
|---|
| 101 | |
|---|
| 102 | #endif |
|---|