# HG changeset patch # User John W. Eaton # Date 1426782474 14400 # Node ID 3cc0734283dca7dd5d290480a8b47b5c93398125 # Parent 40b2c4323c1696c4fd4bb2881741cd7e682483d9 style fixes in Qt graphics code * Backend.cc, BaseControl.cc, ButtonControl.cc, Canvas.cc, CheckBoxControl.cc, Container.cc, ContextMenu.cc, EditControl.cc, Figure.cc, FigureWindow.cc, GLCanvas.cc, KeyMap.cc, ListBoxControl.cc, Logger.cc, Menu.cc, MouseModeActionGroup.cc, Object.cc, ObjectFactory.cc, ObjectProxy.cc, Panel.cc, PopupMenuControl.cc, PushButtonControl.cc, PushTool.cc, QtHandlesUtils.cc, RadioButtonControl.cc, SliderControl.cc, TextControl.cc, TextEdit.cc, ToggleButtonControl.cc, ToggleTool.cc, ToolBar.cc, ToolBarButton.cc, __init_qt__.cc: Follow a few more Octave coding conventions. diff -r 40b2c4323c16 -r 3cc0734283dc libgui/graphics/Backend.cc --- a/libgui/graphics/Backend.cc Thu Mar 19 12:25:28 2015 -0400 +++ b/libgui/graphics/Backend.cc Thu Mar 19 12:27:54 2015 -0400 @@ -48,7 +48,8 @@ namespace QtHandles { -static std::string toolkitObjectProperty (const graphics_object& go) +static std::string +toolkitObjectProperty (const graphics_object& go) { if (go.isa ("figure")) return std::string ("__plot_stream__"); @@ -80,7 +81,8 @@ { } -bool Backend::initialize (const graphics_object& go) +bool +Backend::initialize (const graphics_object& go) { if (go.isa ("figure") || go.isa ("uicontrol") @@ -108,7 +110,8 @@ return false; } -void Backend::update (const graphics_object& go, int pId) +void +Backend::update (const graphics_object& go, int pId) { // Rule out obvious properties we want to ignore. if (pId == figure::properties::ID___PLOT_STREAM__ @@ -143,7 +146,8 @@ } } -void Backend::finalize (const graphics_object& go) +void +Backend::finalize (const graphics_object& go) { Logger::debug ("Backend::finalize %s from thread %08x", go.type ().c_str (), QThread::currentThreadId ()); @@ -161,7 +165,8 @@ } } -void Backend::redraw_figure (const graphics_object& go) const +void +Backend::redraw_figure (const graphics_object& go) const { if (go.get_properties ().is_visible ()) { @@ -172,7 +177,8 @@ } } -void Backend::print_figure (const graphics_object& go, +void +Backend::print_figure (const graphics_object& go, const std::string& term, const std::string& file_cmd, bool /*mono*/, const std::string& /*debug_file*/) const @@ -187,7 +193,8 @@ } } -Object* Backend::toolkitObject (const graphics_object& go) +Object* +Backend::toolkitObject (const graphics_object& go) { ObjectProxy* proxy = toolkitObjectProxy (go); @@ -197,7 +204,8 @@ return 0; } -ObjectProxy* Backend::toolkitObjectProxy (const graphics_object& go) +ObjectProxy* +Backend::toolkitObjectProxy (const graphics_object& go) { if (go) { diff -r 40b2c4323c16 -r 3cc0734283dc libgui/graphics/BaseControl.cc --- a/libgui/graphics/BaseControl.cc Thu Mar 19 12:25:28 2015 -0400 +++ b/libgui/graphics/BaseControl.cc Thu Mar 19 12:27:54 2015 -0400 @@ -36,7 +36,8 @@ namespace QtHandles { -static void updatePalette (const uicontrol::properties& props, QWidget* w) +static void +updatePalette (const uicontrol::properties& props, QWidget* w) { QPalette p = w->palette (); @@ -74,7 +75,8 @@ init (w); } -void BaseControl::init (QWidget* w, bool callBase) +void +BaseControl::init (QWidget* w, bool callBase) { if (callBase) Object::init (w, callBase); @@ -100,7 +102,8 @@ { } -void BaseControl::update (int pId) +void +BaseControl::update (int pId) { uicontrol::properties& up = properties (); QWidget* w = qWidget (); @@ -114,40 +117,49 @@ xround (bb(2)), xround (bb(3))); } break; + case uicontrol::properties::ID_FONTNAME: case uicontrol::properties::ID_FONTSIZE: case uicontrol::properties::ID_FONTWEIGHT: case uicontrol::properties::ID_FONTANGLE: w->setFont (Utils::computeFont (up)); break; + case uicontrol::properties::ID_FONTUNITS: // FIXME: We shouldn't have to do anything, octave should update // the "fontsize" property automatically to the new units. // Hence the actual font used shouldn't change. m_normalizedFont = up.fontunits_is ("normalized"); break; + case uicontrol::properties::ID_BACKGROUNDCOLOR: case uicontrol::properties::ID_FOREGROUNDCOLOR: updatePalette (up, w); break; + case uicontrol::properties::ID_ENABLE: w->setEnabled (up.enable_is ("on")); break; + case uicontrol::properties::ID_TOOLTIPSTRING: w->setToolTip (Utils::fromStdString (up.get_tooltipstring ())); break; + case base_properties::ID_VISIBLE: w->setVisible (up.is_visible ()); break; + case uicontrol::properties::ID_KEYPRESSFCN: m_keyPressHandlerDefined = ! up.get_keypressfcn ().is_empty (); break; + default: break; } } -bool BaseControl::eventFilter (QObject* watched, QEvent* xevent) +bool +BaseControl::eventFilter (QObject* watched, QEvent* xevent) { switch (xevent->type ()) { @@ -160,41 +172,43 @@ (properties ())); } break; + case QEvent::MouseButtonPress: - { - gh_manager::auto_lock lock; + { + gh_manager::auto_lock lock; + + QMouseEvent* m = dynamic_cast (xevent); + graphics_object go = object (); + uicontrol::properties& up = Utils::properties (go); + graphics_object fig = go.get_ancestor ("figure"); - QMouseEvent* m = dynamic_cast (xevent); - graphics_object go = object (); - uicontrol::properties& up = Utils::properties (go); - graphics_object fig = go.get_ancestor ("figure"); + if (m->button () != Qt::LeftButton + || ! up.enable_is ("on")) + { + gh_manager::post_set (fig.get_handle (), "selectiontype", + Utils::figureSelectionType (m), false); + gh_manager::post_set (fig.get_handle (), "currentpoint", + Utils::figureCurrentPoint (fig, m), + false); + gh_manager::post_callback (fig.get_handle (), + "windowbuttondownfcn"); + gh_manager::post_callback (m_handle, "buttondownfcn"); - if (m->button () != Qt::LeftButton - || ! up.enable_is ("on")) - { + if (m->button () == Qt::RightButton) + ContextMenu::executeAt (up, m->globalPos ()); + } + else + { + if (up.style_is ("listbox")) gh_manager::post_set (fig.get_handle (), "selectiontype", Utils::figureSelectionType (m), false); - gh_manager::post_set (fig.get_handle (), "currentpoint", - Utils::figureCurrentPoint (fig, m), - false); - gh_manager::post_callback (fig.get_handle (), - "windowbuttondownfcn"); - gh_manager::post_callback (m_handle, "buttondownfcn"); + else + gh_manager::post_set (fig.get_handle (), "selectiontype", + octave_value ("normal"), false); + } + } + break; - if (m->button () == Qt::RightButton) - ContextMenu::executeAt (up, m->globalPos ()); - } - else - { - if (up.style_is ("listbox")) - gh_manager::post_set (fig.get_handle (), "selectiontype", - Utils::figureSelectionType (m), false); - else - gh_manager::post_set (fig.get_handle (), "selectiontype", - octave_value ("normal"), false); - } - } - break; case QEvent::MouseMove: if (qWidget ()->hasMouseTracking ()) { @@ -209,6 +223,7 @@ gh_manager::post_callback (fig.get_handle (), "windowbuttonmotionfcn"); } break; + case QEvent::KeyPress: if (m_keyPressHandlerDefined) { @@ -223,7 +238,9 @@ gh_manager::post_callback (m_handle, "keypressfcn", keyData); } break; - default: break; + + default: + break; } return Object::eventFilter (watched, xevent); diff -r 40b2c4323c16 -r 3cc0734283dc libgui/graphics/ButtonControl.cc --- a/libgui/graphics/ButtonControl.cc Thu Mar 19 12:25:28 2015 -0400 +++ b/libgui/graphics/ButtonControl.cc Thu Mar 19 12:27:54 2015 -0400 @@ -34,7 +34,7 @@ { ButtonControl::ButtonControl (const graphics_object& go, QAbstractButton* btn) - : BaseControl (go, btn), m_blockCallback (false) + : BaseControl (go, btn), m_blockCallback (false) { uicontrol::properties& up = properties (); @@ -57,7 +57,8 @@ { } -void ButtonControl::update (int pId) +void +ButtonControl::update (int pId) { uicontrol::properties& up = properties (); QAbstractButton* btn = qWidget (); @@ -67,6 +68,7 @@ case uicontrol::properties::ID_STRING: btn->setText (Utils::fromStdString (up.get_string_string ())); break; + case uicontrol::properties::ID_VALUE: m_blockCallback = true; if (btn->isCheckable ()) @@ -85,13 +87,15 @@ } m_blockCallback = false; break; + default: BaseControl::update (pId); break; } } -void ButtonControl::toggled (bool checked) +void +ButtonControl::toggled (bool checked) { QAbstractButton* btn = qWidget (); @@ -111,7 +115,8 @@ } } -void ButtonControl::clicked (void) +void +ButtonControl::clicked (void) { QAbstractButton* btn = qWidget (); diff -r 40b2c4323c16 -r 3cc0734283dc libgui/graphics/Canvas.cc --- a/libgui/graphics/Canvas.cc Thu Mar 19 12:25:28 2015 -0400 +++ b/libgui/graphics/Canvas.cc Thu Mar 19 12:27:54 2015 -0400 @@ -43,7 +43,8 @@ namespace QtHandles { -void Canvas::redraw (bool sync) +void +Canvas::redraw (bool sync) { QWidget *w = qWidget (); @@ -56,12 +57,14 @@ } } -void Canvas::blockRedraw (bool block) +void +Canvas::blockRedraw (bool block) { m_redrawBlocked = block; } -void Canvas::setCursor (MouseMode mode) +void +Canvas::setCursor (MouseMode mode) { QWidget *w = qWidget (); @@ -91,7 +94,8 @@ } } -void Canvas::print (const QString& file_cmd, const QString& term) +void +Canvas::print (const QString& file_cmd, const QString& term) { gh_manager::auto_lock lock; graphics_object obj = gh_manager::get_object (m_handle); @@ -104,8 +108,9 @@ } } -void Canvas::updateCurrentPoint(const graphics_object& fig, - const graphics_object& obj, QMouseEvent* event) +void +Canvas::updateCurrentPoint(const graphics_object& fig, + const graphics_object& obj, QMouseEvent* event) { gh_manager::auto_lock lock; @@ -141,7 +146,8 @@ } } -void Canvas::canvasToggleAxes (const graphics_handle& handle) +void +Canvas::canvasToggleAxes (const graphics_handle& handle) { gh_manager::auto_lock lock; @@ -169,7 +175,8 @@ } } -void Canvas::canvasToggleGrid (const graphics_handle& handle) +void +Canvas::canvasToggleGrid (const graphics_handle& handle) { gh_manager::auto_lock lock; @@ -219,7 +226,8 @@ ap.set_zlimmode ("auto"); } -void Canvas::canvasAutoAxes (const graphics_handle& handle) +void +Canvas::canvasAutoAxes (const graphics_handle& handle) { gh_manager::auto_lock lock; @@ -247,7 +255,8 @@ } } -void Canvas::canvasPaintEvent (void) +void +Canvas::canvasPaintEvent (void) { if (! m_redrawBlocked) { @@ -332,7 +341,8 @@ return zm.contents ("Direction").string_value (); } -void Canvas::canvasMouseMoveEvent (QMouseEvent* event) +void +Canvas::canvasMouseMoveEvent (QMouseEvent* event) { gh_manager::auto_lock lock; graphics_object ax = gh_manager::get_object (m_mouseAxes); @@ -401,7 +411,8 @@ } } -void Canvas::canvasMouseDoubleClickEvent (QMouseEvent* event) +void +Canvas::canvasMouseDoubleClickEvent (QMouseEvent* event) { if (event->buttons () != Qt::LeftButton) return; @@ -485,7 +496,8 @@ return retval; } -void Canvas::canvasMousePressEvent (QMouseEvent* event) +void +Canvas::canvasMousePressEvent (QMouseEvent* event) { gh_manager::auto_lock lock; graphics_object obj = gh_manager::get_object (m_handle); @@ -656,7 +668,8 @@ } } -void Canvas::canvasMouseReleaseEvent (QMouseEvent* event) +void +Canvas::canvasMouseReleaseEvent (QMouseEvent* event) { if ((m_mouseMode == ZoomInMode || m_mouseMode == ZoomOutMode) && m_mouseAxes.ok ()) @@ -722,7 +735,8 @@ m_mouseMode = NoMode; } -void Canvas::canvasWheelEvent (QWheelEvent* event) +void +Canvas::canvasWheelEvent (QWheelEvent* event) { gh_manager::auto_lock lock; graphics_object obj = gh_manager::get_object (m_handle); @@ -829,7 +843,8 @@ } } -bool Canvas::canvasKeyPressEvent (QKeyEvent* event) +bool +Canvas::canvasKeyPressEvent (QKeyEvent* event) { if (m_eventMask & KeyPress) { @@ -845,7 +860,8 @@ return false; } -bool Canvas::canvasKeyReleaseEvent (QKeyEvent* event) +bool +Canvas::canvasKeyReleaseEvent (QKeyEvent* event) { if (! event->isAutoRepeat () && (m_eventMask & KeyRelease)) { @@ -858,8 +874,9 @@ return false; } -Canvas* Canvas::create (const std::string& /* name */, QWidget* parent, - const graphics_handle& handle) +Canvas* +Canvas::create (const std::string& /* name */, QWidget* parent, + const graphics_handle& handle) { // Only OpenGL return new GLCanvas (parent, handle); diff -r 40b2c4323c16 -r 3cc0734283dc libgui/graphics/CheckBoxControl.cc --- a/libgui/graphics/CheckBoxControl.cc Thu Mar 19 12:25:28 2015 -0400 +++ b/libgui/graphics/CheckBoxControl.cc Thu Mar 19 12:27:54 2015 -0400 @@ -32,7 +32,8 @@ namespace QtHandles { -CheckBoxControl* CheckBoxControl::create (const graphics_object& go) +CheckBoxControl* +CheckBoxControl::create (const graphics_object& go) { Object* parent = Object::parentObject (go); diff -r 40b2c4323c16 -r 3cc0734283dc libgui/graphics/Container.cc --- a/libgui/graphics/Container.cc Thu Mar 19 12:25:28 2015 -0400 +++ b/libgui/graphics/Container.cc Thu Mar 19 12:27:54 2015 -0400 @@ -47,7 +47,8 @@ { } -Canvas* Container::canvas (const graphics_handle& gh, bool xcreate) +Canvas* +Container::canvas (const graphics_handle& gh, bool xcreate) { if (! m_canvas && xcreate) { @@ -72,7 +73,8 @@ return m_canvas; } -void Container::resizeEvent (QResizeEvent* /* event */) +void +Container::resizeEvent (QResizeEvent* /* event */) { if (m_canvas) m_canvas->qWidget ()->setGeometry (0, 0, width (), height ()); @@ -97,12 +99,11 @@ } } -void Container::childEvent (QChildEvent* xevent) +void +Container::childEvent (QChildEvent* xevent) { if (xevent->child ()->isWidgetType ()) - { - qobject_cast (xevent->child ())->setMouseTracking (hasMouseTracking ()); - } + qobject_cast (xevent->child ())->setMouseTracking (hasMouseTracking ()); } }; // namespace QtHandles diff -r 40b2c4323c16 -r 3cc0734283dc libgui/graphics/ContextMenu.cc --- a/libgui/graphics/ContextMenu.cc Thu Mar 19 12:25:28 2015 -0400 +++ b/libgui/graphics/ContextMenu.cc Thu Mar 19 12:27:54 2015 -0400 @@ -33,7 +33,8 @@ namespace QtHandles { -ContextMenu* ContextMenu::create (const graphics_object& go) +ContextMenu* +ContextMenu::create (const graphics_object& go) { Object* xparent = Object::parentObject (go); @@ -60,7 +61,8 @@ { } -void ContextMenu::update (int pId) +void +ContextMenu::update (int pId) { uicontextmenu::properties& up = properties (); QMenu* xmenu = qWidget (); @@ -89,23 +91,27 @@ } } -void ContextMenu::aboutToShow (void) +void +ContextMenu::aboutToShow (void) { gh_manager::post_callback (m_handle, "callback"); gh_manager::post_set (m_handle, "visible", "on", false); } -void ContextMenu::aboutToHide (void) +void +ContextMenu::aboutToHide (void) { gh_manager::post_set (m_handle, "visible", "off", false); } -QWidget* ContextMenu::menu (void) +QWidget* +ContextMenu::menu (void) { return qWidget (); } -void ContextMenu::executeAt (const base_properties& props, const QPoint& pt) +void +ContextMenu::executeAt (const base_properties& props, const QPoint& pt) { graphics_handle h = props.get_uicontextmenu (); diff -r 40b2c4323c16 -r 3cc0734283dc libgui/graphics/EditControl.cc --- a/libgui/graphics/EditControl.cc Thu Mar 19 12:25:28 2015 -0400 +++ b/libgui/graphics/EditControl.cc Thu Mar 19 12:27:54 2015 -0400 @@ -34,7 +34,8 @@ namespace QtHandles { -EditControl* EditControl::create (const graphics_object& go) +EditControl* +EditControl::create (const graphics_object& go) { Object* parent = Object::parentObject (go); @@ -62,7 +63,8 @@ init (edit); } -void EditControl::init (QLineEdit* edit, bool callBase) +void +EditControl::init (QLineEdit* edit, bool callBase) { if (callBase) BaseControl::init (edit, callBase); @@ -83,12 +85,13 @@ } EditControl::EditControl (const graphics_object& go, TextEdit* edit) - : BaseControl (go, edit), m_multiLine (true), m_textChanged (false) + : BaseControl (go, edit), m_multiLine (true), m_textChanged (false) { init (edit); } -void EditControl::init (TextEdit* edit, bool callBase) +void +EditControl::init (TextEdit* edit, bool callBase) { if (callBase) BaseControl::init (edit, callBase); @@ -112,12 +115,14 @@ { } -void EditControl::initCommon (QWidget*) +void +EditControl::initCommon (QWidget*) { m_textChanged = false; } -void EditControl::update (int pId) +void +EditControl::update (int pId) { bool handled = false; @@ -137,7 +142,8 @@ } } -bool EditControl::updateSingleLine (int pId) +bool +EditControl::updateSingleLine (int pId) { uicontrol::properties& up = properties (); QLineEdit* edit = qWidget (); @@ -147,11 +153,13 @@ case uicontrol::properties::ID_STRING: edit->setText (Utils::fromStdString (up.get_string_string ())); return true; + case uicontrol::properties::ID_HORIZONTALALIGNMENT: case uicontrol::properties::ID_VERTICALALIGNMENT: edit->setAlignment (Utils::fromHVAlign (up.get_horizontalalignment (), up.get_verticalalignment ())); return true; + case uicontrol::properties::ID_MIN: case uicontrol::properties::ID_MAX: if ((up.get_max () - up.get_min ()) > 1) @@ -162,6 +170,7 @@ init (new TextEdit (container), true); } return true; + default: break; } @@ -169,7 +178,8 @@ return false; } -bool EditControl::updateMultiLine (int pId) +bool +EditControl::updateMultiLine (int pId) { uicontrol::properties& up = properties (); TextEdit* edit = qWidget (); @@ -179,6 +189,7 @@ case uicontrol::properties::ID_STRING: edit->setPlainText (Utils::fromStdString (up.get_string_string ())); return true; + case uicontrol::properties::ID_MIN: case uicontrol::properties::ID_MAX: if ((up.get_max () - up.get_min ()) <= 1) @@ -189,6 +200,7 @@ init (new QLineEdit (container), true); } return true; + default: break; } @@ -196,12 +208,14 @@ return false; } -void EditControl::textChanged (void) +void +EditControl::textChanged (void) { m_textChanged = true; } -void EditControl::editingFinished (void) +void +EditControl::editingFinished (void) { if (m_textChanged) { diff -r 40b2c4323c16 -r 3cc0734283dc libgui/graphics/Figure.cc --- a/libgui/graphics/Figure.cc Thu Mar 19 12:25:28 2015 -0400 +++ b/libgui/graphics/Figure.cc Thu Mar 19 12:27:54 2015 -0400 @@ -58,7 +58,8 @@ DECLARE_GENERICEVENTNOTIFY_SENDER(MenuBar, QMenuBar); -static bool hasUiControlChildren (const figure::properties& fp) +static bool +hasUiControlChildren (const figure::properties& fp) { gh_manager::auto_lock lock; @@ -76,7 +77,8 @@ return false; } -static bool hasUiMenuChildren (const figure::properties& fp) +static bool +hasUiMenuChildren (const figure::properties& fp) { gh_manager::auto_lock lock; @@ -93,7 +95,8 @@ return false; } -static QRect boundingBoxToRect (const Matrix& bb) +static QRect +boundingBoxToRect (const Matrix& bb) { QRect r; @@ -108,15 +111,15 @@ return r; } -Figure* Figure::create (const graphics_object& go) +Figure* +Figure::create (const graphics_object& go) { return new Figure (go, new FigureWindow ()); } Figure::Figure (const graphics_object& go, FigureWindow* win) - : Object (go, win), m_blockUpdates (false), m_figureToolBar (0), - m_menuBar (0), m_innerRect (), m_outerRect (), - m_mouseModeGroup (0) + : Object (go, win), m_blockUpdates (false), m_figureToolBar (0), + m_menuBar (0), m_innerRect (), m_outerRect (), m_mouseModeGroup (0) { m_container = new Container (win); win->setCentralWidget (m_container); @@ -173,7 +176,8 @@ { } -static std::string mouse_mode_to_string (MouseMode mode) +static std::string +mouse_mode_to_string (MouseMode mode) { switch (mode) { @@ -205,7 +209,8 @@ return "none"; } -static MouseMode mouse_mode_from_string (const std::string& mode) +static MouseMode +mouse_mode_from_string (const std::string& mode) { if (mode == "none") return NoMode; @@ -225,7 +230,8 @@ return NoMode; } -QString Figure::fileName (void) +QString +Figure::fileName (void) { gh_manager::auto_lock lock; @@ -236,7 +242,8 @@ return QString::fromStdString (name); } -void Figure::setFileName (const QString& name) +void +Figure::setFileName (const QString& name) { gh_manager::auto_lock lock; @@ -245,7 +252,8 @@ fp.set_filename (name.toStdString ()); } -MouseMode Figure::mouseMode (void) +MouseMode +Figure::mouseMode (void) { gh_manager::auto_lock lock; @@ -265,7 +273,8 @@ return mouse_mode_from_string (mode); } -void Figure::createFigureToolBarAndMenuBar (void) +void +Figure::createFigureToolBarAndMenuBar (void) { QMainWindow* win = qWidget (); @@ -321,7 +330,8 @@ m_menuBar->addReceiver (this); } -void Figure::updateFigureToolBarAndMenuBar (void) +void +Figure::updateFigureToolBarAndMenuBar (void) { if (m_mouseModeGroup) { @@ -331,12 +341,14 @@ } } -Container* Figure::innerContainer (void) +Container* +Figure::innerContainer (void) { return m_container; } -void Figure::redraw (void) +void +Figure::redraw (void) { Canvas* canvas = m_container->canvas (m_handle); @@ -358,7 +370,8 @@ updateFigureToolBarAndMenuBar (); } -void Figure::print (const QString& file_cmd, const QString& term) +void +Figure::print (const QString& file_cmd, const QString& term) { Canvas* canvas = m_container->canvas (m_handle); @@ -366,7 +379,8 @@ canvas->print (file_cmd, term); } -void Figure::beingDeleted (void) +void +Figure::beingDeleted (void) { Canvas* canvas = m_container->canvas (m_handle.value (), false); @@ -378,7 +392,8 @@ qWidget ()->removeReceiver (this); } -void Figure::update (int pId) +void +Figure::update (int pId) { if (m_blockUpdates) return; @@ -406,16 +421,19 @@ //qDebug () << "Figure::update(position): done"; } break; + case figure::properties::ID_NAME: case figure::properties::ID_NUMBERTITLE: win->setWindowTitle (Utils::fromStdString (fp.get_title ())); break; + case figure::properties::ID_VISIBLE: if (fp.is_visible ()) QTimer::singleShot (0, win, SLOT (show ())); else win->hide (); break; + case figure::properties::ID_TOOLBAR: if (fp.toolbar_is ("none")) showFigureToolBar (false); @@ -424,21 +442,25 @@ else // "auto" showFigureToolBar (! hasUiControlChildren (fp)); break; + case figure::properties::ID_MENUBAR: showMenuBar (fp.menubar_is ("figure")); break; + case figure::properties::ID_KEYPRESSFCN: if (fp.get_keypressfcn ().is_empty ()) m_container->canvas (m_handle)->clearEventMask (Canvas::KeyPress); else m_container->canvas (m_handle)->addEventMask (Canvas::KeyPress); break; + case figure::properties::ID_KEYRELEASEFCN: if (fp.get_keyreleasefcn ().is_empty ()) m_container->canvas (m_handle)->clearEventMask (Canvas::KeyRelease); else m_container->canvas (m_handle)->addEventMask (Canvas::KeyRelease); break; + case figure::properties::ID_WINDOWBUTTONMOTIONFCN: { bool hasCallback = ! fp.get_windowbuttonmotionfcn ().is_empty (); @@ -448,6 +470,7 @@ { w->setMouseTracking (hasCallback); } } break; + default: break; } @@ -455,7 +478,8 @@ m_blockUpdates = false; } -void Figure::showFigureToolBar (bool visible) +void +Figure::showFigureToolBar (bool visible) { if ((! m_figureToolBar->isHidden ()) != visible) { @@ -476,7 +500,8 @@ } } -void Figure::showMenuBar (bool visible) +void +Figure::showMenuBar (bool visible) { int h1 = m_menuBar->sizeHint ().height (); @@ -510,7 +535,8 @@ } } -void Figure::updateMenuBar (void) +void +Figure::updateMenuBar (void) { gh_manager::auto_lock lock; graphics_object go = object (); @@ -519,7 +545,8 @@ showMenuBar (Utils::properties
(go).menubar_is ("figure")); } -QWidget* Figure::menu (void) +QWidget* +Figure::menu (void) { return qWidget ()->menuBar (); } @@ -532,7 +559,8 @@ Figure* m_figure; }; -void Figure::updateBoundingBoxHelper (void* data) +void +Figure::updateBoundingBoxHelper (void* data) { gh_manager::auto_lock lock; @@ -543,15 +571,14 @@ { figure::properties& fp = Utils::properties
(go); - //qDebug ("Figure::updateBoundingBoxHelper: internal=%d, bbox=[%g %g %g %g]", - // d->m_internal, d->m_bbox(0), d->m_bbox(1), d->m_bbox(2), d->m_bbox(3)); fp.set_boundingbox (d->m_bbox, d->m_internal, false); } delete d; } -void Figure::updateBoundingBox (bool internal, int flags) +void +Figure::updateBoundingBox (bool internal, int flags) { QWidget* win = qWidget (); Matrix bb (1, 4); @@ -567,7 +594,6 @@ if (r.isValid () && r != m_innerRect) { - //qDebug() << "inner rect changed:" << m_innerRect << "->>" << r; m_innerRect = r; bb(0) = r.x (); @@ -589,7 +615,6 @@ if (r.isValid () && r != m_outerRect) { - //qDebug() << "outer rect changed:" << m_outerRect << "->>" << r; m_outerRect = r; bb(0) = r.x (); @@ -608,12 +633,11 @@ d->m_handle = m_handle; d->m_figure = this; - //qDebug ("Figure::updateBoundingBox: internal=%d, bbox=[%g %g %g %g]", - // d->m_internal, d->m_bbox(0), d->m_bbox(1), d->m_bbox(2), d->m_bbox(3)); gh_manager::post_function (Figure::updateBoundingBoxHelper, d); } -bool Figure::eventNotifyBefore (QObject* obj, QEvent* xevent) +bool +Figure::eventNotifyBefore (QObject* obj, QEvent* xevent) { if (! m_blockUpdates) { @@ -626,14 +650,15 @@ switch (xevent->type ()) { case QEvent::ActionRemoved: - { - QAction* a = dynamic_cast (xevent)->action (); + { + QAction* a = dynamic_cast (xevent)->action (); - if (! a->isSeparator () - && a->objectName () != "builtinMenu") - updateMenuBar (); - } + if (! a->isSeparator () + && a->objectName () != "builtinMenu") + updateMenuBar (); + } break; + default: break; } @@ -646,6 +671,7 @@ xevent->ignore (); gh_manager::post_callback (m_handle, "closerequestfcn"); return true; + default: break; } @@ -655,7 +681,8 @@ return false; } -void Figure::eventNotifyAfter (QObject* watched, QEvent* xevent) +void +Figure::eventNotifyAfter (QObject* watched, QEvent* xevent) { if (! m_blockUpdates) { @@ -666,6 +693,7 @@ case QEvent::Resize: updateBoundingBox (true, UpdateBoundingBoxSize); break; + case QEvent::ChildAdded: if (dynamic_cast (xevent)->child ()->isWidgetType()) @@ -675,6 +703,7 @@ showFigureToolBar (! hasUiControlChildren (fp)); } + default: break; } @@ -692,6 +721,7 @@ updateMenuBar (); } break; + default: break; } @@ -704,9 +734,11 @@ updateBoundingBox (false, UpdateBoundingBoxPosition); updateBoundingBox (true, UpdateBoundingBoxPosition); break; + case QEvent::Resize: updateBoundingBox (false, UpdateBoundingBoxSize); break; + default: break; } @@ -714,13 +746,15 @@ } } -void Figure::helpAboutQtHandles (void) +void +Figure::helpAboutQtHandles (void) { QMessageBox::about (qWidget (), tr ("About QtHandles"), ABOUT_TEXT); } -void Figure::setMouseMode (MouseMode mode) +void +Figure::setMouseMode (MouseMode mode) { if (m_blockUpdates) return; @@ -737,7 +771,8 @@ canvas->setCursor (mode); } -void Figure::fileSaveFigure (bool prompt) +void +Figure::fileSaveFigure (bool prompt) { QString file = fileName (); @@ -769,34 +804,41 @@ } } -void Figure::save_figure_callback (const std::string& file) +void +Figure::save_figure_callback (const std::string& file) { Ffeval (ovl ("print", file)); } -void Figure::fileSaveFigureAs (void) +void +Figure::fileSaveFigureAs (void) { fileSaveFigure (true); } -void Figure::fileCloseFigure (void) +void +Figure::fileCloseFigure (void) { qWidget ()->close (); } -void Figure::editCopy (void) +void +Figure::editCopy (void) { } -void Figure::editCut (void) +void +Figure::editCut (void) { } -void Figure::editPaste (void) +void +Figure::editPaste (void) { } -void Figure::addCustomToolBar (QToolBar* bar, bool visible) +void +Figure::addCustomToolBar (QToolBar* bar, bool visible) { QMainWindow* win = qWidget (); @@ -821,7 +863,8 @@ } } -void Figure::showCustomToolBar (QToolBar* bar, bool visible) +void +Figure::showCustomToolBar (QToolBar* bar, bool visible) { QMainWindow* win = qWidget (); @@ -844,12 +887,14 @@ } } -void Figure::updateContainer (void) +void +Figure::updateContainer (void) { redraw (); } -void Figure::toggleAxes (void) +void +Figure::toggleAxes (void) { Canvas* canvas = m_container->canvas (m_handle); @@ -857,7 +902,8 @@ canvas->toggleAxes (m_handle); } -void Figure::toggleGrid (void) +void +Figure::toggleGrid (void) { Canvas* canvas = m_container->canvas (m_handle); @@ -865,7 +911,8 @@ canvas->toggleGrid (m_handle); } -void Figure::autoAxes (void) +void +Figure::autoAxes (void) { Canvas* canvas = m_container->canvas (m_handle); diff -r 40b2c4323c16 -r 3cc0734283dc libgui/graphics/FigureWindow.cc --- a/libgui/graphics/FigureWindow.cc Thu Mar 19 12:25:28 2015 -0400 +++ b/libgui/graphics/FigureWindow.cc Thu Mar 19 12:27:54 2015 -0400 @@ -42,7 +42,8 @@ { } -QMenu* FigureWindow::createPopupMenu (void) +QMenu* +FigureWindow::createPopupMenu (void) { // For the time being, disable menubar/toolbar popup menu return 0; diff -r 40b2c4323c16 -r 3cc0734283dc libgui/graphics/GLCanvas.cc --- a/libgui/graphics/GLCanvas.cc Thu Mar 19 12:25:28 2015 -0400 +++ b/libgui/graphics/GLCanvas.cc Thu Mar 19 12:27:54 2015 -0400 @@ -47,7 +47,8 @@ { } -void GLCanvas::draw (const graphics_handle& gh) +void +GLCanvas::draw (const graphics_handle& gh) { gh_manager::auto_lock lock; graphics_object go = gh_manager::get_object (gh); @@ -61,23 +62,26 @@ } } -void GLCanvas::toggleAxes (const graphics_handle& gh) +void +GLCanvas::toggleAxes (const graphics_handle& gh) { canvasToggleAxes (gh); } -void GLCanvas::toggleGrid (const graphics_handle& gh) +void +GLCanvas::toggleGrid (const graphics_handle& gh) { canvasToggleGrid (gh); } -void GLCanvas::autoAxes (const graphics_handle& gh) +void +GLCanvas::autoAxes (const graphics_handle& gh) { canvasAutoAxes (gh); } -graphics_object GLCanvas::selectFromAxes (const graphics_object& ax, - const QPoint& pt) +graphics_object +GLCanvas::selectFromAxes (const graphics_object& ax, const QPoint& pt) { makeCurrent (); @@ -92,7 +96,8 @@ return graphics_object (); } -inline void glDrawZoomBox (const QPoint& p1, const QPoint& p2) +inline void +glDrawZoomBox (const QPoint& p1, const QPoint& p2) { glVertex2d (p1.x (), p1.y ()); glVertex2d (p2.x (), p1.y ()); @@ -101,7 +106,8 @@ glVertex2d (p1.x (), p1.y ()); } -void GLCanvas::drawZoomBox (const QPoint& p1, const QPoint& p2) +void +GLCanvas::drawZoomBox (const QPoint& p1, const QPoint& p2) { glPushMatrix (); @@ -130,43 +136,51 @@ glPopMatrix (); } -void GLCanvas::paintGL (void) +void +GLCanvas::paintGL (void) { canvasPaintEvent (); } -void GLCanvas::mouseDoubleClickEvent (QMouseEvent* xevent) +void +GLCanvas::mouseDoubleClickEvent (QMouseEvent* xevent) { canvasMouseDoubleClickEvent (xevent); } -void GLCanvas::mouseMoveEvent (QMouseEvent* xevent) +void +GLCanvas::mouseMoveEvent (QMouseEvent* xevent) { canvasMouseMoveEvent (xevent); } -void GLCanvas::mousePressEvent (QMouseEvent* xevent) +void +GLCanvas::mousePressEvent (QMouseEvent* xevent) { canvasMousePressEvent (xevent); } -void GLCanvas::mouseReleaseEvent (QMouseEvent* xevent) +void +GLCanvas::mouseReleaseEvent (QMouseEvent* xevent) { canvasMouseReleaseEvent (xevent); } -void GLCanvas::wheelEvent (QWheelEvent* xevent) +void +GLCanvas::wheelEvent (QWheelEvent* xevent) { canvasWheelEvent (xevent); } -void GLCanvas::keyPressEvent (QKeyEvent* xevent) +void +GLCanvas::keyPressEvent (QKeyEvent* xevent) { if (! canvasKeyPressEvent (xevent)) QGLWidget::keyPressEvent (xevent); } -void GLCanvas::keyReleaseEvent (QKeyEvent* xevent) +void +GLCanvas::keyReleaseEvent (QKeyEvent* xevent) { if (! canvasKeyReleaseEvent (xevent)) QGLWidget::keyReleaseEvent (xevent); diff -r 40b2c4323c16 -r 3cc0734283dc libgui/graphics/KeyMap.cc --- a/libgui/graphics/KeyMap.cc Thu Mar 19 12:25:28 2015 -0400 +++ b/libgui/graphics/KeyMap.cc Thu Mar 19 12:27:54 2015 -0400 @@ -35,7 +35,8 @@ namespace KeyMap { -std::string qKeyToKeyString (int key) +std::string +qKeyToKeyString (int key) { static QMap keyMapper; diff -r 40b2c4323c16 -r 3cc0734283dc libgui/graphics/ListBoxControl.cc --- a/libgui/graphics/ListBoxControl.cc Thu Mar 19 12:25:28 2015 -0400 +++ b/libgui/graphics/ListBoxControl.cc Thu Mar 19 12:27:54 2015 -0400 @@ -33,7 +33,8 @@ namespace QtHandles { -static void updateSelection (QListWidget* list, const Matrix& value) +static void +updateSelection (QListWidget* list, const Matrix& value) { octave_idx_type n = value.numel (); int lc = list->count (); @@ -60,7 +61,8 @@ } } -ListBoxControl* ListBoxControl::create (const graphics_object& go) +ListBoxControl* +ListBoxControl::create (const graphics_object& go) { Object* parent = Object::parentObject (go); @@ -76,7 +78,7 @@ } ListBoxControl::ListBoxControl (const graphics_object& go, QListWidget* list) - : BaseControl (go, list), m_blockCallback (false) + : BaseControl (go, list), m_blockCallback (false) { uicontrol::properties& up = properties (); @@ -116,7 +118,8 @@ { } -void ListBoxControl::update (int pId) +void +ListBoxControl::update (int pId) { uicontrol::properties& up = properties (); QListWidget* list = qWidget (); @@ -130,25 +133,30 @@ updateSelection (list, up.get_value ().matrix_value ()); m_blockCallback = false; break; + case uicontrol::properties::ID_MIN: + case uicontrol::properties::ID_MAX: if ((up.get_max () - up.get_min ()) > 1) list->setSelectionMode (QAbstractItemView::ExtendedSelection); else list->setSelectionMode (QAbstractItemView::SingleSelection); break; + case uicontrol::properties::ID_VALUE: m_blockCallback = true; updateSelection (list, up.get_value ().matrix_value ()); m_blockCallback = false; break; + default: BaseControl::update (pId); break; } } -void ListBoxControl::itemSelectionChanged (void) +void +ListBoxControl::itemSelectionChanged (void) { if (! m_blockCallback) { diff -r 40b2c4323c16 -r 3cc0734283dc libgui/graphics/Logger.cc --- a/libgui/graphics/Logger.cc Thu Mar 19 12:25:28 2015 -0400 +++ b/libgui/graphics/Logger.cc Thu Mar 19 12:27:54 2015 -0400 @@ -39,7 +39,7 @@ QMutex* Logger::s_mutex = 0; Logger::Logger (void) - : m_debugEnabled (false) + : m_debugEnabled (false) { QProcessEnvironment pe (QProcessEnvironment::systemEnvironment ()); @@ -51,7 +51,8 @@ { } -Logger* Logger::instance (void) +Logger* +Logger::instance (void) { if (! s_instance) { @@ -63,18 +64,19 @@ } #define STATIC_LOGGER(fun) \ -void Logger::fun (const char* fmt, ...) \ -{ \ - QMutexLocker lock (s_mutex); \ - va_list vl; \ - va_start (vl, fmt); \ - instance ()->fun ## V (fmt, vl); \ - va_end (vl); \ -} + void Logger::fun (const char* fmt, ...) \ + { \ + QMutexLocker lock (s_mutex); \ + va_list vl; \ + va_start (vl, fmt); \ + instance ()->fun ## V (fmt, vl); \ + va_end (vl); \ + } STATIC_LOGGER (debug) -void Logger::debugV (const char* fmt, va_list arg) +void +Logger::debugV (const char* fmt, va_list arg) { if (m_debugEnabled) { diff -r 40b2c4323c16 -r 3cc0734283dc libgui/graphics/Menu.cc --- a/libgui/graphics/Menu.cc Thu Mar 19 12:25:28 2015 -0400 +++ b/libgui/graphics/Menu.cc Thu Mar 19 12:27:54 2015 -0400 @@ -36,7 +36,8 @@ namespace QtHandles { -static QKeySequence accelSequence (const uimenu::properties& up) +static QKeySequence +accelSequence (const uimenu::properties& up) { std::string s (up.get_accelerator ()); @@ -56,7 +57,8 @@ return QKeySequence (); } -Menu* Menu::create (const graphics_object& go) +Menu* +Menu::create (const graphics_object& go) { Object* parent_obj = Object::parentObject (go); @@ -72,19 +74,22 @@ } Menu::Menu (const graphics_object& go, QAction* action, Object* xparent) - : Object (go, action), m_parent (0), m_separator (0) + : Object (go, action), m_parent (0), m_separator (0) { uimenu::properties& up = properties (); action->setText (Utils::fromStdString (up.get_label ())); + if (up.is_checked ()) { action->setCheckable (true); action->setChecked (up.is_checked ()); } + action->setEnabled (up.is_enable ()); action->setShortcut (accelSequence (up)); action->setVisible (up.is_visible ()); + if (up.is_separator ()) { m_separator = new QAction (action); @@ -151,7 +156,8 @@ { } -void Menu::update (int pId) +void +Menu::update (int pId) { uimenu::properties& up = properties (); QAction* action = qWidget (); @@ -161,6 +167,7 @@ case uimenu::properties::ID_LABEL: action->setText (Utils::fromStdString (up.get_label ())); break; + case uimenu::properties::ID_CHECKED: if (up.is_checked ()) { @@ -173,13 +180,16 @@ action->setCheckable (false); } break; + case uimenu::properties::ID_ENABLE: action->setEnabled (up.is_enable ()); break; + case uimenu::properties::ID_ACCELERATOR: if (! action->menu ()) action->setShortcut (accelSequence (up)); break; + case uimenu::properties::ID_SEPARATOR: if (up.is_separator ()) { @@ -199,48 +209,56 @@ m_separator = 0; } break; + case uimenu::properties::ID_VISIBLE: action->setVisible (up.is_visible ()); if (m_separator) m_separator->setVisible (up.is_visible ()); break; + case uimenu::properties::ID_POSITION: - if (m_separator) - m_parent->removeAction (m_separator); - m_parent->removeAction (action); - { - int pos = static_cast (up.get_position ()); - QAction* before = 0; + { + if (m_separator) + m_parent->removeAction (m_separator); + + m_parent->removeAction (action); - if (pos > 0) - { - int count = 0; + int pos = static_cast (up.get_position ()); + QAction* before = 0; + + if (pos > 0) + { + int count = 0; - foreach (QAction* a, m_parent->actions ()) - if (! a->isSeparator () && a->objectName () != "builtinMenu") - { - count++; - if (pos <= count) - { - before = a; - break; - } - } - } + foreach (QAction* a, m_parent->actions ()) + if (! a->isSeparator () && a->objectName () != "builtinMenu") + { + count++; + if (pos <= count) + { + before = a; + break; + } + } + } - if (m_separator) - m_parent->insertAction (before, m_separator); - m_parent->insertAction (before, action); - updateSiblingPositions (); - } + if (m_separator) + m_parent->insertAction (before, m_separator); + + m_parent->insertAction (before, action); + + updateSiblingPositions (); + } break; + default: Object::update (pId); break; } } -QWidget* Menu::menu (void) +QWidget* +Menu::menu (void) { QAction* action = qWidget (); QMenu* _menu = action->menu (); @@ -257,7 +275,8 @@ return _menu; } -void Menu::actionTriggered (void) +void +Menu::actionTriggered (void) { QAction* action = qWidget (); @@ -266,12 +285,14 @@ gh_manager::post_callback (m_handle, "callback"); } -void Menu::actionHovered (void) +void +Menu::actionHovered (void) { gh_manager::post_callback (m_handle, "callback"); } -void Menu::updateSiblingPositions (void) +void +Menu::updateSiblingPositions (void) { if (m_parent) { diff -r 40b2c4323c16 -r 3cc0734283dc libgui/graphics/MouseModeActionGroup.cc --- a/libgui/graphics/MouseModeActionGroup.cc Thu Mar 19 12:25:28 2015 -0400 +++ b/libgui/graphics/MouseModeActionGroup.cc Thu Mar 19 12:27:54 2015 -0400 @@ -67,7 +67,8 @@ { } -void MouseModeActionGroup::actionToggled (bool checked) +void +MouseModeActionGroup::actionToggled (bool checked) { if (! checked) { @@ -92,7 +93,8 @@ } } -void MouseModeActionGroup::setMode (MouseMode mode) +void +MouseModeActionGroup::setMode (MouseMode mode) { for (int i = 0; i < m_actions.size (); i++) m_actions[i]->setChecked (i == mode - 1); diff -r 40b2c4323c16 -r 3cc0734283dc libgui/graphics/Object.cc --- a/libgui/graphics/Object.cc Thu Mar 19 12:25:28 2015 -0400 +++ b/libgui/graphics/Object.cc Thu Mar 19 12:27:54 2015 -0400 @@ -47,7 +47,8 @@ init (obj); } -void Object::init (QObject* obj, bool) +void +Object::init (QObject* obj, bool) { if (m_qobject) qCritical ("QtHandles::Object::init: " @@ -68,7 +69,8 @@ { } -graphics_object Object::object (void) const +graphics_object +Object::object (void) const { gh_manager::auto_lock lock (false); @@ -80,7 +82,8 @@ return gh_manager::get_object (m_handle); } -void Object::slotUpdate (int pId) +void +Object::slotUpdate (int pId) { gh_manager::auto_lock lock; @@ -92,6 +95,7 @@ case base_properties::ID_BEINGDELETED: beingDeleted (); break; + default: if (object ().valid_object ()) update (pId); @@ -99,14 +103,16 @@ } } -void Object::slotFinalize (void) +void +Object::slotFinalize (void) { gh_manager::auto_lock lock; finalize (); } -void Object::slotRedraw (void) +void +Object::slotRedraw (void) { gh_manager::auto_lock lock; @@ -114,7 +120,8 @@ redraw (); } -void Object::slotPrint (const QString& file_cmd, const QString& term) +void +Object::slotPrint (const QString& file_cmd, const QString& term) { gh_manager::auto_lock lock; @@ -122,11 +129,13 @@ print (file_cmd, term); } -void Object::update (int /* pId */) +void +Object::update (int /* pId */) { } -void Object::finalize (void) +void +Object::finalize (void) { if (m_qobject) { @@ -136,15 +145,18 @@ deleteLater (); } -void Object::redraw (void) +void +Object::redraw (void) { } -void Object::print (const QString& /* file_cmd */, const QString& /* term */) +void +Object::print (const QString& /* file_cmd */, const QString& /* term */) { } -void Object::beingDeleted (void) +void +Object::beingDeleted (void) { } @@ -154,7 +166,8 @@ m_qobject = 0; } -Object* Object::parentObject (const graphics_object& go) +Object* +Object::parentObject (const graphics_object& go) { gh_manager::auto_lock lock; @@ -164,7 +177,8 @@ return parent; } -Object* Object::fromQObject (QObject* obj) +Object* +Object::fromQObject (QObject* obj) { QVariant v = obj->property ("QtHandles::Object"); diff -r 40b2c4323c16 -r 3cc0734283dc libgui/graphics/ObjectFactory.cc --- a/libgui/graphics/ObjectFactory.cc Thu Mar 19 12:25:28 2015 -0400 +++ b/libgui/graphics/ObjectFactory.cc Thu Mar 19 12:27:54 2015 -0400 @@ -54,7 +54,8 @@ namespace QtHandles { -ObjectFactory* ObjectFactory::instance (void) +ObjectFactory* +ObjectFactory::instance (void) { static ObjectFactory s_instance; static bool s_instanceCreated = false; @@ -69,7 +70,8 @@ return &s_instance; } -void ObjectFactory::createObject (double handle) +void +ObjectFactory::createObject (double handle) { gh_manager::auto_lock lock; diff -r 40b2c4323c16 -r 3cc0734283dc libgui/graphics/ObjectProxy.cc --- a/libgui/graphics/ObjectProxy.cc Thu Mar 19 12:25:28 2015 -0400 +++ b/libgui/graphics/ObjectProxy.cc Thu Mar 19 12:27:54 2015 -0400 @@ -40,7 +40,8 @@ init (obj); } -void ObjectProxy::init (Object* obj) +void +ObjectProxy::init (Object* obj) { if (obj != m_object) { @@ -72,13 +73,15 @@ } } -void ObjectProxy::setObject (Object* obj) +void +ObjectProxy::setObject (Object* obj) { emit sendFinalize (); init (obj); } -void ObjectProxy::update (int pId) +void +ObjectProxy::update (int pId) { if (octave_thread::is_octave_thread ()) emit sendUpdate (pId); @@ -86,18 +89,21 @@ m_object->slotUpdate (pId); } -void ObjectProxy::finalize (void) +void +ObjectProxy::finalize (void) { emit sendFinalize (); init (0); } -void ObjectProxy::redraw (void) +void +ObjectProxy::redraw (void) { emit sendRedraw (); } - void ObjectProxy::print (const QString& file_cmd, const QString& term) +void +ObjectProxy::print (const QString& file_cmd, const QString& term) { emit sendPrint (file_cmd, term); } diff -r 40b2c4323c16 -r 3cc0734283dc libgui/graphics/Panel.cc --- a/libgui/graphics/Panel.cc Thu Mar 19 12:25:28 2015 -0400 +++ b/libgui/graphics/Panel.cc Thu Mar 19 12:27:54 2015 -0400 @@ -39,7 +39,8 @@ namespace QtHandles { -static int frameStyleFromProperties (const uipanel::properties& pp) +static int +frameStyleFromProperties (const uipanel::properties& pp) { if (pp.bordertype_is ("none")) return QFrame::NoFrame; @@ -55,7 +56,8 @@ return (QFrame::Panel | QFrame::Plain); } -static void setupPalette (const uipanel::properties& pp, QPalette& p) +static void +setupPalette (const uipanel::properties& pp, QPalette& p) { p.setColor (QPalette::Window, Utils::fromRgb (pp.get_backgroundcolor_rgb ())); @@ -67,7 +69,8 @@ Utils::fromRgb (pp.get_shadowcolor_rgb ())); } -static int borderWidthFromProperties (const uipanel::properties& pp) +static int +borderWidthFromProperties (const uipanel::properties& pp) { int bw = 0; @@ -81,7 +84,8 @@ return bw; } -Panel* Panel::create (const graphics_object& go) +Panel* +Panel::create (const graphics_object& go) { Object* parent = Object::parentObject (go); @@ -97,7 +101,7 @@ } Panel::Panel (const graphics_object& go, QFrame* frame) - : Object (go, frame), m_container (0), m_title (0), m_blockUpdates (false) + : Object (go, frame), m_container (0), m_title (0), m_blockUpdates (false) { uipanel::properties& pp = properties (); @@ -144,7 +148,8 @@ { } -bool Panel::eventFilter (QObject* watched, QEvent* xevent) +bool +Panel::eventFilter (QObject* watched, QEvent* xevent) { if (! m_blockUpdates) { @@ -177,6 +182,7 @@ } } break; + case QEvent::MouseButtonPress: { QMouseEvent* m = dynamic_cast (xevent); @@ -189,6 +195,7 @@ } } break; + default: break; } @@ -205,6 +212,7 @@ properties ().update_boundingbox (); } break; + default: break; } @@ -214,7 +222,8 @@ return false; } -void Panel::update (int pId) +void +Panel::update (int pId) { uipanel::properties& pp = properties (); QFrame* frame = qWidget (); @@ -224,69 +233,76 @@ switch (pId) { case uipanel::properties::ID_POSITION: - { - Matrix bb = pp.get_boundingbox (false); + { + Matrix bb = pp.get_boundingbox (false); - frame->setGeometry (xround (bb(0)), xround (bb(1)), - xround (bb(2)), xround (bb(3))); - updateLayout (); - } + frame->setGeometry (xround (bb(0)), xround (bb(1)), + xround (bb(2)), xround (bb(3))); + updateLayout (); + } break; + case uipanel::properties::ID_BORDERWIDTH: frame->setLineWidth (xround (pp.get_borderwidth ())); updateLayout (); break; + case uipanel::properties::ID_BACKGROUNDCOLOR: case uipanel::properties::ID_FOREGROUNDCOLOR: case uipanel::properties::ID_HIGHLIGHTCOLOR: case uipanel::properties::ID_SHADOWCOLOR: - { - QPalette pal = frame->palette (); + { + QPalette pal = frame->palette (); - setupPalette (pp, pal); - frame->setPalette (pal); - if (m_title) - m_title->setPalette (pal); - } + setupPalette (pp, pal); + frame->setPalette (pal); + if (m_title) + m_title->setPalette (pal); + } break; + case uipanel::properties::ID_TITLE: - { - QString title = Utils::fromStdString (pp.get_title ()); + { + QString title = Utils::fromStdString (pp.get_title ()); - if (title.isEmpty ()) - { - if (m_title) - delete m_title; - m_title = 0; - } - else - { - if (! m_title) - { - QPalette pal = frame->palette (); + if (title.isEmpty ()) + { + if (m_title) + delete m_title; + m_title = 0; + } + else + { + if (! m_title) + { + QPalette pal = frame->palette (); - m_title = new QLabel (title, frame); - m_title->setAutoFillBackground (true); - m_title->setContentsMargins (4, 0, 4, 0); - m_title->setPalette (pal); - m_title->setFont (Utils::computeFont (pp)); - m_title->show (); - } - else - { - m_title->setText (title); - m_title->resize (m_title->sizeHint ()); - } - } - updateLayout (); - } + m_title = new QLabel (title, frame); + m_title->setAutoFillBackground (true); + m_title->setContentsMargins (4, 0, 4, 0); + m_title->setPalette (pal); + m_title->setFont (Utils::computeFont (pp)); + m_title->show (); + } + else + { + m_title->setText (title); + m_title->resize (m_title->sizeHint ()); + } + } + updateLayout (); + } + break; + case uipanel::properties::ID_TITLEPOSITION: updateLayout (); break; + case uipanel::properties::ID_BORDERTYPE: frame->setFrameStyle (frameStyleFromProperties (pp)); updateLayout (); break; + case uipanel::properties::ID_FONTNAME: case uipanel::properties::ID_FONTSIZE: case uipanel::properties::ID_FONTWEIGHT: @@ -298,10 +314,12 @@ updateLayout (); } break; + case uipanel::properties::ID_VISIBLE: frame->setVisible (pp.is_visible ()); updateLayout (); break; + default: break; } @@ -309,7 +327,8 @@ m_blockUpdates = false; } -void Panel::redraw (void) +void +Panel::redraw (void) { Canvas* canvas = m_container->canvas (m_handle); @@ -317,7 +336,8 @@ canvas->redraw (); } -void Panel::updateLayout (void) +void +Panel::updateLayout (void) { uipanel::properties& pp = properties (); QFrame* frame = qWidget (); diff -r 40b2c4323c16 -r 3cc0734283dc libgui/graphics/PopupMenuControl.cc --- a/libgui/graphics/PopupMenuControl.cc Thu Mar 19 12:25:28 2015 -0400 +++ b/libgui/graphics/PopupMenuControl.cc Thu Mar 19 12:27:54 2015 -0400 @@ -33,7 +33,8 @@ namespace QtHandles { -PopupMenuControl* PopupMenuControl::create (const graphics_object& go) +PopupMenuControl* +PopupMenuControl::create (const graphics_object& go) { Object* parent = Object::parentObject (go); @@ -49,7 +50,7 @@ } PopupMenuControl::PopupMenuControl (const graphics_object& go, QComboBox *box) - : BaseControl (go, box), m_blockUpdate (false) + : BaseControl (go, box), m_blockUpdate (false) { uicontrol::properties& up = properties (); @@ -94,6 +95,7 @@ } m_blockUpdate = false; break; + case uicontrol::properties::ID_VALUE: { Matrix value = up.get_value ().matrix_value (); @@ -110,13 +112,15 @@ } } break; + default: BaseControl::update (pId); break; } } -void PopupMenuControl::currentIndexChanged (int index) +void +PopupMenuControl::currentIndexChanged (int index) { if (! m_blockUpdate) { diff -r 40b2c4323c16 -r 3cc0734283dc libgui/graphics/PushButtonControl.cc --- a/libgui/graphics/PushButtonControl.cc Thu Mar 19 12:25:28 2015 -0400 +++ b/libgui/graphics/PushButtonControl.cc Thu Mar 19 12:27:54 2015 -0400 @@ -34,7 +34,8 @@ namespace QtHandles { -PushButtonControl* PushButtonControl::create (const graphics_object& go) +PushButtonControl* +PushButtonControl::create (const graphics_object& go) { Object* parent = Object::parentObject (go); @@ -49,7 +50,8 @@ return 0; } -PushButtonControl::PushButtonControl (const graphics_object& go, QPushButton* btn) +PushButtonControl::PushButtonControl (const graphics_object& go, + QPushButton* btn) : ButtonControl (go, btn) { btn->setAutoFillBackground (true); @@ -59,7 +61,8 @@ { } -void PushButtonControl::update (int pId) +void +PushButtonControl::update (int pId) { uicontrol::properties& up = properties (); QPushButton* btn = qWidget (); @@ -69,6 +72,7 @@ case uicontrol::properties::ID_STRING: btn->setText (Utils::fromStdString (up.get_string_string ())); break; + default: BaseControl::update (pId); break; diff -r 40b2c4323c16 -r 3cc0734283dc libgui/graphics/PushTool.cc --- a/libgui/graphics/PushTool.cc Thu Mar 19 12:25:28 2015 -0400 +++ b/libgui/graphics/PushTool.cc Thu Mar 19 12:27:54 2015 -0400 @@ -31,7 +31,8 @@ namespace QtHandles { -PushTool* PushTool::create (const graphics_object& go) +PushTool* +PushTool::create (const graphics_object& go) { Object* parent = Object::parentObject (go); @@ -47,7 +48,7 @@ } PushTool::PushTool (const graphics_object& go, QAction* action) - : ToolBarButton (go, action) + : ToolBarButton (go, action) { connect (action, SIGNAL (triggered (bool)), this, SLOT (clicked (void))); } @@ -56,7 +57,8 @@ { } -void PushTool::update (int pId) +void +PushTool::update (int pId) { switch (pId) { @@ -66,7 +68,8 @@ } } -void PushTool::clicked (void) +void +PushTool::clicked (void) { gh_manager::post_callback (m_handle, "clickedcallback"); } diff -r 40b2c4323c16 -r 3cc0734283dc libgui/graphics/QtHandlesUtils.cc --- a/libgui/graphics/QtHandlesUtils.cc Thu Mar 19 12:25:28 2015 -0400 +++ b/libgui/graphics/QtHandlesUtils.cc Thu Mar 19 12:27:54 2015 -0400 @@ -45,17 +45,20 @@ namespace Utils { -QString fromStdString (const std::string& s) +QString +fromStdString (const std::string& s) { return QString::fromLocal8Bit (s.c_str ()); } -std::string toStdString (const QString& s) +std::string +toStdString (const QString& s) { return std::string (s.toLocal8Bit ().data ()); } -QStringList fromStringVector (const string_vector& v) +QStringList +fromStringVector (const string_vector& v) { QStringList l; octave_idx_type n = v.length (); @@ -66,7 +69,8 @@ return l; } -string_vector toStringVector (const QStringList& l) +string_vector +toStringVector (const QStringList& l) { string_vector v (l.length ()); int i = 0; @@ -78,7 +82,8 @@ } template -QFont computeFont (const typename T::properties& props, int height) +QFont +computeFont (const typename T::properties& props, int height) { QFont f (fromStdString (props.get_fontname ())); @@ -109,10 +114,12 @@ template QFont computeFont (const uicontrol::properties& props, int height); + template QFont computeFont (const uipanel::properties& props, int height); -QColor fromRgb (const Matrix& rgb) +QColor +fromRgb (const Matrix& rgb) { QColor c; @@ -122,7 +129,8 @@ return c; } -Matrix toRgb (const QColor& c) +Matrix +toRgb (const QColor& c) { Matrix rgb (1, 3); double* rgbData = rgb.fortran_vec (); @@ -132,7 +140,8 @@ return rgb; } -std::string figureSelectionType (QMouseEvent* event, bool isDoubleClick) +std::string +figureSelectionType (QMouseEvent* event, bool isDoubleClick) { if (isDoubleClick) return std::string ("open"); @@ -167,7 +176,8 @@ return std::string ("normal"); } -Matrix figureCurrentPoint (const graphics_object& fig, QMouseEvent* event) +Matrix +figureCurrentPoint (const graphics_object& fig, QMouseEvent* event) { Object* tkFig = Backend::toolkitObject (fig); @@ -188,8 +198,8 @@ return Matrix (1, 2, 0.0); } -Qt::Alignment fromHVAlign (const caseless_str& halign, - const caseless_str& valign) +Qt::Alignment +fromHVAlign (const caseless_str& halign, const caseless_str& valign) { Qt::Alignment flags; @@ -214,7 +224,8 @@ return flags; } -QImage makeImageFromCData (const octave_value& v, int width, int height) +QImage +makeImageFromCData (const octave_value& v, int width, int height) { dim_vector dv (v.dims ()); @@ -289,7 +300,8 @@ return QImage (); } -octave_scalar_map makeKeyEventStruct (QKeyEvent* event) +octave_scalar_map +makeKeyEventStruct (QKeyEvent* event) { octave_scalar_map retval; diff -r 40b2c4323c16 -r 3cc0734283dc libgui/graphics/RadioButtonControl.cc --- a/libgui/graphics/RadioButtonControl.cc Thu Mar 19 12:25:28 2015 -0400 +++ b/libgui/graphics/RadioButtonControl.cc Thu Mar 19 12:27:54 2015 -0400 @@ -33,7 +33,8 @@ namespace QtHandles { -RadioButtonControl* RadioButtonControl::create (const graphics_object& go) +RadioButtonControl* +RadioButtonControl::create (const graphics_object& go) { Object* parent = Object::parentObject (go); @@ -50,7 +51,7 @@ RadioButtonControl::RadioButtonControl (const graphics_object& go, QRadioButton* radio) - : ButtonControl (go, radio) + : ButtonControl (go, radio) { radio->setAutoFillBackground (true); radio->setAutoExclusive (false); diff -r 40b2c4323c16 -r 3cc0734283dc libgui/graphics/SliderControl.cc --- a/libgui/graphics/SliderControl.cc Thu Mar 19 12:25:28 2015 -0400 +++ b/libgui/graphics/SliderControl.cc Thu Mar 19 12:27:54 2015 -0400 @@ -35,7 +35,8 @@ namespace QtHandles { -SliderControl* SliderControl::create (const graphics_object& go) +SliderControl* +SliderControl::create (const graphics_object& go) { Object* parent = Object::parentObject (go); @@ -52,7 +53,7 @@ SliderControl::SliderControl (const graphics_object& go, QAbstractSlider* slider) - : BaseControl (go, slider), m_blockUpdates (false) + : BaseControl (go, slider), m_blockUpdates (false) { uicontrol::properties& up = properties (); @@ -80,7 +81,8 @@ { } -void SliderControl::update (int pId) +void +SliderControl::update (int pId) { uicontrol::properties& up = properties (); QScrollBar* slider = qWidget (); @@ -88,36 +90,39 @@ switch (pId) { case uicontrol::properties::ID_SLIDERSTEP: - { - Matrix steps = up.get_sliderstep ().matrix_value (); + { + Matrix steps = up.get_sliderstep ().matrix_value (); - slider->setSingleStep (xround (steps(0) * RANGE_INT_MAX)); - slider->setPageStep (xround (steps(1) * RANGE_INT_MAX)); - } + slider->setSingleStep (xround (steps(0) * RANGE_INT_MAX)); + slider->setPageStep (xround (steps(1) * RANGE_INT_MAX)); + } break; + case uicontrol::properties::ID_VALUE: - { - Matrix value = up.get_value ().matrix_value (); - double dmax = up.get_max (), dmin = up.get_min (); + { + Matrix value = up.get_value ().matrix_value (); + double dmax = up.get_max (), dmin = up.get_min (); - if (value.numel () > 0) - { - int ival = xround (((value(0) - dmin) / (dmax - dmin)) - * RANGE_INT_MAX); + if (value.numel () > 0) + { + int ival = xround (((value(0) - dmin) / (dmax - dmin)) + * RANGE_INT_MAX); - m_blockUpdates = true; - slider->setValue (ival); - m_blockUpdates = false; - } - } + m_blockUpdates = true; + slider->setValue (ival); + m_blockUpdates = false; + } + } break; + default: BaseControl::update (pId); break; } } -void SliderControl::valueChanged (int ival) +void +SliderControl::valueChanged (int ival) { if (! m_blockUpdates) { diff -r 40b2c4323c16 -r 3cc0734283dc libgui/graphics/TextControl.cc --- a/libgui/graphics/TextControl.cc Thu Mar 19 12:25:28 2015 -0400 +++ b/libgui/graphics/TextControl.cc Thu Mar 19 12:27:54 2015 -0400 @@ -33,7 +33,8 @@ namespace QtHandles { -TextControl* TextControl::create (const graphics_object& go) +TextControl* +TextControl::create (const graphics_object& go) { Object* parent = Object::parentObject (go); @@ -49,7 +50,7 @@ } TextControl::TextControl (const graphics_object& go, QLabel* label) - : BaseControl (go, label) + : BaseControl (go, label) { uicontrol::properties& up = properties (); @@ -66,7 +67,8 @@ { } -void TextControl::update (int pId) +void +TextControl::update (int pId) { uicontrol::properties& up = properties (); QLabel* label = qWidget (); @@ -77,11 +79,13 @@ // FIXME: support string_vector label->setText (Utils::fromStdString (up.get_string_string ())); break; + case uicontrol::properties::ID_HORIZONTALALIGNMENT: case uicontrol::properties::ID_VERTICALALIGNMENT: label->setAlignment (Utils::fromHVAlign (up.get_horizontalalignment (), up.get_verticalalignment ())); break; + default: BaseControl::update (pId); break; diff -r 40b2c4323c16 -r 3cc0734283dc libgui/graphics/TextEdit.cc --- a/libgui/graphics/TextEdit.cc Thu Mar 19 12:25:28 2015 -0400 +++ b/libgui/graphics/TextEdit.cc Thu Mar 19 12:27:54 2015 -0400 @@ -31,14 +31,16 @@ namespace QtHandles { -void TextEdit::focusOutEvent (QFocusEvent* xevent) +void +TextEdit::focusOutEvent (QFocusEvent* xevent) { QTextEdit::focusOutEvent (xevent); emit editingFinished (); } -void TextEdit::keyPressEvent (QKeyEvent* xevent) +void +TextEdit::keyPressEvent (QKeyEvent* xevent) { QTextEdit::keyPressEvent (xevent); diff -r 40b2c4323c16 -r 3cc0734283dc libgui/graphics/ToggleButtonControl.cc --- a/libgui/graphics/ToggleButtonControl.cc Thu Mar 19 12:25:28 2015 -0400 +++ b/libgui/graphics/ToggleButtonControl.cc Thu Mar 19 12:27:54 2015 -0400 @@ -33,7 +33,8 @@ namespace QtHandles { -ToggleButtonControl* ToggleButtonControl::create (const graphics_object& go) +ToggleButtonControl* +ToggleButtonControl::create (const graphics_object& go) { Object* parent = Object::parentObject (go); diff -r 40b2c4323c16 -r 3cc0734283dc libgui/graphics/ToggleTool.cc --- a/libgui/graphics/ToggleTool.cc Thu Mar 19 12:25:28 2015 -0400 +++ b/libgui/graphics/ToggleTool.cc Thu Mar 19 12:27:54 2015 -0400 @@ -31,7 +31,8 @@ namespace QtHandles { -ToggleTool* ToggleTool::create (const graphics_object& go) +ToggleTool* +ToggleTool::create (const graphics_object& go) { Object* parent = Object::parentObject (go); @@ -47,7 +48,7 @@ } ToggleTool::ToggleTool (const graphics_object& go, QAction* action) - : ToolBarButton (go, action) + : ToolBarButton (go, action) { uitoggletool::properties& tp = properties (); @@ -62,7 +63,8 @@ { } -void ToggleTool::update (int pId) +void +ToggleTool::update (int pId) { uitoggletool::properties& tp = properties (); QAction* action = qWidget (); @@ -72,13 +74,15 @@ case uitoggletool::properties::ID_STATE: action->setChecked (tp.is_state ()); break; + default: ToolBarButton::update (pId); break; } } -void ToggleTool::triggered (bool checked) +void +ToggleTool::triggered (bool checked) { gh_manager::post_set (m_handle, "state", checked, false); gh_manager::post_callback (m_handle, diff -r 40b2c4323c16 -r 3cc0734283dc libgui/graphics/ToolBar.cc --- a/libgui/graphics/ToolBar.cc Thu Mar 19 12:25:28 2015 -0400 +++ b/libgui/graphics/ToolBar.cc Thu Mar 19 12:27:54 2015 -0400 @@ -41,7 +41,8 @@ namespace QtHandles { -static QAction* addEmptyAction (QToolBar* bar) +static QAction* +addEmptyAction (QToolBar* bar) { static QIcon _empty; @@ -62,7 +63,8 @@ return a; } -ToolBar* ToolBar::create (const graphics_object& go) +ToolBar* +ToolBar::create (const graphics_object& go) { Object* parent = Object::parentObject (go); @@ -78,7 +80,7 @@ } ToolBar::ToolBar (const graphics_object& go, QToolBar* bar) - : Object (go, bar), m_empty (0), m_figure (0) + : Object (go, bar), m_empty (0), m_figure (0) { uitoolbar::properties& tp = properties (); @@ -101,7 +103,8 @@ { } -void ToolBar::update (int pId) +void +ToolBar::update (int pId) { uitoolbar::properties& tp = properties (); QToolBar* bar = qWidget (); @@ -112,13 +115,15 @@ if (m_figure) m_figure->showCustomToolBar (bar, tp.is_visible ()); break; + default: Object::update (pId); break; } } -bool ToolBar::eventFilter (QObject* watched, QEvent* xevent) +bool +ToolBar::eventFilter (QObject* watched, QEvent* xevent) { if (watched == qObject ()) { @@ -145,6 +150,7 @@ } } break; + default: break; } @@ -153,12 +159,14 @@ return false; } -void ToolBar::hideEmpty (void) +void +ToolBar::hideEmpty (void) { m_empty->setVisible (false); } -void ToolBar::beingDeleted (void) +void +ToolBar::beingDeleted (void) { if (m_figure) { diff -r 40b2c4323c16 -r 3cc0734283dc libgui/graphics/ToolBarButton.cc --- a/libgui/graphics/ToolBarButton.cc Thu Mar 19 12:25:28 2015 -0400 +++ b/libgui/graphics/ToolBarButton.cc Thu Mar 19 12:27:54 2015 -0400 @@ -35,7 +35,7 @@ template ToolBarButton::ToolBarButton (const graphics_object& go, QAction* action) - : Object (go, action), m_separator (0) + : Object (go, action), m_separator (0) { typename T::properties& tp = properties (); @@ -64,7 +64,8 @@ } template -void ToolBarButton::update (int pId) +void +ToolBarButton::update (int pId) { typename T::properties& tp = properties (); QAction* action = qWidget (); @@ -76,16 +77,19 @@ if (m_separator) m_separator->setVisible (tp.is_visible ()); break; + case T::properties::ID_TOOLTIPSTRING: action->setToolTip (Utils::fromStdString (tp.get_tooltipstring ())); break; + case T::properties::ID_CDATA: - { - QImage img = Utils::makeImageFromCData (tp.get_cdata (), 16, 16); + { + QImage img = Utils::makeImageFromCData (tp.get_cdata (), 16, 16); - action->setIcon (QIcon (QPixmap::fromImage (img))); - } + action->setIcon (QIcon (QPixmap::fromImage (img))); + } break; + case T::properties::ID_SEPARATOR: if (tp.is_separator ()) { @@ -107,9 +111,11 @@ m_separator = 0; } break; + case T::properties::ID_ENABLE: action->setEnabled (tp.is_enable ()); break; + default: Object::update (pId); break; diff -r 40b2c4323c16 -r 3cc0734283dc libgui/graphics/__init_qt__.cc --- a/libgui/graphics/__init_qt__.cc Thu Mar 19 12:25:28 2015 -0400 +++ b/libgui/graphics/__init_qt__.cc Thu Mar 19 12:27:54 2015 -0400 @@ -43,7 +43,8 @@ static bool qtHandlesInitialized = false; -bool __init__ (void) +bool +__init__ (void) { if (! qtHandlesInitialized) { @@ -94,7 +95,8 @@ return false; } -bool __shutdown__ (void) +bool +__shutdown__ (void) { if (qtHandlesInitialized) { @@ -142,7 +144,8 @@ #if 0 -static QStringList makeFilterSpecs (const Cell& filters) +static QStringList +makeFilterSpecs (const Cell& filters) { using namespace QtHandles::Utils; @@ -172,7 +175,8 @@ return filterSpecs; } -static QString appendDirSep (const QString& d) +static QString +appendDirSep (const QString& d) { if (! d.endsWith ("/") && ! d.endsWith (QDir::separator ())) return (d + "/");