Clean up some header files
[lsnes.git] / window.hpp
blob8f78a456a0b97e5cc313b2e0c79ad71c4b8cdf6c
1 #ifndef _window__hpp__included__
2 #define _window__hpp__included__
4 #include "SDL.h"
5 #include "render.hpp"
6 #include <string>
7 #include <map>
8 #include <list>
9 #include <stdexcept>
11 #define WINSTATE_NORMAL 0
12 #define WINSTATE_COMMAND 1
13 #define WINSTATE_MODAL 2
14 #define WINSTATE_IDENTIFY 3
16 class window_internal;
17 class window;
19 /**
20 * This is a handle to graphics system. Note that creating multiple contexts produces undefined results.
22 class window
24 public:
25 /**
26 * Create a graphics system handle, initializing the graphics system.
28 window();
30 /**
31 * Destroy a graphics system handle, shutting down the graphics system.
33 ~window();
35 /**
36 * Adds a messages to mesage queue to be shown.
38 * parameter msg: The messages to add (split by '\n').
39 * throws std::bad_alloc: Not enough memory.
41 void message(const std::string& msg) throw(std::bad_alloc);
43 /**
44 * Get output stream printing into message queue.
46 * Note that lines printed there should be terminated by '\n'.
48 * returns: The output stream.
49 * throws std::bad_alloc: Not enough memory.
51 std::ostream& out() throw(std::bad_alloc);
53 /**
54 * Displays a modal message, not returning until the message is acknowledged. Keybindings are not available, but
55 * should quit be generated somehow, modal message will be closed and command callback triggered.
57 * parameter msg: The message to show.
58 * parameter confirm: If true, ask for Ok/cancel type input.
59 * returns: If confirm is true, true if ok was chosen, false if cancel was chosen. Otherwise always false.
60 * throws std::bad_alloc: Not enough memory.
62 bool modal_message(const std::string& msg, bool confirm = false) throw(std::bad_alloc);
64 /**
65 * Displays fatal error message, quitting after the user acks it.
67 void fatal_error() throw();
69 /**
70 * Bind a key.
72 * parameter mod: Set of modifiers.
73 * parameter modmask: Modifier mask (set of modifiers).
74 * parameter keyname: Name of key or pseudo-key.
75 * parameter command: Command to run.
76 * throws std::bad_alloc: Not enough memory.
77 * throws std::runtime_error: Invalid key or modifier name, or conflict.
79 void bind(std::string mod, std::string modmask, std::string keyname, std::string command)
80 throw(std::bad_alloc, std::runtime_error);
82 /**
83 * Unbind a key.
85 * parameter mod: Set of modifiers.
86 * parameter modmask: Modifier mask (set of modifiers).
87 * parameter keyname: Name of key or pseudo-key.
88 * throws std::bad_alloc: Not enough memory.
89 * throws std::runtime_error: Invalid key or modifier name, or not bound.
91 void unbind(std::string mod, std::string modmask, std::string keyname) throw(std::bad_alloc,
92 std::runtime_error);
94 /**
95 * Dump bindings into this window.
97 * throws std::bad_alloc: Not enough memory.
99 void dumpbindings() throw(std::bad_alloc);
102 * Processes inputs. If in non-modal mode (normal mode without pause), this returns quickly. Otherwise it waits
103 * for modal mode to exit.
105 * throws std::bad_alloc: Not enough memory.
107 void poll_inputs() throw(std::bad_alloc);
110 * Get emulator status area
112 * returns: Emulator status area.
114 std::map<std::string, std::string>& get_emustatus() throw();
117 * Notify that the screen has been updated.
119 * parameter full: Do full refresh if true.
121 void notify_screen_update(bool full = false) throw();
124 * Set the screen to use as main surface.
126 * parameter scr: The screen to use.
128 void set_main_surface(screen& scr) throw();
131 * Enable/Disable pause mode.
133 * parameter enable: Enable pause if true, disable otherwise.
135 void paused(bool enable) throw();
138 * Wait specified number of milliseconds (polling for input).
140 * parameter msec: Number of ms to wait.
141 * throws std::bad_alloc: Not enough memory.
143 void wait_msec(uint64_t msec) throw(std::bad_alloc);
146 * Cancel pending wait_msec, making it return now.
148 void cancel_wait() throw();
151 * Enable or disable sound.
153 * parameter enable: Enable sounds if true, otherwise disable sounds.
155 void sound_enable(bool enable) throw();
158 * Input audio sample (at 32040.5Hz).
160 * parameter left: Left sample.
161 * parameter right: Right sample.
163 void play_audio_sample(uint16_t left, uint16_t right) throw();
167 * Set window main screen compensation parameters. This is used for mouse click reporting.
169 * parameter xoffset: X coordinate of origin.
170 * parameter yoffset: Y coordinate of origin.
171 * parameter hscl: Horizontal scaling factor.
172 * parameter vscl: Vertical scaling factor.
174 void set_window_compensation(uint32_t xoffset, uint32_t yoffset, uint32_t hscl, uint32_t vscl);
175 private:
176 window_internal* i;
177 window(const window&);
178 window& operator==(const window&);
182 * Get number of msec since some undetermined epoch.
184 * returns: The number of milliseconds.
186 uint64_t get_ticks_msec() throw();
188 #endif