summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2024-12-27 20:56:02 -0500
committerMatthias Melcher <github@matthiasm.com>2024-12-27 20:56:10 -0500
commit050cbabdfe2fdbd1337736f017456012e2437b2d (patch)
tree21efed95ef5368e67a7a6377ab0a3a2f936e4426
parent2100655a1b55d1c77932b649b758f2eab1107fcb (diff)
Fluid: Rename Stratgy constants to comply with CMP.
Capitalized constants. Added flag to indicate creation by user or file. Removed global variable 'reading_file'.
-rw-r--r--fluid/Fl_Function_Type.cxx41
-rw-r--r--fluid/Fl_Group_Type.cxx4
-rw-r--r--fluid/Fl_Menu_Type.cxx11
-rw-r--r--fluid/Fl_Type.cxx11
-rw-r--r--fluid/Fl_Type.h32
-rw-r--r--fluid/Fl_Widget_Type.cxx10
-rw-r--r--fluid/Fl_Window_Type.cxx14
-rw-r--r--fluid/autodoc.cxx20
-rw-r--r--fluid/custom_widgets.cxx2
-rw-r--r--fluid/factory.cxx10
-rw-r--r--fluid/file.cxx21
-rw-r--r--fluid/file.h4
-rw-r--r--fluid/fluid.cxx13
-rw-r--r--fluid/fluid.h2
-rw-r--r--fluid/function_panel.cxx4
-rw-r--r--fluid/function_panel.fl5
16 files changed, 114 insertions, 90 deletions
diff --git a/fluid/Fl_Function_Type.cxx b/fluid/Fl_Function_Type.cxx
index f490c9e11..935cd6405 100644
--- a/fluid/Fl_Function_Type.cxx
+++ b/fluid/Fl_Function_Type.cxx
@@ -202,15 +202,16 @@ Fl_Function_Type::~Fl_Function_Type() {
/**
Create a new function for the widget tree.
- \param[in] strategy new function add after current or as last child
+ \param[in] strategy add new function after current or as last child
\return the new node
*/
Fl_Type *Fl_Function_Type::make(Strategy strategy) {
Fl_Type *anchor = Fl_Type::current, *p = anchor;
- if (p && (strategy == kAddAfterCurrent)) p = p->parent;
+ if (p && (strategy.placement() == Strategy::AFTER_CURRENT))
+ p = p->parent;
while (p && !p->is_decl_block()) {
anchor = p;
- strategy = kAddAfterCurrent;
+ strategy.placement(Strategy::AFTER_CURRENT);
p = p->parent;
}
Fl_Function_Type *o = new Fl_Function_Type();
@@ -596,10 +597,11 @@ Fl_Code_Type::Fl_Code_Type() :
*/
Fl_Type *Fl_Code_Type::make(Strategy strategy) {
Fl_Type *anchor = Fl_Type::current, *p = anchor;
- if (p && (strategy == kAddAfterCurrent)) p = p->parent;
+ if (p && (strategy.placement() == Strategy::AFTER_CURRENT))
+ p = p->parent;
while (p && !p->is_code_block()) {
anchor = p;
- strategy = kAddAfterCurrent;
+ strategy.placement(Strategy::AFTER_CURRENT);
p = p->parent;
}
if (!p) {
@@ -763,10 +765,11 @@ Fl_CodeBlock_Type::~Fl_CodeBlock_Type() {
*/
Fl_Type *Fl_CodeBlock_Type::make(Strategy strategy) {
Fl_Type *anchor = Fl_Type::current, *p = anchor;
- if (p && (strategy == kAddAfterCurrent)) p = p->parent;
+ if (p && (strategy.placement() == Strategy::AFTER_CURRENT))
+ p = p->parent;
while (p && !p->is_code_block()) {
anchor = p;
- strategy = kAddAfterCurrent;
+ strategy.placement(Strategy::AFTER_CURRENT);
p = p->parent;
}
if (!p) {
@@ -904,10 +907,11 @@ int Fl_Decl_Type::is_public() const
*/
Fl_Type *Fl_Decl_Type::make(Strategy strategy) {
Fl_Type *anchor = Fl_Type::current, *p = anchor;
- if (p && (strategy == kAddAfterCurrent)) p = p->parent;
+ if (p && (strategy.placement() == Strategy::AFTER_CURRENT))
+ p = p->parent;
while (p && !p->is_decl_block()) {
anchor = p;
- strategy = kAddAfterCurrent;
+ strategy.placement(Strategy::AFTER_CURRENT);
p = p->parent;
}
Fl_Decl_Type *o = new Fl_Decl_Type();
@@ -1131,10 +1135,11 @@ Fl_Data_Type::~Fl_Data_Type() {
*/
Fl_Type *Fl_Data_Type::make(Strategy strategy) {
Fl_Type *anchor = Fl_Type::current, *p = anchor;
- if (p && (strategy == kAddAfterCurrent)) p = p->parent;
+ if (p && (strategy.placement() == Strategy::AFTER_CURRENT))
+ p = p->parent;
while (p && !p->is_decl_block()) {
anchor = p;
- strategy = kAddAfterCurrent;
+ strategy.placement(Strategy::AFTER_CURRENT);
p = p->parent;
}
Fl_Data_Type *o = new Fl_Data_Type();
@@ -1474,10 +1479,10 @@ int Fl_DeclBlock_Type::is_public() const {
*/
Fl_Type *Fl_DeclBlock_Type::make(Strategy strategy) {
Fl_Type *anchor = Fl_Type::current, *p = anchor;
- if (p && (strategy == kAddAfterCurrent)) p = p->parent;
+ if (p && (strategy.placement() == Strategy::AFTER_CURRENT)) p = p->parent;
while (p && !p->is_decl_block()) {
anchor = p;
- strategy = kAddAfterCurrent;
+ strategy.placement(Strategy::AFTER_CURRENT);
p = p->parent;
}
Fl_DeclBlock_Type *o = new Fl_DeclBlock_Type();
@@ -1706,10 +1711,11 @@ Fl_Comment_Type::Fl_Comment_Type() :
*/
Fl_Type *Fl_Comment_Type::make(Strategy strategy) {
Fl_Type *anchor = Fl_Type::current, *p = anchor;
- if (p && (strategy == kAddAfterCurrent)) p = p->parent;
+ if (p && (strategy.placement() == Strategy::AFTER_CURRENT))
+ p = p->parent;
while (p && !p->is_code_block()) {
anchor = p;
- strategy = kAddAfterCurrent;
+ strategy.placement(Strategy::AFTER_CURRENT);
p = p->parent;
}
Fl_Comment_Type *o = new Fl_Comment_Type();
@@ -1985,10 +1991,11 @@ void Fl_Class_Type::prefix(const char*p) {
*/
Fl_Type *Fl_Class_Type::make(Strategy strategy) {
Fl_Type *anchor = Fl_Type::current, *p = anchor;
- if (p && (strategy == kAddAfterCurrent)) p = p->parent;
+ if (p && (strategy.placement() == Strategy::AFTER_CURRENT))
+ p = p->parent;
while (p && !p->is_decl_block()) {
anchor = p;
- strategy = kAddAfterCurrent;
+ strategy.placement(Strategy::AFTER_CURRENT);
p = p->parent;
}
Fl_Class_Type *o = new Fl_Class_Type();
diff --git a/fluid/Fl_Group_Type.cxx b/fluid/Fl_Group_Type.cxx
index bac04a462..d3ec98fce 100644
--- a/fluid/Fl_Group_Type.cxx
+++ b/fluid/Fl_Group_Type.cxx
@@ -117,7 +117,7 @@ void group_cb(Fl_Widget *, void *) {
undo_checkpoint();
undo_suspend();
Fl_Type::current = qq;
- Fl_Group_Type *n = (Fl_Group_Type*)(Fl_Group_type.make(kAddAsLastChild));
+ Fl_Group_Type *n = (Fl_Group_Type*)(Fl_Group_type.make(Strategy::AS_LAST_CHILD));
n->move_before(q);
n->o->resize(q->o->x(),q->o->y(),q->o->w(),q->o->h());
for (Fl_Type *t = qq->next; t && (t->level > qq->level);) {
@@ -126,7 +126,7 @@ void group_cb(Fl_Widget *, void *) {
continue;
}
Fl_Type *nxt = t->remove();
- t->add(n, kAddAsLastChild);
+ t->add(n, Strategy::AS_LAST_CHILD);
t = nxt;
}
fix_group_size(n);
diff --git a/fluid/Fl_Menu_Type.cxx b/fluid/Fl_Menu_Type.cxx
index 23a7868fb..35670766b 100644
--- a/fluid/Fl_Menu_Type.cxx
+++ b/fluid/Fl_Menu_Type.cxx
@@ -162,10 +162,11 @@ Fl_Type *Fl_Menu_Item_Type::make(Strategy strategy) {
Fl_Type* Fl_Menu_Item_Type::make(int flags, Strategy strategy) {
// Find a good insert position based on the current marked node
Fl_Type *anchor = Fl_Type::current, *p = anchor;
- if (p && (strategy == kAddAfterCurrent)) p = p->parent;
+ if (p && (strategy.placement() == Strategy::AFTER_CURRENT))
+ p = p->parent;
while (p && !(p->is_a(ID_Menu_Manager_) || p->is_a(ID_Submenu))) {
anchor = p;
- strategy = kAddAfterCurrent;
+ strategy.placement(Strategy::AFTER_CURRENT);
p = p->parent;
}
if (!p) {
@@ -186,7 +187,7 @@ Fl_Type* Fl_Menu_Item_Type::make(int flags, Strategy strategy) {
t->o->type(flags);
t->factory = this;
t->add(anchor, strategy);
- if (!reading_file) {
+ if (strategy.source() == Strategy::FROM_USER) {
if (flags==FL_SUBMENU) {
t->label("submenu");
} else {
@@ -209,14 +210,14 @@ void group_selected_menuitems() {
}
undo_checkpoint();
undo_suspend();
- Fl_Widget_Type *n = (Fl_Widget_Type*)(q->make(FL_SUBMENU, kAddAfterCurrent));
+ Fl_Widget_Type *n = (Fl_Widget_Type*)(q->make(FL_SUBMENU, Strategy::AFTER_CURRENT));
for (Fl_Type *t = qq->next; t && (t->level > qq->level);) {
if (t->level != n->level || t == n || !t->selected) {
t = t->next;
continue;
}
Fl_Type *nxt = t->remove();
- t->add(n, kAddAsLastChild);
+ t->add(n, Strategy::AS_LAST_CHILD);
t = nxt;
}
widget_browser->rebuild();
diff --git a/fluid/Fl_Type.cxx b/fluid/Fl_Type.cxx
index 071caaff4..444047cd8 100644
--- a/fluid/Fl_Type.cxx
+++ b/fluid/Fl_Type.cxx
@@ -619,7 +619,7 @@ Fl_Group_Type *Fl_Type::group() {
This methods updates the widget_browser.
\param[in] p insert \c this tree as a child of \c p
- \param[in] strategy is kAddAsLastChild or kAddAfterCurrent
+ \param[in] strategy is Strategy::AS_LAST_CHILD or Strategy::AFTER_CURRENT
*/
void Fl_Type::add(Fl_Type *anchor, Strategy strategy) {
#if 0
@@ -637,8 +637,9 @@ void Fl_Type::add(Fl_Type *anchor, Strategy strategy) {
int target_level = 0; // adjust self to this new level
// Find the node after our insertion position
- switch (strategy) {
- case kAddAsFirstChild:
+ switch (strategy.placement()) {
+ case Strategy::AS_FIRST_CHILD:
+ default:
if (anchor == NULL) {
target = Fl_Type::first;
} else {
@@ -647,7 +648,7 @@ void Fl_Type::add(Fl_Type *anchor, Strategy strategy) {
target_parent = anchor;
}
break;
- case kAddAsLastChild:
+ case Strategy::AS_LAST_CHILD:
if (anchor == NULL) {
/* empty */
} else {
@@ -656,7 +657,7 @@ void Fl_Type::add(Fl_Type *anchor, Strategy strategy) {
target_parent = anchor;
}
break;
- case kAddAfterCurrent:
+ case Strategy::AFTER_CURRENT:
if (anchor == NULL) {
target = Fl_Type::first;
} else {
diff --git a/fluid/Fl_Type.h b/fluid/Fl_Type.h
index f38508e16..50f4b34b1 100644
--- a/fluid/Fl_Type.h
+++ b/fluid/Fl_Type.h
@@ -30,9 +30,14 @@ class Fd_Project_Reader;
class Fd_Project_Writer;
/**
- Declare where a new type is placed in the hierarchy.
+ Declare where a new type is placed and how to create it.
- Note that a type can also be the start of a hierarchy of types. In that case,
+ Placement can be as the first or last child of the anchor, or right after the
+ anchor. In most cases, the anchor is the last selected type node.
+
+ If the source is FROM_USER, widgets may be created with default titles and
+ labels. Type created FROM_FILE will start with no label, so the label is set
+ correctly later.
\see Fl_Type *Fl_..._Type::make(Strategy strategy) calls `add()`
Add single Type:
@@ -45,10 +50,25 @@ class Fd_Project_Writer;
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 {
- kAddAsFirstChild = 0,
- kAddAsLastChild,
- kAddAfterCurrent
+typedef struct Strategy {
+ enum Flags {
+ AS_FIRST_CHILD = 0x0000,
+ AS_LAST_CHILD = 0x0001,
+ AFTER_CURRENT = 0x0002,
+ PLACEMENT_MASK = 0x000f,
+ FROM_USER = 0x0000,
+ FROM_FILE = 0x0010,
+ SOURCE_MASK = 0x00f0,
+ FROM_FILE_AS_FIRST_CHILD = 0x0010,
+ FROM_FILE_AS_LAST_CHILD = 0x0011,
+ FROM_FILE_AFTER_CURRENT = 0x0012,
+ };
+ Flags flags;
+ Strategy(Flags f) { flags = f; }
+ void placement(Flags f) { flags = (Flags)((flags & ~PLACEMENT_MASK) | (f & PLACEMENT_MASK)); }
+ Flags placement() { return (Flags)(flags & PLACEMENT_MASK); }
+ void source(Flags f) { flags = (Flags)((flags & ~SOURCE_MASK) | (f & SOURCE_MASK)); }
+ Flags source() { return (Flags)(flags & SOURCE_MASK); }
} Strategy;
enum ID {
diff --git a/fluid/Fl_Widget_Type.cxx b/fluid/Fl_Widget_Type.cxx
index 4048933bc..b92ef53cc 100644
--- a/fluid/Fl_Widget_Type.cxx
+++ b/fluid/Fl_Widget_Type.cxx
@@ -83,15 +83,16 @@ Fl_Widget_Type::ideal_size(int &w, int &h) {
/**
Make a new Widget node.
- \param[in] strategy is kAddAsLastChild or kAddAfterCurrent
+ \param[in] strategy is Strategy::AS_LAST_CHILD or Strategy::AFTER_CURRENT
\return new node
*/
Fl_Type *Fl_Widget_Type::make(Strategy strategy) {
Fl_Type *anchor = Fl_Type::current, *pp = anchor;
- if (pp && (strategy == kAddAfterCurrent)) pp = pp->parent;
+ if (pp && (strategy.placement() == Strategy::AFTER_CURRENT))
+ pp = pp->parent;
while (pp && !pp->is_a(ID_Group)) {
anchor = pp;
- strategy = kAddAfterCurrent;
+ strategy.placement(Strategy::AFTER_CURRENT);
pp = pp->parent;
}
if (!pp || !pp->is_true_widget() || !anchor->is_true_widget()) {
@@ -141,7 +142,8 @@ Fl_Type *Fl_Widget_Type::make(Strategy strategy) {
t->factory = this;
// Construct the Fl_Widget:
t->o = widget(X,Y,W,H);
- if (reading_file) t->o->label(0);
+ if (strategy.source() == Strategy::FROM_FILE)
+ t->o->label(0);
else if (t->o->label()) t->label(t->o->label()); // allow editing
t->o->user_data((void*)t);
// Put it in the parent:
diff --git a/fluid/Fl_Window_Type.cxx b/fluid/Fl_Window_Type.cxx
index 878d802db..de58fb762 100644
--- a/fluid/Fl_Window_Type.cxx
+++ b/fluid/Fl_Window_Type.cxx
@@ -223,15 +223,15 @@ int Overlay_Window::handle(int e) {
/**
Make and add a new Window node.
- \param[in] strategy is kAddAsLastChild or kAddAfterCurrent
+ \param[in] strategy is Strategy::AS_LAST_CHILD or Strategy::AFTER_CURRENT
\return new node
*/
Fl_Type *Fl_Window_Type::make(Strategy strategy) {
Fl_Type *anchor = Fl_Type::current, *p = anchor;
- if (p && (strategy == kAddAfterCurrent)) p = p->parent;
+ if (p && (strategy.placement() == Strategy::AFTER_CURRENT)) p = p->parent;
while (p && (!p->is_code_block() || p->is_a(ID_Widget_Class))) {
anchor = p;
- strategy = kAddAfterCurrent;
+ strategy.placement(Strategy::AFTER_CURRENT);
p = p->parent;
}
if (!p) {
@@ -1073,10 +1073,10 @@ int Fl_Window_Type::handle(int event) {
{
Fl_Type *cc = Fl_Type::current;
Fl_Type::current = Fl_Type::current_dnd;
- add_new_widget_from_user(prototype, kAddAsLastChild);
+ add_new_widget_from_user(prototype, Strategy::AS_LAST_CHILD);
Fl_Type::current = cc;
} else {
- add_new_widget_from_user(prototype, kAddAsLastChild);
+ add_new_widget_from_user(prototype, Strategy::AS_LAST_CHILD);
}
popupx = 0x7FFFFFFF;
popupy = 0x7FFFFFFF; // mark as invalid (MAXINT)
@@ -1376,10 +1376,10 @@ Fl_Widget_Class_Type *current_widget_class = 0;
*/
Fl_Type *Fl_Widget_Class_Type::make(Strategy strategy) {
Fl_Type *anchor = Fl_Type::current, *p = anchor;
- if (p && (strategy == kAddAfterCurrent)) p = p->parent;
+ if (p && (strategy.placement() == Strategy::AFTER_CURRENT)) p = p->parent;
while (p && (!p->is_decl_block() || (p->is_widget() && p->is_class()))) {
anchor = p;
- strategy = kAddAfterCurrent;
+ strategy.placement(Strategy::AFTER_CURRENT);
p = p->parent;
}
Fl_Widget_Class_Type *myo = new Fl_Widget_Class_Type();
diff --git a/fluid/autodoc.cxx b/fluid/autodoc.cxx
index c656cbb78..ef022790b 100644
--- a/fluid/autodoc.cxx
+++ b/fluid/autodoc.cxx
@@ -383,22 +383,22 @@ void run_autodoc(const Fl_String &target_dir) {
// Create a silly project that contains all widgets that we want to document
new_project(false);
- /*Fl_Type *t_func = */ add_new_widget_from_user("Function", kAddAsLastChild, false);
- Fl_Window_Type *t_win = (Fl_Window_Type*)add_new_widget_from_user("Fl_Window", kAddAsLastChild, false);
+ /*Fl_Type *t_func = */ add_new_widget_from_user("Function", Strategy::AS_LAST_CHILD, false);
+ Fl_Window_Type *t_win = (Fl_Window_Type*)add_new_widget_from_user("Fl_Window", Strategy::AS_LAST_CHILD, false);
t_win->label("My Main Window");
- Fl_Widget_Type *t_grp = (Fl_Widget_Type*)add_new_widget_from_user("Fl_Group", kAddAsLastChild, false);
+ Fl_Widget_Type *t_grp = (Fl_Widget_Type*)add_new_widget_from_user("Fl_Group", Strategy::AS_LAST_CHILD, false);
t_grp->public_ = 0;
- Fl_Widget_Type *t_btn = (Fl_Widget_Type*)add_new_widget_from_user("Fl_Button", kAddAsLastChild, false);
+ Fl_Widget_Type *t_btn = (Fl_Widget_Type*)add_new_widget_from_user("Fl_Button", Strategy::AS_LAST_CHILD, false);
t_btn->comment("Don't press this button!");
t_btn->name("emergency_btn");
((Fl_Button*)t_btn->o)->shortcut(FL_COMMAND|'g');
- Fl_Type *t_sldr = add_new_widget_from_user("Fl_Slider", kAddAsLastChild, false);
- Fl_Type *t_inp = add_new_widget_from_user("Fl_Input", kAddAsLastChild, false);
- Fl_Type *t_flx = add_new_widget_from_user("Fl_Flex", kAddAsLastChild, false);
- Fl_Type *t_flxc = add_new_widget_from_user("Fl_Button", kAddAsLastChild, false);
+ Fl_Type *t_sldr = add_new_widget_from_user("Fl_Slider", Strategy::AS_LAST_CHILD, false);
+ Fl_Type *t_inp = add_new_widget_from_user("Fl_Input", Strategy::AS_LAST_CHILD, false);
+ Fl_Type *t_flx = add_new_widget_from_user("Fl_Flex", Strategy::AS_LAST_CHILD, false);
+ Fl_Type *t_flxc = add_new_widget_from_user("Fl_Button", Strategy::AS_LAST_CHILD, false);
select_only(t_grp);
- Fl_Type *t_grd = add_new_widget_from_user("Fl_Grid", kAddAsLastChild, false);
- Fl_Type *t_grdc = add_new_widget_from_user("Fl_Button", kAddAsLastChild, false);
+ Fl_Type *t_grd = add_new_widget_from_user("Fl_Grid", Strategy::AS_LAST_CHILD, false);
+ Fl_Type *t_grdc = add_new_widget_from_user("Fl_Button", Strategy::AS_LAST_CHILD, false);
widget_browser->rebuild();
g_project.update_settings_dialog();
diff --git a/fluid/custom_widgets.cxx b/fluid/custom_widgets.cxx
index 887e2ba14..b50169f3a 100644
--- a/fluid/custom_widgets.cxx
+++ b/fluid/custom_widgets.cxx
@@ -110,7 +110,7 @@ int Widget_Bin_Window_Button::handle(int inEvent)
// create a new window here
Fl_Type *prototype = typename_to_prototype((char*)user_data());
if (prototype) {
- Fl_Type *new_type = add_new_widget_from_user(prototype, kAddAfterCurrent);
+ Fl_Type *new_type = add_new_widget_from_user(prototype, Strategy::AFTER_CURRENT);
if (new_type && new_type->is_a(ID_Window)) {
Fl_Window_Type *new_window = (Fl_Window_Type*)new_type;
Fl_Window *w = (Fl_Window *)new_window->o;
diff --git a/fluid/factory.cxx b/fluid/factory.cxx
index 61eb3479c..a96a1ec45 100644
--- a/fluid/factory.cxx
+++ b/fluid/factory.cxx
@@ -1355,9 +1355,9 @@ Fl_Type *add_new_widget_from_user(const char *inName, Strategy strategy, bool an
static void cbf(Fl_Widget *, void *v) {
Fl_Type *t = NULL;
if (Fl_Type::current && Fl_Type::current->can_have_children())
- t = ((Fl_Type*)v)->make(kAddAsLastChild);
+ t = ((Fl_Type*)v)->make(Strategy::AS_LAST_CHILD);
else
- t = ((Fl_Type*)v)->make(kAddAfterCurrent);
+ t = ((Fl_Type*)v)->make(Strategy::AFTER_CURRENT);
select_only(t);
}
@@ -1370,9 +1370,9 @@ static void cbf(Fl_Widget *, void *v) {
static void cb(Fl_Widget *, void *v) {
Fl_Type *t = NULL;
if (Fl_Type::current && Fl_Type::current->can_have_children())
- t = add_new_widget_from_user((Fl_Type*)v, kAddAsLastChild);
+ t = add_new_widget_from_user((Fl_Type*)v, Strategy::AS_LAST_CHILD);
else
- t = add_new_widget_from_user((Fl_Type*)v, kAddAfterCurrent);
+ t = add_new_widget_from_user((Fl_Type*)v, Strategy::AFTER_CURRENT);
select_only(t);
}
@@ -1546,9 +1546,7 @@ Fl_Type *add_new_widget_from_file(const char *inName, Strategy strategy) {
Fl_Type *prototype = typename_to_prototype(inName);
if (!prototype)
return NULL;
- reading_file = 1; // makes labels be null
Fl_Type *new_node = prototype->make(strategy);
- reading_file = 0;
return new_node;
}
diff --git a/fluid/file.cxx b/fluid/file.cxx
index cdbf10d62..9f5b78c39 100644
--- a/fluid/file.cxx
+++ b/fluid/file.cxx
@@ -63,6 +63,7 @@ int fdesign_flip = 0;
*/
int read_file(const char *filename, int merge, Strategy strategy) {
Fd_Project_Reader f;
+ strategy.source(Strategy::FROM_FILE);
return f.read_project(filename, merge, strategy);
}
@@ -260,7 +261,7 @@ Fl_Type *Fd_Project_Reader::read_children(Fl_Type *p, int merge, Strategy strate
// back compatibility with Vincent Penne's original class code:
if (!p && !strcmp(c,"define_in_struct")) {
- Fl_Type *t = add_new_widget_from_file("class", kAddAsLastChild);
+ Fl_Type *t = add_new_widget_from_file("class", Strategy::FROM_FILE_AS_LAST_CHILD);
t->name(read_word());
Fl_Type::current = p = t;
merge = 1; // stops "missing }" error
@@ -390,7 +391,7 @@ Fl_Type *Fd_Project_Reader::read_children(Fl_Type *p, int merge, Strategy strate
read_error("Missing child list for %s\n",t->title());
goto REUSE_C;
}
- read_children(t, 0, kAddAsLastChild, skip_options);
+ read_children(t, 0, Strategy::FROM_FILE_AS_LAST_CHILD, skip_options);
t->postprocess_read();
// FIXME: this has no business in the file reader!
// TODO: this is called whenever something is pasted from the top level into a grid
@@ -406,10 +407,10 @@ Fl_Type *Fd_Project_Reader::read_children(Fl_Type *p, int merge, Strategy strate
t->layout_widget();
}
- if (strategy == kAddAsFirstChild) {
- strategy = kAddAfterCurrent;
+ if (strategy.placement() == Strategy::AS_FIRST_CHILD) {
+ strategy.placement(Strategy::AFTER_CURRENT);
}
- if (strategy == kAddAfterCurrent) {
+ if (strategy.placement() == Strategy::AFTER_CURRENT) {
Fl_Type::current = t;
} else {
Fl_Type::current = p;
@@ -733,7 +734,7 @@ void Fd_Project_Reader::read_fdesign() {
Fl_Widget_Type *group = 0;
Fl_Widget_Type *widget = 0;
if (!Fl_Type::current) {
- Fl_Type *t = add_new_widget_from_file("Function", kAddAsLastChild);
+ Fl_Type *t = add_new_widget_from_file("Function", Strategy::FROM_FILE_AS_LAST_CHILD);
t->name("create_the_forms()");
Fl_Type::current = t;
}
@@ -744,7 +745,7 @@ void Fd_Project_Reader::read_fdesign() {
if (!strcmp(name,"Name")) {
- window = (Fl_Widget_Type*)add_new_widget_from_file("Fl_Window", kAddAsLastChild);
+ window = (Fl_Widget_Type*)add_new_widget_from_file("Fl_Window", Strategy::FROM_FILE_AS_LAST_CHILD);
window->name(value);
window->label(value);
Fl_Type::current = widget = window;
@@ -752,7 +753,7 @@ void Fd_Project_Reader::read_fdesign() {
} else if (!strcmp(name,"class")) {
if (!strcmp(value,"FL_BEGIN_GROUP")) {
- group = widget = (Fl_Widget_Type*)add_new_widget_from_file("Fl_Group", kAddAsLastChild);
+ group = widget = (Fl_Widget_Type*)add_new_widget_from_file("Fl_Group", Strategy::FROM_FILE_AS_LAST_CHILD);
Fl_Type::current = group;
} else if (!strcmp(value,"FL_END_GROUP")) {
if (group) {
@@ -767,10 +768,10 @@ void Fd_Project_Reader::read_fdesign() {
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*)add_new_widget_from_file(value, kAddAsLastChild);
+ widget = (Fl_Widget_Type*)add_new_widget_from_file(value, Strategy::FROM_FILE_AS_LAST_CHILD);
if (!widget) {
printf("class %s not found, using Fl_Button\n", value);
- widget = (Fl_Widget_Type*)add_new_widget_from_file("Fl_Button", kAddAsLastChild);
+ widget = (Fl_Widget_Type*)add_new_widget_from_file("Fl_Button", Strategy::FROM_FILE_AS_LAST_CHILD);
}
}
diff --git a/fluid/file.h b/fluid/file.h
index 71ee543a4..4000c2b02 100644
--- a/fluid/file.h
+++ b/fluid/file.h
@@ -25,7 +25,7 @@ class Fl_Type;
extern int fdesign_flip;
-int read_file(const char *, int merge, Strategy strategy=kAddAsLastChild);
+int read_file(const char *, int merge, Strategy strategy=Strategy::FROM_FILE_AS_LAST_CHILD);
int write_file(const char *, int selected_only = 0, bool to_codeview = false);
class Fd_Project_Reader
@@ -58,7 +58,7 @@ public:
const char *filename_name();
int read_quoted();
Fl_Type *read_children(Fl_Type *p, int merge, Strategy strategy, char skip_options=0);
- int read_project(const char *, int merge, Strategy strategy=kAddAsLastChild);
+ int read_project(const char *, int merge, Strategy strategy=Strategy::FROM_FILE_AS_LAST_CHILD);
void read_error(const char *format, ...);
const char *read_word(int wantbrace = 0);
int read_int();
diff --git a/fluid/fluid.cxx b/fluid/fluid.cxx
index 1bf7dc161..5d738190e 100644
--- a/fluid/fluid.cxx
+++ b/fluid/fluid.cxx
@@ -106,11 +106,6 @@ int G_debug = 0;
char G_external_editor_command[512];
-/// This is set to create different labels when creating new widgets.
-/// \todo Details unclear.
-int reading_file = 0;
-
-
// File history info...
/// Stores the absolute filename of the last 10 design files, saved in app preferences.
@@ -1418,14 +1413,14 @@ void paste_cb(Fl_Widget*, void*) {
pasteoffset = ipasteoffset;
undo_checkpoint();
undo_suspend();
- Strategy strategy = kAddAfterCurrent;
+ Strategy strategy = Strategy::FROM_FILE_AFTER_CURRENT;
if (Fl_Type::current && Fl_Type::current->can_have_children()) {
if (Fl_Type::current->folded_ == 0) {
// If the current widget is a group widget and it is not folded,
// add the new widgets inside the group.
- strategy = kAddAsLastChild;
+ strategy = Strategy::FROM_FILE_AS_LAST_CHILD;
// The following alternative also works quite nicely
- //strategy = kAddAsFirstChild;
+ //strategy = Strategy::FROM_FILE_AS_FIRST_CHILD;
}
}
if (!read_file(cutfname(), 1, strategy)) {
@@ -1479,7 +1474,7 @@ void duplicate_cb(Fl_Widget*, void*) {
pasteoffset = 0;
undo_checkpoint();
undo_suspend();
- if (!read_file(cutfname(1), 1, kAddAfterCurrent)) {
+ if (!read_file(cutfname(1), 1, Strategy::FROM_FILE_AFTER_CURRENT)) {
fl_message("Can't read %s: %s", cutfname(1), strerror(errno));
}
fl_unlink(cutfname(1));
diff --git a/fluid/fluid.h b/fluid/fluid.h
index 2f92a6e11..7ed488a4a 100644
--- a/fluid/fluid.h
+++ b/fluid/fluid.h
@@ -65,8 +65,6 @@ extern int G_use_external_editor;
extern int G_debug;
extern char G_external_editor_command[512];
-extern int reading_file;
-
// File history info...
extern char absolute_history[10][FL_PATH_MAX];
extern char relative_history[10][FL_PATH_MAX];
diff --git a/fluid/function_panel.cxx b/fluid/function_panel.cxx
index 6147d59f0..af46301a1 100644
--- a/fluid/function_panel.cxx
+++ b/fluid/function_panel.cxx
@@ -766,9 +766,9 @@ Fl_Double_Window* make_comment_panel() {
void type_make_cb(Fl_Widget*,void*d) {
const char *type_name = (const char*)d;
if (Fl_Type::current && Fl_Type::current->can_have_children())
- add_new_widget_from_user(type_name, kAddAsLastChild);
+ add_new_widget_from_user(type_name, Strategy::AS_LAST_CHILD);
else
- add_new_widget_from_user(type_name, kAddAfterCurrent);
+ add_new_widget_from_user(type_name, Strategy::AFTER_CURRENT);
}
Fl_Window *widgetbin_panel=(Fl_Window *)0;
diff --git a/fluid/function_panel.fl b/fluid/function_panel.fl
index aa2ac91ae..bd25f3821 100644
--- a/fluid/function_panel.fl
+++ b/fluid/function_panel.fl
@@ -589,9 +589,10 @@ Function {type_make_cb(Fl_Widget*,void*d)} {open return_type void
} {
code {const char *type_name = (const char*)d;
if (Fl_Type::current && Fl_Type::current->can_have_children())
- add_new_widget_from_user(type_name, kAddAsLastChild);
+ add_new_widget_from_user(type_name, Strategy::AS_LAST_CHILD);
else
- add_new_widget_from_user(type_name, kAddAfterCurrent);} {}
+ add_new_widget_from_user(type_name, Strategy::AFTER_CURRENT);} {selected
+ }
}
Function {make_widgetbin()} {open