X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2F3dengfx%2Fsrc%2Ffxwt%2Ffxwt.cpp;fp=src%2F3dengfx%2Fsrc%2Ffxwt%2Ffxwt.cpp;h=d75561b4e9f04f113bdc78e6a4e7c832c61b9e53;hb=6e23259dbabaeb1711a2a5ca25b9cb421f693759;hp=0000000000000000000000000000000000000000;hpb=fe068fa879814784c45e0cb2e65dac489e8f5594;p=summerhack diff --git a/src/3dengfx/src/fxwt/fxwt.cpp b/src/3dengfx/src/fxwt/fxwt.cpp new file mode 100644 index 0000000..d75561b --- /dev/null +++ b/src/3dengfx/src/fxwt/fxwt.cpp @@ -0,0 +1,102 @@ +/* +This file is part of fxwt, the window system toolkit of 3dengfx. + +Copyright (c) 2004, 2005 John Tsiombikas + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +/* main fxwt event handling and system abstraction. + * + * Author: John Tsiombikas 2004 + * Modified: + * John Tsiombikas 2005 + */ + +#include +#include +#include +#include "3dengfx/3denginefx.hpp" +#include "common/err_msg.h" +#include "fxwt.hpp" +#include "text.hpp" +#include "gfx_library.h" + +using std::list; + +namespace fxwt { + list disp_handlers; + list idle_handlers; + list keyb_handlers; + list motion_handlers; + list button_handlers; + + bool button_state[6]; + int screenx, screeny; +} + +using namespace fxwt; + +void fxwt::init() { + fxwt::text_init(); + + const GraphicsInitParameters *gip = get_graphics_init_parameters(); + screenx = gip->x; + screeny = gip->y; +} + +void fxwt::set_display_handler(void (*handler)()) { + disp_handlers.push_back(handler); +} + +void fxwt::set_idle_handler(void (*handler)()) { + idle_handlers.push_back(handler); +} + +void fxwt::set_keyboard_handler(void (*handler)(int)) { + keyb_handlers.push_back(handler); +} + +void fxwt::set_motion_handler(void (*handler)(int, int)) { + motion_handlers.push_back(handler); +} + +void fxwt::set_button_handler(void (*handler)(int, int, int, int)) { + button_handlers.push_back(handler); +} + +void fxwt::remove_display_handler(void (*handler)()) { + disp_handlers.remove(handler); +} + +void fxwt::remove_idle_handler(void (*handler)()) { + idle_handlers.remove(handler); +} + +void fxwt::remove_keyboard_handler(void (*handler)(int)) { + keyb_handlers.remove(handler); +} + +void fxwt::remove_motion_handler(void (*handler)(int, int)) { + motion_handlers.remove(handler); +} + +void fxwt::remove_button_handler(void (*handler)(int, int, int, int)) { + button_handlers.remove(handler); +} + +bool fxwt::mouse_button_pressed(int bn) { + return button_state[bn]; +}