Enable all of the new FLUID stuff...

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1590 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Michael R Sweet
2001-09-29 06:20:15 +00:00
parent 50fc2f4806
commit 4c97599917
8 changed files with 229 additions and 104 deletions
+21 -5
View File
@@ -1,8 +1,3 @@
TODO - FLUID now provides on-line help.
TODO - FLUID now supports image labels in addition to text
labels + text over image alignment.
TODO - Documentation updates. TODO - Documentation updates.
@@ -12,25 +7,46 @@ CHANGES IN FLTK 1.1.0b2
needed a non-blank text string to display the image. needed a non-blank text string to display the image.
This bug also caused all sorts of crashes and display This bug also caused all sorts of crashes and display
problems. problems.
- Added new filetype() method to Fl_FileBrowser to allow - Added new filetype() method to Fl_FileBrowser to allow
for file or directory browsing. for file or directory browsing.
- Fixed the drawing of the focus box around - Fixed the drawing of the focus box around
Fl_Return_Button. Fl_Return_Button.
- Fixed menu item measurement bug (wasn't initializing - Fixed menu item measurement bug (wasn't initializing
image pointers to 0...) image pointers to 0...)
- Radio and checkbox menu items now draw with the new - Radio and checkbox menu items now draw with the new
style (round radio buttons with dots and square check style (round radio buttons with dots and square check
buttons with check marks.) buttons with check marks.)
- Improved the appearance of Fl_Check_Button. - Improved the appearance of Fl_Check_Button.
- Improved the Fl_HelpView table formatting code; now - Improved the Fl_HelpView table formatting code; now
dynamically sizes the table columns, and supports dynamically sizes the table columns, and supports
COLSPAN. COLSPAN.
- The FLUID keyboard shortcuts now work as expected - The FLUID keyboard shortcuts now work as expected
(CTRL-C copies, SHIFT-CTRL-C writes code, etc.) (CTRL-C copies, SHIFT-CTRL-C writes code, etc.)
- The FLTK_DOCDIR environment variable can now be - The FLTK_DOCDIR environment variable can now be
used to tell FLUID where to find the on-line used to tell FLUID where to find the on-line
documentation files. documentation files.
- FLUID now supports image labels in addition to text
labels + text over image alignment.
- FLUID now supports tooltips.
- The widget panel in FLUID is now tabbed, a la FLTK
2.0.
- The FLUID pixmap destructor tried to free 1 too many
lines of image data.
- FLUID now provides on-line help.
CHANGES IN FLTK 1.1.0b1 CHANGES IN FLTK 1.1.0b1
+13 -2
View File
@@ -1,5 +1,5 @@
// //
// "$Id: Fl_Type.h,v 1.5.2.11.2.1 2001/08/11 16:09:26 easysw Exp $" // "$Id: Fl_Type.h,v 1.5.2.11.2.2 2001/09/29 06:20:15 easysw Exp $"
// //
// Widget type header file for the Fast Light Tool Kit (FLTK). // Widget type header file for the Fast Light Tool Kit (FLTK).
// //
@@ -227,6 +227,9 @@ class Fl_Widget_Type : public Fl_Type {
const char *extra_code_[NUM_EXTRA_CODE]; const char *extra_code_[NUM_EXTRA_CODE];
const char *subclass_; const char *subclass_;
const char *tooltip_;
const char *image_name_;
const char *inactive_name_;
uchar hotspot_; uchar hotspot_;
protected: protected:
@@ -246,6 +249,8 @@ public:
Fluid_Image *image; Fluid_Image *image;
void setimage(Fluid_Image *); void setimage(Fluid_Image *);
Fluid_Image *inactive;
void setinactive(Fluid_Image *);
Fl_Widget_Type(); Fl_Widget_Type();
Fl_Type *make(); Fl_Type *make();
@@ -255,6 +260,12 @@ public:
void extra_code(int n,const char *); void extra_code(int n,const char *);
const char *subclass() const {return subclass_;} const char *subclass() const {return subclass_;}
void subclass(const char *); void subclass(const char *);
const char *tooltip() const {return tooltip_;}
void tooltip(const char *);
const char *image_name() const {return image_name_;}
void image_name(const char *);
const char *inactive_name() const {return inactive_name_;}
void inactive_name(const char *);
uchar hotspot() const {return hotspot_;} uchar hotspot() const {return hotspot_;}
void hotspot(uchar v) {hotspot_ = v;} void hotspot(uchar v) {hotspot_ = v;}
uchar resizable() const; uchar resizable() const;
@@ -549,5 +560,5 @@ int storestring(const char *n, const char * & p, int nostrip=0);
extern int include_H_from_C; extern int include_H_from_C;
// //
// End of "$Id: Fl_Type.h,v 1.5.2.11.2.1 2001/08/11 16:09:26 easysw Exp $". // End of "$Id: Fl_Type.h,v 1.5.2.11.2.2 2001/09/29 06:20:15 easysw Exp $".
// //
+128 -41
View File
@@ -1,5 +1,5 @@
// //
// "$Id: Fl_Widget_Type.cxx,v 1.15.2.16.2.2 2001/09/29 03:36:27 easysw Exp $" // "$Id: Fl_Widget_Type.cxx,v 1.15.2.16.2.3 2001/09/29 06:20:15 easysw Exp $"
// //
// Widget type code for the Fast Light Tool Kit (FLTK). // Widget type code for the Fast Light Tool Kit (FLTK).
// //
@@ -146,19 +146,20 @@ void Fl_Widget_Type::setimage(Fluid_Image *i) {
if (image) image->decrement(); if (image) image->decrement();
if (i) i->increment(); if (i) i->increment();
image = i; image = i;
if (i) i->label(o); i->image(o);
else o->labeltype(FL_NORMAL_LABEL); redraw();
}
void Fl_Widget_Type::setinactive(Fluid_Image *i) {
if (i == inactive) return;
if (inactive) inactive->decrement();
if (i) i->increment();
inactive = i;
i->deimage(o);
redraw(); redraw();
} }
static char dont_touch_image;
void Fl_Widget_Type::setlabel(const char *n) { void Fl_Widget_Type::setlabel(const char *n) {
if (image) {
if (dont_touch_image) return;
Fluid_Image *i = Fluid_Image::find(n);
setimage(i);
if (i) return;
}
o->label(n); o->label(n);
redraw(); redraw();
} }
@@ -166,7 +167,11 @@ void Fl_Widget_Type::setlabel(const char *n) {
Fl_Widget_Type::Fl_Widget_Type() { Fl_Widget_Type::Fl_Widget_Type() {
for (int n=0; n<NUM_EXTRA_CODE; n++) {extra_code_[n] = 0; subclass_ = 0;} for (int n=0; n<NUM_EXTRA_CODE; n++) {extra_code_[n] = 0; subclass_ = 0;}
hotspot_ = 0; hotspot_ = 0;
tooltip_ = 0;
image_name_ = 0;
inactive_name_ = 0;
image = 0; image = 0;
inactive = 0;
xclass = 0; xclass = 0;
o = 0; o = 0;
public_ = 1; public_ = 1;
@@ -190,6 +195,21 @@ void Fl_Widget_Type::subclass(const char *n) {
redraw_browser(); redraw_browser();
} }
void Fl_Widget_Type::tooltip(const char *n) {
storestring(n,tooltip_);
o->tooltip(n);
}
void Fl_Widget_Type::image_name(const char *n) {
setimage(Fluid_Image::find(n));
storestring(n,image_name_);
}
void Fl_Widget_Type::inactive_name(const char *n) {
setinactive(Fluid_Image::find(n));
storestring(n,inactive_name_);
}
void Fl_Widget_Type::redraw() { void Fl_Widget_Type::redraw() {
Fl_Type *t = this; Fl_Type *t = this;
if (is_menu_item()) { if (is_menu_item()) {
@@ -296,15 +316,26 @@ static Fl_Input *image_input;
void image_cb(Fl_Input* i, void *v) { void image_cb(Fl_Input* i, void *v) {
if (v == LOAD) { if (v == LOAD) {
image_input = i; image_input = i;
// i->static_value(current_widget->label()); if (current_widget->is_widget()) {
i->activate();
i->static_value(((Fl_Widget_Type*)current_widget)->image_name());
} else i->deactivate();
} else { } else {
// for (Fl_Type *o = Fl_Type::first; o; o = o->next) for (Fl_Type *o = Fl_Type::first; o; o = o->next)
// if (o->selected && o->is_widget()) o->label(i->value()); if (o->selected && o->is_widget()) ((Fl_Widget_Type*)o)->image_name(i->value());
} }
} }
void image_browse_cb(Fl_Button* b, void *v) { void image_browse_cb(Fl_Button* b, void *v) {
if (v != LOAD) { if (v == LOAD) {
if (current_widget->is_widget()) b->activate();
else b->deactivate();
} else {
if (ui_find_image(image_input->value())) {
image_input->value(ui_find_image_name);
for (Fl_Type *o = Fl_Type::first; o; o = o->next)
if (o->selected && o->is_widget()) ((Fl_Widget_Type*)o)->image_name(ui_find_image_name);
}
} }
} }
@@ -313,15 +344,41 @@ static Fl_Input *inactive_input;
void inactive_cb(Fl_Input* i, void *v) { void inactive_cb(Fl_Input* i, void *v) {
if (v == LOAD) { if (v == LOAD) {
inactive_input = i; inactive_input = i;
// i->static_value(current_widget->label()); if (current_widget->is_widget()) {
i->activate();
i->static_value(((Fl_Widget_Type*)current_widget)->inactive_name());
} else i->deactivate();
} else { } else {
// for (Fl_Type *o = Fl_Type::first; o; o = o->next) for (Fl_Type *o = Fl_Type::first; o; o = o->next)
// if (o->selected && o->is_widget()) o->label(i->value()); if (o->selected && o->is_widget()) ((Fl_Widget_Type*)o)->inactive_name(i->value());
} }
} }
void inactive_browse_cb(Fl_Button* b, void *v) { void inactive_browse_cb(Fl_Button* b, void *v) {
if (v != LOAD) { if (v == LOAD) {
if (current_widget->is_widget()) b->activate();
else b->deactivate();
} else {
if (ui_find_image(inactive_input->value())) {
inactive_input->value(ui_find_image_name);
for (Fl_Type *o = Fl_Type::first; o; o = o->next)
if (o->selected && o->is_widget()) ((Fl_Widget_Type*)o)->inactive_name(ui_find_image_name);
}
}
}
static Fl_Input *tooltip_input;
void tooltip_cb(Fl_Input* i, void *v) {
if (v == LOAD) {
tooltip_input = i;
if (current_widget->is_widget()) {
i->activate();
i->static_value(((Fl_Widget_Type*)current_widget)->tooltip());
} else i->deactivate();
} else {
for (Fl_Type *o = Fl_Type::first; o; o = o->next)
if (o->selected && o->is_widget()) ((Fl_Widget_Type*)o)->tooltip(i->value());
} }
} }
@@ -724,6 +781,7 @@ void labelsize_cb(Fl_Value_Input* i, void *v) {
} }
extern const char *ui_find_image_name; extern const char *ui_find_image_name;
#if 0
void image_cb(Fl_Widget *a, void *) { void image_cb(Fl_Widget *a, void *) {
Fluid_Image *i = ui_find_image(current_widget->label()); Fluid_Image *i = ui_find_image(current_widget->label());
if (!ui_find_image_name) return; // user hit "Cancel" if (!ui_find_image_name) return; // user hit "Cancel"
@@ -740,11 +798,10 @@ void image_cb(Fl_Widget *a, void *) {
label_cb(label_input,LOAD); label_cb(label_input,LOAD);
a->when(FL_WHEN_RELEASE|FL_WHEN_NOT_CHANGED); a->when(FL_WHEN_RELEASE|FL_WHEN_NOT_CHANGED);
} }
#endif /* 0 */
Fl_Menu_Item labeltypemenu[] = { Fl_Menu_Item labeltypemenu[] = {
{"Image...",0,image_cb,(void*)(-1)},
{"NORMAL_LABEL",0,0,(void*)0}, {"NORMAL_LABEL",0,0,(void*)0},
{"SYMBOL_LABEL",0,0,(void*)FL_SYMBOL_LABEL},
{"SHADOW_LABEL",0,0,(void*)FL_SHADOW_LABEL}, {"SHADOW_LABEL",0,0,(void*)FL_SHADOW_LABEL},
{"ENGRAVED_LABEL",0,0,(void*)FL_ENGRAVED_LABEL}, {"ENGRAVED_LABEL",0,0,(void*)FL_ENGRAVED_LABEL},
{"EMBOSSED_LABEL",0,0,(void*)FL_EMBOSSED_LABEL}, {"EMBOSSED_LABEL",0,0,(void*)FL_EMBOSSED_LABEL},
@@ -754,27 +811,17 @@ Fl_Menu_Item labeltypemenu[] = {
void labeltype_cb(Fl_Choice* i, void *v) { void labeltype_cb(Fl_Choice* i, void *v) {
if (v == LOAD) { if (v == LOAD) {
int n; int n;
if (current_widget->image) { n = current_widget->o->labeltype();
n = -1; i->when(FL_WHEN_RELEASE);
i->when(FL_WHEN_RELEASE|FL_WHEN_NOT_CHANGED);
} else {
n = current_widget->o->labeltype();
i->when(FL_WHEN_RELEASE);
}
for (int j = 0; j < int(sizeof(labeltypemenu)/sizeof(*labeltypemenu)); j++) for (int j = 0; j < int(sizeof(labeltypemenu)/sizeof(*labeltypemenu)); j++)
if (labeltypemenu[j].argument() == n) {i->value(j); break;} if (labeltypemenu[j].argument() == n) {i->value(j); break;}
} else { } else {
int m = i->value(); int m = i->value();
int n = int(labeltypemenu[m].argument()); int n = int(labeltypemenu[m].argument());
if (n<0) return; // should not happen if (n<0) return; // should not happen
if (current_widget->image) label_input->activate();
for (Fl_Type *o = Fl_Type::first; o; o = o->next) for (Fl_Type *o = Fl_Type::first; o; o = o->next)
if (o->selected && o->is_widget()) { if (o->selected && o->is_widget()) {
Fl_Widget_Type* p = (Fl_Widget_Type*)o; Fl_Widget_Type* p = (Fl_Widget_Type*)o;
if (p->image) {
p->setimage(0);
p->o->label(p->label());
}
p->o->labeltype((Fl_Labeltype)n); p->o->labeltype((Fl_Labeltype)n);
p->redraw(); p->redraw();
} }
@@ -846,6 +893,7 @@ static Fl_Menu_Item alignmenu[] = {
{"FL_ALIGN_INSIDE",0,0,(void*)(FL_ALIGN_INSIDE)}, {"FL_ALIGN_INSIDE",0,0,(void*)(FL_ALIGN_INSIDE)},
{"FL_ALIGN_CLIP",0,0,(void*)(FL_ALIGN_CLIP)}, {"FL_ALIGN_CLIP",0,0,(void*)(FL_ALIGN_CLIP)},
{"FL_ALIGN_WRAP",0,0,(void*)(FL_ALIGN_WRAP)}, {"FL_ALIGN_WRAP",0,0,(void*)(FL_ALIGN_WRAP)},
{"FL_ALIGN_TEXT_OVER_IMAGE",0,0,(void*)(FL_ALIGN_TEXT_OVER_IMAGE)},
{"FL_ALIGN_TOP_LEFT",0,0,(void*)(FL_ALIGN_TOP_LEFT)}, {"FL_ALIGN_TOP_LEFT",0,0,(void*)(FL_ALIGN_TOP_LEFT)},
{"FL_ALIGN_TOP_RIGHT",0,0,(void*)(FL_ALIGN_TOP_RIGHT)}, {"FL_ALIGN_TOP_RIGHT",0,0,(void*)(FL_ALIGN_TOP_RIGHT)},
{"FL_ALIGN_BOTTOM_LEFT",0,0,(void*)(FL_ALIGN_BOTTOM_LEFT)}, {"FL_ALIGN_BOTTOM_LEFT",0,0,(void*)(FL_ALIGN_BOTTOM_LEFT)},
@@ -1437,7 +1485,7 @@ void Fl_Widget_Type::write_code1() {
} else { } else {
write_c("new %s(%d, %d, %d, %d", t, o->x(), o->y(), o->w(), o->h()); write_c("new %s(%d, %d, %d, %d", t, o->x(), o->y(), o->w(), o->h());
} }
if (!image && label() && *label()) { if (label() && *label()) {
write_c(", "); write_c(", ");
switch (i18n_type) { switch (i18n_type) {
case 0 : /* None */ case 0 : /* None */
@@ -1458,6 +1506,7 @@ void Fl_Widget_Type::write_code1() {
} }
write_c(");\n"); write_c(");\n");
indentation += 2; indentation += 2;
if (is_window()) write_c("%sw = o;\n",indent()); if (is_window()) write_c("%sw = o;\n",indent());
if (varused) write_widget_code(); if (varused) write_widget_code();
} }
@@ -1465,6 +1514,27 @@ void Fl_Widget_Type::write_code1() {
// this is split from write_code1() for Fl_Window_Type: // this is split from write_code1() for Fl_Window_Type:
void Fl_Widget_Type::write_widget_code() { void Fl_Widget_Type::write_widget_code() {
Fl_Widget* tplate = ((Fl_Widget_Type*)factory)->o; Fl_Widget* tplate = ((Fl_Widget_Type*)factory)->o;
if (tooltip() && *tooltip()) {
write_c("%so->tooltip(",indent());
switch (i18n_type) {
case 0 : /* None */
write_cstring(tooltip());
break;
case 1 : /* GNU gettext */
write_c("%s(", i18n_function);
write_cstring(tooltip());
write_c(")");
break;
case 2 : /* POSIX catgets */
write_c("catgets(%s,%s,%d,", i18n_file[0] ? i18n_file : "_catalog",
i18n_set, msgnum());
write_cstring(tooltip());
write_c(")");
break;
}
write_c(");\n");
}
if (o->type() != tplate->type() && !is_window()) if (o->type() != tplate->type() && !is_window())
write_c("%so->type(%d);\n", indent(), o->type()); write_c("%so->type(%d);\n", indent(), o->type());
if (o->box() != tplate->box()) if (o->box() != tplate->box())
@@ -1486,9 +1556,9 @@ void Fl_Widget_Type::write_widget_code() {
write_c("%so->color(%d);\n", indent(), o->color()); write_c("%so->color(%d);\n", indent(), o->color());
if (o->selection_color() != tplate->selection_color()) if (o->selection_color() != tplate->selection_color())
write_c("%so->selection_color(%d);\n", indent(), o->selection_color()); write_c("%so->selection_color(%d);\n", indent(), o->selection_color());
if (image) if (image) image->write_code();
image->write_code(); if (inactive) inactive->write_code(1);
else if (o->labeltype() != tplate->labeltype()) if (o->labeltype() != tplate->labeltype())
write_c("%so->labeltype(FL_%s);\n", indent(), write_c("%so->labeltype(FL_%s);\n", indent(),
item_name(labeltypemenu, o->labeltype())); item_name(labeltypemenu, o->labeltype()));
if (o->labelfont() != tplate->labelfont()) if (o->labelfont() != tplate->labelfont())
@@ -1572,6 +1642,18 @@ void Fl_Widget_Type::write_properties() {
Fl_Type::write_properties(); Fl_Type::write_properties();
write_indent(level+1); write_indent(level+1);
if (!public_) write_string("private"); if (!public_) write_string("private");
if (tooltip() && *tooltip()) {
write_string("tooltip");
write_word(o->tooltip());
}
if (image_name() && *image_name()) {
write_string("image");
write_word(image_name());
}
if (inactive_name() && *inactive_name()) {
write_string("deimage");
write_word(inactive_name());
}
write_string("xywh {%d %d %d %d}", o->x(), o->y(), o->w(), o->h()); write_string("xywh {%d %d %d %d}", o->x(), o->y(), o->w(), o->h());
Fl_Widget* tplate = ((Fl_Widget_Type*)factory)->o; Fl_Widget* tplate = ((Fl_Widget_Type*)factory)->o;
if (o->type() != tplate->type()) { if (o->type() != tplate->type()) {
@@ -1596,9 +1678,7 @@ void Fl_Widget_Type::write_properties() {
write_string("color %d", o->color()); write_string("color %d", o->color());
if (o->selection_color()!=tplate->selection_color()) if (o->selection_color()!=tplate->selection_color())
write_string("selection_color %d", o->selection_color()); write_string("selection_color %d", o->selection_color());
if (image) if (o->labeltype()!=tplate->labeltype()) {
write_string("labeltype image");
else if (o->labeltype()!=tplate->labeltype()) {
write_string("labeltype"); write_string("labeltype");
write_word(item_name(labeltypemenu, o->labeltype())); write_word(item_name(labeltypemenu, o->labeltype()));
} }
@@ -1659,6 +1739,12 @@ void Fl_Widget_Type::read_property(const char *c) {
y += pasteoffset; y += pasteoffset;
o->resize(x,y,w,h); o->resize(x,y,w,h);
} }
} else if (!strcmp(c,"tooltip")) {
tooltip(read_word());
} else if (!strcmp(c,"image")) {
image_name(read_word());
} else if (!strcmp(c,"deimage")) {
inactive_name(read_word());
} else if (!strcmp(c,"type")) { } else if (!strcmp(c,"type")) {
o->type(item_number(subtypes(), read_word())); o->type(item_number(subtypes(), read_word()));
} else if (!strcmp(c,"box")) { } else if (!strcmp(c,"box")) {
@@ -1698,6 +1784,8 @@ void Fl_Widget_Type::read_property(const char *c) {
Fluid_Image *i = Fluid_Image::find(label()); Fluid_Image *i = Fluid_Image::find(label());
if (!i) read_error("Image file '%s' not found", label()); if (!i) read_error("Image file '%s' not found", label());
else setimage(i); else setimage(i);
image_name(label());
label("");
} else { } else {
o->labeltype((Fl_Labeltype)item_number(labeltypemenu,c)); o->labeltype((Fl_Labeltype)item_number(labeltypemenu,c));
} }
@@ -1791,7 +1879,6 @@ int Fl_Widget_Type::read_fdesign(const char* name, const char* value) {
} }
} else if (!strcmp(name,"label")) { } else if (!strcmp(name,"label")) {
label(value); label(value);
if (value[0] == '@') o->labeltype(FL_SYMBOL_LABEL);
} else if (!strcmp(name,"name")) { } else if (!strcmp(name,"name")) {
this->name(value); this->name(value);
} else if (!strcmp(name,"callback")) { } else if (!strcmp(name,"callback")) {
@@ -1868,5 +1955,5 @@ int Fl_Widget_Type::read_fdesign(const char* name, const char* value) {
} }
// //
// End of "$Id: Fl_Widget_Type.cxx,v 1.15.2.16.2.2 2001/09/29 03:36:27 easysw Exp $". // End of "$Id: Fl_Widget_Type.cxx,v 1.15.2.16.2.3 2001/09/29 06:20:15 easysw Exp $".
// //
+29 -15
View File
@@ -1,5 +1,5 @@
// //
// "$Id: Fluid_Image.cxx,v 1.7.2.9.2.1 2001/08/05 23:58:54 easysw Exp $" // "$Id: Fluid_Image.cxx,v 1.7.2.9.2.2 2001/09/29 06:20:15 easysw Exp $"
// //
// Pixmap label support for the Fast Light Tool Kit (FLTK). // Pixmap label support for the Fast Light Tool Kit (FLTK).
// //
@@ -48,9 +48,10 @@ protected:
public: public:
pixmap_image(const char *name, FILE *); pixmap_image(const char *name, FILE *);
~pixmap_image(); ~pixmap_image();
virtual void label(Fl_Widget *); // set the label of this widget virtual void image(Fl_Widget *); // set the image of this widget
virtual void deimage(Fl_Widget *); // set the deimage of this widget
virtual void write_static(); virtual void write_static();
virtual void write_code(); virtual void write_code(int inactive = 0);
static int test_file(char *buffer); static int test_file(char *buffer);
}; };
@@ -58,8 +59,12 @@ int pixmap_image::test_file(char *buffer) {
return (strstr(buffer,"/* XPM") != 0); return (strstr(buffer,"/* XPM") != 0);
} }
void pixmap_image::label(Fl_Widget *o) { void pixmap_image::image(Fl_Widget *o) {
if (p) p->label(o); o->image(p);
}
void pixmap_image::deimage(Fl_Widget *o) {
o->deimage(p);
} }
static int pixmap_header_written; static int pixmap_header_written;
@@ -84,9 +89,9 @@ void pixmap_image::write_static() {
unique_id(this, "image", filename_name(name()), 0)); unique_id(this, "image", filename_name(name()), 0));
} }
void pixmap_image::write_code() { void pixmap_image::write_code(int inactive) {
if (!p) return; if (!p) return;
write_c("%s%s.label(o);\n", indent(), write_c("%so->%s(%s);\n", indent(), inactive ? "deimage" : "image",
unique_id(this, "pixmap", filename_name(name()), 0)); unique_id(this, "pixmap", filename_name(name()), 0));
} }
@@ -101,6 +106,10 @@ static int hexdigit(int x) {
#define INITIALLINES 1024 #define INITIALLINES 1024
pixmap_image::pixmap_image(const char *name, FILE *f) : Fluid_Image(name) { pixmap_image::pixmap_image(const char *name, FILE *f) : Fluid_Image(name) {
p = 0;
numlines = 0;
linelength = 0;
if (!f) return; // for subclasses if (!f) return; // for subclasses
// read all the c-strings out of the file: // read all the c-strings out of the file:
char* local_data[INITIALLINES]; char* local_data[INITIALLINES];
@@ -181,7 +190,7 @@ pixmap_image::pixmap_image(const char *name, FILE *f) : Fluid_Image(name) {
pixmap_image::~pixmap_image() { pixmap_image::~pixmap_image() {
if (p && p->data) { if (p && p->data) {
char** real_data = (char**)(p->data); char** real_data = (char**)(p->data);
for (int i = 0; real_data[i]; i++) delete[] real_data[i]; for (int i = 0; i < numlines; i++) delete[] real_data[i];
free((void*)real_data); free((void*)real_data);
} }
free((void*)linelength); free((void*)linelength);
@@ -234,9 +243,10 @@ class bitmap_image : public Fluid_Image {
public: public:
~bitmap_image(); ~bitmap_image();
bitmap_image(const char *name, FILE *); bitmap_image(const char *name, FILE *);
virtual void label(Fl_Widget *); // set the label of this widget virtual void image(Fl_Widget *); // set the image of this widget
virtual void deimage(Fl_Widget *); // set the deimage of this widget
virtual void write_static(); virtual void write_static();
virtual void write_code(); virtual void write_code(int inactive = 0);
static int test_file(char *buffer); static int test_file(char *buffer);
}; };
@@ -245,8 +255,12 @@ int bitmap_image::test_file(char *buffer) {
return (strstr(buffer,"#define ") != 0); return (strstr(buffer,"#define ") != 0);
} }
void bitmap_image::label(Fl_Widget *o) { void bitmap_image::image(Fl_Widget *o) {
if (p) p->label(o); else o->labeltype(FL_NORMAL_LABEL); o->image(p);
}
void bitmap_image::deimage(Fl_Widget *o) {
o->deimage(p);
} }
static int bitmap_header_written; static int bitmap_header_written;
@@ -284,9 +298,9 @@ void bitmap_image::write_static() {
p->w(), p->h()); p->w(), p->h());
} }
void bitmap_image::write_code() { void bitmap_image::write_code(int inactive) {
if (!p) return; if (!p) return;
write_c("%s%s.label(o);\n", indent(), write_c("%so->%s(%s);\n", indent(), inactive ? "deimage" : "image",
unique_id(this, "bitmap", filename_name(name()), 0)); unique_id(this, "bitmap", filename_name(name()), 0));
} }
@@ -436,5 +450,5 @@ Fluid_Image *ui_find_image(const char *oldname) {
} }
// //
// End of "$Id: Fluid_Image.cxx,v 1.7.2.9.2.1 2001/08/05 23:58:54 easysw Exp $". // End of "$Id: Fluid_Image.cxx,v 1.7.2.9.2.2 2001/09/29 06:20:15 easysw Exp $".
// //
+6 -4
View File
@@ -1,5 +1,5 @@
// //
// "$Id: Fluid_Image.h,v 1.3.2.4 2001/01/22 15:13:38 easysw Exp $" // "$Id: Fluid_Image.h,v 1.3.2.4.2.1 2001/09/29 06:20:15 easysw Exp $"
// //
// Pixmap image header file for the Fast Light Tool Kit (FLTK). // Pixmap image header file for the Fast Light Tool Kit (FLTK).
// //
@@ -43,18 +43,20 @@ public:
static Fluid_Image* find(const char *); static Fluid_Image* find(const char *);
void decrement(); // reference counting & automatic free void decrement(); // reference counting & automatic free
void increment(); void increment();
virtual void label(Fl_Widget *) = 0; // set the label of this widget virtual void image(Fl_Widget *) = 0; // set the image of this widget
virtual void deimage(Fl_Widget *) = 0; // set the deimage of this widget
virtual void write_static() = 0; virtual void write_static() = 0;
virtual void write_code() = 0; virtual void write_code(int inactive = 0) = 0;
const char *name() const {return name_;} const char *name() const {return name_;}
}; };
// pop up file chooser and return a legal image selected by user, // pop up file chooser and return a legal image selected by user,
// or zero for any errors: // or zero for any errors:
Fluid_Image *ui_find_image(const char *); Fluid_Image *ui_find_image(const char *);
extern const char *ui_find_image_name;
#endif #endif
// //
// End of "$Id: Fluid_Image.h,v 1.3.2.4 2001/01/22 15:13:38 easysw Exp $". // End of "$Id: Fluid_Image.h,v 1.3.2.4.2.1 2001/09/29 06:20:15 easysw Exp $".
// //
+8 -15
View File
@@ -31,16 +31,16 @@ Fl_Window* make_widget_panel() {
} }
{ Fl_Input* o = new Fl_Input(95, 65, 195, 20, "Image:"); { Fl_Input* o = new Fl_Input(95, 65, 195, 20, "Image:");
o->callback((Fl_Callback*)image_cb); o->callback((Fl_Callback*)image_cb);
o->when(FL_WHEN_CHANGED);
} }
{ Fl_Button* o = new Fl_Button(290, 65, 105, 20, "Browse..."); { Fl_Button* o = new Fl_Button(290, 65, 105, 20, "Browse...");
o->tooltip("}");
o->callback((Fl_Callback*)image_browse_cb); o->callback((Fl_Callback*)image_browse_cb);
} }
{ Fl_Input* o = new Fl_Input(95, 90, 195, 20, "Inactive:"); { Fl_Input* o = new Fl_Input(95, 90, 195, 20, "Inactive:");
o->callback((Fl_Callback*)inactive_cb); o->callback((Fl_Callback*)inactive_cb);
o->when(FL_WHEN_CHANGED);
} }
{ Fl_Button* o = new Fl_Button(290, 90, 105, 20, "Browse..."); { Fl_Button* o = new Fl_Button(290, 90, 105, 20, "Browse...");
o->tooltip("}");
o->callback((Fl_Callback*)inactive_browse_cb); o->callback((Fl_Callback*)inactive_browse_cb);
} }
{ Fl_Value_Input* o = new Fl_Value_Input(95, 150, 60, 20, "X:"); { Fl_Value_Input* o = new Fl_Value_Input(95, 150, 60, 20, "X:");
@@ -87,7 +87,7 @@ Fl_Window* make_widget_panel() {
{ Fl_Button* o = new Fl_Button(175, 115, 55, 20, "text\nimage"); { Fl_Button* o = new Fl_Button(175, 115, 55, 20, "text\nimage");
o->type(1); o->type(1);
o->labelsize(8); o->labelsize(8);
o->callback((Fl_Callback*)align_cb, (void*)(FL_ALIGN_WRAP)); o->callback((Fl_Callback*)align_cb, (void*)(FL_ALIGN_TEXT_OVER_IMAGE));
} }
{ Fl_Button* o = new Fl_Button(295, 115, 20, 20, "@-1<-"); { Fl_Button* o = new Fl_Button(295, 115, 20, 20, "@-1<-");
o->type(1); o->type(1);
@@ -204,9 +204,11 @@ Fl_Window* make_widget_panel() {
} }
{ Fl_Input* o = new Fl_Input(95, 235, 115, 20, "X Class:"); { Fl_Input* o = new Fl_Input(95, 235, 115, 20, "X Class:");
o->callback((Fl_Callback*)xclass_cb); o->callback((Fl_Callback*)xclass_cb);
o->when(FL_WHEN_NEVER);
} }
new Fl_Input(95, 285, 300, 20, "Tooltip:"); { Fl_Input* o = new Fl_Input(95, 285, 300, 20, "Tooltip:");
o->tooltip("}");
o->callback((Fl_Callback*)tooltip_cb);
}
o->end(); o->end();
} }
{ Fl_Group* o = new Fl_Group(10, 30, 395, 295, "Style"); { Fl_Group* o = new Fl_Group(10, 30, 395, 295, "Style");
@@ -273,7 +275,6 @@ Fl_Window* make_widget_panel() {
o->hide(); o->hide();
{ Fl_Input* o = new Fl_Input(100, 65, 230, 20, "Name:"); { Fl_Input* o = new Fl_Input(100, 65, 230, 20, "Name:");
o->callback((Fl_Callback*)name_cb); o->callback((Fl_Callback*)name_cb);
o->when(FL_WHEN_NEVER);
} }
{ Fl_Light_Button* o = new Fl_Light_Button(330, 65, 65, 20, "public"); { Fl_Light_Button* o = new Fl_Light_Button(330, 65, 65, 20, "public");
o->selection_color(1); o->selection_color(1);
@@ -284,7 +285,6 @@ Fl_Window* make_widget_panel() {
{ Fl_Input* o = new Fl_Input(100, 40, 160, 20, "Class:"); { Fl_Input* o = new Fl_Input(100, 40, 160, 20, "Class:");
o->textfont(4); o->textfont(4);
o->callback((Fl_Callback*)subclass_cb, (void*)(4)); o->callback((Fl_Callback*)subclass_cb, (void*)(4));
o->when(FL_WHEN_NEVER);
} }
{ Fl_Choice* o = new Fl_Choice(260, 40, 135, 20); { Fl_Choice* o = new Fl_Choice(260, 40, 135, 20);
o->box(FL_THIN_UP_BOX); o->box(FL_THIN_UP_BOX);
@@ -294,22 +294,18 @@ Fl_Window* make_widget_panel() {
{ Fl_Input* o = v_input[0] = new Fl_Input(100, 90, 295, 20, "Extra Code:"); { Fl_Input* o = v_input[0] = new Fl_Input(100, 90, 295, 20, "Extra Code:");
o->textfont(4); o->textfont(4);
o->callback((Fl_Callback*)v_input_cb, (void*)(0)); o->callback((Fl_Callback*)v_input_cb, (void*)(0));
o->when(FL_WHEN_NEVER);
} }
{ Fl_Input* o = v_input[1] = new Fl_Input(100, 110, 295, 20); { Fl_Input* o = v_input[1] = new Fl_Input(100, 110, 295, 20);
o->textfont(4); o->textfont(4);
o->callback((Fl_Callback*)v_input_cb, (void*)(1)); o->callback((Fl_Callback*)v_input_cb, (void*)(1));
o->when(FL_WHEN_NEVER);
} }
{ Fl_Input* o = v_input[2] = new Fl_Input(100, 130, 295, 20); { Fl_Input* o = v_input[2] = new Fl_Input(100, 130, 295, 20);
o->textfont(4); o->textfont(4);
o->callback((Fl_Callback*)v_input_cb, (void*)(2)); o->callback((Fl_Callback*)v_input_cb, (void*)(2));
o->when(FL_WHEN_NEVER);
} }
{ Fl_Input* o = v_input[3] = new Fl_Input(100, 150, 295, 20); { Fl_Input* o = v_input[3] = new Fl_Input(100, 150, 295, 20);
o->textfont(4); o->textfont(4);
o->callback((Fl_Callback*)v_input_cb, (void*)(3)); o->callback((Fl_Callback*)v_input_cb, (void*)(3));
o->when(FL_WHEN_NEVER);
} }
{ Fl_Box* o = new Fl_Box(20, 175, 75, 20, "Callback:"); { Fl_Box* o = new Fl_Box(20, 175, 75, 20, "Callback:");
o->align(FL_ALIGN_RIGHT|FL_ALIGN_INSIDE); o->align(FL_ALIGN_RIGHT|FL_ALIGN_INSIDE);
@@ -318,7 +314,6 @@ Fl_Window* make_widget_panel() {
o->type(4); o->type(4);
o->textfont(4); o->textfont(4);
o->callback((Fl_Callback*)callback_cb); o->callback((Fl_Callback*)callback_cb);
o->when(FL_WHEN_NEVER);
} }
{ Fl_Box* o = new Fl_Box(95, 325, 100, 0, "label"); { Fl_Box* o = new Fl_Box(95, 325, 100, 0, "label");
o->hide(); o->hide();
@@ -327,18 +322,16 @@ Fl_Window* make_widget_panel() {
{ Fl_Input* o = new Fl_Input(100, 270, 140, 20, "User Data:"); { Fl_Input* o = new Fl_Input(100, 270, 140, 20, "User Data:");
o->textfont(4); o->textfont(4);
o->callback((Fl_Callback*)user_data_cb); o->callback((Fl_Callback*)user_data_cb);
o->when(FL_WHEN_NEVER);
} }
{ Fl_Input* o = new Fl_Input(100, 295, 140, 20, "Type:"); { Fl_Input* o = new Fl_Input(100, 295, 140, 20, "Type:");
o->textfont(4); o->textfont(4);
o->callback((Fl_Callback*)user_data_type_cb); o->callback((Fl_Callback*)user_data_type_cb);
o->when(FL_WHEN_NEVER);
} }
{ Fl_Choice* o = new Fl_Choice(290, 270, 105, 20, "When:"); { Fl_Choice* o = new Fl_Choice(290, 270, 105, 20, "When:");
o->box(FL_THIN_UP_BOX); o->box(FL_THIN_UP_BOX);
o->down_box(FL_BORDER_BOX); o->down_box(FL_BORDER_BOX);
o->callback((Fl_Callback*)when_cb); o->callback((Fl_Callback*)when_cb);
o->when(FL_WHEN_NEVER); o->when(FL_WHEN_CHANGED);
o->menu(whenmenu); o->menu(whenmenu);
} }
{ Fl_Light_Button* o = new Fl_Light_Button(290, 295, 105, 20, "No Change"); { Fl_Light_Button* o = new Fl_Light_Button(290, 295, 105, 20, "No Change");
+23 -22
View File
@@ -33,41 +33,41 @@ Function {make_widget_panel()} {open
Fl_Input {} { Fl_Input {} {
label {Image:} label {Image:}
callback image_cb callback image_cb
xywh {95 65 195 20} when 1 xywh {95 65 195 20}
} }
Fl_Button {} { Fl_Button {} {
label {Browse...} label {Browse...}
callback image_browse_cb callback image_browse_cb
xywh {290 65 105 20} tooltip {\}} xywh {290 65 105 20}
} }
Fl_Input {} { Fl_Input {} {
label {Inactive:} label {Inactive:}
callback inactive_cb callback inactive_cb
xywh {95 90 195 20} when 1 xywh {95 90 195 20}
} }
Fl_Button {} { Fl_Button {} {
label {Browse...} label {Browse...}
callback inactive_browse_cb callback inactive_browse_cb
xywh {290 90 105 20} tooltip {\}} xywh {290 90 105 20}
} }
Fl_Value_Input {} { Fl_Value_Input {} {
label {X:} label {X:}
callback x_cb selected callback x_cb
xywh {95 150 60 20} labelsize 10 align 5 maximum 2048 step 1 xywh {95 150 60 20} labelsize 10 align 5 maximum 2048 step 1
} }
Fl_Value_Input {} { Fl_Value_Input {} {
label {Y:} label {Y:}
callback y_cb selected callback y_cb
xywh {155 150 60 20} labelsize 10 align 5 maximum 2048 step 1 xywh {155 150 60 20} labelsize 10 align 5 maximum 2048 step 1
} }
Fl_Value_Input {} { Fl_Value_Input {} {
label {Width:} label {Width:}
callback w_cb selected callback w_cb
xywh {215 150 60 20} labelsize 10 align 5 maximum 2048 step 1 xywh {215 150 60 20} labelsize 10 align 5 maximum 2048 step 1
} }
Fl_Value_Input {} { Fl_Value_Input {} {
label {Height:} label {Height:}
callback h_cb selected callback h_cb
xywh {275 150 60 20} labelsize 10 align 5 maximum 2048 step 1 xywh {275 150 60 20} labelsize 10 align 5 maximum 2048 step 1
} }
Fl_Group {} { Fl_Group {} {
@@ -90,7 +90,7 @@ Function {make_widget_panel()} {open
Fl_Button {} { Fl_Button {} {
label {text label {text
image} image}
user_data FL_ALIGN_WRAP user_data FL_ALIGN_TEXT_OVER_IMAGE
callback align_cb callback align_cb
xywh {175 115 55 20} type Toggle labelsize 8 xywh {175 115 55 20} type Toggle labelsize 8
} }
@@ -212,11 +212,12 @@ image}
Fl_Input {} { Fl_Input {} {
label {X Class:} label {X Class:}
callback xclass_cb callback xclass_cb
xywh {95 235 115 20} when 0 xywh {95 235 115 20}
} }
Fl_Input {} { Fl_Input {} {
label {Tooltip:} label {Tooltip:}
xywh {95 285 300 20} callback tooltip_cb
tooltip {\}} xywh {95 285 300 20}
} }
} }
Fl_Group {} { Fl_Group {} {
@@ -289,7 +290,7 @@ image}
Fl_Input {} { Fl_Input {} {
label {Name:} label {Name:}
callback name_cb callback name_cb
xywh {100 65 230 20} when 0 xywh {100 65 230 20}
} }
Fl_Light_Button {} { Fl_Light_Button {} {
label public label public
@@ -300,7 +301,7 @@ image}
label {Class:} label {Class:}
user_data 4 user_data 4
callback subclass_cb callback subclass_cb
xywh {100 40 160 20} when 0 textfont 4 xywh {100 40 160 20} textfont 4
} }
Fl_Choice {} { Fl_Choice {} {
callback subtype_cb open callback subtype_cb open
@@ -310,22 +311,22 @@ image}
label {Extra Code:} label {Extra Code:}
user_data 0 user_data 0
callback v_input_cb callback v_input_cb
xywh {100 90 295 20} when 0 textfont 4 xywh {100 90 295 20} textfont 4
} }
Fl_Input {v_input[1]} { Fl_Input {v_input[1]} {
user_data 1 user_data 1
callback v_input_cb callback v_input_cb
xywh {100 110 295 20} when 0 textfont 4 xywh {100 110 295 20} textfont 4
} }
Fl_Input {v_input[2]} { Fl_Input {v_input[2]} {
user_data 2 user_data 2
callback v_input_cb callback v_input_cb
xywh {100 130 295 20} when 0 textfont 4 xywh {100 130 295 20} textfont 4
} }
Fl_Input {v_input[3]} { Fl_Input {v_input[3]} {
user_data 3 user_data 3
callback v_input_cb callback v_input_cb
xywh {100 150 295 20} when 0 textfont 4 xywh {100 150 295 20} textfont 4
} }
Fl_Box {} { Fl_Box {} {
label {Callback:} label {Callback:}
@@ -333,7 +334,7 @@ image}
} }
Fl_Input {} { Fl_Input {} {
callback callback_cb callback callback_cb
xywh {100 175 295 90} type Multiline when 0 textfont 4 xywh {100 175 295 90} type Multiline textfont 4
} }
Fl_Box {} { Fl_Box {} {
label label label label
@@ -342,17 +343,17 @@ image}
Fl_Input {} { Fl_Input {} {
label {User Data:} label {User Data:}
callback user_data_cb callback user_data_cb
xywh {100 270 140 20} when 0 textfont 4 xywh {100 270 140 20} textfont 4
} }
Fl_Input {} { Fl_Input {} {
label {Type:} label {Type:}
callback user_data_type_cb callback user_data_type_cb
xywh {100 295 140 20} when 0 textfont 4 xywh {100 295 140 20} textfont 4
} }
Fl_Choice {} { Fl_Choice {} {
label {When:} label {When:}
callback when_cb open callback when_cb open
xywh {290 270 105 20} box THIN_UP_BOX down_box BORDER_BOX when 0 xywh {290 270 105 20} box THIN_UP_BOX down_box BORDER_BOX when 1
code0 {extern Fl_Menu_Item whenmenu[];} code0 {extern Fl_Menu_Item whenmenu[];}
code1 {o->menu(whenmenu);} code1 {o->menu(whenmenu);}
} {} } {}
@@ -383,7 +384,7 @@ image}
} }
Fl_Return_Button {} { Fl_Return_Button {} {
label OK label OK
callback ok_cb callback ok_cb selected
xywh {240 335 80 25} xywh {240 335 80 25}
} }
} }
+1
View File
@@ -40,6 +40,7 @@ extern void active_cb(Fl_Light_Button*, void*);
extern void resizable_cb(Fl_Light_Button*, void*); extern void resizable_cb(Fl_Light_Button*, void*);
extern void hotspot_cb(Fl_Light_Button*, void*); extern void hotspot_cb(Fl_Light_Button*, void*);
extern void xclass_cb(Fl_Input*, void*); extern void xclass_cb(Fl_Input*, void*);
extern void tooltip_cb(Fl_Input*, void*);
extern Fl_Menu_Item fontmenu[]; extern Fl_Menu_Item fontmenu[];
extern void labelfont_cb(Fl_Choice*, void*); extern void labelfont_cb(Fl_Choice*, void*);
extern void labelsize_cb(Fl_Value_Input*, void*); extern void labelsize_cb(Fl_Value_Input*, void*);