include/gui/wheel.h

Go to the documentation of this file.
00001 /* vim: set noexpandtab shiftwidth=8 cino=: */
00002 #ifndef _VGUI_WHEEL_H
00003 #define _VGUI_WHEEL_H
00004 
00005 /* slider.h */
00006 #include "gui.h"
00007 
00008 namespace VGUI
00009 {
00010         template<class wheel_t>
00011         class Wheel : public Widget
00012         {
00013         private:
00014                 TEXTURE_HANDLE l_arrow_up, r_arrow_up, l_arrow_down, r_arrow_down;
00015                 string setting;
00016                 string wgt_hook;
00017                 vector<string> option_list;
00018                 vector<wheel_t> value_list;
00019                 unsigned int cur_option, default_option;
00020                 bool l_down, r_down, saved;
00021                 float tex_width, tex_height, spacing;
00022 
00023         public:
00024                 Wheel() { }
00025                 Wheel( Widget* w );
00026                 ~Wheel();
00027                 void Draw();
00028                 void Draw( float opacity );
00029                 void Save();
00030                 bool MouseOver( float x, float y );
00031                 string MousePress( float x, float y );
00032                 string MouseRelease( float x, float y );
00033                 void ResetValue();
00034 
00035                 vector<string> GetOptionList() { return option_list; }
00036                 vector<wheel_t> GetValueList() { return value_list; }
00037                 wheel_t GetValue() { return value_list[cur_option]; }
00038                 wheel_t GetDefaultValue() { return value_list[default_option]; }
00039                 string GetSetting() { return setting; }
00040                 float GetSpacing() { return spacing; }
00041                 string GetHook() { return wgt_hook; }
00042                 bool GetSaved() { return saved; }
00043                 void SetOptionList( vector<string> new_option_list ) { option_list = new_option_list; }
00044                 void SetValueList( vector<wheel_t> new_value_list ) { value_list = new_value_list; }
00045                 void SetValue( wheel_t new_value ) { for( unsigned int i = 0; i < value_list.size(); i++ ) if( value_list[i] == new_value ) cur_option = i; }
00046                 void SetDefaultValue( wheel_t new_value ) { for( unsigned int i = 0; i < value_list.size(); i++ ) if( value_list[i] == new_value ) default_option = i; }
00047                 void SetSetting( string new_setting ) { setting = new_setting; }
00048                 void SetSpacing( float new_spacing );
00049                 void SetHook( string new_hook ) { wgt_hook = new_hook; }
00050                 void SetSaved( bool new_saved ) { saved = new_saved; }
00051                 void IncValuePress();
00052                 void DecValuePress();
00053                 void IncValueRelease();
00054                 void DecValueRelease();
00055                 void Release();
00056         };
00057 
00058         template<class wheel_t1, class wheel_t2>
00059         class Wheel2 : public Widget
00060         {
00061         private:
00062                 TEXTURE_HANDLE l_arrow_up, r_arrow_up, l_arrow_down, r_arrow_down;
00063                 string setting_1, setting_2;
00064                 vector<string> option_list;
00065                 vector<wheel_t1> value_list_1;
00066                 vector<wheel_t2> value_list_2;
00067                 unsigned int cur_option, default_option;
00068                 bool l_down, r_down;
00069                 float tex_width, tex_height, spacing;
00070 
00071         public:
00072                 Wheel2() { }
00073                 Wheel2( Widget* w );
00074                 ~Wheel2();
00075                 void Draw();
00076                 void Draw( float opacity );
00077                 void Save();
00078                 bool MouseOver( float x, float y );
00079                 string MousePress( float x, float y );
00080                 string MouseRelease( float x, float y );
00081                 void ResetValue();
00082 
00083                 vector<string> GetOptionList() { return option_list; }
00084                 vector<int> GetValueList1() { return value_list_1; }
00085                 vector<int> GetValueList2() { return value_list_2; }
00086                 wheel_t1 GetValue1() { return value_list_1[cur_option]; }
00087                 wheel_t2 GetValue2() { return value_list_2[cur_option]; }
00088                 wheel_t1 GetDefaultValue1() { return value_list_1[default_option]; }
00089                 wheel_t2 GetDefaultValue2() { return value_list_2[default_option]; }
00090                 string GetSetting1() { return setting_1; }
00091                 string GetSetting2() { return setting_2; }
00092                 float GetSpacing() { return spacing; }
00093                 void SetOptionList( vector<string> new_option_list ) { option_list = new_option_list; }
00094                 void SetValueList1( vector<wheel_t1> new_value_list ) { value_list_1 = new_value_list; }
00095                 void SetValueList2( vector<wheel_t2> new_value_list ) { value_list_2 = new_value_list; }
00096                 void SetValue1( wheel_t1 new_value ) { for( unsigned int i = 0; i < value_list_1.size(); i++ ) if( value_list_1[i] == new_value ) cur_option = i; }
00097                 void SetValue2( wheel_t2 new_value ) { for( unsigned int i = 0; i < value_list_2.size(); i++ ) if( value_list_2[i] == new_value ) cur_option = i; }
00098                 void SetDefaultValue1( wheel_t1 new_value ) { for( unsigned int i = 0; i < value_list_1.size(); i++ ) if( value_list_1[i] == new_value ) default_option = i; }
00099                 void SetDefaultValue2( wheel_t2 new_value ) { for( unsigned int i = 0; i < value_list_2.size(); i++ ) if( value_list_2[i] == new_value ) default_option = i; }
00100                 void SetSetting1( string new_setting ) { setting_1 = new_setting; }
00101                 void SetSetting2( string new_setting ) { setting_2 = new_setting; }
00102                 void SetSpacing( float new_spacing );
00103                 void IncValuePress();
00104                 void DecValuePress();
00105                 void IncValueRelease();
00106                 void DecValueRelease();
00107                 void Release();
00108         };
00109 
00110         template<class wheel_t>
00111         Wheel<wheel_t>::Wheel( Widget* w )
00112         {
00113                 setting = "";
00114                 wgt_hook = "";
00115                 cur_option = default_option = 0;
00116                 center = w->GetCenter();
00117                 name = w->GetName();
00118                 text = w->GetText();
00119                 type = w->GetType();
00120                 tip = w->GetTip();
00121                 rel_width = w->GetRelWidth();
00122                 rel_height = w->GetRelHeight();
00123                 enabled = w->GetEnabled();
00124                 selected = w->GetSelected();
00125                 is_default = w->GetDefault();
00126                 is_cancel = w->GetCancel();
00127                 has_icon = w->GetHasIcon();
00128                 width_auto = w->GetWidthAuto();
00129                 height_auto = w->GetHeightAuto();
00130                 font_size = w->GetFontSize();
00131                 color_r = w->GetColorR();
00132                 color_g = w->GetColorG();
00133                 color_b = w->GetColorB();
00134                 l_down = false;
00135                 r_down = false;
00136                 spacing = 0.3;
00137                 saved = true;
00138 
00139                 string skin_path = settings.GetSkinPath();
00140                 l_arrow_up.Load( skin_path + "/textures/widgets/wheel_up_l.png", false );
00141                 l_arrow_down.Load( skin_path + "/textures/widgets/wheel_down_l.png", false );
00142                 r_arrow_up.Load( skin_path + "/textures/widgets/wheel_up_r.png", false );
00143                 r_arrow_down.Load( skin_path + "/textures/widgets/wheel_down_r.png", false );
00144 
00145                 tex_width = 0.0277;
00146                 tex_height = 0.0370;
00147 
00148                 // width = dist from left of text to wheel + width of wheel + texture width
00149                 if( width_auto )
00150                 {
00151                         rel_width = spacing + 0.15 + tex_width;
00152                 }
00153 
00154                 // height = button texture height
00155                 if( height_auto )
00156                 {
00157                         rel_height = tex_height;
00158                 }
00159         }
00160 
00161         template<class wheel_t>
00162         Wheel<wheel_t>::~Wheel()
00163         {
00164         }
00165 
00166         template<class wheel_t>
00167         void Wheel<wheel_t>::SetSpacing( float new_spacing )
00168         {
00169                 spacing = new_spacing;
00170                 rel_width = spacing + 0.15 + tex_width;
00171         }
00172 
00173         template<class wheel_t>
00174         void Wheel<wheel_t>::Save()
00175         {
00176                 default_option = cur_option;
00177                 if( saved )
00178                         settings.Set( setting, value_list[cur_option] );
00179         }
00180 
00181         template<class wheel_t>
00182         void Wheel<wheel_t>::ResetValue()
00183         {
00184                 wheel_t default_val;
00185                 if( saved )
00186                 {
00187                         settings.Get( setting, default_val );
00188                         SetValue( default_val );
00189                 }
00190                 else
00191                 {
00192                         cur_option = default_option;
00193                 }
00194         }
00195 
00196         template<class wheel_t>
00197         void Wheel<wheel_t>::Draw()
00198         {
00199                 Draw( 1.0 );
00200         }
00201 
00202         template<class wheel_t>
00203         void Wheel<wheel_t>::Draw( float opacity )
00204         {
00205                 int wheel_font_size = font_size;
00206                 float center_x = center.GetXPercent();
00207                 float center_y = center.GetYPercent();
00208                 float rel_width_half = rel_width / 2.0f;
00209                 float rel_height_half = rel_height / 2.0f;
00210                 float wheel_center = spacing + tex_width + ( ( 0.15 - tex_width ) / 2.0f );
00211                 TEXTURE_HANDLE * t1 = l_down ? &l_arrow_down : &l_arrow_up;
00212                 TEXTURE_HANDLE * t2 = r_down ? &r_arrow_down : &r_arrow_up;
00213                 float l_opacity = ( !enabled || ( cur_option == 0 ) ) ? 0.4 : selected ? 0.9 : 0.75;
00214                 float r_opacity = ( !enabled || ( cur_option == option_list.size() - 1 ) ) ? 0.4 : selected ? 0.9 : 0.75;
00215                 string cur_option_txt = ( option_list.size() == 0 ) ? "" : _(option_list[cur_option]);
00216 
00217                 // draw arrow images
00218                 utility.Draw2D( center_x - rel_width_half + spacing,
00219                                 center_y - rel_height_half,
00220                                 center_x - rel_width_half + spacing + tex_width,
00221                                 center_y + rel_height_half,
00222                                 t1, 0.0, 0, l_opacity * opacity );
00223                 utility.Draw2D( center_x - rel_width_half + spacing  + 0.15,
00224                                 center_y - rel_height_half,
00225                                 center_x - rel_width_half + spacing  + 0.15 + tex_width,
00226                                 center_y + rel_height_half,
00227                                 t2, 0.0, 0, r_opacity * opacity );
00228 
00229                 // draw text
00230                 float opacity_txt = selected ? 0.9 : enabled ? 0.75 : 0.4;
00231 
00232                 font.Print( center_x - rel_width_half, center_y - ( font.Height( text.c_str(), 1, font_size ) / 2.0f ), text.c_str(), 1, font_size, color_r, color_g, color_b, opacity_txt * opacity );
00233 
00234                 while( ( font.Width( cur_option_txt.c_str(), 1, wheel_font_size ) > ( 0.15 - tex_width ) ) && wheel_font_size > 3 )
00235                         wheel_font_size--;
00236 
00237                 font.Print( center_x - rel_width_half + wheel_center - ( font.Width( cur_option_txt.c_str(), 1, wheel_font_size ) / 2.0f ), center_y - ( font.Height( cur_option_txt.c_str(), 1, wheel_font_size ) / 2.0f ), cur_option_txt.c_str() , 1, wheel_font_size, color_r, color_g, color_b, opacity_txt * opacity );
00238 
00239                 // draw tip
00240                 if( selected && ( tip != "" ) )
00241                         font.Print( 0.5 - ( font.Width( tip.c_str(), 1, 6 ) / 2.0f ), 0.90, tip.c_str(), 1, 6, 0.7, 0.7, 0.7, 0.9 * opacity );
00242         }
00243 
00244         template<class wheel_t>
00245         void Wheel<wheel_t>::IncValuePress()
00246         {
00247                 Release();
00248                 r_down = true;
00249         }
00250 
00251         template<class wheel_t>
00252         void Wheel<wheel_t>::IncValueRelease()
00253         {
00254                 Release();
00255                 if( cur_option < option_list.size() - 1 )
00256                 {
00257                         cur_option++;
00258                 }
00259         }
00260 
00261         template<class wheel_t>
00262         void Wheel<wheel_t>::DecValuePress()
00263         {
00264                 Release();
00265                 l_down = true;
00266         }
00267 
00268         template<class wheel_t>
00269         void Wheel<wheel_t>::DecValueRelease()
00270         {
00271                 Release();
00272                 if( cur_option > 0 )
00273                 {
00274                         cur_option--;
00275                 }
00276         }
00277 
00278         template<class wheel_t>
00279         void Wheel<wheel_t>::Release()
00280         {
00281                 r_down = l_down = false;
00282         }
00283 
00284         template<class wheel_t>
00285         bool Wheel<wheel_t>::MouseOver( float x, float y )
00286         {
00287                 float min_x, min_y, max_x, max_y;
00288                 min_x = center.GetXPercent() - ( rel_width / 2.0f );
00289                 min_y = center.GetYPercent() - ( rel_height / 2.0f );
00290                 max_x = center.GetXPercent() + ( rel_width / 2.0f );
00291                 max_y = center.GetYPercent() + ( rel_height / 2.0f );
00292 
00293                 return ( x > min_x ) && ( x < max_x ) && ( y > min_y ) && ( y < max_y );
00294         }
00295 
00296         template<class wheel_t>
00297         string Wheel<wheel_t>::MousePress( float x, float y )
00298         {
00299                 string action = "";
00300                 float l_min_x, l_min_y, l_max_x, l_max_y;
00301                 float r_min_x, r_min_y, r_max_x, r_max_y;
00302                 l_min_x = center.GetXPercent() - ( rel_width / 2.0f ) + spacing;
00303                 l_min_y = center.GetYPercent() - ( rel_height / 2.0f );
00304                 l_max_x = center.GetXPercent() - ( rel_width / 2.0f ) + spacing + tex_width;
00305                 l_max_y = center.GetYPercent() + ( rel_height / 2.0f );
00306                 r_min_x = center.GetXPercent() - ( rel_width / 2.0f ) + spacing  + 0.15;
00307                 r_min_y = center.GetYPercent() - ( rel_height / 2.0f );
00308                 r_max_x = center.GetXPercent() - ( rel_width / 2.0f ) + spacing  + 0.15 + tex_width;
00309                 r_max_y = center.GetYPercent() + ( rel_height / 2.0f );
00310 
00311                 if( wgt_hook != "" )
00312                 {
00313                         if( l_down ) action = wgt_hook + "L";
00314                         if( r_down ) action = wgt_hook + "R";
00315                 }
00316 
00317                 if( ( x > l_min_x ) && ( x < l_max_x ) && ( y > l_min_y ) && ( y < l_max_y ) )
00318                 {
00319                         l_down = true;
00320                 }
00321                 else if( ( x > r_min_x ) && ( x < r_max_x ) && ( y > r_min_y ) && ( y < r_max_y ) )
00322                 {
00323                         r_down = true;
00324                 }
00325 
00326                 return action;
00327         }
00328 
00329         template<class wheel_t>
00330         string Wheel<wheel_t>::MouseRelease( float x, float y )
00331         {
00332                 string action = "";
00333                 float l_min_x, l_min_y, l_max_x, l_max_y;
00334                 float r_min_x, r_min_y, r_max_x, r_max_y;
00335                 l_min_x = center.GetXPercent() - ( rel_width / 2.0f ) + spacing;
00336                 l_min_y = center.GetYPercent() - ( rel_height / 2.0f );
00337                 l_max_x = center.GetXPercent() - ( rel_width / 2.0f ) + spacing + tex_width;
00338                 l_max_y = center.GetYPercent() + ( rel_height / 2.0f );
00339                 r_min_x = center.GetXPercent() - ( rel_width / 2.0f ) + spacing  + 0.15;
00340                 r_min_y = center.GetYPercent() - ( rel_height / 2.0f );
00341                 r_max_x = center.GetXPercent() - ( rel_width / 2.0f ) + spacing  + 0.15 + tex_width;
00342                 r_max_y = center.GetYPercent() + ( rel_height / 2.0f );
00343 
00344                 if( wgt_hook != "" )
00345                 {
00346                         if( l_down ) action = wgt_hook + "L";
00347                         if( r_down ) action = wgt_hook + "R";
00348                 }
00349 
00350                 if( ( x > l_min_x ) && ( x < l_max_x ) && ( y > l_min_y ) && ( y < l_max_y ) && l_down )
00351                 {
00352                         DecValueRelease();
00353                 }
00354                 else if( ( x > r_min_x ) && ( x < r_max_x ) && ( y > r_min_y ) && ( y < r_max_y ) && r_down )
00355                 {
00356                         IncValueRelease();
00357                 }
00358                 else
00359                 {
00360                         Release();
00361                 }
00362 
00363                 return action;
00364         }
00365 
00366         template<class wheel_t1, class wheel_t2>
00367         Wheel2<wheel_t1, wheel_t2>::Wheel2( Widget* w )
00368         {
00369                 setting_1 = "";
00370                 setting_2 = "";
00371                 cur_option = default_option = 0;
00372                 center = w->GetCenter();
00373                 name = w->GetName();
00374                 text = w->GetText();
00375                 type = w->GetType();
00376                 tip = w->GetTip();
00377                 rel_width = w->GetRelWidth();
00378                 rel_height = w->GetRelHeight();
00379                 enabled = w->GetEnabled();
00380                 selected = w->GetSelected();
00381                 is_default = w->GetDefault();
00382                 is_cancel = w->GetCancel();
00383                 has_icon = w->GetHasIcon();
00384                 width_auto = w->GetWidthAuto();
00385                 height_auto = w->GetHeightAuto();
00386                 font_size = w->GetFontSize();
00387                 color_r = w->GetColorR();
00388                 color_g = w->GetColorG();
00389                 color_b = w->GetColorB();
00390                 l_down = false;
00391                 r_down = false;
00392                 spacing = 0.3;
00393 
00394                 string skin_path = settings.GetSkinPath();
00395                 l_arrow_up.Load( skin_path + "/textures/widgets/wheel_up_l.png", false );
00396                 l_arrow_down.Load( skin_path + "/textures/widgets/wheel_down_l.png", false );
00397                 r_arrow_up.Load( skin_path + "/textures/widgets/wheel_up_r.png", false );
00398                 r_arrow_down.Load( skin_path + "/textures/widgets/wheel_down_r.png", false );
00399 
00400                 tex_width = 0.0277;
00401                 tex_height = 0.0370;
00402 
00403                 // width = dist from left of text to wheel + width of wheel + texture width
00404                 if( width_auto )
00405                 {
00406                         rel_width = spacing + 0.15 + tex_width;
00407                 }
00408 
00409                 // height = button texture height
00410                 if( height_auto )
00411                 {
00412                         rel_height = tex_height;
00413                 }
00414         }
00415 
00416         template<class wheel_t1, class wheel_t2>
00417         Wheel2<wheel_t1, wheel_t2>::~Wheel2()
00418         {
00419         }
00420 
00421         template<class wheel_t1, class wheel_t2>
00422         void Wheel2<wheel_t1, wheel_t2>::SetSpacing( float new_spacing )
00423         {
00424                 spacing = new_spacing;
00425                 rel_width = spacing + 0.15 + tex_width;
00426         }
00427 
00428         template<class wheel_t1, class wheel_t2>
00429         void Wheel2<wheel_t1, wheel_t2>::Save()
00430         {
00431                 default_option = cur_option;
00432                 settings.Set( setting_1, value_list_1[cur_option] );
00433                 settings.Set( setting_2, value_list_2[cur_option] );
00434         }
00435 
00436         template<class wheel_t1, class wheel_t2>
00437         void Wheel2<wheel_t1, wheel_t2>::ResetValue()
00438         {
00439                 int default_val_1, default_val_2;
00440                 settings.Get( setting_1, default_val_1 );
00441                 settings.Get( setting_2, default_val_2 );
00442                 SetValue1( default_val_1 );
00443                 SetValue2( default_val_2 );
00444         }
00445 
00446         template<class wheel_t1, class wheel_t2>
00447         void Wheel2<wheel_t1, wheel_t2>::Draw()
00448         {
00449                 Draw( 1.0 );
00450         }
00451 
00452         template<class wheel_t1, class wheel_t2>
00453         void Wheel2<wheel_t1, wheel_t2>::Draw( float opacity )
00454         {
00455                 int wheel_font_size = font_size;
00456                 float center_x = center.GetXPercent();
00457                 float center_y = center.GetYPercent();
00458                 float rel_width_half = rel_width / 2.0f;
00459                 float rel_height_half = rel_height / 2.0f;
00460                 float wheel_center = spacing + tex_width + ( ( 0.15 - tex_width ) / 2.0f );
00461                 string cur_option_txt = option_list[cur_option];
00462                 TEXTURE_HANDLE * t1 = l_down ? &l_arrow_down : &l_arrow_up;
00463                 TEXTURE_HANDLE * t2 = r_down ? &r_arrow_down : &r_arrow_up;
00464                 float l_opacity = ( !enabled || ( cur_option == 0 ) ) ? 0.4 : selected ? 0.9 : 0.75;
00465                 float r_opacity = ( !enabled || ( cur_option == option_list.size() - 1 ) ) ? 0.4 : selected ? 0.9 : 0.75;
00466 
00467                 // draw arrow images
00468                 utility.Draw2D( center_x - rel_width_half + spacing,
00469                                 center_y - rel_height_half,
00470                                 center_x - rel_width_half + spacing + tex_width,
00471                                 center_y + rel_height_half,
00472                                 t1, 0.0, 0, l_opacity * opacity );
00473                 utility.Draw2D( center_x - rel_width_half + spacing  + 0.15,
00474                                 center_y - rel_height_half,
00475                                 center_x - rel_width_half + spacing  + 0.15 + tex_width,
00476                                 center_y + rel_height_half,
00477                                 t2, 0.0, 0, r_opacity * opacity );
00478 
00479                 // draw text
00480                 float opacity_txt = selected ? 0.9 : enabled ? 0.75 : 0.4;
00481 
00482                 font.Print( center_x - rel_width_half, center_y - ( font.Height( text.c_str(), 1, font_size ) / 2.0f ), text.c_str(), 1, font_size, color_r, color_g, color_b, opacity_txt * opacity );
00483 
00484                 while( ( font.Width( cur_option_txt.c_str(), 1, wheel_font_size ) > ( 0.15 - tex_width ) ) && wheel_font_size > 3 )
00485                         wheel_font_size--;
00486 
00487                 font.Print( center_x - rel_width_half + wheel_center - ( font.Width( cur_option_txt.c_str(), 1, wheel_font_size ) / 2.0f ), center_y - ( font.Height( cur_option_txt.c_str(), 1, wheel_font_size ) / 2.0f ), cur_option_txt.c_str() , 1, wheel_font_size, color_r, color_g, color_b, opacity_txt * opacity );
00488 
00489                 // draw tip
00490                 if( selected && ( tip != "" ) )
00491                         font.Print( 0.5 - ( font.Width( tip.c_str(), 1, 6 ) / 2.0f ), 0.90, tip.c_str(), 1, 6, 0.7, 0.7, 0.7, 0.9 * opacity );
00492         }
00493 
00494         template<class wheel_t1, class wheel_t2>
00495         void Wheel2<wheel_t1, wheel_t2>::IncValuePress()
00496         {
00497                 Release();
00498                 r_down = true;
00499         }
00500 
00501         template<class wheel_t1, class wheel_t2>
00502         void Wheel2<wheel_t1, wheel_t2>::IncValueRelease()
00503         {
00504                 Release();
00505                 if( cur_option < option_list.size() - 1 )
00506                 {
00507                         cur_option++;
00508                 }
00509         }
00510 
00511         template<class wheel_t1, class wheel_t2>
00512         void Wheel2<wheel_t1, wheel_t2>::DecValuePress()
00513         {
00514                 Release();
00515                 l_down = true;
00516         }
00517 
00518         template<class wheel_t1, class wheel_t2>
00519         void Wheel2<wheel_t1, wheel_t2>::DecValueRelease()
00520         {
00521                 Release();
00522                 if( cur_option > 0 )
00523                 {
00524                         cur_option--;
00525                 }
00526         }
00527 
00528         template<class wheel_t1, class wheel_t2>
00529         void Wheel2<wheel_t1, wheel_t2>::Release()
00530         {
00531                 r_down = l_down = false;
00532         }
00533 
00534         template<class wheel_t1, class wheel_t2>
00535         bool Wheel2<wheel_t1, wheel_t2>::MouseOver( float x, float y )
00536         {
00537                 float min_x, min_y, max_x, max_y;
00538                 min_x = center.GetXPercent() - ( rel_width / 2.0f );
00539                 min_y = center.GetYPercent() - ( rel_height / 2.0f );
00540                 max_x = center.GetXPercent() + ( rel_width / 2.0f );
00541                 max_y = center.GetYPercent() + ( rel_height / 2.0f );
00542 
00543                 return ( x > min_x ) && ( x < max_x ) && ( y > min_y ) && ( y < max_y );
00544         }
00545 
00546         template<class wheel_t1, class wheel_t2>
00547         string Wheel2<wheel_t1, wheel_t2>::MousePress( float x, float y )
00548         {
00549                 float l_min_x, l_min_y, l_max_x, l_max_y;
00550                 float r_min_x, r_min_y, r_max_x, r_max_y;
00551                 l_min_x = center.GetXPercent() - ( rel_width / 2.0f ) + spacing;
00552                 l_min_y = center.GetYPercent() - ( rel_height / 2.0f );
00553                 l_max_x = center.GetXPercent() - ( rel_width / 2.0f ) + spacing + tex_width;
00554                 l_max_y = center.GetYPercent() + ( rel_height / 2.0f );
00555                 r_min_x = center.GetXPercent() - ( rel_width / 2.0f ) + spacing  + 0.15;
00556                 r_min_y = center.GetYPercent() - ( rel_height / 2.0f );
00557                 r_max_x = center.GetXPercent() - ( rel_width / 2.0f ) + spacing  + 0.15 + tex_width;
00558                 r_max_y = center.GetYPercent() + ( rel_height / 2.0f );
00559 
00560 
00561                 if( ( x > l_min_x ) && ( x < l_max_x ) && ( y > l_min_y ) && ( y < l_max_y ) )
00562                 {
00563                         l_down = true;
00564                 }
00565                 else if( ( x > r_min_x ) && ( x < r_max_x ) && ( y > r_min_y ) && ( y < r_max_y ) )
00566                 {
00567                         r_down = true;
00568                 }
00569 
00570                 return "";
00571         }
00572 
00573         template<class wheel_t1, class wheel_t2>
00574         string Wheel2<wheel_t1, wheel_t2>::MouseRelease( float x, float y )
00575         {
00576                 float l_min_x, l_min_y, l_max_x, l_max_y;
00577                 float r_min_x, r_min_y, r_max_x, r_max_y;
00578                 l_min_x = center.GetXPercent() - ( rel_width / 2.0f ) + spacing;
00579                 l_min_y = center.GetYPercent() - ( rel_height / 2.0f );
00580                 l_max_x = center.GetXPercent() - ( rel_width / 2.0f ) + spacing + tex_width;
00581                 l_max_y = center.GetYPercent() + ( rel_height / 2.0f );
00582                 r_min_x = center.GetXPercent() - ( rel_width / 2.0f ) + spacing  + 0.15;
00583                 r_min_y = center.GetYPercent() - ( rel_height / 2.0f );
00584                 r_max_x = center.GetXPercent() - ( rel_width / 2.0f ) + spacing  + 0.15 + tex_width;
00585                 r_max_y = center.GetYPercent() + ( rel_height / 2.0f );
00586 
00587 
00588                 if( ( x > l_min_x ) && ( x < l_max_x ) && ( y > l_min_y ) && ( y < l_max_y ) && l_down )
00589                 {
00590                         DecValueRelease();
00591                 }
00592                 else if( ( x > r_min_x ) && ( x < r_max_x ) && ( y > r_min_y ) && ( y < r_max_y ) && r_down )
00593                 {
00594                         IncValueRelease();
00595                 }
00596                 else
00597                 {
00598                         Release();
00599                 }
00600 
00601                 return "";
00602         }
00603 }
00604 
00605 
00606 #endif // _VGUI_WHEEL_H

Generated on Thu Oct 19 04:05:47 2006 by  doxygen 1.4.6