From c232e9822d348eec68593ba6753b98ae9f85dfdb Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Wed, 17 Sep 2008 22:43:15 +0000 Subject: This is a stab at supporting Doxygen comments from withing Fluid. Just double click on a function, class, or declaration and you will be able to add a comment. Comments welcome. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6291 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- fluid/Fl_Function_Type.cxx | 169 +++++++++++++++++++++++++++++---------------- fluid/Fl_Type.cxx | 100 +++++++++++++++++++++++++-- fluid/Fl_Type.h | 5 ++ fluid/function_panel.cxx | 137 ++++++++++++++++++++++++------------ fluid/function_panel.fl | 82 ++++++++++++++-------- fluid/function_panel.h | 4 ++ 6 files changed, 354 insertions(+), 143 deletions(-) (limited to 'fluid') diff --git a/fluid/Fl_Function_Type.cxx b/fluid/Fl_Function_Type.cxx index 57b510bbc..f3c114b69 100644 --- a/fluid/Fl_Function_Type.cxx +++ b/fluid/Fl_Function_Type.cxx @@ -178,6 +178,8 @@ void Fl_Function_Type::open() { f_public_member_choice->hide(); } f_c_button->value(cdecl_); + const char *c = comment(); + f_comment_input->buffer()->text(c?c:""); function_panel->show(); const char* message = 0; for (;;) { // repeat as long as there are errors @@ -218,6 +220,15 @@ void Fl_Function_Type::open() { mod = 1; cdecl_ = f_c_button->value(); } + c = f_comment_input->buffer()->text(); + if (c && *c) { + if (!comment() || strcmp(c, comment())) redraw_browser(); + comment(c); + } else { + if (comment()) redraw_browser(); + comment(0); + } + if (c) free((void*)c); if (mod) set_modflag(1); break; } @@ -256,109 +267,111 @@ void Fl_Function_Type::write_code1() { } if (!rtype) { if (havewidgets) { - rtype = subclassname(child); - star = "*"; + rtype = subclassname(child); + star = "*"; } else rtype = "void"; } - + const char* k = class_name(0); if (k) { + write_comment_c(); write_public(public_); if (name()[0] == '~') - constructor = 1; + constructor = 1; else { - size_t n = strlen(k); - if (!strncmp(name(), k, n) && name()[n] == '(') constructor = 1; + size_t n = strlen(k); + if (!strncmp(name(), k, n) && name()[n] == '(') constructor = 1; } write_h(" "); if (is_static) write_h("static "); if (is_virtual) write_h("virtual "); if (!constructor) { write_h("%s%s ", rtype, star); - write_c("%s%s ", rtype, star); + write_c("%s%s ", rtype, star); } - + // if this is a subclass, only write_h() the part before the ':' char s[1024], *sptr = s; char *nptr = (char *)name(); - + while (*nptr) { if (*nptr == ':') { - if (nptr[1] != ':') break; - // Copy extra ":" for "class::member"... + if (nptr[1] != ':') break; + // Copy extra ":" for "class::member"... *sptr++ = *nptr++; } *sptr++ = *nptr++; } *sptr = '\0'; - + write_h("%s;\n", s); // skip all function default param. init in body: int skips=0,skipc=0; int nc=0,plevel=0; for (sptr=s,nptr=(char*)name(); *nptr; nc++,nptr++) { - if (!skips && *nptr=='(') plevel++; - else if (!skips && *nptr==')') plevel--; - if ( *nptr=='"' && !(nc && *(nptr-1)=='\\') ) - skips = skips ? 0 : 1; - else if(!skips && *nptr=='\'' && !(nc && *(nptr-1)=='\\')) - skipc = skipc ? 0 : 1; - if(!skips && !skipc && plevel==1 && *nptr =='=' && - !(nc && *(nptr-1)=='\'') ) // ignore '=' case - while(*++nptr && (skips || skipc || (*nptr!=',' && *nptr!=')' || plevel!=1) )) { - if ( *nptr=='"' && *(nptr-1)!='\\' ) - skips = skips ? 0 : 1; - else if(!skips && *nptr=='\'' && *(nptr-1)!='\\') - skipc = skipc ? 0 : 1; - if (!skips && !skipc && *nptr=='(') plevel++; - else if (!skips && *nptr==')') plevel--; - } - - if (sptr < (s + sizeof(s) - 1)) *sptr++ = *nptr; + if (!skips && *nptr=='(') plevel++; + else if (!skips && *nptr==')') plevel--; + if ( *nptr=='"' && !(nc && *(nptr-1)=='\\') ) + skips = skips ? 0 : 1; + else if(!skips && *nptr=='\'' && !(nc && *(nptr-1)=='\\')) + skipc = skipc ? 0 : 1; + if(!skips && !skipc && plevel==1 && *nptr =='=' && + !(nc && *(nptr-1)=='\'') ) // ignore '=' case + while(*++nptr && (skips || skipc || (*nptr!=',' && *nptr!=')' || plevel!=1) )) { + if ( *nptr=='"' && *(nptr-1)!='\\' ) + skips = skips ? 0 : 1; + else if(!skips && *nptr=='\'' && *(nptr-1)!='\\') + skipc = skipc ? 0 : 1; + if (!skips && !skipc && *nptr=='(') plevel++; + else if (!skips && *nptr==')') plevel--; + } + + if (sptr < (s + sizeof(s) - 1)) *sptr++ = *nptr; } *sptr = '\0'; - + write_c("%s::%s {\n", k, s); } else { + 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()); + 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 "); - + // write everything but the default parameters (if any) char s[1024], *sptr; char *nptr; int skips=0,skipc=0; int nc=0,plevel=0; for (sptr=s,nptr=(char*)name(); *nptr; nc++,nptr++) { - if (!skips && *nptr=='(') plevel++; - else if (!skips && *nptr==')') plevel--; - if ( *nptr=='"' && !(nc && *(nptr-1)=='\\') ) - skips = skips ? 0 : 1; - else if(!skips && *nptr=='\'' && !(nc && *(nptr-1)=='\\')) - skipc = skipc ? 0 : 1; - if(!skips && !skipc && plevel==1 && *nptr =='=' && - !(nc && *(nptr-1)=='\'') ) // ignore '=' case - while(*++nptr && (skips || skipc || (*nptr!=',' && *nptr!=')' || plevel!=1) )) { - if ( *nptr=='"' && *(nptr-1)!='\\' ) - skips = skips ? 0 : 1; - else if(!skips && *nptr=='\'' && *(nptr-1)!='\\') - skipc = skipc ? 0 : 1; - if (!skips && !skipc && *nptr=='(') plevel++; - else if (!skips && *nptr==')') plevel--; - } - - if (sptr < (s + sizeof(s) - 1)) *sptr++ = *nptr; + if (!skips && *nptr=='(') plevel++; + else if (!skips && *nptr==')') plevel--; + if ( *nptr=='"' && !(nc && *(nptr-1)=='\\') ) + skips = skips ? 0 : 1; + else if(!skips && *nptr=='\'' && !(nc && *(nptr-1)=='\\')) + skipc = skipc ? 0 : 1; + if(!skips && !skipc && plevel==1 && *nptr =='=' && + !(nc && *(nptr-1)=='\'') ) // ignore '=' case + while(*++nptr && (skips || skipc || (*nptr!=',' && *nptr!=')' || plevel!=1) )) { + if ( *nptr=='"' && *(nptr-1)!='\\' ) + skips = skips ? 0 : 1; + else if(!skips && *nptr=='\'' && *(nptr-1)!='\\') + skipc = skipc ? 0 : 1; + if (!skips && !skipc && *nptr=='(') plevel++; + else if (!skips && *nptr==')') plevel--; + } + + if (sptr < (s + sizeof(s) - 1)) *sptr++ = *nptr; } *sptr = '\0'; - + write_c("%s%s %s {\n", rtype, star, s); } } - + if (havewidgets && !child->name()) write_c(" %s* w;\n", subclassname(child)); indentation += 2; } @@ -570,6 +583,8 @@ void Fl_Decl_Type::open() { decl_choice->show(); decl_class_choice->hide(); } + const char *c = comment(); + decl_comment_input->buffer()->text(c?c:""); decl_panel->show(); const char* message = 0; for (;;) { // repeat as long as there are errors @@ -600,6 +615,15 @@ void Fl_Decl_Type::open() { static_ = ((decl_choice->value()>>1)&1); } } + c = decl_comment_input->buffer()->text(); + if (c && *c) { + if (!comment() || strcmp(c, comment())) redraw_browser(); + comment(c); + } else { + if (comment()) redraw_browser(); + comment(0); + } + if (c) free((void*)c); break; } BREAK2: @@ -619,6 +643,7 @@ void Fl_Decl_Type::write_code1() { || !strncmp(c,"struct",6) && isspace(c[6]) ) ) { write_public(public_); + write_comment_h(" "); write_h(" %s\n", c); return; } @@ -631,10 +656,13 @@ void Fl_Decl_Type::write_code1() { || !strncmp(c,"FL_EXPORT",9) && isspace(c[9]) // || !strncmp(c,"struct",6) && isspace(c[6]) ) { - if (public_) + if (public_) { + write_comment_h(); write_h("%s\n", c); - else + } else { + write_comment_c(); write_c("%s\n", c); + } return; } // find the first C++ style comment @@ -646,15 +674,21 @@ void Fl_Decl_Type::write_code1() { while (e>c && e[-1]==';') e--; if (class_name(1)) { write_public(public_); + write_comment_h(" "); write_h(" %.*s; %s\n", (int)(e-c), c, csc); } else { if (public_) { if (static_) write_h("extern "); + else + write_comment_h(); write_h("%.*s; %s\n", (int)(e-c), c, csc); - if (static_) + if (static_) { + write_comment_c(); write_c("%.*s; %s\n", (int)(e-c), c, csc); + } } else { + write_comment_c(); if (static_) write_c("static "); write_c("%.*s; %s\n", (int)(e-c), c, csc); @@ -1081,6 +1115,8 @@ void Fl_Class_Type::open() { c_name_input->static_value(fullname); c_subclass_input->static_value(subclass_of); c_public_button->value(public_); + const char *c = comment(); + c_comment_input->buffer()->text(c?c:""); class_panel->show(); const char* message = 0; @@ -1124,6 +1160,15 @@ void Fl_Class_Type::open() { public_ = c_public_button->value(); set_modflag(1); } + c = c_comment_input->buffer()->text(); + if (c && *c) { + if (!comment() || strcmp(c, comment())) redraw_browser(); + comment(c); + } else { + if (comment()) redraw_browser(); + comment(0); + } + if (c) free((void*)c); break; } BREAK2: @@ -1151,10 +1196,12 @@ void Fl_Class_Type::write_code1() { parent_class = current_class; current_class = this; write_public_state = 0; + write_h("\n"); + write_comment_h(); if (prefix() && strlen(prefix())) - write_h("\nclass %s %s ", prefix(), name()); + write_h("class %s %s ", prefix(), name()); else - write_h("\nclass %s ", name()); + write_h("class %s ", name()); if (subclass_of) write_h(": %s ", subclass_of); write_h("{\n"); } diff --git a/fluid/Fl_Type.cxx b/fluid/Fl_Type.cxx index 9d998601e..d7a6a6369 100644 --- a/fluid/Fl_Type.cxx +++ b/fluid/Fl_Type.cxx @@ -232,6 +232,15 @@ int Widget_Browser::item_selected(void *l) const {return ((Fl_Type*)l)->new_sele void Widget_Browser::item_select(void *l,int v) {((Fl_Type*)l)->new_selected = v;} int Widget_Browser::item_height(void *l) const { + Fl_Type *t = (Fl_Type*)l; + if (t->visible) { + if (t->comment()) + return textsize()*2+1; + else + return textsize()+2; + } else { + return 0; + } return ((Fl_Type *)l)->visible ? textsize()+2 : 0; } @@ -250,6 +259,24 @@ extern const char* subclassname(Fl_Type*); void Widget_Browser::item_draw(void *v, int X, int Y, int, int) const { Fl_Type *l = (Fl_Type *)v; X += 3 + 18 + l->level * 12; + int comment_incr = 0; + if (l->comment()) { + char buf[82], *d = buf; + const char *s = l->comment(); + for (int i=0; i<80; i++) { + char c = *s++; + if (c==0 || c=='\n') break; + *d++ = c; + } + *d = 0; + comment_incr = textsize()-1; + if (l->new_selected) fl_color(fl_contrast(FL_DARK_GREEN,FL_SELECTION_COLOR)); + else fl_color(fl_contrast(FL_DARK_GREEN,color())); + fl_font(textfont()+FL_ITALIC, textsize()-2); + fl_draw(buf, (l->is_parent())?X+12:X, Y+12); + Y += comment_incr/2; + comment_incr -= comment_incr/2; + } if (l->new_selected) fl_color(fl_contrast(FL_FOREGROUND_COLOR,FL_SELECTION_COLOR)); else fl_color(FL_FOREGROUND_COLOR); Fl_Pixmap *pm = pixmap[l->pixmapID()]; @@ -261,19 +288,20 @@ void Widget_Browser::item_draw(void *v, int X, int Y, int, int) const { if (l->is_parent()) { if (!l->next || l->next->level <= l->level) { if (l->open_!=(l==pushedtitle)) { - fl_loop(X,Y+7,X+5,Y+12,X+10,Y+7); + fl_loop(X,Y+7,X+5,Y+12,X+10,Y+7); } else { - fl_loop(X+2,Y+2,X+7,Y+7,X+2,Y+12); + fl_loop(X+2,Y+2,X+7,Y+7,X+2,Y+12); } } else { if (l->open_!=(l==pushedtitle)) { - fl_polygon(X,Y+7,X+5,Y+12,X+10,Y+7); + fl_polygon(X,Y+7,X+5,Y+12,X+10,Y+7); } else { - fl_polygon(X+2,Y+2,X+7,Y+7,X+2,Y+12); + fl_polygon(X+2,Y+2,X+7,Y+7,X+2,Y+12); } } X += 10; } + Y += comment_incr; if (l->is_widget() || l->is_class()) { const char* c = subclassname(l); if (!strncmp(c,"Fl_",3)) c += 3; @@ -288,8 +316,8 @@ void Widget_Browser::item_draw(void *v, int X, int Y, int, int) const { char buf[50]; char* p = buf; *p++ = '"'; for (int i = 20; i--;) { - if (! (*c & -32)) break; - *p++ = *c++; + if (! (*c & -32)) break; + *p++ = *c++; } if (*c) {strcpy(p,"..."); p+=3;} *p++ = '"'; @@ -438,6 +466,7 @@ Fl_Type::Fl_Type() { user_data_ = 0; user_data_type_ = 0; callback_ = 0; + comment_ = 0; rtti = 0; level = 0; code_line = header_line = -1; @@ -608,6 +637,10 @@ void Fl_Type::user_data_type(const char *n) { storestring(n,user_data_type_); } +void Fl_Type::comment(const char *n) { + storestring(n, comment_, 1); +} + void Fl_Type::open() { printf("Open of '%s' is not yet implemented\n",type_name()); } @@ -790,7 +823,7 @@ void Fl_Type::write() { if (is_class()) { const char * p = ((Fl_Class_Type*)this)->prefix(); if (p && strlen(p)) - write_word(p); + write_word(p); } write_word(name()); @@ -827,6 +860,11 @@ void Fl_Type::write_properties() { write_word("callback"); write_word(callback()); } + if (comment()) { + write_indent(level+1); + write_word("comment"); + write_word(comment()); + } if (is_parent() && open_) write_word("open"); if (selected) write_word("selected"); } @@ -840,6 +878,8 @@ void Fl_Type::read_property(const char *c) { user_data_type(read_word()); else if (!strcmp(c,"callback")) callback(read_word()); + else if (!strcmp(c,"comment")) + comment(read_word()); else if (!strcmp(c,"open")) open_ = 1; else if (!strcmp(c,"selected")) @@ -865,6 +905,52 @@ int has_toplevel_function(const char *rtype, const char *sig) { return 0; } +/** + * Write a comment inot the header file. + */ +void Fl_Type::write_comment_h(const char *pre) +{ + if (comment()) { + write_h("%s/**\n", pre); + const char *s = comment(); + write_h("%s ", pre); + while(*s) { + if (*s=='\n') { + if (s[1]) { + write_h("\n%s ", pre); + } + } else { + write_h("%c", *s); // FIXME this is much too slow! + } + s++; + } + write_h("\n%s*/\n", pre); + } +} + +/** + * Write a comment inot the header file. + */ +void Fl_Type::write_comment_c(const char *pre) +{ + if (comment()) { + write_c("%s/**\n", pre); + const char *s = comment(); + write_c("%s ", pre); + while(*s) { + if (*s=='\n') { + if (s[1]) { + write_c("\n%s ", pre); + } + } else { + write_c("%c", *s); // FIXME this is much too slow! + } + s++; + } + write_c("\n%s*/\n", pre); + } +} + /** * Make sure that the given item is visible in the browser by opening * all parent groups and moving the item into the visible space. diff --git a/fluid/Fl_Type.h b/fluid/Fl_Type.h index a3bf02490..d26353863 100644 --- a/fluid/Fl_Type.h +++ b/fluid/Fl_Type.h @@ -57,6 +57,7 @@ protected: const char *callback_; const char *user_data_; const char *user_data_type_; + const char *comment_; public: // things that should not be public: @@ -99,6 +100,8 @@ public: void user_data(const char *); const char *user_data_type() const {return user_data_type_;} void user_data_type(const char *); + const char *comment() { return comment_; } + void comment(const char *); virtual Fl_Type* click_test(int,int); virtual void add_child(Fl_Type*, Fl_Type* beforethis); @@ -118,6 +121,8 @@ public: virtual void write_static(); // write static stuff to .c file virtual void write_code1(); // code and .h before children virtual void write_code2(); // code and .h after children + void write_comment_h(const char *ind=""); // write the commentary text into the header file + void write_comment_c(const char *ind=""); // write the commentary text into the source file // live mode virtual Fl_Widget *enter_live_mode(int top=0); // build wdgets needed for live mode diff --git a/fluid/function_panel.cxx b/fluid/function_panel.cxx index 2e1172a62..d2e2c362f 100644 --- a/fluid/function_panel.cxx +++ b/fluid/function_panel.cxx @@ -3,7 +3,7 @@ // // Code dialogs for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2008 by Bill Spitzak and others. +// Copyright 1998-2005 by Bill Spitzak and others. // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public @@ -64,8 +64,10 @@ Fl_Return_Button *f_panel_ok=(Fl_Return_Button *)0; Fl_Button *f_panel_cancel=(Fl_Button *)0; +Fl_Text_Editor *f_comment_input=(Fl_Text_Editor *)0; + Fl_Double_Window* make_function_panel() { - { Fl_Double_Window* o = function_panel = new Fl_Double_Window(290, 150, "Function/Method Properties"); + { function_panel = new Fl_Double_Window(343, 232, "Function/Method Properties"); { Fl_Group* o = new Fl_Group(10, 10, 270, 20); { f_public_member_choice = new Fl_Choice(10, 10, 75, 20); f_public_member_choice->tooltip("Change member access attribute."); @@ -92,42 +94,51 @@ Fl_Double_Window* make_function_panel() { } // Fl_Box* o o->end(); } // Fl_Group* o - { f_name_input = new Fl_Input(10, 50, 270, 20, "Name(args): (blank for main())"); + { f_name_input = new Fl_Input(10, 50, 320, 20, "Name(args): (blank for main())"); f_name_input->tooltip("The name of the function or method."); f_name_input->labelfont(1); f_name_input->labelsize(11); f_name_input->textfont(4); f_name_input->textsize(11); - f_name_input->align(FL_ALIGN_TOP_LEFT); + f_name_input->align(Fl_Align(FL_ALIGN_TOP_LEFT)); f_name_input->when(FL_WHEN_NEVER); - Fl_Group::current()->resizable(f_name_input); } // Fl_Input* f_name_input - { f_return_type_input = new Fl_Input(10, 90, 270, 20, "Return Type: (blank to return outermost widget)"); + { f_return_type_input = new Fl_Input(10, 90, 320, 20, "Return Type: (blank to return outermost widget)"); f_return_type_input->tooltip("The return type of the function or method."); f_return_type_input->labelfont(1); f_return_type_input->labelsize(11); f_return_type_input->textfont(4); f_return_type_input->textsize(11); - f_return_type_input->align(FL_ALIGN_TOP_LEFT); + f_return_type_input->align(Fl_Align(FL_ALIGN_TOP_LEFT)); f_return_type_input->when(FL_WHEN_NEVER); } // Fl_Input* f_return_type_input - { Fl_Group* o = new Fl_Group(10, 120, 270, 20); - { f_panel_ok = new Fl_Return_Button(170, 120, 50, 20, "OK"); + { Fl_Group* o = new Fl_Group(10, 200, 320, 20); + { f_panel_ok = new Fl_Return_Button(220, 200, 50, 20, "OK"); f_panel_ok->tooltip("Apply the changes."); f_panel_ok->labelsize(11); f_panel_ok->window()->hotspot(f_panel_ok); } // Fl_Return_Button* f_panel_ok - { f_panel_cancel = new Fl_Button(230, 120, 50, 20, "Cancel"); + { f_panel_cancel = new Fl_Button(280, 200, 50, 20, "Cancel"); f_panel_cancel->tooltip("Cancel the changes."); f_panel_cancel->shortcut(0xff1b); f_panel_cancel->labelsize(11); } // Fl_Button* f_panel_cancel - { Fl_Box* o = new Fl_Box(10, 120, 150, 20); + { Fl_Box* o = new Fl_Box(10, 200, 205, 20); Fl_Group::current()->resizable(o); } // Fl_Box* o o->end(); } // Fl_Group* o - o->size_range(o->w(), o->h(), Fl::w(), o->h()); + { f_comment_input = new Fl_Text_Editor(10, 125, 320, 65, "Comment:"); + f_comment_input->tooltip("Function comment in Doxygen format"); + f_comment_input->box(FL_DOWN_BOX); + f_comment_input->labelfont(1); + f_comment_input->labelsize(11); + f_comment_input->textfont(4); + f_comment_input->textsize(11); + f_comment_input->align(Fl_Align(FL_ALIGN_TOP_LEFT)); + Fl_Group::current()->resizable(f_comment_input); + f_comment_input->buffer(new Fl_Text_Buffer()); + } // Fl_Text_Editor* f_comment_input function_panel->set_modal(); function_panel->end(); } // Fl_Double_Window* function_panel @@ -155,7 +166,7 @@ Fl_Double_Window* make_code_panel() { code_input->labelcolor(FL_FOREGROUND_COLOR); code_input->textfont(4); code_input->textsize(11); - code_input->align(FL_ALIGN_TOP); + code_input->align(Fl_Align(FL_ALIGN_TOP)); code_input->when(FL_WHEN_RELEASE); Fl_Group::current()->resizable(code_input); o->when(FL_WHEN_ENTER_KEY_CHANGED|FL_WHEN_RELEASE); @@ -201,7 +212,7 @@ Fl_Double_Window* make_codeblock_panel() { code_before_input->labelsize(11); code_before_input->textfont(4); code_before_input->textsize(11); - code_before_input->align(FL_ALIGN_TOP_LEFT); + code_before_input->align(Fl_Align(FL_ALIGN_TOP_LEFT)); code_before_input->when(FL_WHEN_NEVER); } // Fl_Input* code_before_input { code_after_input = new Fl_Input(10, 55, 280, 20, "\"{...child code...}\" is inserted here"); @@ -209,7 +220,7 @@ Fl_Double_Window* make_codeblock_panel() { code_after_input->labelsize(11); code_after_input->textfont(4); code_after_input->textsize(11); - code_after_input->align(FL_ALIGN_TOP_LEFT); + code_after_input->align(Fl_Align(FL_ALIGN_TOP_LEFT)); code_after_input->when(FL_WHEN_NEVER); Fl_Group::current()->resizable(code_after_input); } // Fl_Input* code_after_input @@ -282,7 +293,7 @@ Fl_Double_Window* make_declblock_panel() { decl_before_input->labelsize(11); decl_before_input->textfont(4); decl_before_input->textsize(11); - decl_before_input->align(FL_ALIGN_TOP_LEFT); + decl_before_input->align(Fl_Align(FL_ALIGN_TOP_LEFT)); decl_before_input->when(FL_WHEN_NEVER); Fl_Group::current()->resizable(decl_before_input); } // Fl_Input* decl_before_input @@ -291,7 +302,7 @@ Fl_Double_Window* make_declblock_panel() { decl_after_input->labelsize(11); decl_after_input->textfont(4); decl_after_input->textsize(11); - decl_after_input->align(FL_ALIGN_TOP_LEFT); + decl_after_input->align(Fl_Align(FL_ALIGN_TOP_LEFT)); decl_after_input->when(FL_WHEN_NEVER); } // Fl_Input* decl_after_input { Fl_Group* o = new Fl_Group(10, 105, 280, 20); @@ -342,9 +353,11 @@ Fl_Return_Button *decl_panel_ok=(Fl_Return_Button *)0; Fl_Button *decl_panel_cancel=(Fl_Button *)0; +Fl_Text_Editor *decl_comment_input=(Fl_Text_Editor *)0; + Fl_Double_Window* make_decl_panel() { - { Fl_Double_Window* o = decl_panel = new Fl_Double_Window(290, 150, "Declaration Properties"); - decl_panel->align(FL_ALIGN_CLIP|FL_ALIGN_INSIDE); + { decl_panel = new Fl_Double_Window(343, 237, "Declaration Properties"); + decl_panel->align(Fl_Align(FL_ALIGN_CLIP|FL_ALIGN_INSIDE)); { Fl_Group* o = new Fl_Group(10, 10, 270, 20); { Fl_Box* o = new Fl_Box(200, 10, 80, 20); Fl_Group::current()->resizable(o); @@ -363,32 +376,43 @@ Fl_Double_Window* make_decl_panel() { } // Fl_Choice* decl_class_choice o->end(); } // Fl_Group* o - { decl_input = new Fl_Input(10, 40, 270, 20, "Can be any declaration, like \"int x;\", an external symbol like \"extern int\ - foo();\", a #directive like \"#include \", a comment like \"//foo\" or\ - \"/*foo*/\", or typedef like \"typedef char byte;\" or \"using std::list;\"."); + { decl_input = new Fl_Input(10, 40, 320, 20, "This can be any declaration, like \"int x;\", an external symbol like \"exter\ +n int foo();\", a #directive like \"#include \", a comment like \"//foo\ +\" or \"/*foo*/\", or typedef like \"typedef char byte;\" or \"using std::list\ +;\"."); decl_input->tooltip("Declaration text."); decl_input->labelsize(11); decl_input->textfont(4); decl_input->textsize(11); - decl_input->align(134); + decl_input->align(Fl_Align(134)); decl_input->when(FL_WHEN_NEVER); - Fl_Group::current()->resizable(decl_input); } // Fl_Input* decl_input - { Fl_Group* o = new Fl_Group(10, 120, 270, 20); - { decl_panel_ok = new Fl_Return_Button(150, 120, 60, 20, "OK"); + { Fl_Group* o = new Fl_Group(10, 205, 320, 20); + { decl_panel_ok = new Fl_Return_Button(200, 205, 60, 20, "OK"); decl_panel_ok->labelsize(11); decl_panel_ok->window()->hotspot(decl_panel_ok); } // Fl_Return_Button* decl_panel_ok - { decl_panel_cancel = new Fl_Button(220, 120, 60, 20, "Cancel"); + { decl_panel_cancel = new Fl_Button(270, 205, 60, 20, "Cancel"); decl_panel_cancel->shortcut(0xff1b); decl_panel_cancel->labelsize(11); } // Fl_Button* decl_panel_cancel - { Fl_Box* o = new Fl_Box(10, 120, 130, 20); + { Fl_Box* o = new Fl_Box(10, 205, 185, 20); Fl_Group::current()->resizable(o); } // Fl_Box* o o->end(); } // Fl_Group* o - o->size_range(o->w(), o->h(), Fl::w(), o->h()); + { decl_comment_input = new Fl_Text_Editor(10, 130, 320, 65, "Comment:"); + decl_comment_input->tooltip("Declaration comment in Doxygen format"); + decl_comment_input->box(FL_DOWN_BOX); + decl_comment_input->labelfont(1); + decl_comment_input->labelsize(11); + decl_comment_input->textfont(4); + decl_comment_input->textsize(11); + decl_comment_input->align(Fl_Align(FL_ALIGN_TOP_LEFT)); + Fl_Group::current()->resizable(decl_comment_input); + decl_comment_input->buffer(new Fl_Text_Buffer()); + } // Fl_Text_Editor* decl_comment_input + decl_panel->size_range(343, 237); decl_panel->end(); } // Fl_Double_Window* decl_panel return decl_panel; @@ -402,12 +426,14 @@ Fl_Input *c_name_input=(Fl_Input *)0; Fl_Input *c_subclass_input=(Fl_Input *)0; +Fl_Text_Editor *c_comment_input=(Fl_Text_Editor *)0; + Fl_Return_Button *c_panel_ok=(Fl_Return_Button *)0; Fl_Button *c_panel_cancel=(Fl_Button *)0; Fl_Double_Window* make_class_panel() { - { Fl_Double_Window* o = class_panel = new Fl_Double_Window(300, 115, "Class Properties"); + { class_panel = new Fl_Double_Window(342, 196, "Class Properties"); class_panel->labelsize(11); { Fl_Group* o = new Fl_Group(10, 10, 280, 20); o->hide(); @@ -422,41 +448,51 @@ Fl_Double_Window* make_class_panel() { } // Fl_Box* o o->end(); } // Fl_Group* o - { c_name_input = new Fl_Input(10, 20, 280, 20, "Name:"); + { c_name_input = new Fl_Input(10, 20, 320, 20, "Name:"); c_name_input->tooltip("Name of class."); c_name_input->labelfont(1); c_name_input->labelsize(11); c_name_input->textfont(4); c_name_input->textsize(11); - c_name_input->align(FL_ALIGN_TOP_LEFT); + c_name_input->align(Fl_Align(FL_ALIGN_TOP_LEFT)); c_name_input->when(FL_WHEN_NEVER); - Fl_Group::current()->resizable(c_name_input); } // Fl_Input* c_name_input - { c_subclass_input = new Fl_Input(10, 55, 280, 20, "Subclass of (text between : and {)"); + { c_subclass_input = new Fl_Input(10, 55, 320, 20, "Subclass of (text between : and {)"); c_subclass_input->tooltip("Name of subclass."); c_subclass_input->labelfont(1); c_subclass_input->labelsize(11); c_subclass_input->textfont(4); c_subclass_input->textsize(11); - c_subclass_input->align(FL_ALIGN_TOP_LEFT); + c_subclass_input->align(Fl_Align(FL_ALIGN_TOP_LEFT)); c_subclass_input->when(FL_WHEN_NEVER); } // Fl_Input* c_subclass_input - { Fl_Group* o = new Fl_Group(10, 85, 280, 20); - { c_panel_ok = new Fl_Return_Button(160, 85, 60, 20, "OK"); + { c_comment_input = new Fl_Text_Editor(10, 90, 320, 65, "Comment:"); + c_comment_input->tooltip("Class comment in Doxygen format"); + c_comment_input->box(FL_DOWN_BOX); + c_comment_input->labelfont(1); + c_comment_input->labelsize(11); + c_comment_input->textfont(4); + c_comment_input->textsize(11); + c_comment_input->align(Fl_Align(FL_ALIGN_TOP_LEFT)); + Fl_Group::current()->resizable(c_comment_input); + c_comment_input->buffer(new Fl_Text_Buffer()); + } // Fl_Text_Editor* c_comment_input + { Fl_Group* o = new Fl_Group(10, 165, 320, 20); + { c_panel_ok = new Fl_Return_Button(200, 165, 60, 20, "OK"); c_panel_ok->labelsize(11); c_panel_ok->window()->hotspot(c_panel_ok); } // Fl_Return_Button* c_panel_ok - { c_panel_cancel = new Fl_Button(230, 85, 60, 20, "Cancel"); + { c_panel_cancel = new Fl_Button(270, 165, 60, 20, "Cancel"); c_panel_cancel->shortcut(0xff1b); c_panel_cancel->labelsize(11); } // Fl_Button* c_panel_cancel - { Fl_Box* o = new Fl_Box(10, 85, 140, 20); + { Fl_Box* o = new Fl_Box(10, 165, 185, 20); Fl_Group::current()->resizable(o); } // Fl_Box* o o->end(); } // Fl_Group* o - o->size_range(o->w(), o->h(), Fl::w(), o->h()); class_panel->set_modal(); + class_panel->size_range(343, 188); class_panel->end(); } // Fl_Double_Window* class_panel return class_panel; @@ -491,7 +527,7 @@ Fl_Double_Window* make_comment_panel() { comment_input->labelcolor(FL_FOREGROUND_COLOR); comment_input->textfont(4); comment_input->textsize(11); - comment_input->align(FL_ALIGN_TOP); + comment_input->align(Fl_Align(FL_ALIGN_TOP)); comment_input->when(FL_WHEN_RELEASE); Fl_Group::current()->resizable(comment_input); o->when(FL_WHEN_ENTER_KEY_CHANGED|FL_WHEN_RELEASE); @@ -561,7 +597,7 @@ Fl_Window *widgetbin_panel=(Fl_Window *)0; Fl_Window* make_widgetbin() { { widgetbin_panel = new Fl_Window(550, 85, "Widget Bin"); - widgetbin_panel->align(FL_ALIGN_CLIP|FL_ALIGN_INSIDE); + widgetbin_panel->align(Fl_Align(FL_ALIGN_CLIP|FL_ALIGN_INSIDE)); { Fl_Group* o = new Fl_Group(3, 3, 79, 79); { Fl_Button* o = new Fl_Button(5, 5, 24, 24); o->tooltip("Function"); @@ -898,10 +934,21 @@ Fl_Light_Button *sv_autorefresh=(Fl_Light_Button *)0; Fl_Light_Button *sv_autoposition=(Fl_Light_Button *)0; +/** + Create a preview window for the C++ source code. + + This function creates a dialog box with two tabs + for previewing thw header and source file that will + be generated from the current database. + + The created window is modal. + + \return the newly created dialog window +*/ Fl_Double_Window* make_sourceview() { { sourceview_panel = new Fl_Double_Window(520, 490, "Code View"); sourceview_panel->callback((Fl_Callback*)toggle_sourceview_cb); - sourceview_panel->align(FL_ALIGN_CLIP|FL_ALIGN_INSIDE); + sourceview_panel->align(Fl_Align(FL_ALIGN_CLIP|FL_ALIGN_INSIDE)); { sv_tab = new Fl_Tabs(10, 10, 500, 440); sv_tab->selection_color((Fl_Color)4); sv_tab->labelcolor(FL_BACKGROUND2_COLOR); @@ -919,7 +966,7 @@ Fl_Double_Window* make_sourceview() { sv_source->labelcolor(FL_FOREGROUND_COLOR); sv_source->textfont(4); sv_source->textsize(11); - sv_source->align(FL_ALIGN_TOP); + sv_source->align(Fl_Align(FL_ALIGN_TOP)); sv_source->when(FL_WHEN_RELEASE); Fl_Group::current()->resizable(sv_source); } // CodeViewer* sv_source @@ -938,7 +985,7 @@ Fl_Double_Window* make_sourceview() { sv_header->labelcolor(FL_FOREGROUND_COLOR); sv_header->textfont(4); sv_header->textsize(11); - sv_header->align(FL_ALIGN_TOP); + sv_header->align(Fl_Align(FL_ALIGN_TOP)); sv_header->when(FL_WHEN_RELEASE); Fl_Group::current()->resizable(sv_header); } // CodeViewer* sv_header diff --git a/fluid/function_panel.fl b/fluid/function_panel.fl index 6f279d741..fddab8c29 100644 --- a/fluid/function_panel.fl +++ b/fluid/function_panel.fl @@ -1,5 +1,5 @@ # data file for the Fltk User Interface Designer (fluid) -version 1.0108 +version 1.0300 header_name {.h} code_name {.cxx} comment {// @@ -46,8 +46,7 @@ decl {extern void select_only(Fl_Type*);} {} Function {make_function_panel()} {} { Fl_Window function_panel { label {Function/Method Properties} open - xywh {412 442 290 150} type Double resizable - code0 {o->size_range(o->w(), o->h(), Fl::w(), o->h());} modal visible + xywh {394 671 343 232} type Double resizable modal visible } { Fl_Group {} {open xywh {10 10 270 20} @@ -95,27 +94,32 @@ Function {make_function_panel()} {} { } Fl_Input f_name_input { label {Name(args): (blank for main())} - tooltip {The name of the function or method.} xywh {10 50 270 20} labelfont 1 labelsize 11 align 5 when 0 textfont 4 textsize 11 resizable + tooltip {The name of the function or method.} xywh {10 50 320 20} labelfont 1 labelsize 11 align 5 when 0 textfont 4 textsize 11 } Fl_Input f_return_type_input { label {Return Type: (blank to return outermost widget)} - tooltip {The return type of the function or method.} xywh {10 90 270 20} labelfont 1 labelsize 11 align 5 when 0 textfont 4 textsize 11 + tooltip {The return type of the function or method.} xywh {10 90 320 20} labelfont 1 labelsize 11 align 5 when 0 textfont 4 textsize 11 } Fl_Group {} { - xywh {10 120 270 20} + xywh {10 200 320 20} } { Fl_Return_Button f_panel_ok { label OK - tooltip {Apply the changes.} xywh {170 120 50 20} labelsize 11 hotspot + tooltip {Apply the changes.} xywh {220 200 50 20} labelsize 11 hotspot } Fl_Button f_panel_cancel { label Cancel - tooltip {Cancel the changes.} xywh {230 120 50 20} shortcut 0xff1b labelsize 11 + tooltip {Cancel the changes.} xywh {280 200 50 20} shortcut 0xff1b labelsize 11 } Fl_Box {} { - xywh {10 120 150 20} resizable + xywh {10 200 205 20} resizable } } + Fl_Text_Editor f_comment_input { + label {Comment:} + tooltip {Function comment in Doxygen format} xywh {10 125 320 65} box DOWN_BOX labelfont 1 labelsize 11 align 5 textfont 4 textsize 11 resizable + code0 {f_comment_input->buffer(new Fl_Text_Buffer());} + } } } @@ -237,12 +241,10 @@ Function {make_declblock_panel()} {} { } } -Function {make_decl_panel()} {selected -} { +Function {make_decl_panel()} {} { Fl_Window decl_panel { label {Declaration Properties} open - xywh {501 185 290 150} type Double align 80 resizable - code0 {o->size_range(o->w(), o->h(), Fl::w(), o->h());} visible + xywh {395 411 343 237} type Double align 80 resizable size_range {343 237 0 0} visible } { Fl_Group {} {open xywh {10 10 270 20} @@ -288,32 +290,36 @@ Function {make_decl_panel()} {selected } } Fl_Input decl_input { - label {Can be any declaration, like "int x;", an external symbol like "extern int foo();", a \#directive like "\#include ", a comment like "//foo" or "/*foo*/", or typedef like "typedef char byte;" or "using std::list;".} - tooltip {Declaration text.} xywh {10 40 270 20} labelsize 11 align 134 when 0 textfont 4 textsize 11 resizable + label {This can be any declaration, like "int x;", an external symbol like "extern int foo();", a \#directive like "\#include ", a comment like "//foo" or "/*foo*/", or typedef like "typedef char byte;" or "using std::list;".} + tooltip {Declaration text.} xywh {10 40 320 20} labelsize 11 align 134 when 0 textfont 4 textsize 11 } Fl_Group {} {open - xywh {10 120 270 20} + xywh {10 205 320 20} } { Fl_Return_Button decl_panel_ok { label OK - xywh {150 120 60 20} labelsize 11 hotspot + xywh {200 205 60 20} labelsize 11 hotspot } Fl_Button decl_panel_cancel { label Cancel - xywh {220 120 60 20} shortcut 0xff1b labelsize 11 + xywh {270 205 60 20} shortcut 0xff1b labelsize 11 } Fl_Box {} { - xywh {10 120 130 20} resizable + xywh {10 205 185 20} resizable } } + Fl_Text_Editor decl_comment_input { + label {Comment:} + tooltip {Declaration comment in Doxygen format} xywh {10 130 320 65} box DOWN_BOX labelfont 1 labelsize 11 align 5 textfont 4 textsize 11 resizable + code0 {decl_comment_input->buffer(new Fl_Text_Buffer());} + } } } Function {make_class_panel()} {} { Fl_Window class_panel { label {Class Properties} open - xywh {449 218 300 115} type Double labelsize 11 resizable - code0 {o->size_range(o->w(), o->h(), Fl::w(), o->h());} modal visible + xywh {395 191 342 196} type Double labelsize 11 resizable modal size_range {343 188 0 0} visible } { Fl_Group {} {open xywh {10 10 280 20} hide @@ -328,25 +334,30 @@ Function {make_class_panel()} {} { } Fl_Input c_name_input { label {Name:} - tooltip {Name of class.} xywh {10 20 280 20} labelfont 1 labelsize 11 align 5 when 0 textfont 4 textsize 11 resizable + tooltip {Name of class.} xywh {10 20 320 20} labelfont 1 labelsize 11 align 5 when 0 textfont 4 textsize 11 } Fl_Input c_subclass_input { label {Subclass of (text between : and \{)} - tooltip {Name of subclass.} xywh {10 55 280 20} labelfont 1 labelsize 11 align 5 when 0 textfont 4 textsize 11 + tooltip {Name of subclass.} xywh {10 55 320 20} labelfont 1 labelsize 11 align 5 when 0 textfont 4 textsize 11 + } + Fl_Text_Editor c_comment_input { + label {Comment:} + tooltip {Class comment in Doxygen format} xywh {10 90 320 65} box DOWN_BOX labelfont 1 labelsize 11 align 5 textfont 4 textsize 11 resizable + code0 {c_comment_input->buffer(new Fl_Text_Buffer());} } Fl_Group {} {open - xywh {10 85 280 20} + xywh {10 165 320 20} } { Fl_Return_Button c_panel_ok { label OK - xywh {160 85 60 20} labelsize 11 hotspot + xywh {200 165 60 20} labelsize 11 hotspot } Fl_Button c_panel_cancel { label Cancel - xywh {230 85 60 20} shortcut 0xff1b labelsize 11 + xywh {270 165 60 20} shortcut 0xff1b labelsize 11 } Fl_Box {} { - xywh {10 85 140 20} resizable + xywh {10 165 185 20} resizable } } } @@ -354,7 +365,7 @@ Function {make_class_panel()} {} { Function {make_comment_panel()} {} { Fl_Window comment_panel { - label {Comment Properties} + label {Comment Properties} open xywh {422 190 550 280} type Double labelsize 11 resizable code0 {o->size_range(320, 180);} modal visible } { @@ -418,7 +429,8 @@ Function {type_make_cb(Fl_Widget*,void*d)} {return_type void }} {} } -Function {make_widgetbin()} {} { +Function {make_widgetbin()} {selected +} { Fl_Window widgetbin_panel { label {Widget Bin} xywh {411 171 550 85} type Single align 80 non_modal visible @@ -752,7 +764,17 @@ Function {make_widgetbin()} {} { } } -Function {make_sourceview()} {} { +Function {make_sourceview()} { + comment {Create a preview window for the C++ source code. + +This function creates a dialog box with two tabs +for previewing thw header and source file that will +be generated from the current database. + +The created window is modal. + +\\return the newly created dialog window} +} { Fl_Window sourceview_panel { label {Code View} callback toggle_sourceview_cb diff --git a/fluid/function_panel.h b/fluid/function_panel.h index 3171288f6..52d353d00 100644 --- a/fluid/function_panel.h +++ b/fluid/function_panel.h @@ -46,6 +46,8 @@ extern Fl_Input *f_return_type_input; extern Fl_Return_Button *f_panel_ok; #include extern Fl_Button *f_panel_cancel; +#include +extern Fl_Text_Editor *f_comment_input; Fl_Double_Window* make_function_panel(); extern Fl_Menu_Item menu_f_public_member_choice[]; extern Fl_Menu_Item menu_f_public_choice[]; @@ -76,6 +78,7 @@ extern Fl_Choice *decl_class_choice; extern Fl_Input *decl_input; extern Fl_Return_Button *decl_panel_ok; extern Fl_Button *decl_panel_cancel; +extern Fl_Text_Editor *decl_comment_input; Fl_Double_Window* make_decl_panel(); extern Fl_Menu_Item menu_decl_choice[]; extern Fl_Menu_Item menu_decl_class_choice[]; @@ -83,6 +86,7 @@ extern Fl_Double_Window *class_panel; extern Fl_Light_Button *c_public_button; extern Fl_Input *c_name_input; extern Fl_Input *c_subclass_input; +extern Fl_Text_Editor *c_comment_input; extern Fl_Return_Button *c_panel_ok; extern Fl_Button *c_panel_cancel; Fl_Double_Window* make_class_panel(); -- cgit v1.2.3