00001 #ifndef _VGUI_WIDGET_H
00002 #define _VGUI_WIDGET_H
00003
00004
00005 #include <map>
00006 #include <string>
00007 #include <GL/gl.h>
00008 #include <SDL/SDL.h>
00009 #include "multiplay.h"
00010 #include "textures.h"
00011 #include "font.h"
00012 #include "gamestate.h"
00013 #include "settings.h"
00014 #include "configfile.h"
00015 #include "globals.h"
00016
00017 namespace VGUI
00018 {
00019 class Location
00020 {
00021 private:
00022 float xpct, ypct;
00023
00024 public:
00025 Location();
00026 ~Location();
00027 Location(float _xpct, float _ypct) { xpct = _xpct; ypct = _ypct; }
00028
00029 float GetXPercent() { return xpct; }
00030 float GetYPercent() { return ypct; }
00031
00032 void SetXPercent( float new_xpct ) { xpct = new_xpct; }
00033 void SetYPercent( float new_ypct ) { ypct = new_ypct; }
00034 };
00035
00036
00037 class Widget
00038 {
00039 protected:
00040 Location center;
00041 string name;
00042 string text;
00043 string type;
00044 string tip;
00045 float rel_width;
00046 float rel_height;
00047 bool enabled;
00048 bool selected;
00049 bool is_default;
00050 bool is_cancel;
00051 bool has_icon;
00052 bool width_auto;
00053 bool height_auto;
00054 int font_size;
00055 float color_r;
00056 float color_g;
00057 float color_b;
00058
00059 public:
00060 Widget();
00061 ~Widget() { }
00062
00063 virtual void Save( void ) { }
00064 virtual void Draw( void ) { }
00065 virtual void Draw( float opacity ) { }
00066 virtual void IncValuePress( void ) { }
00067 virtual void DecValuePress( void ) { }
00068 virtual void IncValueRelease( void ) { }
00069 virtual void DecValueRelease( void ) { }
00070 virtual void HookIncValuePress( void ) { }
00071 virtual void HookDecValuePress( void ) { }
00072 virtual void HookIncValueRelease( void ) { }
00073 virtual void HookDecValueRelease( void ) { }
00074 virtual void HookRelease( void ) { }
00075 virtual void BackspacePress() { }
00076 virtual void DeletePress() { }
00077 virtual void BackspaceRelease() { }
00078 virtual void DeleteRelease() { }
00079 virtual string GetAction( void ) { return ""; }
00080 virtual string GetHook( void ) { return ""; }
00081 virtual int GetNumCols( void ) { return 0; }
00082 virtual void SetValue( bool val ) { }
00083 virtual void SetValue( string val ) { }
00084 virtual void SetValue( float val ) { }
00085 virtual void SetDefaultValue( bool val ) { }
00086 virtual void SetDefaultValue( string val ) { }
00087 virtual void SetDefaultValue( float val ) { }
00088 virtual void SetSetting( string new_setting ) { }
00089 virtual void SetSaved( bool new_saved ) { }
00090 virtual bool GetSaved() { return true; }
00091 virtual void SetNumCols( int new_num_cols ) { }
00092 virtual void TogValue( void ) { }
00093 virtual bool MouseOver( float x, float y ) { return false; }
00094 virtual void Press( void ) { }
00095 virtual void Release( void ) { }
00096 virtual string MousePress( float x, float y ) { return ""; }
00097 virtual string MouseRelease( float x, float y ) { return ""; }
00098 virtual void ResetValue() { }
00099 virtual void ClearCar() { }
00100 virtual void EnterText( SDLKey key ) { }
00101 virtual void GrabKey( SDLKey key ) { }
00102 virtual void GrabMouseMovement( string direction ) { }
00103 virtual void GrabMouseButton( int button_idx ) { }
00104 virtual void GrabJoyButton( Uint8 joy_idx, Uint8 joy_btn ) { }
00105 virtual void GrabJoyMove( Uint8 joy_idx, Uint8 joy_axis, bool joy_positive, float joy_value ) { }
00106 virtual void SelectIcon( unsigned int new_selected_icon ) { }
00107 virtual bool GetAdding() { return false; }
00108
00109 Location GetCenter() { return center; }
00110 string GetName() { return name; }
00111 string GetText() { return text; }
00112 string GetType() { return type; }
00113 string GetTip() { return tip; }
00114 float GetRelWidth() { return rel_width; }
00115 float GetRelHeight() { return rel_height; }
00116 bool GetEnabled() { return enabled; }
00117 bool GetSelected() { return selected; }
00118 bool GetDefault() { return is_default; }
00119 bool GetCancel() { return is_cancel; }
00120 bool GetHasIcon() { return has_icon; }
00121 bool GetWidthAuto() { return width_auto; }
00122 bool GetHeightAuto() { return height_auto; }
00123 int GetFontSize() { return font_size; }
00124 float GetColorR() { return color_r; }
00125 float GetColorG() { return color_g; }
00126 float GetColorB() { return color_b; }
00127
00128 void SetCenter( Location new_center ) { center = new_center; }
00129 void SetName( string new_name ) { name = new_name; }
00130 void SetText( string new_text ) { text = new_text; }
00131 void SetType( string new_type ) { type = new_type; }
00132 void SetTip( string new_tip ) { tip = new_tip; }
00133 void SetRelWidth( float new_rel_width ) { rel_width = new_rel_width; }
00134 void SetRelHeight( float new_rel_height ) { rel_height = new_rel_height; }
00135 void SetEnabled( bool new_enabled ) { enabled = new_enabled; }
00136 void SetSelected( bool new_selected ) { selected = new_selected; }
00137 void SetDefault( bool new_is_default ) { is_default = new_is_default; }
00138 void SetCancel( bool new_is_cancel ) { is_cancel = new_is_cancel; }
00139 void SetHasIcon( bool new_has_icon ) { has_icon = new_has_icon; }
00140 void SetWidthAuto( bool new_width_auto ) { width_auto = new_width_auto; }
00141 void SetHeightAuto( bool new_height_auto ) { height_auto = new_height_auto; }
00142 void SetFontSize( int new_font_size ) { font_size = new_font_size; }
00143 void SetColor( float r, float g, float b ) { color_r = r; color_g = g; color_b = b; }
00144 };
00145 }
00146
00147 #endif // _VGUI_WIDGET_H