STR 3210: indentation is now controlled in one single position for all source and header files.
This commit is contained in:
parent
235f9ed709
commit
1c962bf5e2
@ -382,7 +382,7 @@ void Fl_Function_Type::write_code1() {
|
||||
size_t n = strlen(k);
|
||||
if (!strncmp(name(), k, n) && name()[n] == '(') constructor = 1;
|
||||
}
|
||||
write_h(" ");
|
||||
write_h("%s", indent(1));
|
||||
if (is_static) write_h("static ");
|
||||
if (is_virtual) write_h("virtual ");
|
||||
if (!constructor) {
|
||||
@ -482,8 +482,9 @@ void Fl_Function_Type::write_code1() {
|
||||
}
|
||||
}
|
||||
|
||||
if (havewidgets && child && !child->name()) write_c(" %s* w;\n", subclassname(child));
|
||||
indentation += 2;
|
||||
if (havewidgets && child && !child->name())
|
||||
write_c("%s%s* w;\n", indent(1), subclassname(child));
|
||||
indentation++;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -501,10 +502,12 @@ void Fl_Function_Type::write_code2() {
|
||||
}
|
||||
|
||||
if (ismain()) {
|
||||
if (havewidgets) write_c(" %s->show(argc, argv);\n", var);
|
||||
if (havechildren) write_c(" return Fl::run();\n");
|
||||
if (havewidgets)
|
||||
write_c("%s%s->show(argc, argv);\n", indent(1), var);
|
||||
if (havechildren)
|
||||
write_c("%sreturn Fl::run();\n", indent(1));
|
||||
} else if (havewidgets && !constructor && !return_type) {
|
||||
write_c(" return %s;\n", var);
|
||||
write_c("%sreturn %s;\n", indent(1), var);
|
||||
}
|
||||
if (havechildren)
|
||||
write_c("}\n");
|
||||
@ -798,14 +801,14 @@ BREAK2:
|
||||
void Fl_CodeBlock_Type::write_code1() {
|
||||
const char* c = name();
|
||||
write_c("%s%s {\n", indent(), c ? c : "");
|
||||
indentation += 2;
|
||||
indentation++;
|
||||
}
|
||||
|
||||
/**
|
||||
Write the "after" code.
|
||||
*/
|
||||
void Fl_CodeBlock_Type::write_code2() {
|
||||
indentation -= 2;
|
||||
indentation--;
|
||||
if (after) write_c("%s} %s\n", indent(), after);
|
||||
else write_c("%s}\n", indent());
|
||||
}
|
||||
@ -975,8 +978,8 @@ void Fl_Decl_Type::write_code1() {
|
||||
|| (!strncmp(c,"struct",6) && isspace(c[6]))
|
||||
) ) {
|
||||
write_public(public_);
|
||||
write_comment_h(" ");
|
||||
write_h(" %s\n", c);
|
||||
write_comment_h(indent(1));
|
||||
write_h("%s%s\n", indent(1), c);
|
||||
return;
|
||||
}
|
||||
// handle putting #include, extern, using or typedef into decl:
|
||||
@ -1006,8 +1009,8 @@ void Fl_Decl_Type::write_code1() {
|
||||
while (e>c && e[-1]==';') e--;
|
||||
if (class_name(1)) {
|
||||
write_public(public_);
|
||||
write_comment_h(" ");
|
||||
write_hc(" ", int(e-c), c, csc);
|
||||
write_comment_h(indent(1));
|
||||
write_hc(indent(1), int(e-c), c, csc);
|
||||
} else {
|
||||
if (public_) {
|
||||
if (static_)
|
||||
@ -1241,14 +1244,17 @@ void Fl_Data_Type::write_code1() {
|
||||
}
|
||||
if (is_in_class()) {
|
||||
write_public(public_);
|
||||
write_comment_h(" ");
|
||||
if (text_mode_) {
|
||||
write_h(" static const char *%s;\n", c);
|
||||
write_h("%sstatic const char *%s;\n", indent(1), c);
|
||||
write_c("\n");
|
||||
write_comment_c();
|
||||
write_c("const char *%s::%s = /* text inlined from %s */\n", class_name(1), c, fn);
|
||||
if (message) write_c("#error %s %s\n", message, fn);
|
||||
write_cstring(data, nData);
|
||||
} else {
|
||||
write_h(" static unsigned char %s[%d];\n", c, nData);
|
||||
write_h("%sstatic unsigned char %s[%d];\n", indent(1), c, nData);
|
||||
write_c("\n");
|
||||
write_comment_c();
|
||||
write_c("unsigned char %s::%s[%d] = /* data inlined from %s */\n", class_name(1), c, nData, fn);
|
||||
if (message) write_c("#error %s %s\n", message, fn);
|
||||
write_cdata(data, nData);
|
||||
@ -1260,12 +1266,14 @@ void Fl_Data_Type::write_code1() {
|
||||
if (static_) {
|
||||
if (text_mode_) {
|
||||
write_h("extern const char *%s;\n", c);
|
||||
write_c("\n");
|
||||
write_comment_c();
|
||||
write_c("const char *%s = /* text inlined from %s */\n", c, fn);
|
||||
if (message) write_c("#error %s %s\n", message, fn);
|
||||
write_cstring(data, nData);
|
||||
} else {
|
||||
write_h("extern unsigned char %s[%d];\n", c, nData);
|
||||
write_c("\n");
|
||||
write_comment_c();
|
||||
write_c("unsigned char %s[%d] = /* data inlined from %s */\n", c, nData, fn);
|
||||
if (message) write_c("#error %s %s\n", message, fn);
|
||||
@ -1281,6 +1289,7 @@ void Fl_Data_Type::write_code1() {
|
||||
write_h("unsigned char %s[3] = { 1, 2, 3 };\n", c);
|
||||
}
|
||||
} else {
|
||||
write_c("\n");
|
||||
write_comment_c();
|
||||
if (static_)
|
||||
write_c("static ");
|
||||
|
@ -221,7 +221,7 @@ void Fl_Menu_Item_Type::write_static() {
|
||||
write_c("\n}\n");
|
||||
if (k) {
|
||||
write_c("void %s::%s(Fl_Menu_* o, %s v) {\n", k, cn, ut);
|
||||
write_c(" ((%s*)(o", k);
|
||||
write_c("%s((%s*)(o", indent(1), k);
|
||||
Fl_Type* t = parent; while (t->is_menu_item()) t = t->parent;
|
||||
Fl_Type *q = 0;
|
||||
// Go up one more level for Fl_Input_Choice, as these are groups themselves
|
||||
@ -348,8 +348,8 @@ void Fl_Menu_Item_Type::write_code1() {
|
||||
if (!prev->is_menu_item()) {
|
||||
// for first menu item, declare the array
|
||||
if (class_name(1)) {
|
||||
if (i18n_type) write_h(" static unsigned char %s_i18n_done;\n", mname);
|
||||
write_h(" static Fl_Menu_Item %s[];\n", mname);
|
||||
if (i18n_type) write_h("%sstatic unsigned char %s_i18n_done;\n", indent(1), mname);
|
||||
write_h("%sstatic Fl_Menu_Item %s[];\n", indent(1), mname);
|
||||
} else {
|
||||
if (i18n_type) write_h("extern unsigned char %s_i18n_done;\n", mname);
|
||||
write_h("extern Fl_Menu_Item %s[];\n", mname);
|
||||
@ -360,7 +360,7 @@ void Fl_Menu_Item_Type::write_code1() {
|
||||
if (c) {
|
||||
if (class_name(1)) {
|
||||
write_public(public_);
|
||||
write_h(" static Fl_Menu_Item *%s;\n", c);
|
||||
write_h("%sstatic Fl_Menu_Item *%s;\n", indent(1), c);
|
||||
} else {
|
||||
if (c==name())
|
||||
write_h("#define %s (%s+%d)\n", c, mname, i);
|
||||
@ -374,8 +374,8 @@ void Fl_Menu_Item_Type::write_code1() {
|
||||
const char* cn = callback_name();
|
||||
const char* ut = user_data_type() ? user_data_type() : "void*";
|
||||
write_public(0);
|
||||
write_h(" inline void %s_i(Fl_Menu_*, %s);\n", cn, ut);
|
||||
write_h(" static void %s(Fl_Menu_*, %s);\n", cn, ut);
|
||||
write_h("%sinline void %s_i(Fl_Menu_*, %s);\n", indent(1), cn, ut);
|
||||
write_h("%sstatic void %s(Fl_Menu_*, %s);\n", indent(1), cn, ut);
|
||||
}
|
||||
}
|
||||
|
||||
@ -395,7 +395,7 @@ void Fl_Menu_Item_Type::write_code1() {
|
||||
menuItemInitialized = 1;
|
||||
write_c("%s{ Fl_Menu_Item* o = &%s[%d];\n", indent(), mname, i);
|
||||
}
|
||||
write_c("%s %s\n", indent(), extra_code(n));
|
||||
write_c("%s%s\n", indent_plus(1), extra_code(n));
|
||||
}
|
||||
}
|
||||
if (menuItemInitialized)
|
||||
@ -492,21 +492,21 @@ void Fl_Menu_Type::write_code2() {
|
||||
}
|
||||
if (nLabel) {
|
||||
write_c("%sif (!%s_i18n_done) {\n", indent(), mName);
|
||||
write_c("%s int i=0;\n", indent());
|
||||
write_c("%s for ( ; i<%d; i++)\n", indent(), nItem);
|
||||
write_c("%s if (%s[i].label())\n", indent(), mName);
|
||||
write_c("%sint i=0;\n", indent_plus(1));
|
||||
write_c("%sfor ( ; i<%d; i++)\n", indent_plus(1), nItem);
|
||||
write_c("%sif (%s[i].label())\n", indent_plus(2), mName);
|
||||
switch (i18n_type) {
|
||||
case 1:
|
||||
write_c("%s %s[i].label(%s(%s[i].label()));\n",
|
||||
indent(), mName, i18n_function, mName);
|
||||
write_c("%s%s[i].label(%s(%s[i].label()));\n",
|
||||
indent_plus(3), mName, i18n_function, mName);
|
||||
break;
|
||||
case 2:
|
||||
write_c("%s %s[i].label(catgets(%s,%s,i+%d,%s[i].label()));\n",
|
||||
indent(), mName, i18n_file[0] ? i18n_file : "_catalog",
|
||||
write_c("%s%s[i].label(catgets(%s,%s,i+%d,%s[i].label()));\n",
|
||||
indent_plus(3), mName, i18n_file[0] ? i18n_file : "_catalog",
|
||||
i18n_set, mi->msgnum(), mName);
|
||||
break;
|
||||
}
|
||||
write_c("%s %s_i18n_done = 1;\n", indent(), mName);
|
||||
write_c("%s%s_i18n_done = 1;\n", indent_plus(1), mName);
|
||||
write_c("%s}\n", indent());
|
||||
}
|
||||
}
|
||||
|
@ -171,8 +171,11 @@ void delete_all(int selected_only) {
|
||||
// reset the setting for the external shell command
|
||||
shell_prefs_get();
|
||||
shell_settings_write();
|
||||
widget_browser->hposition(0);
|
||||
widget_browser->position(0);
|
||||
}
|
||||
selection_changed(0);
|
||||
widget_browser->redraw();
|
||||
}
|
||||
|
||||
// update a string member:
|
||||
@ -553,7 +556,8 @@ void Fl_Type::read_property(const char *c) {
|
||||
int Fl_Type::read_fdesign(const char*, const char*) {return 0;}
|
||||
|
||||
/**
|
||||
Write a comment into the header file.
|
||||
Write a comment into the header file.
|
||||
\param[in] pre indent the comment by this string
|
||||
*/
|
||||
void Fl_Type::write_comment_h(const char *pre)
|
||||
{
|
||||
@ -609,22 +613,32 @@ void Fl_Type::write_comment_inline_c(const char *pre)
|
||||
// single line comment
|
||||
if (pre) write_c("%s", pre);
|
||||
write_c("// %s\n", s);
|
||||
if (!pre) write_c("%s ", indent());
|
||||
if (!pre) write_c("%s", indent_plus(1));
|
||||
} else {
|
||||
write_c("%s/*\n", pre?pre:"");
|
||||
if (pre) write_c("%s ", pre); else write_c("%s ", indent());
|
||||
if (pre)
|
||||
write_c("%s ", pre);
|
||||
else
|
||||
write_c("%s ", indent_plus(1));
|
||||
while(*s) {
|
||||
if (*s=='\n') {
|
||||
if (s[1]) {
|
||||
if (pre) write_c("\n%s ", pre); else write_c("\n%s ", indent());
|
||||
if (pre)
|
||||
write_c("\n%s ", pre);
|
||||
else
|
||||
write_c("\n%s ", indent_plus(1));
|
||||
}
|
||||
} 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());
|
||||
if (pre)
|
||||
write_c("\n%s */\n", pre);
|
||||
else
|
||||
write_c("\n%s */\n", indent_plus(1));
|
||||
if (!pre)
|
||||
write_c("%s", indent_plus(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2066,7 +2066,7 @@ void Fl_Widget_Type::write_static() {
|
||||
write_c("\n}\n");
|
||||
if (k) {
|
||||
write_c("void %s::%s(%s* o, %s v) {\n", k, cn, t, ut);
|
||||
write_c(" ((%s*)(o", k);
|
||||
write_c("%s((%s*)(o", indent(1), k);
|
||||
Fl_Type *q = 0;
|
||||
for (Fl_Type* p = parent; p && p->is_widget(); q = p, p = p->parent)
|
||||
write_c("->parent()");
|
||||
@ -2097,15 +2097,15 @@ void Fl_Widget_Type::write_code1() {
|
||||
if (c) {
|
||||
if (class_name(1)) {
|
||||
write_public(public_);
|
||||
write_h(" %s *%s;\n", t, c);
|
||||
write_h("%s%s *%s;\n", indent(1), t, c);
|
||||
}
|
||||
}
|
||||
if (class_name(1) && callback() && !is_name(callback())) {
|
||||
const char* cn = callback_name();
|
||||
const char* ut = user_data_type() ? user_data_type() : "void*";
|
||||
write_public(0);
|
||||
write_h(" inline void %s_i(%s*, %s);\n", cn, t, ut);
|
||||
write_h(" static void %s(%s*, %s);\n", cn, t, ut);
|
||||
write_h("%sinline void %s_i(%s*, %s);\n", indent(1), cn, t, ut);
|
||||
write_h("%sstatic void %s(%s*, %s);\n", indent(1), cn, t, ut);
|
||||
}
|
||||
// figure out if local variable will be used (prevent compiler warnings):
|
||||
int wused = !name() && is_window();
|
||||
@ -2184,7 +2184,7 @@ void Fl_Widget_Type::write_code1() {
|
||||
}
|
||||
write_c(");\n");
|
||||
|
||||
indentation += 2;
|
||||
indentation++;
|
||||
|
||||
if (wused) write_c("%sw = o; if (w) {/* empty */}\n", indent());
|
||||
|
||||
@ -2396,7 +2396,7 @@ void Fl_Widget_Type::write_extra_code() {
|
||||
}
|
||||
|
||||
void Fl_Widget_Type::write_block_close() {
|
||||
indentation -= 2;
|
||||
indentation--;
|
||||
write_c("%s} // %s* %s\n", indent(), subclassname(this),
|
||||
name() ? name() : "o");
|
||||
}
|
||||
|
@ -1505,54 +1505,56 @@ void Fl_Widget_Class_Type::write_code1() {
|
||||
const char *c = subclass();
|
||||
if (!c) c = "Fl_Group";
|
||||
|
||||
write_c("\n");
|
||||
write_comment_h();
|
||||
write_h("\nclass %s : public %s {\n", name(), c);
|
||||
if (strstr(c, "Window")) {
|
||||
write_h(" void _%s();\n", trimclassname(name()));
|
||||
write_h("%svoid _%s();\n", indent(1), trimclassname(name()));
|
||||
write_h("public:\n");
|
||||
write_h(" %s(int X, int Y, int W, int H, const char *L = 0);\n", trimclassname(name()));
|
||||
write_h(" %s(int W, int H, const char *L = 0);\n", trimclassname(name()));
|
||||
write_h(" %s();\n", trimclassname(name()));
|
||||
write_h("%s%s(int X, int Y, int W, int H, const char *L = 0);\n", indent(1), trimclassname(name()));
|
||||
write_h("%s%s(int W, int H, const char *L = 0);\n", indent(1), trimclassname(name()));
|
||||
write_h("%s%s();\n", indent(1), trimclassname(name()));
|
||||
|
||||
// a constructor with all four dimensions plus label
|
||||
write_c("%s::%s(int X, int Y, int W, int H, const char *L)\n", name(), trimclassname(name()));
|
||||
write_c(" : %s(X, Y, W, H, L) {\n", c);
|
||||
write_c(" _%s();\n", trimclassname(name()));
|
||||
write_c("%s::%s(int X, int Y, int W, int H, const char *L) :\n", name(), trimclassname(name()));
|
||||
write_c("%s%s(X, Y, W, H, L)\n{\n", indent(1), c);
|
||||
write_c("%s_%s();\n", indent(1), trimclassname(name()));
|
||||
write_c("}\n\n");
|
||||
|
||||
// a constructor with just the size and label. The window manager will position the window
|
||||
write_c("%s::%s(int W, int H, const char *L)\n", name(), trimclassname(name()));
|
||||
write_c(" : %s(0, 0, W, H, L) {\n", c);
|
||||
write_c(" clear_flag(16);\n");
|
||||
write_c(" _%s();\n", trimclassname(name()));
|
||||
write_c("%s::%s(int W, int H, const char *L) :\n", name(), trimclassname(name()));
|
||||
write_c("%s%s(0, 0, W, H, L)\n{\n", indent(1), c);
|
||||
write_c("%sclear_flag(16);\n", indent(1));
|
||||
write_c("%s_%s();\n", indent(1), trimclassname(name()));
|
||||
write_c("}\n\n");
|
||||
|
||||
// a constructor that takes size and label from the Fluid database
|
||||
write_c("%s::%s()\n", name(), trimclassname(name()));
|
||||
write_c(" : %s(0, 0, %d, %d, ", c, o->w(), o->h());
|
||||
write_c("%s::%s() :\n", name(), trimclassname(name()));
|
||||
write_c("%s%s(0, 0, %d, %d, ", indent(1), c, o->w(), o->h());
|
||||
const char *cstr = label();
|
||||
if (cstr) write_cstring(cstr);
|
||||
else write_c("0");
|
||||
write_c(") {\n");
|
||||
write_c(" clear_flag(16);\n");
|
||||
write_c(" _%s();\n", trimclassname(name()));
|
||||
write_c(")\n{\n");
|
||||
write_c("%sclear_flag(16);\n", indent(1));
|
||||
write_c("%s_%s();\n", indent(1), trimclassname(name()));
|
||||
write_c("}\n\n");
|
||||
|
||||
write_c("void %s::_%s() {\n", name(), trimclassname(name()));
|
||||
// write_c(" %s *w = this;\n", name());
|
||||
// write_c("%s%s *w = this;\n", indent(1), name());
|
||||
} else {
|
||||
write_h("public:\n");
|
||||
write_h(" %s(int X, int Y, int W, int H, const char *L = 0);\n", trimclassname(name()));
|
||||
|
||||
write_c("%s::%s(int X, int Y, int W, int H, const char *L)\n", name(), trimclassname(name()));
|
||||
write_h("%s%s(int X, int Y, int W, int H, const char *L = 0);\n",
|
||||
indent(1), trimclassname(name()));
|
||||
write_c("%s::%s(int X, int Y, int W, int H, const char *L) :\n", name(), trimclassname(name()));
|
||||
if (wc_relative)
|
||||
write_c(" : %s(0, 0, W, H, L) {\n", c);
|
||||
write_c("%s%s(0, 0, W, H, L)\n{\n", indent(1), c);
|
||||
else
|
||||
write_c(" : %s(X, Y, W, H, L) {\n", c);
|
||||
write_c("%s%s(X, Y, W, H, L)\n{\n", indent(1), c);
|
||||
}
|
||||
|
||||
// write_c(" %s *o = this;\n", name());
|
||||
// write_c("%s%s *o = this;\n", indent(1), name());
|
||||
|
||||
indentation++;
|
||||
write_widget_code();
|
||||
}
|
||||
|
||||
@ -1570,6 +1572,7 @@ void Fl_Widget_Class_Type::write_code2() {
|
||||
write_c("%send();\n", indent());
|
||||
if (((Fl_Window*)o)->resizable() == o)
|
||||
write_c("%sresizable(this);\n", indent());
|
||||
indentation--;
|
||||
write_c("}\n");
|
||||
}
|
||||
|
||||
|
@ -144,9 +144,10 @@ void Fluid_Image::write_initializer(const char *type_name, const char *format, .
|
||||
} */
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
write_c("static Fl_Image *%s() {\n static Fl_Image *image = new %s(", function_name_, type_name);
|
||||
write_c("static Fl_Image *%s() {\n%sstatic Fl_Image *image = new %s(",
|
||||
function_name_, indent(1), type_name);
|
||||
vwrite_c(format, ap);
|
||||
write_c(");\n return image;\n}\n");
|
||||
write_c(");\n%sreturn image;\n}\n", indent(1));
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
@ -264,11 +264,11 @@ static void cb_Close(Fl_Return_Button* o, void*) {
|
||||
|
||||
Fl_Double_Window* make_about_panel() {
|
||||
static char cbuf[200] = "";
|
||||
if (!cbuf[0]) {
|
||||
time_t t = time(0);
|
||||
struct tm *lt = localtime(&t);
|
||||
sprintf(cbuf, "Copyright © 1998 - %d\nby Bill Spitzak and others", lt->tm_year+1900);
|
||||
}
|
||||
if (!cbuf[0]) {
|
||||
time_t t = time(0);
|
||||
struct tm *lt = localtime(&t);
|
||||
sprintf(cbuf, "Copyright © 1998 - %d\nby Bill Spitzak and others", lt->tm_year+1900);
|
||||
}
|
||||
{ about_panel = new Fl_Double_Window(345, 180, "About FLUID");
|
||||
about_panel->color(FL_LIGHT1);
|
||||
about_panel->selection_color(FL_DARK1);
|
||||
@ -303,6 +303,7 @@ Fl_Double_Window* make_about_panel() {
|
||||
} // Fl_Double_Window* about_panel
|
||||
return about_panel;
|
||||
}
|
||||
|
||||
/**
|
||||
Embedded image for internal fluid.html web page.
|
||||
*/
|
||||
|
@ -2,6 +2,8 @@
|
||||
version 1.0400
|
||||
header_name {.h}
|
||||
code_name {.cxx}
|
||||
mac_shell_cmd {echo "Fluid is nice"}
|
||||
mac_shell_flags 3
|
||||
comment {//
|
||||
// About dialog for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
@ -29,11 +31,11 @@ decl {void show_help(const char *name);} {public local
|
||||
Function {make_about_panel()} {open
|
||||
} {
|
||||
code {static char cbuf[200] = "";
|
||||
if (!cbuf[0]) {
|
||||
time_t t = time(0);
|
||||
struct tm *lt = localtime(&t);
|
||||
sprintf(cbuf, "Copyright © 1998 - %d\\nby Bill Spitzak and others", lt->tm_year+1900);
|
||||
}} {}
|
||||
if (!cbuf[0]) {
|
||||
time_t t = time(0);
|
||||
struct tm *lt = localtime(&t);
|
||||
sprintf(cbuf, "Copyright © 1998 - %d\\nby Bill Spitzak and others", lt->tm_year+1900);
|
||||
}} {}
|
||||
Fl_Window about_panel {
|
||||
label {About FLUID} open
|
||||
xywh {449 217 345 180} type Double color 50 selection_color 47 hotspot
|
||||
@ -64,12 +66,12 @@ Version x.x.x}
|
||||
}
|
||||
Fl_Return_Button {} {
|
||||
label Close
|
||||
callback {((Fl_Window*)(o->parent()))->hide();}
|
||||
callback {((Fl_Window*)(o->parent()))->hide();} selected
|
||||
xywh {250 145 83 25}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data fluid_org_png {
|
||||
comment {Embedded image for internal fluid.html web page.} selected public local filename {../documentation/src/fluid-org.png}
|
||||
comment {Embedded image for internal fluid.html web page.} public local filename {../documentation/src/fluid-org.png}
|
||||
}
|
||||
|
@ -37,8 +37,11 @@
|
||||
static FILE *code_file = NULL;
|
||||
static FILE *header_file = NULL;
|
||||
|
||||
/// Store the current indentation level for the C source code.
|
||||
int indentation = 0;
|
||||
|
||||
int write_number = 0;
|
||||
|
||||
int write_sourceview = 0;
|
||||
|
||||
/**
|
||||
@ -105,15 +108,46 @@ const char* unique_id(void* o, const char* type, const char* name, const char* l
|
||||
|
||||
|
||||
/**
|
||||
Return a C string that indents code to the current depth.
|
||||
*/
|
||||
const char* indent() {
|
||||
static const char* spaces = " ";
|
||||
Return a C string that indents code to the given depth.
|
||||
|
||||
int i = indentation; if (i>16) i = 16;
|
||||
return spaces+16-i;
|
||||
Indentation can be changed by modifying the multiplicator (``*2`` to keep
|
||||
the FLTK indent style). Changing `spaces` to a list of tabs would generate
|
||||
tab indents instead. This function can also be used for fixed depth indents
|
||||
in the header file.
|
||||
|
||||
Do *not* ever make this a user preference, or you will end up writing a
|
||||
fully featured code formatter.
|
||||
|
||||
\param[in] set generate this indent depth
|
||||
\return pointer to a static string
|
||||
*/
|
||||
const char *indent(int set) {
|
||||
static const char* spaces = " ";
|
||||
int i = set * 2;
|
||||
if (i>32) i = 32;
|
||||
if (i<0) i = 0;
|
||||
return spaces+32-i;
|
||||
}
|
||||
|
||||
/**
|
||||
Return a C string that indents code to the current source file depth.
|
||||
\return pointer to a static string
|
||||
*/
|
||||
const char *indent() {
|
||||
return indent(indentation);
|
||||
}
|
||||
|
||||
/**
|
||||
Return a C string that indents code to the current source file depth plus an offset.
|
||||
\param[in] offset adds a temporary offset for this call only; this does not
|
||||
change the `indentation` variable; offset can be negative
|
||||
\return pointer to a static string
|
||||
*/
|
||||
const char *indent_plus(int offset) {
|
||||
return indent(indentation+offset);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// declarations/include files:
|
||||
// Each string generated by write_declare is written only once to
|
||||
@ -360,6 +394,10 @@ void write_h(const char* format,...) {
|
||||
|
||||
/**
|
||||
Write code (c) of size (n) to H file, with optional comment (com) w/o trailing space.
|
||||
\param[in] indent indentation string for all lines
|
||||
\param[in] n number of bytes in code line
|
||||
\param[in] c line of code
|
||||
\param[in] com optional commentary
|
||||
*/
|
||||
void write_hc(const char *indent, int n, const char* c, const char *com) {
|
||||
if (*com)
|
||||
@ -374,7 +412,7 @@ void write_hc(const char *indent, int n, const char* c, const char *com) {
|
||||
*/
|
||||
void write_c_indented(const char *textlines) {
|
||||
if (textlines) {
|
||||
indentation+=2;
|
||||
indentation++;
|
||||
for (;;) {
|
||||
const char *newline = strchr(textlines, '\n');
|
||||
if (!newline) break;
|
||||
@ -383,7 +421,7 @@ void write_c_indented(const char *textlines) {
|
||||
}
|
||||
if (*textlines)
|
||||
write_c("%s%s", indent(), textlines);
|
||||
indentation-=2;
|
||||
indentation--;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,9 @@ extern int write_sourceview;
|
||||
|
||||
int is_id(char c);
|
||||
const char* unique_id(void* o, const char*, const char*, const char*);
|
||||
extern const char* indent();
|
||||
const char *indent();
|
||||
const char *indent(int set);
|
||||
const char *indent_plus(int offset);
|
||||
int write_declare(const char *, ...) __fl_attr((__format__ (__printf__, 1, 2)));
|
||||
void write_cstring(const char *,int length);
|
||||
void write_cstring(const char *);
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// Code dialogs for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2020 by Bill Spitzak and others.
|
||||
// Copyright 1998-2021 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
@ -146,7 +146,7 @@ Fl_Double_Window *code_panel=(Fl_Double_Window *)0;
|
||||
static void cb_code_panel(Fl_Double_Window*, void*) {
|
||||
if (Fl::event()==FL_SHORTCUT && Fl::event_key()==FL_Escape)
|
||||
return; // ignore Escape
|
||||
code_panel->hide(); // otherwise hide..;
|
||||
code_panel->hide(); // otherwise hide..;
|
||||
}
|
||||
|
||||
CodeEditor *code_input=(CodeEditor *)0;
|
||||
@ -720,9 +720,9 @@ Fl_Window *widgetbin_panel=(Fl_Window *)0;
|
||||
|
||||
static void cb_widgetbin_panel(Fl_Window* o, void* v) {
|
||||
if (Fl::event()==FL_SHORTCUT && Fl::event_key()==FL_Escape)
|
||||
exit_cb((Fl_Widget*)o, v);
|
||||
else
|
||||
toggle_widgetbin_cb((Fl_Widget*)o, v);
|
||||
exit_cb((Fl_Widget*)o, v);
|
||||
else
|
||||
toggle_widgetbin_cb((Fl_Widget*)o, v);
|
||||
}
|
||||
|
||||
Fl_Window* make_widgetbin() {
|
||||
|
@ -7,7 +7,7 @@ mac_shell_flags 3
|
||||
comment {//
|
||||
// Code dialogs for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2020 by Bill Spitzak and others.
|
||||
// Copyright 1998-2021 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
@ -60,7 +60,7 @@ Function {make_function_panel()} {open
|
||||
} {
|
||||
MenuItem {} {
|
||||
label private
|
||||
user_data 0 user_data_type long selected
|
||||
user_data 0 user_data_type long
|
||||
xywh {5 5 100 20} labelsize 11
|
||||
}
|
||||
MenuItem {} {
|
||||
@ -84,7 +84,7 @@ Function {make_function_panel()} {open
|
||||
}
|
||||
MenuItem {} {
|
||||
label global
|
||||
user_data 1 user_data_type long
|
||||
user_data 1 user_data_type long selected
|
||||
xywh {15 15 100 20} labelsize 11
|
||||
}
|
||||
}
|
||||
@ -133,7 +133,7 @@ Function {make_code_panel()} {open
|
||||
Fl_Window code_panel {
|
||||
label {Code Properties}
|
||||
callback {if (Fl::event()==FL_SHORTCUT && Fl::event_key()==FL_Escape)
|
||||
return; // ignore Escape
|
||||
return; // ignore Escape
|
||||
code_panel->hide(); // otherwise hide..}
|
||||
xywh {425 882 540 180} type Double labelsize 11 resizable
|
||||
code0 {o->size_range(200, 150);} modal visible
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// Code dialogs for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2020 by Bill Spitzak and others.
|
||||
// Copyright 1998-2021 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
|
@ -45,21 +45,21 @@ Fl_Round_Button *print_all=(Fl_Round_Button *)0;
|
||||
|
||||
static void cb_print_all(Fl_Round_Button*, void*) {
|
||||
print_from->deactivate();
|
||||
print_to->deactivate();
|
||||
print_to->deactivate();
|
||||
}
|
||||
|
||||
Fl_Round_Button *print_pages=(Fl_Round_Button *)0;
|
||||
|
||||
static void cb_print_pages(Fl_Round_Button*, void*) {
|
||||
print_from->activate();
|
||||
print_to->activate();
|
||||
print_to->activate();
|
||||
}
|
||||
|
||||
Fl_Round_Button *print_selection=(Fl_Round_Button *)0;
|
||||
|
||||
static void cb_print_selection(Fl_Round_Button*, void*) {
|
||||
print_from->deactivate();
|
||||
print_to->deactivate();
|
||||
print_to->deactivate();
|
||||
}
|
||||
|
||||
Fl_Int_Input *print_from=(Fl_Int_Input *)0;
|
||||
@ -70,22 +70,22 @@ Fl_Spinner *print_copies=(Fl_Spinner *)0;
|
||||
|
||||
static void cb_print_copies(Fl_Spinner*, void*) {
|
||||
if (print_copies->value() == 1) {
|
||||
print_collate_button->deactivate();
|
||||
print_collate_group[0]->deactivate();
|
||||
print_collate_group[1]->deactivate();
|
||||
} else {
|
||||
print_collate_button->activate();
|
||||
print_collate_group[0]->activate();
|
||||
print_collate_group[1]->activate();
|
||||
};
|
||||
print_collate_button->deactivate();
|
||||
print_collate_group[0]->deactivate();
|
||||
print_collate_group[1]->deactivate();
|
||||
} else {
|
||||
print_collate_button->activate();
|
||||
print_collate_group[0]->activate();
|
||||
print_collate_group[1]->activate();
|
||||
}
|
||||
}
|
||||
|
||||
Fl_Check_Button *print_collate_button=(Fl_Check_Button *)0;
|
||||
|
||||
static void cb_print_collate_button(Fl_Check_Button*, void*) {
|
||||
int i = print_collate_button->value() != 0;
|
||||
print_collate_group[i]->show();
|
||||
print_collate_group[1 - i]->hide();
|
||||
print_collate_group[i]->show();
|
||||
print_collate_group[1 - i]->hide();
|
||||
}
|
||||
|
||||
Fl_Group *print_collate_group[2]={(Fl_Group *)0};
|
||||
@ -100,7 +100,7 @@ Fl_Double_Window *print_properties_panel=(Fl_Double_Window *)0;
|
||||
|
||||
static void cb_print_properties_panel(Fl_Double_Window*, void*) {
|
||||
print_properties_panel->hide();
|
||||
print_update_status();
|
||||
print_update_status();
|
||||
}
|
||||
|
||||
Fl_Choice *print_page_size=(Fl_Choice *)0;
|
||||
@ -214,24 +214,24 @@ Fl_Button *print_output_mode[4]={(Fl_Button *)0};
|
||||
|
||||
static void cb_Save(Fl_Return_Button*, void*) {
|
||||
print_properties_panel->hide();
|
||||
|
||||
char name[1024];
|
||||
int val;
|
||||
const char *printer = (const char *)print_choice->menu()[print_choice->value()].user_data();
|
||||
|
||||
snprintf(name, sizeof(name), "%s/page_size", printer);
|
||||
fluid_prefs.set(name, print_page_size->value());
|
||||
|
||||
snprintf(name, sizeof(name), "%s/output_mode", printer);
|
||||
for (val = 0; val < 4; val ++) {
|
||||
if (print_output_mode[val]->value()) break;
|
||||
}
|
||||
fluid_prefs.set(name, val);
|
||||
|
||||
char name[1024];
|
||||
int val;
|
||||
const char *printer = (const char *)print_choice->menu()[print_choice->value()].user_data();
|
||||
|
||||
snprintf(name, sizeof(name), "%s/page_size", printer);
|
||||
fluid_prefs.set(name, print_page_size->value());
|
||||
|
||||
snprintf(name, sizeof(name), "%s/output_mode", printer);
|
||||
for (val = 0; val < 4; val ++) {
|
||||
if (print_output_mode[val]->value()) break;
|
||||
}
|
||||
fluid_prefs.set(name, val);
|
||||
}
|
||||
|
||||
static void cb_Cancel1(Fl_Button*, void*) {
|
||||
print_properties_panel->hide();
|
||||
print_update_status();
|
||||
print_update_status();
|
||||
}
|
||||
|
||||
static void cb_Use(Fl_Button*, void*) {
|
||||
|
@ -2,6 +2,8 @@
|
||||
version 1.0400
|
||||
header_name {.h}
|
||||
code_name {.cxx}
|
||||
mac_shell_cmd {echo "Fluid is nice"}
|
||||
mac_shell_flags 3
|
||||
comment {//
|
||||
// FLUID print panel for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
@ -20,7 +22,7 @@ comment {//
|
||||
} {in_source in_header
|
||||
}
|
||||
|
||||
decl {\#include "fluid.h"} {selected private local
|
||||
decl {\#include "fluid.h"} {private local
|
||||
}
|
||||
|
||||
decl {\#include <FL/fl_string.h>} {private local
|
||||
@ -212,7 +214,7 @@ print_collate_group[1 - i]->hide();}
|
||||
Fl_Window print_properties_panel {
|
||||
label {Printer Properties}
|
||||
callback {print_properties_panel->hide();
|
||||
print_update_status();}
|
||||
print_update_status();} selected
|
||||
xywh {462 486 290 130} type Double modal visible
|
||||
} {
|
||||
Fl_Choice print_page_size {
|
||||
|
@ -36,62 +36,62 @@ Fl_Double_Window *template_panel=(Fl_Double_Window *)0;
|
||||
|
||||
static void cb_template_panel(Fl_Double_Window*, void*) {
|
||||
Fl_Shared_Image *img = (Fl_Shared_Image *)template_preview->image();
|
||||
if (img) img->release();
|
||||
template_preview->image(0);
|
||||
|
||||
template_browser->deselect();
|
||||
template_name->value("");
|
||||
template_instance->value("");
|
||||
template_panel->hide();
|
||||
if (img) img->release();
|
||||
template_preview->image(0);
|
||||
|
||||
template_browser->deselect();
|
||||
template_name->value("");
|
||||
template_instance->value("");
|
||||
template_panel->hide();
|
||||
}
|
||||
|
||||
Fl_Browser *template_browser=(Fl_Browser *)0;
|
||||
|
||||
static void cb_template_browser(Fl_Browser*, void*) {
|
||||
if (Fl::event_clicks()) {
|
||||
template_panel->hide();
|
||||
return;
|
||||
}
|
||||
Fl_Shared_Image *img = (Fl_Shared_Image *)template_preview->image();
|
||||
if (img) img->release();
|
||||
template_preview->image(0);
|
||||
template_preview->redraw();
|
||||
|
||||
int item = template_browser->value();
|
||||
|
||||
if (item <= 1) template_instance->deactivate();
|
||||
else template_instance->activate();
|
||||
|
||||
if (item < 1) {
|
||||
template_submit->deactivate();
|
||||
template_delete->deactivate();
|
||||
return;
|
||||
}
|
||||
|
||||
template_submit->activate();
|
||||
|
||||
const char *flfile = (const char *)template_browser->data(item);
|
||||
if (!flfile) {
|
||||
template_delete->deactivate();
|
||||
return;
|
||||
}
|
||||
|
||||
template_name->value(template_browser->text(item));
|
||||
|
||||
template_delete->activate();
|
||||
|
||||
char pngfile[1024], *ext;
|
||||
|
||||
strlcpy(pngfile, flfile, sizeof(pngfile));
|
||||
if ((ext = strrchr(pngfile, '.')) == NULL) return;
|
||||
strcpy(ext, ".png");
|
||||
|
||||
img = Fl_Shared_Image::get(pngfile);
|
||||
|
||||
if (img) {
|
||||
template_preview->image(img);
|
||||
template_panel->hide();
|
||||
return;
|
||||
}
|
||||
Fl_Shared_Image *img = (Fl_Shared_Image *)template_preview->image();
|
||||
if (img) img->release();
|
||||
template_preview->image(0);
|
||||
template_preview->redraw();
|
||||
};
|
||||
|
||||
int item = template_browser->value();
|
||||
|
||||
if (item <= 1) template_instance->deactivate();
|
||||
else template_instance->activate();
|
||||
|
||||
if (item < 1) {
|
||||
template_submit->deactivate();
|
||||
template_delete->deactivate();
|
||||
return;
|
||||
}
|
||||
|
||||
template_submit->activate();
|
||||
|
||||
const char *flfile = (const char *)template_browser->data(item);
|
||||
if (!flfile) {
|
||||
template_delete->deactivate();
|
||||
return;
|
||||
}
|
||||
|
||||
template_name->value(template_browser->text(item));
|
||||
|
||||
template_delete->activate();
|
||||
|
||||
char pngfile[1024], *ext;
|
||||
|
||||
strlcpy(pngfile, flfile, sizeof(pngfile));
|
||||
if ((ext = strrchr(pngfile, '.')) == NULL) return;
|
||||
strcpy(ext, ".png");
|
||||
|
||||
img = Fl_Shared_Image::get(pngfile);
|
||||
|
||||
if (img) {
|
||||
template_preview->image(img);
|
||||
template_preview->redraw();
|
||||
}
|
||||
}
|
||||
|
||||
Fl_Box *template_preview=(Fl_Box *)0;
|
||||
@ -100,9 +100,9 @@ Fl_Input *template_name=(Fl_Input *)0;
|
||||
|
||||
static void cb_template_name(Fl_Input*, void*) {
|
||||
if (strlen(template_name->value())) {
|
||||
template_submit->activate();
|
||||
if (Fl::event_key() == FL_Enter) template_panel->hide();
|
||||
} else template_submit->deactivate();
|
||||
template_submit->activate();
|
||||
if (Fl::event_key() == FL_Enter) template_panel->hide();
|
||||
} else template_submit->deactivate();
|
||||
}
|
||||
|
||||
Fl_Input *template_instance=(Fl_Input *)0;
|
||||
@ -111,23 +111,23 @@ Fl_Button *template_delete=(Fl_Button *)0;
|
||||
|
||||
static void cb_Cancel(Fl_Button*, void*) {
|
||||
Fl_Shared_Image *img = (Fl_Shared_Image *)template_preview->image();
|
||||
if (img) img->release();
|
||||
template_preview->image(0);
|
||||
|
||||
template_browser->deselect();
|
||||
template_name->value("");
|
||||
template_instance->value("");
|
||||
template_panel->hide();
|
||||
if (img) img->release();
|
||||
template_preview->image(0);
|
||||
|
||||
template_browser->deselect();
|
||||
template_name->value("");
|
||||
template_instance->value("");
|
||||
template_panel->hide();
|
||||
}
|
||||
|
||||
Fl_Return_Button *template_submit=(Fl_Return_Button *)0;
|
||||
|
||||
static void cb_template_submit(Fl_Return_Button*, void*) {
|
||||
Fl_Shared_Image *img = (Fl_Shared_Image *)template_preview->image();
|
||||
if (img) img->release();
|
||||
template_preview->image(0);
|
||||
|
||||
template_panel->hide();
|
||||
if (img) img->release();
|
||||
template_preview->image(0);
|
||||
|
||||
template_panel->hide();
|
||||
}
|
||||
|
||||
Fl_Double_Window* make_template_panel() {
|
||||
|
@ -2,6 +2,8 @@
|
||||
version 1.0400
|
||||
header_name {.h}
|
||||
code_name {.cxx}
|
||||
mac_shell_cmd {echo "Fluid is nice"}
|
||||
mac_shell_flags 3
|
||||
comment {//
|
||||
// FLUID template support for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
|
@ -39,7 +39,7 @@ Function {make_widget_panel()} {
|
||||
} {
|
||||
Fl_Group {} {
|
||||
label GUI
|
||||
callback propagate_load
|
||||
callback propagate_load selected
|
||||
xywh {10 30 400 330} labelsize 11 when 0 resizable
|
||||
} {
|
||||
Fl_Group {} {
|
||||
|
Loading…
Reference in New Issue
Block a user