fltk
1.3.5-source
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X. Fossies Dox: fltk-1.3.5-source.tar.bz2 ("inofficial" and yet experimental doxygen-generated source code documentation) 
|
Go to the documentation of this file. 26 #include "../src/flstring.h" 57 const char *
_q_check(
const char * & c,
int type) {
58 for (;;)
switch (*c++) {
60 sprintf(
buffer,
"missing %c",type);
66 if (*(c-1) == type)
return 0;
71 const char *
_c_check(
const char * & c,
int type) {
73 for (;;)
switch (*c++) {
76 sprintf(
buffer,
"missing %c", type);
81 while (*c !=
'\n' && *c) c++;
82 }
else if (*c ==
'*') {
84 while ((*c !=
'*' || c[1] !=
'/') && *c) c++;
87 return "missing '*/'";
93 while (*c !=
'\n' && *c) c++;
96 if (type==
')')
goto UNEXPECTED;
115 if (type == *(c-1))
return 0;
116 sprintf(
buffer,
"unexpected %c", *(c-1));
121 const char *
c_check(
const char *c,
int type) {
131 while (
p && !
p->is_decl_block())
p =
p->parent;
133 o->
name(
"make_window()");
156 if (!strcmp(c,
"private")) {
158 }
else if (!strcmp(c,
"protected")) {
160 }
else if (!strcmp(c,
"C")) {
162 }
else if (!strcmp(c,
"return_type")) {
199 while (isspace(*c)) c++;
202 for (; *d !=
'('; d++)
if (isspace(*d) || !*d)
break;
203 if (*c && *d !=
'(') {
204 message =
"must be name(arguments), try again:";
continue;
236 if (c)
free((
void*)c);
255 char havechildren = 0;
267 write_c(
"int main(int argc, char **argv) {\n");
270 const char* star =
"";
276 if (!strcmp(rtype,
"static")) {is_static = 1; rtype = 0;}
277 else if (!strncmp(rtype,
"static ",7)) {is_static = 1; rtype += 7;}
278 if (!strcmp(rtype,
"virtual")) {is_virtual = 1; rtype = 0;}
279 else if (!strncmp(rtype,
"virtual ",8)) {is_virtual = 1; rtype += 8;}
285 }
else rtype =
"void";
293 if (
name()[0] ==
'~')
296 size_t n = strlen(k);
300 if (is_static)
write_h(
"static ");
301 if (is_virtual)
write_h(
"virtual ");
309 char s[1024], *sptr = s;
310 char *nptr = (
char *)
name();
314 if (nptr[1] !=
':')
break;
326 for (sptr=s,nptr=(
char*)
name(); *nptr; nc++,nptr++) {
327 if (!skips && *nptr==
'(') plevel++;
328 else if (!skips && *nptr==
')') plevel--;
329 if ( *nptr==
'"' && !(nc && *(nptr-1)==
'\\') )
330 skips = skips ? 0 : 1;
331 else if(!skips && *nptr==
'\'' && !(nc && *(nptr-1)==
'\\'))
332 skipc = skipc ? 0 : 1;
333 if(!skips && !skipc && plevel==1 && *nptr ==
'=' &&
334 !(nc && *(nptr-1)==
'\'') )
335 while(*++nptr && (skips || skipc || ( (*nptr!=
',' && *nptr!=
')') || plevel!=1) )) {
336 if ( *nptr==
'"' && *(nptr-1)!=
'\\' )
337 skips = skips ? 0 : 1;
338 else if(!skips && *nptr==
'\'' && *(nptr-1)!=
'\\')
339 skipc = skipc ? 0 : 1;
340 if (!skips && !skipc && *nptr==
'(') plevel++;
341 else if (!skips && *nptr==
')') plevel--;
344 if (sptr < (s +
sizeof(s) - 1)) *sptr++ = *nptr;
355 write_h(
"extern \"C\" { %s%s %s; }\n", rtype, star,
name());
368 for (sptr=s,nptr=(
char*)
name(); *nptr; nc++,nptr++) {
369 if (!skips && *nptr==
'(') plevel++;
370 else if (!skips && *nptr==
')') plevel--;
371 if ( *nptr==
'"' && !(nc && *(nptr-1)==
'\\') )
372 skips = skips ? 0 : 1;
373 else if(!skips && *nptr==
'\'' && !(nc && *(nptr-1)==
'\\'))
374 skipc = skipc ? 0 : 1;
375 if(!skips && !skipc && plevel==1 && *nptr ==
'=' &&
376 !(nc && *(nptr-1)==
'\'') )
377 while(*++nptr && (skips || skipc || ( (*nptr!=
',' && *nptr!=
')') || plevel!=1) )) {
378 if ( *nptr==
'"' && *(nptr-1)!=
'\\' )
379 skips = skips ? 0 : 1;
380 else if(!skips && *nptr==
'\'' && *(nptr-1)!=
'\\')
381 skipc = skipc ? 0 : 1;
382 if (!skips && !skipc && *nptr==
'(') plevel++;
383 else if (!skips && *nptr==
')') plevel--;
386 if (sptr < (s +
sizeof(s) - 1)) *sptr++ = *nptr;
391 write_c(
"%s%s %s {\n", rtype, star, s);
401 const char *var =
"w";
402 char havechildren = 0;
410 if (havechildren)
write_c(
" return Fl::run();\n");
421 if (!
name())
return 0;
433 while (
p && !
p->is_code_block())
p =
p->parent;
439 o->
name(
"printf(\"Hello, World!\\n\");");
455 const char *text =
name();
493 const char* c =
name();
497 const char *ind =
indent();
498 while( (pch=strchr(c,
'\n')) )
500 int line_len = pch - c;
501 write_c(
"%s%.*s\n", ind, line_len, c);
513 while (
p && !
p->is_code_block())
p =
p->parent;
519 o->
name(
"if (test())");
535 if (!strcmp(c,
"after")) {
571 const char* c =
name();
587 while (
p && !
p->is_decl_block())
p =
p->parent;
597 while (
p && !
p->is_decl_block())
p =
p->parent;
621 if (!strcmp(c,
"public")) {
623 }
else if (!strcmp(c,
"private")) {
625 }
else if (!strcmp(c,
"protected")) {
627 }
else if (!strcmp(c,
"local")) {
629 }
else if (!strcmp(c,
"global")) {
661 while (isspace(*c)) c++;
688 if (c)
free((
void*)c);
698 const char* c =
name();
701 if (
is_in_class() && ( (!strncmp(c,
"class",5) && isspace(c[5]))
702 || (!strncmp(c,
"typedef",7) && isspace(c[7]))
703 || (!strncmp(c,
"FL_EXPORT",9) && isspace(c[9]))
704 || (!strncmp(c,
"struct",6) && isspace(c[6]))
712 if ( (!isalpha(*c) && *c !=
'~')
713 || (!strncmp(c,
"extern",6) && isspace(c[6]))
714 || (!strncmp(c,
"class",5) && isspace(c[5]))
715 || (!strncmp(c,
"typedef",7) && isspace(c[7]))
716 || (!strncmp(c,
"using",5) && isspace(c[5]))
717 || (!strncmp(c,
"FL_EXPORT",9) && isspace(c[9]))
730 const char* e = c+strlen(c), *csc = c;
731 while (csc<e && (csc[0]!=
'/' || csc[1]!=
'/')) csc++;
734 while (e>c && e[-1]==
' ') e--;
735 while (e>c && e[-1]==
';') e--;
739 write_h(
" %.*s; %s\n", (
int)(e-c), c, csc);
746 write_h(
"%.*s; %s\n", (
int)(e-c), c, csc);
749 write_c(
"%.*s; %s\n", (
int)(e-c), c, csc);
755 write_c(
"%.*s; %s\n", (
int)(e-c), c, csc);
766 while (
p && !
p->is_decl_block())
p =
p->parent;
771 o->name(
"myBinaryData");
786 if (!strcmp(c,
"filename")) {
830 char *s = strdup(c), *
p = s, *q, *n;
832 if (!isspace((
unsigned char)(*
p)))
break;
835 if ( (!isalpha((
unsigned char)(*
p))) && ((*
p)!=
'_') && ((*
p)!=
':') )
goto OOPS;
838 if ( (!isalnum((
unsigned char)(*
p))) && ((*
p)!=
'_') && ((*
p)!=
':') )
break;
843 if (!isspace((
unsigned char)(*q)))
goto OOPS;
846 OOPS:
message =
"variable name must be a C identifier";
886 if (c)
free((
void*)c);
897 const char *c =
name();
906 message =
"Can't include binary file. Can't open";
912 data = (
char*)
calloc(nData, 1);
913 if (fread(data, nData, 1,
f)==0) { }
918 fn =
"<no filename>";
923 write_h(
" static unsigned char %s[%d];\n", c, nData);
924 write_c(
"unsigned char %s::%s[%d] = /* binary data included from %s */\n",
class_name(1), c, nData, fn);
932 write_h(
"extern unsigned char %s[%d];\n", c, nData);
934 write_c(
"unsigned char %s[%d] = /* binary data included from %s */\n", c, nData, fn);
940 write_h(
"#error Unsupported declaration loading binary data %s\n", fn);
941 write_h(
"unsigned char %s[3] = { 1, 2, 3 };\n", c);
947 write_c(
"unsigned char %s[%d] = /* binary data included from %s */\n", c, nData, fn);
957 fprintf(stderr,
"FLUID ERROR: %s %s\n",
message, fn);
961 if (data)
free(data);
972 while (
p && !
p->is_decl_block())
p =
p->parent;
976 o->after = strdup(
"#endif");
993 if(!strcmp(c,
"public")) {
995 }
else if(!strcmp(c,
"protected")) {
997 }
else if (!strcmp(c,
"after")) {
1020 while (isspace(*c)) c++;
1025 while (isspace(*c)) c++;
1043 const char* c =
name();
1050 const char* c =
after;
1060 while (
p && !
p->is_code_block())
p =
p->parent;
1065 o->name(
"my comment");
1068 o->title_buf[0] = 0;
1079 if (!strcmp(c,
"in_source")) {
1081 }
else if (!strcmp(c,
"not_in_source")) {
1083 }
else if (!strcmp(c,
"in_header")) {
1085 }
else if (!strcmp(c,
"not_in_header")) {
1095 static const char *
const predefined_comment[] = {
1096 "GNU Public License/GPL Header",
"GNU Public License/GPL Footer",
1097 "GNU Public License/LGPL Header",
"GNU Public License/LGPL Footer",
1098 "FLTK/Header",
"FLTK/Footer" };
1102 for (i=0; i<6; i++) {
1110 const char *text =
name();
1117 menu.
get(
"n", n, -1);
1119 menu.
get(
"n", n, 0);
1133 int last_selected_item = 0;
1144 "Please enter a name to reference the current\ncomment in your database.\n\n" 1145 "Use forward slashes '/' to create submenus.",
1148 char *
name = strdup(xname);
1149 for (
char*s=
name;*s;s++)
if (*s==
':') *s =
';';
1154 menu.
get(
"n", n, 0);
1162 if (itempath[0]==0 || last_selected_item==0) {
1163 fl_message(
"Please select an entry form this menu first.");
1164 }
else if (
fl_choice(
"Are you sure that you want to delete the entry\n" 1165 "\"%s\"\nfrom the database?",
"Cancel",
"Delete",
1175 if (itempath[0]==
'/') memmove(itempath, itempath+1, 255);
1184 if (itempath[0]==
'/') memmove(itempath, itempath+1, 255);
1187 db.
get(itempath, text,
"(no text found in data base)");
1228 const char* n =
name();
1237 if (n==
'\r') { *d++ =
'\\'; *d++ =
'r'; i--; }
1238 else if (n==
'\n') { *d++ =
'\\'; *d++ =
'n'; i--; }
1239 else if (n<32) { *d++ =
'^'; *d++ =
'A'+n; i--; }
1242 if (i<=0) { *d++ =
'.'; *d++ =
'.'; *d++ =
'.'; }
1251 const char* c =
name();
1256 while (isspace(*s)) s++;
1259 if (s[0]==
'/' && s[1]==
'*') {
1265 char *txt = strdup(c);
1266 char *
b = txt, *e = txt;
1269 while (*e && *e!=
'\n') e++;
1274 while (isspace(*s)) s++;
1275 if (s!=e && ( s[0]!=
'/' || s[1]!=
'/') ) {
1296 if (
p->is_class()) {
1300 if(need_nest) q=
p->class_name(need_nest);
1303 if (q != s)
strlcpy(s, q,
sizeof(s));
1321 if (
p->is_class()) {
1338 while (
p && !
p->is_decl_block())
p =
p->parent;
1340 o->
name(
"UserInterface");
1362 if (!strcmp(c,
"private")) {
1364 }
else if (!strcmp(c,
"protected")) {
1366 }
else if (!strcmp(c,
":")) {
1379 strcpy(fullname,
name());
1388 char *na=0,*pr=0,*
p=0;
1399 char *s = strdup(c);
1400 size_t len = strlen(s);
1402 p = (
char*) (s+len-1);
1403 while (
p>=s && isspace(*
p)) *(
p--)=
'\0';
1406 if ( (
p<s && !
is_id(*(
p+1))) || !*(
p+1) ) {
1407 OOPS:
message =
"class name must be C++ identifier";
1413 while (
p>=s && isspace(*
p)) *(
p--)=
'\0';
1436 if (c)
free((
void*)c);
1454 case 0:
write_h(
"private:\n");
break;
1455 case 1:
write_h(
"public:\n");
break;
1456 case 2:
write_h(
"protected:\n");
break;
void fl_file_chooser_ok_label(const char *l)
void buffer(Fl_Text_Buffer *buf)
void read_property(const char *)
Fl_Function_Type Fl_Function_type
Fl_Button * decl_panel_cancel
Fl_Light_Button * f_c_button
virtual int is_public() const
void fl_message(const char *,...)
Fl_Text_Editor * decl_comment_input
CodeEditor * comment_input
int G_use_external_editor
Fl_Button * codeblock_panel_cancel
virtual void write_properties()
Fl_Class_Type * current_class
char G_external_editor_command[512]
virtual int is_public() const
Fl_Light_Button * comment_in_source
Fl_Comment_Type Fl_Comment_type
Fl_Double_Window * make_comment_panel()
Fl_Return_Button * codeblock_panel_ok
const char * class_prefix
Preferences apply only to the current user.
Fl_Double_Window * make_decl_panel()
void add(Fl_Type *parent)
Fl_Button * code_panel_cancel
static Fl_Widget * readqueue()
Fl_Text_Editor * c_comment_input
static void load_comments_preset(Fl_Preferences &menu)
int has_function(const char *, const char *) const
Fl_Return_Button * code_panel_ok
Fl_Button * declblock_panel_cancel
virtual int is_widget() const
Fl_Double_Window * codeblock_panel
Fl_Choice * declblock_public_choice
void read_property(const char *)
Fl_Button * data_panel_cancel
Fl_Input * decl_before_input
Fl_Return_Button * data_panel_ok
void write_c(const char *format,...)
FILE * fl_fopen(const char *f, const char *mode)
const class Fl_Class_Type * is_in_class() const
void read_property(const char *)
int fl_choice(const char *q, const char *b0, const char *b1, const char *b2,...)
const char * subclassname(Fl_Type *)
Fl_Double_Window * make_function_panel()
virtual int is_public() const
Fl_Double_Window * decl_panel
Fl_Double_Window * make_declblock_panel()
Fl_Class_Type * parent_class
Fl_Input * code_before_input
char * fl_file_chooser(const char *message, const char *pat, const char *fname, int relative=0)
const char * fl_input(const char *label, const char *deflt=0,...)
Fl_Input * f_return_type_input
int fl_filename_match(const char *name, const char *pattern)
Fl_Text_Editor * f_comment_input
static const char * fname
Fl_Light_Button * comment_in_header
Fl_Button * data_filebrowser
virtual const char * type_name()=0
Fl_Return_Button * decl_panel_ok
Fl_Decl_Type Fl_Decl_type
Fl_Double_Window * make_data_panel()
Fl_Code_Type Fl_Code_type
char get(const char *entry, int &value, int defaultValue)
void read_property(const char *)
Fl_Button * f_panel_cancel
char set(const char *entry, int value)
void write_string(const char *format,...)
virtual int is_window() const
Fl_Data_Type Fl_Data_type
void write_comment_h(const char *ind="")
Fl_Light_Button * c_public_button
Fl_Return_Button * f_panel_ok
const char * class_name(const int need_nest) const
Fl_Double_Window * make_class_panel()
Fl_Double_Window * data_panel
const char * _c_check(const char *&c, int type)
void write_word(const char *w)
Fl_Menu_Button * comment_predefined
int handle_editor_changes()
Fl_Double_Window * make_codeblock_panel()
virtual void read_property(const char *)
Fl_Class_Type Fl_Class_type
const char * i18n_function
Fl_Input * c_subclass_input
Fl_DeclBlock_Type Fl_DeclBlock_type
Fl_Double_Window * function_panel
Fl_Choice * decl_class_choice
Fl_Return_Button * declblock_panel_ok
void write_h(const char *format,...)
Fl_Return_Button * c_panel_ok
int has_signature(const char *, const char *) const
Fl_Input * code_after_input
Fl_CodeBlock_Type Fl_CodeBlock_type
int storestring(const char *n, const char *&p, int nostrip)
Fl_Button * comment_panel_cancel
Fl_Double_Window * class_panel
Fl_Return_Button * comment_panel_ok
const char * read_word(int wantbrace)
const char * name() const
Fl_Input * decl_after_input
Fl_Preferences provides methods to store user settings between application starts.
Fl_Choice * f_public_choice
const char * prefix() const
Fl_Double_Window * code_panel
Fl_Choice * f_public_member_choice
void write_comment_c(const char *ind="")
const char * i18n_include
void read_property(const char *)
char deleteEntry(const char *entry)
Fl_Double_Window * make_code_panel()
virtual int is_public() const
void read_property(const char *)
Fl_Widget_Class_Type * current_widget_class
Fl_Choice * data_class_choice
int open_editor(const char *editor_cmd, const char *code)
void fl_alert(const char *,...)
Fl_Double_Window * declblock_panel
void write_cdata(const char *s, int length)
const char * c_check(const char *c, int type)
Fl_Button * c_panel_cancel
Fl_Double_Window * comment_panel
const char * _q_check(const char *&c, int type)
Fl_Text_Editor * data_comment_input
ExternalCodeEditor editor_
void write_public(int state)