Author: matt
Date: 2011-05-23 01:24:53 -0700 (Mon, 23 May 2011)
New Revision: 8720
Log:
123: Reading FLTK1 .fl files in Fluid

Modified:
   branches/branch-3.0/fluid/Fl_Function_Type.cxx
   branches/branch-3.0/fluid/Fl_Type.cxx
   branches/branch-3.0/fluid/Fl_Type.h
   branches/branch-3.0/fluid/Fl_Widget_Type.cxx
   branches/branch-3.0/fluid/Fl_Window_Type.cxx
   branches/branch-3.0/fluid/Fluid_Image.cxx
   branches/branch-3.0/fluid/file.cxx

Modified: branches/branch-3.0/fluid/Fl_Function_Type.cxx
===================================================================
--- branches/branch-3.0/fluid/Fl_Function_Type.cxx      2011-05-22 22:43:15 UTC 
(rev 8719)
+++ branches/branch-3.0/fluid/Fl_Function_Type.cxx      2011-05-23 08:24:53 UTC 
(rev 8720)
@@ -152,7 +152,7 @@
   }
 }
 
-void Fl_Function_Type::read_property(const char *c) {
+char Fl_Function_Type::read_property(const char *c) {
   if (!strcmp(c,"private")) {
     public_ = 0;
   } else if (!strcmp(c,"protected")) {
@@ -162,8 +162,9 @@
   } else if (!strcmp(c,"return_type")) {
     storestring(read_word(),return_type);
   } else {
-    Fl_Type::read_property(c);
+    return Fl_Type::read_property(c);
   }
+  return 1;
 }
 
 #include "function_panel.h"
@@ -509,12 +510,13 @@
   }
 }
 
-void Fl_CodeBlock_Type::read_property(const char *c) {
+char Fl_CodeBlock_Type::read_property(const char *c) {
   if (!strcmp(c,"after")) {
     storestring(read_word(),after);
   } else {
-    Fl_Type::read_property(c);
+    return Fl_Type::read_property(c);
   }
+  return 1;
 }
 
 void Fl_CodeBlock_Type::open() {
@@ -595,7 +597,7 @@
     write_string("global");
 }
 
-void Fl_Decl_Type::read_property(const char *c) {
+char Fl_Decl_Type::read_property(const char *c) {
   if (!strcmp(c,"public")) {
     public_ = 1;
   } else if (!strcmp(c,"private")) {
@@ -607,8 +609,9 @@
   } else if (!strcmp(c,"global")) {
     static_ = 0;
   } else {
-    Fl_Type::read_property(c);
+    return Fl_Type::read_property(c);
   }
+  return 1;
 }
 
 void Fl_Decl_Type::open() {
@@ -760,12 +763,13 @@
   }
 }
 
-void Fl_Data_Type::read_property(const char *c) {
+char Fl_Data_Type::read_property(const char *c) {
   if (!strcmp(c,"filename")) {
     storestring(read_word(), filename_, 1);
   } else {
-    Fl_Decl_Type::read_property(c);
+    return Fl_Decl_Type::read_property(c);
   }
+  return 1;
 }
 
 void Fl_Data_Type::open() {
@@ -967,7 +971,7 @@
   write_word(after);
 }
 
-void Fl_DeclBlock_Type::read_property(const char *c) {
+char Fl_DeclBlock_Type::read_property(const char *c) {
   if(!strcmp(c,"public")) {
     public_ = 1;
   } else if(!strcmp(c,"protected")) {
@@ -975,8 +979,9 @@
   } else  if (!strcmp(c,"after")) {
     storestring(read_word(),after);
   } else {
-    Fl_Type::read_property(c);
+    return Fl_Type::read_property(c);
   }
+  return 1;
 }
 
 void Fl_DeclBlock_Type::open() {
@@ -1053,7 +1058,7 @@
   if (in_h_) write_string("in_header"); else write_string("not_in_header");
 }
 
-void Fl_Comment_Type::read_property(const char *c) {
+char Fl_Comment_Type::read_property(const char *c) {
   if (!strcmp(c,"in_source")) {
     in_c_ = 1;
   } else if (!strcmp(c,"not_in_source")) {
@@ -1063,8 +1068,9 @@
   } else if (!strcmp(c,"not_in_header")) {
     in_h_ = 0;
   } else {
-    Fl_Type::read_property(c);
+    return Fl_Type::read_property(c);
   }
+  return 1;
 }
 
 #include "comments.h"
@@ -1336,7 +1342,7 @@
   }
 }
 
-void Fl_Class_Type::read_property(const char *c) {
+char Fl_Class_Type::read_property(const char *c) {
   if (!strcmp(c,"private")) {
     public_ = 0;
   } else if (!strcmp(c,"protected")) {
@@ -1344,8 +1350,9 @@
   } else if (!strcmp(c,":")) {
     storestring(read_word(), subclass_of);
   } else {
-    Fl_Type::read_property(c);
+    return Fl_Type::read_property(c);
   }
+  return 1;
 }
 
 void Fl_Class_Type::open() {

Modified: branches/branch-3.0/fluid/Fl_Type.cxx
===================================================================
--- branches/branch-3.0/fluid/Fl_Type.cxx       2011-05-22 22:43:15 UTC (rev 
8719)
+++ branches/branch-3.0/fluid/Fl_Type.cxx       2011-05-23 08:24:53 UTC (rev 
8720)
@@ -885,7 +885,7 @@
   if (selected) write_word("selected");
 }
 
-void Fl_Type::read_property(const char *c) {
+char Fl_Type::read_property(const char *c) {
   if (!strcmp(c,"label"))
     label(read_word());
   else if (!strcmp(c,"user_data"))
@@ -900,8 +900,11 @@
     open_ = 1;
   else if (!strcmp(c,"selected"))
     select(this,1);
-  else
+  else {
     read_error("Unknown property \"%s\"", c);
+    return 0;
+  }
+  return 1;
 }
 
 int Fl_Type::read_fdesign(const char*, const char*) {return 0;}

Modified: branches/branch-3.0/fluid/Fl_Type.h
===================================================================
--- branches/branch-3.0/fluid/Fl_Type.h 2011-05-22 22:43:15 UTC (rev 8719)
+++ branches/branch-3.0/fluid/Fl_Type.h 2011-05-23 08:24:53 UTC (rev 8720)
@@ -93,7 +93,7 @@
 
   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
+  virtual const char *alt_type_name() { return type_name(); } // alternate 
type for FLTK1 file reading
 
   const char *name() const {return name_;}
   void name(const char *);
@@ -119,7 +119,7 @@
   // read and write data to a saved file:
   void write();
   virtual void write_properties();
-  virtual void read_property(const char *);
+  virtual char read_property(const char *);
   virtual int read_fdesign(const char*, const char*);
 
   // write code, these are called in order:
@@ -179,6 +179,7 @@
   void open();
   int ismain() {return name_ == 0;}
   virtual const char *type_name() {return "Function";}
+  virtual const char *alt_type_name() { return type_name(); }
   virtual const char *title() {
     return name() ? name() : "main()";
   }
@@ -187,7 +188,7 @@
   virtual int is_public() const;
   int pixmapID() { return 7; }
   void write_properties();
-  void read_property(const char *);
+  char read_property(const char *);
   int has_signature(const char *, const char*) const;
 };
 
@@ -198,6 +199,7 @@
   void write_code2();
   void open();
   virtual const char *type_name() {return "code";}
+  virtual const char *alt_type_name() { return type_name(); }
   int is_code_block() const {return 0;}
   int pixmapID() { return 8; }
   virtual int is_public() const;
@@ -215,12 +217,13 @@
   void write_code2();
   void open();
   virtual const char *type_name() {return "codeblock";}
+  virtual const char *alt_type_name() { return type_name(); }
   int is_code_block() const {return 1;}
   int is_parent() const {return 1;}
   virtual int is_public() const;
   int pixmapID() { return 9; }
   void write_properties();
-  void read_property(const char *);
+  char read_property(const char *);
 };
 
 class Fl_Decl_Type : public Fl_Type {
@@ -233,8 +236,9 @@
   void write_code2();
   void open();
   virtual const char *type_name() {return "decl";}
+  virtual const char *alt_type_name() { return type_name(); }
   void write_properties();
-  void read_property(const char *);
+  char read_property(const char *);
   virtual int is_public() const;
   int pixmapID() { return 10; }
 };
@@ -251,8 +255,9 @@
   void write_code2();
   void open();
   virtual const char *type_name() {return "data";}
+  virtual const char *alt_type_name() { return type_name(); }
   void write_properties();
-  void read_property(const char *);
+  char read_property(const char *);
   int pixmapID() { return 49; }
 };
 
@@ -269,8 +274,9 @@
   void write_code2();
   void open();
   virtual const char *type_name() {return "declblock";}
+  virtual const char *alt_type_name() { return type_name(); }
   void write_properties();
-  void read_property(const char *);
+  char read_property(const char *);
   int is_parent() const {return 1;}
   int is_decl_block() const {return 1;}
   virtual int is_public() const;
@@ -286,9 +292,10 @@
   void write_code2();
   void open();
   virtual const char *type_name() {return "comment";}
+  virtual const char *alt_type_name() { return type_name(); }
   virtual const char *title(); // string for browser
   void write_properties();
-  void read_property(const char *);
+  char read_property(const char *);
   virtual int is_public() const { return 1; }
   virtual int is_comment() const { return 1; }
   int pixmapID() { return 46; }
@@ -312,13 +319,14 @@
   void write_code2();
   void open();
   virtual const char *type_name() {return "class";}
+  virtual const char *alt_type_name() { return type_name(); }
   int is_parent() const {return 1;}
   int is_decl_block() const {return 1;}
   int is_class() const {return 1;}
   virtual int is_public() const;
   int pixmapID() { return 12; }
   void write_properties();
-  void read_property(const char *);
+  char read_property(const char *);
 
   // class prefix attribute access
   void prefix(const char* p);
@@ -391,7 +399,7 @@
   virtual int is_public() const;
 
   virtual void write_properties();
-  virtual void read_property(const char *);
+  virtual char read_property(const char *);
   virtual int read_fdesign(const char*, const char*);
 
   virtual fltk3::Widget *enter_live_mode(int top=0);
@@ -582,7 +590,7 @@
   uchar *read_image(int &ww, int &hh); // Read an image of the window
 
   virtual void write_properties();
-  virtual void read_property(const char *);
+  virtual char read_property(const char *);
   virtual int read_fdesign(const char*, const char*);
 
   void add_child(Fl_Type*, Fl_Type*);
@@ -611,12 +619,13 @@
   char wc_relative; // if true, reposition all child widgets in an fltk3::Group
 
   virtual void write_properties();
-  virtual void read_property(const char *);
+  virtual char read_property(const char *);
 
   void write_code1();
   void write_code2();
   Fl_Type *make();
   virtual const char *type_name() {return "widget_class";}
+  virtual const char *alt_type_name() {return "widget_class";}
   int pixmapID() { return 48; }
   int is_parent() const {return 1;}
   int is_code_block() const {return 1;}

Modified: branches/branch-3.0/fluid/Fl_Widget_Type.cxx
===================================================================
--- branches/branch-3.0/fluid/Fl_Widget_Type.cxx        2011-05-22 22:43:15 UTC 
(rev 8719)
+++ branches/branch-3.0/fluid/Fl_Widget_Type.cxx        2011-05-23 08:24:53 UTC 
(rev 8720)
@@ -1976,7 +1976,7 @@
 void Fl_Widget_Type::write_static() {
   const char* t = subclassname(this);
   if (!subclass() || (is_class() && !strncmp(t, "fltk3::", 7))) {
-    write_declare("#include <fltk3/%s.h>", t);
+    write_declare("#include <fltk3/%s.h>", t+7);
   }
   for (int n=0; n < NUM_EXTRA_CODE; n++) {
     if (extra_code(n) && isdeclare(extra_code(n)))
@@ -2506,7 +2506,7 @@
 
 int pasteoffset;
 extern double read_version;
-void Fl_Widget_Type::read_property(const char *c) {
+char Fl_Widget_Type::read_property(const char *c) {
   int x,y,w,h; fltk3::Font f; int s; fltk3::Color cc;
   if (!strcmp(c,"private")) {
     public_ = 0;
@@ -2639,14 +2639,15 @@
       int n = atoi(c+4);
       if (n >= 0 && n <= NUM_EXTRA_CODE) {
         extra_code(n,read_word());
-        return;
+        return 1;
       }
     } else if (!strcmp(c,"extra_code")) {
       extra_code(0,read_word());
-      return;
+      return 1;
     }
-    Fl_Type::read_property(c);
+    return Fl_Type::read_property(c);
   }
+  return 1;
 }
 
 fltk3::MenuItem boxmenu1[] = {

Modified: branches/branch-3.0/fluid/Fl_Window_Type.cxx
===================================================================
--- branches/branch-3.0/fluid/Fl_Window_Type.cxx        2011-05-22 22:43:15 UTC 
(rev 8719)
+++ branches/branch-3.0/fluid/Fl_Window_Type.cxx        2011-05-23 08:24:53 UTC 
(rev 8720)
@@ -1394,7 +1394,7 @@
 }
 
 extern int pasteoffset;
-void Fl_Window_Type::read_property(const char *c) {
+char Fl_Window_Type::read_property(const char *c) {
   if (!strcmp(c,"modal")) {
     modal = 1;
   } else if (!strcmp(c,"non_modal")) {
@@ -1415,8 +1415,9 @@
     Fl_Widget_Type::read_property(c);
     pasteoffset = 0; // make it not apply to contents
   } else {
-    Fl_Widget_Type::read_property(c);
+    return Fl_Widget_Type::read_property(c);
   }
+  return 1;
 }
 
 int Fl_Window_Type::read_fdesign(const char* propname, const char* value) {
@@ -1477,12 +1478,13 @@
   if (wc_relative) write_string("position_relative");
 }
 
-void Fl_Widget_Class_Type::read_property(const char *c) {
+char Fl_Widget_Class_Type::read_property(const char *c) {
   if (!strcmp(c,"position_relative")) {
     wc_relative = 1;
   } else {
-    Fl_Window_Type::read_property(c);
+    return Fl_Window_Type::read_property(c);
   }
+  return 1;
 }
 
 void Fl_Widget_Class_Type::write_code1() {

Modified: branches/branch-3.0/fluid/Fluid_Image.cxx
===================================================================
--- branches/branch-3.0/fluid/Fluid_Image.cxx   2011-05-22 22:43:15 UTC (rev 
8719)
+++ branches/branch-3.0/fluid/Fluid_Image.cxx   2011-05-23 08:24:53 UTC (rev 
8720)
@@ -90,7 +90,7 @@
     // Write Bitmap data...
     write_c("\n");
     if (bitmap_header_written != write_number) {
-      write_c("#include <fltk3/fltk3::Bitmap.h>\n");
+      write_c("#include <fltk3/Bitmap.h>\n");
       bitmap_header_written = write_number;
     }
     write_c("static unsigned char %s[] =\n",
@@ -136,7 +136,7 @@
     // Write image data...
     write_c("\n");
     if (image_header_written != write_number) {
-      write_c("#include <fltk3/fltk3::Image.h>\n");
+      write_c("#include <fltk3/Image.h>\n");
       image_header_written = write_number;
     }
     write_c("static unsigned char %s[] =\n",

Modified: branches/branch-3.0/fluid/file.cxx
===================================================================
--- branches/branch-3.0/fluid/file.cxx  2011-05-22 22:43:15 UTC (rev 8719)
+++ branches/branch-3.0/fluid/file.cxx  2011-05-23 08:24:53 UTC (rev 8720)
@@ -481,7 +481,10 @@
     for (;;) {
       const char *cc = read_word();
       if (!cc || !strcmp(cc,"}")) break;
-      t->read_property(cc);
+      if (t->read_property(cc)==0) {
+        read_error("Unknown property \"%s\" for \"%s\".\n",cc, t->title());
+        goto CONTINUE;
+      }
     }
 
     if (!t->is_parent()) continue;

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to