DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2259
Version: 1.3-feature


I submitted a patch for the fltk2 version of fluid
http://www.fltk.org/str.php?L2225 , but I recently saw that fltk2 is
basically dead.
Here is a patch for 1.3

I use fluid to define GUI classes, but I like to implement much of the the
class in a separate file.  To use this method, I modified fluid to not
output cpp code for functions that do not have any code associated with
them.  That way, the class if fully defined in the header file, but I can
do most of the code is a separate file.


Link: http://www.fltk.org/str.php?L2259
Version: 1.3-feature
Index: Fl_Function_Type.cxx
===================================================================
--- Fl_Function_Type.cxx        (revision 6895)
+++ Fl_Function_Type.cxx        (working copy)
@@ -244,12 +244,16 @@
   constructor=0;
   havewidgets = 0;
   Fl_Type *child;
-  for (child = next; child && child->level > level; child = child->next)
+  bool havechildren = false;
+  for (child = next; child && child->level > level; child = child->next) {
+    havechildren = true;
     if (child->is_widget()) {
       havewidgets = 1;
       break;
     }
-  write_c("\n");
+  }
+  if (havechildren)
+    write_c("\n");
   if (ismain())
     write_c("int main(int argc, char **argv) {\n");
   else {
@@ -287,7 +291,8 @@
       if (is_virtual) write_h("virtual ");
       if (!constructor) {
         write_h("%s%s ", rtype, star);
-        write_c("%s%s ", rtype, star);
+        if (havechildren)
+          write_c("%s%s ", rtype, star);
       }
       
       // if this is a subclass, only write_h() the part before the ':'
@@ -329,17 +334,19 @@
         if (sptr < (s + sizeof(s) - 1))        *sptr++ = *nptr;
       }
       *sptr = '\0';
-      
-      write_c("%s::%s {\n", k, s);
+      if (havechildren)
+        write_c("%s::%s {\n", k, s);
     } else {
-      write_comment_c();
+      if (havechildren)
+        write_comment_c();
       if (public_) {
         if (cdecl_)
           write_h("extern \"C\" { %s%s %s; }\n", rtype, star, name());
         else
           write_h("%s%s %s;\n", rtype, star, name());
       }
-      else write_c("static ");
+      else if (havechildren)
+        write_c("static ");
       
       // write everything but the default parameters (if any)
       char s[1024], *sptr;
@@ -368,7 +375,8 @@
       }
       *sptr = '\0';
       
-      write_c("%s%s %s {\n", rtype, star, s);
+      if (havechildren)
+        write_c("%s%s %s {\n", rtype, star, s);
     }
   }
   
@@ -379,8 +387,11 @@
 void Fl_Function_Type::write_code2() {
   Fl_Type *child;
   const char *var = "w";
-  for (child = next; child && child->level > level; child = child->next)
+  bool havechildren = false;
+  for (child = next; child && child->level > level; child = child->next) {
+      havechildren = true;
     if (child->is_window() && child->name()) var = child->name();
+  }
 
   if (ismain()) {
     if (havewidgets) write_c("  %s->show(argc, argv);\n", var);
@@ -388,7 +399,8 @@
   } else if (havewidgets && !constructor && !return_type) {
     write_c("  return %s;\n", var);
   }
-  write_c("}\n");
+  if (havechildren)
+    write_c("}\n");
   indentation = 0;
 }
 
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to