aboutsummaryrefslogtreecommitdiff
path: root/src/glut/beos/glutWindow.h
blob: d3ac1862695887553669684bc62fbaca38fa48f8 (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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/***********************************************************
 *      Copyright (C) 1997, Be Inc.  Copyright (C) 1999, Jake Hamby.
 *
 * This program is freely distributable without licensing fees
 * and is provided without guarantee or warrantee expressed or
 * implied. This program is -not- in the public domain.
 *
 *
 *  FILE:	glutWindow.h
 *
 *	DESCRIPTION:	the GlutWindow class saves all events for
 *		handling by main thread
 ***********************************************************/

/***********************************************************
 *	Headers
 ***********************************************************/
#include <GL/glut.h>
#include <Window.h>
#include <GLView.h>

/***********************************************************
 *	CLASS:	GlutWindow
 *
 *  INHERITS FROM:  BGLView (NOT BWindow!)
 *
 *  DESCRIPTION:	all information needed for windows and
 *			subwindows (handled as similarly as possible)
 ***********************************************************/
class GlutWindow : public BGLView {
public:
	GlutWindow(GlutWindow *nparent, char *name, int x, int y, int width,
				int height, ulong options);
	
	void KeyDown(const char *bytes, int32 numBytes);
	void MouseDown(BPoint point);
	void MouseMoved(BPoint point, uint32 transit, const BMessage *message);
	void FrameResized(float width, float height);
	void Draw(BRect updateRect);
	void Pulse();		// needed since MouseUp() is broken
	void MouseCheck();	// check for button state changes
	void ErrorCallback(GLenum errorCode);

	static long MenuThread(void *menu);
	
	int num;			// window number returned to user
	int cursor;			// my cursor
#define GLUT_MAX_MENUS              3
	int menu[GLUT_MAX_MENUS];	// my popup menus
	int m_width, m_height;		// the last width and height reported to GLUT
	uint32 m_buttons;			// the last mouse button state

	/* Window relationship state. */
  GlutWindow *parent;   /* parent window */
  GlutWindow *children; /* first child window */
  GlutWindow *siblings; /* next sibling */

	// leave out buttons and dials callbacks that we don't support
  GLUTdisplayCB display;  /* redraw  */
  GLUTreshapeCB reshape;  /* resize  (width,height) */
  GLUTmouseCB mouse;    /* mouse  (button,state,x,y) */
  GLUTmotionCB motion;  /* motion  (x,y) */
  GLUTpassiveCB passive;  /* passive motion  (x,y) */
  GLUTentryCB entry;    /* window entry/exit  (state) */
  GLUTkeyboardCB keyboard;  /* keyboard  (ASCII,x,y) */
  GLUTvisibilityCB visibility;  /* visibility  */
  GLUTspecialCB special;  /* special key  */
  GLUTwindowStatusCB windowStatus;  /* window status */

	bool anyevents;		// were any events received?
	bool displayEvent;		// call display
	bool reshapeEvent;		// call reshape
	bool mouseEvent;		// call mouse
	bool motionEvent;		// call motion
	bool passiveEvent;		// call passive
	bool entryEvent;		// call entry
	bool keybEvent;			// call keyboard
	bool windowStatusEvent;		// call visibility
	bool specialEvent;		// call special
	bool statusEvent;		// menu status changed
	bool menuEvent;			// menu selected
	
	int button, mouseState; // for mouse callback
	int mouseX, mouseY; // for mouse callback
	int motionX, motionY; // for motion callback
	int passiveX, passiveY; // for passive callback
	int entryState;  // for entry callback
	unsigned char key;  // for keyboard callback
	int keyX, keyY;  // for keyboard callback
	int visState;  // for visibility callback
	int specialKey; // for special key callback
	int specialX, specialY; // for special callback
	int modifierKeys;	// modifier key state
	int menuStatus;		// for status callback
	int statusX, statusY;	// for status callback
	int menuNumber;		// for menu and status callbacks
	int menuValue;		// for menu callback
	bool visible;		// for visibility callback
};

/***********************************************************
 *	CLASS:	GlutBWindow
 *
 *  INHERITS FROM:	BDirectWindow
 *
 *	DESCRIPTION:  basically a BWindow that won't quit
 ***********************************************************/
class GlutBWindow : public BDirectWindow {
public:
	GlutBWindow(BRect frame, char *name);
	~GlutBWindow();
	void DirectConnected(direct_buffer_info *info);
	bool QuitRequested();	// exits app
	void Minimize(bool minimized);  // minimized windows are not visible
	void Hide();
	void Show();
	GlutWindow *bgl;
	bool fConnectionDisabled;
};