FLUID: Eliminating two globals
This commit is contained in:
parent
5cc9845f2f
commit
0ac0ec2aa3
@ -54,9 +54,6 @@ Fl_Menu_Item menu_item_type_menu[] = {
|
|||||||
{"Radio",0,0,(void*)FL_MENU_RADIO},
|
{"Radio",0,0,(void*)FL_MENU_RADIO},
|
||||||
{0}};
|
{0}};
|
||||||
|
|
||||||
static char submenuflag;
|
|
||||||
static uchar menuitemtype = 0;
|
|
||||||
|
|
||||||
static void delete_dependents(Fl_Menu_Item *m) {
|
static void delete_dependents(Fl_Menu_Item *m) {
|
||||||
if (!m)
|
if (!m)
|
||||||
return;
|
return;
|
||||||
@ -153,6 +150,16 @@ void Fl_Input_Choice_Type::build_menu() {
|
|||||||
\return new Menu Item node
|
\return new Menu Item node
|
||||||
*/
|
*/
|
||||||
Fl_Type *Fl_Menu_Item_Type::make(Strategy strategy) {
|
Fl_Type *Fl_Menu_Item_Type::make(Strategy strategy) {
|
||||||
|
return make(0, strategy);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Create an add a specific Menu Item node.
|
||||||
|
\param[in] flags set to 0, FL_MENU_RADIO, FL_MENU_TOGGLE, or FL_SUBMENU
|
||||||
|
\param[in] strategy add after current or as last child
|
||||||
|
\return new Menu Item node
|
||||||
|
*/
|
||||||
|
Fl_Type* Fl_Menu_Item_Type::make(int flags, Strategy strategy) {
|
||||||
// Find the current menu item:
|
// Find the current menu item:
|
||||||
Fl_Type* q = Fl_Type::current;
|
Fl_Type* q = Fl_Type::current;
|
||||||
Fl_Type* p = q;
|
Fl_Type* p = q;
|
||||||
@ -168,28 +175,40 @@ Fl_Type *Fl_Menu_Item_Type::make(Strategy strategy) {
|
|||||||
o = new Fl_Button(0,0,100,20); // create template widget
|
o = new Fl_Button(0,0,100,20); // create template widget
|
||||||
}
|
}
|
||||||
|
|
||||||
Fl_Menu_Item_Type* t = submenuflag ? new Fl_Submenu_Type() : new Fl_Menu_Item_Type();
|
Fl_Menu_Item_Type* t = NULL;
|
||||||
|
if (flags==FL_SUBMENU) {
|
||||||
|
t = new Fl_Submenu_Type();
|
||||||
|
} else {
|
||||||
|
t = new Fl_Menu_Item_Type();
|
||||||
|
}
|
||||||
t->o = new Fl_Button(0,0,100,20);
|
t->o = new Fl_Button(0,0,100,20);
|
||||||
t->o->type(menuitemtype);
|
t->o->type(flags);
|
||||||
t->factory = this;
|
t->factory = this;
|
||||||
t->add(p, strategy);
|
t->add(p, strategy);
|
||||||
if (!reading_file) t->label(submenuflag ? "submenu" : "item");
|
if (!reading_file) {
|
||||||
|
if (flags==FL_SUBMENU) {
|
||||||
|
t->label("submenu");
|
||||||
|
} else {
|
||||||
|
t->label("item");
|
||||||
|
}
|
||||||
|
}
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
void group_selected_menuitems() {
|
void group_selected_menuitems() {
|
||||||
// The group will be created in the parent group of the current menuitem
|
// The group will be created in the parent group of the current menuitem
|
||||||
|
if (!Fl_Type::current->is_a(ID_Menu_Item)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Fl_Menu_Item_Type *q = static_cast<Fl_Menu_Item_Type*>(Fl_Type::current);
|
||||||
Fl_Type *qq = Fl_Type::current->parent;
|
Fl_Type *qq = Fl_Type::current->parent;
|
||||||
Fl_Widget_Type *q = static_cast<Fl_Widget_Type*>(Fl_Type::current);
|
|
||||||
if (!qq || !(qq->is_a(ID_Menu_Manager_) || qq->is_a(ID_Submenu))) {
|
if (!qq || !(qq->is_a(ID_Menu_Manager_) || qq->is_a(ID_Submenu))) {
|
||||||
fl_message("Can't create a new group here.");
|
fl_message("Can't create a new submenu here.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
undo_checkpoint();
|
undo_checkpoint();
|
||||||
undo_suspend();
|
undo_suspend();
|
||||||
submenuflag = 1;
|
Fl_Widget_Type *n = (Fl_Widget_Type*)(q->make(FL_SUBMENU, kAddAfterCurrent));
|
||||||
Fl_Widget_Type *n = (Fl_Widget_Type*)(q->make(kAddAfterCurrent));
|
|
||||||
submenuflag = 0;
|
|
||||||
for (Fl_Type *t = qq->next; t && (t->level > qq->level);) {
|
for (Fl_Type *t = qq->next; t && (t->level > qq->level);) {
|
||||||
if (t->level != n->level || t == n || !t->selected) {
|
if (t->level != n->level || t == n || !t->selected) {
|
||||||
t = t->next;
|
t = t->next;
|
||||||
@ -242,10 +261,7 @@ void ungroup_selected_menuitems() {
|
|||||||
\return new node
|
\return new node
|
||||||
*/
|
*/
|
||||||
Fl_Type *Fl_Checkbox_Menu_Item_Type::make(Strategy strategy) {
|
Fl_Type *Fl_Checkbox_Menu_Item_Type::make(Strategy strategy) {
|
||||||
menuitemtype = FL_MENU_TOGGLE;
|
return Fl_Menu_Item_Type::make(FL_MENU_TOGGLE, strategy);
|
||||||
Fl_Type* t = Fl_Menu_Item_Type::make(strategy);
|
|
||||||
menuitemtype = 0;
|
|
||||||
return t;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -254,10 +270,7 @@ Fl_Type *Fl_Checkbox_Menu_Item_Type::make(Strategy strategy) {
|
|||||||
\return new node
|
\return new node
|
||||||
*/
|
*/
|
||||||
Fl_Type *Fl_Radio_Menu_Item_Type::make(Strategy strategy) {
|
Fl_Type *Fl_Radio_Menu_Item_Type::make(Strategy strategy) {
|
||||||
menuitemtype = FL_MENU_RADIO;
|
return Fl_Menu_Item_Type::make(FL_MENU_RADIO, strategy);
|
||||||
Fl_Type* t = Fl_Menu_Item_Type::make(strategy);
|
|
||||||
menuitemtype = 0;
|
|
||||||
return t;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -266,9 +279,7 @@ Fl_Type *Fl_Radio_Menu_Item_Type::make(Strategy strategy) {
|
|||||||
\return new node
|
\return new node
|
||||||
*/
|
*/
|
||||||
Fl_Type *Fl_Submenu_Type::make(Strategy strategy) {
|
Fl_Type *Fl_Submenu_Type::make(Strategy strategy) {
|
||||||
submenuflag = 1;
|
Fl_Type* t = Fl_Menu_Item_Type::make(FL_SUBMENU, strategy);
|
||||||
Fl_Type* t = Fl_Menu_Item_Type::make(strategy);
|
|
||||||
submenuflag = 0;
|
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@ public:
|
|||||||
const char* type_name() FL_OVERRIDE {return "MenuItem";}
|
const char* type_name() FL_OVERRIDE {return "MenuItem";}
|
||||||
const char* alt_type_name() FL_OVERRIDE {return "fltk::Item";}
|
const char* alt_type_name() FL_OVERRIDE {return "fltk::Item";}
|
||||||
Fl_Type* make(Strategy strategy) FL_OVERRIDE;
|
Fl_Type* make(Strategy strategy) FL_OVERRIDE;
|
||||||
|
Fl_Type* make(int flags, Strategy strategy);
|
||||||
int is_button() const FL_OVERRIDE {return 1;} // this gets shortcut to work
|
int is_button() const FL_OVERRIDE {return 1;} // this gets shortcut to work
|
||||||
Fl_Widget* widget(int,int,int,int) FL_OVERRIDE {return 0;}
|
Fl_Widget* widget(int,int,int,int) FL_OVERRIDE {return 0;}
|
||||||
Fl_Widget_Type* _make() FL_OVERRIDE {return 0;}
|
Fl_Widget_Type* _make() FL_OVERRIDE {return 0;}
|
||||||
|
@ -29,6 +29,22 @@ class Fl_Window_Type;
|
|||||||
class Fd_Project_Reader;
|
class Fd_Project_Reader;
|
||||||
class Fd_Project_Writer;
|
class Fd_Project_Writer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Declare where a new type is placed in the hierarchy.
|
||||||
|
|
||||||
|
Note that a type can also be the start of a hierarchy of types. In that case,
|
||||||
|
|
||||||
|
\see Fl_Type *Fl_..._Type::make(Strategy strategy) calls `add()`
|
||||||
|
Add single Type:
|
||||||
|
Fl_Type *add_new_widget_from_user(Fl_Type *inPrototype, Strategy strategy, bool and_open)
|
||||||
|
Fl_Type *add_new_widget_from_user(const char *inName, Strategy strategy, bool and_open)
|
||||||
|
Fl_Type *add_new_widget_from_file(const char *inName, Strategy strategy)
|
||||||
|
Add a hierarchy of Types
|
||||||
|
void Fl_Type::add(Fl_Type *p, Strategy strategy)
|
||||||
|
int read_file(const char *filename, int merge, Strategy strategy)
|
||||||
|
Fl_Type *Fd_Project_Reader::read_children(Fl_Type *p, int merge, Strategy strategy, char skip_options)
|
||||||
|
int Fd_Project_Reader::read_project(const char *filename, int merge, Strategy strategy)
|
||||||
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
kAddAsLastChild = 0,
|
kAddAsLastChild = 0,
|
||||||
kAddAfterCurrent
|
kAddAfterCurrent
|
||||||
|
Loading…
Reference in New Issue
Block a user