#856: FLUID: improved Declaration dialog

Also makes enum comment in Fl_File_Chooser.fl manageable.
Not backward compatible: don't try to recreate the
File Chooser with older FLUID versions.
This commit is contained in:
Matthias Melcher 2023-12-05 17:54:01 +01:00
parent cb0930190a
commit 7a69c22bd7
6 changed files with 106 additions and 53 deletions

View File

@ -43,8 +43,8 @@
class FL_EXPORT Fl_File_Chooser {
public:
/**
\enum Type
Determines the type of file chooser presented to the user.
\enum Type
Determines the type of file chooser presented to the user.
*/
enum Type {
SINGLE = 0, ///< Select a single, existing file.

View File

@ -940,7 +940,7 @@ void Fl_Decl_Type::read_property(Fd_Project_Reader &f, const char *c) {
*/
void Fl_Decl_Type::open() {
if (!decl_panel) make_decl_panel();
decl_input->value(name());
decl_input->buffer()->text(name());
if (is_in_class()) {
decl_class_choice->value(public_);
decl_class_choice->show();
@ -963,7 +963,7 @@ void Fl_Decl_Type::open() {
else if (!w) Fl::wait();
}
// check values
const char*c = decl_input->value();
const char*c = decl_input->buffer()->text();
while (isspace(*c)) c++;
message = c_check(c&&c[0]=='#' ? c+1 : c);
// alert user
@ -1018,6 +1018,7 @@ void Fl_Decl_Type::write_code1(Fd_Code_Writer& f) {
|| (!strncmp(c,"typedef",7) && isspace(c[7]))
|| (!strncmp(c,"FL_EXPORT",9) && isspace(c[9]))
|| (!strncmp(c,"struct",6) && isspace(c[6]))
|| (!strncmp(c,"enum",4) && isspace(c[4]))
) ) {
f.write_public(public_);
write_comment_h(f, f.indent(1));

View File

@ -354,7 +354,7 @@ Fl_Menu_Item menu_decl_class_choice[] = {
{0,0,0,0,0,0,0,0,0}
};
Fl_Input *decl_input=(Fl_Input *)0;
CodeEditor *decl_input=(CodeEditor *)0;
Fl_Text_Editor *decl_comment_input=(Fl_Text_Editor *)0;
@ -363,7 +363,7 @@ Fl_Return_Button *decl_panel_ok=(Fl_Return_Button *)0;
Fl_Button *decl_panel_cancel=(Fl_Button *)0;
Fl_Double_Window* make_decl_panel() {
{ decl_panel = new Fl_Double_Window(343, 237, "Declaration Properties");
{ decl_panel = new Fl_Double_Window(343, 262, "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);
@ -383,44 +383,67 @@ Fl_Double_Window* make_decl_panel() {
} // Fl_Choice* decl_class_choice
o->end();
} // Fl_Group* o
{ decl_input = new Fl_Input(10, 40, 320, 20, "This can be any declaration, like \"int x;\", an external symbol like \"exter\
{ Fl_Tile* o = new Fl_Tile(10, 40, 320, 180);
{ Fl_Group* o = new Fl_Group(10, 40, 320, 100);
o->box(FL_FLAT_BOX);
{ decl_input = new CodeEditor(10, 40, 320, 45, "This can be any declaration, like \"int x;\", an external symbol like \"exter\
n int foo();\", a #directive like \"#include <foo.h>\", 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(Fl_Align(134));
decl_input->when(FL_WHEN_NEVER);
} // Fl_Input* decl_input
{ 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());
decl_comment_input->add_key_binding(FL_Tab, 0, use_tab_navigation);
} // Fl_Text_Editor* decl_comment_input
{ Fl_Group* o = new Fl_Group(10, 205, 320, 20);
{ decl_panel_ok = new Fl_Return_Button(200, 205, 60, 20, "OK");
decl_input->box(FL_DOWN_FRAME);
decl_input->color(FL_BACKGROUND2_COLOR);
decl_input->selection_color(FL_SELECTION_COLOR);
decl_input->labeltype(FL_NORMAL_LABEL);
decl_input->labelfont(0);
decl_input->labelsize(11);
decl_input->labelcolor(FL_FOREGROUND_COLOR);
decl_input->align(Fl_Align(134));
decl_input->when(FL_WHEN_RELEASE);
Fl_Group::current()->resizable(decl_input);
} // CodeEditor* decl_input
{ Fl_Box* o = new Fl_Box(20, 139, 300, 1);
o->box(FL_BORDER_FRAME);
o->color((Fl_Color)43);
} // Fl_Box* o
o->end();
Fl_Group::current()->resizable(o);
} // Fl_Group* o
{ Fl_Group* o = new Fl_Group(10, 140, 320, 80);
o->box(FL_FLAT_BOX);
{ decl_comment_input = new Fl_Text_Editor(10, 155, 320, 64, "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());
decl_comment_input->add_key_binding(FL_Tab, 0, use_tab_navigation);
} // Fl_Text_Editor* decl_comment_input
o->end();
} // Fl_Group* o
o->size_range(0, 320, 100);
o->size_range(1, 320, 60);
o->end();
Fl_Group::current()->resizable(o);
} // Fl_Tile* o
{ Fl_Group* o = new Fl_Group(10, 230, 320, 20);
{ decl_panel_ok = new Fl_Return_Button(200, 230, 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(270, 205, 60, 20, "Cancel");
{ decl_panel_cancel = new Fl_Button(270, 230, 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, 205, 185, 20);
{ Fl_Box* o = new Fl_Box(10, 230, 185, 20);
Fl_Group::current()->resizable(o);
} // Fl_Box* o
o->end();
} // Fl_Group* o
decl_panel->size_range(343, 237);
decl_panel->size_range(343, 262);
decl_panel->end();
} // Fl_Double_Window* decl_panel
return decl_panel;

View File

@ -51,7 +51,7 @@ Function {make_function_panel()} {open
} {
Fl_Window function_panel {
label {Function/Method Properties}
xywh {540 418 343 232} type Double hide resizable modal
xywh {540 418 343 232} type Double resizable modal visible
} {
Fl_Group {} {open
xywh {10 10 270 20}
@ -264,8 +264,8 @@ Function {make_declblock_panel()} {open
Function {make_decl_panel()} {open
} {
Fl_Window decl_panel {
label {Declaration Properties}
xywh {497 618 343 237} type Double align 80 hide resizable size_range {343 237 0 0}
label {Declaration Properties} open selected
xywh {497 618 343 262} type Double align 80 resizable size_range {343 262 0 0} visible
} {
Fl_Group {} {
xywh {10 10 270 20}
@ -310,29 +310,48 @@ Function {make_decl_panel()} {open
}
}
}
Fl_Input decl_input {
label {This can be any declaration, like "int x;", an external symbol like "extern int foo();", a \#directive like "\#include <foo.h>", 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_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());}
code1 {decl_comment_input->add_key_binding(FL_Tab, 0, use_tab_navigation);}
Fl_Tile {} {open
xywh {10 40 320 180} resizable
code2 {o->size_range(0, 320, 100);}
code3 {o->size_range(1, 320, 60);}
} {
Fl_Group {} {open
xywh {10 40 320 100} box FLAT_BOX resizable
} {
Fl_Text_Editor decl_input {
label {This can be any declaration, like "int x;", an external symbol like "extern int foo();", a \#directive like "\#include <foo.h>", a comment like "//foo" or "/*foo*/", or typedef like "typedef char byte;" or "using std::list;".}
xywh {10 40 320 45} labelsize 11 align 134 resizable
code0 {\#include "CodeEditor.h"}
class CodeEditor
}
Fl_Box {} {
xywh {20 139 300 1} box BORDER_FRAME color 43
}
}
Fl_Group {} {open
xywh {10 140 320 80} box FLAT_BOX
} {
Fl_Text_Editor decl_comment_input {
label {Comment:}
tooltip {Declaration comment in Doxygen format} xywh {10 155 320 64} box DOWN_BOX labelfont 1 labelsize 11 align 5 textfont 4 textsize 11 resizable
code0 {decl_comment_input->buffer(new Fl_Text_Buffer());}
code1 {decl_comment_input->add_key_binding(FL_Tab, 0, use_tab_navigation);}
}
}
}
Fl_Group {} {open
xywh {10 205 320 20}
xywh {10 230 320 20}
} {
Fl_Return_Button decl_panel_ok {
label OK
xywh {200 205 60 20} labelsize 11 hotspot
xywh {200 230 60 20} labelsize 11 hotspot
}
Fl_Button decl_panel_cancel {
label Cancel
xywh {270 205 60 20} shortcut 0xff1b labelsize 11
xywh {270 230 60 20} shortcut 0xff1b labelsize 11
}
Fl_Box {} {
xywh {10 205 185 20} resizable
xywh {10 230 185 20} resizable
}
}
}
@ -341,7 +360,7 @@ Function {make_decl_panel()} {open
Function {make_data_panel()} {open
} {
Fl_Window data_panel {
label {Inline Data Properties} open
label {Inline Data Properties}
xywh {567 382 343 264} type Double align 80 resizable size_range {343 237 0 0} visible
} {
Fl_Group {} {open

View File

@ -64,7 +64,8 @@ extern Fl_Menu_Item menu_declblock_public_choice[];
extern Fl_Double_Window *decl_panel;
extern Fl_Choice *decl_choice;
extern Fl_Choice *decl_class_choice;
extern Fl_Input *decl_input;
#include <FL/Fl_Tile.H>
extern CodeEditor *decl_input;
extern Fl_Text_Editor *decl_comment_input;
extern Fl_Return_Button *decl_panel_ok;
extern Fl_Button *decl_panel_cancel;

View File

@ -32,7 +32,17 @@ decl {\#include <FL/fl_draw.H>} {private local
class FL_EXPORT Fl_File_Chooser {open
} {
decl {enum { SINGLE = 0, MULTI = 1, CREATE = 2, DIRECTORY = 4 };} {public local
decl {enum Type {
SINGLE = 0, ///< Select a single, existing file.
MULTI = 1, ///< Select one or more existing files.
CREATE = 2, ///< When used alone, select a single, existing file or specify a new filename.
///< Can be combined with DIRECTORY (e.g. CREATE|DIRECTORY) to have the same
///< effect for directories.
DIRECTORY = 4 ///< Select a single, existing directory. Can be combined with CREATE.
};} {
comment {\\enum Type
Determines the type of file chooser presented to the user.
} selected public local
}
decl {static Fl_Preferences *prefs_;} {private local
}
@ -54,7 +64,7 @@ class FL_EXPORT Fl_File_Chooser {open
}
decl {void fileListCB();} {private local
}
decl {void fileNameCB();} {selected private local
decl {void fileNameCB();} {private local
}
decl {void newdir();} {private local
}
@ -389,8 +399,7 @@ else
}
Function {user_data(void *d)} {return_type void
} {
code {data_ = d;} {selected
}
code {data_ = d;} {}
}
decl {const char *value(int f = 1);} {public local
}