Ardour
9.8-278-gb1f580e1e2
cairo_widget.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2011-2016 Paul Davis <paul@linuxaudiosystems.com>
3
* Copyright (C) 2014-2018 Robin Gareus <robin@gareus.org>
4
* Copyright (C) 2014 Ben Loftis <ben@harrisonconsoles.com>
5
*
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License along
17
* with this program; if not, write to the Free Software Foundation, Inc.,
18
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
*/
20
21
#ifndef __gtk2_ardour_cairo_widget_h__
22
#define __gtk2_ardour_cairo_widget_h__
23
24
#include <cairomm/context.h>
25
#include <cairomm/surface.h>
26
#include <
ytkmm/eventbox.h
>
27
28
#include "
gtkmm2ext/visibility.h
"
29
#include "
gtkmm2ext/cairo_canvas.h
"
30
#include "
gtkmm2ext/cairo_theme.h
"
31
#include "
gtkmm2ext/colors.h
"
32
#include "
gtkmm2ext/widget_state.h
"
33
37
class
LIBGTKMM2EXT_API
CairoWidget
:
public
Gtk::EventBox
,
public
Gtkmm2ext::CairoCanvas
,
public
Gtkmm2ext::CairoTheme
38
{
39
public
:
40
CairoWidget
();
41
virtual
~CairoWidget
();
42
43
void
set_canvas_widget
();
44
void
use_image_surface
(
bool
yn =
true
);
45
46
/* swizzle Gtk::Widget methods for Canvas::Widget */
47
void
queue_draw
();
48
void
queue_resize
();
49
int
get_width
()
const
;
50
int
get_height
()
const
;
51
void
size_allocate
(
Gtk::Allocation
&);
52
53
void
set_dirty
(cairo_rectangle_t *area = 0);
54
55
Gtkmm2ext::ActiveState
active_state
()
const
{
return
_active_state; }
56
Gtkmm2ext::VisualState
visual_state
()
const
{
return
_visual_state; }
57
58
/* derived widgets can override these two to catch
59
changes in active & visual state
60
*/
61
62
virtual
void
set_active_state
(
Gtkmm2ext::ActiveState
);
63
virtual
void
set_visual_state
(
Gtkmm2ext::VisualState
);
64
65
void
unset_active_state
() { set_active_state (
Gtkmm2ext::Off
); }
66
void
unset_visual_state
() { set_visual_state (
Gtkmm2ext::NoVisualState
); }
67
68
/* this is an API simplification for widgets
69
that only use the Active and Normal active states.
70
*/
71
void
set_active
(
bool
);
72
bool
get_active
()
const
{
return
active_state() !=
Gtkmm2ext::Off
; }
73
74
/* widgets can be told to only draw their "foreground, and thus leave
75
in place whatever background is drawn by their parent. the default
76
is that the widget will fill its event window with the background
77
color of the parent container.
78
*/
79
80
void
set_draw_background
(
bool
yn);
81
82
sigc::signal<void>
StateChanged
;
83
sigc::signal<bool>
QueueDraw
;
84
sigc::signal<bool>
QueueResize
;
85
86
static
void
provide_background_for_cairo_widget
(
Gtk::Widget
& w,
const
Gdk::Color
& bg);
87
88
uint32_t
background_color
();
89
90
91
static
void
set_source_rgb_a
( cairo_t* cr,
Gdk::Color
,
float
a=1.0 );
92
static
void
set_source_rgb_a
( cairo_t* cr,
Gtkmm2ext::Color
,
float
a=1.0 );
93
94
/* set_focus_handler() will cause all button-press events on any
95
CairoWidget to invoke this slot/functor/function/method/callback.
96
97
We do this because in general, CairoWidgets do not grab
98
keyboard focus, but a button press on them should
99
clear focus from any active text entry.
100
101
This is global to all CairoWidgets and derived types.
102
103
However, derived types can override the behaviour by defining their
104
own on_button_press_event() handler which returns true under all
105
conditions (which will block this handler from being called). If
106
they wish to invoke any existing focus handler from their own
107
button press handler, they can just use: focus_handler();
108
*/
109
static
void
set_focus_handler
(sigc::slot<void,Gtk::Widget*>);
110
111
protected
:
113
virtual
bool
on_expose_event
(
GdkEventExpose
*);
114
void
on_size_allocate
(
Gtk::Allocation
&);
115
void
on_state_changed
(
Gtk::StateType
);
116
void
on_style_changed
(
const
Glib::RefPtr<Gtk::Style>&);
117
void
on_realize
();
118
bool
on_button_press_event
(
GdkEventButton
*);
119
Gdk::Color
get_parent_bg
();
120
void
on_map
();
121
void
on_unmap
();
122
123
/* this is an additional virtual "on_..." method. Glibmm does not
124
provide a direct signal for name changes, so this acts as a proxy.
125
*/
126
127
virtual
void
on_name_changed
() {};
128
129
Gtkmm2ext::ActiveState
_active_state
;
130
Gtkmm2ext::VisualState
_visual_state
;
131
bool
_need_bg
;
132
bool
_grabbed
;
133
134
static
sigc::slot<void,Gtk::Widget*>
focus_handler
;
135
136
private
:
137
void
on_widget_name_changed
();
138
139
Cairo::RefPtr<Cairo::Surface>
image_surface
;
140
Glib::SignalProxyProperty
_name_proxy
;
141
sigc::connection
_parent_style_change
;
142
Widget *
_current_parent
;
143
bool
_canvas_widget
;
144
bool
_use_image_surface
;
145
Gdk::Rectangle
_allocation
;
146
Glib::ustring
_widget_name
;
147
148
};
149
150
#endif
cairo_canvas.h
cairo_theme.h
CairoWidget
Definition:
cairo_widget.h:38
CairoWidget::set_visual_state
virtual void set_visual_state(Gtkmm2ext::VisualState)
CairoWidget::_visual_state
Gtkmm2ext::VisualState _visual_state
Definition:
cairo_widget.h:130
CairoWidget::_active_state
Gtkmm2ext::ActiveState _active_state
Definition:
cairo_widget.h:127
CairoWidget::on_expose_event
virtual bool on_expose_event(GdkEventExpose *)
CairoWidget::_parent_style_change
sigc::connection _parent_style_change
Definition:
cairo_widget.h:141
CairoWidget::provide_background_for_cairo_widget
static void provide_background_for_cairo_widget(Gtk::Widget &w, const Gdk::Color &bg)
CairoWidget::set_source_rgb_a
static void set_source_rgb_a(cairo_t *cr, Gdk::Color, float a=1.0)
CairoWidget::set_source_rgb_a
static void set_source_rgb_a(cairo_t *cr, Gtkmm2ext::Color, float a=1.0)
CairoWidget::~CairoWidget
virtual ~CairoWidget()
CairoWidget::_canvas_widget
bool _canvas_widget
Definition:
cairo_widget.h:143
CairoWidget::on_name_changed
virtual void on_name_changed()
Definition:
cairo_widget.h:127
CairoWidget::QueueDraw
sigc::signal< bool > QueueDraw
Definition:
cairo_widget.h:83
CairoWidget::set_active
void set_active(bool)
CairoWidget::QueueResize
sigc::signal< bool > QueueResize
Definition:
cairo_widget.h:84
CairoWidget::on_realize
void on_realize()
This is a default handler for the signal signal_realize().
CairoWidget::on_style_changed
void on_style_changed(const Glib::RefPtr< Gtk::Style > &)
CairoWidget::on_button_press_event
bool on_button_press_event(GdkEventButton *)
This is a default handler for the signal signal_button_press_event().
CairoWidget::queue_draw
void queue_draw()
CairoWidget::background_color
uint32_t background_color()
CairoWidget::_current_parent
Widget * _current_parent
Definition:
cairo_widget.h:142
CairoWidget::StateChanged
sigc::signal< void > StateChanged
Definition:
cairo_widget.h:82
CairoWidget::_use_image_surface
bool _use_image_surface
Definition:
cairo_widget.h:144
CairoWidget::on_unmap
void on_unmap()
This is a default handler for the signal signal_unmap().
CairoWidget::on_state_changed
void on_state_changed(Gtk::StateType)
This is a default handler for the signal signal_state_changed().
CairoWidget::image_surface
Cairo::RefPtr< Cairo::Surface > image_surface
Definition:
cairo_widget.h:139
CairoWidget::set_canvas_widget
void set_canvas_widget()
CairoWidget::focus_handler
static sigc::slot< void, Gtk::Widget * > focus_handler
Definition:
cairo_widget.h:134
CairoWidget::set_draw_background
void set_draw_background(bool yn)
CairoWidget::get_parent_bg
Gdk::Color get_parent_bg()
CairoWidget::_widget_name
Glib::ustring _widget_name
Definition:
cairo_widget.h:146
CairoWidget::use_image_surface
void use_image_surface(bool yn=true)
CairoWidget::active_state
Gtkmm2ext::ActiveState active_state() const
Definition:
cairo_widget.h:55
CairoWidget::size_allocate
void size_allocate(Gtk::Allocation &)
CairoWidget::unset_active_state
void unset_active_state()
Definition:
cairo_widget.h:65
CairoWidget::get_active
bool get_active() const
Definition:
cairo_widget.h:72
CairoWidget::visual_state
Gtkmm2ext::VisualState visual_state() const
Definition:
cairo_widget.h:56
CairoWidget::_name_proxy
Glib::SignalProxyProperty _name_proxy
Definition:
cairo_widget.h:140
CairoWidget::get_height
int get_height() const
CairoWidget::set_focus_handler
static void set_focus_handler(sigc::slot< void, Gtk::Widget * >)
CairoWidget::CairoWidget
CairoWidget()
CairoWidget::unset_visual_state
void unset_visual_state()
Definition:
cairo_widget.h:66
CairoWidget::get_width
int get_width() const
CairoWidget::on_size_allocate
void on_size_allocate(Gtk::Allocation &)
This is a default handler for the signal signal_size_allocate().
CairoWidget::_grabbed
bool _grabbed
Definition:
cairo_widget.h:132
CairoWidget::_need_bg
bool _need_bg
Definition:
cairo_widget.h:131
CairoWidget::queue_resize
void queue_resize()
CairoWidget::on_map
void on_map()
This is a default handler for the signal signal_map().
CairoWidget::set_active_state
virtual void set_active_state(Gtkmm2ext::ActiveState)
CairoWidget::_allocation
Gdk::Rectangle _allocation
Definition:
cairo_widget.h:145
CairoWidget::on_widget_name_changed
void on_widget_name_changed()
CairoWidget::set_dirty
void set_dirty(cairo_rectangle_t *area=0)
Gdk::Color
Definition:
color.h:55
Gdk::Rectangle
Definition:
tk/ydkmm/ydkmm/rectangle.h:42
Gtk::EventBox
Definition:
eventbox.h:59
Gtk::Widget
Definition:
tk/ytkmm/ytkmm/widget.h:336
Gtkmm2ext::CairoCanvas
Definition:
cairo_canvas.h:29
Gtkmm2ext::CairoTheme
Definition:
cairo_theme.h:29
colors.h
eventbox.h
Gtk::StateType
StateType
Definition:
libs/tk/ytkmm/ytkmm/enums.h:1138
visibility.h
LIBGTKMM2EXT_API
#define LIBGTKMM2EXT_API
Definition:
gtkmm2ext/gtkmm2ext/visibility.h:39
Gtkmm2ext::Color
uint32_t Color
Definition:
colors.h:33
Gtkmm2ext::VisualState
VisualState
Definition:
widget_state.h:36
Gtkmm2ext::NoVisualState
@ NoVisualState
Definition:
widget_state.h:38
Gtkmm2ext::ActiveState
ActiveState
Definition:
widget_state.h:30
Gtkmm2ext::Off
@ Off
Definition:
widget_state.h:31
_GdkEventButton
Definition:
gdkevents.h:321
_GdkEventExpose
Definition:
gdkevents.h:281
widget_state.h
libs
gtkmm2ext
gtkmm2ext
cairo_widget.h
Generated on Mon Nov 2 2026 07:08:14 for Ardour by
1.9.1