summaryrefslogtreecommitdiff
path: root/fluid
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2009-10-02 19:08:55 +0000
committerMatthias Melcher <fltk@matthiasm.com>2009-10-02 19:08:55 +0000
commit1238d1576b8e2bc15c097b23ebe0fdc4d3cdb527 (patch)
tree47ee6159eb30ae6bb15722ecc91b6ee8b85bb460 /fluid
parentf1ef3c10477609be6bea13f7e49d137631fa9297 (diff)
Very crude extension of Fluid 1 to read Fluid 2 files (and possibly write them back as Fluid 1 files, but not Fluid 2!). Also, I started a README that points out the differences between FLTK 1 and FLTK 2 and tries to give some help in designing a downward compatible FLTK 3.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6912 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'fluid')
-rw-r--r--fluid/Fl_Type.h14
-rw-r--r--fluid/Fl_Widget_Type.cxx30
-rw-r--r--fluid/factory.cxx41
-rw-r--r--fluid/file.cxx2
4 files changed, 72 insertions, 15 deletions
diff --git a/fluid/Fl_Type.h b/fluid/Fl_Type.h
index 88e0b2197..cfe1292d2 100644
--- a/fluid/Fl_Type.h
+++ b/fluid/Fl_Type.h
@@ -92,6 +92,7 @@ public:
virtual const char *title(); // string for browser
virtual const char *type_name() = 0; // type for code output
+ virtual const char *alt_type_name() { return type_name(); } // alternate type for FLTK2 code output
const char *name() const {return name_;}
void name(const char *);
@@ -393,6 +394,7 @@ public:
class Fl_Group_Type : public Fl_Widget_Type {
public:
virtual const char *type_name() {return "Fl_Group";}
+ virtual const char *alt_type_name() {return "fltk::Group";}
Fl_Widget *widget(int X,int Y,int W,int H) {
igroup *g = new igroup(X,Y,W,H); Fl_Group::current(0); return g;}
Fl_Widget_Type *_make() {return new Fl_Group_Type();}
@@ -418,6 +420,7 @@ class Fl_Pack_Type : public Fl_Group_Type {
Fl_Menu_Item *subtypes() {return pack_type_menu;}
public:
virtual const char *type_name() {return pack_type_name;}
+ virtual const char *alt_type_name() {return "fltk::PackedGroup";}
Fl_Widget_Type *_make() {return new Fl_Pack_Type();}
int pixmapID() { return 22; }
void copy_properties();
@@ -433,6 +436,7 @@ public:
y = fl_height() + o->labelsize() - 6;
}
virtual const char *type_name() {return tabs_type_name;}
+ virtual const char *alt_type_name() {return "fltk::TabGroup";}
Fl_Widget *widget(int X,int Y,int W,int H) {
itabs *g = new itabs(X,Y,W,H); Fl_Group::current(0); return g;}
Fl_Widget_Type *_make() {return new Fl_Tabs_Type();}
@@ -450,6 +454,7 @@ class Fl_Scroll_Type : public Fl_Group_Type {
Fl_Menu_Item *subtypes() {return scroll_type_menu;}
public:
virtual const char *type_name() {return scroll_type_name;}
+ virtual const char *alt_type_name() {return "fltk::ScrollGroup";}
Fl_Widget_Type *_make() {return new Fl_Scroll_Type();}
int pixmapID() { return 19; }
Fl_Widget *enter_live_mode(int top=0);
@@ -461,6 +466,7 @@ extern const char tile_type_name[];
class Fl_Tile_Type : public Fl_Group_Type {
public:
virtual const char *type_name() {return tile_type_name;}
+ virtual const char *alt_type_name() {return "fltk::TileGroup";}
Fl_Widget_Type *_make() {return new Fl_Tile_Type();}
int pixmapID() { return 20; }
void copy_properties();
@@ -471,6 +477,7 @@ extern const char wizard_type_name[];
class Fl_Wizard_Type : public Fl_Group_Type {
public:
virtual const char *type_name() {return wizard_type_name;}
+ virtual const char *alt_type_name() {return "fltk::WizardGroup";}
Fl_Widget *widget(int X,int Y,int W,int H) {
iwizard *g = new iwizard(X,Y,W,H); Fl_Group::current(0); return g;}
Fl_Widget_Type *_make() {return new Fl_Wizard_Type();}
@@ -513,6 +520,7 @@ public:
Fl_Type *make();
virtual const char *type_name() {return "Fl_Window";}
+ virtual const char *alt_type_name() {return "fltk::Window";}
void open();
@@ -569,6 +577,7 @@ class Fl_Menu_Item_Type : public Fl_Widget_Type {
public:
Fl_Menu_Item* subtypes() {return menu_item_type_menu;}
const char* type_name() {return "MenuItem";}
+ const char* alt_type_name() {return "fltk::Item";}
Fl_Type* make();
int is_menu_item() const {return 1;}
int is_button() const {return 1;} // this gets shortcut to work
@@ -587,6 +596,7 @@ class Fl_Submenu_Type : public Fl_Menu_Item_Type {
public:
Fl_Menu_Item* subtypes() {return 0;}
const char* type_name() {return "Submenu";}
+ const char* alt_type_name() {return "fltk::ItemGroup";}
int is_parent() const {return 1;}
int is_button() const {return 0;} // disable shortcut
Fl_Type* make();
@@ -643,6 +653,7 @@ public:
if (w < (15 + h)) w = 15 + h;
}
virtual const char *type_name() {return "Fl_Menu_Button";}
+ virtual const char *alt_type_name() {return "fltk::MenuButton";}
Fl_Widget *widget(int X,int Y,int W,int H) {
return new Fl_Menu_Button(X,Y,W,H,"menu");}
Fl_Widget_Type *_make() {return new Fl_Menu_Button_Type();}
@@ -666,6 +677,7 @@ public:
if (w < (15 + h)) w = 15 + h;
}
virtual const char *type_name() {return "Fl_Choice";}
+ virtual const char *alt_type_name() {return "fltk::Choice";}
Fl_Widget *widget(int X,int Y,int W,int H) {
Fl_Choice *myo = new Fl_Choice(X,Y,W,H,"choice:");
myo->menu(dummymenu);
@@ -700,6 +712,7 @@ public:
if (w < (15 + h)) w = 15 + h;
}
virtual const char *type_name() {return "Fl_Input_Choice";}
+ virtual const char *alt_type_name() {return "fltk::ComboBox";}
virtual Fl_Type* click_test(int,int);
Fl_Widget *widget(int X,int Y,int W,int H) {
Fl_Input_Choice *myo = new Fl_Input_Choice(X,Y,W,H,"input choice:");
@@ -723,6 +736,7 @@ public:
if (h < 15) h = 15;
}
virtual const char *type_name() {return "Fl_Menu_Bar";}
+ virtual const char *alt_type_name() {return "fltk::MenuBar";}
Fl_Widget *widget(int X,int Y,int W,int H) {return new Fl_Menu_Bar(X,Y,W,H);}
Fl_Widget_Type *_make() {return new Fl_Menu_Bar_Type();}
int pixmapID() { return 17; }
diff --git a/fluid/Fl_Widget_Type.cxx b/fluid/Fl_Widget_Type.cxx
index 8fe4c9edf..dc6215dec 100644
--- a/fluid/Fl_Widget_Type.cxx
+++ b/fluid/Fl_Widget_Type.cxx
@@ -2431,7 +2431,7 @@ void Fl_Widget_Type::write_properties() {
}
int pasteoffset;
-
+extern double read_version;
void Fl_Widget_Type::read_property(const char *c) {
int x,y,w,h; Fl_Font f; int s; Fl_Color cc;
if (!strcmp(c,"private")) {
@@ -2442,6 +2442,11 @@ void Fl_Widget_Type::read_property(const char *c) {
if (sscanf(read_word(),"%d %d %d %d",&x,&y,&w,&h) == 4) {
x += pasteoffset;
y += pasteoffset;
+ // FIXME temporary change!
+ if (read_version>=2.0 && o->parent() && o->parent()!=o->window()) {
+ x += o->parent()->x();
+ y += o->parent()->y();
+ }
o->resize(x,y,w,h);
}
} else if (!strcmp(c,"tooltip")) {
@@ -2483,12 +2488,18 @@ void Fl_Widget_Type::read_property(const char *c) {
const char* value = read_word();
((Fl_Button*)o)->value(atoi(value));
} else if (!strcmp(c,"color")) {
- int n = sscanf(read_word(),"%d %d",&x,&y);
- if (n == 2) { // back compatibility...
- if (x != 47) o->color(x);
- o->selection_color(y);
- } else {
+ const char *cw = read_word();
+ if (cw[0]=='0' && cw[1]=='x') {
+ sscanf(cw,"0x%x",&x);
o->color(x);
+ } else {
+ int n = sscanf(cw,"%d %d",&x,&y);
+ if (n == 2) { // back compatibility...
+ if (x != 47) o->color(x);
+ o->selection_color(y);
+ } else {
+ o->color(x);
+ }
}
} else if (!strcmp(c,"selection_color")) {
if (sscanf(read_word(),"%d",&x)) o->selection_color(x);
@@ -2553,9 +2564,12 @@ void Fl_Widget_Type::read_property(const char *c) {
if (!strncmp(c,"code",4)) {
int n = atoi(c+4);
if (n >= 0 && n <= NUM_EXTRA_CODE) {
- extra_code(n,read_word());
- return;
+ extra_code(n,read_word());
+ return;
}
+ } else if (!strcmp(c,"extra_code")) {
+ extra_code(0,read_word());
+ return;
}
Fl_Type::read_property(c);
}
diff --git a/fluid/factory.cxx b/fluid/factory.cxx
index 176067a5d..fae67a929 100644
--- a/fluid/factory.cxx
+++ b/fluid/factory.cxx
@@ -77,6 +77,7 @@ strcasecmp(const char *s, const char *t) {
class Fl_Box_Type : public Fl_Widget_Type {
public:
virtual const char *type_name() {return "Fl_Box";}
+ virtual const char *alt_type_name() {return "fltk::Widget";}
Fl_Widget *widget(int x,int y,int w, int h) {
return new Fl_Box(x,y,w,h,"label");}
Fl_Widget_Type *_make() {return new Fl_Box_Type();}
@@ -101,6 +102,7 @@ public:
h = (h / 5) * 5;
}
virtual const char *type_name() {return "Fl_Button";}
+ virtual const char *alt_type_name() {return "fltk::Button";}
Fl_Widget *widget(int x,int y,int w,int h) {
return new Fl_Button(x,y,w,h,"button");}
Fl_Widget_Type *_make() {return new Fl_Button_Type();}
@@ -121,6 +123,7 @@ public:
w += W + 8 - o->labelsize();
}
virtual const char *type_name() {return "Fl_Return_Button";}
+ virtual const char *alt_type_name() {return "fltk::ReturnButton";}
Fl_Widget *widget(int x,int y,int w,int h) {
return new Fl_Return_Button(x,y,w,h,"button");}
Fl_Widget_Type *_make() {return new Fl_Return_Button_Type();}
@@ -134,6 +137,7 @@ static Fl_Return_Button_Type Fl_Return_Button_type;
class Fl_Repeat_Button_Type : public Fl_Widget_Type {
public:
virtual const char *type_name() {return "Fl_Repeat_Button";}
+ virtual const char *alt_type_name() {return "fltk::RepeatButton";}
Fl_Widget *widget(int x,int y,int w,int h) {
return new Fl_Repeat_Button(x,y,w,h,"button");}
Fl_Widget_Type *_make() {return new Fl_Repeat_Button_Type();}
@@ -151,6 +155,7 @@ public:
w += 4;
}
virtual const char *type_name() {return "Fl_Light_Button";}
+ virtual const char *alt_type_name() {return "fltk::LightButton";}
Fl_Widget *widget(int x,int y,int w,int h) {
return new Fl_Light_Button(x,y,w,h,"button");}
Fl_Widget_Type *_make() {return new Fl_Light_Button_Type();}
@@ -168,6 +173,7 @@ public:
w += 4;
}
virtual const char *type_name() {return "Fl_Check_Button";}
+ virtual const char *alt_type_name() {return "fltk::CheckButton";}
Fl_Widget *widget(int x,int y,int w,int h) {
return new Fl_Check_Button(x,y,w,h,"button");}
Fl_Widget_Type *_make() {return new Fl_Check_Button_Type();}
@@ -185,6 +191,7 @@ public:
w += 4;
}
virtual const char *type_name() {return "Fl_Round_Button";}
+ virtual const char *alt_type_name() {return "fltk::RadioButton";}
Fl_Widget *widget(int x,int y,int w,int h) {
return new Fl_Round_Button(x,y,w,h,"button");}
Fl_Widget_Type *_make() {return new Fl_Round_Button_Type();}
@@ -223,6 +230,7 @@ public:
if (w < 50) w = 50;
}
virtual const char *type_name() {return "Fl_Browser";}
+ virtual const char *alt_type_name() {return "fltk::Browser";}
Fl_Widget *widget(int x,int y,int w,int h) {
Fl_Browser* b = new Fl_Browser(x,y,w,h);
// Fl_Browser::add calls fl_height(), which requires the X display open.
@@ -270,6 +278,7 @@ public:
if (w < 50) w = 50;
}
virtual const char *type_name() {return "Fl_Check_Browser";}
+ virtual const char *alt_type_name() {return "fltk::CheckBrowser";}
Fl_Widget *widget(int x,int y,int w,int h) {
Fl_Check_Browser* b = new Fl_Check_Browser(x,y,w,h);
// Fl_Check_Browser::add calls fl_height(), which requires the X display open.
@@ -317,6 +326,7 @@ public:
if (w < 50) w = 50;
}
virtual const char *type_name() {return "Fl_File_Browser";}
+ virtual const char *alt_type_name() {return "fltk::FileBrowser";}
Fl_Widget *widget(int x,int y,int w,int h) {
Fl_File_Browser* b = new Fl_File_Browser(x,y,w,h);
// Fl_File_Browser::add calls fl_height(), which requires the X display open.
@@ -357,6 +367,7 @@ class Fl_Counter_Type : public Fl_Widget_Type {
int pixmapID() { return 41; }
public:
virtual const char *type_name() {return "Fl_Counter";}
+ virtual const char *alt_type_name() {return "fltk::Counter";}
Fl_Widget *widget(int x,int y,int w,int h) {
return new Fl_Counter(x,y,w,h,"counter:");}
Fl_Widget_Type *_make() {return new Fl_Counter_Type();}
@@ -398,6 +409,7 @@ public:
if (w < 40) w = 40 ;
}
virtual const char *type_name() {return "Fl_Spinner";}
+ virtual const char *alt_type_name() {return "fltk::Spinner";}
int is_spinner() const { return 1; }
Fl_Widget *widget(int x,int y,int w,int h) {
return new Fl_Spinner(x,y,w,h,"spinner:");}
@@ -442,6 +454,7 @@ public:
if (w < 15) w = 15;
}
virtual const char *type_name() {return "Fl_Input";}
+ virtual const char *alt_type_name() {return "fltk::Input";}
int is_input() const {return 1;}
Fl_Widget *widget(int x,int y,int w,int h) {
Fl_Input *myo = new Fl_Input(x,y,w,h,"input:");
@@ -491,6 +504,7 @@ public:
if (w < 50) w = 50;
}
virtual const char *type_name() {return "Fl_File_Input";}
+ virtual const char *alt_type_name() {return "fltk::FileInput";}
int is_input() const {return 1;}
Fl_Widget *widget(int x,int y,int w,int h) {
Fl_File_Input *myo = new Fl_File_Input(x,y,w,h,"file:");
@@ -533,6 +547,7 @@ public:
if (w < 50) w = 50;
}
virtual const char *type_name() {return "Fl_Text_Display";}
+ virtual const char *alt_type_name() {return "fltk::TextDisplay";}
int is_text_display() const {return 1;}
Fl_Widget *widget(int x,int y,int w,int h) {
Fl_Text_Display *myo = new Fl_Text_Display(x,y,w,h);
@@ -574,6 +589,7 @@ public:
if (w < 50) w = 50;
}
virtual const char *type_name() {return "Fl_Text_Editor";}
+ virtual const char *alt_type_name() {return "fltk::TextEditor";}
int is_text_display() const {return 1;}
Fl_Widget *widget(int x,int y,int w,int h) {
Fl_Text_Editor *myo = new Fl_Text_Editor(x,y,w,h);
@@ -602,6 +618,7 @@ int Fl_Text_Editor_Type::textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) {
class Fl_Clock_Type : public Fl_Widget_Type {
public:
virtual const char *type_name() {return "Fl_Clock";}
+ virtual const char *alt_type_name() {return "fltk::Clock";}
Fl_Widget *widget(int x,int y,int w,int h) {
return new Fl_Clock(x,y,w,h);}
Fl_Widget_Type *_make() {return new Fl_Clock_Type();}
@@ -627,6 +644,7 @@ public:
if (w < 50) w = 50;
}
virtual const char *type_name() {return "Fl_Help_View";}
+ virtual const char *alt_type_name() {return "fltk::HelpView";}
Fl_Widget *widget(int x,int y,int w,int h) {
Fl_Help_View *myo = new Fl_Help_View(x,y,w,h);
if (!compile_only) {
@@ -645,6 +663,7 @@ static Fl_Help_View_Type Fl_Help_View_type;
class Fl_Progress_Type : public Fl_Widget_Type {
public:
virtual const char *type_name() {return "Fl_Progress";}
+ virtual const char *alt_type_name() {return "fltk::ProgressBar";}
Fl_Widget *widget(int x,int y,int w,int h) {
Fl_Progress *myo = new Fl_Progress(x,y,w,h,"label");
myo->value(50);
@@ -661,6 +680,7 @@ class Fl_Adjuster_Type : public Fl_Widget_Type {
int is_valuator() const {return 1;}
public:
virtual const char *type_name() {return "Fl_Adjuster";}
+ virtual const char *alt_type_name() {return "fltk::Adjuster";}
Fl_Widget *widget(int x,int y,int w,int h) {
return new Fl_Adjuster(x,y,w,h);}
Fl_Widget_Type *_make() {return new Fl_Adjuster_Type();}
@@ -681,6 +701,7 @@ class Fl_Dial_Type : public Fl_Widget_Type {
int is_valuator() const {return 1;}
public:
virtual const char *type_name() {return "Fl_Dial";}
+ virtual const char *alt_type_name() {return "fltk::Dial";}
Fl_Widget *widget(int x,int y,int w,int h) {
return new Fl_Dial(x,y,w,h);}
Fl_Widget_Type *_make() {return new Fl_Dial_Type();}
@@ -700,6 +721,7 @@ class Fl_Roller_Type : public Fl_Widget_Type {
int is_valuator() const {return 1;}
public:
virtual const char *type_name() {return "Fl_Roller";}
+ virtual const char *alt_type_name() {return "fltk::Roller";}
Fl_Widget *widget(int x,int y,int w,int h) {
return new Fl_Roller(x,y,w,h);}
Fl_Widget_Type *_make() {return new Fl_Roller_Type();}
@@ -723,6 +745,7 @@ class Fl_Slider_Type : public Fl_Widget_Type {
int is_valuator() const {return 2;}
public:
virtual const char *type_name() {return "Fl_Slider";}
+ virtual const char *alt_type_name() {return "fltk::Slider";}
Fl_Widget *widget(int x,int y,int w,int h) {
return new Fl_Slider(x,y,w,h,"slider:");}
Fl_Widget_Type *_make() {return new Fl_Slider_Type();}
@@ -739,6 +762,7 @@ class Fl_Scrollbar_Type : public Fl_Slider_Type {
int is_valuator() const {return 3;}
public:
virtual const char *type_name() {return "Fl_Scrollbar";}
+ virtual const char *alt_type_name() {return "fltk::Scrollbar";}
Fl_Widget *widget(int x,int y,int w,int h) {
return new Fl_Scrollbar(x,y,w,h);}
Fl_Widget_Type *_make() {return new Fl_Scrollbar_Type();}
@@ -767,6 +791,7 @@ public:
if (w < 15) w = 15;
}
virtual const char *type_name() {return "Fl_Output";}
+ virtual const char *alt_type_name() {return "fltk::Output";}
Fl_Widget *widget(int x,int y,int w,int h) {
Fl_Output *myo = new Fl_Output(x,y,w,h,"output:");
myo->value("Text Output");
@@ -793,6 +818,7 @@ public:
if (w < 15) w = 15;
}
virtual const char *type_name() {return "Fl_Value_Input";}
+ virtual const char *alt_type_name() {return "fltk::ValueInput";}
int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c);
int is_valuator() const {return 1;}
int is_value_input() const {return 1;}
@@ -833,6 +859,7 @@ public:
if (w < 15) w = 15;
}
virtual const char *type_name() {return "Fl_Value_Output";}
+ virtual const char *alt_type_name() {return "fltk::ValueOutput";}
int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c);
int is_valuator() const {return 1;}
Fl_Widget *widget(int x,int y,int w,int h) {
@@ -863,6 +890,7 @@ class Fl_Value_Slider_Type : public Fl_Slider_Type {
int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c);
public:
virtual const char *type_name() {return "Fl_Value_Slider";}
+ virtual const char *alt_type_name() {return "fltk::ValueSlider";}
Fl_Widget *widget(int x,int y,int w,int h) {
return new Fl_Value_Slider(x,y,w,h,"slider:");}
Fl_Widget_Type *_make() {return new Fl_Value_Slider_Type();}
@@ -1046,12 +1074,12 @@ void fill_in_New_Menu() {
if (m->user_data()) {
Fl_Type *t = (Fl_Type*)m->user_data();
if (m->text) {
- make_iconlabel( m, pixmap[t->pixmapID()], m->label() );
- }
- else {
- const char *n = t->type_name();
- if (!strncmp(n,"Fl_",3)) n += 3;
- make_iconlabel( m, pixmap[t->pixmapID()], n );
+ make_iconlabel( m, pixmap[t->pixmapID()], m->label() );
+ } else {
+ const char *n = t->type_name();
+ if (!strncmp(n,"Fl_",3)) n += 3;
+ if (!strncmp(n,"fltk::",6)) n += 6;
+ make_iconlabel( m, pixmap[t->pixmapID()], n );
}
}
}
@@ -1067,6 +1095,7 @@ Fl_Type *Fl_Type_make(const char *tn) {
if (!m->user_data()) continue;
Fl_Type *t = (Fl_Type*)(m->user_data());
if (!strcasecmp(tn,t->type_name())) {r = t->make(); break;}
+ if (!strcasecmp(tn,t->alt_type_name())) {r = t->make(); break;}
}
reading_file = 0;
return r;
diff --git a/fluid/file.cxx b/fluid/file.cxx
index b2abf90e5..c98cb6f60 100644
--- a/fluid/file.cxx
+++ b/fluid/file.cxx
@@ -389,7 +389,7 @@ static void read_children(Fl_Type *p, int paste) {
c = read_word();
read_version = strtod(c,0);
if (read_version<=0 || read_version>FL_VERSION)
- read_error("unknown version '%s'",c);
+ read_error("unknown version '%s'",c);
continue;
}