Initial commit
[forms.git] / F / F_Menu_Button.H
blobf1ac0548f7aab0b49084aa8de13d3b2474575595
2 #ifndef _F_MENU_BUTTON_H_
3 #define _F_MENU_BUTTON_H_
5 #include <F_Text_Display.H>
6 #include <F_Window.H>
7 #include <F_Menu.H>
8 #include <F_Button.H>
10 namespace F {
12 class F_Menu_Button : public F_Menu {
14   F_Button *b_;
16   bool handle(F_Event_t &ev);
18   static void f_menu_button_cb(F_Button *b, void *d) {
19     F_Menu_Button *mb = (F_Menu_Button *) d;
20     switch (b->state()) {
21       case F_BUTTON_PRESSED:
22         mb->b_->hide();
23         mb->state_ = F_BUTTON_ON_FOCUS;
24         mb->draw();
25         mb->show();
26         break;
27       default:
28         break;
29     }
30   }
32  public:
33   F_Menu_Button(F_Box_Type_t btype, coord_t x, coord_t y, dim_t w, dim_t h,
34     const char *label = 0) : F_Menu(x, y, w, h, label) {
35       b_ = new F_Button(F_UP_BOX, x, y, w, h, label);
36       b_->callback((F_Callback *)f_menu_button_cb, this);
37       b_->when(F_WHEN_NOT_CHANGED);
38       add_child(b_);
39  }
40   ~F_Menu_Button() { delete b_; }
41  };
44 #endif