00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef KYRA_BUTTONWIDGET_INCLUDED
00033 #define KYRA_BUTTONWIDGET_INCLUDED
00034
00035 #ifdef _MSC_VER
00036
00037 #pragma warning( disable : 4530 )
00038 #pragma warning( disable : 4786 )
00039 #endif
00040
00041 #include "../gui/widget.h"
00042
00046 class KrButton : public KrWidget
00047 {
00048 public:
00049 virtual ~KrButton();
00050
00052 void SetTextChar( const std::string& text );
00053
00065 void SetIcon( KrSprite* giveSprite );
00066
00067
00068 virtual void AddedtoTree();
00069
00070 protected:
00071 KrButton( int width,
00072 int height,
00073 const KrScheme& scheme );
00074 KrButton( KrSprite* graphic,
00075 const KrScheme& scheme );
00076
00077
00078 enum
00079 {
00080 OVER = 0x01,
00081 DOWN = 0x02,
00082
00083 ICON_DEPTH = 1,
00084 TEXT_DEPTH = 2,
00085 };
00086 void SetMode( int mode );
00087
00088 virtual void ModeChange(KrColorTransform& color);
00089 void PlaceText();
00090 void PlaceIcon();
00091
00092 int width, height, mode;
00093 KrSprite *icon;
00094
00095 private:
00096 KrImNode *holder;
00097 KrBoxResource *plateRes;
00098 KrBox *plate;
00099 KrBevelElement bevel;
00100 bool userDrawn;
00101 int iconX, iconY;
00102
00103 KrTextBox* textBox;
00104 std::string text;
00105 };
00106
00107
00125 class KrPushButton : public KrButton
00126 {
00127 public:
00129 KrPushButton( int width,
00130 int height,
00131 const KrScheme& scheme ) : KrButton( width, height, scheme ) {}
00132
00137 KrPushButton( KrSprite* graphic,
00138 const KrScheme& scheme ) : KrButton( graphic, scheme ) {}
00139
00140 virtual ~KrPushButton() {}
00141
00142 virtual const char* WidgetType() { return "PushButton"; }
00143
00144 virtual int IsMouseListener() { return LEFT_MOUSE; }
00145
00146 virtual void MouseIn( bool down, bool in );
00147 virtual void MouseMove( bool down, int x, int y );
00148 virtual bool MouseClick( int down, int x, int y );
00149
00150
00151
00152
00153 virtual bool CanAccelerate() { return true; }
00154 virtual void Accelerate( bool down );
00155 };
00156
00157
00175 class KrToggleButton : public KrButton
00176 {
00177 public:
00179 KrToggleButton( int width,
00180 int height,
00181 const KrScheme& scheme ) : KrButton( width, height, scheme ) {}
00182
00187 KrToggleButton( KrSprite* graphic,
00188 const KrScheme& scheme ) : KrButton( graphic, scheme ) {}
00189
00190 ~KrToggleButton() {}
00191
00192 virtual const char* WidgetType() { return "ToggleButton"; }
00193
00194 virtual int IsMouseListener() { return LEFT_MOUSE; }
00195 virtual void MouseIn( bool down, bool in );
00196 virtual void MouseMove( bool down, int x, int y );
00197 virtual bool MouseClick( int down, int x, int y );
00198
00199
00200
00201 virtual bool IsSelectable() { return true; }
00202 virtual void Selected( bool selected );
00203
00204 virtual void Accelerate( bool down );
00205 };
00206
00207
00208 #endif
00209