summaryrefslogtreecommitdiff
path: root/fluid
diff options
context:
space:
mode:
Diffstat (limited to 'fluid')
-rw-r--r--fluid/Fl_Widget_Type.cxx76
-rw-r--r--fluid/README_fl.txt2
-rw-r--r--fluid/widget_panel.cxx51
-rw-r--r--fluid/widget_panel.fl31
-rw-r--r--fluid/widget_panel.h2
5 files changed, 144 insertions, 18 deletions
diff --git a/fluid/Fl_Widget_Type.cxx b/fluid/Fl_Widget_Type.cxx
index 6b86e6ae0..2e1cee809 100644
--- a/fluid/Fl_Widget_Type.cxx
+++ b/fluid/Fl_Widget_Type.cxx
@@ -1985,8 +1985,66 @@ void image_spacing_cb(Fl_Value_Input* i, void* v) {
Fl_Widget_Type* q = (Fl_Widget_Type*)o;
if (q->o->label_image_spacing() != s) {
q->o->label_image_spacing(s);
- if (q->o->parent())
- q->o->parent()->damage(FL_DAMAGE_EXPOSE); // outside labels
+ if (!(q->o->align() & FL_ALIGN_INSIDE) && q->o->window())
+ q->o->window()->damage(FL_DAMAGE_EXPOSE); // outside labels
+ q->o->redraw();
+ mod = 1;
+ }
+ }
+ }
+ if (mod) set_modflag(1);
+ }
+}
+
+void h_label_margin_cb(Fl_Value_Input* i, void* v) {
+ int s;
+ if (v == LOAD) {
+ if (!current_widget->is_true_widget()) {
+ i->deactivate();
+ i->value(0);
+ } else {
+ i->activate();
+ i->value(((Fl_Widget_Type*)current_widget)->o->horizontal_label_margin());
+ }
+ } else {
+ int mod = 0;
+ s = int(i->value());
+ for (Fl_Type *o = Fl_Type::first; o; o = o->next) {
+ if (o->selected && o->is_true_widget()) {
+ Fl_Widget_Type* q = (Fl_Widget_Type*)o;
+ if (q->o->horizontal_label_margin() != s) {
+ q->o->horizontal_label_margin(s);
+ if (!(q->o->align() & FL_ALIGN_INSIDE) && q->o->window())
+ q->o->window()->damage(FL_DAMAGE_EXPOSE); // outside labels
+ q->o->redraw();
+ mod = 1;
+ }
+ }
+ }
+ if (mod) set_modflag(1);
+ }
+}
+
+void v_label_margin_cb(Fl_Value_Input* i, void* v) {
+ int s;
+ if (v == LOAD) {
+ if (!current_widget->is_true_widget()) {
+ i->deactivate();
+ i->value(0);
+ } else {
+ i->activate();
+ i->value(((Fl_Widget_Type*)current_widget)->o->vertical_label_margin());
+ }
+ } else {
+ int mod = 0;
+ s = int(i->value());
+ for (Fl_Type *o = Fl_Type::first; o; o = o->next) {
+ if (o->selected && o->is_true_widget()) {
+ Fl_Widget_Type* q = (Fl_Widget_Type*)o;
+ if (q->o->vertical_label_margin() != s) {
+ q->o->vertical_label_margin(s);
+ if (!(q->o->align() & FL_ALIGN_INSIDE) && q->o->window())
+ q->o->window()->damage(FL_DAMAGE_EXPOSE); // outside labels
q->o->redraw();
mod = 1;
}
@@ -3218,6 +3276,12 @@ void Fl_Widget_Type::write_widget_code(Fd_Code_Writer& f) {
f.write_c("%s%s->labelsize(%d);\n", f.indent(), var, o->labelsize());
if (o->labelcolor() != tplate->labelcolor() || subclass())
write_color(f, "labelcolor", o->labelcolor());
+ if (o->horizontal_label_margin() != tplate->horizontal_label_margin())
+ f.write_c("%s%s->horizontal_label_margin(%d);\n", f.indent(), var, o->horizontal_label_margin());
+ if (o->vertical_label_margin() != tplate->vertical_label_margin())
+ f.write_c("%s%s->vertical_label_margin(%d);\n", f.indent(), var, o->vertical_label_margin());
+ if (o->label_image_spacing() != tplate->label_image_spacing())
+ f.write_c("%s%s->label_image_spacing(%d);\n", f.indent(), var, o->label_image_spacing());
if (is_a(ID_Valuator_)) {
Fl_Valuator* v = (Fl_Valuator*)o;
Fl_Valuator* t = (Fl_Valuator*)(tplate);
@@ -3397,6 +3461,10 @@ void Fl_Widget_Type::write_properties(Fd_Project_Writer &f) {
f.write_string("labelcolor %d", o->labelcolor());
if (o->align()!=tplate->align())
f.write_string("align %d", o->align());
+ if (o->horizontal_label_margin()!=tplate->horizontal_label_margin())
+ f.write_string("h_label_margin %d", o->horizontal_label_margin());
+ if (o->vertical_label_margin()!=tplate->vertical_label_margin())
+ f.write_string("v_label_margin %d", o->vertical_label_margin());
if (o->label_image_spacing()!=tplate->label_image_spacing())
f.write_string("image_spacing %d", o->label_image_spacing());
if (o->when() != tplate->when())
@@ -3568,6 +3636,10 @@ void Fl_Widget_Type::read_property(Fd_Project_Reader &f, const char *c) {
if (sscanf(f.read_word(),"%d",&x) == 1) o->labelcolor(x);
} else if (!strcmp(c,"align")) {
if (sscanf(f.read_word(),"%d",&x) == 1) o->align(x);
+ } else if (!strcmp(c,"h_label_margin")) {
+ if (sscanf(f.read_word(),"%d",&x) == 1) o->horizontal_label_margin(x);
+ } else if (!strcmp(c,"v_label_margin")) {
+ if (sscanf(f.read_word(),"%d",&x) == 1) o->vertical_label_margin(x);
} else if (!strcmp(c,"image_spacing")) {
if (sscanf(f.read_word(),"%d",&x) == 1) o->label_image_spacing(x);
} else if (!strcmp(c,"when")) {
diff --git a/fluid/README_fl.txt b/fluid/README_fl.txt
index 387d69f98..c52b4d091 100644
--- a/fluid/README_fl.txt
+++ b/fluid/README_fl.txt
@@ -468,6 +468,8 @@ Type "Fl_Widget" <word> : C++ variable name
"labelsize" <word> : integer
"labelcolor" <word> : integer, color index
"align" <word> : integer, see Fl_Align
+ "h_label_margin" <word> : integer, horizontal label margin
+ "v_label_margin" <word> : integer, vertical label margin
"image_spacing" <word> : integer, see Fl_Widget::label_image_spacing()
"when" <word> : integer, see Fl_When
"minimum" <word> : (is_valuator(), is_spinner()) double
diff --git a/fluid/widget_panel.cxx b/fluid/widget_panel.cxx
index a54ab7bfb..4280a3fce 100644
--- a/fluid/widget_panel.cxx
+++ b/fluid/widget_panel.cxx
@@ -1664,23 +1664,54 @@ Fl_Double_Window* make_widget_panel() {
} // Fl_Menu_Button* o
wp_style_text->end();
} // Fl_Group* wp_style_text
- { Fl_Value_Input* o = new Fl_Value_Input(99, 140, 49, 20, "Image Spacing:");
- o->tooltip("Gap between label image and text in pixels");
+ { Fl_Group* o = new Fl_Group(99, 150, 242, 20, "Label Margin:");
o->labelfont(1);
o->labelsize(11);
- o->maximum(100);
- o->step(1);
- o->value(14);
- o->textsize(11);
- o->callback((Fl_Callback*)image_spacing_cb);
- } // Fl_Value_Input* o
- { Fl_Light_Button* o = new Fl_Light_Button(99, 165, 90, 20, "Compact");
+ o->callback((Fl_Callback*)propagate_load);
+ o->align(Fl_Align(FL_ALIGN_LEFT));
+ { Fl_Value_Input* o = new Fl_Value_Input(99, 150, 55, 20, "Horizontal:");
+ o->tooltip("Spacing between label and the horizontally aligned side of the widget.");
+ o->labelsize(11);
+ o->minimum(-127);
+ o->maximum(128);
+ o->step(1);
+ o->textsize(11);
+ o->callback((Fl_Callback*)h_label_margin_cb);
+ o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
+ } // Fl_Value_Input* o
+ { Fl_Value_Input* o = new Fl_Value_Input(159, 150, 55, 20, "Vertical:");
+ o->tooltip("Spacing between label and the vertically aligned side of the widget.");
+ o->labelsize(11);
+ o->minimum(-127);
+ o->maximum(127);
+ o->step(1);
+ o->textsize(11);
+ o->callback((Fl_Callback*)v_label_margin_cb);
+ o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
+ } // Fl_Value_Input* o
+ { Fl_Value_Input* o = new Fl_Value_Input(219, 150, 55, 20, "Text to Image:");
+ o->tooltip("Gap between label image and text in pixels");
+ o->labelsize(11);
+ o->maximum(255);
+ o->step(1);
+ o->textsize(11);
+ o->callback((Fl_Callback*)image_spacing_cb);
+ o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
+ } // Fl_Value_Input* o
+ { Fl_Box* o = new Fl_Box(281, 150, 60, 20);
+ o->labelsize(11);
+ o->hide();
+ Fl_Group::current()->resizable(o);
+ } // Fl_Box* o
+ o->end();
+ } // Fl_Group* o
+ { Fl_Light_Button* o = new Fl_Light_Button(99, 175, 90, 20, "Compact");
o->tooltip("use compact box types for closely set buttons");
o->selection_color((Fl_Color)1);
o->labelsize(11);
o->callback((Fl_Callback*)compact_cb);
} // Fl_Light_Button* o
- { Fl_Box* o = new Fl_Box(195, 195, 40, 40);
+ { Fl_Box* o = new Fl_Box(195, 205, 40, 40);
o->labelsize(11);
Fl_Group::current()->resizable(o);
} // Fl_Box* o
diff --git a/fluid/widget_panel.fl b/fluid/widget_panel.fl
index e7f0b70b7..cdb5deabe 100644
--- a/fluid/widget_panel.fl
+++ b/fluid/widget_panel.fl
@@ -935,18 +935,37 @@ Use Ctrl-J for newlines.} xywh {95 285 310 20} labelfont 1 labelsize 11 textsize
code1 {o->menu(colormenu);}
} {}
}
- Fl_Value_Input {} {
- label {Image Spacing:}
- callback image_spacing_cb
- tooltip {Gap between label image and text in pixels} xywh {99 140 49 20} labelfont 1 labelsize 11 maximum 100 step 1 value 14 textsize 11
+ Fl_Group {} {
+ label {Label Margin:}
+ callback propagate_load open
+ xywh {99 150 242 20} labelfont 1 labelsize 11 align 4
+ } {
+ Fl_Value_Input {} {
+ label {Horizontal:}
+ callback h_label_margin_cb
+ tooltip {Spacing between label and the horizontally aligned side of the widget.} xywh {99 150 55 20} labelsize 11 align 5 minimum -127 maximum 128 step 1 textsize 11
+ }
+ Fl_Value_Input {} {
+ label {Vertical:}
+ callback v_label_margin_cb
+ tooltip {Spacing between label and the vertically aligned side of the widget.} xywh {159 150 55 20} labelsize 11 align 5 minimum -127 maximum 127 step 1 textsize 11
+ }
+ Fl_Value_Input {} {
+ label {Text to Image:}
+ callback image_spacing_cb
+ tooltip {Gap between label image and text in pixels} xywh {219 150 55 20} labelsize 11 align 5 maximum 255 step 1 textsize 11
+ }
+ Fl_Box {} {
+ xywh {281 150 60 20} labelsize 11 hide resizable
+ }
}
Fl_Light_Button {} {
label Compact
callback compact_cb
- tooltip {use compact box types for closely set buttons} xywh {99 165 90 20} selection_color 1 labelsize 11
+ tooltip {use compact box types for closely set buttons} xywh {99 175 90 20} selection_color 1 labelsize 11
}
Fl_Box {} {
- xywh {195 195 40 40} labelsize 11 resizable
+ xywh {195 205 40 40} labelsize 11 resizable
}
}
Fl_Group wp_cpp_tab {
diff --git a/fluid/widget_panel.h b/fluid/widget_panel.h
index 759cd9081..96022286c 100644
--- a/fluid/widget_panel.h
+++ b/fluid/widget_panel.h
@@ -144,6 +144,8 @@ extern void textsize_cb(Fl_Value_Input*, void*);
extern void textcolor_cb(Fl_Button*, void*);
extern Fl_Button *w_textcolor;
extern void textcolor_menu_cb(Fl_Menu_Button*, void*);
+extern void h_label_margin_cb(Fl_Value_Input*, void*);
+extern void v_label_margin_cb(Fl_Value_Input*, void*);
extern void image_spacing_cb(Fl_Value_Input*, void*);
extern void compact_cb(Fl_Light_Button*, void*);
extern Fl_Group *wp_cpp_tab;