00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef GUIBUTTON_H
00019 #define GUIBUTTON_H
00020
00021 #include "game.h"
00022 #include "font.h"
00023
00024 class Game;
00025
00030 class GUIButton {
00031 public:
00033 GUIButton( Game *parentgame, Texture *icon, const char *tooltip, int x, int y, Vector &baseposition, SDLKey hotkey=SDLK_UNKNOWN, int modifier=KMOD_NONE );
00035 GUIButton( Game *parentgame, const char *text, int x, int y, Vector &baseposition, SDLKey hotkey=SDLK_UNKNOWN, int modifier=KMOD_NONE );
00037 ~GUIButton();
00038
00040 void setAutoRefresh( bool enable ) { autorefresh=enable; }
00042 void setCallback( void (*callback)() ) { buttonCallback=callback; }
00043
00045 bool clicked() { return click; }
00047 void render();
00049 void refresh();
00051 void setFont( BFont *tipfont ) { font=tipfont; }
00052 private:
00053 int ismouseover;
00054 Texture *tex;
00055 const char *tip, *buttontext;
00056 Vector pos, size, *basepos;
00057 Game *game;
00058 BFont *font;
00059 int buttontype;
00060 float normalcolor[4], hovercolor[4], activecolor[4], currentcolor[4];
00061
00063 void (*buttonCallback)();
00064 bool click, autorefresh;
00065 SDLKey hotk;
00066 int modk;
00067 };
00068
00069 #endif