2011-09-13 17:50:18 +03:00
|
|
|
#ifndef _window__hpp__included__
|
|
|
|
#define _window__hpp__included__
|
|
|
|
|
|
|
|
#include "SDL.h"
|
|
|
|
#include "render.hpp"
|
|
|
|
#include <string>
|
|
|
|
#include <map>
|
|
|
|
#include <list>
|
|
|
|
#include <stdexcept>
|
|
|
|
|
|
|
|
#define WINSTATE_NORMAL 0
|
|
|
|
#define WINSTATE_COMMAND 1
|
|
|
|
#define WINSTATE_MODAL 2
|
|
|
|
#define WINSTATE_IDENTIFY 3
|
|
|
|
|
|
|
|
class window_internal;
|
|
|
|
class window;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is a handle to graphics system. Note that creating multiple contexts produces undefined results.
|
|
|
|
*/
|
|
|
|
class window
|
|
|
|
{
|
|
|
|
public:
|
2011-09-15 15:12:26 +03:00
|
|
|
/**
|
|
|
|
* Create a graphics system handle, initializing the graphics system.
|
|
|
|
*/
|
2011-09-13 17:50:18 +03:00
|
|
|
window();
|
2011-09-15 15:12:26 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Destroy a graphics system handle, shutting down the graphics system.
|
|
|
|
*/
|
2011-09-13 17:50:18 +03:00
|
|
|
~window();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a messages to mesage queue to be shown.
|
2011-09-15 22:56:33 +03:00
|
|
|
*
|
2011-09-15 15:12:26 +03:00
|
|
|
* parameter msg: The messages to add (split by '\n').
|
|
|
|
* throws std::bad_alloc: Not enough memory.
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
void message(const std::string& msg) throw(std::bad_alloc);
|
|
|
|
|
|
|
|
/**
|
2011-09-15 15:12:26 +03:00
|
|
|
* Get output stream printing into message queue.
|
2011-09-15 22:56:33 +03:00
|
|
|
*
|
2011-09-15 15:12:26 +03:00
|
|
|
* Note that lines printed there should be terminated by '\n'.
|
2011-09-15 22:56:33 +03:00
|
|
|
*
|
2011-09-15 15:12:26 +03:00
|
|
|
* returns: The output stream.
|
|
|
|
* throws std::bad_alloc: Not enough memory.
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
std::ostream& out() throw(std::bad_alloc);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Displays a modal message, not returning until the message is acknowledged. Keybindings are not available, but
|
|
|
|
* should quit be generated somehow, modal message will be closed and command callback triggered.
|
2011-09-15 22:56:33 +03:00
|
|
|
*
|
2011-09-15 15:12:26 +03:00
|
|
|
* parameter msg: The message to show.
|
|
|
|
* parameter confirm: If true, ask for Ok/cancel type input.
|
|
|
|
* returns: If confirm is true, true if ok was chosen, false if cancel was chosen. Otherwise always false.
|
|
|
|
* throws std::bad_alloc: Not enough memory.
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
bool modal_message(const std::string& msg, bool confirm = false) throw(std::bad_alloc);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Displays fatal error message, quitting after the user acks it.
|
|
|
|
*/
|
|
|
|
void fatal_error() throw();
|
|
|
|
|
|
|
|
/**
|
2011-09-15 15:12:26 +03:00
|
|
|
* Bind a key.
|
2011-09-15 22:56:33 +03:00
|
|
|
*
|
2011-09-15 15:12:26 +03:00
|
|
|
* parameter mod: Set of modifiers.
|
|
|
|
* parameter modmask: Modifier mask (set of modifiers).
|
|
|
|
* parameter keyname: Name of key or pseudo-key.
|
|
|
|
* parameter command: Command to run.
|
|
|
|
* throws std::bad_alloc: Not enough memory.
|
|
|
|
* throws std::runtime_error: Invalid key or modifier name, or conflict.
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
void bind(std::string mod, std::string modmask, std::string keyname, std::string command)
|
|
|
|
throw(std::bad_alloc, std::runtime_error);
|
|
|
|
|
|
|
|
/**
|
2011-09-15 15:12:26 +03:00
|
|
|
* Unbind a key.
|
2011-09-15 22:56:33 +03:00
|
|
|
*
|
2011-09-15 15:12:26 +03:00
|
|
|
* parameter mod: Set of modifiers.
|
|
|
|
* parameter modmask: Modifier mask (set of modifiers).
|
|
|
|
* parameter keyname: Name of key or pseudo-key.
|
|
|
|
* throws std::bad_alloc: Not enough memory.
|
|
|
|
* throws std::runtime_error: Invalid key or modifier name, or not bound.
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
void unbind(std::string mod, std::string modmask, std::string keyname) throw(std::bad_alloc,
|
|
|
|
std::runtime_error);
|
|
|
|
|
|
|
|
/**
|
2011-09-15 15:12:26 +03:00
|
|
|
* Dump bindings into this window.
|
2011-09-15 22:56:33 +03:00
|
|
|
*
|
2011-09-15 15:12:26 +03:00
|
|
|
* throws std::bad_alloc: Not enough memory.
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
void dumpbindings() throw(std::bad_alloc);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Processes inputs. If in non-modal mode (normal mode without pause), this returns quickly. Otherwise it waits
|
|
|
|
* for modal mode to exit.
|
2011-09-15 22:56:33 +03:00
|
|
|
*
|
2011-09-15 15:12:26 +03:00
|
|
|
* throws std::bad_alloc: Not enough memory.
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
void poll_inputs() throw(std::bad_alloc);
|
|
|
|
|
|
|
|
/**
|
2011-09-15 15:12:26 +03:00
|
|
|
* Get emulator status area
|
2011-09-15 22:56:33 +03:00
|
|
|
*
|
2011-09-15 15:12:26 +03:00
|
|
|
* returns: Emulator status area.
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
std::map<std::string, std::string>& get_emustatus() throw();
|
|
|
|
|
|
|
|
/**
|
2011-09-15 15:12:26 +03:00
|
|
|
* Notify that the screen has been updated.
|
2011-09-15 22:56:33 +03:00
|
|
|
*
|
2011-09-15 15:12:26 +03:00
|
|
|
* parameter full: Do full refresh if true.
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
void notify_screen_update(bool full = false) throw();
|
|
|
|
|
|
|
|
/**
|
2011-09-15 15:12:26 +03:00
|
|
|
* Set the screen to use as main surface.
|
2011-09-15 22:56:33 +03:00
|
|
|
*
|
2011-09-15 15:12:26 +03:00
|
|
|
* parameter scr: The screen to use.
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
void set_main_surface(screen& scr) throw();
|
|
|
|
|
|
|
|
/**
|
2011-09-15 15:12:26 +03:00
|
|
|
* Enable/Disable pause mode.
|
2011-09-15 22:56:33 +03:00
|
|
|
*
|
2011-09-15 15:12:26 +03:00
|
|
|
* parameter enable: Enable pause if true, disable otherwise.
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
void paused(bool enable) throw();
|
|
|
|
|
|
|
|
/**
|
2011-09-15 15:12:26 +03:00
|
|
|
* Wait specified number of milliseconds (polling for input).
|
2011-09-15 22:56:33 +03:00
|
|
|
*
|
2011-09-15 15:12:26 +03:00
|
|
|
* parameter msec: Number of ms to wait.
|
|
|
|
* throws std::bad_alloc: Not enough memory.
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
void wait_msec(uint64_t msec) throw(std::bad_alloc);
|
|
|
|
|
|
|
|
/**
|
2011-09-15 15:12:26 +03:00
|
|
|
* Cancel pending wait_msec, making it return now.
|
|
|
|
*/
|
|
|
|
void cancel_wait() throw();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enable or disable sound.
|
2011-09-15 22:56:33 +03:00
|
|
|
*
|
2011-09-15 15:12:26 +03:00
|
|
|
* parameter enable: Enable sounds if true, otherwise disable sounds.
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
void sound_enable(bool enable) throw();
|
|
|
|
|
|
|
|
/**
|
2011-09-15 15:12:26 +03:00
|
|
|
* Input audio sample (at 32040.5Hz).
|
2011-09-15 22:56:33 +03:00
|
|
|
*
|
2011-09-15 15:12:26 +03:00
|
|
|
* parameter left: Left sample.
|
|
|
|
* parameter right: Right sample.
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
void play_audio_sample(uint16_t left, uint16_t right) throw();
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2011-09-15 15:12:26 +03:00
|
|
|
* Set window main screen compensation parameters. This is used for mouse click reporting.
|
2011-09-15 22:56:33 +03:00
|
|
|
*
|
2011-09-15 15:12:26 +03:00
|
|
|
* parameter xoffset: X coordinate of origin.
|
|
|
|
* parameter yoffset: Y coordinate of origin.
|
|
|
|
* parameter hscl: Horizontal scaling factor.
|
2011-09-15 22:56:33 +03:00
|
|
|
* parameter vscl: Vertical scaling factor.
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
void set_window_compensation(uint32_t xoffset, uint32_t yoffset, uint32_t hscl, uint32_t vscl);
|
|
|
|
private:
|
|
|
|
window_internal* i;
|
|
|
|
window(const window&);
|
|
|
|
window& operator==(const window&);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2011-09-15 15:12:26 +03:00
|
|
|
* Get number of msec since some undetermined epoch.
|
2011-09-15 22:56:33 +03:00
|
|
|
*
|
2011-09-15 15:12:26 +03:00
|
|
|
* returns: The number of milliseconds.
|
2011-09-13 17:50:18 +03:00
|
|
|
*/
|
|
|
|
uint64_t get_ticks_msec() throw();
|
|
|
|
|
|
|
|
#endif
|