| 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_PARENT_FRAME_HPP_INCLUDED |
|---|
| 23 | #define CAFU_PARENT_FRAME_HPP_INCLUDED |
|---|
| 24 | |
|---|
| 25 | #include "wx/docview.h" // Needed for wxFileHistory. |
|---|
| 26 | #include "wx/mdi.h" |
|---|
| 27 | #include "Templates/Array.hpp" |
|---|
| 28 | |
|---|
| 29 | #if __linux__ |
|---|
| 30 | #define HMODULE void* |
|---|
| 31 | #endif |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | class wxGLCanvas; |
|---|
| 35 | class wxGLContext; |
|---|
| 36 | class wxFileName; |
|---|
| 37 | class ChildFrameT; |
|---|
| 38 | class GameConfigT; |
|---|
| 39 | class MapDocumentT; |
|---|
| 40 | namespace ModelEditor { class ChildFrameT; } |
|---|
| 41 | namespace GuiEditor { class ChildFrameT; } |
|---|
| 42 | namespace MatSys { class TextureMapI; } |
|---|
| 43 | |
|---|
| 44 | |
|---|
| 45 | /// This class represents the CaWE parent (main) frame. |
|---|
| 46 | class ParentFrameT : public wxMDIParentFrame |
|---|
| 47 | { |
|---|
| 48 | public: |
|---|
| 49 | |
|---|
| 50 | /// IDs for the controls whose events we are interested in. |
|---|
| 51 | /// This is a public enum so that our children (and possibly grandchildren) can have controls |
|---|
| 52 | /// that trigger these events as well, e.g. child frames that duplicate our menu items or dialogs |
|---|
| 53 | /// (any children of the child frames) that provide buttons for the same events. |
|---|
| 54 | /// The IDs that the ParentFrameT class uses start at wxID_HIGHEST+1+1000 and the IDs that the various |
|---|
| 55 | /// ChildFrameT classes (map, gui, and model editors) use start at wxID_HIGHEST+1+2000. This way, the |
|---|
| 56 | /// children of the child frames (dialogs, panes, toolbars, ...) can start their own ID enumerations |
|---|
| 57 | /// at wxID_HIGHEST+1. This keeps all IDs nicely unique when events bubble up from the dialogs, pane |
|---|
| 58 | /// and toolbars first to the child frame and finally to the parent frame. |
|---|
| 59 | /// See the "Events and Event Handling: How Events are Processed" in the wx documentation for more details. |
|---|
| 60 | enum |
|---|
| 61 | { |
|---|
| 62 | ID_MENU_FILE_NEW_MAP=wxID_HIGHEST+1+1000, |
|---|
| 63 | ID_MENU_FILE_NEW_MODEL, |
|---|
| 64 | ID_MENU_FILE_NEW_GUI, |
|---|
| 65 | ID_MENU_FILE_NEW_FONT, |
|---|
| 66 | ID_MENU_FILE_OPEN, |
|---|
| 67 | ID_MENU_FILE_OPEN_CMDLINE, |
|---|
| 68 | ID_MENU_FILE_CONFIGURE, |
|---|
| 69 | ID_MENU_FILE_EXIT, |
|---|
| 70 | |
|---|
| 71 | // Note that the entire "Windows" menu is provided and managed by wx. |
|---|
| 72 | // ID_MENU_WINDOW_NEW, |
|---|
| 73 | // ID_MENU_WINDOW_CASCADE, |
|---|
| 74 | // ID_MENU_WINDOW_TILE, |
|---|
| 75 | // ID_MENU_WINDOW_ARRANGE_ICONS, |
|---|
| 76 | // ID_MENU_WINDOW_LOG_MESSAGES, |
|---|
| 77 | |
|---|
| 78 | ID_MENU_HELP_CONTENTS, |
|---|
| 79 | ID_MENU_HELP_CAFU_WEBSITE, |
|---|
| 80 | ID_MENU_HELP_CAFU_FORUM, |
|---|
| 81 | ID_MENU_HELP_SET_FRAME_SIZE, |
|---|
| 82 | ID_MENU_HELP_D3_MTR_CONVERTER, |
|---|
| 83 | ID_MENU_HELP_ABOUT |
|---|
| 84 | }; |
|---|
| 85 | |
|---|
| 86 | |
|---|
| 87 | /// The constructor. |
|---|
| 88 | ParentFrameT(wxCmdLineParser& Parser); |
|---|
| 89 | |
|---|
| 90 | /// The destructor. |
|---|
| 91 | ~ParentFrameT(); |
|---|
| 92 | |
|---|
| 93 | ChildFrameT* GetActiveMapChildFrame() const; ///< Returns the currently active child frame or NULL if no map childframe is active (e.g. no map open or GUI editor is active). |
|---|
| 94 | MapDocumentT* GetActiveMapDoc() const; ///< Returns the document of the currently active map child frame or NULL if no map document is active. |
|---|
| 95 | |
|---|
| 96 | // These member variables are public because they must be available to other code anyway. |
|---|
| 97 | wxGLCanvas* m_GLCanvas; ///< Our persistent "home" of the shared GL context. Used whenever there is no view. |
|---|
| 98 | wxGLContext* m_GLContext; ///< The OpenGL rendering context that represents our app-global OpenGL state. |
|---|
| 99 | MatSys::TextureMapI* m_WhiteTexture; ///< A white texture map that is set as default lightmap whenever nothing else is available. |
|---|
| 100 | wxFileHistory m_FileHistory; ///< The file history of our and all our childrens "File" menu. |
|---|
| 101 | ArrayT<ChildFrameT*> m_ChildFrames; ///< The list where all map child frames register themselves on construction and unregister on destruction. |
|---|
| 102 | ArrayT<ModelEditor::ChildFrameT*> m_MdlChildFrames; ///< The list where all model child frames register themselves on construction and unregister on destruction. |
|---|
| 103 | ArrayT<GuiEditor::ChildFrameT*> m_GuiChildFrames; ///< The list where all GUI child frames register themselves on construction and unregister on destruction. |
|---|
| 104 | |
|---|
| 105 | /// The OpenGL attribute list for this window. The same list must be used for all child windows, so that they get identical pixel formats! |
|---|
| 106 | static int OpenGLAttributeList[]; |
|---|
| 107 | |
|---|
| 108 | |
|---|
| 109 | private: |
|---|
| 110 | |
|---|
| 111 | /// A helper function for opening or creating Cafu documents (maps, models or GUIs), for learning which game config should be used |
|---|
| 112 | /// (first by extrapolating the config from the document path or (if unsuccessful) by querying it from the user). |
|---|
| 113 | GameConfigT* AskUserForGameConfig(const wxFileName& DocumentPath) const; |
|---|
| 114 | |
|---|
| 115 | /// Using the specified game config, this method opens the specified file in a new child frame: |
|---|
| 116 | /// It inspects the suffix of the given filename in order to determine the proper document type (map, model or GUI), |
|---|
| 117 | /// creates the document from the file, and finally creates a new child frame for the newly loaded document. |
|---|
| 118 | /// Files that have an ambiguous filename suffix (e.g. ".map") must have a type specifier appended to their filename. |
|---|
| 119 | /// Currently supported type specifiers are " (HL1)", " (HL2)" and " (D3)". |
|---|
| 120 | /// Errors on opening the file are gracefully handled and the user is informed. |
|---|
| 121 | wxMDIChildFrame* OpenFile(GameConfigT* GameConfig, wxString FileName); |
|---|
| 122 | |
|---|
| 123 | #ifdef __WXGTK__ |
|---|
| 124 | void OnSize (wxSizeEvent& SE); |
|---|
| 125 | #endif |
|---|
| 126 | void OnShow (wxShowEvent& SE); ///< Event handler for "has been shown" events. |
|---|
| 127 | void OnClose (wxCloseEvent& CE); ///< Event handler for close events, e.g. after a system close button or command or a call to Close(). See wx Window Deletion Overview for more details. |
|---|
| 128 | void OnMenuFile(wxCommandEvent& CE); ///< Event handler for File menu events. |
|---|
| 129 | void OnMenuHelp(wxCommandEvent& CE); ///< Event handler for Help menu events. |
|---|
| 130 | |
|---|
| 131 | wxCmdLineParser& m_CmdLineParser; |
|---|
| 132 | HMODULE m_RendererDLL; |
|---|
| 133 | |
|---|
| 134 | DECLARE_EVENT_TABLE() |
|---|
| 135 | }; |
|---|
| 136 | |
|---|
| 137 | #endif |
|---|