1
/****************************************************************************
3
GLUI User Interface Toolkit
4
---------------------------
6
glui_panel.cpp - GLUI_Panel 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_Panel::draw() **********/
24
void GLUI_Panel::draw( int x, int y )
31
orig = set_to_glut_window();
33
if ( int_val == GLUI_PANEL_RAISED ) {
36
glColor3f( 1.0, 1.0, 1.0 );
37
glBegin( GL_LINE_LOOP );
38
glVertex2i( 0, top ); glVertex2i( w, top );
39
glVertex2i( 0, top ); glVertex2i( 0, h );
42
glColor3f( .5, .5, .5 );
43
glBegin( GL_LINE_LOOP );
50
/** ORIGINAL RAISED PANEL METHOD - A LITTLE TOO HIGH **
53
glColor3f( 1.0, 1.0, 1.0 );
54
glVertex2i( 1, 1 ); glVertex2i( w-2, 1 );
55
glVertex2i( 1, 1 ); glVertex2i( 1, h-2 );
57
glColor3f( .5, .5, .5 );
58
glVertex2i( w-1, 1 ); glVertex2i( w-1, h-1 );
59
glVertex2i( 1, h-1 ); glVertex2i( w-1, h-1 );
61
glColor3f( 0.0, 0.0, 0.0 );
62
glVertex2i( 0, h ); glVertex2i( w, h );
63
glVertex2i( w, 0 ); glVertex2i( w, h );
66
-- Touch up the lines a bit (needed in some opengl implementations
68
glColor3f( .5, .5, .5 );
69
glVertex2i( w-1, h-1 );
70
glColor3f( 0.0, 0.0, 0.0 );
75
else if ( int_val == GLUI_PANEL_EMBOSSED ) {
76
if ( name[0] == '\0' ) {
80
top = GLUI_PANEL_EMBOSS_TOP;
84
glColor3f( 1.0, 1.0, 1.0 );
85
glBegin( GL_LINE_LOOP );
86
glVertex2i( 0, top ); glVertex2i( w, top );
87
glVertex2i( w, h ); glVertex2i( 0, h );
89
glVertex2i( 1, top+1 ); glVertex2i( w-1, top+1 );
90
glVertex2i( w-1, h-1 ); glVertex2i( 1, h-1 );
93
glColor3f( .5, .5, .5 );
94
glBegin( GL_LINE_LOOP );
96
glVertex2i( w-1, top );
97
glVertex2i( w-1, h-1 );
101
/**** Only display text in embossed panel ****/
102
if ( name[0] != '\0' ) { /* Only draw non-null strings */
103
int left = 7, height=GLUI_PANEL_NAME_DROP+1;
106
str_width = string_width(name);
109
glColor3ub(glui->bkgd_color.r,glui->bkgd_color.g,glui->bkgd_color.b);
110
glDisable( GL_CULL_FACE );
112
glVertex2i( left-3, 0 ); glVertex2i( left+str_width+3, 0 );
113
glVertex2i( left+str_width+3, height ); glVertex2i( left-3, height );
116
draw_name( left, GLUI_PANEL_NAME_DROP );
122
restore_window(orig);
126
/****************************** GLUI_Panel::set_name() **********/
128
void GLUI_Panel::set_name( char *new_name )
130
strncpy(name,new_name,sizeof(GLUI_String));
139
/****************************** GLUI_Panel::set_type() **********/
141
void GLUI_Panel::set_type( int new_type )
145
if ( new_type != int_val ) {
148
/* translate_and_draw_front(); */
151
old_window = set_to_glut_window();
152
glutPostRedisplay( );
153
restore_window( old_window );
158
/************************************** GLUI_Panel::update_size() **********/
160
void GLUI_Panel::update_size( void )
167
text_size = string_width(name);
169
if ( w < text_size + 16 )
172
if ( name[0] != '\0' AND int_val == GLUI_PANEL_EMBOSSED ) {
173
this->y_off_top = GLUI_YOFF + 8;
176
this->y_off_top = GLUI_YOFF;