summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2022-12-10 23:22:24 +0100
committerGitHub <noreply@github.com>2022-12-10 23:22:24 +0100
commita5adbd99ca073ecb9d6153b089543b23a673c9b5 (patch)
tree0e1bdebff56e5e0b23369b91b68a90fa42da4f65 /src
parent8dcd121d44f1b5041c83081277e2633745fa376d (diff)
Add option to bind images to a widget (#589)
Adding image binding to FLUID as well
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Widget.cxx40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/Fl_Widget.cxx b/src/Fl_Widget.cxx
index 2289dcf0b..1d1b71dc4 100644
--- a/src/Fl_Widget.cxx
+++ b/src/Fl_Widget.cxx
@@ -165,6 +165,8 @@ Fl_Widget::~Fl_Widget() {
Fl::clear_widget_pointer(this);
if (flags() & COPIED_LABEL) free((void *)(label_.value));
if (flags() & COPIED_TOOLTIP) free((void *)(tooltip_));
+ image(NULL);
+ deimage(NULL);
// remove from parent group
if (parent_) parent_->remove(this);
#ifdef DEBUG_DELETE
@@ -323,6 +325,44 @@ void Fl_Widget::copy_label(const char *a) {
}
}
+void Fl_Widget::image(Fl_Image* img) {
+ if (image_bound()) {
+ if (label_.image && (label_.image != img)) {
+ label_.image->release();
+ }
+ bind_image(0);
+ }
+ label_.image = img;
+}
+
+void Fl_Widget::image(Fl_Image& img) {
+ image(&img);
+}
+
+void Fl_Widget::bind_image(Fl_Image* img) {
+ image(img);
+ bind_image( (img != NULL) );
+}
+
+void Fl_Widget::deimage(Fl_Image* img) {
+ if (deimage_bound()) {
+ if (label_.deimage && (label_.deimage != img)) {
+ label_.deimage->release();
+ }
+ bind_deimage(0);
+ }
+ label_.deimage = img;
+}
+
+void Fl_Widget::deimage(Fl_Image& img) {
+ deimage(&img);
+}
+
+void Fl_Widget::bind_deimage(Fl_Image* img) {
+ deimage(img);
+ bind_deimage( (img != NULL) );
+}
+
/** Calls the widget callback function with arbitrary arguments.
All overloads of do_callback() call this method.