comparison libgui/graphics/Figure.cc @ 18692:fe0e34be5576

maint: untabify recently added code files. * Backend.cc, BaseControl.cc, ButtonControl.cc, Canvas.cc, Canvas.h, CheckBoxControl.cc, Container.cc, ContextMenu.cc, EditControl.cc, Figure.cc, Figure.h, GLCanvas.h, ListBoxControl.cc, Menu.cc, MouseModeActionGroup.cc, Object.cc, Object.h, ObjectFactory.cc, ObjectProxy.cc, Panel.cc, PopupMenuControl.cc, PushButtonControl.cc, PushTool.cc, QtHandlesUtils.cc, QtHandlesUtils.h, RadioButtonControl.cc, SliderControl.cc, TextControl.cc, ToggleButtonControl.cc, ToggleTool.cc, ToolBar.cc, ToolBarButton.cc, __init_qt__.cc, pt-jit.cc, ov-classdef.cc, ov-classdef.h: Untabify code.
author Rik <rik@octave.org>
date Sun, 27 Apr 2014 18:02:47 -0700
parents 6113e0c6920b
children dbb207d10d7c
comparison
equal deleted inserted replaced
18691:9a6646cc7c3e 18692:fe0e34be5576
59 for (int i = 0; i < kids.numel (); i++) 59 for (int i = 0; i < kids.numel (); i++)
60 { 60 {
61 graphics_object go (gh_manager::get_object (kids(i))); 61 graphics_object go (gh_manager::get_object (kids(i)));
62 62
63 if (go && (go.isa ("uicontrol") || go.isa ("uipanel") 63 if (go && (go.isa ("uicontrol") || go.isa ("uipanel")
64 || go.isa ("uibuttongroup"))) 64 || go.isa ("uibuttongroup")))
65 return true; 65 return true;
66 } 66 }
67 67
68 return false; 68 return false;
69 } 69 }
70 70
75 for (int i = 0; i < kids.numel (); i++) 75 for (int i = 0; i < kids.numel (); i++)
76 { 76 {
77 graphics_object go (gh_manager::get_object (kids(i))); 77 graphics_object go (gh_manager::get_object (kids(i)));
78 78
79 if (go && go.isa ("uimenu")) 79 if (go && go.isa ("uimenu"))
80 return true; 80 return true;
81 } 81 }
82 82
83 return false; 83 return false;
84 } 84 }
85 85
171 m_figureToolBar->setMovable (false); 171 m_figureToolBar->setMovable (false);
172 m_figureToolBar->setFloatable (false); 172 m_figureToolBar->setFloatable (false);
173 173
174 MouseModeActionGroup* mouseModeGroup = new MouseModeActionGroup (win); 174 MouseModeActionGroup* mouseModeGroup = new MouseModeActionGroup (win);
175 connect (mouseModeGroup, SIGNAL (modeChanged (MouseMode)), 175 connect (mouseModeGroup, SIGNAL (modeChanged (MouseMode)),
176 SLOT (setMouseMode (MouseMode))); 176 SLOT (setMouseMode (MouseMode)));
177 m_figureToolBar->addActions (mouseModeGroup->actions ()); 177 m_figureToolBar->addActions (mouseModeGroup->actions ());
178 178
179 m_menuBar = new MenuBar (win); 179 m_menuBar = new MenuBar (win);
180 win->setMenuBar (m_menuBar); 180 win->setMenuBar (m_menuBar);
181 181
186 fileMenu->addSeparator (); 186 fileMenu->addSeparator ();
187 fileMenu->addAction (tr ("&Save"))->setEnabled (false); 187 fileMenu->addAction (tr ("&Save"))->setEnabled (false);
188 fileMenu->addAction (tr ("Save &As"))->setEnabled (false); 188 fileMenu->addAction (tr ("Save &As"))->setEnabled (false);
189 fileMenu->addSeparator (); 189 fileMenu->addSeparator ();
190 fileMenu->addAction (tr ("&Close Figure"), this, 190 fileMenu->addAction (tr ("&Close Figure"), this,
191 SLOT (fileCloseFigure (void)), Qt::CTRL|Qt::Key_W); 191 SLOT (fileCloseFigure (void)), Qt::CTRL|Qt::Key_W);
192 192
193 QMenu* editMenu = m_menuBar->addMenu (tr ("&Edit")); 193 QMenu* editMenu = m_menuBar->addMenu (tr ("&Edit"));
194 editMenu->menuAction ()->setObjectName ("builtinMenu"); 194 editMenu->menuAction ()->setObjectName ("builtinMenu");
195 editMenu->addAction (tr ("Cop&y"), this, SLOT (editCopy (void)), 195 editMenu->addAction (tr ("Cop&y"), this, SLOT (editCopy (void)),
196 Qt::CTRL|Qt::Key_C)->setEnabled (false); 196 Qt::CTRL|Qt::Key_C)->setEnabled (false);
197 editMenu->addAction (tr ("Cu&t"), this, SLOT (editCut (void)), 197 editMenu->addAction (tr ("Cu&t"), this, SLOT (editCut (void)),
198 Qt::CTRL|Qt::Key_X)->setEnabled (false); 198 Qt::CTRL|Qt::Key_X)->setEnabled (false);
199 editMenu->addAction (tr ("&Paste"), this, SLOT (editPaste(void)), 199 editMenu->addAction (tr ("&Paste"), this, SLOT (editPaste(void)),
200 Qt::CTRL|Qt::Key_V)->setEnabled (false); 200 Qt::CTRL|Qt::Key_V)->setEnabled (false);
201 editMenu->addSeparator (); 201 editMenu->addSeparator ();
202 editMenu->addActions (mouseModeGroup->actions ()); 202 editMenu->addActions (mouseModeGroup->actions ());
203 203
204 QMenu* helpMenu = m_menuBar->addMenu (tr ("&Help")); 204 QMenu* helpMenu = m_menuBar->addMenu (tr ("&Help"));
205 helpMenu->menuAction ()->setObjectName ("builtinMenu"); 205 helpMenu->menuAction ()->setObjectName ("builtinMenu");
206 helpMenu->addAction (tr ("&About QtHandles"), this, 206 helpMenu->addAction (tr ("&About QtHandles"), this,
207 SLOT (helpAboutQtHandles (void))); 207 SLOT (helpAboutQtHandles (void)));
208 helpMenu->addAction (tr ("About &Qt"), qApp, SLOT (aboutQt (void))); 208 helpMenu->addAction (tr ("About &Qt"), qApp, SLOT (aboutQt (void)));
209 209
210 m_menuBar->addReceiver (this); 210 m_menuBar->addReceiver (this);
211 } 211 }
212 212
224 canvas->redraw (); 224 canvas->redraw ();
225 //canvas->setMouseMode (RotateMode); 225 //canvas->setMouseMode (RotateMode);
226 } 226 }
227 227
228 foreach (QFrame* frame, 228 foreach (QFrame* frame,
229 qWidget<QWidget> ()->findChildren<QFrame*> ("UIPanel")) 229 qWidget<QWidget> ()->findChildren<QFrame*> ("UIPanel"))
230 { 230 {
231 Object* obj = Object::fromQObject (frame); 231 Object* obj = Object::fromQObject (frame);
232 232
233 if (obj) 233 if (obj)
234 obj->slotRedraw (); 234 obj->slotRedraw ();
235 } 235 }
236 } 236 }
237 237
238 void Figure::beingDeleted (void) 238 void Figure::beingDeleted (void)
239 { 239 {
258 m_blockUpdates = true; 258 m_blockUpdates = true;
259 259
260 switch (pId) 260 switch (pId)
261 { 261 {
262 case figure::properties::ID_POSITION: 262 case figure::properties::ID_POSITION:
263 { 263 {
264 m_innerRect = boundingBoxToRect (fp.get_boundingbox (true)); 264 m_innerRect = boundingBoxToRect (fp.get_boundingbox (true));
265 //qDebug () << "Figure::update(position):" << m_innerRect; 265 //qDebug () << "Figure::update(position):" << m_innerRect;
266 int offset = 0; 266 int offset = 0;
267 267
268 foreach (QToolBar* tb, win->findChildren<QToolBar*> ()) 268 foreach (QToolBar* tb, win->findChildren<QToolBar*> ())
269 if (! tb->isHidden ()) 269 if (! tb->isHidden ())
270 offset += tb->sizeHint ().height (); 270 offset += tb->sizeHint ().height ();
271 if (! m_menuBar->isHidden ()) 271 if (! m_menuBar->isHidden ())
272 offset += m_menuBar->sizeHint ().height () + 1; 272 offset += m_menuBar->sizeHint ().height () + 1;
273 //qDebug () << "Figure::update(position)(adjusted):" << m_innerRect.adjusted (0, -offset, 0, 0); 273 //qDebug () << "Figure::update(position)(adjusted):" << m_innerRect.adjusted (0, -offset, 0, 0);
274 win->setGeometry (m_innerRect.adjusted (0, -offset, 0, 0)); 274 win->setGeometry (m_innerRect.adjusted (0, -offset, 0, 0));
275 //qDebug () << "Figure::update(position): done"; 275 //qDebug () << "Figure::update(position): done";
276 } 276 }
277 break; 277 break;
278 case figure::properties::ID_NAME: 278 case figure::properties::ID_NAME:
279 case figure::properties::ID_NUMBERTITLE: 279 case figure::properties::ID_NUMBERTITLE:
280 win->setWindowTitle (Utils::fromStdString (fp.get_title ())); 280 win->setWindowTitle (Utils::fromStdString (fp.get_title ()));
281 break; 281 break;
282 case figure::properties::ID_VISIBLE: 282 case figure::properties::ID_VISIBLE:
283 if (fp.is_visible ()) 283 if (fp.is_visible ())
284 QTimer::singleShot (0, win, SLOT (show ())); 284 QTimer::singleShot (0, win, SLOT (show ()));
285 else 285 else
286 win->hide (); 286 win->hide ();
287 break; 287 break;
288 case figure::properties::ID_TOOLBAR: 288 case figure::properties::ID_TOOLBAR:
289 if (fp.toolbar_is ("none")) 289 if (fp.toolbar_is ("none"))
290 showFigureToolBar (false); 290 showFigureToolBar (false);
291 else if (fp.toolbar_is ("figure")) 291 else if (fp.toolbar_is ("figure"))
292 showFigureToolBar (true); 292 showFigureToolBar (true);
293 else // "auto" 293 else // "auto"
294 showFigureToolBar (! hasUiControlChildren (fp)); 294 showFigureToolBar (! hasUiControlChildren (fp));
295 break; 295 break;
296 case figure::properties::ID_MENUBAR: 296 case figure::properties::ID_MENUBAR:
297 showMenuBar (fp.menubar_is ("figure")); 297 showMenuBar (fp.menubar_is ("figure"));
298 break; 298 break;
299 case figure::properties::ID_KEYPRESSFCN: 299 case figure::properties::ID_KEYPRESSFCN:
330 { 330 {
331 int dy = m_figureToolBar->sizeHint ().height (); 331 int dy = m_figureToolBar->sizeHint ().height ();
332 QRect r = qWidget<QWidget> ()->geometry (); 332 QRect r = qWidget<QWidget> ()->geometry ();
333 333
334 if (! visible) 334 if (! visible)
335 r.adjust (0, dy, 0, 0); 335 r.adjust (0, dy, 0, 0);
336 else 336 else
337 r.adjust (0, -dy, 0, 0); 337 r.adjust (0, -dy, 0, 0);
338 338
339 m_blockUpdates = true; 339 m_blockUpdates = true;
340 qWidget<QWidget> ()->setGeometry (r); 340 qWidget<QWidget> ()->setGeometry (r);
341 m_figureToolBar->setVisible (visible); 341 m_figureToolBar->setVisible (visible);
342 m_blockUpdates = false; 342 m_blockUpdates = false;
343 343
344 updateBoundingBox (false); 344 updateBoundingBox (false);
345 345
346 if (visible) 346 if (visible)
347 m_mouseMode = m_lastMouseMode; 347 m_mouseMode = m_lastMouseMode;
348 else 348 else
349 { 349 {
350 m_lastMouseMode = m_mouseMode; 350 m_lastMouseMode = m_mouseMode;
351 m_mouseMode = NoMode; 351 m_mouseMode = NoMode;
352 } 352 }
353 } 353 }
354 } 354 }
355 355
356 void Figure::showMenuBar (bool visible) 356 void Figure::showMenuBar (bool visible)
357 { 357 {
371 int dy = qMax (h1, h2) + 1; 371 int dy = qMax (h1, h2) + 1;
372 QRect r = qWidget<QWidget> ()->geometry (); 372 QRect r = qWidget<QWidget> ()->geometry ();
373 373
374 //qDebug () << "Figure::showMenuBar:" << r; 374 //qDebug () << "Figure::showMenuBar:" << r;
375 if (! visible) 375 if (! visible)
376 r.adjust (0, dy, 0, 0); 376 r.adjust (0, dy, 0, 0);
377 else 377 else
378 r.adjust (0, -dy, 0, 0); 378 r.adjust (0, -dy, 0, 0);
379 //qDebug () << "Figure::showMenuBar(adjusted):" << r; 379 //qDebug () << "Figure::showMenuBar(adjusted):" << r;
380 380
381 m_blockUpdates = true; 381 m_blockUpdates = true;
382 qWidget<QWidget> ()->setGeometry (r); 382 qWidget<QWidget> ()->setGeometry (r);
383 m_menuBar->setVisible (visible); 383 m_menuBar->setVisible (visible);
496 bool Figure::eventNotifyBefore (QObject* obj, QEvent* event) 496 bool Figure::eventNotifyBefore (QObject* obj, QEvent* event)
497 { 497 {
498 if (! m_blockUpdates) 498 if (! m_blockUpdates)
499 { 499 {
500 if (obj == m_container) 500 if (obj == m_container)
501 { 501 {
502 // Do nothing... 502 // Do nothing...
503 } 503 }
504 else if (obj == m_menuBar) 504 else if (obj == m_menuBar)
505 { 505 {
506 switch (event->type ()) 506 switch (event->type ())
507 { 507 {
508 case QEvent::ActionRemoved: 508 case QEvent::ActionRemoved:
509 { 509 {
510 QAction* a = dynamic_cast<QActionEvent*> (event)->action (); 510 QAction* a = dynamic_cast<QActionEvent*> (event)->action ();
511 511
512 if (! a->isSeparator () 512 if (! a->isSeparator ()
513 && a->objectName () != "builtinMenu")
514 updateMenuBar ();
515 }
516 break;
517 default:
518 break;
519 }
520 }
521 else
522 {
523 switch (event->type ())
524 {
525 case QEvent::Close:
526 event->ignore ();
527 gh_manager::post_callback (m_handle, "closerequestfcn");
528 return true;
529 default:
530 break;
531 }
532 }
533 }
534
535 return false;
536 }
537
538 void Figure::eventNotifyAfter (QObject* watched, QEvent* event)
539 {
540 if (! m_blockUpdates)
541 {
542 if (watched == m_container)
543 {
544 switch (event->type ())
545 {
546 case QEvent::Resize:
547 updateBoundingBox (true, UpdateBoundingBoxSize);
548 break;
549 case QEvent::ChildAdded:
550 if (dynamic_cast<QChildEvent*> (event)->child
551 ()->isWidgetType())
552 {
553 gh_manager::auto_lock lock;
554 const figure::properties& fp = properties<figure> ();
555
556 showFigureToolBar (! hasUiControlChildren (fp));
557 }
558 default:
559 break;
560 }
561 }
562 else if (watched == m_menuBar)
563 {
564 switch (event->type ())
565 {
566 case QEvent::ActionAdded:
567 {
568 QAction* a = dynamic_cast<QActionEvent*> (event)->action ();
569
570 if (! a->isSeparator ()
571 && a->objectName () != "builtinMenu") 513 && a->objectName () != "builtinMenu")
572 updateMenuBar (); 514 updateMenuBar ();
573 } 515 }
574 break; 516 break;
575 default: 517 default:
576 break; 518 break;
577 } 519 }
578 } 520 }
579 else 521 else
580 { 522 {
581 switch (event->type ()) 523 switch (event->type ())
582 { 524 {
583 case QEvent::Move: 525 case QEvent::Close:
584 updateBoundingBox (false, UpdateBoundingBoxPosition); 526 event->ignore ();
585 updateBoundingBox (true, UpdateBoundingBoxPosition); 527 gh_manager::post_callback (m_handle, "closerequestfcn");
586 break; 528 return true;
587 case QEvent::Resize: 529 default:
588 updateBoundingBox (false, UpdateBoundingBoxSize); 530 break;
589 break; 531 }
590 default: 532 }
591 break; 533 }
592 } 534
535 return false;
536 }
537
538 void Figure::eventNotifyAfter (QObject* watched, QEvent* event)
539 {
540 if (! m_blockUpdates)
541 {
542 if (watched == m_container)
543 {
544 switch (event->type ())
545 {
546 case QEvent::Resize:
547 updateBoundingBox (true, UpdateBoundingBoxSize);
548 break;
549 case QEvent::ChildAdded:
550 if (dynamic_cast<QChildEvent*> (event)->child
551 ()->isWidgetType())
552 {
553 gh_manager::auto_lock lock;
554 const figure::properties& fp = properties<figure> ();
555
556 showFigureToolBar (! hasUiControlChildren (fp));
557 }
558 default:
559 break;
560 }
561 }
562 else if (watched == m_menuBar)
563 {
564 switch (event->type ())
565 {
566 case QEvent::ActionAdded:
567 {
568 QAction* a = dynamic_cast<QActionEvent*> (event)->action ();
569
570 if (! a->isSeparator ()
571 && a->objectName () != "builtinMenu")
572 updateMenuBar ();
573 }
574 break;
575 default:
576 break;
577 }
578 }
579 else
580 {
581 switch (event->type ())
582 {
583 case QEvent::Move:
584 updateBoundingBox (false, UpdateBoundingBoxPosition);
585 updateBoundingBox (true, UpdateBoundingBoxPosition);
586 break;
587 case QEvent::Resize:
588 updateBoundingBox (false, UpdateBoundingBoxSize);
589 break;
590 default:
591 break;
592 }
593 } 593 }
594 } 594 }
595 } 595 }
596 596
597 void Figure::helpAboutQtHandles (void) 597 void Figure::helpAboutQtHandles (void)
598 { 598 {
599 QMessageBox::about (qWidget<QMainWindow> (), tr ("About QtHandles"), 599 QMessageBox::about (qWidget<QMainWindow> (), tr ("About QtHandles"),
600 ABOUT_TEXT); 600 ABOUT_TEXT);
601 } 601 }
602 602
603 void Figure::fileNewFigure (void) 603 void Figure::fileNewFigure (void)
604 { 604 {
605 } 605 }
654 { 654 {
655 QSize sz = bar->sizeHint (); 655 QSize sz = bar->sizeHint ();
656 QRect r = win->geometry (); 656 QRect r = win->geometry ();
657 657
658 if (visible) 658 if (visible)
659 r.adjust (0, -sz.height (), 0, 0); 659 r.adjust (0, -sz.height (), 0, 0);
660 else 660 else
661 r.adjust (0, sz.height (), 0, 0); 661 r.adjust (0, sz.height (), 0, 0);
662 662
663 m_blockUpdates = true; 663 m_blockUpdates = true;
664 win->setGeometry (r); 664 win->setGeometry (r);
665 bar->setVisible (visible); 665 bar->setVisible (visible);
666 m_blockUpdates = false; 666 m_blockUpdates = false;