23 #if defined (HAVE_CONFIG_H)
28 #include <QActionEvent>
29 #include <QActionGroup>
30 #include <QApplication>
33 #include <QFileDialog>
37 #include <QMainWindow>
40 #include <QMessageBox>
73 for (
int i = 0;
i < kids.
numel ();
i++)
77 if (go && (go.
isa (
"uicontrol") || go.
isa (
"uipanel")
78 || go.
isa (
"uibuttongroup")))
92 for (
int i = 0;
i < kids.
numel ();
i++)
96 if (go && go.
isa (
"uimenu"))
108 if (bb.
numel () == 4)
126 :
Object (go, win), m_blockUpdates (
false), m_figureToolBar (0),
127 m_menuBar (0), m_innerRect (), m_outerRect (), m_mouseModeGroup (0)
147 boffset += m_statusBar->sizeHint ().height ();
152 m_statusBar->hide ();
156 toffset +=
m_menuBar->sizeHint ().height ();
163 win->setGeometry (
m_innerRect.adjusted (0, -toffset, 0, boffset));
233 else if (mode ==
"rotate")
235 else if (mode ==
"zoom in")
237 else if (mode ==
"zoom out")
239 else if (mode ==
"pan")
241 else if (mode ==
"text")
243 else if (mode ==
"select")
286 mode +=
" " + direction;
298 m_figureToolBar->setMovable (
false);
299 m_figureToolBar->setFloatable (
false);
306 QAction *toggle_axes = m_figureToolBar->addAction (tr (
"Axes"));
307 connect (toggle_axes, SIGNAL (triggered (
void)),
310 QAction *toggle_grid = m_figureToolBar->addAction (tr (
"Grid"));
311 connect (toggle_grid, SIGNAL (triggered (
void)),
314 QAction *auto_axes = m_figureToolBar->addAction (tr (
"Autoscale"));
315 connect (auto_axes, SIGNAL (triggered (
void)),
321 QMenu* fileMenu =
m_menuBar->addMenu (tr (
"&File"));
322 fileMenu->menuAction ()->setObjectName (
"builtinMenu");
323 fileMenu->addAction (tr (
"&Save"),
this, SLOT (
fileSaveFigure (
bool)));
324 fileMenu->addAction (tr (
"Save &As"),
this, SLOT (
fileSaveFigureAs (
void)));
325 fileMenu->addSeparator ();
326 fileMenu->addAction (tr (
"&Close Figure"),
this,
329 QMenu* editMenu =
m_menuBar->addMenu (tr (
"&Edit"));
330 editMenu->menuAction ()->setObjectName (
"builtinMenu");
331 editMenu->addAction (tr (
"Cop&y"),
this, SLOT (
editCopy (
bool)),
333 editMenu->addSeparator ();
336 QMenu* helpMenu =
m_menuBar->addMenu (tr (
"&Help"));
337 helpMenu->menuAction ()->setObjectName (
"builtinMenu");
338 helpMenu->addAction (tr (
"About Octave"),
this,
372 foreach (QFrame*
frame,
373 qWidget<QWidget> ()->findChildren<QFrame*> ())
375 if (frame->objectName () ==
"UIPanel"
376 || frame->objectName () ==
"UIButtonGroup")
394 canvas->
print (file_cmd, term);
407 qWidget<FigureWindow> ()->removeReceiver (
this);
429 foreach (QToolBar* tb, win->findChildren<QToolBar*> ())
430 if (! tb->isHidden ())
431 toffset += tb->sizeHint ().height ();
434 toffset +=
m_menuBar->sizeHint ().height ();
439 win->setGeometry (
m_innerRect.adjusted (0, -toffset, 0, boffset));
450 QTimer::singleShot (0, win, SLOT (show ()));
488 bool is_visible = win->isVisible ();
493 win->setVisible (
false);
495 win->setWindowModality (Qt::ApplicationModal);
496 win->setVisible (is_visible);
499 win->setWindowModality (Qt::NonModal);
507 m_blockUpdates =
false;
517 QRect r = qWidget<QWidget> ()->geometry ();
520 r.adjust (0, dy1, 0, -dy2);
522 r.adjust (0, -dy1, 0, dy2);
525 qWidget<QWidget> ()->setGeometry (r);
537 int h1 =
m_menuBar->sizeHint ().height ();
540 if (a->objectName () ==
"builtinMenu")
541 a->setVisible (visible);
543 int h2 =
m_menuBar->sizeHint ().height ();
550 int dy = qMax (h1, h2);
551 QRect r = qWidget<QWidget> ()->geometry ();
555 r.adjust (0, dy, 0, 0);
557 r.adjust (0, -dy, 0, 0);
561 qWidget<QWidget> ()->setGeometry (r);
576 showMenuBar (Utils::properties<figure> (go).menubar_is (
"figure"));
584 .
arg (pt(0), 0,
'g', 5)
585 .
arg (pt(1), 0,
'g', 5));
591 return qWidget<QMainWindow> ()->menuBar ();
623 QWidget* win = qWidget<QWidget> ();
631 r.moveTopLeft (win->mapToGlobal (
m_container->pos ()));
652 r.moveTopLeft (win->pos ());
654 r.setSize (win->frameGeometry ().size ());
690 switch (xevent->type ())
692 case QEvent::ActionRemoved:
694 QAction*
a =
dynamic_cast<QActionEvent*
> (xevent)->action ();
696 if (! a->isSeparator ()
697 && a->objectName () !=
"builtinMenu")
708 switch (xevent->type ())
731 switch (xevent->type ())
737 case QEvent::ChildAdded:
738 if (dynamic_cast<QChildEvent*> (xevent)->child
747 case QEvent::ChildRemoved:
748 if (dynamic_cast<QChildEvent*> (xevent)->child
761 switch (xevent->type ())
763 case QEvent::ActionAdded:
765 QAction*
a =
dynamic_cast<QActionEvent*
> (xevent)->action ();
767 if (! a->isSeparator ()
768 && a->objectName () !=
"builtinMenu")
779 switch (xevent->type ())
803 QMessageBox::about (qWidget<QMainWindow> (), tr (
"About Octave"),
834 file =
"untitled.pdf";
837 if (prompt || file.isEmpty ())
839 QFileInfo finfo (file);
841 file = QFileDialog::getSaveFileName (qWidget<FigureWindow> (),
842 tr (
"Save Figure As"),
843 finfo.absoluteFilePath (), 0, 0,
844 QFileDialog::DontUseNativeDialog);
847 if (! file.isEmpty ())
849 QFileInfo finfo (file);
854 file.toStdString ());
894 qWidget<QMainWindow> ()->close ();
908 QFileInfo finfo (
file);
910 format = QFileDialog::getSaveFileName (qWidget<FigureWindow> (),
911 tr (
"Save Figure As"),
912 finfo.absoluteFilePath (), 0, 0,
913 QFileDialog::DontUseNativeDialog);
918 format.toStdString ());
927 win->addToolBar (bar);
930 QSize
sz = bar->sizeHint ();
931 QRect r = win->geometry ();
934 r.adjust (0, -sz.height (), 0, 0);
937 win->setGeometry (r);
938 win->addToolBarBreak ();
939 win->addToolBar (bar);
952 if ((! bar->isHidden ()) != visible)
954 QSize
sz = bar->sizeHint ();
955 QRect r = win->geometry ();
958 r.adjust (0, -sz.height (), 0, 0);
960 r.adjust (0, sz.height (), 0, 0);
963 win->setGeometry (r);
964 bar->setVisible (visible);
1011 { w->setMouseTracking (
true); }
virtual QWidget * qWidget(void)=0
For example cd octave end example noindent changes the current working directory to file
static MouseMode mouse_mode_from_string(const std::string &mode)
static void post_callback(const graphics_handle &h, const std::string &name, const octave_value &data=Matrix())
bool is_visible(void) const
bool isa(const std::string &go_name) const
QList< QAction * > actions(void) const
OCTAVE_EXPORT octave_value_list isa nd deftypefn *return ovl(args(0).is_integer_type())
octave_idx_type numel(void) const
Number of elements in the array.
Return the CPU time used by your Octave session The first output is the total time spent executing your process and is equal to the sum of second and third which are the number of CPU seconds spent executing in user mode and the number of CPU seconds spent executing in system mode
virtual void autoAxes(const graphics_handle &handle)=0
std::string tempnam(const std::string &dir, const std::string &pfx)
QString fromStdString(const std::string &s)
void setMode(MouseMode mode)
void print(const QString &file_cmd, const QString &term)
static QRect boundingBoxToRect(const Matrix &bb)
void redraw(bool sync=false)
static bool hasUiControlChildren(const figure::properties &fp)
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
void message(const char *name, const char *fmt,...)
std::string string_value(bool force=false) const
std::complex< double > w(std::complex< double > z, double relerr=0)
static bool copy_image_to_clipboard(const std::string &file)
static Object * fromQObject(QObject *obj)
static void post_event(T *obj, void(T::*method)(void))
void removeReceiver(GenericEventNotifyReceiver *r)
virtual void toggleAxes(const graphics_handle &handle)=0
virtual void toggleGrid(const graphics_handle &handle)=0
graphics_object object(void) const
octave::unwind_protect frame
std::string octave_name_version_copyright_copying_warranty_and_bugs(bool html, const std::string &extra_info)
bool valid_object(void) const
bool is_empty(void) const
static bool hasUiMenuChildren(const figure::properties &fp)
octave_scalar_map scalar_map_value(void) const
void setCursor(MouseMode mode)
static std::string mouse_mode_to_string(MouseMode mode)
=val(i)}if ode{val(i)}occurs in table i
Matrix get_all_children(void) const
void addReceiver(GenericEventNotifyReceiver *r)
static graphics_object get_object(double val)
static void post_function(graphics_event::event_fcn fcn, void *data=0)
octave_value getfield(const std::string &key) const
OCTINTERP_API octave_value_list Ffeval(const octave_value_list &=octave_value_list(), int=0)
Canvas * canvas(const graphics_handle &handle, bool create=true)
graphics_handle get___myhandle__(void) const
#define DECLARE_GENERICEVENTNOTIFY_SENDER(T, B)
octave_value as_octave_value(void) const
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
void blockRedraw(bool block=true)
void clearEventMask(int m)