00001 #ifndef CVBUTTONS_H_
00002 #define CVBUTTONS_H_
00003
00004 #include <cv.h>
00005 #include <vector>
00006 using namespace std;
00007
00012 void cvButtonsOnMouse( int event, int x, int y, int flags, void* param );
00013
00023 class PushButton {
00024
00025 public:
00026
00036 PushButton( int x, int y, int w, int h, int t, char *text, void (*cb)(int) ):
00037 x_pos(x), y_pos(y), width(w), height(h), toggle(t), text(text), cb(cb) {}
00038
00042 int x_pos, y_pos;
00043
00047 int width, height;
00048
00052 int toggle;
00053
00057 char *text;
00058
00062 void (*cb)(int);
00063 };
00064
00075 class CvButtons {
00076
00077 public:
00078
00082 CvButtons(){ cvInitFont( &font, CV_FONT_HERSHEY_PLAIN, 1, 1, 0, 1, CV_AA ); }
00083
00087 ~CvButtons(){ buttonList.clear(); }
00088
00092 void setMouseState(int e, int x, int y, int f) {me=e; mx=x; my=y; mf=f;}
00093
00097 void paintButtons(IplImage *img);
00098
00102 void addButton(PushButton pb){ buttonList.push_back(pb); }
00103
00107 void delButton(int pos){ buttonList.erase( buttonList.begin()+pos ); }
00108
00109 private:
00110
00114 vector<PushButton> buttonList;
00115
00119 int me, mx, my, mf;
00120
00124 CvFont font;
00125 };
00126
00127 #endif