GNU Octave
4.0.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
libgui
graphics
ContextMenu.cc
Go to the documentation of this file.
1
/*
2
3
Copyright (C) 2011-2015 Michael Goffioul
4
5
This file is part of Octave.
6
7
Octave is free software; you can redistribute it and/or modify it
8
under the terms of the GNU General Public License as published by the
9
Free Software Foundation; either version 3 of the License, or (at your
10
option) any later version.
11
12
Octave is distributed in the hope that it will be useful, but WITHOUT
13
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15
for more details.
16
17
You should have received a copy of the GNU General Public License
18
along with Octave; see the file COPYING. If not, see
19
<http://www.gnu.org/licenses/>.
20
21
*/
22
23
#ifdef HAVE_CONFIG_H
24
#include <config.h>
25
#endif
26
27
#include <QMenu>
28
29
#include "
Backend.h
"
30
#include "
ContextMenu.h
"
31
#include "
QtHandlesUtils.h
"
32
33
namespace
QtHandles
34
{
35
36
ContextMenu*
37
ContextMenu::create
(
const
graphics_object
& go)
38
{
39
Object
* xparent =
Object::parentObject
(go);
40
41
if
(xparent)
42
{
43
QWidget
*
w
= xparent->
qWidget
<
QWidget
> ();
44
45
return
new
ContextMenu
(go,
new
QMenu (w));
46
}
47
48
return
0;
49
}
50
51
ContextMenu::ContextMenu
(
const
graphics_object
& go, QMenu* xmenu)
52
:
Object
(go, xmenu)
53
{
54
xmenu->setAutoFillBackground (
true
);
55
56
connect (xmenu, SIGNAL (
aboutToShow
(
void
)), SLOT (
aboutToShow
(
void
)));
57
connect (xmenu, SIGNAL (
aboutToHide
(
void
)), SLOT (
aboutToHide
(
void
)));
58
}
59
60
ContextMenu::~ContextMenu
(
void
)
61
{
62
}
63
64
void
65
ContextMenu::update
(
int
pId)
66
{
67
uicontextmenu::properties
& up = properties<uicontextmenu> ();
68
QMenu* xmenu = qWidget<QMenu> ();
69
70
switch
(pId)
71
{
72
case
base_properties::ID_VISIBLE
:
73
if
(up.
is_visible
())
74
{
75
Matrix
pos = up.
get_position
().
matrix_value
();
76
QWidget
* parentW = xmenu->parentWidget ();
77
QPoint pt;
78
79
pt.rx () =
xround
(pos(0));
80
pt.ry () = parentW->height () -
xround
(pos(1));
81
pt = parentW->mapToGlobal (pt);
82
83
xmenu->popup (pt);
84
}
85
else
86
xmenu->hide ();
87
break
;
88
default
:
89
Object::update
(pId);
90
break
;
91
}
92
}
93
94
void
95
ContextMenu::aboutToShow
(
void
)
96
{
97
gh_manager::post_callback
(
m_handle
,
"callback"
);
98
gh_manager::post_set
(
m_handle
,
"visible"
,
"on"
,
false
);
99
}
100
101
void
102
ContextMenu::aboutToHide
(
void
)
103
{
104
gh_manager::post_set
(
m_handle
,
"visible"
,
"off"
,
false
);
105
}
106
107
QWidget
*
108
ContextMenu::menu
(
void
)
109
{
110
return
qWidget<QWidget> ();
111
}
112
113
void
114
ContextMenu::executeAt
(
const
base_properties
& props,
const
QPoint& pt)
115
{
116
graphics_handle
h = props.
get_uicontextmenu
();
117
118
if
(h.
ok
())
119
{
120
gh_manager::auto_lock
lock;
121
graphics_object
go =
gh_manager::get_object
(h);
122
123
if
(go.
valid_object
())
124
{
125
ContextMenu
* cMenu =
126
dynamic_cast<
ContextMenu
*
>
(
Backend::toolkitObject
(go));
127
128
if
(cMenu)
129
{
130
QMenu*
menu
= cMenu->
qWidget
<QMenu> ();
131
132
if
(menu)
133
menu->popup (pt);
134
}
135
}
136
}
137
}
138
139
};
// namespace QtHandles
ContextMenu.h
gh_manager::post_callback
static void post_callback(const graphics_handle &h, const std::string &name, const octave_value &data=Matrix())
Definition:
graphics.h:13329
QtHandles::Object
Definition:
Object.h:40
base_properties::is_visible
bool is_visible(void) const
Definition:
graphics.h:2758
xround
double xround(double x)
Definition:
lo-mappers.cc:63
uicontextmenu::properties
Definition:
graphics.h:11411
QWidget
octave_handle::ok
bool ok(void) const
Definition:
oct-handle.h:105
base_properties::ID_VISIBLE
Definition:
graphics.h:2710
uicontextmenu::properties::get_position
octave_value get_position(void) const
Definition:
graphics.h:11492
QtHandles::ContextMenu::ContextMenu
ContextMenu(const graphics_object &go, QMenu *menu)
Definition:
ContextMenu.cc:51
QtHandles::Object::parentObject
static Object * parentObject(const graphics_object &go)
Definition:
Object.cc:170
QtHandles::ContextMenu
Definition:
ContextMenu.h:36
QtHandles::ContextMenu::executeAt
static void executeAt(const base_properties &props, const QPoint &pt)
Definition:
ContextMenu.cc:114
QtHandlesUtils.h
QtHandles
Definition:
__init_qt__.cc:41
gh_manager::auto_lock
Definition:
graphics.h:13385
QtHandles::ContextMenu::aboutToShow
void aboutToShow(void)
Definition:
ContextMenu.cc:95
Faddeeva::w
std::complex< double > w(std::complex< double > z, double relerr=0)
QtHandles::Object::m_handle
graphics_handle m_handle
Definition:
Object.h:100
QtHandles::Object::qWidget
T * qWidget(void)
Definition:
Object.h:74
QtHandles::ContextMenu::update
void update(int pId)
Definition:
ContextMenu.cc:65
Matrix
Definition:
dMatrix.h:35
octave_value::matrix_value
Matrix matrix_value(bool frc_str_conv=false) const
Definition:
ov.h:773
QtHandles::ContextMenu::~ContextMenu
~ContextMenu(void)
Definition:
ContextMenu.cc:60
base_properties::get_uicontextmenu
graphics_handle get_uicontextmenu(void) const
Definition:
graphics.h:2754
graphics_object::valid_object
bool valid_object(void) const
Definition:
graphics.h:3395
Backend.h
QtHandles::Backend::toolkitObject
static Object * toolkitObject(const graphics_object &go)
Definition:
Backend.cc:197
QtHandles::Object::update
virtual void update(int pId)
Definition:
Object.cc:133
QtHandles::ContextMenu::aboutToHide
void aboutToHide(void)
Definition:
ContextMenu.cc:102
base_properties
Definition:
graphics.h:2476
octave_handle
Definition:
oct-handle.h:33
gh_manager::get_object
static graphics_object get_object(double val)
Definition:
graphics.h:13212
graphics_object
Definition:
graphics.h:3230
QtHandles::ContextMenu::create
static ContextMenu * create(const graphics_object &go)
Definition:
ContextMenu.cc:37
QtHandles::ContextMenu::menu
QWidget * menu(void)
Definition:
ContextMenu.cc:108
gh_manager::post_set
static void post_set(const graphics_handle &h, const std::string &name, const octave_value &value, bool notify_toolkit=true)
Definition:
graphics.h:13343
Generated on Thu Jun 4 2015 23:30:10 for GNU Octave by
1.8.8