mirror of
https://github.com/fltk/fltk.git
synced 2026-06-06 00:22:42 +08:00
Add support to FLUID for widget class creation without the intermediate
class stuff. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4197 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
@@ -2,6 +2,7 @@ CHANGES IN FLTK 1.1.7
|
|||||||
|
|
||||||
- Documentation fixes (STR #648, STR #692, STR #730, STR
|
- Documentation fixes (STR #648, STR #692, STR #730, STR
|
||||||
#744, STR #745)
|
#744, STR #745)
|
||||||
|
- FLUID now supports direct creation of widget classes.
|
||||||
- Fl_File_Chooser now correctly handles multiple
|
- Fl_File_Chooser now correctly handles multiple
|
||||||
selections that are a mix of files and directories.
|
selections that are a mix of files and directories.
|
||||||
- Fl_File_Chooser no longer resets the type() when
|
- Fl_File_Chooser no longer resets the type() when
|
||||||
|
|||||||
@@ -969,11 +969,14 @@ void Fl_Class_Type::open() {
|
|||||||
Fl_Class_Type Fl_Class_type;
|
Fl_Class_Type Fl_Class_type;
|
||||||
|
|
||||||
static Fl_Class_Type *current_class;
|
static Fl_Class_Type *current_class;
|
||||||
|
extern Fl_Widget_Class_Type *current_widget_class;
|
||||||
extern int varused_test;
|
extern int varused_test;
|
||||||
void write_public(int state) {
|
void write_public(int state) {
|
||||||
if (!current_class || varused_test) return;
|
if ((!current_class && !current_widget_class) || varused_test) return;
|
||||||
if (current_class->write_public_state == state) return;
|
if (current_class && current_class->write_public_state == state) return;
|
||||||
current_class->write_public_state = state;
|
if (current_widget_class && current_widget_class->write_public_state == state) return;
|
||||||
|
if (current_class) current_class->write_public_state = state;
|
||||||
|
if (current_widget_class) current_widget_class->write_public_state = state;
|
||||||
write_h(state ? "public:\n" : "private:\n");
|
write_h(state ? "public:\n" : "private:\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -490,6 +490,9 @@ public:
|
|||||||
|
|
||||||
class Fl_Widget_Class_Type : private Fl_Window_Type {
|
class Fl_Widget_Class_Type : private Fl_Window_Type {
|
||||||
public:
|
public:
|
||||||
|
// state variables for output:
|
||||||
|
char write_public_state; // true when public: has been printed
|
||||||
|
|
||||||
void write_code1();
|
void write_code1();
|
||||||
void write_code2();
|
void write_code2();
|
||||||
Fl_Type *make();
|
Fl_Type *make();
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ const char* subclassname(Fl_Type* l) {
|
|||||||
Fl_Widget_Type* p = (Fl_Widget_Type*)l;
|
Fl_Widget_Type* p = (Fl_Widget_Type*)l;
|
||||||
const char* c = p->subclass();
|
const char* c = p->subclass();
|
||||||
if (c) return c;
|
if (c) return c;
|
||||||
|
if (l->is_class()) return "Fl_Group";
|
||||||
if (p->o->type() == FL_WINDOW+1) return "Fl_Double_Window";
|
if (p->o->type() == FL_WINDOW+1) return "Fl_Double_Window";
|
||||||
}
|
}
|
||||||
return l->type_name();
|
return l->type_name();
|
||||||
@@ -1454,7 +1455,7 @@ void Fl_Widget_Type::write_static() {
|
|||||||
user_data_type() ? user_data_type() : "void*");
|
user_data_type() ? user_data_type() : "void*");
|
||||||
const char* c = array_name(this);
|
const char* c = array_name(this);
|
||||||
const char* k = class_name(1);
|
const char* k = class_name(1);
|
||||||
if (c && !k) {
|
if (c && !k && !is_class()) {
|
||||||
write_c("\n");
|
write_c("\n");
|
||||||
if (!public_) write_c("static ");
|
if (!public_) write_c("static ");
|
||||||
else write_h("extern %s *%s;\n", t, c);
|
else write_h("extern %s *%s;\n", t, c);
|
||||||
|
|||||||
@@ -1291,6 +1291,7 @@ int Fl_Window_Type::read_fdesign(const char* propname, const char* value) {
|
|||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
Fl_Widget_Class_Type Fl_Widget_Class_type;
|
Fl_Widget_Class_Type Fl_Widget_Class_type;
|
||||||
|
Fl_Widget_Class_Type *current_widget_class = 0;
|
||||||
|
|
||||||
Fl_Type *Fl_Widget_Class_Type::make() {
|
Fl_Type *Fl_Widget_Class_Type::make() {
|
||||||
Fl_Type *p = Fl_Type::current;
|
Fl_Type *p = Fl_Type::current;
|
||||||
@@ -1322,23 +1323,68 @@ Fl_Type *Fl_Widget_Class_Type::make() {
|
|||||||
|
|
||||||
|
|
||||||
void Fl_Widget_Class_Type::write_code1() {
|
void Fl_Widget_Class_Type::write_code1() {
|
||||||
|
#if 0
|
||||||
Fl_Widget_Type::write_code1();
|
Fl_Widget_Type::write_code1();
|
||||||
|
#endif // 0
|
||||||
|
|
||||||
|
current_widget_class = this;
|
||||||
|
write_public_state = 1;
|
||||||
|
|
||||||
|
const char *c = subclass();
|
||||||
|
if (!c) c = "Fl_Group";
|
||||||
|
|
||||||
|
write_h("\nclass %s : public %s {\n", name(), c);
|
||||||
|
if (!strcmp(c, "Fl_Window") ||
|
||||||
|
!strcmp(c, "Fl_Double_Window") ||
|
||||||
|
!strcmp(c, "Fl_Gl_Window") ||
|
||||||
|
!strcmp(c, "Fl_Overlay_Window")) {
|
||||||
|
write_h(" void _%s();\n", name());
|
||||||
|
write_h("public:\n");
|
||||||
|
write_h(" %s(int X, int Y, int W, int H, const char *L = 0);\n", name());
|
||||||
|
write_h(" %s(int W, int H, const char *L = 0);\n");
|
||||||
|
|
||||||
|
write_c("%s::%s(int X, int Y, int W, int H, const char *L)\n", name(), name());
|
||||||
|
write_c(" : %s(X, Y, W, H, L) {\n", c);
|
||||||
|
write_c(" _%s();\n", name());
|
||||||
|
write_c("}\n\n");
|
||||||
|
|
||||||
|
write_c("%s::%s(int W, int H, const char *L)\n", name(), name());
|
||||||
|
write_c(" : %s(0, 0, W, H, L) {\n", c);
|
||||||
|
write_c(" clear_flag(FL_FORCE_POSITION);\n");
|
||||||
|
write_c(" _%s();\n", name());
|
||||||
|
write_c("}\n\n");
|
||||||
|
|
||||||
|
write_c("void %s::_%s() {\n", name(), name());
|
||||||
|
write_c(" %s *w = this;\n", name());
|
||||||
|
} else {
|
||||||
|
write_h("public:\n");
|
||||||
|
write_h(" %s(int X, int Y, int W, int H, const char *L = 0);\n", name());
|
||||||
|
|
||||||
|
write_c("%s::%s(int X, int Y, int W, int H, const char *L)\n", name(), name());
|
||||||
|
write_c(" : %s(X, Y, W, H, L) {\n", c);
|
||||||
|
}
|
||||||
|
|
||||||
|
write_c(" %s *o = this;\n", name());
|
||||||
|
|
||||||
|
write_widget_code();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fl_Widget_Class_Type::write_code2() {
|
void Fl_Widget_Class_Type::write_code2() {
|
||||||
write_extra_code();
|
write_extra_code();
|
||||||
if (modal) write_c("%so->set_modal();\n", indent());
|
if (modal) write_c("%sset_modal();\n", indent());
|
||||||
else if (non_modal) write_c("%so->set_non_modal();\n", indent());
|
else if (non_modal) write_c("%sset_non_modal();\n", indent());
|
||||||
if (!((Fl_Window*)o)->border()) write_c("%so->clear_border();\n", indent());
|
if (!((Fl_Window*)o)->border()) write_c("%sclear_border();\n", indent());
|
||||||
if (xclass) {
|
if (xclass) {
|
||||||
write_c("%so->xclass(", indent());
|
write_c("%sxclass(", indent());
|
||||||
write_cstring(xclass);
|
write_cstring(xclass);
|
||||||
write_c(");\n");
|
write_c(");\n");
|
||||||
}
|
}
|
||||||
write_c("%so->end();\n", indent());
|
write_c("%send();\n", indent());
|
||||||
if (((Fl_Window*)o)->resizable() == o)
|
if (((Fl_Window*)o)->resizable() == o)
|
||||||
write_c("%so->resizable(o);\n", indent());
|
write_c("%sresizable(this);\n", indent());
|
||||||
write_block_close();
|
write_c("}\n");
|
||||||
|
|
||||||
|
write_h("};\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user