mirror of
https://github.com/fltk/fltk.git
synced 2026-05-31 13:55:38 +08:00
Fix label/image problems.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1581 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
@@ -6,6 +6,13 @@ TODO - FLUID now supports image labels in addition to text
|
|||||||
TODO - Documentation updates.
|
TODO - Documentation updates.
|
||||||
|
|
||||||
|
|
||||||
|
CHANGES IN FLTK 1.1.0b2
|
||||||
|
|
||||||
|
- Fixed image/text label handling; in b1 the label needed
|
||||||
|
a non-blank text string to display the image. This bug
|
||||||
|
also caused all sorts of crashes and display problems.
|
||||||
|
|
||||||
|
|
||||||
CHANGES IN FLTK 1.1.0b1
|
CHANGES IN FLTK 1.1.0b1
|
||||||
|
|
||||||
- Added new image() and deimage() methods to support
|
- Added new image() and deimage() methods to support
|
||||||
|
|||||||
+28
-24
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// "$Id: fl_draw.cxx,v 1.6.2.4.2.3 2001/08/06 15:19:20 easysw Exp $"
|
// "$Id: fl_draw.cxx,v 1.6.2.4.2.4 2001/09/02 11:23:27 easysw Exp $"
|
||||||
//
|
//
|
||||||
// Label drawing code for the Fast Light Tool Kit (FLTK).
|
// Label drawing code for the Fast Light Tool Kit (FLTK).
|
||||||
//
|
//
|
||||||
@@ -149,13 +149,15 @@ void fl_draw(
|
|||||||
}
|
}
|
||||||
|
|
||||||
symtotal = symwidth[0] + symwidth[1];
|
symtotal = symwidth[0] + symwidth[1];
|
||||||
|
|
||||||
for (p = str, lines=0; p;) {
|
if (str) {
|
||||||
e = expand(p, buf, w - symtotal, buflen, width, align&FL_ALIGN_WRAP);
|
for (p = str, lines=0; p;) {
|
||||||
lines++;
|
e = expand(p, buf, w - symtotal, buflen, width, align&FL_ALIGN_WRAP);
|
||||||
if (!*e || *e == '@') break;
|
lines++;
|
||||||
p = e;
|
if (!*e || *e == '@') break;
|
||||||
}
|
p = e;
|
||||||
|
}
|
||||||
|
} else lines = 0;
|
||||||
|
|
||||||
if ((symwidth[0] || symwidth[1]) && lines) {
|
if ((symwidth[0] || symwidth[1]) && lines) {
|
||||||
if (symwidth[0]) symwidth[0] = lines * fl_height();
|
if (symwidth[0]) symwidth[0] = lines * fl_height();
|
||||||
@@ -189,24 +191,26 @@ void fl_draw(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// now draw all the lines:
|
// now draw all the lines:
|
||||||
int desc = fl_descent();
|
if (str) {
|
||||||
for (p=str; ; ypos += height) {
|
int desc = fl_descent();
|
||||||
if (lines>1) e = expand(p, buf, w - symtotal, buflen, width,
|
for (p=str; ; ypos += height) {
|
||||||
align&FL_ALIGN_WRAP);
|
if (lines>1) e = expand(p, buf, w - symtotal, buflen, width,
|
||||||
|
align&FL_ALIGN_WRAP);
|
||||||
|
|
||||||
if (width > symoffset) symoffset = (int)(width + 0.5);
|
if (width > symoffset) symoffset = (int)(width + 0.5);
|
||||||
|
|
||||||
if (align & FL_ALIGN_LEFT) xpos = x + symwidth[0];
|
if (align & FL_ALIGN_LEFT) xpos = x + symwidth[0];
|
||||||
else if (align & FL_ALIGN_RIGHT) xpos = x + w - (int)(width + .5) - symwidth[1];
|
else if (align & FL_ALIGN_RIGHT) xpos = x + w - (int)(width + .5) - symwidth[1];
|
||||||
else xpos = x + (w - (int)(width + .5) - symtotal) / 2 + symwidth[0];
|
else xpos = x + (w - (int)(width + .5) - symtotal) / 2 + symwidth[0];
|
||||||
|
|
||||||
callthis(buf,buflen,xpos,ypos-desc);
|
callthis(buf,buflen,xpos,ypos-desc);
|
||||||
|
|
||||||
if (underline_at)
|
if (underline_at)
|
||||||
callthis("_",1,xpos+int(fl_width(buf,underline_at-buf)),ypos-desc);
|
callthis("_",1,xpos+int(fl_width(buf,underline_at-buf)),ypos-desc);
|
||||||
|
|
||||||
if (!*e || *e == '@') break;
|
if (!*e || *e == '@') break;
|
||||||
p = e;
|
p = e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw the image if the "text over image" alignment flag is set...
|
// draw the image if the "text over image" alignment flag is set...
|
||||||
@@ -253,7 +257,7 @@ void fl_draw(
|
|||||||
int x, int y, int w, int h, // bounding box
|
int x, int y, int w, int h, // bounding box
|
||||||
Fl_Align align,
|
Fl_Align align,
|
||||||
Fl_Image* img) {
|
Fl_Image* img) {
|
||||||
if (!str || !*str) return;
|
if ((!str || !*str) && !img) return;
|
||||||
if (w && h && !fl_not_clipped(x, y, w, h)) return;
|
if (w && h && !fl_not_clipped(x, y, w, h)) return;
|
||||||
if (align & FL_ALIGN_CLIP) fl_clip(x, y, w, h);
|
if (align & FL_ALIGN_CLIP) fl_clip(x, y, w, h);
|
||||||
fl_draw(str, x, y, w, h, align, fl_draw, img);
|
fl_draw(str, x, y, w, h, align, fl_draw, img);
|
||||||
@@ -261,8 +265,8 @@ void fl_draw(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void fl_measure(const char* str, int& w, int& h) {
|
void fl_measure(const char* str, int& w, int& h) {
|
||||||
|
if (!str || !*str) {w = 0; h = 0; return;}
|
||||||
h = fl_height();
|
h = fl_height();
|
||||||
if (!str || !*str) {w = 0; return;}
|
|
||||||
const char* p;
|
const char* p;
|
||||||
const char* e;
|
const char* e;
|
||||||
char buf[MAXBUF];
|
char buf[MAXBUF];
|
||||||
@@ -318,5 +322,5 @@ void fl_measure(const char* str, int& w, int& h) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// End of "$Id: fl_draw.cxx,v 1.6.2.4.2.3 2001/08/06 15:19:20 easysw Exp $".
|
// End of "$Id: fl_draw.cxx,v 1.6.2.4.2.4 2001/09/02 11:23:27 easysw Exp $".
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// "$Id: fl_labeltype.cxx,v 1.6.2.3.2.2 2001/08/06 03:17:43 easysw Exp $"
|
// "$Id: fl_labeltype.cxx,v 1.6.2.3.2.3 2001/09/02 11:23:27 easysw Exp $"
|
||||||
//
|
//
|
||||||
// Label drawing routines for the Fast Light Tool Kit (FLTK).
|
// Label drawing routines for the Fast Light Tool Kit (FLTK).
|
||||||
//
|
//
|
||||||
@@ -31,6 +31,7 @@
|
|||||||
#include <FL/Fl_Widget.H>
|
#include <FL/Fl_Widget.H>
|
||||||
#include <FL/Fl_Group.H>
|
#include <FL/Fl_Group.H>
|
||||||
#include <FL/fl_draw.H>
|
#include <FL/fl_draw.H>
|
||||||
|
#include <FL/Fl_Image.H>
|
||||||
|
|
||||||
void
|
void
|
||||||
fl_no_label(const Fl_Label*,int,int,int,int,Fl_Align) {}
|
fl_no_label(const Fl_Label*,int,int,int,int,Fl_Align) {}
|
||||||
@@ -56,6 +57,10 @@ void
|
|||||||
fl_normal_measure(const Fl_Label* o, int& W, int& H) {
|
fl_normal_measure(const Fl_Label* o, int& W, int& H) {
|
||||||
fl_font(o->font, o->size);
|
fl_font(o->font, o->size);
|
||||||
fl_measure(o->value, W, H);
|
fl_measure(o->value, W, H);
|
||||||
|
if (o->image) {
|
||||||
|
if (o->image->w() > W) W = o->image->w();
|
||||||
|
H += o->image->h();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MAX_LABELTYPE 16
|
#define MAX_LABELTYPE 16
|
||||||
@@ -131,5 +136,5 @@ void Fl_Widget::draw_label(int X, int Y, int W, int H, Fl_Align a) const {
|
|||||||
#include <FL/Fl_Input_.H>
|
#include <FL/Fl_Input_.H>
|
||||||
|
|
||||||
//
|
//
|
||||||
// End of "$Id: fl_labeltype.cxx,v 1.6.2.3.2.2 2001/08/06 03:17:43 easysw Exp $".
|
// End of "$Id: fl_labeltype.cxx,v 1.6.2.3.2.3 2001/09/02 11:23:27 easysw Exp $".
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// "$Id: pixmap_browser.cxx,v 1.5.2.4 2001/01/22 15:13:41 easysw Exp $"
|
// "$Id: pixmap_browser.cxx,v 1.5.2.4.2.1 2001/09/02 11:23:27 easysw Exp $"
|
||||||
//
|
//
|
||||||
// Another pixmap test program for the Fast Light Tool Kit (FLTK).
|
// Another pixmap test program for the Fast Light Tool Kit (FLTK).
|
||||||
//
|
//
|
||||||
@@ -123,7 +123,8 @@ Fl_Pixmap *pixmap;
|
|||||||
void newpixmap() {
|
void newpixmap() {
|
||||||
delete pixmap;
|
delete pixmap;
|
||||||
pixmap = new Fl_Pixmap(data);
|
pixmap = new Fl_Pixmap(data);
|
||||||
pixmap->label(b);
|
b->image(pixmap);
|
||||||
|
b->redraw();
|
||||||
w->redraw();
|
w->redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,5 +166,5 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// End of "$Id: pixmap_browser.cxx,v 1.5.2.4 2001/01/22 15:13:41 easysw Exp $".
|
// End of "$Id: pixmap_browser.cxx,v 1.5.2.4.2.1 2001/09/02 11:23:27 easysw Exp $".
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user