Adds a standard button to the toolbar. @param name C-String containing the label for the Button @param img Image (Fl_PNG_Image) for the button (optional) @param cb Callback function, activated when the button is pressed @param data Data that should get sent to the callback @param width Width (and height) of the button. (TODO Not working!?) @param shortName If given, it is used as the
| 59 | @return Newly created button. |
| 60 | */ |
| 61 | Fl_Button *My_Toolbar::AddButton(const char *name, Fl_RGB_Image *img, Fl_Callback *cb, void *data, int width, std::string shortName, int fontSize) { |
| 62 | begin(); |
| 63 | if( !width ) { |
| 64 | width = 40; |
| 65 | } |
| 66 | Fl_Button *b = new Fl_Button(0,0,width,width); |
| 67 | b->box(FL_NO_BOX); |
| 68 | b->clear_visible_focus(); |
| 69 | if( name ) |
| 70 | b->tooltip(name); |
| 71 | if( img ) { |
| 72 | b->image(img); |
| 73 | } else { |
| 74 | b->labelcolor(ColorThemes::getColor(app.getTheme(), "toolbar_text")); |
| 75 | if( fontSize > 0 ) |
| 76 | b->labelsize(fontSize); |
| 77 | if( shortName != "" ) { |
| 78 | b->copy_label(shortName.c_str()); |
| 79 | } else { |
| 80 | b->copy_label(name); |
| 81 | } |
| 82 | } |
| 83 | if( cb ) |
| 84 | b->callback(cb,data); |
| 85 | if( width ) |
| 86 | b->resize(0,0,width,width); |
| 87 | end(); |
| 88 | return b; |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | Adds a checkbox to the toolbar. |