button.h
00001
00002
00003
00004
00005
00006
00007
00008 #ifndef BUTTON_H
00009 #define BUTTON_H
00010
00011 #include "widget.h"
00012
00013 #include <string>
00014
00015 namespace cwidget
00016 {
00017 class fragment;
00018 class fragment_cache;
00019
00020 namespace widgets
00021 {
00023 class button : public widget
00024 {
00025 fragment_cache *label;
00026
00027 void accept_focus();
00028 void lose_focus();
00029
00030 protected:
00031 bool handle_key(const config::key &k);
00032 fragment_cache *get_label() const {return label;}
00033
00039 button(const std::wstring &_label);
00040 button(fragment *_label);
00041 button(const std::string &_label);
00042 public:
00043
00044 ~button();
00045
00046 static util::ref_ptr<button>
00047 create(const std::wstring &label)
00048 {
00049 util::ref_ptr<button> rval(new button(label));
00050
00051 rval->decref();
00052 return rval;
00053 }
00054
00060 static util::ref_ptr<button> create(fragment *label)
00061 {
00062 util::ref_ptr<button> rval(new button(label));
00063 rval->decref();
00064 return rval;
00065 }
00066
00072 static util::ref_ptr<button> create(const std::string &label)
00073 {
00074 util::ref_ptr<button> rval(new button(label));
00075 rval->decref();
00076 return rval;
00077 }
00078
00079 void paint(const style &st);
00080
00081 bool get_cursorvisible();
00082 point get_cursorloc();
00083 bool focus_me();
00084
00085 int width_request();
00086 int height_request(int width);
00087 void dispatch_mouse(short id, int x, int y, int z, mmask_t bmask);
00088
00089 void set_label(const fragment *_label);
00090
00091
00092
00093
00094 sigc::signal0<void> pressed;
00095 };
00096
00097 typedef util::ref_ptr<button> button_ref;
00098 }
00099 }
00100
00101 #endif