1 // -*- mode: c++; c-set-style: "stroustrup"; tab-width: 4; -*-
2 //
3 // CApp.h
4 //
5 // Copyright (C) 2004 Koji Nakamaru
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 2, or (at your option)
10 // any later version.
11 //
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software Foundation,
19 // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 //
21 
22 #ifndef _CApp_h_
23 #define _CApp_h_
24 
25 class CApp {
26 protected:
27 	bool _is_dragging;
28 	bool _is_fullscreen;
29 	struct {
30 		int w, h;
31 		int x0, y0, w0, h0;
32 	} _view;
33 	struct {
34 		bool enable;
35 		unsigned long millis;
36 		struct timeval tv0;
37 	} _timer;
38 
39 	CApp();
40 	virtual ~CApp();
41 	virtual void initialize(int argc, char *argv[]);
42 	virtual void finalize();
43 	virtual void display();
44 	virtual void reshape(int width, int height);
45 	virtual void menu(int value);
46 	virtual void key(unsigned char key, int x, int y);
47 	virtual void special(int key, int x, int y);
48 	virtual void mouse(int button, int state, int x, int y);
49 	virtual void drag(int x, int y);
50 	virtual void passive(int x, int y);
51 	virtual void timer(unsigned dmillis);
52 	void startTimer(unsigned millis);
53 	void stopTimer();
54 
55 private:
56 	static void finalizeCB();
57 	static void displayCB();
58 	static void reshapeCB(int width, int height);
59 	static void menuCB(int value);
60 	static void keyCB(unsigned char key, int x, int y);
61 	static void specialCB(int key, int x, int y);
62 	static void mouseCB(int button, int state, int x, int y);
63 	static void motionCB(int x, int y);
64 	static void passiveCB(int x, int y);
65 	static void timerCB(int value);
66 
67 	friend int main(int argc, char *argv[]);
68 };
69 
70 #endif
71