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