FLUID: Improve usability of Declaration Blocks

Decl Blocks can now output code around static code
in source and header files.
This commit is contained in:
Matthias Melcher 2024-04-25 17:52:32 +02:00
parent c0d2aa3f09
commit e52a358e85
11 changed files with 339 additions and 142 deletions

View File

@ -331,10 +331,10 @@ void Fl_Function_Type::open() {
}
c = f_comment_input->buffer()->text();
if (c && *c) {
if (!comment() || strcmp(c, comment())) redraw_browser();
if (!comment() || strcmp(c, comment())) { set_modflag(1); redraw_browser(); }
comment(c);
} else {
if (comment()) redraw_browser();
if (comment()) { set_modflag(1); redraw_browser(); }
comment(0);
}
if (c) free((void*)c);
@ -993,10 +993,10 @@ void Fl_Decl_Type::open() {
}
c = decl_comment_input->buffer()->text();
if (c && *c) {
if (!comment() || strcmp(c, comment())) redraw_browser();
if (!comment() || strcmp(c, comment())) { set_modflag(1); redraw_browser(); }
comment(c);
} else {
if (comment()) redraw_browser();
if (comment()) { set_modflag(1); redraw_browser(); }
comment(0);
}
if (c) free((void*)c);
@ -1253,10 +1253,10 @@ void Fl_Data_Type::open() {
// store the comment
c = data_comment_input->buffer()->text();
if (c && *c) {
if (!comment() || strcmp(c, comment())) redraw_browser();
if (!comment() || strcmp(c, comment())) { set_modflag(1); redraw_browser(); }
comment(c);
} else {
if (comment()) redraw_browser();
if (comment()) { set_modflag(1); redraw_browser(); }
comment(0);
}
if (c) free((void*)c);
@ -1423,7 +1423,8 @@ Fl_DeclBlock_Type Fl_DeclBlock_type;
*/
Fl_DeclBlock_Type::Fl_DeclBlock_Type() :
Fl_Type(),
after(NULL)
after(NULL),
write_map_(CODE_IN_SOURCE)
{ }
/**
@ -1431,13 +1432,15 @@ Fl_DeclBlock_Type::Fl_DeclBlock_Type() :
*/
Fl_DeclBlock_Type::~Fl_DeclBlock_Type() {
if (after)
free((void*)after);
::free((void*)after);
}
/**
Return 1 if this block is public.
*/
int Fl_DeclBlock_Type::is_public() const {return public_;}
int Fl_DeclBlock_Type::is_public() const {
return ((write_map_&CODE_IN_HEADER) != 0);
}
/**
Create a new declaration block.
@ -1449,7 +1452,7 @@ Fl_Type *Fl_DeclBlock_Type::make(Strategy strategy) {
while (p && !p->is_decl_block()) p = p->parent;
Fl_DeclBlock_Type *o = new Fl_DeclBlock_Type();
o->name("#if 1");
o->public_ = 0;
o->write_map_ = CODE_IN_SOURCE;
o->after = fl_strdup("#endif");
o->add(p, strategy);
o->factory = this;
@ -1463,10 +1466,11 @@ Fl_Type *Fl_DeclBlock_Type::make(Strategy strategy) {
*/
void Fl_DeclBlock_Type::write_properties(Fd_Project_Writer &f) {
Fl_Type::write_properties(f);
switch (public_) {
case 1: f.write_string("public"); break;
case 2: f.write_string("protected"); break;
}
// deprecated
if (is_public()) f.write_string("public");
// new way to map declaration block to various parts of the generated code
if (write_map_ != CODE_IN_SOURCE)
f.write_string("map %d", write_map_);
f.write_string("after");
f.write_word(after);
}
@ -1476,9 +1480,11 @@ void Fl_DeclBlock_Type::write_properties(Fd_Project_Writer &f) {
*/
void Fl_DeclBlock_Type::read_property(Fd_Project_Reader &f, const char *c) {
if(!strcmp(c,"public")) {
public_ = 1;
write_map_ |= CODE_IN_HEADER;
} else if(!strcmp(c,"protected")) {
public_ = 2;
//
} else if(!strcmp(c,"map")) {
write_map_ = (int)atol(f.read_word());
} else if (!strcmp(c,"after")) {
storestring(f.read_word(),after);
} else {
@ -1490,10 +1496,18 @@ void Fl_DeclBlock_Type::read_property(Fd_Project_Reader &f, const char *c) {
Open the declblock_panel to edit this node.
*/
void Fl_DeclBlock_Type::open() {
// build dialog box
if (!declblock_panel) make_declblock_panel();
decl_before_input->value(name());
declblock_public_choice->value((public_>0));
decl_after_input->value(after);
// preset all values
declblock_before_input->value(name());
declblock_after_input->value(after);
declblock_static_header->value(write_map_ & STATIC_IN_HEADER);
declblock_static_source->value(write_map_ & STATIC_IN_SOURCE);
declblock_code_header->value(write_map_ & CODE_IN_HEADER);
declblock_code_source->value(write_map_ & CODE_IN_SOURCE);
const char *c = comment();
declblock_comment_input->buffer()->text(c?c:"");
// show modal dialog and loop until satisfied
declblock_panel->show();
const char* message = 0;
for (;;) { // repeat as long as there are errors
@ -1503,9 +1517,10 @@ void Fl_DeclBlock_Type::open() {
else if (w == declblock_panel_ok) break;
else if (!w) Fl::wait();
}
const char* a = decl_before_input->value();
// verify user input
const char* a = declblock_before_input->value();
while (isspace(*a)) a++;
const char* b = decl_after_input->value();
const char* b = declblock_after_input->value();
while (isspace(*b)) b++;
message = c_check(a&&a[0]=='#' ? a+1 : a);
if (!message)
@ -1516,19 +1531,95 @@ void Fl_DeclBlock_Type::open() {
if (v==0) continue; // Continue Editing
//if (v==1) { } // Ignore Error and close dialog
}
// store user choices in data structure
name(a);
storestring(b, after);
if (public_ != declblock_public_choice->value()) {
set_modflag(1);
public_ = declblock_public_choice->value();
redraw_browser();
if (write_map_ & STATIC_IN_HEADER) {
if (declblock_static_header->value()==0) {
write_map_ &= ~STATIC_IN_HEADER;
set_modflag(1);
}
} else {
if (declblock_static_header->value()) {
write_map_ |= STATIC_IN_HEADER;
set_modflag(1);
}
}
if (write_map_ & STATIC_IN_SOURCE) {
if (declblock_static_source->value()==0) {
write_map_ &= ~STATIC_IN_SOURCE;
set_modflag(1);
}
} else {
if (declblock_static_source->value()) {
write_map_ |= STATIC_IN_SOURCE;
set_modflag(1);
}
}
if (write_map_ & CODE_IN_HEADER) {
if (declblock_code_header->value()==0) {
write_map_ &= ~CODE_IN_HEADER;
set_modflag(1);
}
} else {
if (declblock_code_header->value()) {
write_map_ |= CODE_IN_HEADER;
set_modflag(1);
}
}
if (write_map_ & CODE_IN_SOURCE) {
if (declblock_code_source->value()==0) {
write_map_ &= ~CODE_IN_SOURCE;
set_modflag(1);
}
} else {
if (declblock_code_source->value()) {
write_map_ |= CODE_IN_SOURCE;
set_modflag(1);
}
}
c = declblock_comment_input->buffer()->text();
if (c && *c) {
if (!comment() || strcmp(c, comment())) { set_modflag(1); redraw_browser(); }
comment(c);
} else {
if (comment()) { set_modflag(1); redraw_browser(); }
comment(0);
}
if (c) free((void*)c);
break;
}
BREAK2:
declblock_panel->hide();
}
/**
Write the \b before static code to the source file, and to the header file if declared public.
The before code is stored in the name() field.
*/
void Fl_DeclBlock_Type::write_static(Fd_Code_Writer& f) {
const char* c = name();
if (c && *c) {
if (write_map_ & STATIC_IN_HEADER)
f.write_h("%s\n", c);
if (write_map_ & STATIC_IN_SOURCE)
f.write_c("%s\n", c);
}
}
/**
Write the \b after static code to the source file, and to the header file if declared public.
*/
void Fl_DeclBlock_Type::write_static_after(Fd_Code_Writer& f) {
const char* c = after;
if (c && *c) {
if (write_map_ & STATIC_IN_HEADER)
f.write_h("%s\n", c);
if (write_map_ & STATIC_IN_SOURCE)
f.write_c("%s\n", c);
}
}
/**
Write the \b before code to the source file, and to the header file if declared public.
The before code is stored in the name() field.
@ -1536,9 +1627,10 @@ BREAK2:
void Fl_DeclBlock_Type::write_code1(Fd_Code_Writer& f) {
const char* c = name();
if (c && *c) {
if (public_)
if (write_map_ & CODE_IN_HEADER)
f.write_h("%s\n", c);
f.write_c("%s\n", c);
if (write_map_ & CODE_IN_SOURCE)
f.write_c("%s\n", c);
}
}
@ -1548,9 +1640,10 @@ void Fl_DeclBlock_Type::write_code1(Fd_Code_Writer& f) {
void Fl_DeclBlock_Type::write_code2(Fd_Code_Writer& f) {
const char* c = after;
if (c && *c) {
if (public_)
if (write_map_ & CODE_IN_HEADER)
f.write_h("%s\n", c);
f.write_c("%s\n", c);
if (write_map_ & CODE_IN_SOURCE)
f.write_c("%s\n", c);
}
}
@ -1962,10 +2055,10 @@ void Fl_Class_Type::open() {
}
c = c_comment_input->buffer()->text();
if (c && *c) {
if (!comment() || strcmp(c, comment())) redraw_browser();
if (!comment() || strcmp(c, comment())) { set_modflag(1); redraw_browser(); }
comment(c);
} else {
if (comment()) redraw_browser();
if (comment()) { set_modflag(1); redraw_browser(); }
comment(0);
}
if (c) free((void*)c);

View File

@ -172,13 +172,21 @@ public:
class Fl_DeclBlock_Type : public Fl_Type
{
typedef Fl_Type super;
const char* after;
char public_;
enum {
CODE_IN_HEADER = 1,
CODE_IN_SOURCE = 2,
STATIC_IN_HEADER = 4,
STATIC_IN_SOURCE = 8
};
const char* after; ///< code after all children of this block
int write_map_; ///< see enum above
public:
Fl_DeclBlock_Type();
~Fl_DeclBlock_Type();
Fl_Type *make(Strategy strategy) FL_OVERRIDE;
void write_static(Fd_Code_Writer& f) FL_OVERRIDE;
void write_static_after(Fd_Code_Writer& f) FL_OVERRIDE;
void write_code1(Fd_Code_Writer& f) FL_OVERRIDE;
void write_code2(Fd_Code_Writer& f) FL_OVERRIDE;
void open() FL_OVERRIDE;

View File

@ -1044,6 +1044,9 @@ bool Fl_Type::is_in_class() const {
void Fl_Type::write_static(Fd_Code_Writer&) {
}
void Fl_Type::write_static_after(Fd_Code_Writer&) {
}
void Fl_Type::write_code1(Fd_Code_Writer& f) {
f.write_h("// Header for %s\n", title());
f.write_c("// Code for %s\n", title());

View File

@ -218,6 +218,7 @@ public:
// write code, these are called in order:
virtual void write_static(Fd_Code_Writer& f); // write static stuff to .c file
virtual void write_static_after(Fd_Code_Writer& f); // write static stuff after children
virtual void write_code1(Fd_Code_Writer& f); // code and .h before children
virtual void write_code2(Fd_Code_Writer& f); // code and .h after children
void write_comment_h(Fd_Code_Writer& f, const char *ind=""); // write the commentary text into the header file

View File

@ -504,8 +504,8 @@ void run_autodoc(const Fl_String &target_dir) {
// -- ID_DeclBlock
Fl_Window *adoc_declblock_panel = make_declblock_panel();
decl_before_input->value("#ifdef NDEBUG");
decl_after_input->value("#endif // NDEBUG");
declblock_before_input->value("#ifdef NDEBUG");
declblock_after_input->value("#endif // NDEBUG");
fl_snapshot((target_dir + "declblock_panel.png").c_str(), adoc_declblock_panel, win_margin, win_blend);
adoc_declblock_panel->hide();

View File

@ -682,7 +682,29 @@ bool is_comment_before_class_member(Fl_Type *q) {
}
/**
Recursively dump code, putting children between the two parts of the parent code.
Recursively write static code and declarations
\param[in] p write this type and all its children
\return pointer to the next sibling
*/
Fl_Type* Fd_Code_Writer::write_static(Fl_Type* p) {
if (write_codeview) p->header_static_start = (int)ftell(header_file);
if (write_codeview) p->code_static_start = (int)ftell(code_file);
p->write_static(*this);
if (write_codeview) p->code_static_end = (int)ftell(code_file);
if (write_codeview) p->header_static_end = (int)ftell(header_file);
Fl_Type* q;
for (q = p->next; q && q->level > p->level;) {
q = write_static(q);
}
p->write_static_after(*this);
return q;
}
/**
Recursively write code, putting children between the two parts of the parent code.
\param[in] p write this type and all its children
\return pointer to the next sibling
*/
@ -879,18 +901,7 @@ int Fd_Code_Writer::write_code(const char *s, const char *t, bool to_codeview) {
}
for (Fl_Type* p = first_type; p;) {
// write all static data for this & all children first
if (write_codeview) p->header_static_start = (int)ftell(header_file);
if (write_codeview) p->code_static_start = (int)ftell(code_file);
p->write_static(*this);
if (write_codeview) p->code_static_end = (int)ftell(code_file);
if (write_codeview) p->header_static_end = (int)ftell(header_file);
for (Fl_Type* q = p->next; q && q->level > p->level; q = q->next) {
if (write_codeview) q->header_static_start = (int)ftell(header_file);
if (write_codeview) q->code_static_start = (int)ftell(code_file);
q->write_static(*this);
if (write_codeview) q->code_static_end = (int)ftell(code_file);
if (write_codeview) q->header_static_end = (int)ftell(header_file);
}
write_static(p);
// then write the nested code:
p = write_code(p);
}

View File

@ -99,6 +99,7 @@ public:
void write_h(const char*, ...) __fl_attr((__format__ (__printf__, 2, 3)));
void write_hc(const char *, int, const char*, const char*);
void write_c_indented(const char *textlines, int inIndent, char inTrailwWith);
Fl_Type* write_static(Fl_Type* p);
Fl_Type* write_code(Fl_Type* p);
int write_code(const char *cfile, const char *hfile, bool to_codeview=false);
void write_public(int state); // writes pubic:/private: as needed

View File

@ -279,15 +279,39 @@
\image html declblock_panel.png "Declaration Block Properties"
\image latex declblock_panel.png "Declaration Block Properties" width=7cm
Users can select if the block is generated in the source file only, or in the
header file as well. The two input fields are used to enter the line of code
before and after the child nodes. Two consecutive Declaration Blocks can be
used to generate `#else`/`#elif` style code by leaving the second field of
the first node empty.
The C++ code in the "Start" field is output before the code of
all children of this node is written to the source file. The text in the "End"
field is written after code for all children was generated.
\note Declaration Blocks are not smart, and child nodes may still generate
unexpected code outside the scope of this block. This may change in future
versions of FLUID.
The following check boxes enable code generation for different locations in
header and source code files. The first two boxes modify the C++ source code
file.
If the first check box, "implementations", is ticked, all C++ code that
implements the children of this declaration block will be enclosed with the
code from the "Start" and "End" fields. This check box is marked by default.
The second check box, "static initializations and callbacks", will enclose
callbacks that may be created by child widgets, menu item arrays, and code
as well as data for images. This box should be ticked in most cases, but
may be harmful if one image is used more than once and outside of this
declaration block.
The next two boxes modify the C++ code in the header file. Ticking "forward
declarations" will wrap the code that declares functions, methods, and menus.
The last box ensure that code declaring widgets is wrapped with yet another
copy of from the "Start" and "End" fields. This will also wrap
`#include` statements and declarations from widget "Code" fields.
FLUID optimizes header files by removing duplicate include statements and
certain declarations. Declaration blocks are commonly used for conditional
compilation and may effectively "optimize away" include statements that are
still needed elsewhere. This can be litigated by explicitly creating
Declaration nodes outside of the declaration block.
The "Start" and "End" code may appear multiple times per file if more than
one of the check boxes above is ticked. The code should not have any side
effects or cause conflicts when compiled more than once. It's not safe to rely
on a specific order of the generated blocks.
<!-- ---------------------------------------------------------------------- -->

View File

@ -66,6 +66,7 @@ Fl_Button *f_panel_cancel=(Fl_Button *)0;
Fl_Double_Window* make_function_panel() {
{ function_panel = new Fl_Double_Window(343, 232, "Function/Method Properties");
function_panel->align(Fl_Align(FL_ALIGN_CLIP|FL_ALIGN_INSIDE));
{ 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.");
@ -254,79 +255,109 @@ Fl_Double_Window* make_codeblock_panel() {
Fl_Double_Window *declblock_panel=(Fl_Double_Window *)0;
Fl_Choice *declblock_public_choice=(Fl_Choice *)0;
Fl_Input *declblock_before_input=(Fl_Input *)0;
Fl_Menu_Item menu_declblock_public_choice[] = {
{"in source code only", 0, 0, (void*)(0), 0, (uchar)FL_NORMAL_LABEL, 0, 11, 0},
{"in header and source", 0, 0, (void*)(1), 0, (uchar)FL_NORMAL_LABEL, 0, 11, 0},
{0,0,0,0,0,0,0,0,0}
};
Fl_Input *declblock_after_input=(Fl_Input *)0;
Fl_Light_Button *declblock_public_button_x=(Fl_Light_Button *)0;
Fl_Check_Button *declblock_code_source=(Fl_Check_Button *)0;
Fl_Input *decl_before_input=(Fl_Input *)0;
Fl_Check_Button *declblock_static_source=(Fl_Check_Button *)0;
Fl_Input *decl_after_input=(Fl_Input *)0;
Fl_Check_Button *declblock_code_header=(Fl_Check_Button *)0;
Fl_Check_Button *declblock_static_header=(Fl_Check_Button *)0;
Fl_Text_Editor *declblock_comment_input=(Fl_Text_Editor *)0;
Fl_Return_Button *declblock_panel_ok=(Fl_Return_Button *)0;
Fl_Button *declblock_panel_cancel=(Fl_Button *)0;
Fl_Double_Window* make_declblock_panel() {
{ Fl_Double_Window* o = declblock_panel = new Fl_Double_Window(300, 135, "Declaration Block Properties");
{ Fl_Double_Window* o = declblock_panel = new Fl_Double_Window(300, 355, "Declaration Block Properties");
declblock_panel->labelsize(11);
{ Fl_Group* o = new Fl_Group(10, 10, 280, 20);
{ declblock_public_choice = new Fl_Choice(10, 10, 140, 20);
declblock_public_choice->tooltip("Change widget accessibility.");
declblock_public_choice->down_box(FL_BORDER_BOX);
declblock_public_choice->labelsize(11);
declblock_public_choice->textsize(11);
declblock_public_choice->when(FL_WHEN_NEVER);
declblock_public_choice->menu(menu_declblock_public_choice);
} // Fl_Choice* declblock_public_choice
{ declblock_public_button_x = new Fl_Light_Button(10, 10, 60, 20, "public");
declblock_public_button_x->tooltip("Make the declaration publicly accessible.");
declblock_public_button_x->labelsize(11);
declblock_public_button_x->when(FL_WHEN_NEVER);
declblock_public_button_x->hide();
} // Fl_Light_Button* declblock_public_button_x
{ Fl_Box* o = new Fl_Box(155, 10, 135, 20);
declblock_panel->align(Fl_Align(FL_ALIGN_CLIP|FL_ALIGN_INSIDE));
{ declblock_before_input = new Fl_Input(10, 23, 280, 20, "Start Code:");
declblock_before_input->tooltip("#ifdef or similar conditional declaration block.");
declblock_before_input->labelfont(1);
declblock_before_input->labelsize(11);
declblock_before_input->textfont(4);
declblock_before_input->textsize(11);
declblock_before_input->align(Fl_Align(FL_ALIGN_TOP_LEFT));
declblock_before_input->when(FL_WHEN_NEVER);
} // Fl_Input* declblock_before_input
{ Fl_Box* o = new Fl_Box(10, 48, 280, 20, "\"\\n...child code...\\n\" is inserted here");
o->labelsize(11);
} // Fl_Box* o
{ declblock_after_input = new Fl_Input(10, 80, 280, 20, "End Code:");
declblock_after_input->tooltip("#endif or similar declaration code block.");
declblock_after_input->labelfont(1);
declblock_after_input->labelsize(11);
declblock_after_input->textfont(4);
declblock_after_input->textsize(11);
declblock_after_input->align(Fl_Align(FL_ALIGN_TOP_LEFT));
declblock_after_input->when(FL_WHEN_NEVER);
} // Fl_Input* declblock_after_input
{ Fl_Group* o = new Fl_Group(10, 105, 280, 120);
{ Fl_Box* o = new Fl_Box(10, 105, 270, 20, "Enclose code generated by children in source file:");
o->labelsize(11);
o->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE));
} // Fl_Box* o
{ declblock_code_source = new Fl_Check_Button(20, 125, 260, 20, "implementations");
declblock_code_source->down_box(FL_DOWN_BOX);
declblock_code_source->labelsize(11);
} // Fl_Check_Button* declblock_code_source
{ declblock_static_source = new Fl_Check_Button(20, 145, 260, 20, "static initializations and callbacks");
declblock_static_source->down_box(FL_DOWN_BOX);
declblock_static_source->labelsize(11);
} // Fl_Check_Button* declblock_static_source
{ Fl_Box* o = new Fl_Box(10, 165, 270, 20, "Enclose code in header file:");
o->labelsize(11);
o->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE));
} // Fl_Box* o
{ declblock_code_header = new Fl_Check_Button(20, 185, 260, 20, "forward declarations");
declblock_code_header->down_box(FL_DOWN_BOX);
declblock_code_header->labelsize(11);
} // Fl_Check_Button* declblock_code_header
{ declblock_static_header = new Fl_Check_Button(20, 205, 260, 20, "preprecessor and callback declarations");
declblock_static_header->down_box(FL_DOWN_BOX);
declblock_static_header->labelsize(11);
} // Fl_Check_Button* declblock_static_header
{ Fl_Box* o = new Fl_Box(280, 105, 10, 120);
o->labelsize(11);
o->hide();
Fl_Group::current()->resizable(o);
} // Fl_Box* o
o->end();
} // Fl_Group* o
{ decl_before_input = new Fl_Input(10, 40, 280, 20);
decl_before_input->tooltip("#ifdef or similar conditional declaration block.");
decl_before_input->labelsize(11);
decl_before_input->textfont(4);
decl_before_input->textsize(11);
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
{ decl_after_input = new Fl_Input(10, 75, 280, 20, "\"\\n...child code...\\n\" is inserted here");
decl_after_input->tooltip("#endif or similar declaration code block.");
decl_after_input->labelsize(11);
decl_after_input->textfont(4);
decl_after_input->textsize(11);
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);
{ declblock_panel_ok = new Fl_Return_Button(160, 105, 60, 20, "OK");
{ declblock_comment_input = new Fl_Text_Editor(10, 242, 280, 65, "Comment:");
declblock_comment_input->tooltip("Declaration comment in Doxygen format");
declblock_comment_input->box(FL_DOWN_BOX);
declblock_comment_input->labelfont(1);
declblock_comment_input->labelsize(11);
declblock_comment_input->textfont(4);
declblock_comment_input->textsize(11);
declblock_comment_input->align(Fl_Align(FL_ALIGN_TOP_LEFT));
Fl_Group::current()->resizable(declblock_comment_input);
declblock_comment_input->buffer(new Fl_Text_Buffer());
declblock_comment_input->add_key_binding(FL_Tab, 0, use_tab_navigation);
} // Fl_Text_Editor* declblock_comment_input
{ Fl_Group* o = new Fl_Group(10, 321, 280, 20);
{ declblock_panel_ok = new Fl_Return_Button(160, 321, 60, 20, "OK");
declblock_panel_ok->labelsize(11);
declblock_panel_ok->window()->hotspot(declblock_panel_ok);
} // Fl_Return_Button* declblock_panel_ok
{ declblock_panel_cancel = new Fl_Button(230, 105, 60, 20, "Cancel");
{ declblock_panel_cancel = new Fl_Button(230, 321, 60, 20, "Cancel");
declblock_panel_cancel->shortcut(0xff1b);
declblock_panel_cancel->labelsize(11);
} // Fl_Button* declblock_panel_cancel
{ Fl_Box* o = new Fl_Box(10, 105, 140, 20);
{ Fl_Box* o = new Fl_Box(10, 321, 140, 20);
Fl_Group::current()->resizable(o);
} // Fl_Box* o
o->end();
} // Fl_Group* o
declblock_panel->set_modal();
declblock_panel->size_range(300, 355);
o->size_range(o->w(), o->h(), Fl::w(), o->h());
declblock_panel->end();
} // Fl_Double_Window* declblock_panel

View File

@ -2,6 +2,11 @@
version 1.0400
header_name {.h}
code_name {.cxx}
snap {
ver 1
current_suite FLTK
current_preset 1
}
comment {//
// Code dialogs for the Fast Light Tool Kit (FLTK).
//
@ -51,7 +56,7 @@ Function {make_function_panel()} {open
} {
Fl_Window function_panel {
label {Function/Method Properties}
xywh {540 418 343 232} type Double resizable modal visible
xywh {540 418 343 232} type Double align 80 resizable modal visible
} {
Fl_Group {} {open
xywh {10 10 270 20}
@ -207,55 +212,72 @@ Function {make_codeblock_panel()} {open
Function {make_declblock_panel()} {open
} {
Fl_Window declblock_panel {
label {Declaration Block Properties}
xywh {806 564 300 135} type Double labelsize 11 hide resizable
code0 {o->size_range(o->w(), o->h(), Fl::w(), o->h());} modal
label {Declaration Block Properties} open
xywh {645 452 300 355} type Double labelsize 11 align 80 resizable
code0 {o->size_range(o->w(), o->h(), Fl::w(), o->h());} modal size_range {300 355 0 0} visible
} {
Fl_Input declblock_before_input {
label {Start Code:}
tooltip {\#ifdef or similar conditional declaration block.} xywh {10 23 280 20} labelfont 1 labelsize 11 align 5 when 0 textfont 4 textsize 11
}
Fl_Box {} {
label {"\\n...child code...\\n" is inserted here}
xywh {10 48 280 20} labelsize 11
}
Fl_Input declblock_after_input {
label {End Code:}
tooltip {\#endif or similar declaration code block.} xywh {10 80 280 20} labelfont 1 labelsize 11 align 5 when 0 textfont 4 textsize 11
}
Fl_Group {} {open
xywh {10 10 280 20}
xywh {10 105 280 120}
} {
Fl_Choice declblock_public_choice {open
tooltip {Change widget accessibility.} xywh {10 10 140 20} down_box BORDER_BOX labelsize 11 when 0 textsize 11
} {
MenuItem {} {
label {in source code only}
user_data 0 user_data_type long
xywh {25 25 100 20} labelsize 11
}
MenuItem {} {
label {in header and source}
user_data 1 user_data_type long
xywh {25 25 100 20} labelsize 11
}
Fl_Box {} {
label {Enclose code generated by children in source file:}
xywh {10 105 270 20} labelsize 11 align 20
}
Fl_Light_Button declblock_public_button_x {
label public
tooltip {Make the declaration publicly accessible.} xywh {10 10 60 20} labelsize 11 when 0 hide
Fl_Check_Button declblock_code_source {
label implementations
xywh {20 125 260 20} down_box DOWN_BOX labelsize 11
}
Fl_Check_Button declblock_static_source {
label {static initializations and callbacks}
xywh {20 145 260 20} down_box DOWN_BOX labelsize 11
}
Fl_Box {} {
xywh {155 10 135 20} resizable
label {Enclose code in header file:}
xywh {10 165 270 20} labelsize 11 align 20
}
Fl_Check_Button declblock_code_header {
label {forward declarations}
xywh {20 185 260 20} down_box DOWN_BOX labelsize 11
}
Fl_Check_Button declblock_static_header {
label {preprecessor and callback declarations}
xywh {20 205 260 20} down_box DOWN_BOX labelsize 11
}
Fl_Box {} {
xywh {280 105 10 120} labelsize 11 hide resizable
}
}
Fl_Input decl_before_input {
tooltip {\#ifdef or similar conditional declaration block.} xywh {10 40 280 20} labelsize 11 align 5 when 0 textfont 4 textsize 11 resizable
Fl_Text_Editor declblock_comment_input {
label {Comment:}
tooltip {Declaration comment in Doxygen format} xywh {10 242 280 65} box DOWN_BOX labelfont 1 labelsize 11 align 5 textfont 4 textsize 11 resizable
code0 {declblock_comment_input->buffer(new Fl_Text_Buffer());}
code1 {declblock_comment_input->add_key_binding(FL_Tab, 0, use_tab_navigation);}
}
Fl_Input decl_after_input {
label {"\\n...child code...\\n" is inserted here}
tooltip {\#endif or similar declaration code block.} xywh {10 75 280 20} labelsize 11 align 5 when 0 textfont 4 textsize 11
}
Fl_Group {} {open
xywh {10 105 280 20}
Fl_Group {} {
xywh {10 321 280 20}
} {
Fl_Return_Button declblock_panel_ok {
label OK
xywh {160 105 60 20} labelsize 11 hotspot
xywh {160 321 60 20} labelsize 11 hotspot
}
Fl_Button declblock_panel_cancel {
label Cancel
xywh {230 105 60 20} shortcut 0xff1b labelsize 11
xywh {230 321 60 20} shortcut 0xff1b labelsize 11
}
Fl_Box {} {
xywh {10 105 140 20} resizable
xywh {10 321 140 20} resizable
}
}
}
@ -264,7 +286,7 @@ Function {make_declblock_panel()} {open
Function {make_decl_panel()} {open
} {
Fl_Window decl_panel {
label {Declaration Properties} open selected
label {Declaration Properties}
xywh {497 618 343 262} type Double align 80 resizable size_range {343 262 0 0} visible
} {
Fl_Group {} {

View File

@ -53,14 +53,17 @@ extern Fl_Return_Button *codeblock_panel_ok;
extern Fl_Button *codeblock_panel_cancel;
Fl_Double_Window* make_codeblock_panel();
extern Fl_Double_Window *declblock_panel;
extern Fl_Choice *declblock_public_choice;
extern Fl_Light_Button *declblock_public_button_x;
extern Fl_Input *decl_before_input;
extern Fl_Input *decl_after_input;
extern Fl_Input *declblock_before_input;
extern Fl_Input *declblock_after_input;
#include <FL/Fl_Check_Button.H>
extern Fl_Check_Button *declblock_code_source;
extern Fl_Check_Button *declblock_static_source;
extern Fl_Check_Button *declblock_code_header;
extern Fl_Check_Button *declblock_static_header;
extern Fl_Text_Editor *declblock_comment_input;
extern Fl_Return_Button *declblock_panel_ok;
extern Fl_Button *declblock_panel_cancel;
Fl_Double_Window* make_declblock_panel();
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;