diff options
| author | Matthias Melcher <github@matthiasm.com> | 2024-08-27 15:13:32 +0200 |
|---|---|---|
| committer | Matthias Melcher <github@matthiasm.com> | 2024-08-27 15:13:32 +0200 |
| commit | ec05f78d98d8e38ea34eb1bd73647fa5b8b35f81 (patch) | |
| tree | 64768c2ff44f44200e3d9d8463924fc9450be973 /test/label.cxx | |
| parent | 5879e7fae7d34c037f2ac02c6c7fca86c42a186d (diff) | |
Adding horiizonatl and vertical label margin
- sizeof(Fl_Widget) not increased
- label positions can be adjusted
- try it out in test/label app
- full support in FLUD
Diffstat (limited to 'test/label.cxx')
| -rw-r--r-- | test/label.cxx | 48 |
1 files changed, 38 insertions, 10 deletions
diff --git a/test/label.cxx b/test/label.cxx index de88b976b..f155132eb 100644 --- a/test/label.cxx +++ b/test/label.cxx @@ -32,7 +32,7 @@ Fl_Box *text; Fl_Input *input; Fl_Hor_Value_Slider *fonts; Fl_Hor_Value_Slider *sizes; -Fl_Hor_Value_Slider *spacing; +Fl_Hor_Value_Slider *h_margin, *v_margin, *img_spacing; Fl_Double_Window *window; Fl_Pixmap *img; @@ -65,8 +65,18 @@ void font_cb(Fl_Widget *,void *) { window->redraw(); } +void h_margin_cb(Fl_Widget *,void *) { + text->horizontal_label_margin(int(h_margin->value())); + window->redraw(); +} + +void v_margin_cb(Fl_Widget *,void *) { + text->vertical_label_margin(int(v_margin->value())); + window->redraw(); +} + void spacing_cb(Fl_Widget *,void *) { - text->label_image_spacing(int(spacing->value())); + text->label_image_spacing(int(img_spacing->value())); window->redraw(); } @@ -120,9 +130,9 @@ Fl_Menu_Item choices[] = { int main(int argc, char **argv) { img = new Fl_Pixmap(blast_xpm); - window = new Fl_Double_Window(440,445); + window = new Fl_Double_Window(440,495); - input = new Fl_Input(70,400,350,25,"Label:"); + input = new Fl_Input(70,435,350,25,"Label:"); input->static_value("The quick brown fox jumped over the lazy dog."); input->when(FL_WHEN_CHANGED); input->callback(input_cb); @@ -142,12 +152,30 @@ int main(int argc, char **argv) { fonts->value(0); fonts->callback(font_cb); - spacing=new Fl_Hor_Value_Slider(70,375,350,25,"Spacing:"); - spacing->align(FL_ALIGN_LEFT); - spacing->bounds(0,100); - spacing->step(1); - spacing->value(0); - spacing->callback(spacing_cb); + Fl_Box *margin = new Fl_Box(0, 380, 70, 25, "Margins"); + margin->box(FL_FLAT_BOX); + margin->align(FL_ALIGN_RIGHT|FL_ALIGN_INSIDE); + + h_margin = new Fl_Hor_Value_Slider(70+50,380,125,25,"Hor:"); + h_margin->align(FL_ALIGN_LEFT); + h_margin->bounds(-25,25); + h_margin->step(1); + h_margin->value(0); + h_margin->callback(h_margin_cb); + + v_margin = new Fl_Hor_Value_Slider(70+175+50,380,125,25,"Vert:"); + v_margin->align(FL_ALIGN_LEFT); + v_margin->bounds(-25,25); + v_margin->step(1); + v_margin->value(0); + v_margin->callback(v_margin_cb); + + img_spacing = new Fl_Hor_Value_Slider(70+50,405,125,25,"Image:"); + img_spacing->align(FL_ALIGN_LEFT); + img_spacing->bounds(0,50); + img_spacing->step(1); + img_spacing->value(0); + img_spacing->callback(spacing_cb); Fl_Group *g = new Fl_Group(70,275,350,50); imageb = new Fl_Toggle_Button(70,275,50,25,"image"); |
