~ubuntu-branches/ubuntu/edgy/glui/edgy

« back to all changes in this revision

Viewing changes to glui_statictext.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Marcelo E. Magallon
  • Date: 2001-09-23 12:57:28 UTC
  • Revision ID: james.westby@ubuntu.com-20010923125728-qbts7xit2eg1ogo2
Tags: upstream-2.1.0.beta
ImportĀ upstreamĀ versionĀ 2.1.0.beta

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
  
 
3
  GLUI User Interface Toolkit
 
4
  ---------------------------
 
5
 
 
6
     glui_statictext.cpp - GLUI_StaticText Control
 
7
 
 
8
 
 
9
          --------------------------------------------------
 
10
 
 
11
  Copyright (c) 1998 Paul Rademacher
 
12
 
 
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.
 
16
 
 
17
*****************************************************************************/
 
18
 
 
19
#include "glui.h"
 
20
#include "stdinc.h"
 
21
 
 
22
/****************************** GLUI_StaticText::draw() **********/
 
23
 
 
24
void    GLUI_StaticText::draw( int x, int y )
 
25
{
 
26
  int orig;
 
27
 
 
28
  if ( NOT can_draw() )
 
29
    return;
 
30
 
 
31
  orig = set_to_glut_window();
 
32
 
 
33
  draw_text();
 
34
 
 
35
  restore_window( orig );
 
36
}
 
37
 
 
38
 
 
39
/****************************** GLUI_StaticText::set_text() **********/
 
40
 
 
41
void    GLUI_StaticText::set_text( char *text )
 
42
{
 
43
  int orig;
 
44
 
 
45
  /**** Erase old text first *****/
 
46
  glMatrixMode( GL_MODELVIEW );
 
47
  glPushMatrix();
 
48
  translate_to_origin();
 
49
  erase_text();
 
50
  glPopMatrix();
 
51
 
 
52
  set_name( text );
 
53
 
 
54
  if ( NOT can_draw() )
 
55
    return;
 
56
 
 
57
  orig = set_to_glut_window();
 
58
  /**** Redraw the text in the window ****/
 
59
  glMatrixMode( GL_MODELVIEW );
 
60
  glPushMatrix();
 
61
  translate_to_origin();
 
62
  draw_text();
 
63
  glPopMatrix();
 
64
 
 
65
  restore_window( orig );
 
66
}
 
67
 
 
68
 
 
69
/************************************ GLUI_StaticText::update_size() **********/
 
70
 
 
71
void   GLUI_StaticText::update_size( void )
 
72
{
 
73
  int text_size;
 
74
 
 
75
  if ( NOT glui )
 
76
    return;
 
77
 
 
78
  text_size = string_width( name );
 
79
 
 
80
  if ( w < text_size )
 
81
    w = text_size;    
 
82
}
 
83
 
 
84
 
 
85
/****************************** GLUI_StaticText::draw_text() **********/
 
86
 
 
87
void    GLUI_StaticText::draw_text( void )
 
88
{
 
89
  if ( NOT can_draw() )
 
90
    return;
 
91
 
 
92
  erase_text();
 
93
  draw_name( 0, 9 );
 
94
}
 
95
 
 
96
 
 
97
/****************************** GLUI_StaticText::erase_text() **********/
 
98
 
 
99
void    GLUI_StaticText::erase_text( void )
 
100
{
 
101
  if ( NOT can_draw() )
 
102
    return;
 
103
 
 
104
  set_to_bkgd_color();
 
105
  glDisable( GL_CULL_FACE );
 
106
  glBegin( GL_TRIANGLES );
 
107
  glVertex2i( 0,0 );   glVertex2i( w, 0 );  glVertex2i( w, h );  
 
108
  glVertex2i( 0, 0 );  glVertex2i( w, h );  glVertex2i( 0, h );   
 
109
  glEnd();
 
110
}
 
111
 
 
112
 
 
113