![]() |
TAPs 0.7.7.3
|
00001 /****************************************************************************** 00002 TAPsOpenGLCtrlSlider.cpp 00003 00004 Slider Control via OpenGL 00005 00006 SUKITTI PUNAK (06/15/2007) 00007 UPDATE (06/15/2007) 00008 ******************************************************************************/ 00009 #include "TAPsOpenGLCtrlSlider.hpp" 00010 // Using Inclusion Model (i.e. definitions are included in declarations) 00011 // (this name.cpp is included in name.hpp) 00012 // Each friend is defined directly inside its declaration. 00013 00014 BEGIN_NAMESPACE_TAPs__OpenGL 00015 //============================================================================= 00016 // Constructor(s) and Destructor 00017 //----------------------------------------------------------------------------- 00018 OpenGLCtrlSlider::OpenGLCtrlSlider () 00019 : OpenGLCtrl() 00020 { 00021 Default(); 00022 } 00023 //----------------------------------------------------------------------------- 00024 OpenGLCtrlSlider::~OpenGLCtrlSlider () 00025 {} 00026 //----------------------------------------------------------------------------- 00027 //============================================================================= 00028 00029 //============================================================================= 00030 // Get/Set Function(s) 00031 //----------------------------------------------------------------------------- 00032 void OpenGLCtrlSlider::Default () 00033 { 00034 SetSize( 100, 14 ); 00035 SetText( "Slider" ); 00036 m_BorderSize = 1; 00037 // 00038 m_ForegroundColor[0] = 1.0; 00039 m_ForegroundColor[1] = 1.0; 00040 m_ForegroundColor[2] = 1.0; 00041 m_ForegroundColor[3] = 0.90; 00042 // 00043 m_BackgroundColor[0] = 0.25; 00044 m_BackgroundColor[1] = 0.25; 00045 m_BackgroundColor[2] = 0.25; 00046 m_BackgroundColor[3] = 0.90; 00047 } 00048 //----------------------------------------------------------------------------- 00049 //============================================================================= 00050 00051 //============================================================================= 00052 // Draw Function(s) 00053 //----------------------------------------------------------------------------- 00054 void OpenGLCtrlSlider::Draw () 00055 { 00056 //--------------------------------------------------------------- 00057 // Draw Background with Border 00058 { 00059 int oneThirdHeight = m_DrawSizeXY[1] / 3; 00060 int mx = m_xyLowerLeftPt[0]; 00061 int my = m_xyLowerLeftPt[1] + oneThirdHeight; 00062 int X = m_xyLowerLeftPt[0] + m_DrawSizeXY[0]; 00063 int Y = my + oneThirdHeight; 00064 glBegin( GL_QUADS ); 00065 // Draw Background 00066 glColor4fv( m_BackgroundColor ); 00067 glVertex2f( mx, my ); 00068 glVertex2f( X, my ); 00069 glVertex2f( X, Y ); 00070 glVertex2f( mx, Y ); 00071 // 00072 /* 00073 glColor4fv( g_BorderColor ); 00074 // Draw Left Border 00075 int LX = m_xyLowerLeftPt[0] - m_BorderSize; 00076 int BY = m_xyLowerLeftPt[1] - m_BorderSize; 00077 glVertex2f( LX, m_xyLowerLeftPt[1] ); 00078 glVertex2f( m_xyLowerLeftPt[0], m_xyLowerLeftPt[1] ); 00079 glVertex2f( m_xyLowerLeftPt[0], Y ); 00080 glVertex2f( LX, Y ); 00081 // Draw Right Border 00082 int RX = X + m_BorderSize; 00083 int TY = Y + m_BorderSize; 00084 glVertex2f( X, m_xyLowerLeftPt[1] ); 00085 glVertex2f( RX, m_xyLowerLeftPt[1] ); 00086 glVertex2f( RX, Y ); 00087 glVertex2f( X, Y ); 00088 // Draw Top Border 00089 glVertex2f( LX, Y ); 00090 glVertex2f( RX, Y ); 00091 glVertex2f( RX, TY ); 00092 glVertex2f( LX, TY ); 00093 // Draw Bottom Border 00094 glVertex2f( LX, BY ); 00095 glVertex2f( RX, BY ); 00096 glVertex2f( RX, m_xyLowerLeftPt[1] ); 00097 glVertex2f( LX, m_xyLowerLeftPt[1] ); 00098 //*/ 00099 glEnd(); 00100 } 00101 00102 DrawText(); 00103 DrawMarker(); 00104 } 00105 void OpenGLCtrlSlider::DrawMarker () 00106 { 00107 //int X = m_xyLowerLeftPt[0] + m_DrawSizeXY[0]; 00108 //int Y = m_xyLowerLeftPt[1] + m_DrawSizeXY[1]; 00109 int X = m_DrawSizeXY[0] / 20; 00110 int halfX = X / 2; 00111 int Y = m_DrawSizeXY[1]; 00112 int mx = m_xyLowerLeftPt[0]; 00113 int my = m_xyLowerLeftPt[1]; 00114 glPushMatrix(); 00115 glTranslatef( 50+mx-halfX, my, 0 ); 00116 glBegin( GL_QUADS ); 00117 glColor4fv( m_BackgroundActColor ); 00118 glVertex2f( 0, 0 ); 00119 glVertex2f( X, 0 ); 00120 glVertex2f( X, Y ); 00121 glVertex2f( 0, Y ); 00122 glEnd(); 00123 glPopMatrix(); 00124 } 00125 //----------------------------------------------------------------------------- 00126 //============================================================================= 00127 00128 //============================================================================= 00129 END_NAMESPACE_TAPs__OpenGL 00130 //----------------------------------------------------------------------------- 00131 //34567890123456789012345678901234567890123456789012345678901234567890123456789 00132 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----