Mercurial > octave
diff libinterp/dldfcn/__init_fltk__.cc @ 23097:0c5f04b9dca1
style fixes
* __init_fltk__.cc: Use m_ prefix for class data members. Use
constructor initialization lists where practical.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 26 Jan 2017 23:19:45 -0500 |
parents | ef4d915df748 |
children | 95a9d6ffaecc |
line wrap: on
line diff
--- a/libinterp/dldfcn/__init_fltk__.cc Thu Jan 26 17:14:58 2017 -0500 +++ b/libinterp/dldfcn/__init_fltk__.cc Thu Jan 26 23:19:45 2017 -0500 @@ -120,9 +120,10 @@ class OpenGL_fltk : public Fl_Gl_Window { public: + OpenGL_fltk (int xx, int yy, int ww, int hh, double num) - : Fl_Gl_Window (xx, yy, ww, hh, 0), number (num), renderer (), - in_zoom (false), zoom_box () + : Fl_Gl_Window (xx, yy, ww, hh, 0), m_number (num), m_renderer (), + m_in_zoom (false), m_zoom_box () { #if defined (HAVE_OPENGL) // Ask for double buffering and a depth buffer. @@ -136,19 +137,19 @@ void zoom (bool z) { - in_zoom = z; - if (! in_zoom) + m_in_zoom = z; + if (! m_in_zoom) hide_overlay (); } - bool zoom (void) { return in_zoom; } - void set_zoom_box (const Matrix& zb) { zoom_box = zb; } + bool zoom (void) { return m_in_zoom; } + void set_zoom_box (const Matrix& zb) { m_zoom_box = zb; } void print (const std::string& cmd, const std::string& term) { //std::cout << "OpenGL_fltk::print(cmd=" << cmd << ", term=" << term << ") canvas size = " << w () << "x" << h () << std::endl; - gl2ps_print (gh_manager::get_object (number), cmd, term); + gl2ps_print (gh_manager::get_object (m_number), cmd, term); } void resize (int xx, int yy, int ww, int hh) @@ -169,9 +170,9 @@ { bool retval = false; - if (number != new_number) + if (m_number != new_number) { - number = new_number; + m_number = new_number; retval = true; } @@ -179,11 +180,15 @@ } private: - double number; - octave::opengl_renderer renderer; - bool in_zoom; + + double m_number; + + octave::opengl_renderer m_renderer; + + bool m_in_zoom; + // (x1,y1,x2,y2) - Matrix zoom_box; + Matrix m_zoom_box; void draw (void) { @@ -196,7 +201,7 @@ glViewport (0, 0, w (), h ()); } - renderer.draw (gh_manager::get_object (number)); + m_renderer.draw (gh_manager::get_object (m_number)); if (zoom ()) overlay (); @@ -213,11 +218,11 @@ { #if defined (HAVE_OPENGL) - glVertex2d (zoom_box(0), h () - zoom_box(1)); - glVertex2d (zoom_box(0), h () - zoom_box(3)); - glVertex2d (zoom_box(2), h () - zoom_box(3)); - glVertex2d (zoom_box(2), h () - zoom_box(1)); - glVertex2d (zoom_box(0), h () - zoom_box(1)); + glVertex2d (m_zoom_box(0), h () - m_zoom_box(1)); + glVertex2d (m_zoom_box(0), h () - m_zoom_box(3)); + glVertex2d (m_zoom_box(2), h () - m_zoom_box(3)); + glVertex2d (m_zoom_box(2), h () - m_zoom_box(1)); + glVertex2d (m_zoom_box(0), h () - m_zoom_box(1)); #else // This shouldn't happen because construction of Opengl_fltk @@ -296,24 +301,24 @@ static_cast<uimenu::properties*> (data)->execute_callback (); } - class fltk_uimenu { public: + fltk_uimenu (int xx, int yy, int ww, int hh) - { - menubar = new Fl_Menu_Bar (xx, yy, ww, hh); - } + : m_menubar (new Fl_Menu_Bar (xx, yy, ww, hh)) + { } int items_to_show (void) { //returns the number of visible menu items - int len = menubar->size (); + int len = m_menubar->size (); int n = 0; for (int t = 0; t < len; t++) { - const Fl_Menu_Item *m = static_cast<const Fl_Menu_Item*> (& - (menubar->menu ()[t])); + const Fl_Menu_Item *m + = static_cast<const Fl_Menu_Item*> (&(m_menubar->menu ()[t])); + if (m->label () && m->visible ()) n++; } @@ -323,19 +328,19 @@ void show (void) { - menubar->show (); - menubar->redraw (); + m_menubar->show (); + m_menubar->redraw (); } void hide (void) { - menubar->hide (); - menubar->redraw (); + m_menubar->hide (); + m_menubar->redraw (); } bool is_visible (void) { - return menubar->visible (); + return m_menubar->visible (); } int find_index_by_name (const std::string& findname) @@ -347,9 +352,9 @@ // Kai Habel (14.10.2010) std::string menupath; - for (int t = 0; t < menubar->size (); t++) + for (int t = 0; t < m_menubar->size (); t++) { - Fl_Menu_Item *m = const_cast<Fl_Menu_Item*> (&(menubar->menu ()[t])); + Fl_Menu_Item *m = const_cast<Fl_Menu_Item*> (&(m_menubar->menu ()[t])); if (m->submenu ()) { // item has submenu @@ -436,7 +441,7 @@ int idx = find_index_by_name (fltk_label.c_str ()); if (idx >= 0) - menubar->remove (idx); + m_menubar->remove (idx); } void update_accelerator (uimenu::properties& uimenup) @@ -444,8 +449,8 @@ std::string fltk_label = uimenup.get___fltk_label__ (); if (! fltk_label.empty ()) { - Fl_Menu_Item* item = const_cast<Fl_Menu_Item*> (menubar->find_item ( - fltk_label.c_str ())); + Fl_Menu_Item* item = + const_cast<Fl_Menu_Item*> (m_menubar->find_item (fltk_label.c_str ())); if (item) { std::string acc = uimenup.get_accelerator (); @@ -463,8 +468,8 @@ std::string fltk_label = uimenup.get___fltk_label__ (); if (! fltk_label.empty ()) { - Fl_Menu_Item* item = const_cast<Fl_Menu_Item*> (menubar->find_item ( - fltk_label.c_str ())); + Fl_Menu_Item* item + = const_cast<Fl_Menu_Item*> (m_menubar->find_item (fltk_label.c_str ())); if (item) { if (! uimenup.get_callback ().is_empty ()) @@ -481,8 +486,8 @@ std::string fltk_label = uimenup.get___fltk_label__ (); if (! fltk_label.empty ()) { - Fl_Menu_Item* item = const_cast<Fl_Menu_Item*> (menubar->find_item ( - fltk_label.c_str ())); + Fl_Menu_Item* item + = const_cast<Fl_Menu_Item*> (m_menubar->find_item (fltk_label.c_str ())); if (item) { if (uimenup.is_enable ()) @@ -498,8 +503,8 @@ std::string fltk_label = uimenup.get___fltk_label__ (); if (! fltk_label.empty ()) { - Fl_Menu_Item* item = const_cast<Fl_Menu_Item*> (menubar->find_item ( - fltk_label.c_str ())); + Fl_Menu_Item* item + = const_cast<Fl_Menu_Item*> (m_menubar->find_item (fltk_label.c_str ())); if (item) { Matrix rgb = uimenup.get_foregroundcolor_rgb (); @@ -527,21 +532,21 @@ for (idx = curr_idx - 1; idx >= 0; idx--) { Fl_Menu_Item* item - = const_cast<Fl_Menu_Item*> (&menubar->menu () [idx]); + = const_cast<Fl_Menu_Item*> (&m_menubar->menu () [idx]); itemflags = item->flags; if (item->label ()) break; } - if (idx >= 0 && idx < menubar->size ()) + if (idx >= 0 && idx < m_menubar->size ()) { if (uimenup.is_separator ()) { if (idx >= 0 && !(itemflags & FL_SUBMENU)) - menubar->mode (idx, itemflags | FL_MENU_DIVIDER); + m_menubar->mode (idx, itemflags | FL_MENU_DIVIDER); } else - menubar->mode (idx, itemflags & (~FL_MENU_DIVIDER)); + m_menubar->mode (idx, itemflags & (~FL_MENU_DIVIDER)); } } } @@ -552,7 +557,7 @@ if (! fltk_label.empty ()) { Fl_Menu_Item* item - = const_cast<Fl_Menu_Item*> (menubar->find_item (fltk_label.c_str ())); + = const_cast<Fl_Menu_Item*> (m_menubar->find_item (fltk_label.c_str ())); if (item) { if (uimenup.is_visible ()) @@ -580,7 +585,7 @@ do { const Fl_Menu_Item* item - = menubar->find_item (fltk_label.c_str ()); + = m_menubar->find_item (fltk_label.c_str ()); if (item) { @@ -610,7 +615,7 @@ flags = FL_SUBMENU; if (len == 0 && uimenup.is_checked ()) flags += FL_MENU_TOGGLE + FL_MENU_VALUE; - menubar->add (fltk_label.c_str (), 0, 0, 0, flags); + m_menubar->add (fltk_label.c_str (), 0, 0, 0, flags); item_added = true; } } @@ -675,7 +680,7 @@ Matrix kids = find_uimenu_children (figp); int len = kids.numel (); int count = 0; - menubar->clear (); + m_menubar->clear (); for (octave_idx_type ii = 0; ii < len; ii++) { graphics_object kgo = gh_manager::get_object (kids (len - (ii + 1))); @@ -735,7 +740,7 @@ if (type == "uimenu") delete_entry (dynamic_cast<uimenu::properties&> (prop)); else if (type == "figure") - menubar->clear (); + m_menubar->clear (); } // No copying! @@ -746,12 +751,12 @@ ~fltk_uimenu (void) { - delete menubar; + delete m_menubar; } private: - Fl_Menu_Bar* menubar; + Fl_Menu_Bar* m_menubar; }; #if defined (HAVE_X_WINDOWS) @@ -765,22 +770,27 @@ class plot_window : public Fl_Window { friend class fltk_uimenu; + public: + plot_window (int xx, int yy, int ww, int hh, figure::properties& xfp, bool internal) - : Fl_Window (xx, yy, ww, hh + menu_h + status_h + 2, "octave"), - window_label (), fp (xfp), canvas (0), - autoscale (0), togglegrid (0), panzoom (0), rotate (0), help (0), - status (0), resize_dummy (0), ax_obj (), pos_x (0), pos_y (0) + : Fl_Window (xx, yy, ww, hh + m_menu_h + m_status_h + 2, "octave"), + m_window_label (), m_fp (xfp), m_uimenu (0), m_canvas (0), + m_autoscale (0), m_togglegrid (0), m_panzoom (0), m_rotate (0), + m_help (0), m_status (0), m_resize_dummy (0), m_ax_obj (), + m_pos_x (0), m_pos_y (0) { callback (window_close, static_cast<void*> (this)); - // The size of the resize_dummy box also determines the minimum window size - resize_dummy = new Fl_Box (5 * status_h, menu_h, - ww - 5 * status_h, hh); + // The size of the resize_dummy box also determines the minimum + // window size. + m_resize_dummy = new Fl_Box (5 * m_status_h, m_menu_h, + ww - 5 * m_status_h, hh); + // See http://fltk.org/articles.php?L415+I0+T+M1000+P1 // for how resizable works - resizable (resize_dummy); + resizable (m_resize_dummy); // FIXME: The function below is only available in FLTK >= 1.3 // At some point support for FLTK 1.1 will be dropped in Octave. @@ -790,53 +800,53 @@ // windows. Otherwise, the class is just "FLTK" //default_xclass ("Octave"); - uimenu = new fltk_uimenu (0, 0, ww, menu_h); - canvas = new OpenGL_fltk (0, menu_h, ww, hh, number ()); + m_uimenu = new fltk_uimenu (0, 0, ww, m_menu_h); + m_canvas = new OpenGL_fltk (0, m_menu_h, ww, hh, number ()); // The bottom toolbar is a composite of "autoscale", "togglegrid", // "panzoom", "rotate", "help", and "status". // Only "status" should be resized. - int toolbar_y = menu_h + hh + 1; - status = new Fl_Output (5 * status_h, toolbar_y, - ww - 5 * status_h, status_h, ""); - - status->textcolor (FL_BLACK); - status->color (FL_GRAY); - status->textfont (FL_COURIER); - status->textsize (10); - status->box (FL_ENGRAVED_BOX); - - autoscale = new Fl_Button (0, toolbar_y, status_h, status_h, "A"); - autoscale->callback (button_callback, static_cast<void*> (this)); - autoscale->tooltip ("Autoscale"); - - togglegrid = new Fl_Button (status_h, toolbar_y, status_h, status_h, "G"); - togglegrid->callback (button_callback, static_cast<void*> (this)); - togglegrid->tooltip ("Toggle Grid"); - - panzoom = new Fl_Button (2* status_h, toolbar_y, status_h, status_h, "P"); - panzoom->callback (button_callback, static_cast<void*> (this)); - panzoom->tooltip ("Mouse Pan/Zoom"); - - rotate = new Fl_Button (3 * status_h, toolbar_y, status_h, status_h, "R"); - rotate->callback (button_callback, static_cast<void*> (this)); - rotate->tooltip ("Mouse Rotate"); - - help = new Fl_Button (4 * status_h, toolbar_y, status_h, status_h, "?"); - help->callback (button_callback, static_cast<void*> (this)); - help->tooltip ("Help"); + int toolbar_y = m_menu_h + hh + 1; + m_status = new Fl_Output (5 * m_status_h, toolbar_y, + ww - 5 * m_status_h, m_status_h, ""); + + m_status->textcolor (FL_BLACK); + m_status->color (FL_GRAY); + m_status->textfont (FL_COURIER); + m_status->textsize (10); + m_status->box (FL_ENGRAVED_BOX); + + m_autoscale = new Fl_Button (0, toolbar_y, m_status_h, m_status_h, "A"); + m_autoscale->callback (button_callback, static_cast<void*> (this)); + m_autoscale->tooltip ("Autoscale"); + + m_togglegrid = new Fl_Button (m_status_h, toolbar_y, m_status_h, m_status_h, "G"); + m_togglegrid->callback (button_callback, static_cast<void*> (this)); + m_togglegrid->tooltip ("Toggle Grid"); + + m_panzoom = new Fl_Button (2* m_status_h, toolbar_y, m_status_h, m_status_h, "P"); + m_panzoom->callback (button_callback, static_cast<void*> (this)); + m_panzoom->tooltip ("Mouse Pan/Zoom"); + + m_rotate = new Fl_Button (3 * m_status_h, toolbar_y, m_status_h, m_status_h, "R"); + m_rotate->callback (button_callback, static_cast<void*> (this)); + m_rotate->tooltip ("Mouse Rotate"); + + m_help = new Fl_Button (4 * m_status_h, toolbar_y, m_status_h, m_status_h, "?"); + m_help->callback (button_callback, static_cast<void*> (this)); + m_help->tooltip ("Help"); end (); set_name (); - uimenu->add_to_menu (fp); - if (fp.menubar_is ("none") || ! uimenu->items_to_show ()) + m_uimenu->add_to_menu (m_fp); + if (m_fp.menubar_is ("none") || ! m_uimenu->items_to_show ()) hide_menubar (); update_boundingbox (internal); - if (fp.is_visible ()) + if (m_fp.is_visible ()) { // FIXME: This code should be removed when Octave drops support // for FLTK 1.1. Search for default_xclass in this file to find @@ -857,7 +867,7 @@ XSetErrorHandler (xerror_handler); #endif - if (fp.get_currentaxes ().ok ()) + if (m_fp.get_currentaxes ().ok ()) show_canvas (); else hide_canvas (); @@ -876,31 +886,31 @@ Fl::check (); } - double number (void) { return fp.get___myhandle__ ().value (); } + double number (void) { return m_fp.get___myhandle__ ().value (); } void renumber (double new_number) { - if (! canvas) + if (! m_canvas) error ("unable to renumber figure"); - if (canvas->renumber (new_number)) + if (m_canvas->renumber (new_number)) mark_modified (); } void print (const std::string& cmd, const std::string& term) { - canvas->print (cmd, term); + m_canvas->print (cmd, term); } void show_menubar (void) { - uimenu->show (); + m_uimenu->show (); update_toolbar_position (); } void hide_menubar (void) { - uimenu->hide (); + m_uimenu->hide (); update_toolbar_position (); } @@ -920,47 +930,47 @@ switch (id) { case base_properties::ID_BEINGDELETED: - uimenu->remove_from_menu (uimenup); + m_uimenu->remove_from_menu (uimenup); break; case base_properties::ID_VISIBLE: - uimenu->update_visible (uimenup); + m_uimenu->update_visible (uimenup); break; case uimenu::properties::ID_ACCELERATOR: - uimenu->update_accelerator (uimenup); + m_uimenu->update_accelerator (uimenup); break; case uimenu::properties::ID_CALLBACK: - uimenu->update_callback (uimenup); + m_uimenu->update_callback (uimenup); break; case uimenu::properties::ID_CHECKED: - uimenu->add_to_menu (figp);//rebuilding entire menu + m_uimenu->add_to_menu (figp);//rebuilding entire menu break; case uimenu::properties::ID_ENABLE: - uimenu->update_enable (uimenup); + m_uimenu->update_enable (uimenup); break; case uimenu::properties::ID_FOREGROUNDCOLOR: - uimenu->update_foregroundcolor (uimenup); + m_uimenu->update_foregroundcolor (uimenup); break; case uimenu::properties::ID_LABEL: - uimenu->add_to_menu (figp);//rebuilding entire menu + m_uimenu->add_to_menu (figp);//rebuilding entire menu break; case uimenu::properties::ID_POSITION: - uimenu->add_to_menu (figp);//rebuilding entire menu + m_uimenu->add_to_menu (figp);//rebuilding entire menu break; case uimenu::properties::ID_SEPARATOR: - uimenu->update_seperator (uimenup); + m_uimenu->update_seperator (uimenup); break; } - if (uimenu->items_to_show ()) + if (m_uimenu->items_to_show ()) show_menubar (); else hide_menubar (); @@ -969,18 +979,18 @@ void show_canvas (void) { - if (! canvas->can_do ()) + if (! m_canvas->can_do ()) error ("unable to plot due to insufficient OpenGL support"); - else if (fp.is_visible ()) + else if (m_fp.is_visible ()) { - canvas->show (); - canvas->make_current (); + m_canvas->show (); + m_canvas->make_current (); } } void hide_canvas (void) { - canvas->hide (); + m_canvas->hide (); } // Move the toolbar at the bottom of the plot_window. @@ -989,20 +999,20 @@ void update_toolbar_position () { - int old_canvas_h = canvas->h (); + int old_canvas_h = m_canvas->h (); // keep position fix, change outerposition accordingly update_boundingbox (true); - canvas->resize (0, menu_dy (), w (), old_canvas_h); - - int toolbar_y = canvas->h () + menu_dy () + 1; - autoscale->position (0, toolbar_y); - togglegrid->position (status_h, toolbar_y); - panzoom->position (2 * status_h, toolbar_y); - rotate->position (3 * status_h, toolbar_y); - help->position (4 * status_h, toolbar_y); - status->resize (5 * status_h, toolbar_y, - w () - 5 * status_h, status_h); + m_canvas->resize (0, menu_dy (), w (), old_canvas_h); + + int toolbar_y = m_canvas->h () + menu_dy () + 1; + m_autoscale->position (0, toolbar_y); + m_togglegrid->position (m_status_h, toolbar_y); + m_panzoom->position (2 * m_status_h, toolbar_y); + m_rotate->position (3 * m_status_h, toolbar_y); + m_help->position (4 * m_status_h, toolbar_y); + m_status->resize (5 * m_status_h, toolbar_y, + w () - 5 * m_status_h, m_status_h); init_sizes (); redraw (); } @@ -1011,7 +1021,7 @@ { Matrix pos = outerpos; pos(1) += menu_dy (); - pos(3) -= menu_dy () + status_h + 2; + pos(3) -= menu_dy () + m_status_h + 2; return pos; } @@ -1019,7 +1029,7 @@ { Matrix outerpos = pos; outerpos(1) -= menu_dy (); - outerpos(3) += menu_dy () + status_h + 2; + outerpos(3) += menu_dy () + m_status_h + 2; return outerpos; } @@ -1030,7 +1040,7 @@ void update_boundingbox (bool internal) { - Matrix bb = fp.get_boundingbox (internal); + Matrix bb = m_fp.get_boundingbox (internal); if (internal) bb = position2outerposition (bb); resize (bb(0), bb(1), bb(2), bb(3)); @@ -1038,29 +1048,47 @@ void mark_modified (void) { - canvas->redraw (); + m_canvas->redraw (); } void set_name (void) { - window_label = fp.get_title (); - label (window_label.c_str ()); + m_window_label = m_fp.get_title (); + label (m_window_label.c_str ()); } private: // window name -- this must exists for the duration of the window's // life - std::string window_label; + std::string m_window_label; // Figure properties. - figure::properties& fp; + figure::properties& m_fp; // Status area height. - static const int status_h = 20; + static const int m_status_h = 20; // Menu height - static const int menu_h = 25; + static const int m_menu_h = 25; + + fltk_uimenu* m_uimenu; + + OpenGL_fltk* m_canvas; + + Fl_Button* m_autoscale; + Fl_Button* m_togglegrid; + Fl_Button* m_panzoom; + Fl_Button* m_rotate; + Fl_Button* m_help; + Fl_Output* m_status; + + Fl_Box* m_resize_dummy; + + graphics_object m_ax_obj; + + int m_pos_x; + int m_pos_y; // Window callback. static void window_close (Fl_Widget*, void* data) @@ -1078,32 +1106,32 @@ void button_press (Fl_Widget* widg, void*) { - if (widg == autoscale) + if (widg == m_autoscale) axis_auto (); - else if (widg == togglegrid) + else if (widg == m_togglegrid) toggle_grid (); - else if (widg == panzoom) - fp.set___mouse_mode__ ("pan"); - else if (widg == rotate) - fp.set___mouse_mode__ ("rotate"); - else if (widg == help) + else if (widg == m_panzoom) + m_fp.set___mouse_mode__ ("pan"); + else if (widg == m_rotate) + m_fp.set___mouse_mode__ ("rotate"); + else if (widg == m_help) fl_message ("%s", help_text); } void set_on_ax_obj (const std::string& name, const std::string& value) { // ax_obj is the last clicked axes object - if (ax_obj && ax_obj.isa ("axes") - && ax_obj.get_properties ().get_tag () != "legend" - && ax_obj.get_properties ().get_tag () != "colorbar") + if (m_ax_obj && m_ax_obj.isa ("axes") + && m_ax_obj.get_properties ().get_tag () != "legend" + && m_ax_obj.get_properties ().get_tag () != "colorbar") { axes::properties& ap = - dynamic_cast<axes::properties&>(ax_obj.get_properties ()); + dynamic_cast<axes::properties&>(m_ax_obj.get_properties ()); ap.set (name, value); } else // no axes object clicked so far, take currentaxes { - graphics_handle gh = fp.get_currentaxes (); + graphics_handle gh = m_fp.get_currentaxes (); if (gh.ok ()) { graphics_object go = gh_manager::get_object (gh); @@ -1114,25 +1142,12 @@ } } - fltk_uimenu* uimenu; - OpenGL_fltk* canvas; - Fl_Button* autoscale; - Fl_Button* togglegrid; - Fl_Button* panzoom; - Fl_Button* rotate; - Fl_Button* help; - Fl_Output* status; - Fl_Box* resize_dummy; - graphics_object ax_obj; - int pos_x; - int pos_y; - void axis_auto (void) { octave_value_list args; - if (fp.get_currentaxes ().ok ()) + if (m_fp.get_currentaxes ().ok ()) { - args(0) = fp.get_currentaxes ().as_octave_value (); + args(0) = m_fp.get_currentaxes ().as_octave_value (); args(1) = "auto"; octave::feval ("axis", args); mark_modified (); @@ -1142,8 +1157,8 @@ void toggle_grid (void) { octave_value_list args; - if (fp.get_currentaxes ().ok ()) - args(0) = fp.get_currentaxes ().as_octave_value (); + if (m_fp.get_currentaxes ().ok ()) + args(0) = m_fp.get_currentaxes ().as_octave_value (); octave::feval ("grid", args); mark_modified (); @@ -1170,7 +1185,7 @@ graphics_handle pixel2axes_or_ca (int px, int py) { - Matrix kids = fp.get_children (); + Matrix kids = m_fp.get_children (); int len = kids.numel (); for (int k = 0; k < len; k++) @@ -1193,7 +1208,7 @@ } } } - return fp.get_currentaxes (); + return m_fp.get_currentaxes (); } void pixel2status (const graphics_handle& ax, int px0, int py0, @@ -1218,7 +1233,7 @@ cbuf << " -> ["<< x1 << ", " << y1 << "]"; } - status->value (cbuf.str ().c_str ()); + m_status->value (cbuf.str ().c_str ()); } void view2status (graphics_object ax) @@ -1234,20 +1249,20 @@ v = ap.get ("view").matrix_value (); cbuf << "[azimuth: " << v(0) << ", elevation: " << v(1) << "]"; - status->value (cbuf.str ().c_str ()); + m_status->value (cbuf.str ().c_str ()); } } void set_currentpoint (int px, int py) { - if (! fp.is_beingdeleted ()) + if (! m_fp.is_beingdeleted ()) { - Matrix pos = fp.map_from_boundingbox (px, py); - fp.set_currentpoint (pos); - graphics_object robj = gh_manager::get_object (fp.get_parent ()); + Matrix pos = m_fp.map_from_boundingbox (px, py); + m_fp.set_currentpoint (pos); + graphics_object robj = gh_manager::get_object (m_fp.get_parent ()); root_figure::properties& rp = dynamic_cast<root_figure::properties&> (robj.get_properties ()); - rp.set_currentfigure (fp.get___myhandle__ ().value ()); + rp.set_currentfigure (m_fp.get___myhandle__ ().value ()); } } @@ -1275,14 +1290,14 @@ ap.set_currentpoint (pos); if (ap.get_tag () != "legend" && ap.get_tag () != "colorbar") - fp.set_currentaxes (ap.get___myhandle__ ().value ()); + m_fp.set_currentaxes (ap.get___myhandle__ ().value ()); } } int menu_dy () { - if (uimenu->is_visible ()) - return menu_h; + if (m_uimenu->is_visible ()) + return m_menu_h; else return 0; } @@ -1409,16 +1424,16 @@ bb(3) = hh; // update outerposition - fp.set_boundingbox (bb, false, false); + m_fp.set_boundingbox (bb, false, false); // update position - fp.set_boundingbox (outerposition2position (bb), true, false); + m_fp.set_boundingbox (outerposition2position (bb), true, false); } bool pan_enabled (void) { // Getting pan mode property: - octave_value ov_pm = fp.get___pan_mode__ (); + octave_value ov_pm = m_fp.get___pan_mode__ (); octave_scalar_map pm = ov_pm.scalar_map_value (); @@ -1428,7 +1443,7 @@ std::string pan_mode (void) { // Getting pan mode property: - octave_value ov_pm = fp.get___pan_mode__ (); + octave_value ov_pm = m_fp.get___pan_mode__ (); octave_scalar_map pm = ov_pm.scalar_map_value (); @@ -1438,7 +1453,7 @@ bool rotate_enabled (void) { // Getting rotate mode property: - octave_value ov_rm = fp.get___rotate_mode__ (); + octave_value ov_rm = m_fp.get___rotate_mode__ (); octave_scalar_map rm = ov_rm.scalar_map_value (); @@ -1452,7 +1467,7 @@ graphics_handle gh; - if (! fp.is_beingdeleted ()) + if (! m_fp.is_beingdeleted ()) { //std::cout << "plot_window::handle event = " << fl_eventnames[event] << std::endl; @@ -1488,29 +1503,29 @@ int e_state = Fl::event_state (); octave_scalar_map evt = format_key_event (e_key, e_text, e_state); - fp.set_currentcharacter (std::string (e_text)); - - if (! fp.get_keypressfcn ().is_empty () + m_fp.set_currentcharacter (std::string (e_text)); + + if (! m_fp.get_keypressfcn ().is_empty () && (evt.contents ("Key").length () > 0)) { // Update CurrentPoint before callback - if (Fl::event_inside (canvas)) + if (Fl::event_inside (m_canvas)) { - pos_x = Fl::event_x (); - pos_y = Fl::event_y () - menu_dy (); - - set_currentpoint (pos_x, pos_y); - - gh = pixel2axes_or_ca (pos_x, pos_y); + m_pos_x = Fl::event_x (); + m_pos_y = Fl::event_y () - menu_dy (); + + set_currentpoint (m_pos_x, m_pos_y); + + gh = pixel2axes_or_ca (m_pos_x, m_pos_y); if (gh.ok ()) { - ax_obj = gh_manager::get_object (gh); - set_axes_currentpoint (ax_obj, pos_x, pos_y); + m_ax_obj = gh_manager::get_object (gh); + set_axes_currentpoint (m_ax_obj, m_pos_x, m_pos_y); } } - fp.execute_keypressfcn (evt); + m_fp.execute_keypressfcn (evt); } // Handle special keys used in toolbar @@ -1528,12 +1543,12 @@ case 'p': case 'P': - fp.set___mouse_mode__ ("pan"); + m_fp.set___mouse_mode__ ("pan"); return 1; case 'r': case 'R': - fp.set___mouse_mode__ ("rotate"); + m_fp.set___mouse_mode__ ("rotate"); return 1; } } @@ -1564,16 +1579,16 @@ evt = format_key_event (e_key, e_text, e_state); } - if (! fp.get_keyreleasefcn ().is_empty () + if (! m_fp.get_keyreleasefcn ().is_empty () && (evt.contents ("Key").length () > 0)) - fp.execute_keyreleasefcn (evt); + m_fp.execute_keyreleasefcn (evt); return 1; } break; } // Events we only handle if they are in the canvas area. - if (Fl::event_inside (canvas)) + if (Fl::event_inside (m_canvas)) switch (event) { case FL_MOVE: @@ -1583,88 +1598,88 @@ return 1; case FL_PUSH: - pos_x = Fl::event_x (); - pos_y = Fl::event_y () - menu_dy (); - - set_currentpoint (pos_x, pos_y); + m_pos_x = Fl::event_x (); + m_pos_y = Fl::event_y () - menu_dy (); + + set_currentpoint (m_pos_x, m_pos_y); if (Fl::event_clicks ()) - fp.set_selectiontype ("open"); + m_fp.set_selectiontype ("open"); else if (Fl::event_button () == FL_MIDDLE_MOUSE || (Fl::event_button () == FL_LEFT_MOUSE && Fl::event_shift ())) - fp.set_selectiontype ("extend"); + m_fp.set_selectiontype ("extend"); else if (Fl::event_button () == FL_RIGHT_MOUSE || (Fl::event_button () == FL_LEFT_MOUSE && Fl::event_ctrl ())) - fp.set_selectiontype ("alt"); + m_fp.set_selectiontype ("alt"); else - fp.set_selectiontype ("normal"); - - gh = pixel2axes_or_ca (pos_x, pos_y); + m_fp.set_selectiontype ("normal"); + + gh = pixel2axes_or_ca (m_pos_x, m_pos_y); if (gh.ok ()) { - ax_obj = gh_manager::get_object (gh); - set_axes_currentpoint (ax_obj, pos_x, pos_y); + m_ax_obj = gh_manager::get_object (gh); + set_axes_currentpoint (m_ax_obj, m_pos_x, m_pos_y); } // Ensure windowbuttondownfcn is called after currentpoint // is updated but before calling buttondownfcn. - if (! fp.get_windowbuttondownfcn ().is_empty ()) - fp.execute_windowbuttondownfcn (Fl::event_button ()); + if (! m_fp.get_windowbuttondownfcn ().is_empty ()) + m_fp.execute_windowbuttondownfcn (Fl::event_button ()); if (gh.ok ()) { - int ndim = calc_dimensions (ax_obj); + int ndim = calc_dimensions (m_ax_obj); if (ndim == 3) - rotate->activate (); + m_rotate->activate (); else // ndim == 2 - rotate->deactivate (); - - fp.set_currentobject (ax_obj.get_handle ().value ()); - - base_properties& props = ax_obj.get_properties (); + m_rotate->deactivate (); + + m_fp.set_currentobject (m_ax_obj.get_handle ().value ()); + + base_properties& props = m_ax_obj.get_properties (); if (! props.get_buttondownfcn ().is_empty ()) props.execute_buttondownfcn (Fl::event_button ()); return 1; } - else if (! fp.get_buttondownfcn ().is_empty ()) - fp.execute_buttondownfcn (Fl::event_button ()); + else if (! m_fp.get_buttondownfcn ().is_empty ()) + m_fp.execute_buttondownfcn (Fl::event_button ()); break; case FL_DRAG: - if (! fp.get_windowbuttonmotionfcn ().is_empty ()) + if (! m_fp.get_windowbuttonmotionfcn ().is_empty ()) { set_currentpoint (Fl::event_x (), Fl::event_y () - menu_dy ()); - fp.execute_windowbuttonmotionfcn (); + m_fp.execute_windowbuttonmotionfcn (); } if (Fl::event_button () == 1) { - if (ax_obj && ax_obj.isa ("axes")) + if (m_ax_obj && m_ax_obj.isa ("axes")) { axes::properties& ap = dynamic_cast<axes::properties&> - (ax_obj.get_properties ()); + (m_ax_obj.get_properties ()); // Don't pan or rotate legend if (ap.get_tag () != "legend") { if (rotate_enabled ()) - view2status (ax_obj); + view2status (m_ax_obj); else - pixel2status (ax_obj, pos_x, pos_y, + pixel2status (m_ax_obj, m_pos_x, m_pos_y, Fl::event_x (), Fl::event_y () - menu_dy ()); double x0, y0, x1, y1; - Matrix pos = fp.get_boundingbox (true); - pixel2pos (ax_obj, pos_x, pos_y, x0, y0); - pixel2pos (ax_obj, Fl::event_x (), + Matrix pos = m_fp.get_boundingbox (true); + pixel2pos (m_ax_obj, m_pos_x, m_pos_y, x0, y0); + pixel2pos (m_ax_obj, Fl::event_x (), Fl::event_y () - menu_dy (), x1, y1); @@ -1677,8 +1692,8 @@ else if (rotate_enabled ()) { double daz, del; - daz = (Fl::event_x () - pos_x) / pos(2) * 360; - del = (Fl::event_y () - menu_dy () - pos_y) + daz = (Fl::event_x () - m_pos_x) / pos(2) * 360; + del = (Fl::event_y () - menu_dy () - m_pos_y) / pos(3) * 360; ap.rotate_view (del, daz); } @@ -1687,30 +1702,30 @@ { // move the position of the legend Matrix pos = ap.get_position ().matrix_value (); - pos(0) += double (Fl::event_x () - pos_x) - / canvas->w (); - pos(1) -= double (Fl::event_y () - menu_dy () - pos_y) - / canvas->h (); + pos(0) += double (Fl::event_x () - m_pos_x) + / m_canvas->w (); + pos(1) -= double (Fl::event_y () - menu_dy () - m_pos_y) + / m_canvas->h (); ap.set_position (pos); } - pos_x = Fl::event_x (); - pos_y = Fl::event_y () - menu_dy (); + m_pos_x = Fl::event_x (); + m_pos_y = Fl::event_y () - menu_dy (); mark_modified (); } return 1; } else if (Fl::event_button () == 3) { - pixel2status (ax_obj, pos_x, pos_y, + pixel2status (m_ax_obj, m_pos_x, m_pos_y, Fl::event_x (), Fl::event_y () - menu_dy ()); Matrix zoom_box (1,4,0); - zoom_box (0) = pos_x; - zoom_box (1) = pos_y; - zoom_box (2) = Fl::event_x (); - zoom_box (3) = Fl::event_y () - menu_dy (); - canvas->set_zoom_box (zoom_box); - canvas->zoom (true); + zoom_box(0) = m_pos_x; + zoom_box(1) = m_pos_y; + zoom_box(2) = Fl::event_x (); + zoom_box(3) = Fl::event_y () - menu_dy (); + m_canvas->set_zoom_box (zoom_box); + m_canvas->zoom (true); mark_modified (); return 1; } @@ -1750,10 +1765,10 @@ } case FL_RELEASE: - if (! fp.get_windowbuttonupfcn ().is_empty ()) + if (! m_fp.get_windowbuttonupfcn ().is_empty ()) { set_currentpoint (Fl::event_x (), Fl::event_y () - menu_dy ()); - fp.execute_windowbuttonupfcn (); + m_fp.execute_windowbuttonupfcn (); } if ((Fl::event_button () == 1) && Fl::event_clicks ()) @@ -1768,22 +1783,22 @@ if (Fl::event_button () == 3) { // End of drag -- zoom. - if (canvas->zoom ()) + if (m_canvas->zoom ()) { - canvas->zoom (false); + m_canvas->zoom (false); double x0,y0,x1,y1; - if (ax_obj && ax_obj.isa ("axes")) + if (m_ax_obj && m_ax_obj.isa ("axes")) { axes::properties& ap = dynamic_cast<axes::properties&> - (ax_obj.get_properties ()); - pixel2pos (ax_obj, pos_x, pos_y, x0, y0); + (m_ax_obj.get_properties ()); + pixel2pos (m_ax_obj, m_pos_x, m_pos_y, x0, y0); int pos_x1 = Fl::event_x (); int pos_y1 = Fl::event_y () - menu_dy (); - pixel2pos (ax_obj, pos_x1, pos_y1, x1, y1); + pixel2pos (m_ax_obj, pos_x1, pos_y1, x1, y1); Matrix xl (1,2,0); Matrix yl (1,2,0); - int dx = abs (pos_x - pos_x1); - int dy = abs (pos_y - pos_y1); + int dx = abs (m_pos_x - pos_x1); + int dy = abs (m_pos_y - pos_y1); // Smallest zoom box must be 4 pixels square if ((dx > 4) && (dy > 4)) { @@ -2198,6 +2213,7 @@ class fltk_graphics_toolkit : public base_graphics_toolkit { public: + fltk_graphics_toolkit (void) : base_graphics_toolkit (FLTK_GRAPHICS_TOOLKIT_NAME), input_event_hook_fcn_id ()