summaryrefslogtreecommitdiff
path: root/include/engine.h
blob: 5e74ddc2158ad8625fab6517ba8ead32e9fa0558 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
 *  mogltk
 *  Copyright (C) 1999-2004 Nicolas "Pixel" Noble
 *
 *  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
 */

/* $Id: engine.h,v 1.24 2007-07-27 14:10:19 pixel Exp $ */

#ifndef __ENGINE_H__
#define __ENGINE_H__

#include <SDL.h>
#include <Handle.h>
#include <Exceptions.h>
#include <base.h>
#include <glbase.h>

namespace mogltk {
    class Widget;
    class engine : public Base {
      public:
        class keyevent : public Base {
	  public:
              keyevent();
              virtual ~keyevent();
	    virtual void down(SDL_keysym) = 0;
	    virtual void up(SDL_keysym) = 0;
          protected:
            keyevent * old_handler, * new_handler;
	};
        class mouseevent : public Base {
          public:
              mouseevent();
              virtual ~mouseevent();
            virtual void move(SDL_MouseMotionEvent) = 0;
            virtual void action(SDL_MouseButtonEvent) = 0;
          protected:
            mouseevent * old_handler, * new_handler;
        };
        static int setup() throw(GeneralException);
        static int postsetup() throw(GeneralException);
        static int GetInited();
	static SDL_RWops * RWFromHandle(Handle *, bool = false) throw (GeneralException);
	static void pollevents() throw (GeneralException);
	static void setappactive(bool);
	static bool getappactive();
	static void setcursorvisible(bool);
	static bool getcursorvisible();
        static void quit();
	static bool quitrequested();
	static int mouseX();
	static int mouseY();
	static int mouseZ();
        static void setmouseX(int);
        static void setmouseY(int);
        static void setmouseZ(int);
	static int mousebuttons();
	static double FPS();
	static void lockmouse();
	static void unlockmouse();
	static void setkeyevent(keyevent *);
        static void setmouseevent(mouseevent *);
        static keyevent * getkeyevent();
        static mouseevent * getmouseevent();
	static glbase * glbase_o;
	static base * base_o;
	static Widget * root;
      private:
        static bool inited;
	static bool postsetuped;
	static bool appactive;
	static bool cursorvisible;
	static bool quitrequest;
	static int mx;
	static int my;
	static int mz;
	static int mbuttons;
	static int frames;
	static double curfps;
	static Uint32 curticks;
	static int locked;
	static keyevent * keyevent_h;
        static mouseevent * mouseevent_h;
	static void updatemouse();
    };
};

#include <widgets.h>

#endif