summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2010-04-07 23:17:33 +0000
committerMatthias Melcher <fltk@matthiasm.com>2010-04-07 23:17:33 +0000
commitf899c3897d62bd4f3c2d3bcaaf1ac5447ca8d158 (patch)
tree98d2c3bbfabae8ba92f3f31c825b4de700b391a1 /test
parent0fe65e94c98cee0baf9df8d60bef0137f42fdb92 (diff)
Added new flags for label alignment: FL_LEFT_TOP, FL_RIGHT_TOP, FL_LEFT_BOTTOM, and FL_RIGHT_BOTTOM align outside labels first to the side, then to the top or botton, filling a gap in possible alignment. Also FL_ALIGN_TEXT_NEXT_TO_IMAGE and FL_ALIGN_IMAGE_NEXT_TO_TEXT which do just that, and finally FL_ALIGN_IMAGE_BACKDROP which renders the image in the background and draws the label on top.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7469 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'test')
-rw-r--r--test/label.cxx30
1 files changed, 28 insertions, 2 deletions
diff --git a/test/label.cxx b/test/label.cxx
index 35927552f..2d5fee5cb 100644
--- a/test/label.cxx
+++ b/test/label.cxx
@@ -32,14 +32,19 @@
#include <FL/Fl_Toggle_Button.H>
#include <FL/Fl_Input.H>
#include <FL/Fl_Choice.H>
+#include <FL/Fl_Pixmap.H>
#include <FL/fl_draw.H>
+#include "pixmaps/blast.xpm"
+
+Fl_Toggle_Button *imageb, *imageovertextb, *imagenexttotextb, *imagebackdropb;
Fl_Toggle_Button *leftb,*rightb,*topb,*bottomb,*insideb,*clipb,*wrapb;
Fl_Box *text;
Fl_Input *input;
Fl_Hor_Value_Slider *fonts;
Fl_Hor_Value_Slider *sizes;
Fl_Double_Window *window;
+Fl_Pixmap *img;
void button_cb(Fl_Widget *,void *) {
int i = 0;
@@ -50,10 +55,21 @@ void button_cb(Fl_Widget *,void *) {
if (insideb->value()) i |= FL_ALIGN_INSIDE;
if (clipb->value()) i |= FL_ALIGN_CLIP;
if (wrapb->value()) i |= FL_ALIGN_WRAP;
+ if (imageovertextb->value()) i |= FL_ALIGN_TEXT_OVER_IMAGE;
+ if (imagenexttotextb->value()) i |= FL_ALIGN_TEXT_NEXT_TO_IMAGE;
+ if (imagebackdropb->value()) i |= FL_ALIGN_IMAGE_BACKDROP;
text->align(i);
window->redraw();
}
+void image_cb(Fl_Widget *,void *) {
+ if (imageb->value())
+ text->image(img);
+ else
+ text->image(0);
+ window->redraw();
+}
+
void font_cb(Fl_Widget *,void *) {
text->labelfont(int(fonts->value()));
window->redraw();
@@ -107,6 +123,8 @@ Fl_Menu_Item choices[] = {
{0}};
int main(int argc, char **argv) {
+ img = new Fl_Pixmap(blast_xpm);
+
window = new Fl_Double_Window(400,400);
input = new Fl_Input(50,375,350,25);
@@ -128,7 +146,15 @@ int main(int argc, char **argv) {
fonts->value(0);
fonts->callback(font_cb);
- Fl_Group *g = new Fl_Group(50,300,350,25);
+ Fl_Group *g = new Fl_Group(50,275,350,50);
+ imageb = new Fl_Toggle_Button(50,275,50,25,"image");
+ imageb->callback(image_cb);
+ imageovertextb = new Fl_Toggle_Button(100,275,50,25,"I - T");
+ imageovertextb->callback(button_cb);
+ imagenexttotextb = new Fl_Toggle_Button(150,275,50,25,"I | T");
+ imagenexttotextb->callback(button_cb);
+ imagebackdropb = new Fl_Toggle_Button(200,275,50,25,"back");
+ imagebackdropb->callback(button_cb);
leftb = new Fl_Toggle_Button(50,300,50,25,"left");
leftb->callback(button_cb);
rightb = new Fl_Toggle_Button(100,300,50,25,"right");
@@ -146,7 +172,7 @@ int main(int argc, char **argv) {
g->resizable(insideb);
g->end();
- Fl_Choice *c = new Fl_Choice(50,275,200,25);
+ Fl_Choice *c = new Fl_Choice(50,250,200,25);
c->menu(choices);
text= new Fl_Box(FL_FRAME_BOX,100,75,200,100,input->value());