MCPcopy Create free account
hub / github.com/Tablecruncher/tablecruncher / AddButton

Method AddButton

src/csvwidgets.cpp:61–89  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

59 @return Newly created button.
60*/
61Fl_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.

Callers 2

createMethod · 0.80
executeMacroMethod · 0.80

Calls 4

beginFunction · 0.85
endFunction · 0.85
getThemeMethod · 0.80
resizeMethod · 0.80

Tested by

no test coverage detected