1 /****************************************************************************
3 GLUI User Interface Toolkit
4 ---------------------------
6 glui_panel.cpp - GLUI_Panel control class
9 --------------------------------------------------
11 Copyright (c) 1998 Paul Rademacher
13 WWW: http://sourceforge.net/projects/glui/
14 Forums: http://sourceforge.net/forum/?group_id=92496
16 This library is free software; you can redistribute it and/or
17 modify it under the terms of the GNU Lesser General Public
18 License as published by the Free Software Foundation; either
19 version 2.1 of the License, or (at your option) any later version.
21 This library is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 Lesser General Public License for more details.
26 You should have received a copy of the GNU Lesser General Public
27 License along with this library; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 *****************************************************************************/
32 #include "glui_internal_control.h"
34 GLUI_Panel::GLUI_Panel( GLUI_Node *parent, const char *name, int type )
41 parent->add_control( this );
44 /****************************** GLUI_Panel::draw() **********/
46 void GLUI_Panel::draw( int x, int y )
49 GLUI_DRAWINGSENTINAL_IDIOM
51 if ( int_val == GLUI_PANEL_RAISED ) {
54 glColor3f( 1.0, 1.0, 1.0 );
55 glBegin( GL_LINE_LOOP );
56 glVertex2i( 0, top ); glVertex2i( w, top );
57 glVertex2i( 0, top ); glVertex2i( 0, h );
60 glColor3f( .5, .5, .5 );
61 glBegin( GL_LINE_LOOP );
68 /** ORIGINAL RAISED PANEL METHOD - A LITTLE TOO HIGH **
71 glColor3f( 1.0, 1.0, 1.0 );
72 glVertex2i( 1, 1 ); glVertex2i( w-2, 1 );
73 glVertex2i( 1, 1 ); glVertex2i( 1, h-2 );
75 glColor3f( .5, .5, .5 );
76 glVertex2i( w-1, 1 ); glVertex2i( w-1, h-1 );
77 glVertex2i( 1, h-1 ); glVertex2i( w-1, h-1 );
79 glColor3f( 0.0, 0.0, 0.0 );
80 glVertex2i( 0, h ); glVertex2i( w, h );
81 glVertex2i( w, 0 ); glVertex2i( w, h );
84 -- Touch up the lines a bit (needed in some opengl implementations
86 glColor3f( .5, .5, .5 );
87 glVertex2i( w-1, h-1 );
88 glColor3f( 0.0, 0.0, 0.0 );
93 else if ( int_val == GLUI_PANEL_EMBOSSED ) {
94 if ( parent_node == NULL || name == "" ) {
98 top = GLUI_PANEL_EMBOSS_TOP;
102 glColor3f( 1.0, 1.0, 1.0 );
103 glBegin( GL_LINE_LOOP );
104 glVertex2i( 0, top ); glVertex2i( w, top );
105 glVertex2i( w, h ); glVertex2i( 0, h );
107 glVertex2i( 1, top+1 ); glVertex2i( w-1, top+1 );
108 glVertex2i( w-1, h-1 ); glVertex2i( 1, h-1 );
111 glColor3f( .5, .5, .5 );
112 glBegin( GL_LINE_LOOP );
113 glVertex2i( 0, top );
114 glVertex2i( w-1, top );
115 glVertex2i( w-1, h-1 );
116 glVertex2i( 0, h-1 );
119 /**** Only display text in embossed panel ****/
120 if ( parent_node != NULL && name != "" ) { /* Only draw non-null strings */
121 int left = 7, height=GLUI_PANEL_NAME_DROP+1;
124 str_width = string_width(name);
127 glColor3ub(glui->bkgd_color.r,glui->bkgd_color.g,glui->bkgd_color.b);
128 glDisable( GL_CULL_FACE );
130 glVertex2i( left-3, 0 ); glVertex2i( left+str_width+3, 0 );
131 glVertex2i( left+str_width+3, height ); glVertex2i( left-3, height );
134 draw_name( left, GLUI_PANEL_NAME_DROP );
141 /****************************** GLUI_Panel::set_name() **********/
143 void GLUI_Panel::set_name( const char *new_name )
145 name = new_name ? new_name : "";
154 /****************************** GLUI_Panel::set_type() **********/
156 void GLUI_Panel::set_type( int new_type )
158 if ( new_type != int_val ) {
166 /************************************** GLUI_Panel::update_size() **********/
168 void GLUI_Panel::update_size( void )
175 text_size = string_width(name);
177 if ( w < text_size + 16 )
180 if ( name != "" AND int_val == GLUI_PANEL_EMBOSSED ) {
181 this->y_off_top = GLUI_YOFF + 8;
184 this->y_off_top = GLUI_YOFF;