GNU Octave
6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
TextControl.cc
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 (HAVE_CONFIG_H)
27
# include "config.h"
28
#endif
29
30
#include <QLabel>
31
32
#include "
Container.h
"
33
#include "
TextControl.h
"
34
#include "
QtHandlesUtils.h
"
35
36
#include "
octave-qobject.h
"
37
38
namespace
QtHandles
39
{
40
41
TextControl*
42
TextControl::create
(
octave::base_qobject
& oct_qobj,
43
octave::interpreter
& interp,
const
graphics_object
& go)
44
{
45
Object
*parent =
parentObject
(interp, go);
46
47
if
(parent)
48
{
49
Container
*container = parent->
innerContainer
();
50
51
if
(container)
52
return
new
TextControl
(oct_qobj, interp, go,
new
QLabel (container));
53
}
54
55
return
nullptr
;
56
}
57
58
TextControl::TextControl
(
octave::base_qobject
& oct_qobj,
59
octave::interpreter
& interp,
60
const
graphics_object
& go, QLabel *label)
61
:
BaseControl
(oct_qobj, interp, go, label)
62
{
63
uicontrol::properties
& up = properties<uicontrol> ();
64
65
label->setAutoFillBackground (
true
);
66
label->setTextFormat (Qt::PlainText);
67
label->setWordWrap (
false
);
68
label->setAlignment (
Utils::fromHVAlign
(up.get_horizontalalignment (),
69
up.get_verticalalignment ()));
70
label->setText (
Utils::fromStringVector
(up.get_string_vector ()).join (
"\n"
));
71
}
72
73
TextControl::~TextControl
(
void
)
74
{ }
75
76
void
77
TextControl::update
(
int
pId)
78
{
79
uicontrol::properties
& up = properties<uicontrol> ();
80
QLabel *label = qWidget<QLabel> ();
81
82
switch
(pId)
83
{
84
case
uicontrol::properties::ID_STRING:
85
label->setText (
Utils::fromStringVector
(up.get_string_vector ()).join (
"\n"
));
86
break
;
87
88
case
uicontrol::properties::ID_HORIZONTALALIGNMENT:
89
case
uicontrol::properties::ID_VERTICALALIGNMENT:
90
label->setAlignment (
Utils::fromHVAlign
(up.get_horizontalalignment (),
91
up.get_verticalalignment ()));
92
break
;
93
94
default
:
95
BaseControl::update
(pId);
96
break
;
97
}
98
}
99
100
}
Container.h
QtHandlesUtils.h
TextControl.h
QtHandles::BaseControl
Definition:
BaseControl.h:44
QtHandles::BaseControl::update
void update(int pId)
Definition:
BaseControl.cc:142
QtHandles::Container
Definition:
Container.h:49
QtHandles::Object
Definition:
Object.h:51
QtHandles::Object::innerContainer
virtual Container * innerContainer(void)=0
QtHandles::Object::parentObject
static Object * parentObject(octave::interpreter &interp, const graphics_object &go)
Definition:
Object.cc:201
QtHandles::TextControl::TextControl
TextControl(octave::base_qobject &oct_qobj, octave::interpreter &interp, const graphics_object &go, QLabel *label)
Definition:
TextControl.cc:58
QtHandles::TextControl::update
void update(int pId)
Definition:
TextControl.cc:77
QtHandles::TextControl::~TextControl
~TextControl(void)
Definition:
TextControl.cc:73
QtHandles::TextControl::create
static TextControl * create(octave::base_qobject &oct_qobj, octave::interpreter &interp, const graphics_object &go)
Definition:
TextControl.cc:42
graphics_object
Definition:
graphics.in.h:2696
octave::base_qobject
Base class for Octave interfaces that use Qt.
Definition:
octave-qobject.h:80
octave::interpreter
Definition:
interpreter.h:113
uicontrol::properties
Definition:
graphics.in.h:5508
QtHandles::Utils::fromStringVector
QStringList fromStringVector(const string_vector &v)
Definition:
QtHandlesUtils.cc:66
QtHandles::Utils::fromHVAlign
Qt::Alignment fromHVAlign(const std::string &halign, const std::string &valign)
Definition:
QtHandlesUtils.cc:256
QtHandles
Definition:
BaseControl.cc:43
octave-qobject.h
libgui
graphics
TextControl.cc
Generated on Tue Apr 13 2021 15:27:43 for GNU Octave by
1.9.1