Browse Source

FLUID changes to support GNU gettext and POSIX catgets under FLTK 1.0;

will work on changes for 2.0 later this week...

(please let me know what you think...)


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@1082 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
branch-1.0
Michael R Sweet 25 years ago
parent
commit
8ff6d1daf4
  1. 29
      fluid/Fl_Menu_Type.cxx
  2. 5
      fluid/Fl_Type.h
  3. 27
      fluid/Fl_Widget_Type.cxx
  4. 79
      fluid/Fl_Window_Type.cxx
  5. 77
      fluid/alignment_panel.cxx
  6. 68
      fluid/alignment_panel.fl
  7. 9
      fluid/alignment_panel.h
  8. 91
      fluid/code.cxx
  9. 55
      fluid/file.cxx
  10. 33
      fluid/fluid.cxx

29
fluid/Fl_Menu_Type.cxx

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
//
// "$Id: Fl_Menu_Type.cxx,v 1.16.2.5 2000/02/05 09:20:45 bill Exp $"
// "$Id: Fl_Menu_Type.cxx,v 1.16.2.6 2000/04/24 18:22:47 mike Exp $"
//
// Menu item code for the Fast Light Tool Kit (FLTK).
//
@ -31,6 +31,7 @@ @@ -31,6 +31,7 @@
#include <FL/Fl.H>
#include "Fl_Widget_Type.h"
#include "alignment_panel.h"
#include <FL/fl_message.H>
#include <FL/Fl_Menu_.H>
#include <FL/Fl_Button.H>
@ -46,6 +47,12 @@ Fl_Menu_Item menu_item_type_menu[] = { @@ -46,6 +47,12 @@ Fl_Menu_Item menu_item_type_menu[] = {
extern int reading_file;
extern int force_parent;
extern int msgnum;
extern int i18n_type;
extern const char* i18n_include;
extern const char* i18n_function;
extern const char* i18n_file;
extern const char* i18n_set;
static char submenuflag;
@ -209,7 +216,23 @@ int Fl_Menu_Item_Type::flags() { @@ -209,7 +216,23 @@ int Fl_Menu_Item_Type::flags() {
void Fl_Menu_Item_Type::write_item() {
write_c(" {");
if (image) write_c("0");
else if (label()) write_cstring(label());
else if (label()) {
switch (i18n_type) {
case 0 : /* None */
write_cstring(label());
break;
case 1 : /* GNU gettext */
write_c("%s(", i18n_function);
write_cstring(label());
write_c(")");
break;
case 2 : /* POSIX catgets */
write_c("catgets(%s,%s,%d,", i18n_file, i18n_set, msgnum ++);
write_cstring(label());
write_c(")");
break;
}
}
else write_c("\"\"");
if (((Fl_Button*)o)->shortcut())
write_c(", 0x%x, ", ((Fl_Button*)o)->shortcut());
@ -439,5 +462,5 @@ void shortcut_in_cb(Shortcut_Button* i, void* v) { @@ -439,5 +462,5 @@ void shortcut_in_cb(Shortcut_Button* i, void* v) {
}
//
// End of "$Id: Fl_Menu_Type.cxx,v 1.16.2.5 2000/02/05 09:20:45 bill Exp $".
// End of "$Id: Fl_Menu_Type.cxx,v 1.16.2.6 2000/04/24 18:22:47 mike Exp $".
//

5
fluid/Fl_Type.h

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
//
// "$Id: Fl_Type.h,v 1.5.2.6 2000/02/05 09:20:46 bill Exp $"
// "$Id: Fl_Type.h,v 1.5.2.7 2000/04/24 18:22:47 mike Exp $"
//
// Widget type header file for the Fast Light Tool Kit (FLTK).
//
@ -499,6 +499,7 @@ void write_word(const char *); @@ -499,6 +499,7 @@ void write_word(const char *);
void write_string(const char *,...);
int write_file(const char *, int selected_only = 0);
int write_code(const char *cfile, const char *hfile);
int write_strings(const char *sfile);
int write_declare(const char *, ...);
int is_id(char);
@ -528,5 +529,5 @@ int storestring(const char *n, const char * & p, int nostrip=0); @@ -528,5 +529,5 @@ int storestring(const char *n, const char * & p, int nostrip=0);
extern int include_H_from_C;
//
// End of "$Id: Fl_Type.h,v 1.5.2.6 2000/02/05 09:20:46 bill Exp $".
// End of "$Id: Fl_Type.h,v 1.5.2.7 2000/04/24 18:22:47 mike Exp $".
//

27
fluid/Fl_Widget_Type.cxx

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
//
// "$Id: Fl_Widget_Type.cxx,v 1.15.2.10 2000/03/06 14:45:54 mike Exp $"
// "$Id: Fl_Widget_Type.cxx,v 1.15.2.11 2000/04/24 18:22:48 mike Exp $"
//
// Widget type code for the Fast Light Tool Kit (FLTK).
//
@ -27,6 +27,7 @@ @@ -27,6 +27,7 @@
#include <FL/Fl_Group.H>
#include <FL/Fl_Input.H>
#include "Fl_Widget_Type.h"
#include "alignment_panel.h"
#include <FL/fl_message.H>
#include <FL/Fl_Slider.H>
#include <FL/Fl_Window.H>
@ -45,6 +46,12 @@ extern int reading_file; @@ -45,6 +46,12 @@ extern int reading_file;
int force_parent;
extern int gridx;
extern int gridy;
extern int msgnum;
extern int i18n_type;
extern const char* i18n_include;
extern const char* i18n_function;
extern const char* i18n_file;
extern const char* i18n_set;
int Fl_Widget_Type::is_widget() const {return 1;}
@ -1333,7 +1340,21 @@ void Fl_Widget_Type::write_code1() { @@ -1333,7 +1340,21 @@ void Fl_Widget_Type::write_code1() {
}
if (!image && label() && *label()) {
write_c(", ");
write_cstring(label());
switch (i18n_type) {
case 0 : /* None */
write_cstring(label());
break;
case 1 : /* GNU gettext */
write_c("%s(", i18n_function);
write_cstring(label());
write_c(")");
break;
case 2 : /* POSIX catgets */
write_c("catgets(%s,%s,%d,", i18n_file, i18n_set, msgnum ++);
write_cstring(label());
write_c(")");
break;
}
}
write_c(");\n");
indentation += 2;
@ -1747,5 +1768,5 @@ int Fl_Widget_Type::read_fdesign(const char* name, const char* value) { @@ -1747,5 +1768,5 @@ int Fl_Widget_Type::read_fdesign(const char* name, const char* value) {
}
//
// End of "$Id: Fl_Widget_Type.cxx,v 1.15.2.10 2000/03/06 14:45:54 mike Exp $".
// End of "$Id: Fl_Widget_Type.cxx,v 1.15.2.11 2000/04/24 18:22:48 mike Exp $".
//

79
fluid/Fl_Window_Type.cxx

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
//
// "$Id: Fl_Window_Type.cxx,v 1.13.2.3 1999/09/10 16:40:17 bill Exp $"
// "$Id: Fl_Window_Type.cxx,v 1.13.2.4 2000/04/24 18:22:49 mike Exp $"
//
// Window type code for the Fast Light Tool Kit (FLTK).
//
@ -43,6 +43,12 @@ int gridy = 5; @@ -43,6 +43,12 @@ int gridy = 5;
int snap = 3;
int include_H_from_C = 1;
extern int i18n_type;
extern const char* i18n_include;
extern const char* i18n_function;
extern const char* i18n_file;
extern const char* i18n_set;
extern int modflag;
void alignment_cb(Fl_Input *i, long v) {
int n = atoi(i->value());
@ -52,6 +58,50 @@ void alignment_cb(Fl_Input *i, long v) { @@ -52,6 +58,50 @@ void alignment_cb(Fl_Input *i, long v) {
case 2: gridy = n; break;
case 3: snap = n; break;
}
modflag = 1;
}
void i18n_type_cb(Fl_Choice *c, void *) {
switch (i18n_type = c->value()) {
case 0 : /* None */
i18n_include_input->hide();
i18n_file_input->hide();
i18n_set_input->hide();
i18n_function_input->hide();
break;
case 1 : /* GNU gettext */
i18n_include_input->value("<libintl.h>");
i18n_function_input->value("gettext");
i18n_include_input->show();
i18n_file_input->hide();
i18n_set_input->hide();
i18n_function_input->show();
break;
case 2 : /* POSIX cat */
i18n_include_input->value("<nl_types.h>");
i18n_file_input->value("i18n_file");
i18n_set_input->value("1");
i18n_include_input->show();
i18n_file_input->show();
i18n_set_input->show();
i18n_function_input->hide();
break;
}
modflag = 1;
}
void i18n_text_cb(Fl_Input *i, void *) {
if (i == i18n_function_input)
i18n_function = i->value();
else if (i == i18n_file_input)
i18n_file = i->value();
else if (i == i18n_set_input)
i18n_set = i->value();
else if (i == i18n_include_input)
i18n_include = i->value();
modflag = 1;
}
extern const char* header_file_name;
@ -66,6 +116,31 @@ void show_alignment_cb(Fl_Widget *, void *) { @@ -66,6 +116,31 @@ void show_alignment_cb(Fl_Widget *, void *) {
sprintf(buf,"%d",gridx); horizontal_input->value(buf);
sprintf(buf,"%d",gridy); vertical_input->value(buf);
sprintf(buf,"%d",snap); snap_input->value(buf);
i18n_type_chooser->value(i18n_type);
i18n_function_input->value(i18n_function);
i18n_file_input->value(i18n_file);
i18n_set_input->value(i18n_set);
i18n_include_input->value(i18n_include);
switch (i18n_type) {
case 0 : /* None */
i18n_include_input->hide();
i18n_file_input->hide();
i18n_set_input->hide();
i18n_function_input->hide();
break;
case 1 : /* GNU gettext */
i18n_include_input->show();
i18n_file_input->hide();
i18n_set_input->hide();
i18n_function_input->show();
break;
case 2 : /* POSIX cat */
i18n_include_input->show();
i18n_file_input->show();
i18n_set_input->show();
i18n_function_input->hide();
break;
}
alignment_window->show();
}
@ -672,5 +747,5 @@ int Fl_Window_Type::read_fdesign(const char* name, const char* value) { @@ -672,5 +747,5 @@ int Fl_Window_Type::read_fdesign(const char* name, const char* value) {
}
//
// End of "$Id: Fl_Window_Type.cxx,v 1.13.2.3 1999/09/10 16:40:17 bill Exp $".
// End of "$Id: Fl_Window_Type.cxx,v 1.13.2.4 2000/04/24 18:22:49 mike Exp $".
//

77
fluid/alignment_panel.cxx

@ -20,62 +20,117 @@ Fl_Input *code_file_input=(Fl_Input *)0; @@ -20,62 +20,117 @@ Fl_Input *code_file_input=(Fl_Input *)0;
Fl_Light_Button *include_H_from_C_button=(Fl_Light_Button *)0;
Fl_Choice *i18n_type_chooser=(Fl_Choice *)0;
Fl_Menu_Item menu_i18n_type_chooser[] = {
{"None", 0, 0, 0, 0, 0, 0, 14, 0},
{"GNU gettext", 0, 0, 0, 0, 0, 0, 14, 0},
{"POSIX catgets", 0, 0, 0, 0, 0, 0, 14, 0},
{0}
};
Fl_Input *i18n_include_input=(Fl_Input *)0;
Fl_Input *i18n_file_input=(Fl_Input *)0;
Fl_Input *i18n_set_input=(Fl_Input *)0;
Fl_Input *i18n_function_input=(Fl_Input *)0;
Fl_Window* make_alignment_window() {
Fl_Window* w;
{ Fl_Window* o = alignment_window = new Fl_Window(210, 320, "Preferences");
{ Fl_Window* o = alignment_window = new Fl_Window(365, 340, "Preferences");
w = o;
{ Fl_Box* o = new Fl_Box(10, 25, 190, 100, "Alignment:");
{ Fl_Box* o = new Fl_Box(10, 25, 130, 130, "Alignment:");
o->box(FL_ENGRAVED_FRAME);
o->labelsize(12);
o->align(FL_ALIGN_TOP_LEFT);
}
{ Fl_Input* o = horizontal_input = new Fl_Input(90, 35, 100, 20, "Horizontal:");
{ Fl_Input* o = horizontal_input = new Fl_Input(90, 35, 40, 20, "Horizontal:");
o->type(2);
o->box(FL_THIN_DOWN_BOX);
o->callback((Fl_Callback*)alignment_cb, (void*)(1));
o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);
}
{ Fl_Input* o = vertical_input = new Fl_Input(90, 65, 100, 20, "Vertical:");
{ Fl_Input* o = vertical_input = new Fl_Input(90, 65, 40, 20, "Vertical:");
o->type(2);
o->box(FL_THIN_DOWN_BOX);
o->callback((Fl_Callback*)alignment_cb, (void*)(2));
o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);
}
{ Fl_Input* o = snap_input = new Fl_Input(90, 95, 100, 20, "Snap:");
{ Fl_Input* o = snap_input = new Fl_Input(90, 95, 40, 20, "Snap:");
o->type(2);
o->box(FL_THIN_DOWN_BOX);
o->callback((Fl_Callback*)alignment_cb, (void*)(3));
o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);
}
{ Fl_Button* o = new Fl_Button(140, 285, 60, 25, "Close");
{ Fl_Button* o = new Fl_Button(295, 305, 60, 25, "Close");
o->callback((Fl_Callback*)cb_Close);
}
{ Fl_Box* o = new Fl_Box(10, 145, 190, 130, "Output File Names:");
{ Fl_Box* o = new Fl_Box(10, 175, 345, 120, "Output File Names:");
o->box(FL_ENGRAVED_FRAME);
o->labelsize(12);
o->align(FL_ALIGN_TOP_LEFT);
}
{ Fl_Box* o = new Fl_Box(20, 155, 170, 30, "Use \"name.ext\" to set name or just \".ext\" to set only extension.");
{ Fl_Box* o = new Fl_Box(20, 185, 325, 15, "Use \"name.ext\" to set name or just \".ext\" to set only extension.");
o->labelsize(10);
o->align(132|FL_ALIGN_INSIDE);
}
{ Fl_Input* o = header_file_input = new Fl_Input(100, 185, 90, 20, "Header File:");
{ Fl_Input* o = header_file_input = new Fl_Input(100, 205, 245, 20, "Header File:");
o->box(FL_THIN_DOWN_BOX);
o->textfont(4);
o->callback((Fl_Callback*)header_input_cb, (void*)(1));
o->when(FL_WHEN_CHANGED);
}
{ Fl_Input* o = code_file_input = new Fl_Input(100, 215, 90, 20, "Code File:");
{ Fl_Input* o = code_file_input = new Fl_Input(100, 235, 245, 20, "Code File:");
o->box(FL_THIN_DOWN_BOX);
o->textfont(4);
o->callback((Fl_Callback*)code_input_cb, (void*)(1));
o->when(FL_WHEN_CHANGED);
}
{ Fl_Light_Button* o = include_H_from_C_button = new Fl_Light_Button(20, 245, 170, 20, "Include Header from Code");
{ Fl_Light_Button* o = include_H_from_C_button = new Fl_Light_Button(100, 265, 170, 20, "Include Header from Code");
o->value(1);
o->labelsize(12);
o->callback((Fl_Callback*)include_H_from_C_button_cb);
}
{ Fl_Box* o = new Fl_Box(150, 25, 205, 130, "Internationalization:");
o->box(FL_ENGRAVED_FRAME);
o->labelsize(12);
o->align(FL_ALIGN_TOP_LEFT);
}
{ Fl_Choice* o = i18n_type_chooser = new Fl_Choice(220, 35, 125, 20, "Use:");
o->box(FL_THIN_UP_BOX);
o->callback((Fl_Callback*)i18n_type_cb);
o->menu(menu_i18n_type_chooser);
}
{ Fl_Input* o = i18n_include_input = new Fl_Input(220, 65, 125, 20, "#include:");
o->box(FL_THIN_DOWN_BOX);
o->textfont(4);
o->callback((Fl_Callback*)i18n_text_cb);
o->hide();
}
{ Fl_Input* o = i18n_file_input = new Fl_Input(220, 95, 125, 20, "File:");
o->box(FL_THIN_DOWN_BOX);
o->textfont(4);
o->callback((Fl_Callback*)i18n_text_cb);
o->hide();
}
{ Fl_Input* o = i18n_set_input = new Fl_Input(220, 125, 125, 20, "Set:");
o->type(2);
o->box(FL_THIN_DOWN_BOX);
o->textfont(4);
o->callback((Fl_Callback*)i18n_text_cb);
o->hide();
}
{ Fl_Input* o = i18n_function_input = new Fl_Input(220, 95, 125, 20, "Function:");
o->box(FL_THIN_DOWN_BOX);
o->textfont(4);
o->callback((Fl_Callback*)i18n_text_cb);
o->hide();
}
o->set_modal();
o->end();
}
return w;
}
extern void i18n_cb(Fl_Choice *,void *);

68
fluid/alignment_panel.fl

@ -8,63 +8,107 @@ snap 3 @@ -8,63 +8,107 @@ snap 3
Function {make_alignment_window()} {open
} {
Fl_Window alignment_window {
label Preferences open selected
xywh {658 262 210 320} modal visible
label Preferences open
xywh {473 284 365 340} hide modal
} {
Fl_Box {} {
label {Alignment:}
xywh {10 25 190 100} box ENGRAVED_FRAME labelsize 12 align 5
xywh {10 25 130 130} box ENGRAVED_FRAME labelsize 12 align 5
}
Fl_Input horizontal_input {
label {Horizontal:}
user_data 1 user_data_type long
callback alignment_cb
xywh {90 35 100 20} type Int box THIN_DOWN_BOX
xywh {90 35 40 20} type Int box THIN_DOWN_BOX
code0 {o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);}
}
Fl_Input vertical_input {
label {Vertical:}
user_data 2 user_data_type long
callback alignment_cb
xywh {90 65 100 20} type Int box THIN_DOWN_BOX
xywh {90 65 40 20} type Int box THIN_DOWN_BOX
code0 {o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);}
}
Fl_Input snap_input {
label {Snap:}
user_data 3 user_data_type long
callback alignment_cb
xywh {90 95 100 20} type Int box THIN_DOWN_BOX
xywh {90 95 40 20} type Int box THIN_DOWN_BOX
code0 {o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);}
}
Fl_Button {} {
label Close
callback {alignment_window->hide();}
xywh {140 285 60 25}
xywh {295 305 60 25}
}
Fl_Box {} {
label {Output File Names:}
xywh {10 145 190 130} box ENGRAVED_FRAME labelsize 12 align 5
xywh {10 175 345 120} box ENGRAVED_FRAME labelsize 12 align 5
}
Fl_Box {} {
label {Use "name.ext" to set name or just ".ext" to set only extension.}
xywh {20 155 170 30} labelsize 10 align 148
xywh {20 185 325 15} labelsize 10 align 148
}
Fl_Input header_file_input {
label {Header File:}
user_data 1 user_data_type {void*}
callback header_input_cb
xywh {100 185 90 20} box THIN_DOWN_BOX when 1
xywh {100 205 245 20} box THIN_DOWN_BOX when 1 textfont 4
}
Fl_Input code_file_input {
label {Code File:}
user_data 1 user_data_type {void*}
callback code_input_cb
xywh {100 215 90 20} box THIN_DOWN_BOX when 1
xywh {100 235 245 20} box THIN_DOWN_BOX when 1 textfont 4
}
Fl_Light_Button include_H_from_C_button {
label {Include Header from Code}
callback include_H_from_C_button_cb
xywh {20 245 170 20} value 1 labelsize 12
xywh {100 265 170 20} value 1 labelsize 12
}
Fl_Box {} {
label {Internationalization:}
xywh {150 25 205 130} box ENGRAVED_FRAME labelsize 12 align 5
}
Fl_Choice i18n_type_chooser {
label {Use:}
callback i18n_type_cb open
xywh {220 35 125 20} box THIN_UP_BOX
} {
menuitem {} {
label None
xywh {0 0 100 20}
}
menuitem {} {
label {GNU gettext}
xywh {0 0 100 20}
}
menuitem {} {
label {POSIX catgets}
xywh {0 0 100 20}
}
}
Fl_Input i18n_include_input {
label {\#include:}
callback i18n_text_cb selected
xywh {220 65 125 20} box THIN_DOWN_BOX textfont 4 hide
}
Fl_Input i18n_file_input {
label {File:}
callback i18n_text_cb
xywh {220 95 125 20} box THIN_DOWN_BOX textfont 4 hide
}
Fl_Input i18n_set_input {
label {Set:}
callback i18n_text_cb
xywh {220 125 125 20} type Int box THIN_DOWN_BOX textfont 4 hide
}
Fl_Input i18n_function_input {
label {Function:}
callback i18n_text_cb
xywh {220 95 125 20} box THIN_DOWN_BOX textfont 4 hide
}
}
}
decl {extern void i18n_cb(Fl_Choice *,void *);} {}

9
fluid/alignment_panel.h

@ -19,5 +19,14 @@ extern Fl_Input *code_file_input; @@ -19,5 +19,14 @@ extern Fl_Input *code_file_input;
#include <FL/Fl_Light_Button.H>
extern void include_H_from_C_button_cb(Fl_Light_Button*, void*);
extern Fl_Light_Button *include_H_from_C_button;
#include <FL/Fl_Choice.H>
extern void i18n_type_cb(Fl_Choice*, void*);
extern Fl_Choice *i18n_type_chooser;
extern void i18n_text_cb(Fl_Input*, void*);
extern Fl_Input *i18n_include_input;
extern Fl_Input *i18n_file_input;
extern Fl_Input *i18n_set_input;
extern Fl_Input *i18n_function_input;
Fl_Window* make_alignment_window();
extern Fl_Menu_Item menu_i18n_type_chooser[];
#endif

91
fluid/code.cxx

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
//
// "$Id: code.cxx,v 1.9.2.3 2000/02/25 03:44:21 mike Exp $"
// "$Id: code.cxx,v 1.9.2.4 2000/04/24 18:22:50 mike Exp $"
//
// Code output routines for the Fast Light Tool Kit (FLTK).
//
@ -35,6 +35,12 @@ @@ -35,6 +35,12 @@
static FILE *code_file;
static FILE *header_file;
int msgnum;
extern int i18n_type;
extern const char* i18n_include;
extern const char* i18n_function;
extern const char* i18n_file;
extern const char* i18n_set;
// return true if c can be in a C identifier. I needed this so
// it is not messed up by locale settings:
@ -279,9 +285,18 @@ int write_code(const char *s, const char *t) { @@ -279,9 +285,18 @@ int write_code(const char *s, const char *t) {
}
write_declare("#include <FL/Fl.H>");
if (i18n_type && i18n_include_input->value()[0]) {
if (i18n_include_input->value()[0] != '<' &&
i18n_include_input->value()[0] != '\"')
write_c("#include \"%s\"\n", i18n_include_input->value());
else
write_c("#include %s\n", i18n_include_input->value());
if (i18n_type == 2)
write_c("extern nl_catd %s;\n", i18n_file_input->value());
}
if (t && include_H_from_C)
write_c("#include \"%s\"\n", filename_name(t));
msgnum = 1;
for (Fl_Type* p = Fl_Type::first; p;) {
// write all static data for this & all children first
p->write_static();
@ -302,6 +317,76 @@ int write_code(const char *s, const char *t) { @@ -302,6 +317,76 @@ int write_code(const char *s, const char *t) {
return x >= 0 && y >= 0;
}
int write_strings(const char *sfile) {
FILE *fp = fopen(sfile, "w");
Fl_Type *p;
if (!fp) return 1;
switch (i18n_type) {
case 0 : /* None, just put static text out */
fprintf(fp, "# generated by Fast Light User Interface Designer (fluid) version %.4f\n",
FL_VERSION);
for (p = Fl_Type::first; p; p = p->next) {
if (p->is_widget() && p->label() && !((Fl_Widget_Type *)p)->image) {
for (const char *s = p->label(); *s; s ++)
if (*s < 32 || *s > 126 || *s == '\"')
fprintf(fp, "\\%03o", *s);
else
putc(*s, fp);
putc('\n', fp);
}
}
break;
case 1 : /* GNU gettext, put a .po file out */
fprintf(fp, "# generated by Fast Light User Interface Designer (fluid) version %.4f\n",
FL_VERSION);
for (p = Fl_Type::first; p; p = p->next) {
if (p->is_widget() && p->label() && !((Fl_Widget_Type *)p)->image) {
const char *s;
fputs("msgid \"", fp);
for (s = p->label(); *s; s ++)
if (*s < 32 || *s > 126 || *s == '\"')
fprintf(fp, "\\%03o", *s);
else
putc(*s, fp);
fputs("\"\n", fp);
fputs("msgstr \"", fp);
for (s = p->label(); *s; s ++)
if (*s < 32 || *s > 126 || *s == '\"')
fprintf(fp, "\\%03o", *s);
else
putc(*s, fp);
fputs("\"\n", fp);
}
}
break;
case 2 : /* POSIX catgets, put a .msg file out */
msgnum = 1;
fprintf(fp, "$ generated by Fast Light User Interface Designer (fluid) version %.4f\n",
FL_VERSION);
fprintf(fp, "$set %s\n", i18n_set_input->value());
fputs("$quote \"\n", fp);
for (p = Fl_Type::first; p; p = p->next) {
if (p->is_widget() && p->label() && !((Fl_Widget_Type *)p)->image) {
fprintf(fp, "%d \"", msgnum ++);
for (const char *s = p->label(); *s; s ++)
if (*s < 32 || *s > 126 || *s == '\"')
fprintf(fp, "\\%03o", *s);
else
putc(*s, fp);
fputs("\"\n", fp);
}
}
break;
}
return fclose(fp);
}
////////////////////////////////////////////////////////////////
void Fl_Type::write_static() {}
@ -312,5 +397,5 @@ void Fl_Type::write_code1() { @@ -312,5 +397,5 @@ void Fl_Type::write_code1() {
void Fl_Type::write_code2() {}
//
// End of "$Id: code.cxx,v 1.9.2.3 2000/02/25 03:44:21 mike Exp $".
// End of "$Id: code.cxx,v 1.9.2.4 2000/04/24 18:22:50 mike Exp $".
//

55
fluid/file.cxx

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
//
// "$Id: file.cxx,v 1.7.2.1 2000/02/25 03:44:22 mike Exp $"
// "$Id: file.cxx,v 1.7.2.2 2000/04/24 18:22:50 mike Exp $"
//
// Fluid file routines for the Fast Light Tool Kit (FLTK).
//
@ -305,6 +305,11 @@ const char *read_word(int wantbrace) { @@ -305,6 +305,11 @@ const char *read_word(int wantbrace) {
// global int variables:
extern int gridx, gridy, snap;
extern int i18n_type;
extern const char* i18n_include;
extern const char* i18n_function;
extern const char* i18n_file;
extern const char* i18n_set;
static struct {const char* name; int* value;} inttable[] = {
{"gridx", &gridx},
{"gridy", &gridy},
@ -323,6 +328,19 @@ int write_file(const char *filename, int selected_only) { @@ -323,6 +328,19 @@ int write_file(const char *filename, int selected_only) {
"version %.4f",FL_VERSION);
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 */
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);
@ -390,11 +408,40 @@ static void read_children(Fl_Type *p, int paste) { @@ -390,11 +408,40 @@ static void read_children(Fl_Type *p, int paste) {
continue;
}
if (!strcmp(c,"do_not_include_H_from_C"))
{
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();
@ -592,5 +639,5 @@ void read_fdesign() { @@ -592,5 +639,5 @@ void read_fdesign() {
}
//
// End of "$Id: file.cxx,v 1.7.2.1 2000/02/25 03:44:22 mike Exp $".
// End of "$Id: file.cxx,v 1.7.2.2 2000/04/24 18:22:50 mike Exp $".
//

33
fluid/fluid.cxx

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
//
// "$Id: fluid.cxx,v 1.15.2.3 2000/04/04 17:57:01 bill Exp $"
// "$Id: fluid.cxx,v 1.15.2.4 2000/04/24 18:22:50 mike Exp $"
//
// FLUID main entry for the Fast Light Tool Kit (FLTK).
//
@ -163,6 +163,11 @@ int header_file_set = 0; @@ -163,6 +163,11 @@ int header_file_set = 0;
int code_file_set = 0;
const char* header_file_name = ".h";
const char* code_file_name = ".cxx";
int i18n_type = 0;
const char* i18n_include = "";
const char* i18n_function = "";
const char* i18n_file = "";
const char* i18n_set = "";
void write_cb(Fl_Widget *, void *) {
if (!filename) {
@ -198,6 +203,29 @@ void write_cb(Fl_Widget *, void *) { @@ -198,6 +203,29 @@ void write_cb(Fl_Widget *, void *) {
}
}
void write_strings_cb(Fl_Widget *, void *) {
static char *exts[] = { ".txt", ".po", ".msg" };
if (!filename) {
save_cb(0,0);
if (!filename) return;
}
char sname[1024];
strcpy(sname,filename_name(filename));
filename_setext(sname, exts[i18n_type]);
if (!compile_only) goto_source_dir();
int x = write_strings(sname);
if (!compile_only) leave_source_dir();
if (compile_only) {
if (x) {fprintf(stderr,"%s : %s\n",sname,strerror(errno)); exit(1);}
} else {
if (x) {
fl_message("Can't write %s: %s", sname, strerror(errno));
} else {
fl_message("Wrote %s", sname);
}
}
}
void openwidget_cb(Fl_Widget *, void *) {
if (!Fl_Type::current) {
fl_message("Please select a widget");
@ -297,6 +325,7 @@ Fl_Menu_Item Main_Menu[] = { @@ -297,6 +325,7 @@ Fl_Menu_Item Main_Menu[] = {
{"Save As...", FL_ALT+'S', save_cb, (void*)1},
{"Merge...", FL_ALT+'i', open_cb, (void*)1, FL_MENU_DIVIDER},
{"Write code", FL_ALT+'C', write_cb, 0},
{"Write strings", FL_ALT+'W', write_strings_cb, 0},
{"Quit", FL_ALT+'q', exit_cb},
{0},
{"&Edit",0,0,0,FL_SUBMENU},
@ -428,5 +457,5 @@ int main(int argc,char **argv) { @@ -428,5 +457,5 @@ int main(int argc,char **argv) {
}
//
// End of "$Id: fluid.cxx,v 1.15.2.3 2000/04/04 17:57:01 bill Exp $".
// End of "$Id: fluid.cxx,v 1.15.2.4 2000/04/24 18:22:50 mike Exp $".
//

Loading…
Cancel
Save