1 //////////////////////////////////////////////////////////////////////////////////////// 2 // 3 // Nestopia - NES/Famicom emulator written in C++ 4 // 5 // Copyright (C) 2003-2008 Martin Freij 6 // 7 // This file is part of Nestopia. 8 // 9 // Nestopia is free software; you can redistribute it and/or modify 10 // it under the terms of the GNU General Public License as published by 11 // the Free Software Foundation; either version 2 of the License, or 12 // (at your option) any later version. 13 // 14 // Nestopia is distributed in the hope that it will be useful, 15 // but WITHOUT ANY WARRANTY; without even the implied warranty of 16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 // GNU General Public License for more details. 18 // 19 // You should have received a copy of the GNU General Public License 20 // along with Nestopia; if not, write to the Free Software 21 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 // 23 //////////////////////////////////////////////////////////////////////////////////////// 24 25 #ifndef NST_WINDOW_MAIN_H 26 #define NST_WINDOW_MAIN_H 27 28 #pragma once 29 30 #include "NstWindowDynamic.hpp" 31 #include "NstManagerVideo.hpp" 32 #include "NstManagerSound.hpp" 33 #include "NstManagerInput.hpp" 34 #include "NstManagerFrameClock.hpp" 35 36 namespace Nestopia 37 { 38 namespace Window 39 { 40 class Main : Managers::Manager 41 { 42 public: 43 44 Main 45 ( 46 Managers::Emulator&, 47 const Configuration&, 48 Menu&, 49 const Managers::Paths&, 50 const Managers::Preferences&, 51 int 52 ); 53 54 ~Main(); 55 56 int Run(); 57 void Save(Configuration&) const; 58 uint GetMaxMessageLength() const; 59 60 private: 61 62 struct MainWindow : Dynamic 63 { 64 MainWindow(const Configuration&,const Menu&); 65 66 enum 67 { 68 CLASS_STYLE = 69 ( 70 CS_HREDRAW | 71 CS_VREDRAW 72 ), 73 74 WIN_STYLE = 75 ( 76 WS_OVERLAPPED | 77 WS_CAPTION | 78 WS_SYSMENU | 79 WS_MINIMIZEBOX | 80 WS_MAXIMIZEBOX | 81 WS_THICKFRAME | 82 WS_CLIPCHILDREN 83 ), 84 85 WIN_EXSTYLE = 86 ( 87 WS_EX_ACCEPTFILES | 88 WS_EX_CLIENTEDGE 89 ) 90 }; 91 92 bool menu; 93 bool maximized; 94 Rect rect; 95 96 static const wchar_t name[]; 97 }; 98 99 inline bool Fullscreen() const; 100 inline bool Windowed() const; 101 102 bool CanRunInBackground() const; 103 bool ToggleMenu() const; 104 105 bool OnStartEmulation(); 106 void OnStopEmulation(); 107 108 void OnReturnInputScreen(Rect&); 109 void OnReturnOutputScreen(Rect&); 110 111 ibool OnSysKeyDown (Param&); 112 ibool OnCommand (Param&); 113 ibool OnEnable (Param&); 114 ibool OnEnterSizeMoveMenu (Param&); 115 ibool OnActivate (Param&); 116 ibool OnSysCommand (Param&); 117 ibool OnNclButton (Param&); 118 ibool OnNcrButton (Param&); 119 ibool OnPowerBroadCast (Param&); 120 ibool OnCommandResume (Param&); 121 122 void OnCmdViewSwitchScreen (uint); 123 void OnCmdViewShowOnTop (uint); 124 void OnCmdViewShowMenu (uint); 125 126 void OnEmuEvent(Managers::Emulator::Event,Managers::Emulator::Data); 127 void OnAppEvent(Application::Instance::Event,const void*); 128 129 const Managers::Preferences& preferences; 130 MainWindow window; 131 Managers::Video video; 132 Managers::Sound sound; 133 Managers::Input input; 134 Managers::FrameClock frameClock; 135 136 public: 137 Get()138 Custom& Get() 139 { 140 return window; 141 } 142 Get() const143 const Custom& Get() const 144 { 145 return window; 146 } 147 }; 148 } 149 } 150 151 #endif 152