1 /***********************************************************
2 * Copyright (C) 1997, Be Inc. All rights reserved.
6 * DESCRIPTION: the GlutWindow class saves all events for
7 * handling by main thread
8 ***********************************************************/
10 /***********************************************************
12 ***********************************************************/
17 /***********************************************************
20 * INHERITS FROM: BGLView (NOT BWindow!)
22 * DESCRIPTION: all information needed for windows and
23 * subwindows (handled as similarly as possible)
24 ***********************************************************/
25 class GlutWindow
: public BGLView
{
27 GlutWindow(GlutWindow
*nparent
, char *name
, int x
, int y
, int width
,
28 int height
, ulong options
);
30 void KeyDown(const char *bytes
, int32 numBytes
);
31 void MouseDown(BPoint point
);
32 void MouseMoved(BPoint point
, uint32 transit
, const BMessage
*message
);
33 void FrameResized(float width
, float height
);
34 void Draw(BRect updateRect
);
37 void Pulse(); // needed since MouseUp() is broken
38 void MouseCheck(); // check for button state changes
39 void ErrorCallback(GLenum errorCode
);
41 static long MenuThread(void *menu
);
43 int num
; // window number returned to user
44 int cursor
; // my cursor
45 #define GLUT_MAX_MENUS 3
46 int menu
[GLUT_MAX_MENUS
]; // my popup menus
47 int m_width
, m_height
; // the last width and height reported to GLUT
48 uint32 m_buttons
; // the last mouse button state
50 /* Window relationship state. */
51 GlutWindow
*parent
; /* parent window */
52 GlutWindow
*children
; /* first child window */
53 GlutWindow
*siblings
; /* next sibling */
55 // leave out buttons and dials callbacks that we don't support
56 GLUTdisplayCB display
; /* redraw */
57 GLUTreshapeCB reshape
; /* resize (width,height) */
58 GLUTmouseCB mouse
; /* mouse (button,state,x,y) */
59 GLUTmotionCB motion
; /* motion (x,y) */
60 GLUTpassiveCB passive
; /* passive motion (x,y) */
61 GLUTentryCB entry
; /* window entry/exit (state) */
62 GLUTkeyboardCB keyboard
; /* keyboard (ASCII,x,y) */
63 GLUTvisibilityCB visibility
; /* visibility */
64 GLUTspecialCB special
; /* special key */
66 bool anyevents
; // were any events received?
67 bool displayEvent
; // call display
68 bool reshapeEvent
; // call reshape
69 bool mouseEvent
; // call mouse
70 bool motionEvent
; // call motion
71 bool passiveEvent
; // call passive
72 bool entryEvent
; // call entry
73 bool keybEvent
; // call keyboard
74 bool visEvent
; // call visibility
75 bool specialEvent
; // call special
76 bool statusEvent
; // menu status changed
77 bool menuEvent
; // menu selected
79 bool swapHack
; // faked out single buffering
81 int button
, mouseState
; // for mouse callback
82 int mouseX
, mouseY
; // for mouse callback
83 int motionX
, motionY
; // for motion callback
84 int passiveX
, passiveY
; // for passive callback
85 int entryState
; // for entry callback
86 unsigned char key
; // for keyboard callback
87 int keyX
, keyY
; // for keyboard callback
88 int visState
; // for visibility callback
89 int specialKey
; // for special key callback
90 int specialX
, specialY
; // for special callback
91 int modifierKeys
; // modifier key state
92 int menuStatus
; // for status callback
93 int statusX
, statusY
; // for status callback
94 int menuNumber
; // for menu and status callbacks
95 int menuValue
; // for menu callback
98 /***********************************************************
101 * INHERITS FROM: BWindow
103 * DESCRIPTION: basically a BWindow that won't quit
104 ***********************************************************/
105 class GlutBWindow
: public BWindow
{
107 GlutBWindow(BRect frame
, char *name
);
108 bool QuitRequested(); // exits app