diff src/gtk/window.h @ 1:f9f4f1b99eed

importing src directory
author Robert McIntyre <rlm@mit.edu>
date Sat, 03 Mar 2012 10:31:27 -0600
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/gtk/window.h	Sat Mar 03 10:31:27 2012 -0600
     1.3 @@ -0,0 +1,322 @@
     1.4 +// -*- C++ -*-
     1.5 +// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
     1.6 +// Copyright (C) 1999-2003 Forgotten
     1.7 +// Copyright (C) 2004 Forgotten and the VBA development team
     1.8 +
     1.9 +// This program is free software; you can redistribute it and/or modify
    1.10 +// it under the terms of the GNU General Public License as published by
    1.11 +// the Free Software Foundation; either version 2, or(at your option)
    1.12 +// any later version.
    1.13 +//
    1.14 +// This program is distributed in the hope that it will be useful,
    1.15 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.16 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.17 +// GNU General Public License for more details.
    1.18 +//
    1.19 +// You should have received a copy of the GNU General Public License
    1.20 +// along with this program; if not, write to the Free Software Foundation,
    1.21 +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    1.22 +
    1.23 +#ifndef __VBA_WINDOW_H__
    1.24 +#define __VBA_WINDOW_H__
    1.25 +
    1.26 +#include <sys/types.h>
    1.27 +#include <stdarg.h>
    1.28 +
    1.29 +#include <libglademm.h>
    1.30 +#include <gtkmm.h>
    1.31 +
    1.32 +#ifndef GTKMM20
    1.33 +# include "sigccompat.h"
    1.34 +#endif // ! GTKMM20
    1.35 +
    1.36 +#include <string>
    1.37 +#include <vector>
    1.38 +#include <list>
    1.39 +
    1.40 +#include "../common/System.h"
    1.41 +
    1.42 +#include "configfile.h"
    1.43 +#include "screenarea.h"
    1.44 +#include "filters.h"
    1.45 +#include "input.h"
    1.46 +#include "joypadconfig.h"
    1.47 +
    1.48 +namespace VBA
    1.49 +{
    1.50 +
    1.51 +class Window : public Gtk::Window
    1.52 +{
    1.53 +  friend class Gnome::Glade::Xml;
    1.54 +
    1.55 +public:
    1.56 +  virtual ~Window();
    1.57 +
    1.58 +  inline static Window * poGetInstance() { return m_poInstance; }
    1.59 +
    1.60 +  enum ECartridge
    1.61 +  {
    1.62 +    CartridgeNone,
    1.63 +    CartridgeGB,
    1.64 +    CartridgeGBA
    1.65 +  };
    1.66 +
    1.67 +  // GB/GBA screen sizes
    1.68 +  const int m_iGBScreenWidth;
    1.69 +  const int m_iGBScreenHeight;
    1.70 +  const int m_iSGBScreenWidth;
    1.71 +  const int m_iSGBScreenHeight;
    1.72 +  const int m_iGBAScreenWidth;
    1.73 +  const int m_iGBAScreenHeight;
    1.74 +
    1.75 +  bool bLoadROM(const std::string & _rsFile);
    1.76 +  void vPopupError(const char * _csFormat, ...);
    1.77 +  void vPopupErrorV(const char * _csFormat, va_list _args);
    1.78 +  void vDrawScreen();
    1.79 +  void vComputeFrameskip(int _iRate);
    1.80 +  void vShowSpeed(int _iSpeed);
    1.81 +  void vCaptureScreen(int _iNum);
    1.82 +  u32  uiReadJoypad();
    1.83 +
    1.84 +  inline ECartridge eGetCartridge() const { return m_eCartridge; }
    1.85 +  inline int        iGetThrottle()  const { return m_iThrottle; }
    1.86 +
    1.87 +protected:
    1.88 +  Window(GtkWindow * _pstWindow,
    1.89 +         const Glib::RefPtr<Gnome::Glade::Xml> & _poXml);
    1.90 +
    1.91 +  enum EShowSpeed
    1.92 +  {
    1.93 +    ShowNone,
    1.94 +    ShowPercentage,
    1.95 +    ShowDetailed
    1.96 +  };
    1.97 +
    1.98 +  enum ESaveType
    1.99 +  {
   1.100 +    SaveAuto,
   1.101 +    SaveEEPROM,
   1.102 +    SaveSRAM,
   1.103 +    SaveFlash,
   1.104 +    SaveEEPROMSensor,
   1.105 +    SaveNone
   1.106 +  };
   1.107 +
   1.108 +  enum ESoundStatus
   1.109 +  {
   1.110 +    SoundOff,
   1.111 +    SoundMute,
   1.112 +    SoundOn
   1.113 +  };
   1.114 +
   1.115 +  enum ESoundQuality
   1.116 +  {
   1.117 +    Sound44K = 1,
   1.118 +    Sound22K = 2,
   1.119 +    Sound11K = 4
   1.120 +  };
   1.121 +
   1.122 +  enum ESoundVolume
   1.123 +  {
   1.124 +    Sound100,
   1.125 +    Sound200,
   1.126 +    Sound300,
   1.127 +    Sound400,
   1.128 +    Sound25,
   1.129 +    Sound50
   1.130 +  };
   1.131 +
   1.132 +  enum EEmulatorType
   1.133 +  {
   1.134 +    EmulatorAuto,
   1.135 +    EmulatorCGB,
   1.136 +    EmulatorSGB,
   1.137 +    EmulatorGB,
   1.138 +    EmulatorGBA,
   1.139 +    EmulatorSGB2
   1.140 +  };
   1.141 +
   1.142 +  virtual void vOnFileOpen();
   1.143 +  virtual void vOnFileLoad();
   1.144 +  virtual void vOnFileSave();
   1.145 +  virtual void vOnLoadGameMostRecent();
   1.146 +  virtual void vOnLoadGameAutoToggled(Gtk::CheckMenuItem * _poCMI);
   1.147 +  virtual void vOnLoadGame(int _iSlot);
   1.148 +  virtual void vOnSaveGameOldest();
   1.149 +  virtual void vOnSaveGame(int _iSlot);
   1.150 +  virtual void vOnFilePauseToggled(Gtk::CheckMenuItem * _poCMI);
   1.151 +  virtual void vOnFileReset();
   1.152 +  virtual void vOnRecentReset();
   1.153 +  virtual void vOnRecentFreezeToggled(Gtk::CheckMenuItem * _poCMI);
   1.154 +  virtual void vOnRecentFile(std::string _sFile);
   1.155 +  virtual void vOnImportBatteryFile();
   1.156 +  virtual void vOnExportBatteryFile();
   1.157 +  virtual void vOnFileScreenCapture();
   1.158 +  virtual void vOnFileClose();
   1.159 +  virtual void vOnFileExit();
   1.160 +  virtual void vOnFrameskipToggled(Gtk::CheckMenuItem * _poCMI, int _iValue);
   1.161 +  virtual void vOnThrottleToggled(Gtk::CheckMenuItem * _poCMI, int _iPercent);
   1.162 +  virtual void vOnThrottleOther(Gtk::CheckMenuItem * _poCMI);
   1.163 +  virtual void vOnVideoScaleToggled(Gtk::CheckMenuItem * _poCMI, int _iScale);
   1.164 +  virtual void vOnLayerToggled(Gtk::CheckMenuItem * _poCMI, int _iLayer);
   1.165 +  virtual void vOnDirectories();
   1.166 +  virtual void vOnDirectoryReset(Gtk::Entry * _poEntry);
   1.167 +  virtual void vOnDirectorySelect(Gtk::Entry * _poEntry);
   1.168 +  virtual void vOnPauseWhenInactiveToggled(Gtk::CheckMenuItem * _poCMI);
   1.169 +  virtual void vOnSelectBios();
   1.170 +  virtual void vOnUseBiosToggled(Gtk::CheckMenuItem * _poCMI);
   1.171 +  virtual void vOnShowSpeedToggled(Gtk::CheckMenuItem * _poCMI, int _iShowSpeed);
   1.172 +  virtual void vOnSaveTypeToggled(Gtk::CheckMenuItem * _poCMI, int _iSaveType);
   1.173 +  virtual void vOnFlashSizeToggled(Gtk::CheckMenuItem * _poCMI, int _iFlashSize);
   1.174 +  virtual void vOnScreenshotFormatToggled(Gtk::CheckMenuItem * _poCMI, std::string _sFormat);
   1.175 +  virtual void vOnSoundStatusToggled(Gtk::CheckMenuItem * _poCMI, int _iSoundStatus);
   1.176 +  virtual void vOnSoundEchoToggled(Gtk::CheckMenuItem * _poCMI);
   1.177 +  virtual void vOnSoundLowPassToggled(Gtk::CheckMenuItem * _poCMI);
   1.178 +  virtual void vOnSoundReverseToggled(Gtk::CheckMenuItem * _poCMI);
   1.179 +  virtual void vOnSoundChannelToggled(Gtk::CheckMenuItem * _poCMI, int _iSoundChannel);
   1.180 +  virtual void vOnSoundQualityToggled(Gtk::CheckMenuItem * _poCMI, int _iSoundQuality);
   1.181 +  virtual void vOnSoundVolumeToggled(Gtk::CheckMenuItem * _poCMI, int _iSoundVolume);
   1.182 +  virtual void vOnGBBorderToggled(Gtk::CheckMenuItem * _poCMI);
   1.183 +  virtual void vOnGBPrinterToggled(Gtk::CheckMenuItem * _poCMI);
   1.184 +  virtual void vOnEmulatorTypeToggled(Gtk::CheckMenuItem * _poCMI, int _iEmulatorType);
   1.185 +  virtual void vOnFilter2xToggled(Gtk::CheckMenuItem * _poCMI, int _iFilter2x);
   1.186 +  virtual void vOnFilterIBToggled(Gtk::CheckMenuItem * _poCMI, int _iFilterIB);
   1.187 +#ifdef MMX
   1.188 +  virtual void vOnDisableMMXToggled(Gtk::CheckMenuItem * _poCMI);
   1.189 +#endif // MMX
   1.190 +  virtual void vOnJoypadConfigure(int _iJoypad);
   1.191 +  virtual void vOnJoypadToggled(Gtk::CheckMenuItem * _poCMI, int _iJoypad);
   1.192 +  virtual void vOnAutofireToggled(Gtk::CheckMenuItem * _poCMI, u32 _uiKeyFlag);
   1.193 +  virtual void vOnGDBWait();
   1.194 +  virtual void vOnGDBLoadAndWait();
   1.195 +  virtual void vOnGDBBreak();
   1.196 +  virtual void vOnGDBDisconnect();
   1.197 +  virtual void vOnHelpAbout();
   1.198 +  virtual bool bOnEmuIdle();
   1.199 +
   1.200 +  virtual bool on_focus_in_event(GdkEventFocus * _pstEvent);
   1.201 +  virtual bool on_focus_out_event(GdkEventFocus * _pstEvent);
   1.202 +  virtual bool on_key_press_event(GdkEventKey * _pstEvent);
   1.203 +  virtual bool on_key_release_event(GdkEventKey * _pstEvent);
   1.204 +
   1.205 +private:
   1.206 +  // Config limits
   1.207 +  const int m_iFrameskipMin;
   1.208 +  const int m_iFrameskipMax;
   1.209 +  const int m_iThrottleMin;
   1.210 +  const int m_iThrottleMax;
   1.211 +  const int m_iScaleMin;
   1.212 +  const int m_iScaleMax;
   1.213 +  const int m_iShowSpeedMin;
   1.214 +  const int m_iShowSpeedMax;
   1.215 +  const int m_iSaveTypeMin;
   1.216 +  const int m_iSaveTypeMax;
   1.217 +  const int m_iSoundQualityMin;
   1.218 +  const int m_iSoundQualityMax;
   1.219 +  const int m_iSoundVolumeMin;
   1.220 +  const int m_iSoundVolumeMax;
   1.221 +  const int m_iEmulatorTypeMin;
   1.222 +  const int m_iEmulatorTypeMax;
   1.223 +  const int m_iFilter2xMin;
   1.224 +  const int m_iFilter2xMax;
   1.225 +  const int m_iFilterIBMin;
   1.226 +  const int m_iFilterIBMax;
   1.227 +  const int m_iJoypadMin;
   1.228 +  const int m_iJoypadMax;
   1.229 +
   1.230 +  static Window * m_poInstance;
   1.231 +
   1.232 +  Glib::RefPtr<Gnome::Glade::Xml> m_poXml;
   1.233 +
   1.234 +  std::string       m_sUserDataDir;
   1.235 +  std::string       m_sConfigFile;
   1.236 +  Config::File      m_oConfig;
   1.237 +  Config::Section * m_poHistoryConfig;
   1.238 +  Config::Section * m_poDirConfig;
   1.239 +  Config::Section * m_poCoreConfig;
   1.240 +  Config::Section * m_poDisplayConfig;
   1.241 +  Config::Section * m_poSoundConfig;
   1.242 +  Config::Section * m_poInputConfig;
   1.243 +
   1.244 +#ifdef GTKMM20
   1.245 +  Gtk::FileSelection * m_poFileOpenDialog;
   1.246 +#else // ! GTKMM20
   1.247 +  Gtk::FileChooserDialog * m_poFileOpenDialog;
   1.248 +#endif // ! GTKMM20
   1.249 +  ScreenArea *         m_poScreenArea;
   1.250 +  Gtk::Menu *          m_poRecentMenu;
   1.251 +  Gtk::MenuItem *      m_poRecentResetItem;
   1.252 +  Gtk::CheckMenuItem * m_poFilePauseItem;
   1.253 +  Gtk::CheckMenuItem * m_poUseBiosItem;
   1.254 +  Gtk::CheckMenuItem * m_poSoundOffItem;
   1.255 +
   1.256 +  struct SGameSlot
   1.257 +  {
   1.258 +    bool        m_bEmpty;
   1.259 +    std::string m_sFile;
   1.260 +    time_t      m_uiTime;
   1.261 +  };
   1.262 +
   1.263 +  Gtk::MenuItem * m_apoLoadGameItem[10];
   1.264 +  Gtk::MenuItem * m_apoSaveGameItem[10];
   1.265 +  SGameSlot       m_astGameSlot[10];
   1.266 +
   1.267 +  std::list<std::string> m_listHistory;
   1.268 +
   1.269 +  std::list<Gtk::Widget *> m_listSensitiveWhenPlaying;
   1.270 +
   1.271 +  Gtk::Tooltips m_oTooltips;
   1.272 +
   1.273 +  SigC::connection m_oEmuSig;
   1.274 +
   1.275 +  std::vector<JoypadConfig> m_oJoypads;
   1.276 +  Keymap * m_poKeymap;
   1.277 +
   1.278 +  int m_iScreenWidth;
   1.279 +  int m_iScreenHeight;
   1.280 +
   1.281 +  std::string    m_sRomFile;
   1.282 +  ECartridge     m_eCartridge;
   1.283 +  EmulatedSystem m_stEmulator;
   1.284 +  u32            m_uiJoypadState;
   1.285 +  u32            m_uiAutofireState;
   1.286 +  bool           m_bAutofireToggle;
   1.287 +  bool           m_bPaused;
   1.288 +  bool           m_bWasEmulating;
   1.289 +  bool           m_bAutoFrameskip;
   1.290 +  int            m_iThrottle;
   1.291 +  u32            m_uiThrottleLastTime;
   1.292 +  u32            m_uiThrottleDelay;
   1.293 +  EShowSpeed     m_eShowSpeed;
   1.294 +  ESoundQuality  m_eSoundQuality;
   1.295 +
   1.296 +  void vInitSystem();
   1.297 +  void vInitSDL();
   1.298 +  void vInitConfig();
   1.299 +  void vCheckConfig();
   1.300 +  void vLoadConfig(const std::string & _rsFile);
   1.301 +  void vSaveConfig(const std::string & _rsFile);
   1.302 +  void vLoadHistoryFromConfig();
   1.303 +  void vSaveHistoryToConfig();
   1.304 +  void vHistoryAdd(const std::string & _rsFile);
   1.305 +  void vClearHistoryMenu();
   1.306 +  void vUpdateHistoryMenu();
   1.307 +  void vLoadJoypadsFromConfig();
   1.308 +  void vSaveJoypadsToConfig();
   1.309 +  void vUpdateScreen();
   1.310 +  void vDrawDefaultScreen();
   1.311 +  void vSetDefaultTitle();
   1.312 +  void vCreateFileOpenDialog();
   1.313 +  void vLoadBattery();
   1.314 +  void vSaveBattery();
   1.315 +  void vStartEmu();
   1.316 +  void vStopEmu();
   1.317 +  void vSetThrottle(int _iPercent);
   1.318 +  void vSelectBestThrottleItem();
   1.319 +  void vUpdateGameSlots();
   1.320 +};
   1.321 +
   1.322 +} // namespace VBA
   1.323 +
   1.324 +
   1.325 +#endif // __VBA_WINDOW_H__