1/***********************************************************
2 *      Copyright (C) 1997, Be Inc.  Copyright (C) 1999, Jake Hamby.
3 *
4 * This program is freely distributable without licensing fees
5 * and is provided without guarantee or warrantee expressed or
6 * implied. This program is -not- in the public domain.
7 *
8 *
9 *  FILE:	glutWindow.h
10 *
11 *	DESCRIPTION:	the GlutWindow class saves all events for
12 *		handling by main thread
13 ***********************************************************/
14
15/***********************************************************
16 *	Headers
17 ***********************************************************/
18#include <GL/glut.h>
19#include <Window.h>
20#include <GLView.h>
21
22/***********************************************************
23 *	CLASS:	GlutWindow
24 *
25 *  INHERITS FROM:  BGLView (NOT BWindow!)
26 *
27 *  DESCRIPTION:	all information needed for windows and
28 *			subwindows (handled as similarly as possible)
29 ***********************************************************/
30class GlutWindow : public BGLView {
31public:
32	GlutWindow(GlutWindow *nparent, char *name, int x, int y, int width,
33				int height, ulong options);
34
35	void KeyDown(const char *bytes, int32 numBytes);
36	void MouseDown(BPoint point);
37	void MouseMoved(BPoint point, uint32 transit, const BMessage *message);
38	void FrameResized(float width, float height);
39	void Draw(BRect updateRect);
40	void Pulse();		// needed since MouseUp() is broken
41	void MouseCheck();	// check for button state changes
42	void ErrorCallback(GLenum errorCode);
43
44	static long MenuThread(void *menu);
45
46	int num;			// window number returned to user
47	int cursor;			// my cursor
48#define GLUT_MAX_MENUS              3
49	int menu[GLUT_MAX_MENUS];	// my popup menus
50	int m_width, m_height;		// the last width and height reported to GLUT
51	uint32 m_buttons;			// the last mouse button state
52
53	/* Window relationship state. */
54  GlutWindow *parent;   /* parent window */
55  GlutWindow *children; /* first child window */
56  GlutWindow *siblings; /* next sibling */
57
58	// leave out buttons and dials callbacks that we don't support
59  GLUTdisplayCB display;  /* redraw  */
60  GLUTreshapeCB reshape;  /* resize  (width,height) */
61  GLUTmouseCB mouse;    /* mouse  (button,state,x,y) */
62  GLUTmotionCB motion;  /* motion  (x,y) */
63  GLUTpassiveCB passive;  /* passive motion  (x,y) */
64  GLUTentryCB entry;    /* window entry/exit  (state) */
65  GLUTkeyboardCB keyboard;  /* keyboard  (ASCII,x,y) */
66  GLUTvisibilityCB visibility;  /* visibility  */
67  GLUTspecialCB special;  /* special key  */
68  GLUTwindowStatusCB windowStatus;  /* window status */
69
70	bool anyevents;		// were any events received?
71	bool displayEvent;		// call display
72	bool reshapeEvent;		// call reshape
73	bool mouseEvent;		// call mouse
74	bool motionEvent;		// call motion
75	bool passiveEvent;		// call passive
76	bool entryEvent;		// call entry
77	bool keybEvent;			// call keyboard
78	bool windowStatusEvent;		// call visibility
79	bool specialEvent;		// call special
80	bool statusEvent;		// menu status changed
81	bool menuEvent;			// menu selected
82
83	int button, mouseState; // for mouse callback
84	int mouseX, mouseY; // for mouse callback
85	int motionX, motionY; // for motion callback
86	int passiveX, passiveY; // for passive callback
87	int entryState;  // for entry callback
88	unsigned char key;  // for keyboard callback
89	int keyX, keyY;  // for keyboard callback
90	int visState;  // for visibility callback
91	int specialKey; // for special key callback
92	int specialX, specialY; // for special callback
93	int modifierKeys;	// modifier key state
94	int menuStatus;		// for status callback
95	int statusX, statusY;	// for status callback
96	int menuNumber;		// for menu and status callbacks
97	int menuValue;		// for menu callback
98	bool visible;		// for visibility callback
99};
100
101/***********************************************************
102 *	CLASS:	GlutBWindow
103 *
104 *  INHERITS FROM:	BDirectWindow
105 *
106 *	DESCRIPTION:  basically a BWindow that won't quit
107 ***********************************************************/
108class GlutBWindow : public BDirectWindow {
109public:
110	GlutBWindow(BRect frame, char *name);
111	~GlutBWindow();
112	void DirectConnected(direct_buffer_info *info);
113	bool QuitRequested();	// exits app
114	void Minimize(bool minimized);  // minimized windows are not visible
115	void Hide();
116	void Show();
117	GlutWindow *bgl;
118	bool fConnectionDisabled;
119};
120