root/cafu/trunk/CaWE/ChildFrame.hpp

Revision 457, 12.0 KB (checked in by Carsten, 4 months ago)

Using UltraEdit's multi-line search-and-replace-in-files feature, replaced


^#ifndef _(CAFU|CF|CFS|CA)_(.*)_$
^#define _\1_\2_$

with

#ifndef CAFU_\2_INCLUDED
#define CAFU_\2_INCLUDED

and


^#ifndef _(.*)_HPP_$
^#define _\1_HPP_$

with

#ifndef CAFU_\1_HPP_INCLUDED
#define CAFU_\1_HPP_INCLUDED

Closes #91.

Line 
1/*
2=================================================================================
3This file is part of Cafu, the open-source game engine and graphics engine
4for multiplayer, cross-platform, real-time 3D action.
5Copyright (C) 2002-2012 Carsten Fuchs Software.
6
7Cafu is free software: you can redistribute it and/or modify it under the terms
8of the GNU General Public License as published by the Free Software Foundation,
9either version 3 of the License, or (at your option) any later version.
10
11Cafu is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13PURPOSE. See the GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with Cafu. If not, see <http://www.gnu.org/licenses/>.
17
18For support and more information about Cafu, visit us at <http://www.cafu.de>.
19=================================================================================
20*/
21
22#ifndef CAFU_CHILDFRAME_HPP_INCLUDED
23#define CAFU_CHILDFRAME_HPP_INCLUDED
24
25#include "Math3D/Vector3.hpp"
26#include "Templates/Array.hpp"
27
28#include "wx/mdi.h"
29#include "wx/timer.h"
30#include "wx/aui/framemanager.h"
31
32
33class ConsoleDialogT;
34class EditSurfacePropsDialogT;
35class InspectorDialogT;
36class TerrainEditorDialogT;
37class GroupsToolbarT;
38class MapDocumentT;
39class MaterialsToolbarT;
40class ParentFrameT;
41class ToolManagerT;
42class ViewWindowT;
43class wxProcessEvent;
44
45
46class AutoSaveTimerT : public wxTimer
47{
48    public:
49
50    AutoSaveTimerT(MapDocumentT* Doc, unsigned long ChildFrameNr);
51    ~AutoSaveTimerT();
52
53    void Notify();
54
55
56    private:
57
58    MapDocumentT* m_Doc;
59    wxString      m_AutoSaveName;
60};
61
62
63/// This class represents a child frame.
64class ChildFrameT : public wxMDIChildFrame
65{
66    public:
67
68    /// IDs for the controls whose events we are interested in.
69    /// Some of the IDs below are commented out. This is usually because there already exists a wx-defined
70    /// ID for the same purpose, which works well with the wx model-view-controler framework.
71    /// See the ParentFrameT class header and documentation for additional information.
72    enum
73    {
74        ID_MENU_FILE_CLOSE=wxID_HIGHEST+1+2000,
75        ID_MENU_FILE_SAVE,
76        ID_MENU_FILE_SAVEAS,
77
78     // ID_MENU_EDIT_UNDO,
79     // ID_MENU_EDIT_REDO,
80     // ID_MENU_EDIT_CUT,
81     // ID_MENU_EDIT_COPY,
82     // ID_MENU_EDIT_PASTE,
83        ID_MENU_EDIT_PASTE_SPECIAL,
84        ID_MENU_EDIT_DELETE,
85        ID_MENU_EDIT_SELECT_NONE,
86     // ID_MENU_EDIT_SELECT_ALL,
87        ID_MENU_EDIT_ENTITY_INSPECTOR,
88
89        ID_MENU_SELECTION_APPLY_MATERIAL,       // TODO: Review...
90
91        ID_MENU_MAP_SNAP_TO_GRID,
92        ID_MENU_MAP_SHOW_GRID_2D,
93        ID_MENU_MAP_GRID_SETTINGS,
94        ID_MENU_MAP_FINER_GRID,
95        ID_MENU_MAP_COARSER_GRID,
96        ID_MENU_MAP_GOTO_PRIMITIVE,
97        ID_MENU_MAP_SHOW_INFO,
98        ID_MENU_MAP_CHECK_FOR_PROBLEMS,
99        ID_MENU_MAP_PROPERTIES,
100        ID_MENU_MAP_LOAD_POINTFILE,
101        ID_MENU_MAP_UNLOAD_POINTFILE,
102
103        ID_MENU_VIEW_TOOLBARS,
104        ID_MENU_VIEW_TOOLBARS_FILE,
105        ID_MENU_VIEW_TOOLBARS_TOOLS,
106        ID_MENU_VIEW_PANELS,
107        ID_MENU_VIEW_PANELS_TOOLOPTIONS,
108        ID_MENU_VIEW_PANELS_MATERIALS,
109        ID_MENU_VIEW_PANELS_GROUPS,
110        ID_MENU_VIEW_PANELS_INSPECTOR,
111        ID_MENU_VIEW_PANELS_CONSOLE,
112        ID_MENU_VIEW_NEW_2D_VIEW,
113        ID_MENU_VIEW_NEW_3D_VIEW,
114        ID_MENU_VIEW_LOAD_DEFAULT_PERSPECTIVE,
115        ID_MENU_VIEW_LOAD_USER_PERSPECTIVE,
116        ID_MENU_VIEW_SAVE_USER_PERSPECTIVE,
117        ID_MENU_VIEW_CENTER_2D_VIEWS,
118        ID_MENU_VIEW_CENTER_3D_VIEWS,
119        ID_MENU_VIEW_SHOW_ENTITY_INFO,
120        ID_MENU_VIEW_SHOW_ENTITY_TARGETS,
121        ID_MENU_VIEW_HIDE_SELECTED_OBJECTS,
122        ID_MENU_VIEW_HIDE_UNSELECTED_OBJECTS,   // TODO: Review...
123        ID_MENU_VIEW_SHOW_HIDDEN_OBJECTS,
124
125        ID_MENU_TOOLS_TOOL_SELECTION,
126        ID_MENU_TOOLS_TOOL_CAMERA,
127        ID_MENU_TOOLS_TOOL_NEWBRUSH,
128        ID_MENU_TOOLS_TOOL_NEWENTITY,
129        ID_MENU_TOOLS_TOOL_NEWBEZIERPATCH,
130        ID_MENU_TOOLS_TOOL_NEWTERRAIN,
131        ID_MENU_TOOLS_TOOL_NEWLIGHT,
132        ID_MENU_TOOLS_TOOL_NEWDECAL,
133        ID_MENU_TOOLS_TOOL_EDITSURFACEPROPERTIES,
134        ID_MENU_TOOLS_TOOL_TERRAINEDITOR,
135        ID_MENU_TOOLS_TOOL_CLIP,
136        ID_MENU_TOOLS_TOOL_EDITVERTICES,
137        ID_MENU_TOOLS_CARVE,
138        ID_MENU_TOOLS_MAKE_HOLLOW,
139        ID_MENU_TOOLS_IGNORE_GROUPS,
140        ID_MENU_TOOLS_GROUP,
141        ID_MENU_TOOLS_ASSIGN_PRIM_TO_ENTITY,
142        ID_MENU_TOOLS_ASSIGN_PRIM_TO_WORLD,
143        ID_MENU_TOOLS_REPLACE_MATERIALS,
144        ID_MENU_TOOLS_MATERIAL_LOCK,
145        ID_MENU_TOOLS_SNAP_SELECTION_TO_GRID,
146        ID_MENU_TOOLS_TRANSFORM,
147        ID_MENU_TOOLS_ALIGN,
148        ID_MENU_TOOLS_ALIGN_LEFT,
149        ID_MENU_TOOLS_ALIGN_RIGHT,
150        ID_MENU_TOOLS_ALIGN_HOR_CENTER,
151        ID_MENU_TOOLS_ALIGN_TOP,
152        ID_MENU_TOOLS_ALIGN_BOTTOM,
153        ID_MENU_TOOLS_ALIGN_VERT_CENTER,
154        ID_MENU_TOOLS_MIRROR,
155        ID_MENU_TOOLS_MIRROR_HOR,
156        ID_MENU_TOOLS_MIRROR_VERT,
157
158        ID_MENU_COMPILE_FLAG_SAVE_MAP,
159        ID_MENU_COMPILE_FLAG_RUN_BSP,
160        ID_MENU_COMPILE_FLAG_RUN_PVS,
161        ID_MENU_COMPILE_FLAG_RUN_LIGHT,
162        ID_MENU_COMPILE_FLAG_RUN_ENGINE,
163        ID_MENU_COMPILE_QUICK,
164        ID_MENU_COMPILE_NORMAL,
165        ID_MENU_COMPILE_QUALITY,
166        ID_MENU_COMPILE_CUSTOM,
167        ID_MENU_COMPILE_ABORT
168    };
169
170    /// Constants for use with SetStatusText, to give the individual panes a name.
171    enum StatusBarPaneIDs
172    {
173        SBP_MENU_HELP=0,
174        SBP_SELECTION,
175        SBP_MOUSE_POS,
176        SBP_SELECTION_DIMS,
177        SBP_GRID_ZOOM,
178        SBP_GRID_SNAP
179    };
180
181
182    /// The constructor.
183    /// @param Parent     The parent frame.
184    /// @param Title      The title of the new child frame (i.e. the name of the document).
185    /// @param Document   This frames document. The frame becomes the owner of the document, i.e. it is responsible for destructing it.
186    ///                   (Document is created externally so that this constructor doesn't fail on doc creation failure.)
187    ChildFrameT(ParentFrameT* Parent, const wxString& Title, MapDocumentT* Document);
188
189    /// The destructor.
190    /// Notifies the dependent ViewWindowTs that we're being destroyed before them.
191    /// See documentation of ViewWindowT::NotifyChildFrameDies() for full details.
192    ~ChildFrameT();
193
194    /// Returns this child frames document.
195    MapDocumentT* GetDoc() const { return m_Doc; }
196
197    /// Returns the list of all (2D and 3D) view windows that are currently open in this frame.
198    /// The returned list is always sorted in MRU (most-recently-used) order.
199    const ArrayT<ViewWindowT*>& GetViewWindows() const { return m_ViewWindows; }
200
201    /// Based on the most recently used views (2D or 3D), this method figures out a point in space that the user can see well.
202    Vector3fT GuessUserVisiblePoint() const;
203
204    void All2DViews_Zoom(float ZoomFactor);
205    void All2DViews_Center(const Vector3fT& CenterPoint);
206
207    // These two methods are needed because we cannot show or hide wxAUI panes from "outside" otherwise.
208    bool IsPaneShown(wxWindow* Pane);                         ///< Tells if the given pane (one of our toolbars or dialogs that is managed by wxAUI) is currently shown.
209    void ShowPane(wxWindow* Pane, bool DoShow=true);          ///< Shows or hides the given pane (one of our toolbars or dialogs that is managed by wxAUI).
210    void SetCaption(wxWindow* Pane, const wxString& Caption); ///< Sets the caption of the AUI pane for the given window.
211
212    ToolManagerT&            GetToolManager()         { return *m_ToolManager;        }  ///< Returns our tool manager.
213    MaterialsToolbarT*       GetMaterialsToolbar()    { return m_MaterialsToolbar;    }  ///< Returns the Materials toolbar.
214    GroupsToolbarT*          GetGroupsToolbar()       { return m_GroupsToolbar;       }  ///< Returns the Groups toolbar.
215    EditSurfacePropsDialogT* GetSurfacePropsDialog()  { return m_SurfacePropsDialog;  }  ///< Returns the Surface Properties dialog.
216    TerrainEditorDialogT*    GetTerrainEditorDialog() { return m_TerrainEditorDialog; }  ///< Returns the Terrain Editor dialog.
217    InspectorDialogT*        GetInspectorDialog()     { return m_InspectorDialog;     }  ///< Returns the Entity Inspector dialog.
218
219
220    private:
221
222    class UpdaterT;             ///< An observer of the map document and the tools that updates this child frame (its status bar, tool options bar, etc.).
223    friend class ViewWindowT;   ///< Friend class so that our ViewWindowT children can manage/maintain the m_ViewWindows list themselves.
224
225    ParentFrameT*            m_Parent;
226    wxAuiManager             m_AUIManager;
227    wxString                 m_AUIDefaultPerspective;
228    MapDocumentT*            m_Doc;
229    unsigned long            m_LastSavedAtCommandNr;    ///< The ID of the command after which the document was last saved. If the current command ID from the history differs from this, the document contains unsaved changes.
230    AutoSaveTimerT           m_AutoSaveTimer;
231    ToolManagerT*            m_ToolManager;
232    MaterialsToolbarT*       m_MaterialsToolbar;
233    GroupsToolbarT*          m_GroupsToolbar;
234    ConsoleDialogT*          m_ConsoleDialog;
235    EditSurfacePropsDialogT* m_SurfacePropsDialog;
236    TerrainEditorDialogT*    m_TerrainEditorDialog;
237    InspectorDialogT*        m_InspectorDialog;
238    UpdaterT*                m_Updater;
239    wxMenu*                  FileMenu;
240    wxMenu*                  CompileMenu;
241
242    wxProcess*               CurrentProcess;            ///< The currently running process started from the Compile menu. NULL when there is no process running.
243    int                      CurrentProcessID;          ///< The PID of the currently running process, or 0 if no process is running.
244    ArrayT<wxString>         PendingCompileCommands;    ///< Pending console commands for map compilation.
245    ArrayT<ViewWindowT*>     m_ViewWindows;             ///< The list of all (2D and 3D) view windows that are currently open in this frame. Managed/maintained by the ViewWindowTs themselves.
246
247
248    /// Helper method that resets compile process and pending commands and prints a message into the console.
249    /// Used to prevent code duplication.
250    void EndCompiling(const wxString& ConsoleMessage, const wxColour* Colour=wxGREEN);
251
252    /// Shows or hides the given AUI pane.
253    void PaneToggleShow(wxAuiPaneInfo& PaneInfo);
254
255    // Event handlers.
256    void OnClose          (wxCloseEvent&      CE);  ///< Event handler for close events, e.g. after a system close button or command or a call to Close() (also see ParentFrameT::OnClose()). See wx Window Deletion Overview for more details.
257    void OnIdle           (wxIdleEvent&       IE);  ///< Idle event handler, for updating the console when an external compile process runs, update all 3D views and caching textures.
258    void OnProcessEnd     (wxProcessEvent&    PE);
259    void OnMenuFile       (wxCommandEvent&    CE);  ///< Event handler for File    menu events.
260    void OnMenuFileUpdate (wxUpdateUIEvent&   UE);  ///< Event handler for File    menu update events.
261    void OnMenuEdit       (wxCommandEvent&    CE);  ///< Event handler for Edit    menu events.
262    void OnMenuEditUpdate (wxUpdateUIEvent&   UE);  ///< Event handler for Edit    menu update events.
263    void OnMenuView       (wxCommandEvent&    CE);  ///< Event handler for View    menu events.
264    void OnMenuViewUpdate (wxUpdateUIEvent&   UE);  ///< Event handler for View    menu update events.
265    void OnMenuTools      (wxCommandEvent&    CE);  ///< Event handler for Tools   menu events.
266    void OnMenuToolsUpdate(wxUpdateUIEvent&   UE);  ///< Event handler for Tools   menu update events.
267    void OnMenuCompile    (wxCommandEvent&    CE);  ///< Event handler for Compile menu events.
268    void OnWindowActivate (wxActivateEvent&   AE);
269    void OnAuiPaneClose   (wxAuiManagerEvent& AE);
270
271    DECLARE_EVENT_TABLE()
272};
273
274#endif
Note: See TracBrowser for help on using the browser.