1
/****************************************************************************
3
GLUI User Interface Toolkit
4
---------------------------
6
glui_mouse_iaction - GLUI Mouse Interaction control class
9
--------------------------------------------------
11
Copyright (c) 1998 Paul Rademacher
13
This program is freely distributable without licensing fees and is
14
provided without guarantee or warrantee expressed or implied. This
15
program is -not- in the public domain.
17
*****************************************************************************/
22
/********************** GLUI_Mouse_Interaction::mouse_down_handler() ******/
24
int GLUI_Mouse_Interaction::mouse_down_handler( int local_x, int local_y )
26
int win_h = glutGet( GLUT_WINDOW_HEIGHT );
28
/* iaction_mouse_down_handler( local_x, local_y ); */
29
iaction_mouse_down_handler( local_x-x_abs, local_y-y_abs );
30
/*local_x-x_abs, ((glui->h-local_y)-y_abs) ); */
36
/**************************** GLUI_Mouse_Interaction::mouse_up_handler() */
38
int GLUI_Mouse_Interaction::mouse_up_handler( int local_x, int local_y, int inside )
40
iaction_mouse_up_handler( local_x-x_abs, local_y-y_abs, inside );
45
/****************************** GLUI_Mouse_Interaction::mouse_held_down_handler() ******/
47
int GLUI_Mouse_Interaction::mouse_held_down_handler( int local_x, int local_y,
50
iaction_mouse_held_down_handler( local_x-x_abs, local_y-y_abs , inside );
54
/** Tell the main graphics window to update iteself **/
56
glui->post_update_main_gfx();
65
/****************************** GLUI_Mouse_Interaction::draw() **********/
67
void GLUI_Mouse_Interaction::draw( int x, int y )
70
int text_width = string_width( this->name );
71
int x_left = this->w/2 - text_width/2;
76
if ( NOT draw_active_area_only ) {
77
orig = set_to_glut_window();
78
draw_name( x_left, h-4 );
81
draw_active_box( x_left-4, x_left+string_width( name.string )+4,
89
/************************************ GLUI_Mouse_Interaction::update_size() **********/
91
void GLUI_Mouse_Interaction::update_size( void )
96
int text_width = string_width( this->name );
98
if ( w < text_width+6 )
108
/****************************** GLUI_Mouse_Interaction::special_handler() **********/
110
int GLUI_Mouse_Interaction::special_handler( int key,int modifiers )
112
int center_x, center_y;
121
if ( key == GLUT_KEY_LEFT )
123
else if ( key == GLUT_KEY_RIGHT )
125
else if ( key == GLUT_KEY_UP )
127
else if ( key == GLUT_KEY_DOWN )
130
if ( drag_x != 0 OR drag_y != 0 ) {
131
mouse_down_handler( center_x, center_y );
132
mouse_held_down_handler( center_x + drag_x, center_y + drag_y,true );
133
mouse_up_handler( center_x + drag_x, center_y + drag_y, true );
140
/****************************** GLUI_Mouse_Interaction::draw_active_area() **********/
142
void GLUI_Mouse_Interaction::draw_active_area( void )
145
int win_h = glutGet( GLUT_WINDOW_HEIGHT ), win_w = glutGet(GLUT_WINDOW_WIDTH);
150
/*putchar( 'X' ); flushout; */
152
orig = set_to_glut_window();
154
int text_height = 18; /* what a kludge */
156
int viewport_size = h-text_height; /*MIN(w,h); */
158
glMatrixMode( GL_MODELVIEW );
161
glTranslatef( (float) win_w/2.0, (float) win_h/2.0, 0.0 );
162
glRotatef( 180.0, 0.0, 1.0, 0.0 );
163
glRotatef( 180.0, 0.0, 0.0, 1.0 );
164
glTranslatef( (float) -win_w/2.0, (float) -win_h/2.0, 0.0 );
166
glTranslatef( (float) this->x_abs + .5, (float) this->y_abs + .5, 0.0 );
168
glTranslatef( (float)this->w/2.0, (float)viewport_size/2.0 + 2.0 , 0.0 );
170
/*** Draw the interaction control's orthographic elements ***/
171
iaction_draw_active_area_ortho();
173
/*** Setup and draw the interaction control's perspective elements ***/
175
/*** Set the viewport to just the square of the drawing area ***/
176
/* glViewport( this->x_abs , glui->main_panel->h - this->y_abs - this->h,*/
177
/*glViewport( this->x_abs+1+(this->w/2-viewport_size/2),
178
this->h-this->y_abs-viewport_size-1,
179
viewport_size, viewport_size );*/
183
if ( ((this->w-viewport_size) % 2) == 1 )
186
glViewport( this->x_abs + (this->w-viewport_size)/2 + offset,
187
win_h - this->y_abs - this->h + text_height,
188
viewport_size, viewport_size );
190
glMatrixMode( GL_PROJECTION );
192
glFrustum( -1.0*.08, 1.0*.08, -.08, .08, .1, 8.0 );
193
glMatrixMode( GL_MODELVIEW );
196
glTranslatef( 0.0, 0.0, -3.2f );
198
/* glutSolidTeapot( 1.0 ); */
199
iaction_draw_active_area_persp();
201
glMatrixMode( GL_MODELVIEW );
204
glui->set_viewport();
205
glui->set_ortho_projection();
207
glMatrixMode( GL_MODELVIEW );
210
restore_window(orig);