file.cxx
来自「SRI international 发布的OAA框架软件」· CXX 代码 · 共 642 行 · 第 1/2 页
CXX
642 行
if(!include_H_from_C)
write_string("\ndo_not_include_H_from_C");
if (i18n_type) {
write_string("\ni18n_type %d", i18n_type);
write_string("\ni18n_include %s", i18n_include);
switch (i18n_type) {
case 1 : /* GNU gettext */
write_string("\ni18n_function %s", i18n_function);
break;
case 2 : /* POSIX catgets */
if (i18n_file[0]) write_string("\ni18n_file %s", i18n_file);
write_string("\ni18n_set %s", i18n_set);
break;
}
}
if (!selected_only) {
write_string("\nheader_name"); write_word(header_file_name);
write_string("\ncode_name"); write_word(code_file_name);
}
for (Fl_Type *p = Fl_Type::first; p;) {
if (!selected_only || p->selected) {
p->write();
write_string("\n");
int q = p->level;
for (p = p->next; p && p->level > q; p = p->next);
} else {
p = p->next;
}
}
return close_write();
}
////////////////////////////////////////////////////////////////
// read all the objects out of the input file:
void read_fdesign();
double read_version;
extern Fl_Type *Fl_Type_make(const char *tn);
static void read_children(Fl_Type *p, int paste) {
Fl_Type::current = p;
for (;;) {
const char *c = read_word();
REUSE_C:
if (!c) {
if (p && !paste) read_error("Missing '}'");
break;
}
if (!strcmp(c,"}")) {
if (!p) read_error("Unexpected '}'");
break;
}
// this is the first word in a .fd file:
if (!strcmp(c,"Magic:")) {
read_fdesign();
return;
}
if (!strcmp(c,"version")) {
c = read_word();
read_version = strtod(c,0);
if (read_version<=0 || read_version>FL_VERSION)
read_error("unknown version '%s'",c);
continue;
}
// back compatability with Vincent Penne's original class code:
if (!p && !strcmp(c,"define_in_struct")) {
Fl_Type *t = Fl_Type_make("class");
t->name(read_word());
Fl_Type::current = p = t;
paste = 1; // stops "missing }" error
continue;
}
if (!strcmp(c,"do_not_include_H_from_C")) {
include_H_from_C=0;
goto CONTINUE;
}
if (!strcmp(c,"i18n_type")) {
i18n_type = atoi(read_word());
goto CONTINUE;
}
if (!strcmp(c,"i18n_function")) {
i18n_function = strdup(read_word());
goto CONTINUE;
}
if (!strcmp(c,"i18n_file")) {
i18n_file = strdup(read_word());
goto CONTINUE;
}
if (!strcmp(c,"i18n_set")) {
i18n_set = strdup(read_word());
goto CONTINUE;
}
if (!strcmp(c,"i18n_include")) {
i18n_include = strdup(read_word());
goto CONTINUE;
}
if (!strcmp(c,"i18n_type"))
{
i18n_type = atoi(read_word());
goto CONTINUE;
}
if (!strcmp(c,"i18n_type"))
{
i18n_type = atoi(read_word());
goto CONTINUE;
}
if (!strcmp(c,"header_name")) {
if (!header_file_set) header_file_name = strdup(read_word());
else read_word();
goto CONTINUE;
}
if (!strcmp(c,"code_name")) {
if (!code_file_set) code_file_name = strdup(read_word());
else read_word();
goto CONTINUE;
}
if (!strcmp(c, "snap") || !strcmp(c, "gridx") || !strcmp(c, "gridy")) {
// grid settings are now global
read_word();
goto CONTINUE;
}
{Fl_Type *t = Fl_Type_make(c);
if (!t) {
read_error("Unknown word \"%s\"", c);
continue;
}
t->name(read_word());
c = read_word(1);
if (strcmp(c,"{") && t->is_class()) { // <prefix> <name>
((Fl_Class_Type*)t)->prefix(t->name());
t->name(c);
c = read_word(1);
}
if (strcmp(c,"{")) {
read_error("Missing property list for %s\n",t->title());
goto REUSE_C;
}
t->open_ = 0;
for (;;) {
const char *cc = read_word();
if (!cc || !strcmp(cc,"}")) break;
t->read_property(cc);
}
if (!t->is_parent()) continue;
c = read_word(1);
if (strcmp(c,"{")) {
read_error("Missing child list for %s\n",t->title());
goto REUSE_C;
}
read_children(t, 0);}
Fl_Type::current = p;
CONTINUE:;
}
}
extern void deselect();
int read_file(const char *filename, int merge) {
Fl_Type *o;
read_version = 0.0;
if (!open_read(filename)) return 0;
if (merge) deselect(); else delete_all();
read_children(Fl_Type::current, merge);
Fl_Type::current = 0;
// Force menu items to be rebuilt...
for (o = Fl_Type::first; o; o = o->next)
if (o->is_menu_button()) o->add_child(0,0);
for (o = Fl_Type::first; o; o = o->next)
if (o->selected) {Fl_Type::current = o; break;}
return close_read();
}
////////////////////////////////////////////////////////////////
// Read Forms and XForms fdesign files:
int read_fdesign_line(const char*& name, const char*& value) {
int length = 0;
int x;
// find a colon:
for (;;) {
x = getc(fin);
if (x < 0) return 0;
if (x == '\n') {length = 0; continue;} // no colon this line...
if (!isspace(x)) {
buffer[length++] = x;
expand_buffer(length);
}
if (x == ':') break;
}
int valueoffset = length;
buffer[length-1] = 0;
// skip to start of value:
for (;;) {
x = getc(fin);
if (x < 0 || x == '\n' || !isspace(x)) break;
}
// read the value:
for (;;) {
if (x == '\\') {x = read_quoted(); if (x<0) continue;}
else if (x == '\n') break;
buffer[length++] = x;
expand_buffer(length);
x = getc(fin);
}
buffer[length] = 0;
name = buffer;
value = buffer+valueoffset;
return 1;
}
int fdesign_flip;
int fdesign_magic;
#include <FL/Fl_Group.H>
static const char *class_matcher[] = {
"FL_CHECKBUTTON", "Fl_Check_Button",
"FL_ROUNDBUTTON", "Fl_Round_Button",
"FL_ROUND3DBUTTON", "Fl_Round_Button",
"FL_LIGHTBUTTON", "Fl_Light_Button",
"FL_FRAME", "Fl_Box",
"FL_LABELFRAME", "Fl_Box",
"FL_TEXT", "Fl_Box",
"FL_VALSLIDER", "Fl_Value_Slider",
"FL_MENU", "Fl_Menu_Button",
"3", "FL_BITMAP",
"1", "FL_BOX",
"71","FL_BROWSER",
"11","FL_BUTTON",
"4", "FL_CHART",
"42","FL_CHOICE",
"61","FL_CLOCK",
"25","FL_COUNTER",
"22","FL_DIAL",
"101","FL_FREE",
"31","FL_INPUT",
"12","Fl_Light_Button",
"41","FL_MENU",
"23","FL_POSITIONER",
"13","Fl_Round_Button",
"21","FL_SLIDER",
"2", "FL_BOX", // was FL_TEXT
"62","FL_TIMER",
"24","Fl_Value_Slider",
0};
void read_fdesign() {
fdesign_magic = atoi(read_word());
fdesign_flip = (fdesign_magic < 13000);
Fl_Widget_Type *window = 0;
Fl_Widget_Type *group = 0;
Fl_Widget_Type *widget = 0;
if (!Fl_Type::current) {
Fl_Type *t = Fl_Type_make("Function");
t->name("create_the_forms()");
Fl_Type::current = t;
}
for (;;) {
const char *name;
const char *value;
if (!read_fdesign_line(name, value)) break;
if (!strcmp(name,"Name")) {
window = (Fl_Widget_Type*)Fl_Type_make("Fl_Window");
window->name(value);
window->label(value);
Fl_Type::current = widget = window;
} else if (!strcmp(name,"class")) {
if (!strcmp(value,"FL_BEGIN_GROUP")) {
group = widget = (Fl_Widget_Type*)Fl_Type_make("Fl_Group");
Fl_Type::current = group;
} else if (!strcmp(value,"FL_END_GROUP")) {
if (group) {
Fl_Group* g = (Fl_Group*)(group->o);
g->begin();
g->forms_end();
Fl_Group::current(0);
}
group = widget = 0;
Fl_Type::current = window;
} else {
for (int i = 0; class_matcher[i]; i += 2)
if (!strcmp(value,class_matcher[i])) {
value = class_matcher[i+1]; break;}
widget = (Fl_Widget_Type*)Fl_Type_make(value);
if (!widget) {
printf("class %s not found, using Fl_Button\n", value);
widget = (Fl_Widget_Type*)Fl_Type_make("Fl_Button");
}
}
} else if (widget) {
if (!widget->read_fdesign(name, value))
printf("Ignoring \"%s: %s\"\n", name, value);
}
}
}
//
// End of "$Id: file.cxx,v 1.1.1.1 2003/06/03 22:25:41 agno Exp $".
//
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?