GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
QtHandlesUtils.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2011-2021 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_QtHandlesUtils_h)
27 #define octave_QtHandlesUtils_h 1
28 
29 #include <QColor>
30 #include <QFont>
31 #include <QImage>
32 #include <QString>
33 #include <QStringList>
34 
35 #include <string>
36 
37 #include "graphics.h"
38 
39 class QKeyEvent;
40 class QMouseEvent;
41 class QWheelEvent;
42 
43 namespace QtHandles
44 {
45 
46  namespace Utils
47  {
48  QString fromStdString (const std::string& s);
49  std::string toStdString (const QString& s);
50 
51  QStringList fromStringVector (const string_vector& v);
52  string_vector toStringVector (const QStringList& l);
53 
54  Cell toCellString (const QStringList& l);
55 
56  template <typename T>
57  QFont computeFont (const typename T::properties& props, int height = -1);
58 
59  QColor fromRgb (const Matrix& rgb);
60  Matrix toRgb (const QColor& c);
61 
62  Qt::Alignment fromHVAlign (const std::string& halign,
63  const std::string& valign);
64 
65  std::string figureSelectionType (QMouseEvent *event,
66  bool isDoubleClick = false);
67 
68  Matrix figureCurrentPoint (const graphics_object& fig, QMouseEvent *event);
70 
71  template <typename T>
72  inline typename T::properties&
74  { return dynamic_cast<typename T::properties&> (obj.get_properties ()); }
75 
76  QImage makeImageFromCData (const octave_value& v, int width = -1,
77  int height = -1);
78 
79  octave_scalar_map makeKeyEventStruct (QKeyEvent *event);
80  octave_scalar_map makeScrollEventStruct (QWheelEvent *event);
81  }
82 
83 }
84 
85 #endif
Definition: Cell.h:43
Definition: dMatrix.h:42
base_properties & get_properties(void)
Definition: graphics.in.h:2829
QColor fromRgb(const Matrix &rgb)
QFont computeFont(const typename T::properties &props, int height)
string_vector toStringVector(const QStringList &l)
std::string figureSelectionType(QMouseEvent *event, bool isDoubleClick)
QStringList fromStringVector(const string_vector &v)
Qt::Alignment fromHVAlign(const std::string &halign, const std::string &valign)
octave_scalar_map makeScrollEventStruct(QWheelEvent *event)
octave_scalar_map makeKeyEventStruct(QKeyEvent *event)
Matrix figureCurrentPoint(const graphics_object &fig, QMouseEvent *event)
Cell toCellString(const QStringList &l)
Matrix toRgb(const QColor &c)
QString fromStdString(const std::string &s)
std::string toStdString(const QString &s)
T::properties & properties(graphics_object obj)
QImage makeImageFromCData(const octave_value &v, int width, int height)