diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2015-04-02 17:19:33 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2015-04-02 17:19:33 +0000 |
| commit | d5a8755eadbed7667858866e968dead47e5bf8fb (patch) | |
| tree | ed47c718386760fdd8e93a9ba701adaf3802e915 /fluid/Fl_Type.cxx | |
| parent | 552502d44afeb7214fefe0266bd9abe3d503f47e (diff) | |
Added comments to Fluid Widgets. The comment field is between the Additional Code and Callback field on the C++ Tab of the Widget Editor. Care was taken to correctly resize.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10659 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'fluid/Fl_Type.cxx')
| -rw-r--r-- | fluid/Fl_Type.cxx | 58 |
1 files changed, 50 insertions, 8 deletions
diff --git a/fluid/Fl_Type.cxx b/fluid/Fl_Type.cxx index cc55a1a65..c3844fc0d 100644 --- a/fluid/Fl_Type.cxx +++ b/fluid/Fl_Type.cxx @@ -192,6 +192,14 @@ Fl_Widget *make_widget_browser(int x,int y,int w,int h) { return (widget_browser = new Widget_Browser(x,y,w,h)); } +void redraw_widget_browser(Fl_Type *caller) +{ + if (caller) { + widget_browser->display(caller); + } + widget_browser->redraw(); +} + void select(Fl_Type *o, int v) { widget_browser->select(o,v,1); // Fl_Type::current = o; @@ -699,7 +707,9 @@ void Fl_Type::user_data_type(const char *n) { } void Fl_Type::comment(const char *n) { - storestring(n, comment_, 1); + if (storestring(n,comment_,1)) { + if (visible) widget_browser->redraw(); + } } void Fl_Type::open() { @@ -845,6 +855,7 @@ void Fl_Type::move_before(Fl_Type* g) { widget_browser->redraw(); } + // move selected widgets in their parent's list: void earlier_cb(Fl_Widget*,void*) { Fl_Type *f; @@ -979,14 +990,14 @@ int has_toplevel_function(const char *rtype, const char *sig) { */ void Fl_Type::write_comment_h(const char *pre) { - if (comment()) { + if (comment() && *comment()) { write_h("%s/**\n", pre); const char *s = comment(); - write_h("%s ", pre); + write_h("%s ", pre); while(*s) { if (*s=='\n') { if (s[1]) { - write_h("\n%s ", pre); + write_h("\n%s ", pre); } } else { write_h("%c", *s); // FIXME this is much too slow! @@ -998,18 +1009,18 @@ void Fl_Type::write_comment_h(const char *pre) } /** - * Write a comment inot the header file. + * Write a comment into the source file. */ void Fl_Type::write_comment_c(const char *pre) { - if (comment()) { + if (comment() && *comment()) { write_c("%s/**\n", pre); const char *s = comment(); - write_c("%s ", pre); + write_c("%s ", pre); while(*s) { if (*s=='\n') { if (s[1]) { - write_c("\n%s ", pre); + write_c("\n%s ", pre); } } else { write_c("%c", *s); // FIXME this is much too slow! @@ -1021,6 +1032,37 @@ void Fl_Type::write_comment_c(const char *pre) } /** + * Write a comment into the source file. + */ +void Fl_Type::write_comment_inline_c(const char *pre) +{ + if (comment() && *comment()) { + const char *s = comment(); + if (strchr(s, '\n')==0L) { + // single line comment + if (pre) write_c("%s", pre); + write_c("// %s\n", s); + if (!pre) write_c("%s ", indent()); + } else { + write_c("%s/*\n", pre?pre:""); + if (pre) write_c("%s ", pre); else write_c("%s ", indent()); + while(*s) { + if (*s=='\n') { + if (s[1]) { + if (pre) write_c("\n%s ", pre); else write_c("\n%s ", indent()); + } + } else { + write_c("%c", *s); // FIXME this is much too slow! + } + s++; + } + if (pre) write_c("\n%s */\n", pre); else write_c("\n%s */\n", indent()); + if (!pre) write_c("%s ", indent()); + } + } +} + +/** * Make sure that the given item is visible in the browser by opening * all parent groups and moving the item into the visible space. */ |
