28 #pragma warning( disable : 4005 4554) 52 AnyFuncData(
const char *s,
void (*f)(
void *,
void *), gpointer d) {
54 func=
reinterpret_cast<GCallback
>(f);
61 #define ANYSTRUCT(s,f,d) AnyFuncData(s,f,d) 62 #define BUTTONANYSTRUCT(s,f,d) AnyFuncData(s,f,d) 73 #define BUTTONLABELSTRUCT(s,f,d) LabelFuncData(s,f,d) // visual C++ doesn't support compound literals 76 #define GDKPIXMAPCREATE(win, ref) gdk_pixmap_colormap_create_from_xpm_d(gtk_widget_get_window(win),gtk_widget_get_colormap(win),NULL,NULL,ref) 77 #define GTKPIXMAPCREATE(pixGdk) (GtkPixmap*)gtk_image_new_from_pixmap(pixGdk, NULL) 94 #define BUTTONPIXMAPSTRUCT(p,f,d) PixmapFuncData(p,f,d) 111 #define BUTTONPIXMAPSTRUCTTRANSPARENT(i,f,d) PixmapFuncDataTransparent(i,f,d) 122 #define BUTTONTOGGLESTRUCT(s,f,d) ToggleFuncData(s,f,d) 129 whichArrow=(GtkArrowType)0;
130 whichShadow=(GtkShadowType)0;
143 #define BUTTONARROWSTRUCT(f,d,a,sh) arrowFuncData(f,d,a,sh) 154 #define BUTTONRADIOSTRUCT(s,f,d) RadioFuncData(s,f,d) 165 #define BUTTONCHECKSTRUCT(s,f,d) CheckFuncData(s,f,d) 190 #if GTK_MAJOR_VERSION==2 191 gdk_colormap_new(gdk_visual_get_best(),1);
201 gtk_button_set_alignment(GTK_BUTTON(current()), xAlign, yAlign);
202 gtk_widget_queue_draw(current());
212 gtk_button_get_alignment(GTK_BUTTON(current()), xAlign, yAlign);
228 g_signal_connect_after(G_OBJECT((GtkButton*)current()),
"released",reinterpret_cast<GCallback>(nf.
func), nf.
data);
236 g_signal_connect_after(G_OBJECT((GtkButton*)current()),
"released", af.
func, af.
data);
245 g_signal_handlers_disconnect_by_func(G_OBJECT((GtkButton*)current()), (
void *)(nfOld.
func), nfOld.
data);
247 g_signal_connect(G_OBJECT((GtkButton*)current()),
"released",reinterpret_cast<GCallback>(nfNew.
func), nfNew.
data);
256 g_signal_handlers_disconnect_by_func(G_OBJECT((GtkButton*)current()), (
void *)(nfOld.
func), nfOld.
data);
271 g_signal_connect(G_OBJECT((GtkButton*)current()),
"released",reinterpret_cast<GCallback>(nf.
func), nf.
data);
272 gtk_widget_show(current());
282 g_signal_connect_after(current(),
"expose-event", G_CALLBACK(exposePixmap), (gpointer)nf.
pixGtk);
285 g_signal_connect(G_OBJECT(current()),
"released",reinterpret_cast<GCallback>(nf.
func), nf.
data);
286 gtk_widget_show(current());
309 g_signal_connect(G_OBJECT((GtkButton*)current()),
"released",reinterpret_cast<GCallback>(nf.
func), nf.
data);
310 gtk_widget_show(current());
321 g_signal_connect_after(current(),
"expose-event", G_CALLBACK(exposePixmap), (gpointer)pfdt.
imageXPM);
324 g_signal_connect(G_OBJECT(current()),
"released",reinterpret_cast<GCallback>(pfdt.
func), pfdt.
data);
325 gtk_widget_show(current());
338 gtk_container_add (GTK_CONTAINER (current()), arrow);
339 gtk_widget_show(arrow);
342 g_signal_connect(G_OBJECT((GtkButton*)current()),
"released",reinterpret_cast<GCallback>(af.
func), af.
data);
343 gtk_widget_show_all(current());
358 g_signal_connect(G_OBJECT((GtkButton*)current()),
"released",reinterpret_cast<GCallback>(nf.
func), nf.
data);
359 gtk_widget_show(current());
374 g_signal_connect(G_OBJECT((GtkButton*)current()),
"released",reinterpret_cast<GCallback>(nf.
func), nf.
data);
375 gtk_widget_show(current());
387 static gboolean
exposePixmap(GtkWidget *widget, GdkEventExpose *event, gpointer data) {
388 GdkPixbuf *tipGDKPixBuf = gdk_pixbuf_new_from_xpm_data(static_cast<const char**>(data));
389 int width = gdk_pixbuf_get_width(tipGDKPixBuf), height = gdk_pixbuf_get_height(tipGDKPixBuf);
390 gint allocWidth, allocHeight, allocX;
391 #if GTK_MAJOR_VERSION==2 392 allocX=widget->allocation.x;
393 allocWidth=widget->allocation.width;
394 allocHeight=widget->allocation.height;
397 GtkAllocation widgetAlloc;
398 gtk_widget_get_allocation(widget, &widgetAlloc);
399 allocX=widgetAlloc.x;
400 allocWidth=widgetAlloc.width;
401 allocHeight=widgetAlloc.height;
404 if ((allocWidth<width) | (allocHeight<height))
405 gtk_widget_set_size_request(widget, width, height);
407 cairo_t *cr=gdk_cairo_create(gtk_widget_get_window(widget));
410 float xAlign, yAlign;
411 gtk_button_get_alignment(GTK_BUTTON(widget), &xAlign, &yAlign);
412 int xOffset=(int)((
float)(allocWidth-width-1)*xAlign);
413 if (xOffset<0) xOffset=0;
414 int yOffset=(int)((
float)(allocHeight-height-1)*yAlign);
415 if (yOffset<0) yOffset=0;
417 gdk_cairo_set_source_pixbuf(cr, tipGDKPixBuf, allocX+xOffset, allocX+yOffset);
436 if (pangoFontDescription) {
437 GtkWidget *child=gtk_bin_get_child(GTK_BIN(current()));
439 gtk_widget_modify_font(child,pangoFontDescription);
447 gtk_button_set_label(GTK_BUTTON(current()),l);
454 return gtk_button_get_label(GTK_BUTTON(current()));
464 GtkWidget *c=current();
467 for (
int i=1; i<=getCount(); i++) {
468 if (next()==widget) {
484 GtkWidget *retVal=NULL;
485 if (index<getCount() && index>0)
496 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wid), state);
505 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(current()), state);
514 return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(current()));
524 return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wid));
533 for (
int i=1; i<=getCount(); i++)
class to pass for creating a transparent XPM overlay on a button
ToggleFuncData(const char *s, GCallback f, gpointer d)
PixmapFuncData(const char **p, GCallback f, gpointer d)
CheckFuncData(const char *s, GCallback f, gpointer d)
const char ** pixGtk
The pixmap to show.
CheckFuncData(const char *s, void(*f)(void *, void *), gpointer d)
class to pass using operator<< for creating a regular pixmap on a button
PixmapFuncDataTransparent(const char **i, void(*f)(void *, void *), gpointer d)
LabelFuncData(const string &s, GCallback f, gpointer d)
class to pass using operator<< for creating a toggle button with a label
PixmapFuncDataTransparent(void)
GtkShadowType whichShadow
The shadow to use {GTK_SHADOW_NONE, GTK_SHADOW_IN, GTK_SHADOW_OUT, GTK_SHADOW_ETCHED_IN, GTK_SHADOW_ETCHED_OUT}.
CheckFuncData(const string &s, GCallback f, gpointer d)
LabelFuncData(const char *s, GCallback f, gpointer d)
class to pass using operator<< for creating a check button with a label
RadioFuncData(const string &s, GCallback f, gpointer d)
GtkArrowType whichArrow
The type of arrow to create {GTK_ARROW_UP, GTK_ARROW_DOWN, GTK_ARROW_LEFT, GTK_ARROW_RIGHT, GTK_ARROW_NONE}.
ArrowFuncData(GCallback f, gpointer d, GtkArrowType at, GtkShadowType sh, GtkWidget *a)
RadioFuncData(const char *s, void(*f)(void *, void *), gpointer d)
ArrowFuncData(void(*f)(void *, void *), gpointer d, GtkArrowType at, GtkShadowType sh, GtkWidget *a)
gpointer data
The data to pass to func when the button it pressed.
const char * str
The label to show in the button.
class to pass using operator<< for creating an arrow button
LabelFuncData(const char *s, void(*f)(void *, void *), gpointer d)
void add(TYPE newElement)
Adds as the current element ... Added to the next of the current lug.
class to pass using operator<< for creating a label button
std::ostream & operator<<(std::ostream &stream, const BitStream &bitStream)
AnyFuncData(const char *s, GCallback f, gpointer d)
void(* func)()
The function to call when the button is pressed.
AnyFuncData(const char *s, void(*f)(void *, void *), gpointer d)
PixmapFuncDataTransparent(const char **i, GCallback f, gpointer d)
const char ** imageXPM
The pointer to the image for overlaying on the button.
ToggleFuncData(const string &s, GCallback f, gpointer d)
ToggleFuncData(const char *s, void(*f)(void *, void *), gpointer d)
RadioFuncData(const char *s, GCallback f, gpointer d)
class to pass using operator<< for creating a radio button with a label
PixmapFuncData(const char **p, void(*f)(void *, void *), gpointer d)
AnyFuncData(const string &s, GCallback f, gpointer d)
class to pass using connectSignalAfter for connecting a signal to a widget