00001 /* This is -*- C -*-) 00002 00003 BButton.h 00004 \author: Bjoern Giesler <bjoern@giesler.de> 00005 00006 00007 00008 $Author: giesler $ 00009 $Locker$ 00010 $Revision$ 00011 $Date: 2002-08-19 10:41:28 +0200 (Mon, 19 Aug 2002) $ 00012 */ 00013 00014 #ifndef BBUTTON_H 00015 #define BBUTTON_H 00016 00017 /* system includes */ 00018 #include <string> 00019 00020 /* my includes */ 00021 #include "BLabel.h" 00022 #include "BGraphics.h" 00023 #include "BFont.h" 00024 00029 class BButton: public BLabel { 00030 public: 00031 class Delegate { 00032 public: 00033 virtual ~Delegate() {} 00034 virtual void onButtonClick(BButton* button) {} 00035 }; 00036 00037 typedef enum { 00038 BT_TRIGGER, 00039 BT_TOGGLE 00040 } ButtonType; 00041 00042 BButton(BWidget* parent, const BRect& frame, 00043 ButtonType type = BT_TRIGGER); 00044 void setDelegate(Delegate* deleg); 00045 Delegate* delegate() { return _deleg; } 00046 00047 virtual void setType(ButtonType type); 00048 virtual ButtonType type() const { return _type; } 00049 00050 virtual bool value() const { return _value; } 00051 virtual void setValue(bool value); 00052 00053 virtual void draw(BImage& img); 00054 00055 virtual void handleEvent(const BEvent& event); 00056 00057 private: 00058 Delegate* _deleg; 00059 bool _touchdown; 00060 ButtonType _type; 00061 bool _value; 00062 }; 00063 00064 #endif /* BBUTTON_H */
1.3-rc3