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