From b4995f979d127cea667b4e2b71c91e9db4ab52ef Mon Sep 17 00:00:00 2001 From: maxim nikonov Date: Fri, 6 Feb 2026 18:12:40 +0500 Subject: wip --- fluid/app/Snap_Action.cxx | 351 +++++++++++++++++--------------- fluid/app/templates.cxx | 3 - fluid/io/Code_Writer.cxx | 66 +++--- fluid/io/Project_Reader.cxx | 39 ++-- fluid/io/Project_Writer.cxx | 26 ++- fluid/io/String_Writer.cxx | 6 +- fluid/nodes/Function_Node.cxx | 3 - fluid/nodes/Grid_Node.cxx | 43 ++-- fluid/nodes/Group_Node.cxx | 39 ++-- fluid/nodes/Menu_Node.cxx | 19 +- fluid/nodes/Node.cxx | 47 +++-- fluid/nodes/Tree.cxx | 18 +- fluid/nodes/Widget_Node.cxx | 64 +++--- fluid/nodes/Window_Node.cxx | 57 ++++-- fluid/nodes/factory.cxx | 15 +- fluid/panels/settings_panel.cxx | 8 +- fluid/panels/widget_panel.cxx | 27 ++- fluid/proj/align_widget.cxx | 23 ++- fluid/proj/mergeback.cxx | 9 +- fluid/proj/undo.cxx | 34 ++-- fluid/tools/ExternalCodeEditor_UNIX.cxx | 2 - fluid/tools/autodoc.cxx | 24 ++- fluid/widgets/App_Menu_Bar.cxx | 8 +- fluid/widgets/Bin_Button.cxx | 4 +- fluid/widgets/Code_Editor.cxx | 23 ++- fluid/widgets/Code_Viewer.cxx | 8 +- fluid/widgets/Formula_Input.cxx | 27 +-- fluid/widgets/Node_Browser.cxx | 71 +++---- fluid/widgets/Style_Parser.cxx | 34 ++-- fluid/widgets/Text_Viewer.cxx | 10 +- 30 files changed, 600 insertions(+), 508 deletions(-) (limited to 'fluid') diff --git a/fluid/app/Snap_Action.cxx b/fluid/app/Snap_Action.cxx index f045d325f..39a328b24 100644 --- a/fluid/app/Snap_Action.cxx +++ b/fluid/app/Snap_Action.cxx @@ -39,19 +39,16 @@ #endif -using namespace fld; -using namespace fld::app; - // TODO: warning if the user wants to change builtin layouts // TODO: move panel to global settings panel (move load & save to main pulldown, or to toolbox?) // INFO: how about a small tool box for quick preset selection and disabling of individual snaps? void select_layout_suite_cb(Fl_Widget *, void *user_data); -int Snap_Action::eex = 0; -int Snap_Action::eey = 0; +int fld::app::Snap_Action::eex = 0; +int fld::app::Snap_Action::eey = 0; -static Layout_Preset fltk_app = { +static fld::app::Layout_Preset fltk_app = { 15, 15, 15, 15, 0, 0, // window: l, r, t, b, gx, gy 10, 10, 10, 10, 0, 0, // group: l, r, t, b, gx, gy 25, 25, // tabs: t, b @@ -59,7 +56,7 @@ static Layout_Preset fltk_app = { 20, 4, 8, // widget_y: min, inc, gap 0, 14, -1, 14 // labelfont/size, textfont/size }; -static Layout_Preset fltk_dlg = { +static fld::app::Layout_Preset fltk_dlg = { 10, 10, 10, 10, 0, 0, // window: l, r, t, b, gx, gy 10, 10, 10, 10, 0, 0, // group: l, r, t, b, gx, gy 20, 20, // tabs: t, b @@ -67,7 +64,7 @@ static Layout_Preset fltk_dlg = { 20, 5, 5, // widget_y: min, inc, gap 0, 11, -1, 11 // labelfont/size, textfont/size }; -static Layout_Preset fltk_tool = { +static fld::app::Layout_Preset fltk_tool = { 10, 10, 10, 10, 0, 0, // window: l, r, t, b, gx, gy 10, 10, 10, 10, 0, 0, // group: l, r, t, b, gx, gy 18, 18, // tabs: t, b @@ -76,7 +73,7 @@ static Layout_Preset fltk_tool = { 0, 10, -1, 10 // labelfont/size, textfont/size }; -static Layout_Preset grid_app = { +static fld::app::Layout_Preset grid_app = { 12, 12, 12, 12, 12, 12, // window: l, r, t, b, gx, gy 12, 12, 12, 12, 12, 12, // group: l, r, t, b, gx, gy 24, 24, // tabs: t, b @@ -85,7 +82,7 @@ static Layout_Preset grid_app = { 0, 14, -1, 14 // labelfont/size, textfont/size }; -static Layout_Preset grid_dlg = { +static fld::app::Layout_Preset grid_dlg = { 10, 10, 10, 10, 10, 10, // window: l, r, t, b, gx, gy 10, 10, 10, 10, 10, 10, // group: l, r, t, b, gx, gy 20, 20, // tabs: t, b @@ -94,7 +91,7 @@ static Layout_Preset grid_dlg = { 0, 12, -1, 12 // labelfont/size, textfont/size }; -static Layout_Preset grid_tool = { +static fld::app::Layout_Preset grid_tool = { 8, 8, 8, 8, 8, 8, // window: l, r, t, b, gx, gy 8, 8, 8, 8, 8, 8, // group: l, r, t, b, gx, gy 16, 16, // tabs: t, b @@ -103,9 +100,9 @@ static Layout_Preset grid_tool = { 0, 10, -1, 10 // labelfont/size, textfont/size }; -Layout_Preset *fld::app::default_layout_preset = &fltk_app; +fld::app::Layout_Preset *fld::app::default_layout_preset = &fltk_app; -static Layout_Suite static_suite_list[] = { +static fld::app::Layout_Suite static_suite_list[] = { { (char*)"FLTK", (char*)"@fd_beaker FLTK", { &fltk_app, &fltk_dlg, &fltk_tool }, FLD_TOOL_STORE_INTERNAL }, { (char*)"Grid", (char*)"@fd_beaker Grid", { &grid_app, &grid_dlg, &grid_tool }, FLD_TOOL_STORE_INTERNAL } }; @@ -157,12 +154,12 @@ void edit_layout_preset_cb(Fl_Button *w, void *user_data) { } } -// ---- Layout_Suite ------------------------------------------------ MARK: - +// ---- fld::app::Layout_Suite ------------------------------------------------ MARK: - /** Write presets to a Preferences database. */ -void Layout_Preset::write(Fl_Preferences &prefs) { +void fld::app::Layout_Preset::write(Fl_Preferences &prefs) { assert(this); Fl_Preferences p_win(prefs, "Window"); p_win.set("left_margin", left_window_margin); @@ -202,7 +199,7 @@ void Layout_Preset::write(Fl_Preferences &prefs) { /** Read presets from a Preferences database. */ -void Layout_Preset::read(Fl_Preferences &prefs) { +void fld::app::Layout_Preset::read(Fl_Preferences &prefs) { assert(this); Fl_Preferences p_win(prefs, "Window"); p_win.get("left_margin", left_window_margin, 15); @@ -242,7 +239,7 @@ void Layout_Preset::read(Fl_Preferences &prefs) { /** Write presets to an .fl project file. */ -void Layout_Preset::write(fld::io::Project_Writer *out) { +void fld::app::Layout_Preset::write(fld::io::Project_Writer *out) { out->write_string(" preset { 1\n"); // preset format version out->write_string(" %d %d %d %d %d %d\n", left_window_margin, right_window_margin, @@ -264,7 +261,7 @@ void Layout_Preset::write(fld::io::Project_Writer *out) { /** Read presets from an .fl project file. */ -void Layout_Preset::read(fld::io::Project_Reader *in) { +void fld::app::Layout_Preset::read(fld::io::Project_Reader *in) { const char *key; key = in->read_word(1); if (key && !strcmp(key, "{")) { @@ -320,7 +317,7 @@ void Layout_Preset::read(fld::io::Project_Reader *in) { /** Return the preferred text size, but make sure it's not 0. */ -int Layout_Preset::textsize_not_null() { +int fld::app::Layout_Preset::textsize_not_null() { // try the user selected text size if (textsize > 0) return textsize; // if the user did not set one, try the label size @@ -330,16 +327,17 @@ int Layout_Preset::textsize_not_null() { } -// ---- Layout_Suite ------------------------------------------------ MARK: - +// ---- fld::app::Layout_Suite ------------------------------------------------ MARK: - /** Write a presets suite to a Preferences database. */ -void Layout_Suite::write(Fl_Preferences &prefs) { +void fld::app::Layout_Suite::write(Fl_Preferences &prefs) { assert(this); assert(name_); prefs.set("name", name_); - for (int i = 0; i < 3; ++i) { + int i; + for (i = 0; i < 3; ++i) { Fl_Preferences prefs_preset(prefs, Fl_Preferences::Name(i)); assert(layout[i]); layout[i]->write(prefs_preset); @@ -349,9 +347,10 @@ void Layout_Suite::write(Fl_Preferences &prefs) { /** Read a presets suite from a Preferences database. */ -void Layout_Suite::read(Fl_Preferences &prefs) { +void fld::app::Layout_Suite::read(Fl_Preferences &prefs) { assert(this); - for (int i = 0; i < 3; ++i) { + int i; + for (i = 0; i < 3; ++i) { Fl_Preferences prefs_preset(prefs, Fl_Preferences::Name(i)); assert(layout[i]); layout[i]->read(prefs_preset); @@ -361,10 +360,11 @@ void Layout_Suite::read(Fl_Preferences &prefs) { /** Write a presets suite to an .fl project file. */ -void Layout_Suite::write(fld::io::Project_Writer *out) { +void fld::app::Layout_Suite::write(fld::io::Project_Writer *out) { out->write_string(" suite {\n"); out->write_string(" name "); out->write_word(name_); out->write_string("\n"); - for (int i = 0; i < 3; ++i) { + int i; + for (i = 0; i < 3; ++i) { layout[i]->write(out); } out->write_string(" }\n"); @@ -373,7 +373,7 @@ void Layout_Suite::write(fld::io::Project_Writer *out) { /** Read a presets suite from an .fl project file. */ -void Layout_Suite::read(fld::io::Project_Reader *in) { +void fld::app::Layout_Suite::read(fld::io::Project_Reader *in) { const char *key; key = in->read_word(1); if (key && !strcmp(key, "{")) { @@ -401,7 +401,7 @@ void Layout_Suite::read(fld::io::Project_Reader *in) { \brief Update the menu_label to show a symbol representing the storage location. Also updates the FLUID user interface. */ -void Layout_Suite::update_label() { +void fld::app::Layout_Suite::update_label() { const char *sym = ""; switch (storage_) { case FLD_TOOL_STORE_INTERNAL: sym = "@fd_beaker "; break; @@ -421,7 +421,7 @@ void Layout_Suite::update_label() { \brief Update the Suite name and the Suite menu_label. Also updates the FLUID user interface. */ -void Layout_Suite::name(const char *n) { +void fld::app::Layout_Suite::name(const char *n) { if (name_) ::free(name_); if (n) @@ -434,7 +434,7 @@ void Layout_Suite::name(const char *n) { /** Initialize the class for first use. */ -void Layout_Suite::init() { +void fld::app::Layout_Suite::init() { name_ = 0; menu_label = 0; layout[0] = layout[1] = layout[2] = 0; @@ -444,15 +444,16 @@ void Layout_Suite::init() { /** Free all allocated resources. */ -Layout_Suite::~Layout_Suite() { +fld::app::Layout_Suite::~Layout_Suite() { if (storage_ == FLD_TOOL_STORE_INTERNAL) return; if (name_) ::free(name_); - for (int i = 0; i < 3; ++i) { + int i; + for (i = 0; i < 3; ++i) { delete layout[i]; } } -// ---- Layout_List ------------------------------------------------- MARK: - +// ---- fld::app::Layout_List ------------------------------------------------- MARK: - /** Draw a little FLUID beaker symbol. @@ -595,7 +596,7 @@ void fd_file(Fl_Color c) { /** Instantiate the class that holds a list of all layouts and manages the UI. */ -Layout_List::Layout_List() +fld::app::Layout_List::Layout_List() : main_menu_(main_layout_submenu_), choice_menu_(static_choice_menu), list_(static_suite_list), @@ -614,15 +615,16 @@ Layout_List::Layout_List() /** Release allocated resources. */ -Layout_List::~Layout_List() { +fld::app::Layout_List::~Layout_List() { assert(this); if (!list_is_static_) { ::free(main_menu_); ::free(choice_menu_); - for (int i = 0; i < list_size_; i++) { - Layout_Suite &suite = list_[i]; + int i; + for (i = 0; i < list_size_; i++) { + fld::app::Layout_Suite &suite = list_[i]; if (suite.storage_ != FLD_TOOL_STORE_INTERNAL) - suite.~Layout_Suite(); + suite.fld::app::Layout_Suite::~Layout_Suite(); } ::free(list_); } @@ -631,7 +633,7 @@ Layout_List::~Layout_List() { /** Update the Setting dialog and menus to reflect the current Layout selection state. */ -void Layout_List::update_dialogs() { +void fld::app::Layout_List::update_dialogs() { static Fl_Menu_Item *preset_menu = 0; if (!preset_menu) { preset_menu = (Fl_Menu_Item*)Fluid.main_menubar->find_item(select_layout_preset_cb); @@ -655,8 +657,9 @@ void Layout_List::update_dialogs() { /** Refresh the label pointers for both pulldown menus. */ -void Layout_List::update_menu_labels() { - for (int i=0; iwrite_string("\nsnap {\n ver 1\n"); out->write_string(" current_suite "); out->write_word(list_[current_suite()].name_); out->write_string("\n"); out->write_string(" current_preset %d\n", current_preset()); - for (int i=0; iread_word(1); if (key && !strcmp(key, "{")) { @@ -793,7 +798,7 @@ void Layout_List::read(fld::io::Project_Reader *in) { Set the current Suite. \param[in] ix index into list of suites */ -void Layout_List::current_suite(int ix) { +void fld::app::Layout_List::current_suite(int ix) { assert(ix >= 0); assert(ix < list_size_); current_suite_ = ix; @@ -805,11 +810,11 @@ void Layout_List::current_suite(int ix) { \param[in] arg_name name of the selected suite \return if no name is given or the name is not found, keep the current suite selected */ -void Layout_List::current_suite(const char *arg_name) { +void fld::app::Layout_List::current_suite(const char *arg_name) { if (!arg_name || !arg_name[0]) return; int i; for (i = 0; i < list_size_; ++i) { - Layout_Suite &suite = list_[i]; + fld::app::Layout_Suite &suite = list_[i]; if (suite.name_ && (strcmp(suite.name_, arg_name) == 0)) { current_suite(i); break; @@ -821,7 +826,7 @@ void Layout_List::current_suite(const char *arg_name) { Select a Preset within the current Suite. \param[in] ix 0 = application, 1 = dialog, 2 = toolbox */ -void Layout_List::current_preset(int ix) { +void fld::app::Layout_List::current_preset(int ix) { assert(ix >= 0); assert(ix < 3); current_preset_ = ix; @@ -831,7 +836,7 @@ void Layout_List::current_preset(int ix) { /** Allocate enough space for n entries in the list. */ -void Layout_List::capacity(int n) { +void fld::app::Layout_List::capacity(int n) { static Fl_Menu_Item *suite_menu = 0; if (!suite_menu) suite_menu = (Fl_Menu_Item*)Fluid.main_menubar->find_item(layout_suite_marker); @@ -839,7 +844,7 @@ void Layout_List::capacity(int n) { int old_n = list_size_; int i; - Layout_Suite *new_list = (Layout_Suite*)::calloc(n, sizeof(Layout_Suite)); + fld::app::Layout_Suite *new_list = (fld::app::Layout_Suite*)::calloc(n, sizeof(fld::app::Layout_Suite)); for (i = 0; i < old_n; i++) new_list[i] = list_[i]; if (!list_is_static_) ::free(list_); @@ -867,18 +872,19 @@ void Layout_List::capacity(int n) { \brief Clone the currently selected suite and append it to the list. Selects the new layout and updates the UI. */ -int Layout_List::add(const char *name) { +int fld::app::Layout_List::add(const char *name) { if (list_size_ == list_capacity_) { capacity(list_capacity_ * 2); } int n = list_size_; - Layout_Suite &old_suite = list_[current_suite_]; - Layout_Suite &new_suite = list_[n]; + fld::app::Layout_Suite &old_suite = list_[current_suite_]; + fld::app::Layout_Suite &new_suite = list_[n]; new_suite.init(); new_suite.name(name); - for (int i=0; i<3; ++i) { - new_suite.layout[i] = new Layout_Preset; - ::memcpy(new_suite.layout[i], old_suite.layout[i], sizeof(Layout_Preset)); + int i; + for (i =0; i<3; ++i) { + new_suite.layout[i] = new fld::app::Layout_Preset; + ::memcpy(new_suite.layout[i], old_suite.layout[i], sizeof(fld::app::Layout_Preset)); } fld::Tool_Store new_storage = old_suite.storage_; if (new_storage == FLD_TOOL_STORE_INTERNAL) @@ -897,7 +903,7 @@ int Layout_List::add(const char *name) { /** Rename the current Suite. */ -void Layout_List::rename(const char *name) { +void fld::app::Layout_List::rename(const char *name) { int n = current_suite(); list_[n].name(name); main_menu_[n].label(list_[n].menu_label); @@ -908,10 +914,11 @@ void Layout_List::rename(const char *name) { Remove the given suite. \param[in] ix index into list of suites */ -void Layout_List::remove(int ix) { +void fld::app::Layout_List::remove(int ix) { int tail = list_size_-ix-1; if (tail) { - for (int i = ix; i < list_size_-1; i++) + int i; + for (i = ix; i < list_size_-1; i++) list_[i] = list_[i+1]; } ::memmove(main_menu_+ix, main_menu_+ix+1, (tail+1) * sizeof(Fl_Menu_Item)); @@ -925,8 +932,9 @@ void Layout_List::remove(int ix) { Remove all Suites that use the given storage attribute. \param[in] storage storage attribute, see FLD_TOOL_STORE_INTERNAL, etc. */ -void Layout_List::remove_all(fld::Tool_Store storage) { - for (int i=list_size_-1; i>=0; --i) { +void fld::app::Layout_List::remove_all(fld::Tool_Store storage) { + int i; + for (i =list_size_-1; i>=0; --i) { if (list_[i].storage_ == storage) remove(i); } @@ -951,19 +959,19 @@ static int nearest(int x, int left, int grid, int right=0x7fff) { return grid_x; } -static bool in_window(Snap_Data &d) { +static bool in_window(fld::app::Snap_Data &d) { return (d.wgt && d.wgt->parent == d.win); } -static bool in_group(Snap_Data &d) { +static bool in_group(fld::app::Snap_Data &d) { return (d.wgt && d.wgt->parent && d.wgt->parent->is_a(FLD_NODE_TYPE_Group) && d.wgt->parent != d.win); } -static bool in_tabs(Snap_Data &d) { +static bool in_tabs(fld::app::Snap_Data &d) { return (d.wgt && d.wgt->parent && d.wgt->parent->is_a(FLD_NODE_TYPE_Tabs)); } -static Fl_Group *parent(Snap_Data &d) { +static Fl_Group *parent(fld::app::Snap_Data &d) { return (d.wgt->o->parent()); } @@ -994,7 +1002,7 @@ static Fl_Group *parent(Snap_Data &d) { \return -1 if this point is closer than any previous check, and this is the new distance to beat. */ -int Snap_Action::check_x_(Snap_Data &d, int x_ref, int x_snap) { +int fld::app::Snap_Action::check_x_(fld::app::Snap_Data &d, int x_ref, int x_snap) { int dd = x_ref + d.dx - x_snap; int d2 = abs(dd); if (d2 > d.x_dist) return 1; @@ -1007,9 +1015,9 @@ int Snap_Action::check_x_(Snap_Data &d, int x_ref, int x_snap) { /** \brief Check if a snap action has reached a preferred y position. - \see Snap_Action::check_x_(Snap_Data &d, int x_ref, int x_snap) + \see fld::app::Snap_Action::check_x_(fld::app::Snap_Data &d, int x_ref, int x_snap) */ -int Snap_Action::check_y_(Snap_Data &d, int y_ref, int y_snap) { +int fld::app::Snap_Action::check_y_(fld::app::Snap_Data &d, int y_ref, int y_snap) { int dd = y_ref + d.dy - y_snap; int d2 = abs(dd); if (d2 > d.y_dist) return 1; @@ -1022,9 +1030,9 @@ int Snap_Action::check_y_(Snap_Data &d, int y_ref, int y_snap) { /** \brief Check if a snap action has reached a preferred x and y position. - \see Snap_Action::check_x_(Snap_Data &d, int x_ref, int x_snap) + \see fld::app::Snap_Action::check_x_(fld::app::Snap_Data &d, int x_ref, int x_snap) */ -void Snap_Action::check_x_y_(Snap_Data &d, int x_ref, int x_snap, int y_ref, int y_snap) { +void fld::app::Snap_Action::check_x_y_(fld::app::Snap_Data &d, int x_ref, int x_snap, int y_ref, int y_snap) { int ddx = x_ref + d.dx - x_snap; int d2x = abs(ddx); int ddy = y_ref + d.dy - y_snap; @@ -1045,7 +1053,7 @@ void Snap_Action::check_x_y_(Snap_Data &d, int x_ref, int x_snap, int y_ref, int should be drawn. \param[inout] d current event data */ -bool Snap_Action::matches(Snap_Data &d) { +bool fld::app::Snap_Action::matches(fld::app::Snap_Data &d) { switch (type) { case 1: return (d.drag & mask) && (eex == ex) && (d.dx == dx); case 2: return (d.drag & mask) && (eey == ey) && (d.dy == dy); @@ -1058,8 +1066,9 @@ bool Snap_Action::matches(Snap_Data &d) { \brief Run through all possible snap actions and store the winning coordinates in eex and eey. \param[inout] d current event data */ -void Snap_Action::check_all(Snap_Data &data) { - for (int i=0; list[i]; i++) { +void fld::app::Snap_Action::check_all(fld::app::Snap_Data &data) { + int i; + for (i =0; list[i]; i++) { if (list[i]->mask & data.drag) list[i]->check(data); } @@ -1074,16 +1083,17 @@ void Snap_Action::check_all(Snap_Data &data) { coordinate, all of them will be drawn. \param[inout] d current event data */ -void Snap_Action::draw_all(Snap_Data &data) { - for (int i=0; list[i]; i++) { +void fld::app::Snap_Action::draw_all(fld::app::Snap_Data &data) { + int i; + for (i =0; list[i]; i++) { if (list[i]->matches(data)) list[i]->draw(data); } } /** Return a sensible step size for resizing a widget. */ -void Snap_Action::get_resize_stepsize(int &x_step, int &y_step) { - Layout_Preset *layout = Fluid.proj.layout; +void fld::app::Snap_Action::get_resize_stepsize(int &x_step, int &y_step) { + fld::app::Layout_Preset *layout = Fluid.proj.layout; if ((layout->widget_inc_w > 1) && (layout->widget_inc_h > 1)) { x_step = layout->widget_inc_w; y_step = layout->widget_inc_h; @@ -1097,8 +1107,8 @@ void Snap_Action::get_resize_stepsize(int &x_step, int &y_step) { } /** Return a sensible step size for moving a widget. */ -void Snap_Action::get_move_stepsize(int &x_step, int &y_step) { - Layout_Preset *layout = Fluid.proj.layout; +void fld::app::Snap_Action::get_move_stepsize(int &x_step, int &y_step) { + fld::app::Layout_Preset *layout = Fluid.proj.layout; if ((layout->group_grid_x > 1) && (layout->group_grid_y > 1)) { x_step = layout->group_grid_x; y_step = layout->group_grid_y; @@ -1112,8 +1122,8 @@ void Snap_Action::get_move_stepsize(int &x_step, int &y_step) { } /** Fix the given size to the same or next bigger snap position. */ -void Snap_Action::better_size(int &w, int &h) { - Layout_Preset *layout = Fluid.proj.layout; +void fld::app::Snap_Action::better_size(int &w, int &h) { + fld::app::Layout_Preset *layout = Fluid.proj.layout; int x_min = 1, y_min = 1, x_inc = 1, y_inc = 1; get_resize_stepsize(x_inc, y_inc); if (x_inc < 1) x_inc = 1; @@ -1138,7 +1148,7 @@ void Snap_Action::better_size(int &w, int &h) { /** Base class for all actions that drag the left side or the entire widget. */ -class Fd_Snap_Left : public Snap_Action { +class Fd_Snap_Left : public fld::app::Snap_Action { public: Fd_Snap_Left() { type = 1; mask = FD_LEFT|FD_DRAG; } }; @@ -1146,7 +1156,7 @@ public: /** Base class for all actions that drag the right side or the entire widget. */ -class Fd_Snap_Right : public Snap_Action { +class Fd_Snap_Right : public fld::app::Snap_Action { public: Fd_Snap_Right() { type = 1; mask = FD_RIGHT|FD_DRAG; } }; @@ -1154,7 +1164,7 @@ public: /** Base class for all actions that drag the top side or the entire widget. */ -class Fd_Snap_Top : public Snap_Action { +class Fd_Snap_Top : public fld::app::Snap_Action { public: Fd_Snap_Top() { type = 2; mask = FD_TOP|FD_DRAG; } }; @@ -1162,7 +1172,7 @@ public: /** Base class for all actions that drag the bottom side or the entire widget. */ -class Fd_Snap_Bottom : public Snap_Action { +class Fd_Snap_Bottom : public fld::app::Snap_Action { public: Fd_Snap_Bottom() { type = 2; mask = FD_BOTTOM|FD_DRAG; } }; @@ -1174,8 +1184,8 @@ public: */ class Fd_Snap_Left_Window_Edge : public Fd_Snap_Left { public: - void check(Snap_Data &d) { clr(); check_x_(d, d.bx, 0); } - void draw(Snap_Data &d) { draw_left_brace(d.win->o); } + void check(fld::app::Snap_Data &d) { clr(); check_x_(d, d.bx, 0); } + void draw(fld::app::Snap_Data &d) { draw_left_brace(d.win->o); } }; Fd_Snap_Left_Window_Edge snap_left_window_edge; @@ -1184,8 +1194,8 @@ Fd_Snap_Left_Window_Edge snap_left_window_edge; */ class Fd_Snap_Right_Window_Edge : public Fd_Snap_Right { public: - void check(Snap_Data &d) { clr(); check_x_(d, d.br, d.win->o->w()); } - void draw(Snap_Data &d) { draw_right_brace(d.win->o); } + void check(fld::app::Snap_Data &d) { clr(); check_x_(d, d.br, d.win->o->w()); } + void draw(fld::app::Snap_Data &d) { draw_right_brace(d.win->o); } }; Fd_Snap_Right_Window_Edge snap_right_window_edge; @@ -1194,8 +1204,8 @@ Fd_Snap_Right_Window_Edge snap_right_window_edge; */ class Fd_Snap_Top_Window_Edge : public Fd_Snap_Top { public: - void check(Snap_Data &d) { clr(); check_y_(d, d.by, 0); } - void draw(Snap_Data &d) { draw_top_brace(d.win->o); } + void check(fld::app::Snap_Data &d) { clr(); check_y_(d, d.by, 0); } + void draw(fld::app::Snap_Data &d) { draw_top_brace(d.win->o); } }; Fd_Snap_Top_Window_Edge snap_top_window_edge; @@ -1204,8 +1214,8 @@ Fd_Snap_Top_Window_Edge snap_top_window_edge; */ class Fd_Snap_Bottom_Window_Edge : public Fd_Snap_Bottom { public: - void check(Snap_Data &d) { clr(); check_y_(d, d.bt, d.win->o->h()); } - void draw(Snap_Data &d) { draw_bottom_brace(d.win->o); } + void check(fld::app::Snap_Data &d) { clr(); check_y_(d, d.bt, d.win->o->h()); } + void draw(fld::app::Snap_Data &d) { draw_bottom_brace(d.win->o); } }; Fd_Snap_Bottom_Window_Edge snap_bottom_window_edge; @@ -1214,11 +1224,11 @@ Fd_Snap_Bottom_Window_Edge snap_bottom_window_edge; */ class Fd_Snap_Left_Window_Margin : public Fd_Snap_Left { public: - void check(Snap_Data &d) { + void check(fld::app::Snap_Data &d) { clr(); if (in_window(d)) check_x_(d, d.bx, Fluid.proj.layout->left_window_margin); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { draw_h_arrow(d.bx, (d.by+d.bt)/2, 0); } }; @@ -1226,11 +1236,11 @@ Fd_Snap_Left_Window_Margin snap_left_window_margin; class Fd_Snap_Right_Window_Margin : public Fd_Snap_Right { public: - void check(Snap_Data &d) { + void check(fld::app::Snap_Data &d) { clr(); if (in_window(d)) check_x_(d, d.br, d.win->o->w()-Fluid.proj.layout->right_window_margin); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { draw_h_arrow(d.br, (d.by+d.bt)/2, d.win->o->w()-1); } }; @@ -1238,11 +1248,11 @@ Fd_Snap_Right_Window_Margin snap_right_window_margin; class Fd_Snap_Top_Window_Margin : public Fd_Snap_Top { public: - void check(Snap_Data &d) { + void check(fld::app::Snap_Data &d) { clr(); if (in_window(d)) check_y_(d, d.by, Fluid.proj.layout->top_window_margin); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { draw_v_arrow((d.bx+d.br)/2, d.by, 0); } }; @@ -1250,11 +1260,11 @@ Fd_Snap_Top_Window_Margin snap_top_window_margin; class Fd_Snap_Bottom_Window_Margin : public Fd_Snap_Bottom { public: - void check(Snap_Data &d) { + void check(fld::app::Snap_Data &d) { clr(); if (in_window(d)) check_y_(d, d.bt, d.win->o->h()-Fluid.proj.layout->bottom_window_margin); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { draw_v_arrow((d.bx+d.br)/2, d.bt, d.win->o->h()-1); } }; @@ -1267,11 +1277,11 @@ Fd_Snap_Bottom_Window_Margin snap_bottom_window_margin; */ class Fd_Snap_Left_Group_Edge : public Fd_Snap_Left { public: - void check(Snap_Data &d) { + void check(fld::app::Snap_Data &d) { clr(); if (in_group(d)) check_x_(d, d.bx, parent(d)->x()); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { draw_left_brace(parent(d)); } }; @@ -1279,11 +1289,11 @@ Fd_Snap_Left_Group_Edge snap_left_group_edge; class Fd_Snap_Right_Group_Edge : public Fd_Snap_Right { public: - void check(Snap_Data &d) { + void check(fld::app::Snap_Data &d) { clr(); if (in_group(d)) check_x_(d, d.br, parent(d)->x() + parent(d)->w()); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { draw_right_brace(parent(d)); } }; @@ -1291,11 +1301,11 @@ Fd_Snap_Right_Group_Edge snap_right_group_edge; class Fd_Snap_Top_Group_Edge : public Fd_Snap_Top { public: - void check(Snap_Data &d) { + void check(fld::app::Snap_Data &d) { clr(); if (in_group(d)) check_y_(d, d.by, parent(d)->y()); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { draw_top_brace(parent(d)); } }; @@ -1303,11 +1313,11 @@ Fd_Snap_Top_Group_Edge snap_top_group_edge; class Fd_Snap_Bottom_Group_Edge : public Fd_Snap_Bottom { public: - void check(Snap_Data &d) { + void check(fld::app::Snap_Data &d) { clr(); if (in_group(d)) check_y_(d, d.bt, parent(d)->y() + parent(d)->h()); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { draw_bottom_brace(parent(d)); } }; @@ -1319,11 +1329,11 @@ Fd_Snap_Bottom_Group_Edge snap_bottom_group_edge; */ class Fd_Snap_Left_Group_Margin : public Fd_Snap_Left { public: - void check(Snap_Data &d) { + void check(fld::app::Snap_Data &d) { clr(); if (in_group(d)) check_x_(d, d.bx, parent(d)->x() + Fluid.proj.layout->left_group_margin); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { draw_left_brace(parent(d)); draw_h_arrow(d.bx, (d.by+d.bt)/2, parent(d)->x()); } @@ -1332,11 +1342,11 @@ Fd_Snap_Left_Group_Margin snap_left_group_margin; class Fd_Snap_Right_Group_Margin : public Fd_Snap_Right { public: - void check(Snap_Data &d) { + void check(fld::app::Snap_Data &d) { clr(); if (in_group(d)) check_x_(d, d.br, parent(d)->x()+parent(d)->w()-Fluid.proj.layout->right_group_margin); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { draw_right_brace(parent(d)); draw_h_arrow(d.br, (d.by+d.bt)/2, parent(d)->x()+parent(d)->w()-1); } @@ -1345,11 +1355,11 @@ Fd_Snap_Right_Group_Margin snap_right_group_margin; class Fd_Snap_Top_Group_Margin : public Fd_Snap_Top { public: - void check(Snap_Data &d) { + void check(fld::app::Snap_Data &d) { clr(); if (in_group(d) && !in_tabs(d)) check_y_(d, d.by, parent(d)->y()+Fluid.proj.layout->top_group_margin); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { draw_top_brace(parent(d)); draw_v_arrow((d.bx+d.br)/2, d.by, parent(d)->y()); } @@ -1358,11 +1368,11 @@ Fd_Snap_Top_Group_Margin snap_top_group_margin; class Fd_Snap_Bottom_Group_Margin : public Fd_Snap_Bottom { public: - void check(Snap_Data &d) { + void check(fld::app::Snap_Data &d) { clr(); if (in_group(d) && !in_tabs(d)) check_y_(d, d.bt, parent(d)->y()+parent(d)->h()-Fluid.proj.layout->bottom_group_margin); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { draw_bottom_brace(parent(d)); draw_v_arrow((d.bx+d.br)/2, d.bt, parent(d)->y()+parent(d)->h()-1); } @@ -1376,7 +1386,7 @@ Fd_Snap_Bottom_Group_Margin snap_bottom_group_margin; */ class Fd_Snap_Top_Tabs_Margin : public Fd_Snap_Top_Group_Margin { public: - void check(Snap_Data &d) { + void check(fld::app::Snap_Data &d) { clr(); if (in_tabs(d)) check_y_(d, d.by, parent(d)->y()+Fluid.proj.layout->top_tabs_margin); } @@ -1385,7 +1395,7 @@ Fd_Snap_Top_Tabs_Margin snap_top_tabs_margin; class Fd_Snap_Bottom_Tabs_Margin : public Fd_Snap_Bottom_Group_Margin { public: - void check(Snap_Data &d) { + void check(fld::app::Snap_Data &d) { clr(); if (in_tabs(d)) check_y_(d, d.bt, parent(d)->y()+parent(d)->h()-Fluid.proj.layout->bottom_tabs_margin); } @@ -1397,12 +1407,12 @@ Fd_Snap_Bottom_Tabs_Margin snap_bottom_tabs_margin; /** Base class for grid based snapping. */ -class Fd_Snap_Grid : public Snap_Action { +class Fd_Snap_Grid : public fld::app::Snap_Action { protected: int nearest_x, nearest_y; public: Fd_Snap_Grid() { type = 3; mask = FD_LEFT|FD_TOP|FD_DRAG; } - void check_grid(Snap_Data &d, int left, int grid_x, int right, int top, int grid_y, int bottom) { + void check_grid(fld::app::Snap_Data &d, int left, int grid_x, int right, int top, int grid_y, int bottom) { if ((grid_x <= 1) || (grid_y <= 1)) return; int suggested_x = d.bx + d.dx; nearest_x = nearest(suggested_x, left, grid_x, right); @@ -1415,7 +1425,7 @@ public: else check_x_y_(d, d.bx, nearest_x, d.by, nearest_y); } - bool matches(Snap_Data &d) { + bool matches(fld::app::Snap_Data &d) { if (d.drag == FD_LEFT) return (eex == ex); if (d.drag == FD_TOP) return (eey == ey) && (d.dx == dx); return (d.drag & mask) && (eex == ex) && (d.dx == dx) && (eey == ey) && (d.dy == dy); @@ -1427,14 +1437,14 @@ public: */ class Fd_Snap_Window_Grid : public Fd_Snap_Grid { public: - void check(Snap_Data &d) { - Layout_Preset *layout = Fluid.proj.layout; + void check(fld::app::Snap_Data &d) { + fld::app::Layout_Preset *layout = Fluid.proj.layout; clr(); if (in_window(d)) check_grid(d, layout->left_window_margin, layout->window_grid_x, d.win->o->w()-layout->right_window_margin, layout->top_window_margin, layout->window_grid_y, d.win->o->h()-layout->bottom_window_margin); } - void draw(Snap_Data &d) { - Layout_Preset *layout = Fluid.proj.layout; + void draw(fld::app::Snap_Data &d) { + fld::app::Layout_Preset *layout = Fluid.proj.layout; draw_grid(nearest_x, nearest_y, layout->window_grid_x, layout->window_grid_y); } }; @@ -1445,17 +1455,17 @@ Fd_Snap_Window_Grid snap_window_grid; */ class Fd_Snap_Group_Grid : public Fd_Snap_Grid { public: - void check(Snap_Data &d) { + void check(fld::app::Snap_Data &d) { if (in_group(d)) { - Layout_Preset *layout = Fluid.proj.layout; + fld::app::Layout_Preset *layout = Fluid.proj.layout; clr(); Fl_Widget *g = parent(d); check_grid(d, g->x()+layout->left_group_margin, layout->group_grid_x, g->x()+g->w()-layout->right_group_margin, g->y()+layout->top_group_margin, layout->group_grid_y, g->y()+g->h()-layout->bottom_group_margin); } } - void draw(Snap_Data &d) { - Layout_Preset *layout = Fluid.proj.layout; + void draw(fld::app::Snap_Data &d) { + fld::app::Layout_Preset *layout = Fluid.proj.layout; draw_grid(nearest_x, nearest_y, layout->group_grid_x, layout->group_grid_y); } }; @@ -1466,13 +1476,13 @@ Fd_Snap_Group_Grid snap_group_grid; /** Base class the check distance to other widgets in the same group. */ -class Fd_Snap_Sibling : public Snap_Action { +class Fd_Snap_Sibling : public fld::app::Snap_Action { protected: Fl_Widget *best_match; public: Fd_Snap_Sibling() : best_match(0) { } - virtual int sibling_check(Snap_Data &d, Fl_Widget *s) = 0; - void check(Snap_Data &d) { + virtual int sibling_check(fld::app::Snap_Data &d, Fl_Widget *s) = 0; + void check(fld::app::Snap_Data &d) { clr(); best_match = 0; if (!d.wgt) return; @@ -1481,7 +1491,8 @@ public: Group_Node *gt = (Group_Node*)d.wgt->parent; Fl_Group *g = (Fl_Group*)gt->o; Fl_Widget *w = d.wgt->o; - for (int i=0; ichildren(); i++) { + int i; + for (i =0; ichildren(); i++) { Fl_Widget *c = g->child(i); if (c == w) continue; int sret = sibling_check(d, c); @@ -1506,10 +1517,10 @@ public: class Fd_Snap_Siblings_Left_Same : public Fd_Snap_Sibling { public: Fd_Snap_Siblings_Left_Same() { type = 1; mask = FD_LEFT|FD_DRAG; } - int sibling_check(Snap_Data &d, Fl_Widget *s) { + int sibling_check(fld::app::Snap_Data &d, Fl_Widget *s) { return check_x_(d, d.bx, s->x()); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { if (best_match) draw_left_brace(best_match); } }; @@ -1521,11 +1532,11 @@ Fd_Snap_Siblings_Left_Same snap_siblings_left_same; class Fd_Snap_Siblings_Left : public Fd_Snap_Sibling { public: Fd_Snap_Siblings_Left() { type = 1; mask = FD_LEFT|FD_DRAG; } - int sibling_check(Snap_Data &d, Fl_Widget *s) { + int sibling_check(fld::app::Snap_Data &d, Fl_Widget *s) { return MIN(check_x_(d, d.bx, s->x()+s->w()), check_x_(d, d.bx, s->x()+s->w()+Fluid.proj.layout->widget_gap_x) ); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { if (best_match) draw_right_brace(best_match); } }; @@ -1534,10 +1545,10 @@ Fd_Snap_Siblings_Left snap_siblings_left; class Fd_Snap_Siblings_Right_Same : public Fd_Snap_Sibling { public: Fd_Snap_Siblings_Right_Same() { type = 1; mask = FD_RIGHT|FD_DRAG; } - int sibling_check(Snap_Data &d, Fl_Widget *s) { + int sibling_check(fld::app::Snap_Data &d, Fl_Widget *s) { return check_x_(d, d.br, s->x()+s->w()); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { if (best_match) draw_right_brace(best_match); } }; @@ -1546,11 +1557,11 @@ Fd_Snap_Siblings_Right_Same snap_siblings_right_same; class Fd_Snap_Siblings_Right : public Fd_Snap_Sibling { public: Fd_Snap_Siblings_Right() { type = 1; mask = FD_RIGHT|FD_DRAG; } - int sibling_check(Snap_Data &d, Fl_Widget *s) { + int sibling_check(fld::app::Snap_Data &d, Fl_Widget *s) { return MIN(check_x_(d, d.br, s->x()), check_x_(d, d.br, s->x()-Fluid.proj.layout->widget_gap_x)); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { if (best_match) draw_left_brace(best_match); } }; @@ -1559,10 +1570,10 @@ Fd_Snap_Siblings_Right snap_siblings_right; class Fd_Snap_Siblings_Top_Same : public Fd_Snap_Sibling { public: Fd_Snap_Siblings_Top_Same() { type = 2; mask = FD_TOP|FD_DRAG; } - int sibling_check(Snap_Data &d, Fl_Widget *s) { + int sibling_check(fld::app::Snap_Data &d, Fl_Widget *s) { return check_y_(d, d.by, s->y()); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { if (best_match) draw_top_brace(best_match); } }; @@ -1571,11 +1582,11 @@ Fd_Snap_Siblings_Top_Same snap_siblings_top_same; class Fd_Snap_Siblings_Top : public Fd_Snap_Sibling { public: Fd_Snap_Siblings_Top() { type = 2; mask = FD_TOP|FD_DRAG; } - int sibling_check(Snap_Data &d, Fl_Widget *s) { + int sibling_check(fld::app::Snap_Data &d, Fl_Widget *s) { return MIN(check_y_(d, d.by, s->y()+s->h()), check_y_(d, d.by, s->y()+s->h()+Fluid.proj.layout->widget_gap_y)); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { if (best_match) draw_bottom_brace(best_match); } }; @@ -1584,10 +1595,10 @@ Fd_Snap_Siblings_Top snap_siblings_top; class Fd_Snap_Siblings_Bottom_Same : public Fd_Snap_Sibling { public: Fd_Snap_Siblings_Bottom_Same() { type = 2; mask = FD_BOTTOM|FD_DRAG; } - int sibling_check(Snap_Data &d, Fl_Widget *s) { + int sibling_check(fld::app::Snap_Data &d, Fl_Widget *s) { return check_y_(d, d.bt, s->y()+s->h()); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { if (best_match) draw_bottom_brace(best_match); } }; @@ -1596,11 +1607,11 @@ Fd_Snap_Siblings_Bottom_Same snap_siblings_bottom_same; class Fd_Snap_Siblings_Bottom : public Fd_Snap_Sibling { public: Fd_Snap_Siblings_Bottom() { type = 2; mask = FD_BOTTOM|FD_DRAG; } - int sibling_check(Snap_Data &d, Fl_Widget *s) { + int sibling_check(fld::app::Snap_Data &d, Fl_Widget *s) { return MIN(check_y_(d, d.bt, s->y()), check_y_(d, d.bt, s->y()-Fluid.proj.layout->widget_gap_y)); } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { if (best_match) draw_top_brace(best_match); } }; @@ -1612,11 +1623,11 @@ Fd_Snap_Siblings_Bottom snap_siblings_bottom; /** Snap horizontal resizing to min_w or min_w and a multiple of inc_w. */ -class Fd_Snap_Widget_Ideal_Width : public Snap_Action { +class Fd_Snap_Widget_Ideal_Width : public fld::app::Snap_Action { public: Fd_Snap_Widget_Ideal_Width() { type = 1; mask = FD_LEFT|FD_RIGHT; } - void check(Snap_Data &d) { - Layout_Preset *layout = Fluid.proj.layout; + void check(fld::app::Snap_Data &d) { + fld::app::Layout_Preset *layout = Fluid.proj.layout; clr(); if (!d.wgt) return; int iw = 15, ih = 15; @@ -1633,17 +1644,17 @@ public: check_x_(d, d.bx, d.br-iw); } } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { draw_width(d.bx, d.bt+7, d.br, 0); } }; Fd_Snap_Widget_Ideal_Width snap_widget_ideal_width; -class Fd_Snap_Widget_Ideal_Height : public Snap_Action { +class Fd_Snap_Widget_Ideal_Height : public fld::app::Snap_Action { public: Fd_Snap_Widget_Ideal_Height() { type = 2; mask = FD_TOP|FD_BOTTOM; } - void check(Snap_Data &d) { - Layout_Preset *layout = Fluid.proj.layout; + void check(fld::app::Snap_Data &d) { + fld::app::Layout_Preset *layout = Fluid.proj.layout; clr(); if (!d.wgt) return; int iw, ih; @@ -1660,7 +1671,7 @@ public: check_y_(d, d.by, d.bt-ih); } } - void draw(Snap_Data &d) { + void draw(fld::app::Snap_Data &d) { draw_height(d.br+7, d.by, d.bt, 0); } }; @@ -1675,7 +1686,7 @@ Fd_Snap_Widget_Ideal_Height snap_widget_ideal_height; action in the list wins. All snap actions with the same distance and same winning coordinates are drawn in the overlay plane. */ -Snap_Action *Snap_Action::list[] = { +fld::app::Snap_Action *fld::app::Snap_Action::list[] = { &snap_left_window_edge, &snap_right_window_edge, &snap_top_window_edge, @@ -1834,8 +1845,10 @@ void draw_width(int x, int y, int r, Fl_Align a) { static void draw_grid(int x, int y, int dx, int dy) { int dx2 = 1, dy2 = 1; const int n = 2; - for (int i=-n; i<=n; i++) { - for (int j=-n; j<=n; j++) { + int i; + for (i =-n; i<=n; i++) { + int j; + for (j =-n; j<=n; j++) { if (abs(i)+abs(j) < 4) { int xx = x + i*dx , yy = y + j*dy; fl_xyline(xx-dx2, yy, xx+dx2); diff --git a/fluid/app/templates.cxx b/fluid/app/templates.cxx index 8b9b69f2a..9b2253001 100644 --- a/fluid/app/templates.cxx +++ b/fluid/app/templates.cxx @@ -28,9 +28,6 @@ #include #include "../src/flstring.h" -using namespace fld; -using namespace fld::app; - /** Save a design template. \todo We should document the concept of templates. diff --git a/fluid/io/Code_Writer.cxx b/fluid/io/Code_Writer.cxx index f451d187e..ffa63514a 100644 --- a/fluid/io/Code_Writer.cxx +++ b/fluid/io/Code_Writer.cxx @@ -31,9 +31,6 @@ #include #include -using namespace fld; -using namespace fld::io; - // ---- Fd_Id_Map implementation ---- void Fd_Id_Map::clear() { @@ -144,7 +141,7 @@ int is_id(char c) { \param[in] label else if label is set, it is appended, skipping non-keyword characters \return buffer to a unique identifier, managed by Code_Writer, so caller must NOT free() it */ -const char* Code_Writer::unique_id(void* o, const char* type, const char* name, const char* label) { +const char* fld::io::Code_Writer::unique_id(void* o, const char* type, const char* name, const char* label) { char buffer[128]; char* q = buffer; char* q_end = q + 128 - 8 - 1; // room for hex number and NUL @@ -189,7 +186,7 @@ const char* Code_Writer::unique_id(void* o, const char* type, const char* name, \param[in] set generate this indent depth \return pointer to a static string */ -const char *Code_Writer::indent(int set) { +const char *fld::io::Code_Writer::indent(int set) { static const char* spaces = " "; int i = set * 2; if (i>64) i = 64; @@ -201,7 +198,7 @@ const char *Code_Writer::indent(int set) { Return a C string that indents code to the current source file depth. \return pointer to a static string */ -const char *Code_Writer::indent() { +const char *fld::io::Code_Writer::indent() { return indent(indentation); } @@ -211,7 +208,7 @@ const char *Code_Writer::indent() { change the `indentation` variable; offset can be negative \return pointer to a static string */ -const char *Code_Writer::indent_plus(int offset) { +const char *fld::io::Code_Writer::indent_plus(int offset) { return indent(indentation+offset); } @@ -222,7 +219,7 @@ const char *Code_Writer::indent_plus(int offset) { \param[in] format printf-style formatting text, followed by a vararg list \return 1 if the text was written to the file, 0 if it was previously written. */ -int Code_Writer::write_h_once(const char *format, ...) { +int fld::io::Code_Writer::write_h_once(const char *format, ...) { va_list args; char buf[1024]; va_start(args, format); @@ -242,7 +239,7 @@ int Code_Writer::write_h_once(const char *format, ...) { \param[in] format printf-style formatting text, followed by a vararg list \return 1 if the text was written to the file, 0 if it was previously written. */ -int Code_Writer::write_c_once(const char *format, ...) { +int fld::io::Code_Writer::write_c_once(const char *format, ...) { va_list args; char buf[1024]; va_start(args, format); @@ -267,7 +264,7 @@ int Code_Writer::write_c_once(const char *format, ...) { \param[in] pp ay pointer \return true if found in the tree, false if added to the tree */ -bool Code_Writer::c_contains(void *pp) { +bool fld::io::Code_Writer::c_contains(void *pp) { if (ptr_in_code.contains(pp)) { return true; } @@ -292,7 +289,7 @@ bool Code_Writer::c_contains(void *pp) { \see f.write_cstring(const char*) */ -void Code_Writer::write_cstring(const char *s, int length) { +void fld::io::Code_Writer::write_cstring(const char *s, int length) { const char *next_line = "\"\n\""; if (varused_test) { varused = 1; @@ -373,7 +370,7 @@ void Code_Writer::write_cstring(const char *s, int length) { \param[in] s write this string \see f.write_cstring(const char*, int) */ -void Code_Writer::write_cstring(const char *s) { +void fld::io::Code_Writer::write_cstring(const char *s) { write_cstring(s, (int)strlen(s)); } @@ -385,7 +382,7 @@ void Code_Writer::write_cstring(const char *s) { \param[in] s a block of binary data, interpreted as unsigned bytes \param[in] length size of the block in bytes */ -void Code_Writer::write_cdata(const char *s, int length) { +void fld::io::Code_Writer::write_cdata(const char *s, int length) { if (varused_test) { varused = 1; return; @@ -423,7 +420,7 @@ void Code_Writer::write_cdata(const char *s, int length) { \param[in] format printf-style formatting text \param[in] args list of arguments */ -void Code_Writer::vwrite_c(const char* format, va_list args) { +void fld::io::Code_Writer::vwrite_c(const char* format, va_list args) { if (varused_test) { varused = 1; return; @@ -435,7 +432,7 @@ void Code_Writer::vwrite_c(const char* format, va_list args) { Print a formatted line to the source file. \param[in] format printf-style formatting text, followed by a vararg list */ -void Code_Writer::write_c(const char* format,...) { +void fld::io::Code_Writer::write_c(const char* format,...) { va_list args; va_start(args, format); vwrite_c(format, args); @@ -450,7 +447,7 @@ void Code_Writer::write_c(const char* format,...) { \param[in] c line of code \param[in] com optional commentary */ -void Code_Writer::write_cc(const char *indent, int n, const char *c, const char *com) { +void fld::io::Code_Writer::write_cc(const char *indent, int n, const char *c, const char *com) { write_c("%s%.*s", indent, n, c); char cc = c[n-1]; if (cc!='}' && cc!=';') @@ -464,7 +461,7 @@ void Code_Writer::write_cc(const char *indent, int n, const char *c, const char Print a formatted line to the header file. \param[in] format printf-style formatting text, followed by a vararg list */ -void Code_Writer::write_h(const char* format,...) { +void fld::io::Code_Writer::write_h(const char* format,...) { if (varused_test) return; va_list args; va_start(args, format); @@ -480,7 +477,7 @@ void Code_Writer::write_h(const char* format,...) { \param[in] c line of code \param[in] com optional commentary */ -void Code_Writer::write_hc(const char *indent, int n, const char* c, const char *com) { +void fld::io::Code_Writer::write_hc(const char *indent, int n, const char* c, const char *com) { write_h("%s%.*s", indent, n, c); char cc = c[n-1]; if (cc!='}' && cc!=';') @@ -497,7 +494,7 @@ void Code_Writer::write_hc(const char *indent, int n, const char* c, const char \param[in] inTrailWith append this character if the last line did not end with a newline, usually 0 or newline. */ -void Code_Writer::write_c_indented(const char *textlines, int inIndent, char inTrailWith) { +void fld::io::Code_Writer::write_c_indented(const char *textlines, int inIndent, char inTrailWith) { if (textlines) { indentation += inIndent; for (;;) { @@ -570,7 +567,7 @@ bool is_comment_before_class_member(Node *q) { \param[in] p write this type and all its children \return pointer to the next sibling */ -Node* Code_Writer::write_static(Node* p) { +Node* fld::io::Code_Writer::write_static(Node* p) { if (write_codeview) p->header_static_start = (int)ftell(header_file); if (write_codeview) p->code_static_start = (int)ftell(code_file); p->write_static(*this); @@ -592,7 +589,7 @@ Node* Code_Writer::write_static(Node* p) { \param[in] p write this node and all its children \return pointer to the next sibling */ -Node* Code_Writer::write_code(Node* p) { +Node* fld::io::Code_Writer::write_code(Node* p) { // write all code that comes before the children code // (but don't write the last comment until the very end) if (!(p==Fluid.proj.tree.last && p->is_a(FLD_NODE_TYPE_Comment))) { @@ -661,7 +658,7 @@ Node* Code_Writer::write_code(Node* p) { \param[in] t filename of the header file \return 0 if the operation failed, 1 if it was successful */ -int Code_Writer::write_code(const char *s, const char *t, bool to_codeview) { +int fld::io::Code_Writer::write_code(const char *s, const char *t, bool to_codeview) { write_codeview = to_codeview; unique_id_list.clear(); indentation = 0; @@ -835,7 +832,8 @@ int Code_Writer::write_code(const char *s, const char *t, bool to_codeview) { write_c("#endif\n"); } } - for (Node* p = first_node; p;) { + Node *p; + for (p = first_node; p;) { // write all static data for this & all children first write_static(p); // then write the nested code: @@ -875,7 +873,7 @@ int Code_Writer::write_code(const char *s, const char *t, bool to_codeview) { This avoids repeating these words if the mode is already set. \param[in] state 0 for private, 1 for public, 2 for protected */ -void Code_Writer::write_public(int state) { +void fld::io::Code_Writer::write_public(int state) { if (!current_class && !current_widget_class) return; if (current_class && current_class->write_public_state == state) return; if (current_widget_class && current_widget_class->write_public_state == state) return; @@ -891,7 +889,7 @@ void Code_Writer::write_public(int state) { /** Create and initialize a new C++ source code writer. */ -Code_Writer::Code_Writer(Project &proj) +fld::io::Code_Writer::Code_Writer(Project &proj) : proj_ { proj } { block_crc_ = crc32(0, 0, 0); @@ -900,7 +898,7 @@ Code_Writer::Code_Writer(Project &proj) /** Release all resources. */ -Code_Writer::~Code_Writer() +fld::io::Code_Writer::~Code_Writer() { if (block_buffer_) ::free(block_buffer_); } @@ -913,7 +911,7 @@ Code_Writer::~Code_Writer() \param[in] type FD_TAG_GENERIC, FD_TAG_CODE, FD_TAG_MENU_CALLBACK, or FD_TAG_WIDGET_CALLBACK \param[in] uid the unique id of the current type */ -void Code_Writer::tag(Mergeback::Tag prev_type, Mergeback::Tag next_type, unsigned short uid) { +void fld::io::Code_Writer::tag(Mergeback::Tag prev_type, Mergeback::Tag next_type, unsigned short uid) { if (proj_.write_mergeback_data) { ::Mergeback::print_tag(code_file, prev_type, next_type, uid, (uint32_t)block_crc_); } @@ -931,7 +929,7 @@ void Code_Writer::tag(Mergeback::Tag prev_type, Mergeback::Tag next_type, unsign if we are the start of a line, used to find leading whitespace \return the new CRC */ -unsigned long Code_Writer::block_crc(const void *data, int n, unsigned long in_crc, bool *inout_line_start) { +unsigned long fld::io::Code_Writer::block_crc(const void *data, int n, unsigned long in_crc, bool *inout_line_start) { if (!data) return 0; if (n==-1) n = (int)strlen((const char*)data); bool line_start = true; @@ -958,7 +956,7 @@ unsigned long Code_Writer::block_crc(const void *data, int n, unsigned long in_c \param[in] data a pointer to the data block \param[in] n the size of the data in bytes, or -1 to use strlen() */ -void Code_Writer::crc_add(const void *data, int n) { +void fld::io::Code_Writer::crc_add(const void *data, int n) { block_crc_ = block_crc(data, n, block_crc_, &block_line_start_); } @@ -967,7 +965,7 @@ void Code_Writer::crc_add(const void *data, int n) { \param[in] format printf style formatting string \return see fprintf(FILE *, *const char*, ...) */ -int Code_Writer::crc_printf(const char *format, ...) { +int fld::io::Code_Writer::crc_printf(const char *format, ...) { va_list args; va_start(args, format); int ret = crc_vprintf(format, args); @@ -981,7 +979,7 @@ int Code_Writer::crc_printf(const char *format, ...) { \param[in] args list of arguments \return see fprintf(FILE *, *const char*, ...) */ -int Code_Writer::crc_vprintf(const char *format, va_list args) { +int fld::io::Code_Writer::crc_vprintf(const char *format, va_list args) { if (proj_.write_mergeback_data) { int n = vsnprintf(block_buffer_, block_buffer_size_, format, args); if (n > block_buffer_size_) { @@ -1002,7 +1000,7 @@ int Code_Writer::crc_vprintf(const char *format, va_list args) { \param[in] text any text, no requirements to end in a newline or such \return see fputs(const char*, FILE*) */ -int Code_Writer::crc_puts(const char *text) { +int fld::io::Code_Writer::crc_puts(const char *text) { if (proj_.write_mergeback_data) { crc_add(text); } @@ -1011,11 +1009,11 @@ int Code_Writer::crc_puts(const char *text) { /** Write a single ASCII character to the code file. If MergeBack is enabled, the CRC calculation is continued. - \note to write UTF-8 characters, use Code_Writer::crc_puts(const char *text) + \note to write UTF-8 characters, use fld::io::Code_Writer::crc_puts(const char *text) \param[in] c any character between 0 and 127 inclusive \return see fputc(int, FILE*) */ -int Code_Writer::crc_putc(int c) { +int fld::io::Code_Writer::crc_putc(int c) { if (proj_.write_mergeback_data) { uchar uc = (uchar)c; crc_add(&uc, 1); diff --git a/fluid/io/Project_Reader.cxx b/fluid/io/Project_Reader.cxx index 3bf9608a3..54baa9a85 100644 --- a/fluid/io/Project_Reader.cxx +++ b/fluid/io/Project_Reader.cxx @@ -41,9 +41,6 @@ /// \defgroup flfile .fl Project File Operations /// \{ -using namespace fld; -using namespace fld::io; - // This file contains code to read and write .fl files. /// If set, we read an old fdesign file and widget y coordinates need to be flipped. @@ -85,7 +82,7 @@ static int hexdigit(int x) { Oh how I wish sometimes we would upgrade to modern C++. \param[in] length minimum length in bytes */ -void Project_Reader::expand_buffer(int length) { +void fld::io::Project_Reader::expand_buffer(int length) { if (length >= buflen) { if (!buflen) { buflen = length+1; @@ -99,13 +96,13 @@ void Project_Reader::expand_buffer(int length) { } /** \brief Construct local project reader. */ -Project_Reader::Project_Reader(Project &proj) +fld::io::Project_Reader::Project_Reader(Project &proj) : proj_(proj) { } /** \brief Release project reader resources. */ -Project_Reader::~Project_Reader() +fld::io::Project_Reader::~Project_Reader() { // fname is not copied, so do not free it if (buffer) @@ -117,7 +114,7 @@ Project_Reader::~Project_Reader() \param[in] s filename, if 0, read from stdin instead \return 0 if the operation failed, 1 if it succeeded */ -int Project_Reader::open_read(const char *s) { +int fld::io::Project_Reader::open_read(const char *s) { lineno = 1; if (!s) { fin = stdin; @@ -136,7 +133,7 @@ int Project_Reader::open_read(const char *s) { Close the .fl file. \return 0 if the operation failed, 1 if it succeeded */ -int Project_Reader::close_read() { +int fld::io::Project_Reader::close_read() { if (fin != stdin) { int x = fclose(fin); fin = 0; @@ -149,7 +146,7 @@ int Project_Reader::close_read() { Return the name part of the current filename and path. \return a pointer into a string that is not owned by this class */ -const char *Project_Reader::filename_name() { +const char *fld::io::Project_Reader::filename_name() { return fl_filename_name(fname); } @@ -159,7 +156,7 @@ const char *Project_Reader::filename_name() { values, and \\o### octal values. \return a character in the ASCII range */ -int Project_Reader::read_quoted() { // read whatever character is after a \ . +int fld::io::Project_Reader::read_quoted() { // read whatever character is after a \ . int c,d,x; switch(c = nextchar()) { case '\n': lineno++; return -1; @@ -204,7 +201,7 @@ int Project_Reader::read_quoted() { // read whatever character is after a \ a previous call, and there is no need to waste time searching for them. \return the last node that was created */ -Node *Project_Reader::read_children(Node *p, int merge, Strategy strategy, char skip_options) { +Node *fld::io::Project_Reader::read_children(Node *p, int merge, Strategy strategy, char skip_options) { Fluid.proj.tree.current = p; Node *last_child_read = 0; Node *t = 0; @@ -388,7 +385,7 @@ Node *Project_Reader::read_children(Node *p, int merge, Strategy strategy, char \param[in] strategy add new nodes after current or as last child \return 0 if the operation failed, 1 if it succeeded */ -int Project_Reader::read_project(const char *filename, int merge, Strategy strategy) { +int fld::io::Project_Reader::read_project(const char *filename, int merge, Strategy strategy) { Node *o; proj_.undo.suspend(); read_version = 0.0; @@ -438,7 +435,7 @@ int Project_Reader::read_project(const char *filename, int merge, Strategy strat operations. \param[in] format printf style format string, followed by an argument list */ -void Project_Reader::read_error(const char *format, ...) { +void fld::io::Project_Reader::read_error(const char *format, ...) { va_list args; va_start(args, format); if (!fin) { // FIXME: this line suppresses any error messages in interactive mode @@ -471,7 +468,7 @@ void Project_Reader::read_error(const char *format, ...) { overwrite this buffer. If wantbrace is not set, but we read a leading '{', the returned string will be stripped of its leading and trailing braces. */ -const char *Project_Reader::read_word(int wantbrace) { +const char *fld::io::Project_Reader::read_word(int wantbrace) { int x; // skip all the whitespace before it: @@ -541,7 +538,7 @@ const char *Project_Reader::read_word(int wantbrace) { /** Read a word and interpret it as an integer value. \return integer value, or 0 if the word is not an integer */ -int Project_Reader::read_int() { +int fld::io::Project_Reader::read_int() { const char *word = read_word(); if (word) { return atoi(word); @@ -557,7 +554,7 @@ int Project_Reader::read_int() { \param[out] value string \return 0 if end of file, else 1 */ -int Project_Reader::read_fdesign_line(const char*& name, const char*& value) { +int fld::io::Project_Reader::read_fdesign_line(const char*& name, const char*& value) { int length = 0; int x; // find a colon: @@ -646,6 +643,7 @@ static const char *class_matcher[] = { static void forms_end(Fl_Group *g, int flip) { // set the dimensions of a group to surround its contents const int nc = g->children(); + int i; if (nc && !g->w()) { Fl_Widget*const* a = g->array(); Fl_Widget* o = *a++; @@ -653,7 +651,7 @@ static void forms_end(Fl_Group *g, int flip) { int ry = o->y(); int rw = rx+o->w(); int rh = ry+o->h(); - for (int i = nc - 1; i--;) { + for (i = nc - 1; i--;) { o = *a++; if (o->x() < rx) rx = o->x(); if (o->y() < ry) ry = o->y(); @@ -667,7 +665,7 @@ static void forms_end(Fl_Group *g, int flip) { Fl_Widget* o = (g->as_window()) ? g : g->window(); int Y = o->h(); Fl_Widget*const* a = g->array(); - for (int i = nc; i--;) { + for (i = nc; i--;) { Fl_Widget* ow = *a++; int newy = Y - ow->y() - ow->h(); ow->Fl_Widget::resize(ow->x(), newy, ow->w(), ow->h()); @@ -683,7 +681,7 @@ static void forms_end(Fl_Group *g, int flip) { FLTK widgets. \see http://xforms-toolkit.org */ -void Project_Reader::read_fdesign() { +void fld::io::Project_Reader::read_fdesign() { int fdesign_magic = atoi(read_word()); fdesign_flip = (fdesign_magic < 13000); Widget_Node *window = 0; @@ -721,7 +719,8 @@ void Project_Reader::read_fdesign() { group = widget = 0; Fluid.proj.tree.current = window; } else { - for (int i = 0; class_matcher[i]; i += 2) + int i; + for (i = 0; class_matcher[i]; i += 2) if (!strcmp(value,class_matcher[i])) { value = class_matcher[i+1]; break;} widget = (Widget_Node*)add_new_widget_from_file(value, Strategy::FROM_FILE_AS_LAST_CHILD); diff --git a/fluid/io/Project_Writer.cxx b/fluid/io/Project_Writer.cxx index 9af369c93..e2f670f8f 100644 --- a/fluid/io/Project_Writer.cxx +++ b/fluid/io/Project_Writer.cxx @@ -32,9 +32,6 @@ /// \defgroup flfile .fl Project File Operations /// \{ -using namespace fld; -using namespace fld::io; - /** \brief Write an .fl design description file. The .fl file format is documented in `fluid/README_fl.txt`. @@ -52,13 +49,13 @@ int fld::io::write_file(Project &proj, const char *filename, int selected_only, // ---- Project_Writer ---------------------------------------------- MARK: - /** \brief Construct local project writer. */ -Project_Writer::Project_Writer(Project &proj) +fld::io::Project_Writer::Project_Writer(Project &proj) : proj_(proj) { } /** \brief Release project writer resources. */ -Project_Writer::~Project_Writer() +fld::io::Project_Writer::~Project_Writer() { } @@ -68,7 +65,7 @@ Project_Writer::~Project_Writer() \param[in] s the filename or 0 for stdout \return 1 if successful. 0 if the operation failed */ -int Project_Writer::open_write(const char *s) { +int fld::io::Project_Writer::open_write(const char *s) { if (!s) { fout = stdout; } else { @@ -84,7 +81,7 @@ int Project_Writer::open_write(const char *s) { Don't close, if data was sent to stdout. \return 1 if succeeded, 0 if fclose failed */ -int Project_Writer::close_write() { +int fld::io::Project_Writer::close_write() { if (fout != stdout) { int x = fclose(fout); fout = stdout; @@ -100,7 +97,7 @@ int Project_Writer::close_write() { \param[in] sv if set, this file will be used by codeview \return 0 if the operation failed, 1 if it succeeded */ -int Project_Writer::write_project(const char *filename, int selected_only, bool sv) { +int fld::io::Project_Writer::write_project(const char *filename, int selected_only, bool sv) { write_codeview_ = sv; proj_.undo.suspend(); if (!open_write(filename)) { @@ -131,7 +128,8 @@ int Project_Writer::write_project(const char *filename, int selected_only, bool write_string("\nmergeback %d", proj_.write_mergeback_data); } - for (Node *p = proj_.tree.first; p;) { + Node *p; + for (p = proj_.tree.first; p;) { if (!selected_only || p->selected) { p->write(*this); write_string("\n"); @@ -150,7 +148,7 @@ int Project_Writer::write_project(const char *filename, int selected_only, bool Write a string to the .fl file, quoting characters if necessary. \param[in] w NUL terminated text */ -void Project_Writer::write_word(const char *w) { +void fld::io::Project_Writer::write_word(const char *w) { if (needspace) putc(' ', fout); needspace = 1; if (!w || !*w) {fprintf(fout,"{}"); return;} @@ -188,7 +186,7 @@ void Project_Writer::write_word(const char *w) { unless the format starts with a newline character \\n. \param[in] format printf style formatting string followed by a list of arguments */ -void Project_Writer::write_string(const char *format, ...) { +void fld::io::Project_Writer::write_string(const char *format, ...) { va_list args; va_start(args, format); if (needspace && *format != '\n') fputc(' ',fout); @@ -201,7 +199,7 @@ void Project_Writer::write_string(const char *format, ...) { Start a new line in the .fl file and indent it for a given nesting level. \param[in] n indent level */ -void Project_Writer::write_indent(int n) { +void fld::io::Project_Writer::write_indent(int n) { fputc('\n',fout); while (n--) {fputc(' ',fout); fputc(' ',fout);} needspace = 0; @@ -210,7 +208,7 @@ void Project_Writer::write_indent(int n) { /** Write a '{' to the .fl file at the given indenting level. */ -void Project_Writer::write_open() { +void fld::io::Project_Writer::write_open() { if (needspace) fputc(' ',fout); fputc('{',fout); needspace = 0; @@ -220,7 +218,7 @@ void Project_Writer::write_open() { Write a '}' to the .fl file at the given indenting level. \param[in] n indent level */ -void Project_Writer::write_close(int n) { +void fld::io::Project_Writer::write_close(int n) { if (needspace) write_indent(n); fputc('}',fout); needspace = 1; diff --git a/fluid/io/String_Writer.cxx b/fluid/io/String_Writer.cxx index 97245697b..891fc5a25 100644 --- a/fluid/io/String_Writer.cxx +++ b/fluid/io/String_Writer.cxx @@ -21,9 +21,6 @@ #include "nodes/Window_Node.h" #include "nodes/Function_Node.h" -using namespace fld; -using namespace fld::io; - /** Write a string to a file, replacing all non-ASCII characters with octal codes. \param[in] out output file @@ -33,7 +30,8 @@ using namespace fld::io; static int write_escaped_strings(FILE *out, const char *text) { int ret = 0; const unsigned char *utf8_text = (const unsigned char *)text; - for (const unsigned char *s = utf8_text; *s; ++s) { + const unsigned char *s; + for (s = utf8_text; *s; ++s) { unsigned char c = *s; // escape control characters, delete, all utf-8, and the double quotes // note: we should have an option in the project settings to allow utf-8 diff --git a/fluid/nodes/Function_Node.cxx b/fluid/nodes/Function_Node.cxx index de3706eb3..daf5822c0 100644 --- a/fluid/nodes/Function_Node.cxx +++ b/fluid/nodes/Function_Node.cxx @@ -37,9 +37,6 @@ extern void open_panel(); -using namespace fld; -using namespace fld::io; -using namespace fld::proj; /// Set a current class, so that the code of the children is generated correctly. Class_Node *current_class = 0; diff --git a/fluid/nodes/Grid_Node.cxx b/fluid/nodes/Grid_Node.cxx index d38bbd1ca..6759c33f2 100644 --- a/fluid/nodes/Grid_Node.cxx +++ b/fluid/nodes/Grid_Node.cxx @@ -225,7 +225,8 @@ void Fl_Grid_Proxy::transient_make_room_(int n) { \param[in] w remove the transient cell for this widget */ void Fl_Grid_Proxy::transient_remove_(Fl_Widget *w) { - for (int i=0; igap(&rg, &cg); d->gap(rg, cg); // copy col widths, heights, and gaps - for (int c=0; ccols(); c++) { + int c; + for (c =0; ccols(); c++) { d->col_width(c, s->col_width(c)); d->col_gap(c, s->col_gap(c)); d->col_weight(c, s->col_weight(c)); } // copy row widths, heights, and gaps - for (int r=0; rrows(); r++) { + int r; + for (r =0; rrows(); r++) { d->row_height(r, s->row_height(r)); d->row_gap(r, s->row_gap(r)); d->row_weight(r, s->row_weight(r)); @@ -331,7 +335,8 @@ void Grid_Node::copy_properties() void Grid_Node::copy_properties_for_children() { Fl_Grid *d = (Fl_Grid*)live_widget, *s =(Fl_Grid*)o; - for (int i=0; ichildren(); i++) { + int i; + for (i =0; ichildren(); i++) { Fl_Grid::Cell *cell = s->cell(s->child(i)); if (cell && ichildren()) { d->widget(d->child(i), @@ -411,6 +416,7 @@ void Grid_Node::write_properties(fld::io::Project_Writer &f) void Grid_Node::read_property(fld::io::Project_Reader &f, const char *c) { Fl_Grid* grid = (Fl_Grid*)o; + int i; if (!strcmp(c,"dimensions")) { int rows = 3, cols = 3; if (sscanf(f.read_word(),"%d %d", &rows, &cols) == 2) @@ -426,32 +432,32 @@ void Grid_Node::read_property(fld::io::Project_Reader &f, const char *c) } else if (!strcmp(c,"rowheights")) { int rows = grid->rows(); f.read_word(1); // "{" - for (int i=0; irow_height(i, f.read_int()); + for (i =0; irow_height(i, f.read_int()); f.read_word(1); // "}" } else if (!strcmp(c,"rowweights")) { int rows = grid->rows(); f.read_word(1); // "{" - for (int i=0; irow_weight(i, f.read_int()); + for (i =0; irow_weight(i, f.read_int()); f.read_word(1); // "}" } else if (!strcmp(c,"rowgaps")) { int rows = grid->rows(); f.read_word(1); // "{" - for (int i=0; irow_gap(i, f.read_int()); + for (i =0; irow_gap(i, f.read_int()); f.read_word(1); // "}" } else if (!strcmp(c,"colwidths")) { int cols = grid->cols(); f.read_word(1); // "{" - for (int i=0; icol_width(i, f.read_int()); + for (i =0; icol_width(i, f.read_int()); f.read_word(1); // "}" } else if (!strcmp(c,"colweights")) { int cols = grid->cols(); f.read_word(1); // "{" - for (int i=0; icol_weight(i, f.read_int()); + for (i =0; icol_weight(i, f.read_int()); f.read_word(1); // "}" } else if (!strcmp(c,"colgaps")) { int cols = grid->cols(); f.read_word(1); // "{" - for (int i=0; icol_gap(i, f.read_int()); + for (i =0; icol_gap(i, f.read_int()); f.read_word(1); // "}" } else { super::read_property(f, c); @@ -612,7 +618,8 @@ void Grid_Node::write_code2(fld::io::Code_Writer& f) { const char *var = name() ? name() : "o"; Fl_Grid* grid = (Fl_Grid*)o; bool first_cell = true; - for (int i=0; ichildren(); i++) { + int i; + for (i =0; ichildren(); i++) { Fl_Widget *c = grid->child(i); Fl_Grid::Cell *cell = grid->cell(c); if (cell) { @@ -694,14 +701,16 @@ void Grid_Node::insert_child_at(Fl_Widget *child, int x, int y) { int x0 = grid->x() + Fl::box_dx(grid->box()) + ml; int y0 = grid->y() + Fl::box_dy(grid->box()) + mt; - for (int r = 0; r < grid->rows(); r++) { + int r; + for (r = 0; r < grid->rows(); r++) { if (y>y0) row = r; int gap = grid->row_gap(r)>=0 ? grid->row_gap(r) : grg; y0 += grid->computed_row_height(r); y0 += gap; } - for (int c = 0; c < grid->cols(); c++) { + int c; + for (c = 0; c < grid->cols(); c++) { if (x>x0) col = c; int gap = grid->col_gap(c)>=0 ? grid->col_gap(c) : gcg; x0 += grid->computed_col_width(c); @@ -732,8 +741,10 @@ void Grid_Node::insert_child_at_next_free_cell(Fl_Widget *child) { // c = current_cell->col(); // } // } - for (int r = 0; r < grid->rows(); r++) { - for (int c = 0; c < grid->cols(); c++) { + int r; + for (r = 0; r < grid->rows(); r++) { + int c; + for (c = 0; c < grid->cols(); c++) { if (!grid->cell(r, c)) { grid->move_cell(child, r, c); return; diff --git a/fluid/nodes/Group_Node.cxx b/fluid/nodes/Group_Node.cxx index 8ff3b9cdf..d4dc93780 100644 --- a/fluid/nodes/Group_Node.cxx +++ b/fluid/nodes/Group_Node.cxx @@ -79,7 +79,8 @@ void fix_group_size(Node *tt) { int Y = t->o->y(); int R = X+t->o->w(); int B = Y+t->o->h(); - for (Node *nn = t->next; nn && nn->level > t->level; nn = nn->next) { + Node *nn; + for (nn = t->next; nn && nn->level > t->level; nn = nn->next) { if (nn->is_true_widget()) { Widget_Node* n = (Widget_Node*)nn; int x = n->o->x(); if (x < X) X = x; @@ -122,7 +123,8 @@ void group_cb(Fl_Widget *, void *) { Group_Node *n = (Group_Node*)(Group_Node::prototype.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 (Node *t = qq->next; t && (t->level > qq->level);) { + Node *t; + for (t = qq->next; t && (t->level > qq->level);) { if (t->level != n->level || t == n || !t->selected) { t = t->next; continue; @@ -166,7 +168,8 @@ void ungroup_cb(Fl_Widget *, void *) { Fluid.proj.undo.checkpoint(); Fluid.proj.undo.suspend(); Fluid.proj.tree.current = qq; - for (Node *t = qq->next; t && (t->level > qq->level);) { + Node *t; + for (t = qq->next; t && (t->level > qq->level);) { if (t->level != q_level || !t->selected) { t = t->next; continue; @@ -319,7 +322,8 @@ Fl_Widget *Flex_Node::enter_live_mode(int) { Fl_Flex *d = grp, *s =(Fl_Flex*)o; int nc = s->children(), nd = d->children(); if (nc>nd) nc = nd; - for (int i=0; ifixed(s->child(i))) { Fl_Widget *dc = d->child(i); d->fixed(d->child(i), s->horizontal() ? dc->w() : dc->h()); @@ -340,7 +344,8 @@ void Flex_Node::copy_properties() void Flex_Node::copy_properties_for_children() { Fl_Flex *d = (Fl_Flex*)live_widget, *s =(Fl_Flex*)o; - for (int i=0; ichildren(); i++) { + int i; + for (i =0; ichildren(); i++) { if (s->fixed(s->child(i)) && ichildren()) { if (s->horizontal()) { d->fixed(d->child(i), d->child(i)->w()); @@ -363,12 +368,13 @@ void Flex_Node::write_properties(fld::io::Project_Writer &f) if (flex->gap()) f.write_string("gap %d", flex->gap()); int nSet = 0; - for (int i=0; ichildren(); i++) + int i; + for (i =0; ichildren(); i++) if (flex->fixed(flex->child(i))) nSet++; if (nSet) { f.write_string("fixed_size_tuples {%d", nSet); - for (int i=0; ichildren(); i++) { + for (i =0; ichildren(); i++) { Fl_Widget *ci = flex->child(i); if (flex->fixed(ci)) f.write_string(" %d %d", i, flex->horizontal() ? ci->w() : ci->h()); @@ -394,7 +400,8 @@ void Flex_Node::read_property(fld::io::Project_Reader &f, const char *c) const char *nStr = f.read_word(1); // number of indices in table fixedSizeTupleSize = atoi(nStr); fixedSizeTuple = new int[fixedSizeTupleSize*2]; - for (int i=0; i0) { - for (int i=0; i=0 && ixchildren()) { @@ -434,7 +442,8 @@ void Flex_Node::write_code2(fld::io::Code_Writer& f) { f.write_c("%s%s->margin(%d, %d, %d, %d);\n", f.indent(), var, lm, tm, rm, bm); if (flex->gap()) f.write_c("%s%s->gap(%d);\n", f.indent(), var, flex->gap()); - for (int i=0; ichildren(); ++i) { + int i; + for (i =0; ichildren(); ++i) { Fl_Widget *ci = flex->child(i); if (flex->fixed(ci)) f.write_c("%s%s->fixed(%s->child(%d), %d);\n", f.indent(), var, var, i, @@ -489,15 +498,16 @@ void Flex_Node::change_subtype_to(int n) { int fh = f->h()-dh-tm-bm-(nc*gap); if (fh<=nc) fh = nc; // avoid division by zero + int i; if (f->type()==Fl_Flex::HORIZONTAL && n==Fl_Flex::VERTICAL) { float scl = (float)fh/(float)fw; - for (int i=0; ichild(i); c->size(f->w(), (int)(c->w()*scl)); } } else if (f->type()==Fl_Flex::VERTICAL && n==Fl_Flex::HORIZONTAL) { float scl = (float)fw/(float)fh; - for (int i=0; ichild(i); c->size((int)(c->h()*scl), f->h()); } @@ -658,8 +668,9 @@ public: Fl_Table_Proxy(int x, int y, int w, int h, const char *l=0) : Fl_Table(x, y, w, h, l) { end(); - for ( int r=0; r #include -using namespace fld; -using namespace fld::proj; Fl_Menu_Item menu_item_type_menu[] = { {"Normal",0,0,(void*)0}, @@ -210,7 +208,8 @@ void group_selected_menuitems() { Fluid.proj.undo.checkpoint(); Fluid.proj.undo.suspend(); Widget_Node *n = (Widget_Node*)(q->make(FL_SUBMENU, Strategy::AFTER_CURRENT)); - for (Node *t = qq->next; t && (t->level > qq->level);) { + Node *t; + for (t = qq->next; t && (t->level > qq->level);) { if (t->level != n->level || t == n || !t->selected) { t = t->next; continue; @@ -236,7 +235,8 @@ void ungroup_selected_menuitems() { Fluid.proj.undo.checkpoint(); Fluid.proj.undo.suspend(); Fluid.proj.tree.current = qq; - for (Node *t = qq->next; t && (t->level > qq->level);) { + Node *t; + for (t = qq->next; t && (t->level > qq->level);) { if (t->level != q_level || !t->selected) { t = t->next; continue; @@ -325,7 +325,8 @@ void Menu_Item_Node::write_static(fld::io::Code_Writer& f) { if (callback() && is_name(callback()) && !user_defined(callback())) f.write_h_once("extern void %s(Fl_Menu_*, %s);", callback(), user_data_type() ? user_data_type() : "void*"); - for (int n=0; n < NUM_EXTRA_CODE; n++) { + int n; + for (n =0; n < NUM_EXTRA_CODE; n++) { if (extra_code(n) && extra_code(n)[0] && isdeclare(extra_code(n))) f.write_h_once("%s", extra_code(n)); } @@ -426,7 +427,8 @@ void Menu_Item_Node::write_static(fld::io::Code_Writer& f) { f.write_c("\nFl_Menu_Item %s[] = {\n", menu_name(f, i)); } Node* t = prev; while (t && t->is_a(FLD_NODE_TYPE_Menu_Item)) t = t->prev; - for (Node* q = t->next; q && q->is_a(FLD_NODE_TYPE_Menu_Item); q = q->next) { + Node *q; + for (q = t->next; q && q->is_a(FLD_NODE_TYPE_Menu_Item); q = q->next) { ((Menu_Item_Node*)q)->write_item(f); int thislevel = q->level; if (q->can_have_children()) thislevel++; int nextlevel = @@ -438,7 +440,7 @@ void Menu_Item_Node::write_static(fld::io::Code_Writer& f) { if (k) { // Write menu item variables... t = prev; while (t && t->is_a(FLD_NODE_TYPE_Menu_Item)) t = t->prev; - for (Node* q = t->next; q && q->is_a(FLD_NODE_TYPE_Menu_Item); q = q->next) { + for (q = t->next; q && q->is_a(FLD_NODE_TYPE_Menu_Item); q = q->next) { Menu_Item_Node *m = (Menu_Item_Node*)q; const char *c = array_name(m); if (c) { @@ -637,7 +639,8 @@ void Menu_Item_Node::write_code1(fld::io::Code_Writer& f) { } } } - for (int n=0; n < NUM_EXTRA_CODE; n++) { + int n; + for (n =0; n < NUM_EXTRA_CODE; n++) { if (extra_code(n) && extra_code(n)[0] && !isdeclare(extra_code(n))) { start_menu_initialiser(f, menuItemInitialized, mname, i); f.write_c("%s%s\n", f.indent(), extra_code(n)); diff --git a/fluid/nodes/Node.cxx b/fluid/nodes/Node.cxx index 8e0041f3c..79bd04b3b 100644 --- a/fluid/nodes/Node.cxx +++ b/fluid/nodes/Node.cxx @@ -133,8 +133,10 @@ Node *in_this_only; // set if menu popped-up in window */ void print_project_tree() { fprintf(stderr, "---- %s --->\n", Fluid.proj.projectfile_name().c_str()); - for (Node *t = Fluid.proj.tree.first; t; t = t->next) { - for (int i = t->level; i > 0; i--) + Node *t; + for (t = Fluid.proj.tree.first; t; t = t->next) { + int i; + for (i = t->level; i > 0; i--) fprintf(stderr, ". "); fprintf(stderr, "%s\n", subclassname(t).c_str()); } @@ -180,7 +182,8 @@ bool validate_project_tree() { bool validate_independent_branch(class Node *root) { // Make sure that `first` and `last` do not point at any node in this branch if (Fluid.proj.tree.first) { - for (Node *t = root; t; t = t->next) { + Node *t; + for (t = root; t; t = t->next) { if (Fluid.proj.tree.first == t) { fprintf(stderr, "ERROR: Branch is not independent, `first` is pointing to branch member!\n"); return false; @@ -188,7 +191,7 @@ bool validate_independent_branch(class Node *root) { } } if (Fluid.proj.tree.last) { - for (Node *t = root; t; t = t->next) { + for (t = root; t; t = t->next) { if (Fluid.proj.tree.last == t) { fprintf(stderr, "ERROR: Branch is not independent, `last` is pointing to branch member!\n"); return false; @@ -216,7 +219,8 @@ bool validate_branch(class Node *root) { return false; } // Check relation between this and next node - for (Node *t = root; t; t = t->next) { + Node *t; + for (t = root; t; t = t->next) { if (t->level < root->level) { fprintf(stderr, "ERROR: Node in tree is above root level!\n"); return false; @@ -241,7 +245,8 @@ bool validate_branch(class Node *root) { } } // Validate the `parent` entry - for (Node *p = t->prev; ; p = p->prev) { + Node *p; + for (p = t->prev; ; p = p->prev) { if (p == 0) { if (t->parent != 0) { fprintf(stderr, "ERROR: `parent` pointer should be 0!\n"); @@ -270,16 +275,17 @@ void select_all_cb(Fl_Widget *,void *) { for (; t && t != in_this_only; t = t->parent) {/*empty*/} if (t != in_this_only) p = in_this_only; } + Node *t; for (;;) { if (p) { int foundany = 0; - for (Node *t = p->next; t && t->level>p->level; t = t->next) { + for (t = p->next; t && t->level>p->level; t = t->next) { if (!t->new_selected) {widget_browser->select(t,1,0); foundany = 1;} } if (foundany) break; p = p->parent; } else { - for (Node *t = Fluid.proj.tree.first; t; t = t->next) + for (t = Fluid.proj.tree.first; t; t = t->next) widget_browser->select(t,1,0); break; } @@ -294,16 +300,17 @@ void select_none_cb(Fl_Widget *,void *) { for (; t && t != in_this_only; t = t->parent) {/*empty*/} if (t != in_this_only) p = in_this_only; } + Node *t; for (;;) { if (p) { int foundany = 0; - for (Node *t = p->next; t && t->level>p->level; t = t->next) { + for (t = p->next; t && t->level>p->level; t = t->next) { if (t->new_selected) {widget_browser->select(t,0,0); foundany = 1;} } if (foundany) break; p = p->parent; } else { - for (Node *t = Fluid.proj.tree.first; t; t = t->next) + for (t = Fluid.proj.tree.first; t; t = t->next) widget_browser->select(t,0,0); break; } @@ -388,7 +395,8 @@ void delete_all(int selected_only) { widget_browser->save_scroll_position(); widget_browser->new_list(); } - for (Node *f = Fluid.proj.tree.first; f;) { + Node *f; + for (f = Fluid.proj.tree.first; f;) { if (f->selected || !selected_only) { delete_children(f); Node *g = f->next; @@ -590,7 +598,8 @@ const char* Node::title() { Window_Node *Node::window() { if (!is_widget()) return 0; - for (Node *t = this; t; t=t->parent) + Node *t; + for (t = this; t; t=t->parent) if (t->is_a(FLD_NODE_TYPE_Window)) return (Window_Node*)t; return 0; @@ -603,7 +612,8 @@ Window_Node *Node::window() { Group_Node *Node::group() { if (!is_widget()) return 0; - for (Node *t = this; t; t=t->parent) + Node *t; + for (t = this; t; t=t->parent) if (t->is_a(FLD_NODE_TYPE_Group)) return (Group_Node*)t; return 0; @@ -677,7 +687,8 @@ void Node::add(Node *anchor, Strategy strategy) { // Walk the tree to update parent pointers and levels int source_level = level; - for (Node *t = this; t; t = t->next) { + Node *t; + for (t = this; t; t = t->next) { t->level += (target_level-source_level); if (t->level == target_level) t->parent = target_parent; @@ -708,7 +719,7 @@ void Node::add(Node *anchor, Strategy strategy) { } // Give the widgets in our tree a chance to update themselves - for (Node *t = this; t && t!=end->next; t = t->next) { + for (t = this; t && t!=end->next; t = t->next) { if (target_parent && (t->level == target_level)) target_parent->add_child(t, 0); update_visibility_flag(t); @@ -744,7 +755,8 @@ void Node::insert(Node *g) { // run the list again to set the future node levels int newlevel = g->level; visible = g->visible; - for (Node *t = this->next; t; t = t->next) t->level += newlevel-level; + Node *t; + for (t = this->next; t; t = t->next) t->level += newlevel-level; level = newlevel; // insert this in the list before g prev = g->prev; @@ -1186,7 +1198,8 @@ void Node::copy_properties() { the parameter types match. */ int Node::user_defined(const char* cbname) const { - for (Node* p = Fluid.proj.tree.first; p ; p = p->next) + Node *p; + for (p = Fluid.proj.tree.first; p ; p = p->next) if (p->is_a(FLD_NODE_TYPE_Function) && p->name() != 0) if (strncmp(p->name(), cbname, strlen(cbname)) == 0) if (p->name()[strlen(cbname)] == '(') diff --git a/fluid/nodes/Tree.cxx b/fluid/nodes/Tree.cxx index d437b5bd3..e11c399e2 100644 --- a/fluid/nodes/Tree.cxx +++ b/fluid/nodes/Tree.cxx @@ -19,11 +19,7 @@ #include "Project.h" -using namespace fld; -using namespace fld::node; - - -Tree::Iterator::Iterator(Node *t, bool only_selected) +fld::node::Tree::Iterator::Iterator(Node *t, bool only_selected) : type_(t) , only_selected_(only_selected) { @@ -36,7 +32,7 @@ Tree::Iterator::Iterator(Node *t, bool only_selected) } } -Tree::Iterator &Tree::Iterator::operator++() { +fld::node::Tree::Iterator &fld::node::Tree::Iterator::operator++() { if (only_selected_) { do { type_ = type_->next; @@ -47,7 +43,7 @@ Tree::Iterator &Tree::Iterator::operator++() { return *this; } -Tree::WIterator::WIterator(Node *t, bool only_selected) +fld::node::Tree::WIterator::WIterator(Node *t, bool only_selected) : type_(t) , only_selected_(only_selected) { @@ -64,7 +60,7 @@ Tree::WIterator::WIterator(Node *t, bool only_selected) } } -Tree::WIterator& Tree::WIterator::operator++() { +fld::node::Tree::WIterator& fld::node::Tree::WIterator::operator++() { if (only_selected_) { do { type_ = type_->next; @@ -78,7 +74,7 @@ Tree::WIterator& Tree::WIterator::operator++() { } -Tree::Tree(Project &proj) +fld::node::Tree::Tree(Project &proj) : proj_(proj) { (void)proj_; } @@ -91,7 +87,7 @@ Tree::Tree(Project &proj) \param[in] uid any number between 0 and 65535 \return the node with this uid, or 0 if not found */ -Node *Tree::find_by_uid(unsigned short uid) { +Node *fld::node::Tree::find_by_uid(unsigned short uid) { for (Node *tp: all_nodes()) { if (tp->get_uid() == uid) return tp; } @@ -105,7 +101,7 @@ Node *Tree::find_by_uid(unsigned short uid) { \param[in] crsr cursor position in text \return the node we found or 0 */ -Node *Tree::find_in_text(int text_type, int crsr) { +Node *fld::node::Tree::find_in_text(int text_type, int crsr) { for (Node *node: all_nodes()) { switch (text_type) { case 0: diff --git a/fluid/nodes/Widget_Node.cxx b/fluid/nodes/Widget_Node.cxx index d5d256dbe..757155335 100644 --- a/fluid/nodes/Widget_Node.cxx +++ b/fluid/nodes/Widget_Node.cxx @@ -51,8 +51,6 @@ #define MAX(a,b) ((a)>=(b) ? (a) : (b)) #endif -using namespace fld; -using namespace fld::proj; extern void redraw_browser(); @@ -386,7 +384,8 @@ void name_public_cb(Fl_Choice* i, void* v) { i->show(); } else { int mod = 0; - for (Node* o = Fluid.proj.tree.first; o; o = o->next) { + Node *o; + for (o = Fluid.proj.tree.first; o; o = o->next) { if (o->selected && o->is_widget()) { ((Widget_Node*)o)->public_ = i->value(); mod = 1; @@ -433,7 +432,8 @@ void label_cb(Fl_Input* i, void* v) { if (i->changed()) { Fluid.proj.undo.suspend(); int mod = 0; - for (Node* o = Fluid.proj.tree.first; o; o = o->next) { + Node *o; + for (o = Fluid.proj.tree.first; o; o = o->next) { if (o->selected && o->is_widget()) { if (!mod) { if (first_change) { @@ -724,7 +724,8 @@ Fl_Menu_Item boxmenu[] = { const char* boxname(int i) { if (!i) i = ZERO_ENTRY; - for (int j = 0; j < int(sizeof(boxmenu)/sizeof(*boxmenu)); j++) + int j; + for (j = 0; j < int(sizeof(boxmenu)/sizeof(*boxmenu)); j++) if (boxmenu[j].argument() == i) return boxmenu[j].label(); return 0; @@ -733,7 +734,8 @@ const char* boxname(int i) { int boxnumber(const char* i) { if (i[0]=='F' && i[1]=='L' && i[2]=='_') i += 3; - for (int j = 0; j < int(sizeof(boxmenu)/sizeof(*boxmenu)); j++) + int j; + for (j = 0; j < int(sizeof(boxmenu)/sizeof(*boxmenu)); j++) if (boxmenu[j].label() && !strcmp(boxmenu[j].label(), i)) { return int(boxmenu[j].argument()); } @@ -896,7 +898,8 @@ void labeltype_cb(Fl_Choice* i, void* v) { if (v == LOAD) { int n = current_widget->o->labeltype(); i->when(FL_WHEN_RELEASE); - for (int j = 0; j < int(sizeof(labeltypemenu)/sizeof(*labeltypemenu)); j++) { + int j; + for (j = 0; j < int(sizeof(labeltypemenu)/sizeof(*labeltypemenu)); j++) { if (labeltypemenu[j].argument() == n) { i->value(j); break; @@ -908,7 +911,8 @@ void labeltype_cb(Fl_Choice* i, void* v) { int n = int(labeltypemenu[m].argument()); if (n<0) return; // should not happen - for (Node* o = Fluid.proj.tree.first; o; o = o->next) { + Node *o; + for (o = Fluid.proj.tree.first; o; o = o->next) { if (o->selected && o->is_widget()) { Widget_Node* p = (Widget_Node*)o; p->o->labeltype((Fl_Labeltype)n); @@ -943,7 +947,8 @@ Fl_Menu_Item colormenu[] = { void color_common(Fl_Color c) { int mod = 0; - for (Node* o = Fluid.proj.tree.first; o; o = o->next) { + Node *o; + for (o = Fluid.proj.tree.first; o; o = o->next) { if (o->selected && o->is_widget()) { Widget_Node* q = (Widget_Node*)o; q->o->color(c); q->o->redraw(); @@ -963,7 +968,8 @@ void color_common(Fl_Color c) { void color2_common(Fl_Color c) { int mod = 0; - for (Node* o = Fluid.proj.tree.first; o; o = o->next) { + Node *o; + for (o = Fluid.proj.tree.first; o; o = o->next) { if (o->selected && o->is_widget()) { Widget_Node* q = (Widget_Node*)o; q->o->selection_color(c); q->o->redraw(); @@ -978,7 +984,8 @@ void color2_common(Fl_Color c) { void labelcolor_common(Fl_Color c) { int mod = 0; - for (Node* o = Fluid.proj.tree.first; o; o = o->next) { + Node *o; + for (o = Fluid.proj.tree.first; o; o = o->next) { if (o->selected && o->is_widget()) { Widget_Node* q = (Widget_Node*)o; q->o->labelcolor(c); q->redraw(); @@ -1029,7 +1036,8 @@ void align_cb(Fl_Button* i, void* v) { } else { int mod = 0; Fluid.proj.undo.checkpoint(); - for (Node* o = Fluid.proj.tree.first; o; o = o->next) { + Node *o; + for (o = Fluid.proj.tree.first; o; o = o->next) { if (o->selected && o->is_widget()) { Widget_Node* q = (Widget_Node*)o; Fl_Align x = q->o->align(); @@ -1079,7 +1087,8 @@ void align_position_cb(Fl_Choice* i, void* v) { Fl_Align b = Fl_Align(fl_uintptr_t(mi->user_data())); int mod = 0; Fluid.proj.undo.checkpoint(); - for (Node* o = Fluid.proj.tree.first; o; o = o->next) { + Node *o; + for (o = Fluid.proj.tree.first; o; o = o->next) { if (o->selected && o->is_widget()) { Widget_Node* q = (Widget_Node*)o; Fl_Align x = q->o->align(); @@ -1114,7 +1123,8 @@ void align_text_image_cb(Fl_Choice* i, void* v) { Fl_Align b = Fl_Align(fl_uintptr_t(mi->user_data())); int mod = 0; Fluid.proj.undo.checkpoint(); - for (Node* o = Fluid.proj.tree.first; o; o = o->next) { + Node *o; + for (o = Fluid.proj.tree.first; o; o = o->next) { if (o->selected && o->is_widget()) { Widget_Node* q = (Widget_Node*)o; Fl_Align x = q->o->align(); @@ -1156,7 +1166,8 @@ int Widget_Node::textstuff(int, Fl_Font&, int&, Fl_Color&) { void textcolor_common(Fl_Color c) { Fl_Font n; int s; int mod = 0; - for (Node* o = Fluid.proj.tree.first; o; o = o->next) { + Node *o; + for (o = Fluid.proj.tree.first; o; o = o->next) { if (o->selected && o->is_widget()) { Widget_Node* q = (Widget_Node*)o; q->textstuff(3,n,s,c); q->o->redraw(); @@ -1245,7 +1256,8 @@ Fl_Menu_Item* Widget_Node::subtypes() { return 0; } void propagate_load(Fl_Group* g, void* v) { if (v == LOAD) { Fl_Widget*const* a = g->array(); - for (int i=g->children(); i--;) { + int i; + for (i =g->children(); i--;) { Fl_Widget* o = *a++; o->do_callback(o, LOAD, FL_REASON_USER); } @@ -1255,7 +1267,8 @@ void propagate_load(Fl_Group* g, void* v) { void set_cb(Fl_Button*, void*) { haderror = 0; Fl_Widget*const* a = the_panel->array(); - for (int i=the_panel->children(); i--;) { + int i; + for (i =the_panel->children(); i--;) { Fl_Widget* o = *a++; if (o->changed()) { o->do_callback(); @@ -1391,7 +1404,8 @@ void load_panel() { current_node = 0; if (Fluid.proj.tree.current->is_widget()) current_widget=(Widget_Node*)Fluid.proj.tree.current; - for (Node* o = Fluid.proj.tree.first; o; o = o->next) { + Node *o; + for (o = Fluid.proj.tree.first; o; o = o->next) { if (o->is_widget() && o->selected) { numselected++; if (!current_widget) current_widget = (Widget_Node*)o; @@ -1468,12 +1482,13 @@ extern void update_codeview_position(); // old panel in that case, as the object may no longer exist) void selection_changed(Node* p) { // store all changes to the current selected objects: + Node *o; if (p && the_panel && the_panel->visible()) { set_cb(0,0); // if there was an error, we try to leave the selected set unchanged: if (haderror) { Node* q = 0; - for (Node* o = Fluid.proj.tree.first; o; o = o->next) { + for (o = Fluid.proj.tree.first; o; o = o->next) { o->new_selected = o->selected; if (!q && o->selected) q = o; } @@ -1485,7 +1500,7 @@ void selection_changed(Node* p) { } // update the selected flags to new set: Node* q = 0; - for (Node* o = Fluid.proj.tree.first; o; o = o->next) { + for (o = Fluid.proj.tree.first; o; o = o->next) { o->selected = o->new_selected; if (!q && o->selected) q = o; } @@ -1626,7 +1641,8 @@ void Widget_Node::write_static(fld::io::Code_Writer& f) { f.write_c("void %s::%s(%s* o, %s v) {\n", k, cn, t, ut); f.write_c("%s((%s*)(o", f.indent(1), k); Node* q = 0; - for (Node* p = parent; p && p->is_widget(); q = p, p = p->parent) + Node *p; + for (p = parent; p && p->is_widget(); q = p, p = p->parent) f.write_c("->parent()"); if (!q || !q->is_a(FLD_NODE_TYPE_Widget_Class)) f.write_c("->user_data()"); @@ -2018,7 +2034,8 @@ void Widget_Node::write_widget_code(fld::io::Code_Writer& f) { } void Widget_Node::write_extra_code(fld::io::Code_Writer& f) { - for (int n=0; n < NUM_EXTRA_CODE; n++) + int n; + for (n =0; n < NUM_EXTRA_CODE; n++) if (extra_code(n) && extra_code(n)[0] && !isdeclare(extra_code(n))) f.write_c("%s%s\n", f.indent(), extra_code(n)); } @@ -2158,7 +2175,8 @@ void Widget_Node::write_properties(fld::io::Project_Writer &f) { if (resizable()) f.write_string("resizable"); if (hotspot()) f.write_string(is_a(FLD_NODE_TYPE_Menu_Item) ? "divider" : "hotspot"); if (menu_headline()) f.write_string("headline"); - for (int n=0; n < NUM_EXTRA_CODE; n++) if (extra_code(n) && extra_code(n)[0]) { + int n; + for (n =0; n < NUM_EXTRA_CODE; n++) if (extra_code(n) && extra_code(n)[0]) { f.write_indent(level+1); f.write_string("code%d",n); f.write_word(extra_code(n)); diff --git a/fluid/nodes/Window_Node.cxx b/fluid/nodes/Window_Node.cxx index 9a53d2ecb..5cdda615d 100644 --- a/fluid/nodes/Window_Node.cxx +++ b/fluid/nodes/Window_Node.cxx @@ -163,8 +163,9 @@ void Overlay_Window::draw() { if ((damage()&FL_DAMAGE_ALL) && (!box() || (box()>=4&&!(box()&2)) || box()>=FL_ROUNDED_BOX)) { // if so, draw checkerboard so user can see what areas are clear: - for (int Y = 0; Y < h(); Y += CHECKSIZE) - for (int X = 0; X < w(); X += CHECKSIZE) { + int Y, X; + for (Y = 0; Y < h(); Y += CHECKSIZE) + for (X = 0; X < w(); X += CHECKSIZE) { fl_color(((Y/(2*CHECKSIZE))&1) != ((X/(2*CHECKSIZE))&1) ? FL_WHITE : FL_BLACK); fl_rectf(X,Y,CHECKSIZE,CHECKSIZE); @@ -402,7 +403,8 @@ void Window_Node::newdx() { if (Fluid.show_guides && (drag & (FD_DRAG|FD_TOP|FD_LEFT|FD_BOTTOM|FD_RIGHT))) { Node *selection = 0; // special power for the first selected widget - for (Node *q=next; q && q->level>level; q = q->next) { + Node *q; + for (q =next; q && q->level>level; q = q->next) { if (q->selected && q->is_true_widget()) { selection = q; break; @@ -492,7 +494,8 @@ void fd_hatch(int x, int y, int w, int h, int size=6, int offset=0, int pad=3) { \param[in] x, y, w, h bounding box of this group */ void Window_Node::draw_out_of_bounds(Widget_Node *group, int x, int y, int w, int h) { - for (Node *p = group->next; p && p->level>group->level; p = p->next) { + Node *p; + for (p = group->next; p && p->level>group->level; p = p->next) { if (p->level == group->level+1 && p->is_true_widget()) { Fl_Widget *o = ((Widget_Node*)p)->o; if (o->x() < x) fd_hatch(o->x(), o->y(), x-o->x(), o->h()); @@ -510,7 +513,8 @@ void Window_Node::draw_out_of_bounds() { // get every group in the hierarchy, then draw any overlap of a direct child with that group fl_color(FL_DARK_RED); draw_out_of_bounds(this, 0, 0, o->w(), o->h()); - for (Node *q=next; q && q->level>level; q = q->next) { + Node *q; + for (q =next; q && q->level>level; q = q->next) { // don't do this for Fl_Scroll (which we currently can't handle in FLUID anyway) if (q->is_a(FLD_NODE_TYPE_Group) && !q->is_a(FLD_NODE_TYPE_Scroll)) { Widget_Node *w = (Widget_Node*)q; @@ -526,7 +530,8 @@ void Window_Node::draw_out_of_bounds() { void Window_Node::draw_overlaps() { fl_color(FL_DARK_YELLOW); // loop through all widgets in this window - for (Node *q=next; q && q->level>level; q = q->next) { + Node *q; + for (q =next; q && q->level>level; q = q->next) { // is it a valid widget if (q->is_true_widget()) { Widget_Node *w = (Widget_Node*)q; @@ -534,7 +539,8 @@ void Window_Node::draw_overlaps() { if (w->o->visible()) { int x = w->o->x(), y = w->o->y(); int r = x + w->o->w(), b = y + w->o->h(); - for (Node *p=q->next; p && p->level>=q->level; p = p->next) { + Node *p; + for (p =q->next; p && p->level>=q->level; p = p->next) { if (p->level==q->level && p->is_true_widget()) { Widget_Node *wp = (Widget_Node*)p; if (wp->o->visible()) { @@ -557,10 +563,11 @@ void Window_Node::draw_overlaps() { } void Window_Node::draw_overlay() { + Node *q; if (recalc) { bx = o->w(); by = o->h(); br = 0; bt = 0; numselected = 0; - for (Node *q=next; q && q->level>level; q=q->next) + for (q =next; q && q->level>level; q=q->next) if (q->selected && q->is_true_widget()) { numselected++; Widget_Node* myo = (Widget_Node*)q; @@ -592,7 +599,7 @@ void Window_Node::draw_overlay() { int mysx,mysy,mysr,myst; mybx = mysx = o->w(); myby = mysy = o->h(); mybr = mysr = 0; mybt = myst = 0; Node *selection = 0; // special power for the first selected widget - for (Node *q=next; q && q->level>level; q = q->next) + for (q =next; q && q->level>level; q = q->next) if (q->selected && q->is_true_widget()) { if (!selection) selection = q; Widget_Node* myo = (Widget_Node*)q; @@ -674,7 +681,8 @@ void Window_Node::fix_overlay() { void check_redraw_corresponding_parent(Node *s) { Widget_Node * prev_parent = 0; if( !s || !s->selected || !s->is_widget()) return; - for (Node *i=s; i && i->parent; i=i->parent) { + Node *i; + for (i =s; i && i->parent; i=i->parent) { if (i->is_a(FLD_NODE_TYPE_Group) && prev_parent) { if (i->is_a(FLD_NODE_TYPE_Tabs)) { ((Fl_Tabs*)((Widget_Node*)i)->o)->value(prev_parent->o); @@ -692,7 +700,8 @@ void check_redraw_corresponding_parent(Node *s) { // do that for every window (when selected set changes): void redraw_overlays() { - for (Node *o=Fluid.proj.tree.first; o; o=o->next) + Node *o; + for (o =Fluid.proj.tree.first; o; o=o->next) if (o->is_a(FLD_NODE_TYPE_Window)) ((Window_Node*)o)->fix_overlay(); } @@ -707,7 +716,8 @@ void toggle_overlays(Fl_Widget *,void *) { if (overlay_button) overlay_button->label("Hide &Overlays"); } - for (Node *o=Fluid.proj.tree.first; o; o=o->next) + Node *o; + for (o =Fluid.proj.tree.first; o; o=o->next) if (o->is_a(FLD_NODE_TYPE_Window)) { Widget_Node* w = (Widget_Node*)o; ((Overlay_Window*)(w->o))->redraw_overlay(); @@ -730,7 +740,8 @@ void toggle_guides(Fl_Widget *,void *) { if (guides_button) guides_button->value(Fluid.show_guides); - for (Node *o=Fluid.proj.tree.first; o; o=o->next) { + Node *o; + for (o =Fluid.proj.tree.first; o; o=o->next) { if (o->is_a(FLD_NODE_TYPE_Window)) { Widget_Node* w = (Widget_Node*)o; ((Overlay_Window*)(w->o))->redraw_overlay(); @@ -762,7 +773,8 @@ void toggle_restricted(Fl_Widget *,void *) { if (restricted_button) restricted_button->value(Fluid.show_restricted); - for (Node *o=Fluid.proj.tree.first; o; o=o->next) { + Node *o; + for (o =Fluid.proj.tree.first; o; o=o->next) { if (o->is_a(FLD_NODE_TYPE_Window)) { Widget_Node* w = (Widget_Node*)o; ((Overlay_Window*)(w->o))->redraw_overlay(); @@ -776,7 +788,8 @@ void toggle_restricted(Fl_Widget *,void *) { void toggle_ghosted_outline_cb(Fl_Check_Button *,void *) { Fluid.show_ghosted_outline = !Fluid.show_ghosted_outline; Fluid.preferences.set("Fluid.show_ghosted_outline", Fluid.show_ghosted_outline); - for (Node *o=Fluid.proj.tree.first; o; o=o->next) { + Node *o; + for (o =Fluid.proj.tree.first; o; o=o->next) { if (o->is_a(FLD_NODE_TYPE_Window)) { Widget_Node* w = (Widget_Node*)o; ((Overlay_Window*)(w->o))->redraw(); @@ -914,6 +927,8 @@ int Window_Node::popupy = 0x7FFFFFFF; int Window_Node::handle(int event) { static Node* selection = 0; + Node *i; + Fl_Widget *o1; switch (event) { case FL_DND_ENTER: // printf("DND enter\n"); @@ -922,7 +937,7 @@ int Window_Node::handle(int event) { { // find the innermost item clicked on: selection = this; - for (Node* i=next; i && i->level>level; i=i->next) + for (i =next; i && i->level>level; i=i->next) if (i->is_a(FLD_NODE_TYPE_Group)) { Widget_Node* myo = (Widget_Node*)i; if (Fl::event_inside(myo->o) && myo->o->visible_r()) { @@ -974,7 +989,7 @@ int Window_Node::handle(int event) { // ok, so it is an image - now add it as image() or deimage() to the widget // printf("DND check for target %s\n", fn); Widget_Node *tgt = 0; - for (Node* i=next; i && i->level>level; i=i->next) { + for (i =next; i && i->level>level; i=i->next) { if (i->is_widget()) { Widget_Node* myo = (Widget_Node*)i; if (Fl::event_inside(myo->o) && myo->o->visible_r()) @@ -1044,10 +1059,10 @@ int Window_Node::handle(int event) { } // find the innermost item clicked on: selection = this; - {for (Node* i=next; i && i->level>level; i=i->next) + {for (i =next; i && i->level>level; i=i->next) if (i->is_true_widget()) { Widget_Node* myo = (Widget_Node*)i; - for (Fl_Widget *o1 = myo->o; o1; o1 = o1->parent()) + for (o1 = myo->o; o1; o1 = o1->parent()) if (!o1->visible()) goto CONTINUE2; if (Fl::event_inside(myo->o)) { selection = myo; @@ -1107,10 +1122,10 @@ int Window_Node::handle(int event) { // clear selection on everything: if (!toggle) deselect(); else Fl::event_is_click(0); // select everything in box: - for (Node*i=next; i&&i->level>level; i=i->next) + for (i =next; i&&i->level>level; i=i->next) if (i->is_true_widget()) { Widget_Node* myo = (Widget_Node*)i; - for (Fl_Widget *o1 = myo->o; o1; o1 = o1->parent()) + for (o1 = myo->o; o1; o1 = o1->parent()) if (!o1->visible()) goto CONTINUE; if (Fl::event_inside(myo->o)) selection = myo; if (myo && myo->o && myo->o->x()>=x1 && myo->o->y()>y1 && diff --git a/fluid/nodes/factory.cxx b/fluid/nodes/factory.cxx index 7e6726a41..c901c9945 100644 --- a/fluid/nodes/factory.cxx +++ b/fluid/nodes/factory.cxx @@ -158,7 +158,8 @@ public: // Avoid this when compiling so it works w/o a display: if (!Fluid.batch_mode) { char buffer[20]; - for (int i = 1; i <= 20; i++) { + int i; + for (i = 1; i <= 20; i++) { sprintf(buffer,"Browser Line %d",i); b->add(buffer); } @@ -193,7 +194,8 @@ public: // Avoid this when compiling so it works w/o a display: if (!Fluid.batch_mode) { char buffer[20]; - for (int i = 1; i <= 20; i++) { + int i; + for (i = 1; i <= 20; i++) { sprintf(buffer,"Browser Line %d",i); b->add(buffer); } @@ -1560,7 +1562,8 @@ static void make_iconlabel(Fl_Menu_Item *mi, Fl_Image *ic, const char *txt) Names and icons are taken from the referenced prototypes. */ void fill_in_New_Menu() { - for (unsigned i = 0; i < sizeof(New_Menu)/sizeof(*New_Menu); i++) { + unsigned i; + for (i = 0; i < sizeof(New_Menu)/sizeof(*New_Menu); i++) { Fl_Menu_Item *m = New_Menu+i; if (m->user_data()) { Node *t = (Node*)m->user_data(); @@ -1586,7 +1589,8 @@ Node *typename_to_prototype(const char *inName) { if (inName==0 || *inName==0) return 0; - for (unsigned i = 0; i < sizeof(known_types)/sizeof(*known_types); i++) { + unsigned i; + for (i = 0; i < sizeof(known_types)/sizeof(*known_types); i++) { Node *prototype = known_types[i]; if (fl_ascii_strcasecmp(inName, prototype->type_name())==0) return prototype; @@ -1774,7 +1778,8 @@ static symbol table[] = { int lookup_symbol(const char *name, int &v, int numberok) { if ((name[0]=='F') && (name[1]=='L') && (name[2]=='_')) name += 3; - for (int i=0; i < int(sizeof(table)/sizeof(*table)); i++) { + int i; + for (i =0; i < int(sizeof(table)/sizeof(*table)); i++) { if (!fl_ascii_strcasecmp(name,table[i].name)) { v = table[i].value; return 1; diff --git a/fluid/panels/settings_panel.cxx b/fluid/panels/settings_panel.cxx index 04aa8e900..66df11816 100644 --- a/fluid/panels/settings_panel.cxx +++ b/fluid/panels/settings_panel.cxx @@ -545,13 +545,14 @@ Fl_Menu_Button *w_layout_menu=(Fl_Menu_Button *)0; static void cb_w_layout_menu(Fl_Menu_Button*, void* v) { if (v == LOAD) { fld::app::Layout_Suite &suite = (*Fluid.layout_list)[Fluid.layout_list->current_suite()]; + int i; if (suite.storage_ == FLD_TOOL_STORE_INTERNAL) { w_layout_menu_rename->deactivate(); - for (int i=1; i<4; i++) w_layout_menu_storage[i]->deactivate(); + for (i =1; i<4; i++) w_layout_menu_storage[i]->deactivate(); w_layout_menu_delete->deactivate(); } else { w_layout_menu_rename->activate(); - for (int i=1; i<4; i++) w_layout_menu_storage[i]->activate(); + for (i =1; i<4; i++) w_layout_menu_storage[i]->activate(); w_layout_menu_delete->activate(); } w_layout_menu_storage[(int)(suite.storage_)]->setonly(menu_w_layout_menu); @@ -889,7 +890,8 @@ static void cb_w_settings_shell_list(Fl_Browser* o, void* v) { if (g_shell_config) { o->clear(); w_settings_shell_list_selected = 0; - for (int i=0; ilist_size; i++) { + int i; + for (i =0; ilist_size; i++) { Fd_Shell_Command *cmd = g_shell_config->list[i]; o->add(cmd->name); if (cmd->storage == FLD_TOOL_STORE_USER) diff --git a/fluid/panels/widget_panel.cxx b/fluid/panels/widget_panel.cxx index 1f60bc178..33720b5ac 100644 --- a/fluid/panels/widget_panel.cxx +++ b/fluid/panels/widget_panel.cxx @@ -101,7 +101,8 @@ static void cb_image_panel_imagew(fld::widget::Formula_Input* o, void* v) { } } else { int mod = 0; - for (Node *t = Fluid.proj.tree.first; t; t = t->next) { + Node *t; + for (t = Fluid.proj.tree.first; t; t = t->next) { if (t->selected && t->is_widget()) { Widget_Node* wt = ((Widget_Node*)t); wt->scale_image_w_ = o->value(); @@ -133,7 +134,8 @@ static void cb_image_panel_imageh(fld::widget::Formula_Input* o, void* v) { } } else { int mod = 0; - for (Node *t = Fluid.proj.tree.first; t; t = t->next) { + Node *t; + for (t = Fluid.proj.tree.first; t; t = t->next) { if (t->selected && t->is_widget()) { Widget_Node* wt = ((Widget_Node*)t); wt->scale_image_h_ = o->value(); @@ -241,7 +243,8 @@ static void cb_image_panel_deimagew(fld::widget::Formula_Input* o, void* v) { } } else { int mod = 0; - for (Node *t = Fluid.proj.tree.first; t; t = t->next) { + Node *t; + for (t = Fluid.proj.tree.first; t; t = t->next) { if (t->selected && t->is_widget()) { Widget_Node* wt = ((Widget_Node*)t); wt->scale_deimage_w_ = o->value(); @@ -273,7 +276,8 @@ static void cb_image_panel_deimageh(fld::widget::Formula_Input* o, void* v) { } } else { int mod = 0; - for (Node *t = Fluid.proj.tree.first; t; t = t->next) { + Node *t; + for (t = Fluid.proj.tree.first; t; t = t->next) { if (t->selected && t->is_widget()) { Widget_Node* wt = ((Widget_Node*)t); wt->scale_deimage_h_ = o->value(); @@ -555,7 +559,8 @@ void flex_margin_cb(Fl_Value_Input* i, void* v, void (*load_margin)(Fl_Flex*,Fl_ } else { int mod = 0; int new_value = (int)i->value(); - for (Node *o = Fluid.proj.tree.first; o; o = o->next) { + Node *o; + for (o = Fluid.proj.tree.first; o; o = o->next) { if (o->selected && o->is_a(FLD_NODE_TYPE_Flex)) { Flex_Node* q = (Flex_Node*)o; Fl_Flex* w = (Fl_Flex*)q->o; @@ -1654,7 +1659,8 @@ static void cb_Hotspot(Fl_Light_Button* o, void* v) { Node *p = current_widget->parent; if (!p || !p->is_widget()) return; while (!p->is_a(FLD_NODE_TYPE_Window)) p = p->parent; - for (Node *q = p->next; q && q->level > p->level; q = q->next) { + Node *q; + for (q = p->next; q && q->level > p->level; q = q->next) { if (q->is_widget() && q != current_widget) ((Widget_Node*)q)->hotspot(0); } @@ -1771,7 +1777,8 @@ static void cb_7(Fl_Choice* o, void* v) { if (current_widget->is_a(FLD_NODE_TYPE_Menu_Item)) {o->deactivate(); return;} else o->activate(); int n = current_widget->o->box(); if (!n) n = ZERO_ENTRY; - for (int j = 0; j < 72 /*int(sizeof(boxmenu)/sizeof(*boxmenu))*/; j++) + int j; + for (j = 0; j < 72 /*int(sizeof(boxmenu)/sizeof(*boxmenu))*/; j++) if (boxmenu[j].argument() == n) {o->value(j); break;} } else { int mod = 0; @@ -1846,7 +1853,8 @@ static void cb_9(Fl_Choice* o, void* v) { } o->activate(); if (!n) n = ZERO_ENTRY; - for (int j = 0; j < 72 /*int(sizeof(boxmenu)/sizeof(*boxmenu))*/; j++) + int j; + for (j = 0; j < 72 /*int(sizeof(boxmenu)/sizeof(*boxmenu))*/; j++) if (boxmenu[j].argument() == n) {o->value(j); break;} } else { int mod = 0; @@ -2711,7 +2719,8 @@ static void cb_comment_predefined_2(Fl_Menu_Button* o, void* v) { "My Comment"); if (xname) { char *name = fl_strdup(xname); - for (char*s=name;*s;s++) if (*s==':') *s = ';'; + char *s; + for (s =name;*s;s++) if (*s==':') *s = ';'; int n; Fl_Preferences db(Fl_Preferences::USER_L, "fltk.org", "fluid_comments"); db.set(name, comment_tabs_name->buffer()->text()); diff --git a/fluid/proj/align_widget.cxx b/fluid/proj/align_widget.cxx index 8056de429..0877c35f0 100644 --- a/fluid/proj/align_widget.cxx +++ b/fluid/proj/align_widget.cxx @@ -52,7 +52,8 @@ void align_widget_cb(Fl_Widget*, void *user_data) BREAK_ON_FIRST; } if (left!=max) - for (Node *o = Fluid.proj.tree.first; o; o = o->next) + Node *o; + for (o = Fluid.proj.tree.first; o; o = o->next) if (o->selected && o->is_widget()) { if (!changed) { @@ -82,7 +83,7 @@ void align_widget_cb(Fl_Widget*, void *user_data) if (left!=max) { int center2 = left+right; - for (Node *o = Fluid.proj.tree.first; o; o = o->next) + for (o = Fluid.proj.tree.first; o; o = o->next) if (o->selected && o->is_widget()) { if (!changed) { @@ -109,7 +110,7 @@ void align_widget_cb(Fl_Widget*, void *user_data) BREAK_ON_FIRST; } if (right!=min) - for (Node *o = Fluid.proj.tree.first; o; o = o->next) + for (o = Fluid.proj.tree.first; o; o = o->next) if (o->selected && o->is_widget()) { if (!changed) { @@ -135,7 +136,7 @@ void align_widget_cb(Fl_Widget*, void *user_data) BREAK_ON_FIRST; } if (top!=max) - for (Node *o = Fluid.proj.tree.first; o; o = o->next) + for (o = Fluid.proj.tree.first; o; o = o->next) if (o->selected && o->is_widget()) { if (!changed) { @@ -165,7 +166,7 @@ void align_widget_cb(Fl_Widget*, void *user_data) if (top!=max) { int center2 = top+bot; - for (Node *o = Fluid.proj.tree.first; o; o = o->next) + for (o = Fluid.proj.tree.first; o; o = o->next) if (o->selected && o->is_widget()) { if (!changed) { @@ -192,7 +193,7 @@ void align_widget_cb(Fl_Widget*, void *user_data) BREAK_ON_FIRST; } if (bot!=min) - for (Node *o = Fluid.proj.tree.first; o; o = o->next) + for (o = Fluid.proj.tree.first; o; o = o->next) if (o->selected && o->is_widget()) { if (!changed) { @@ -227,7 +228,7 @@ void align_widget_cb(Fl_Widget*, void *user_data) { wdt = wdt/n*n; // make sure that all gaps are the same, possibly moving the rightmost widget int cnt = 0, wsum = 0; - for (Node *o = Fluid.proj.tree.first; o; o = o->next) + for (o = Fluid.proj.tree.first; o; o = o->next) if (o->selected && o->is_widget()) { if (!changed) { @@ -264,7 +265,7 @@ void align_widget_cb(Fl_Widget*, void *user_data) { hgt = hgt/n*n; // make sure that all gaps are the same, possibly moving the rightmost widget int cnt = 0, hsum = 0; - for (Node *o = Fluid.proj.tree.first; o; o = o->next) + for (o = Fluid.proj.tree.first; o; o = o->next) if (o->selected && o->is_widget()) { if (!changed) { @@ -294,7 +295,7 @@ void align_widget_cb(Fl_Widget*, void *user_data) BREAK_ON_FIRST; } if (wdt!=min) - for (Node *o = Fluid.proj.tree.first; o; o = o->next) + for (o = Fluid.proj.tree.first; o; o = o->next) if (o->selected && o->is_widget()) { if (!changed) { @@ -320,7 +321,7 @@ void align_widget_cb(Fl_Widget*, void *user_data) BREAK_ON_FIRST; } if (hgt!=min) - for (Node *o = Fluid.proj.tree.first; o; o = o->next) + for (o = Fluid.proj.tree.first; o; o = o->next) if (o->selected && o->is_widget()) { if (!changed) { @@ -348,7 +349,7 @@ void align_widget_cb(Fl_Widget*, void *user_data) BREAK_ON_FIRST; } if (hgt!=min) - for (Node *o = Fluid.proj.tree.first; o; o = o->next) + for (o = Fluid.proj.tree.first; o; o = o->next) if (o->selected && o->is_widget()) { if (!changed) { diff --git a/fluid/proj/mergeback.cxx b/fluid/proj/mergeback.cxx index bb7ef5504..2d553aedb 100644 --- a/fluid/proj/mergeback.cxx +++ b/fluid/proj/mergeback.cxx @@ -304,7 +304,8 @@ void Mergeback::analyse_code(unsigned long code_crc, unsigned long tag_crc, int */ uint32_t Mergeback::decode_trichar32(const char *text) { uint32_t word = 0; - for (int i=30; i>=0; i-=3) { + int i; + for (i =30; i>=0; i-=3) { char a = *text++; if (a==0) break; char b = *text++; @@ -335,7 +336,8 @@ uint32_t Mergeback::decode_trichar32(const char *text) { */ void Mergeback::print_trichar32(FILE *out, uint32_t value) { static const char *lut[] = { "--", "-~", "~-", "~~", "-=", "=-", "~=", "=~" }; - for (int i=30; i>=0; i-=3) fputs(lut[(value>>i)&7], out); + int i; + for (i =30; i>=0; i-=3) fputs(lut[(value>>i)&7], out); } /** @@ -365,7 +367,8 @@ bool Mergeback::read_tag(const char *tag, Tag *prev_type, uint16_t *uid, uint32_ if (strncmp(tag, "▼", 3)==0) tag += 3; // E2 96 BC if (*tag==' ') tag += 1; uint32_t w1 = decode_trichar32(tag); // Read the first word - for (int i=0; i<32; i++) if (*tag++ == 0) return false; + int i; + for (i =0; i<32; i++) if (*tag++ == 0) return false; uint32_t w2 = decode_trichar32(tag); // Read the second word // Return the decoded values *prev_type = static_cast((w1>>16) & 0xff); diff --git a/fluid/proj/undo.cxx b/fluid/proj/undo.cxx index e4ee89bf6..d3444c91a 100644 --- a/fluid/proj/undo.cxx +++ b/fluid/proj/undo.cxx @@ -47,15 +47,11 @@ extern Fl_Window* the_panel; -using namespace fld; -using namespace fld::proj; - - -Undo::Undo(Project &p) +fld::proj::Undo::Undo(fld::Project &p) : proj_( p ) { } -Undo::~Undo() { +fld::proj::Undo::~Undo() { // TODO: delete old undo files when calling the destructor. } @@ -64,7 +60,7 @@ Undo::~Undo() { // The filename is constructed in a static internal buffer and // this buffer is overwritten by every call of this function. // The return value is a pointer to this internal string. -char *Undo::filename(int level) { +char *fld::proj::Undo::filename(int level) { if (!path_len_) { Fluid.preferences.getUserdataPath(path_, sizeof(path_)); path_len_ = (unsigned int)strlen(path_); @@ -79,7 +75,7 @@ char *Undo::filename(int level) { // Redo menu callback -void Undo::redo() { +void fld::proj::Undo::redo() { // int undo_item = main_menubar->find_index(undo_cb); // int redo_item = main_menubar->find_index(redo_cb); once_type_ = FLD_UNDO_ONCETYPE_ALWAYS; @@ -123,7 +119,7 @@ void Undo::redo() { } // Undo menu callback -void Undo::undo() { +void fld::proj::Undo::undo() { // int undo_item = main_menubar->find_index(undo_cb); // int redo_item = main_menubar->find_index(redo_cb); once_type_ = FLD_UNDO_ONCETYPE_ALWAYS; @@ -155,7 +151,8 @@ void Undo::undo() { return; } if (reload_panel) { - for (Node *t = Fluid.proj.tree.first; t; t=t->next) { + Node *t; + for (t = Fluid.proj.tree.first; t; t=t->next) { if (t->is_widget() && t->selected) { t->open(); break; @@ -183,7 +180,7 @@ void Undo::undo() { \param[in] type set a new type, or set to 0 to clear the once_type without setting a checkpoint \return 1 if the checkpoint was set, 0 if this is a repeating event */ -int Undo::checkpoint(OnceType type) { +int fld::proj::Undo::checkpoint(OnceType type) { if (type == FLD_UNDO_ONCETYPE_ALWAYS) { once_type_ = FLD_UNDO_ONCETYPE_ALWAYS; return 0; @@ -200,7 +197,7 @@ int Undo::checkpoint(OnceType type) { } // Save current file to undo buffer -void Undo::checkpoint() { +void fld::proj::Undo::checkpoint() { // printf("checkpoint(): current_=%d, paused_=%d, modflag=%d\n", // current_, paused_, modflag); @@ -234,11 +231,12 @@ void Undo::checkpoint() { } // Clear undo buffer -void Undo::clear() { +void fld::proj::Undo::clear() { // int undo_item = main_menubar->find_index(undo_cb); // int redo_item = main_menubar->find_index(redo_cb); // Remove old checkpoint files... - for (int i = 0; i <= max_; i ++) { + int i; + for (i = 0; i <= max_; i ++) { fl_unlink(filename(i)); } @@ -253,19 +251,19 @@ void Undo::clear() { } // Resume undo checkpoints -void Undo::resume() { +void fld::proj::Undo::resume() { paused_--; } // Suspend undo checkpoints -void Undo::suspend() { +void fld::proj::Undo::suspend() { paused_++; } -void Undo::undo_cb(Fl_Widget *, void *) { +void fld::proj::Undo::undo_cb(Fl_Widget *, void *) { Fluid.proj.undo.undo(); } -void Undo::redo_cb(Fl_Widget *, void *) { +void fld::proj::Undo::redo_cb(Fl_Widget *, void *) { Fluid.proj.undo.redo(); } diff --git a/fluid/tools/ExternalCodeEditor_UNIX.cxx b/fluid/tools/ExternalCodeEditor_UNIX.cxx index 1d1efc462..f848e8158 100644 --- a/fluid/tools/ExternalCodeEditor_UNIX.cxx +++ b/fluid/tools/ExternalCodeEditor_UNIX.cxx @@ -23,8 +23,6 @@ #include /* free().. */ #include /* snprintf().. */ -using namespace fld; - // Static local data static int L_editors_open = 0; // keep track of #editors open static Fl_Timeout_Handler L_update_timer_cb = 0; // app's update timer callback diff --git a/fluid/tools/autodoc.cxx b/fluid/tools/autodoc.cxx index a59e08ab9..aaa61486e 100644 --- a/fluid/tools/autodoc.cxx +++ b/fluid/tools/autodoc.cxx @@ -125,10 +125,12 @@ void blend_alpha_left(const Fl_RGB_Image *img, int dx) { int max_x = dx, max_y = img->h(); int ld = img->ld(); if (ld == 0) ld = img->w() * img->d(); float a = 255.0f/static_cast(max_x); - for (int i = 0; i < max_x; i++) { + int i; + for (i = 0; i < max_x; i++) { uchar *rgba = (uchar*)img->data()[0] + i * img->d(); uchar alpha = static_cast(i * a); - for (int j = 0; j < max_y; j++) { + int j; + for (j = 0; j < max_y; j++) { rgba[3] = fl_min(alpha, rgba[3]); rgba += ld; } @@ -150,10 +152,12 @@ void blend_alpha_top(const Fl_RGB_Image *img, int dy) { int max_x = img->w(), max_y = dy; int ld = img->ld(); if (ld == 0) ld = img->w() * img->d(); float a = 255.0f/static_cast(max_y); - for (int i = 0; i < max_y; i++) { + int i; + for (i = 0; i < max_y; i++) { uchar *rgba = (uchar*)img->data()[0] + i * ld; uchar alpha = static_cast(i * a); - for (int j = 0; j < max_x; j++) { + int j; + for (j = 0; j < max_x; j++) { rgba[3] = fl_min(alpha, rgba[3]); rgba += 4; } @@ -175,10 +179,12 @@ void blend_alpha_right(const Fl_RGB_Image *img, int dx) { int max_x = dx, max_y = img->h(); int ld = img->ld(); if (ld == 0) ld = img->w() * img->d(); float a = 255.0f/static_cast(max_x); - for (int i = 0; i < max_x; i++) { + int i; + for (i = 0; i < max_x; i++) { uchar *rgba = (uchar*)img->data()[0] + (img->w()-i-1) * img->d(); uchar alpha = static_cast(i * a); - for (int j = 0; j < max_y; j++) { + int j; + for (j = 0; j < max_y; j++) { rgba[3] = fl_min(alpha, rgba[3]); rgba += ld; } @@ -200,10 +206,12 @@ void blend_alpha_bottom(const Fl_RGB_Image *img, int dy) { int max_x = img->w(), max_y = dy; int ld = img->ld(); if (ld == 0) ld = img->w() * img->d(); float a = 255.0f/static_cast(max_y); - for (int i = 0; i < max_y; i++) { + int i; + for (i = 0; i < max_y; i++) { uchar *rgba = (uchar*)img->data()[0] + (img->h()-i-1) * ld; uchar alpha = static_cast(i * a); - for (int j = 0; j < max_x; j++) { + int j; + for (j = 0; j < max_x; j++) { rgba[3] = fl_min(alpha, rgba[3]); rgba += 4; } diff --git a/fluid/widgets/App_Menu_Bar.cxx b/fluid/widgets/App_Menu_Bar.cxx index 9cb3e2d15..cb0dae33f 100644 --- a/fluid/widgets/App_Menu_Bar.cxx +++ b/fluid/widgets/App_Menu_Bar.cxx @@ -23,8 +23,8 @@ #include "Fluid.h" #include "Project.h" -using namespace fld; -using namespace fld::widget; + + extern void mergeback_cb(Fl_Widget *, void *); @@ -33,7 +33,7 @@ extern void mergeback_cb(Fl_Widget *, void *); \param[in] X, Y, W, H position and size of the widget \param[in] L optional label */ -App_Menu_Bar::App_Menu_Bar(int X, int Y, int W, int H, const char *L) +fld::widget::App_Menu_Bar::App_Menu_Bar(int X, int Y, int W, int H, const char *L) : Fl_Menu_Bar(X, Y, W, H, L) { } @@ -41,7 +41,7 @@ App_Menu_Bar::App_Menu_Bar(int X, int Y, int W, int H, const char *L) /** Set menu item visibility and active state before menu pops up. */ -int App_Menu_Bar::handle(int event) +int fld::widget::App_Menu_Bar::handle(int event) { Fl_Menu_Item *mi = 0; if (event == FL_BEFORE_MENU) { diff --git a/fluid/widgets/Bin_Button.cxx b/fluid/widgets/Bin_Button.cxx index 728bcc8ed..1a14433e2 100644 --- a/fluid/widgets/Bin_Button.cxx +++ b/fluid/widgets/Bin_Button.cxx @@ -24,8 +24,8 @@ #include #include -using namespace fld; -using namespace fld::widget; + + /** \class fld::widget::Bin_Button diff --git a/fluid/widgets/Code_Editor.cxx b/fluid/widgets/Code_Editor.cxx index 583d07c5b..1551ed3e2 100644 --- a/fluid/widgets/Code_Editor.cxx +++ b/fluid/widgets/Code_Editor.cxx @@ -24,8 +24,8 @@ #include #include "widgets/Code_Editor.h" -using namespace fld; -using namespace fld::widget; + + // ---- Code_Editor implementation @@ -33,7 +33,7 @@ using namespace fld::widget; Lookup table for all supported styles. Every table entry describes a rendering style for the corresponding text. */ -Fl_Text_Display::Style_Table_Entry Code_Editor::styletable[] = { // Style table +Fl_Text_Display::Style_Table_Entry fld::widget::Code_Editor::styletable[] = { // Style table { FL_FOREGROUND_COLOR, FL_COURIER, 11 }, // A - Plain { FL_DARK_GREEN, FL_COURIER_ITALIC, 11 }, // B - Line comments { FL_DARK_GREEN, FL_COURIER_ITALIC, 11 }, // C - Block comments @@ -51,7 +51,7 @@ Fl_Text_Display::Style_Table_Entry Code_Editor::styletable[] = { // Style tabl \param[in] in_len byte length to parse \param[in] in_style starting style letter */ -void Code_Editor::style_parse(const char *in_tbuff, // text buffer to parse +void fld::widget::Code_Editor::style_parse(const char *in_tbuff, // text buffer to parse char *in_sbuff, // style buffer we modify int in_len, // byte length to parse char in_style) { // starting style letter @@ -104,7 +104,7 @@ void Code_Editor::style_parse(const char *in_tbuff, // text buffer to pa /** Update unfinished styles. */ -void Code_Editor::style_unfinished_cb(int, void*) { +void fld::widget::Code_Editor::style_unfinished_cb(int, void*) { } /** @@ -114,7 +114,7 @@ void Code_Editor::style_unfinished_cb(int, void*) { \param[in] nDeleted number of bytes deleted \param[in] cbArg pointer back to the code editor */ -void Code_Editor::style_update(int pos, int nInserted, int nDeleted, +void fld::widget::Code_Editor::style_update(int pos, int nInserted, int nDeleted, int /*nRestyled*/, const char * /*deletedText*/, void *cbArg) { Code_Editor *editor = (Code_Editor*)cbArg; @@ -165,7 +165,7 @@ void Code_Editor::style_update(int pos, int nInserted, int nDeleted, Find the right indentation depth after pressing the Enter key. \param[in] e pointer back to the code editor */ -int Code_Editor::auto_indent(int, Code_Editor* e) { +int fld::widget::Code_Editor::auto_indent(int, Code_Editor* e) { if (e->buffer()->selected()) { e->insert_position(e->buffer()->primary_selection()->start()); e->buffer()->remove_selection(); @@ -203,7 +203,7 @@ int Code_Editor::auto_indent(int, Code_Editor* e) { \param[in] X, Y, W, H position and size of the widget \param[in] L optional label */ -Code_Editor::Code_Editor(int X, int Y, int W, int H, const char *L) : +fld::widget::Code_Editor::Code_Editor(int X, int Y, int W, int H, const char *L) : Fl_Text_Editor(X, Y, W, H, L) { buffer(new Fl_Text_Buffer); @@ -231,7 +231,7 @@ Code_Editor::Code_Editor(int X, int Y, int W, int H, const char *L) : /** Destroy a Code_Editor widget. */ -Code_Editor::~Code_Editor() { +fld::widget::Code_Editor::~Code_Editor() { Fl_Text_Buffer *buf = mStyleBuffer; mStyleBuffer = 0; delete buf; @@ -246,11 +246,12 @@ Code_Editor::~Code_Editor() { This works by updating the fontsizes in the style table. \param[in] s the new general height of the text font */ -void Code_Editor::textsize(Fl_Fontsize s) { +void fld::widget::Code_Editor::textsize(Fl_Fontsize s) { Fl_Text_Editor::textsize(s); // call base class method // now attempt to update our styletable to honor the new size... int entries = sizeof(styletable) / sizeof(styletable[0]); - for(int iter = 0; iter < entries; iter++) { + int iter; + for (iter = 0; iter < entries; iter++) { styletable[iter].size = s; } } // textsize diff --git a/fluid/widgets/Code_Viewer.cxx b/fluid/widgets/Code_Viewer.cxx index fdbfdc626..978ed178e 100644 --- a/fluid/widgets/Code_Viewer.cxx +++ b/fluid/widgets/Code_Viewer.cxx @@ -22,15 +22,15 @@ #include "widgets/Code_Viewer.h" -using namespace fld; -using namespace fld::widget; + + /** Create a fld::widget::Code_Viewer widget. \param[in] X, Y, W, H position and size of the widget \param[in] L optional label */ -Code_Viewer::Code_Viewer(int X, int Y, int W, int H, const char *L) +fld::widget::Code_Viewer::Code_Viewer(int X, int Y, int W, int H, const char *L) : Code_Editor(X, Y, W, H, L) { default_key_function(kf_ignore); @@ -41,7 +41,7 @@ Code_Viewer::Code_Viewer(int X, int Y, int W, int H, const char *L) /** Tricking Fl_Text_Display into using bearable colors for this specific task. */ -void Code_Viewer::draw() +void fld::widget::Code_Viewer::draw() { Fl_Color c = Fl::get_color(FL_SELECTION_COLOR); Fl::set_color(FL_SELECTION_COLOR, fl_color_average(FL_BACKGROUND_COLOR, FL_FOREGROUND_COLOR, 0.9f)); diff --git a/fluid/widgets/Formula_Input.cxx b/fluid/widgets/Formula_Input.cxx index 16bc2310a..06f5e3672 100644 --- a/fluid/widgets/Formula_Input.cxx +++ b/fluid/widgets/Formula_Input.cxx @@ -23,8 +23,8 @@ #include #include -using namespace fld; -using namespace fld::widget; + + /** \class fld::widget::Formula_Input The Formula_Input widget is an input field for entering widget coordinates @@ -36,18 +36,18 @@ using namespace fld::widget; /** Create an input field. */ -Formula_Input::Formula_Input(int x, int y, int w, int h, const char *l) +fld::widget::Formula_Input::Formula_Input(int x, int y, int w, int h, const char *l) : Fl_Input(x, y, w, h, l) { Fl_Input::callback((Fl_Callback*)callback_handler_cb); text("0"); } -void Formula_Input::callback_handler_cb(Formula_Input *This, void *v) { +void fld::widget::Formula_Input::callback_handler_cb(Formula_Input *This, void *v) { This->callback_handler(v); } -void Formula_Input::callback_handler(void *v) { +void fld::widget::Formula_Input::callback_handler(void *v) { if (user_callback_) (*user_callback_)(this, v); // do *not* update the value to show the evaluated formula here, because the @@ -63,7 +63,7 @@ void Formula_Input::callback_handler(void *v) { the last character of the variable name when returning. \return the integer value that was found or calculated */ -int Formula_Input::eval_var(uchar *&s) const { +int fld::widget::Formula_Input::eval_var(uchar *&s) const { if (!vars_) return 0; // find the end of the variable name @@ -71,7 +71,8 @@ int Formula_Input::eval_var(uchar *&s) const { while (isalpha(*s)) s++; int n = (int)(s-v); // find the variable in the list - for (Formula_Input_Vars *vars = vars_; vars->name_; vars++) { + Formula_Input_Vars *vars; + for (vars = vars_; vars->name_; vars++) { if (strncmp((char*)v, vars->name_, n)==0 && vars->name_[n]==0) return vars->callback_(this, vars_user_data_); } @@ -85,7 +86,7 @@ int Formula_Input::eval_var(uchar *&s) const { \param prio priority of current operation \return the value so far */ -int Formula_Input::eval(uchar *&s, int prio) const { +int fld::widget::Formula_Input::eval(uchar *&s, int prio) const { int v = 0, sgn = 1; uchar c = *s++; @@ -157,7 +158,7 @@ int Formula_Input::eval(uchar *&s, int prio) const { \param s formula as a C string \return the calculated value */ -int Formula_Input::eval(const char *s) const +int fld::widget::Formula_Input::eval(const char *s) const { // duplicate the text, so we can modify it uchar *buf = (uchar*)fl_strdup(s); @@ -179,14 +180,14 @@ int Formula_Input::eval(const char *s) const /** Evaluate the formula and return the result. */ -int Formula_Input::value() const { +int fld::widget::Formula_Input::value() const { return eval(text()); } /** Set the field to an integer value, replacing previous texts. */ -void Formula_Input::value(int v) { +void fld::widget::Formula_Input::value(int v) { char buf[32]; fl_snprintf(buf, sizeof(buf), "%d", v); text(buf); @@ -195,7 +196,7 @@ void Formula_Input::value(int v) { /** Allow vertical mouse dragging and mouse wheel to interactively change the value. */ -int Formula_Input::handle(int event) { +int fld::widget::Formula_Input::handle(int event) { switch (event) { case FL_MOUSEWHEEL: if (Fl::event_dy()) { @@ -211,7 +212,7 @@ int Formula_Input::handle(int event) { /** Set the list of the available variables \param vars array of variables, last entry `has name_` set to `0` \param user_data is forwarded to the Variable callback */ -void Formula_Input::variables(Formula_Input_Vars *vars, void *user_data) { +void fld::widget::Formula_Input::variables(Formula_Input_Vars *vars, void *user_data) { vars_ = vars; vars_user_data_ = user_data; } diff --git a/fluid/widgets/Node_Browser.cxx b/fluid/widgets/Node_Browser.cxx index 3343d6772..7482298b5 100644 --- a/fluid/widgets/Node_Browser.cxx +++ b/fluid/widgets/Node_Browser.cxx @@ -30,8 +30,8 @@ /// Global access to the widget browser. fld::widget::Node_Browser *widget_browser = 0; -using namespace fld; -using namespace fld::widget; + + /** @@ -49,18 +49,18 @@ using namespace fld::widget; // ---- static variables -Fl_Color Node_Browser::label_color = 72; -Fl_Font Node_Browser::label_font = FL_HELVETICA; -Fl_Color Node_Browser::class_color = FL_FOREGROUND_COLOR; -Fl_Font Node_Browser::class_font = FL_HELVETICA_BOLD; -Fl_Color Node_Browser::func_color = FL_FOREGROUND_COLOR; -Fl_Font Node_Browser::func_font = FL_HELVETICA; -Fl_Color Node_Browser::name_color = FL_FOREGROUND_COLOR; -Fl_Font Node_Browser::name_font = FL_HELVETICA; -Fl_Color Node_Browser::code_color = FL_FOREGROUND_COLOR; -Fl_Font Node_Browser::code_font = FL_HELVETICA; -Fl_Color Node_Browser::comment_color = FL_DARK_GREEN; -Fl_Font Node_Browser::comment_font = FL_HELVETICA; +Fl_Color fld::widget::Node_Browser::label_color = 72; +Fl_Font fld::widget::Node_Browser::label_font = FL_HELVETICA; +Fl_Color fld::widget::Node_Browser::class_color = FL_FOREGROUND_COLOR; +Fl_Font fld::widget::Node_Browser::class_font = FL_HELVETICA_BOLD; +Fl_Color fld::widget::Node_Browser::func_color = FL_FOREGROUND_COLOR; +Fl_Font fld::widget::Node_Browser::func_font = FL_HELVETICA; +Fl_Color fld::widget::Node_Browser::name_color = FL_FOREGROUND_COLOR; +Fl_Font fld::widget::Node_Browser::name_font = FL_HELVETICA; +Fl_Color fld::widget::Node_Browser::code_color = FL_FOREGROUND_COLOR; +Fl_Font fld::widget::Node_Browser::code_font = FL_HELVETICA; +Fl_Color fld::widget::Node_Browser::comment_color = FL_DARK_GREEN; +Fl_Font fld::widget::Node_Browser::comment_font = FL_HELVETICA; // ---- global functions @@ -75,7 +75,7 @@ void redraw_browser() { Shortcut to create the widget browser. */ Fl_Widget *make_widget_browser(int x,int y,int w,int h) { - return (widget_browser = new Node_Browser(x,y,w,h)); + return (widget_browser = new fld::widget::Node_Browser(x,y,w,h)); } /** @@ -213,7 +213,7 @@ static char *copy_trunc(char *p, const char *str, int maxl, int quote, int trunc \todo It would be nice to be able to grab one or more nodes and move them within the hierarchy. */ -Node_Browser::Node_Browser(int X,int Y,int W,int H,const char*l) : +fld::widget::Node_Browser::Node_Browser(int X,int Y,int W,int H,const char*l) : Fl_Browser_(X,Y,W,H,l) { type(FL_MULTI_BROWSER); @@ -225,7 +225,7 @@ Node_Browser::Node_Browser(int X,int Y,int W,int H,const char*l) : Override the method to find the first item in the list of elements. \return the first item */ -void *Node_Browser::item_first() const { +void *fld::widget::Node_Browser::item_first() const { return Fluid.proj.tree.first; } @@ -234,7 +234,7 @@ void *Node_Browser::item_first() const { \param l this item \return the next item, irregardless of tree depth, or 0 at the end */ -void *Node_Browser::item_next(void *l) const { +void *fld::widget::Node_Browser::item_next(void *l) const { return ((Node*)l)->next; } @@ -243,7 +243,7 @@ void *Node_Browser::item_next(void *l) const { \param l this item \return the previous item, irregardless of tree depth, or 0 at the start */ -void *Node_Browser::item_prev(void *l) const { +void *fld::widget::Node_Browser::item_prev(void *l) const { return ((Node*)l)->prev; } @@ -253,7 +253,7 @@ void *Node_Browser::item_prev(void *l) const { \return 1 if selected, 0 if not \todo what is the difference between selected and new_selected, and why do we do this? */ -int Node_Browser::item_selected(void *l) const { +int fld::widget::Node_Browser::item_selected(void *l) const { return ((Node*)l)->new_selected; } @@ -262,7 +262,7 @@ int Node_Browser::item_selected(void *l) const { \param l this item \param[in] v 1 if selecting, 0 if not */ -void Node_Browser::item_select(void *l,int v) { +void fld::widget::Node_Browser::item_select(void *l,int v) { ((Node*)l)->new_selected = v; } @@ -271,7 +271,7 @@ void Node_Browser::item_select(void *l,int v) { \param l this item \return height in FLTK units (used to be pixels before high res screens) */ -int Node_Browser::item_height(void *l) const { +int fld::widget::Node_Browser::item_height(void *l) const { Node *t = (Node*)l; if (t->visible) { if (Fluid.show_comments && t->comment()) @@ -286,7 +286,7 @@ int Node_Browser::item_height(void *l) const { Override the method to return the estimated height of all items. \return height in FLTK units */ -int Node_Browser::incr_height() const { +int fld::widget::Node_Browser::incr_height() const { return textsize() + 5 + linespacing(); } @@ -311,7 +311,7 @@ int Node_Browser::incr_height() const { \param X,Y these give the position in window coordinates of the top left corner of this line */ -void Node_Browser::item_draw(void *v, int X, int Y, int, int) const { +void fld::widget::Node_Browser::item_draw(void *v, int X, int Y, int, int) const { // cast to a more general type Node *l = (Node *)v; @@ -455,7 +455,7 @@ void Node_Browser::item_draw(void *v, int X, int Y, int, int) const { \param v this item \return width in FLTK units */ -int Node_Browser::item_width(void *v) const { +int fld::widget::Node_Browser::item_width(void *v) const { char buf[500]; // edit buffer: large enough to hold 80 UTF-8 chars + nul @@ -490,7 +490,7 @@ int Node_Browser::item_width(void *v) const { /** Callback to tell the Fluid UI when the list of selected items changed. */ -void Node_Browser::callback() { +void fld::widget::Node_Browser::callback() { selection_changed((Node*)selection()); } @@ -508,7 +508,7 @@ void Node_Browser::callback() { \param[in] e the incoming event type \return 0 if the event is not supported, and 1 if the event was "used up" */ -int Node_Browser::handle(int e) { +int fld::widget::Node_Browser::handle(int e) { static Node *title; Node *l; int X,Y,W,H; bbox(X,Y,W,H); @@ -549,13 +549,14 @@ int Node_Browser::handle(int e) { l = pushedtitle; title = pushedtitle = 0; if (l) { + Node *k; if (!l->folded_) { l->folded_ = 1; - for (Node*k = l->next; k&&k->level>l->level; k = k->next) + for (k = l->next; k&&k->level>l->level; k = k->next) k->visible = 0; } else { l->folded_ = 0; - for (Node*k=l->next; k&&k->level>l->level;) { + for (k =l->next; k&&k->level>l->level;) { k->visible = 1; if (k->can_have_children() && k->folded_) { Node *j; @@ -575,7 +576,7 @@ int Node_Browser::handle(int e) { /** Save the current scrollbar position during rebuild. */ -void Node_Browser::save_scroll_position() { +void fld::widget::Node_Browser::save_scroll_position() { saved_h_scroll_ = hposition(); saved_v_scroll_ = vposition(); } @@ -583,7 +584,7 @@ void Node_Browser::save_scroll_position() { /** Restore the previous scrollbar position after rebuild. */ -void Node_Browser::restore_scroll_position() { +void fld::widget::Node_Browser::restore_scroll_position() { hposition(saved_h_scroll_); vposition(saved_v_scroll_); } @@ -593,7 +594,7 @@ void Node_Browser::restore_scroll_position() { This clears internal caches, recalculates the scroll bar sizes, and sends a redraw() request to the widget. */ -void Node_Browser::rebuild() { +void fld::widget::Node_Browser::rebuild() { save_scroll_position(); new_list(); damage(FL_DAMAGE_SCROLL); @@ -605,7 +606,7 @@ void Node_Browser::rebuild() { Rebuild the browser layout and make sure that the given item is visible. \param[in] inNode pointer to a widget node derived from Node. */ -void Node_Browser::display(Node *inNode) { +void fld::widget::Node_Browser::display(Node *inNode) { if (!inNode) { // Alternative: find the first (last?) visible selected item. return; @@ -639,7 +640,7 @@ void Node_Browser::display(Node *inNode) { vposition(newV); } -void Node_Browser::load_prefs() { +void fld::widget::Node_Browser::load_prefs() { int c; Fl_Preferences p(Fluid.preferences, "widget_browser"); p.get("label_color", c, 72); label_color = c; @@ -656,7 +657,7 @@ void Node_Browser::load_prefs() { p.get("comment_font", c, FL_HELVETICA); comment_font = c; } -void Node_Browser::save_prefs() { +void fld::widget::Node_Browser::save_prefs() { Fl_Preferences p(Fluid.preferences, "widget_browser"); p.set("label_color", (int)label_color); p.set("label_font", (int)label_font); diff --git a/fluid/widgets/Style_Parser.cxx b/fluid/widgets/Style_Parser.cxx index 9929cc01a..9188e565e 100644 --- a/fluid/widgets/Style_Parser.cxx +++ b/fluid/widgets/Style_Parser.cxx @@ -22,9 +22,6 @@ #include #include // bsearch() -using namespace fld; -using namespace fld::widget; - // Sorted list of C/C++ keywords... static const char * const code_keywords[] = { "and", @@ -133,7 +130,7 @@ static void* search_types(char *find) { // Applies the current style, advances to next text + style char. // Returns 0 if hit end of buffer, 1 otherwise. // -int Style_Parser::parse_over_char(int handle_crlf) { +int fld::widget::Style_Parser::parse_over_char(int handle_crlf) { char c = *tbuff; // End of line? @@ -160,7 +157,7 @@ int Style_Parser::parse_over_char(int handle_crlf) { // Parse over white space using current style // Returns 0 if hit end of buffer, 1 otherwise. // -int Style_Parser::parse_over_white() { +int fld::widget::Style_Parser::parse_over_white() { while ( len > 0 && strchr(" \t", *tbuff)) { if ( !parse_over_char() ) return 0; } return 1; @@ -169,7 +166,7 @@ int Style_Parser::parse_over_white() { // Parse over non-white alphabetic text // Returns 0 if hit end of buffer, 1 otherwise. // -int Style_Parser::parse_over_alpha() { +int fld::widget::Style_Parser::parse_over_alpha() { while ( len > 0 && isalpha(*tbuff) ) { if ( !parse_over_char() ) return 0; } return 1; @@ -178,7 +175,7 @@ int Style_Parser::parse_over_alpha() { // Parse to end of line in specified style. // Returns 0 if hit end of buffer, 1 otherwise. // -int Style_Parser::parse_to_eol(char s) { +int fld::widget::Style_Parser::parse_to_eol(char s) { char save = style; style = s; while ( *tbuff != '\n' ) @@ -190,7 +187,7 @@ int Style_Parser::parse_to_eol(char s) { // Parse a block comment until end of comment or buffer. // Returns 0 if hit end of buffer, 1 otherwise. // -int Style_Parser::parse_block_comment() { +int fld::widget::Style_Parser::parse_block_comment() { char save = style; style = 'C'; // block comment style while ( len > 0 ) { @@ -206,10 +203,11 @@ int Style_Parser::parse_block_comment() { } // Copy keyword from tbuff -> keyword[] buffer -void Style_Parser::buffer_keyword() { +void fld::widget::Style_Parser::buffer_keyword() { char *key = keyword; char *kend = key + sizeof(keyword) - 1; // end of buffer - for ( const char *s=tbuff; + const char *s; + for (s =tbuff; (islower(*s) || *s=='_') && (key < kend); *key++ = *s++ ) { } *key = 0; // terminate @@ -218,7 +216,7 @@ void Style_Parser::buffer_keyword() { // Parse over specified 'key'word in specified style 's'. // Returns 0 if hit end of buffer, 1 otherwise. // -int Style_Parser::parse_over_key(const char *key, char s) { +int fld::widget::Style_Parser::parse_over_key(const char *key, char s) { char save = style; style = s; // Parse over the keyword while applying style to sbuff @@ -232,7 +230,7 @@ int Style_Parser::parse_over_key(const char *key, char s) { // Parse over angle brackets <..> in specified style. // Returns 0 if hit end of buffer, 1 otherwise. // -int Style_Parser::parse_over_angles(char s) { +int fld::widget::Style_Parser::parse_over_angles(char s) { if ( *tbuff != '<' ) return 1; // not <..>, early exit char save = style; style = s; @@ -248,7 +246,7 @@ int Style_Parser::parse_over_angles(char s) { // spi.keyword[] will contain parsed word. // Returns 0 if hit end of buffer, 1 otherwise. // -int Style_Parser::parse_keyword() { +int fld::widget::Style_Parser::parse_keyword() { // Parse into 'keyword' buffer buffer_keyword(); char *key = keyword; @@ -265,7 +263,7 @@ int Style_Parser::parse_keyword() { // Style parse a quoted string, either "" or ''. // Returns 0 if hit end of buffer, 1 otherwise. // -int Style_Parser::parse_quoted_string(char quote_char, // e.g. '"' or '\'' +int fld::widget::Style_Parser::parse_quoted_string(char quote_char, // e.g. '"' or '\'' char in_style) { // style for quoted text style = in_style; // start string style if ( !parse_over_char() ) return 0; // parse over opening quote @@ -292,7 +290,7 @@ int Style_Parser::parse_quoted_string(char quote_char, // e.g. '"' or '\'' // Style parse a directive (#include, #define..) // Returns 0 if hit end of buffer, 1 otherwise. // -int Style_Parser::parse_directive() { +int fld::widget::Style_Parser::parse_directive() { style = 'E'; // start directive style if ( !parse_over_char() ) return 0; // Parse over '#' if ( !parse_over_white() ) return 0; // Parse over any whitespace after '#' @@ -306,7 +304,7 @@ int Style_Parser::parse_directive() { // Style parse a line comment to end of line. // Returns 0 if hit end of buffer, 1 otherwise. // -int Style_Parser::parse_line_comment() { +int fld::widget::Style_Parser::parse_line_comment() { return parse_to_eol('B'); } @@ -315,7 +313,7 @@ int Style_Parser::parse_line_comment() { // a continuation of a line, such as in a multiline #directive. // Returns 0 if hit end of buffer, 1 otherwise. // -int Style_Parser::parse_escape() { +int fld::widget::Style_Parser::parse_escape() { const char no_crlf = 0; if ( !parse_over_char(no_crlf) ) return 0; // backslash if ( !parse_over_char(no_crlf) ) return 0; // char escaped @@ -325,7 +323,7 @@ int Style_Parser::parse_escape() { // Parse all other non-specific characters // Returns 0 if hit end of buffer, 1 otherwise. // -int Style_Parser::parse_all_else() { +int fld::widget::Style_Parser::parse_all_else() { last = isalnum(*tbuff) || *tbuff == '_' || *tbuff == '.'; return parse_over_char(); } diff --git a/fluid/widgets/Text_Viewer.cxx b/fluid/widgets/Text_Viewer.cxx index 310fa6919..3cd89d4d8 100644 --- a/fluid/widgets/Text_Viewer.cxx +++ b/fluid/widgets/Text_Viewer.cxx @@ -20,15 +20,15 @@ #include "widgets/Text_Viewer.h" -using namespace fld; -using namespace fld::widget; + + /** Create a fld::widget::Text_Viewer widget. \param[in] X, Y, W, H position and size of the widget \param[in] L optional label */ -Text_Viewer::Text_Viewer(int X, int Y, int W, int H, const char *L) +fld::widget::Text_Viewer::Text_Viewer(int X, int Y, int W, int H, const char *L) : Fl_Text_Display(X, Y, W, H, L) { buffer(new Fl_Text_Buffer); @@ -37,7 +37,7 @@ Text_Viewer::Text_Viewer(int X, int Y, int W, int H, const char *L) /** Avoid memory leaks. */ -Text_Viewer::~Text_Viewer() { +fld::widget::Text_Viewer::~Text_Viewer() { Fl_Text_Buffer *buf = mBuffer; buffer(0); delete buf; @@ -46,7 +46,7 @@ Text_Viewer::~Text_Viewer() { /** Tricking Fl_Text_Display into using bearable colors for this specific task. */ -void Text_Viewer::draw() +void fld::widget::Text_Viewer::draw() { Fl_Color c = Fl::get_color(FL_SELECTION_COLOR); Fl::set_color(FL_SELECTION_COLOR, fl_color_average(FL_BACKGROUND_COLOR, FL_FOREGROUND_COLOR, 0.9f)); -- cgit v1.2.3