gtk3 2.1.0-x86-mingw32 → 2.2.0-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/gtk3/extconf.rb +1 -1
- data/ext/gtk3/rbgtk-about-dialog.c +0 -6
- data/ext/gtk3/rbgtk-accessible.c +0 -16
- data/ext/gtk3/rbgtk-entry.c +4 -18
- data/ext/gtk3/rbgtk-header-bar.c +58 -0
- data/ext/gtk3/rbgtk-icon-view.c +30 -5
- data/ext/gtk3/rbgtk-level-bar.c +88 -0
- data/ext/gtk3/rbgtk-link-button.c +0 -6
- data/ext/gtk3/rbgtk-menu-button.c +41 -0
- data/ext/gtk3/rbgtk-revealer.c +42 -0
- data/ext/gtk3/rbgtk-search-bar.c +59 -0
- data/ext/gtk3/rbgtk-search-entry.c +42 -0
- data/ext/gtk3/rbgtk-stack.c +106 -0
- data/ext/gtk3/rbgtk-tree-selection.c +7 -22
- data/ext/gtk3/rbgtk.c +24 -3
- data/ext/gtk3/rbgtk3conversions.h +25 -2
- data/ext/gtk3/rbgtk3private.h +23 -3
- data/lib/1.9/gtk3.so +0 -0
- data/lib/2.0/gtk3.so +0 -0
- data/lib/2.1/gtk3.so +0 -0
- data/sample/gtk-demo/appwindow.rb +95 -95
- data/sample/gtk-demo/cairo-operator.rb +8 -8
- data/sample/gtk-demo/drawingarea.rb +74 -99
- data/sample/gtk-demo/pixbufs.rb +48 -57
- data/sample/misc/alpha-demo.rb +1 -1
- data/sample/misc/assistant.rb +45 -51
- data/sample/misc/cairo-pong.rb +26 -24
- data/sample/misc/composited-windows.rb +2 -2
- data/sample/misc/dnd.rb +23 -23
- data/sample/misc/drag-move.rb +19 -11
- data/sample/misc/drawing.rb +1 -1
- data/sample/misc/mouse-gesture.rb +3 -3
- data/sample/misc/pangorenderer.rb +1 -1
- data/sample/misc/properties.rb +1 -0
- data/sample/misc/to_drawable.rb +1 -1
- data/sample/misc/tooltips.rb +1 -1
- data/test/test_gtk_accessible.rb +31 -0
- data/test/test_gtk_entry.rb +36 -0
- data/test/test_gtk_header_bar.rb +66 -0
- data/test/test_gtk_icon_view.rb +41 -0
- data/test/test_gtk_level_bar.rb +82 -0
- data/test/test_gtk_list_store.rb +2 -1
- data/test/test_gtk_menu_button.rb +49 -0
- data/test/test_gtk_revealer.rb +57 -0
- data/test/test_gtk_search_bar.rb +55 -0
- data/test/test_gtk_search_entry.rb +34 -0
- data/test/test_gtk_stack.rb +115 -0
- data/test/test_gtk_tree_selection.rb +31 -0
- metadata +31 -14
data/lib/1.9/gtk3.so
CHANGED
Binary file
|
data/lib/2.0/gtk3.so
CHANGED
Binary file
|
data/lib/2.1/gtk3.so
CHANGED
Binary file
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2003-
|
1
|
+
# Copyright (c) 2003-2014 Ruby-GNOME2 Project Team
|
2
2
|
# This program is licenced under the same licence as Ruby-GNOME2.
|
3
3
|
#
|
4
4
|
# $Id: appwindow.rb,v 1.7 2005/03/05 15:01:16 mutoh Exp $
|
@@ -26,98 +26,98 @@ module Demo
|
|
26
26
|
add_accel_group(accel_group)
|
27
27
|
|
28
28
|
item_factory = Gtk::ItemFactory.new(Gtk::ItemFactory::TYPE_MENU_BAR,
|
29
|
-
|
29
|
+
'<main>', accel_group)
|
30
30
|
# create menu items
|
31
31
|
menuitem_cb = proc do |data, widget|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
32
|
+
# TODO: Show item-factory's path to menu item
|
33
|
+
dialog = Gtk::MessageDialog.new(self,
|
34
|
+
Gtk::Dialog::DESTROY_WITH_PARENT,
|
35
|
+
Gtk::MessageDialog::INFO,
|
36
|
+
Gtk::MessageDialog::BUTTONS_CLOSE,
|
37
|
+
"You selected or toggled the menu item \"#{Gtk::ItemFactory.path_from_widget(widget)}\"")
|
38
|
+
|
39
|
+
# Close dialog on user response
|
40
|
+
dialog.signal_connect('response') do |widget, data|
|
41
|
+
widget.destroy
|
42
|
+
end
|
43
|
+
|
44
|
+
dialog.show
|
45
45
|
end
|
46
46
|
|
47
47
|
menu_items = [
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
48
|
+
["/_File"],
|
49
|
+
["/_File/_New",
|
50
|
+
"<StockItem>", "<control>N", Gtk::Stock::NEW, menuitem_cb],
|
51
|
+
["/_File/_Open",
|
52
|
+
"<StockItem>", "<control>O", Gtk::Stock::OPEN, menuitem_cb],
|
53
|
+
["/File/_Save",
|
54
|
+
"<StockItem>", "<control>S", Gtk::Stock::SAVE, menuitem_cb],
|
55
|
+
["/File/Save _As...",
|
56
|
+
"<StockItem>", nil, Gtk::Stock::SAVE, menuitem_cb],
|
57
|
+
["/File/sep1",
|
58
|
+
"<Separator>", nil, nil, menuitem_cb],
|
59
|
+
["/File/Quit",
|
60
|
+
"<StockItem>", "<control>Q", Gtk::Stock::QUIT, menuitem_cb],
|
61
|
+
|
62
|
+
["/_Preferences"],
|
63
|
+
["/_Preferences/_Color"],
|
64
|
+
["/_Preferences/Color/_Red",
|
65
|
+
"<RadioItem>", nil, nil, menuitem_cb],
|
66
|
+
["/_Preferences/Color/_Green",
|
67
|
+
"/Preferences/Color/Red", nil, nil, menuitem_cb],
|
68
|
+
["/_Preferences/Color/_Blue",
|
69
|
+
"/Preferences/Color/Red", nil, nil, menuitem_cb],
|
70
|
+
|
71
|
+
["/Preferences/_Shape"],
|
72
|
+
["/Preferences/Shape/_Square",
|
73
|
+
"<RadioItem>", nil, nil, menuitem_cb],
|
74
|
+
["/Preferences/Shape/_Rectangle",
|
75
|
+
"/Preferences/Shape/Square", nil, nil, menuitem_cb],
|
76
|
+
["/Preferences/Shape/_Oval",
|
77
|
+
"/Preferences/Shape/Square", nil, nil, menuitem_cb],
|
78
|
+
|
79
|
+
# If you wanted this to be right justified you would use
|
80
|
+
# "<LastBranch>", not "<Branch>". Right justified help menu
|
81
|
+
# items are generally considered a bad idea now days.
|
82
|
+
["/_Help"],
|
83
|
+
["/Help/_About", "<Item>", nil, nil, Proc.new{about_cb}],
|
84
84
|
]
|
85
85
|
item_factory.create_items(menu_items)
|
86
86
|
|
87
87
|
table.attach(item_factory.get_widget('<main>'),
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
88
|
+
# X direction # Y direction
|
89
|
+
0, 1, 0, 1,
|
90
|
+
Gtk::EXPAND | Gtk::FILL, 0,
|
91
|
+
0, 0)
|
92
92
|
|
93
93
|
## Create the toolbar
|
94
94
|
toolbar = Gtk::Toolbar.new
|
95
95
|
# toolbar.set_toolbar_style(Gtk::Toolbar::BOTH)
|
96
96
|
toolbar.append(Gtk::Stock::OPEN,
|
97
|
-
|
98
|
-
|
97
|
+
"This is a demo button with an 'open' icon"
|
98
|
+
) do toolbar_cb end
|
99
99
|
toolbar.append(Gtk::Stock::QUIT,
|
100
|
-
|
101
|
-
|
100
|
+
"This is a demo button with an 'quit' icon"
|
101
|
+
) do toolbar_cb end
|
102
102
|
toolbar.append_space
|
103
103
|
toolbar.append(:demo_gtk_logo,
|
104
|
-
|
105
|
-
|
104
|
+
"This is a demo button with an 'gtk' icon"
|
105
|
+
) do toolbar_cb end
|
106
106
|
table.attach(toolbar,
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
107
|
+
# X direction # Y direction
|
108
|
+
0, 1, 1, 2,
|
109
|
+
Gtk::EXPAND | Gtk::FILL, 0,
|
110
|
+
0, 0)
|
111
111
|
|
112
112
|
## Create document
|
113
113
|
sw = Gtk::ScrolledWindow.new
|
114
114
|
sw.set_policy(:automatic, :automatic)
|
115
115
|
sw.shadow_type = :in
|
116
116
|
table.attach(sw,
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
117
|
+
# X direction # Y direction
|
118
|
+
0, 1, 2, 3,
|
119
|
+
Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL,
|
120
|
+
0, 0)
|
121
121
|
|
122
122
|
set_default_size(200, 200)
|
123
123
|
|
@@ -127,32 +127,32 @@ module Demo
|
|
127
127
|
## Create statusbar
|
128
128
|
statusbar = Gtk::Statusbar.new
|
129
129
|
table.attach(statusbar,
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
130
|
+
# X direction # Y direction
|
131
|
+
0, 1, 3, 4,
|
132
|
+
Gtk::EXPAND | Gtk::FILL, 0,
|
133
|
+
0, 0)
|
134
134
|
|
135
135
|
# Show text widget info in the statusbar
|
136
136
|
buffer = contents.buffer
|
137
137
|
buffer.signal_connect('changed') do |buffer|
|
138
|
-
|
138
|
+
update_statusbar(buffer, statusbar)
|
139
139
|
end
|
140
140
|
# cursor moved
|
141
141
|
buffer.signal_connect('mark_set') do |buffer, iter, mark|
|
142
|
-
|
142
|
+
update_statusbar(buffer, statusbar)
|
143
143
|
end
|
144
144
|
end
|
145
145
|
|
146
146
|
def toolbar_cb(*args)
|
147
147
|
dialog = Gtk::MessageDialog.new(self,
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
148
|
+
Gtk::Dialog::DESTROY_WITH_PARENT,
|
149
|
+
Gtk::MessageDialog::INFO,
|
150
|
+
Gtk::MessageDialog::BUTTONS_CLOSE,
|
151
|
+
"You selected a toolbar button")
|
152
152
|
|
153
153
|
# Close dialog on user response
|
154
154
|
dialog.signal_connect('response') do |widget, data|
|
155
|
-
|
155
|
+
widget.destroy
|
156
156
|
end
|
157
157
|
|
158
158
|
dialog.show
|
@@ -165,8 +165,8 @@ module Demo
|
|
165
165
|
end
|
166
166
|
|
167
167
|
authors = ["Peter Mattis", "Spencer Kimball", "Josh MacDonald", "and many more..."]
|
168
|
-
documentors = ["Owen Taylor", "Tony Gale", "Mattias Clasen <mclasen@redhat.com>",
|
169
|
-
|
168
|
+
documentors = ["Owen Taylor", "Tony Gale", "Mattias Clasen <mclasen@redhat.com>",
|
169
|
+
"and many more..."]
|
170
170
|
license = %Q[
|
171
171
|
This library is free software; you can redistribute it and/or
|
172
172
|
modify it under the terms of the GNU Library General Public License as
|
@@ -185,23 +185,23 @@ Boston, MA 02111-1307, USA.
|
|
185
185
|
]
|
186
186
|
|
187
187
|
transparent = Gdk::Pixbuf.new(Demo.find_file("gtk-logo-rgb.gif")).add_alpha(true, 0xff, 0xff, 0xff)
|
188
|
-
|
188
|
+
|
189
189
|
Gtk::AboutDialog.set_email_hook {|about, link|
|
190
|
-
|
190
|
+
puts "send mail to #{link}"
|
191
191
|
}
|
192
192
|
Gtk::AboutDialog.set_url_hook {|about, link|
|
193
|
-
|
193
|
+
puts "show url #{link}"
|
194
194
|
}
|
195
195
|
Gtk::AboutDialog.show(self,
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
196
|
+
:name => "GTK+ Code Demos",
|
197
|
+
:version => Gtk::VERSION.join("."),
|
198
|
+
:copyright => "(C) 1997-2004 The GTK+ Team",
|
199
|
+
:license => license,
|
200
|
+
:website => "http://www.gtk.org",
|
201
|
+
:comments => "Program to demonstrate GTK+ functions.",
|
202
|
+
:authors => authors,
|
203
|
+
:documenters => documentors,
|
204
|
+
:logo => transparent)
|
205
205
|
end
|
206
206
|
|
207
207
|
def update_statusbar(buffer, statusbar)
|
@@ -210,7 +210,7 @@ Boston, MA 02111-1307, USA.
|
|
210
210
|
iter = buffer.get_iter_at_mark(buffer.get_mark('insert'))
|
211
211
|
|
212
212
|
statusbar.push(0,
|
213
|
-
|
213
|
+
"Cursor at row #{iter.line} column #{iter.line_offset} - #{buffer.char_count} chars in document")
|
214
214
|
end
|
215
215
|
|
216
216
|
def register_stock_icons
|
@@ -18,20 +18,20 @@ From http://cairographics.org/samples/operator_add.html,
|
|
18
18
|
http://cairographics.org/samples/operator_saturate.html and
|
19
19
|
http://cairographics.org/samples/operator_xor.html
|
20
20
|
=end
|
21
|
-
require
|
21
|
+
require "common"
|
22
22
|
|
23
23
|
module Demo
|
24
24
|
class CairoOperator < CairoWindow
|
25
25
|
def initialize
|
26
|
-
super(
|
26
|
+
super("cairo operator")
|
27
27
|
@operator = Cairo::OPERATOR_ADD
|
28
28
|
|
29
29
|
set_default_size(400, 400)
|
30
|
-
|
30
|
+
|
31
31
|
@drawing_area = child
|
32
32
|
remove(@drawing_area)
|
33
|
-
|
34
|
-
vbox = Gtk::
|
33
|
+
|
34
|
+
vbox = Gtk::Box.new(:vertical)
|
35
35
|
vbox.pack_start(@drawing_area, :expand => true, :fill => true)
|
36
36
|
vbox.pack_start(operator_selector, :expand => false, :fill => false)
|
37
37
|
add(vbox)
|
@@ -47,9 +47,9 @@ module Demo
|
|
47
47
|
cr.set_source(image, 0.0, 0.0)
|
48
48
|
cr.paint
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
cr.set_operator(@operator)
|
52
|
-
|
52
|
+
|
53
53
|
cr.set_source_rgba(1, 0, 0, 0.5)
|
54
54
|
cr.rectangle(0.2, 0.2, 0.5, 0.5)
|
55
55
|
cr.fill
|
@@ -62,7 +62,7 @@ module Demo
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def operator_selector
|
65
|
-
combo = Gtk::
|
65
|
+
combo = Gtk::ComboBoxText.new
|
66
66
|
operators = []
|
67
67
|
Cairo.constants.each do |name|
|
68
68
|
operators << name if /^OPERATOR_/ =~ name
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2003-
|
1
|
+
# Copyright (c) 2003-2014 Ruby-GNOME2 Project Team
|
2
2
|
# This program is licenced under the same licence as Ruby-GNOME2.
|
3
3
|
#
|
4
4
|
# $Id: drawingarea.rb,v 1.5 2005/02/12 23:02:43 kzys Exp $
|
@@ -18,50 +18,49 @@ and drag in the scribble area to draw squiggles. Resize the window
|
|
18
18
|
to clear the area.
|
19
19
|
=end
|
20
20
|
|
21
|
-
require
|
21
|
+
require "common"
|
22
22
|
|
23
23
|
module Demo
|
24
24
|
class DrawingArea < BasicWindow
|
25
25
|
def initialize
|
26
26
|
# Pixmap for scribble area, to store current scribbles
|
27
|
-
@
|
28
|
-
super(
|
27
|
+
@cairo_context = nil
|
28
|
+
super("Drawing Area")
|
29
29
|
|
30
30
|
self.border_width = 8
|
31
31
|
|
32
|
-
vbox = Gtk::
|
32
|
+
vbox = Gtk::Box.new(:vertical, 8)
|
33
33
|
vbox.border_width = 8
|
34
34
|
add(vbox)
|
35
35
|
|
36
|
-
|
37
36
|
## Create the checkerboard area
|
38
37
|
label = Gtk::Label.new
|
39
|
-
label.set_markup(
|
38
|
+
label.set_markup("<u>Checkerboard pattern</u>")
|
40
39
|
vbox.pack_start(label, :expand => false, :fill => false, :padding => 0)
|
41
|
-
|
40
|
+
|
42
41
|
frame = Gtk::Frame.new
|
43
42
|
frame.shadow_type = :in
|
44
43
|
vbox.pack_start(frame, :expand => true, :fill => true, :padding => 0)
|
45
|
-
|
44
|
+
|
46
45
|
da = Gtk::DrawingArea.new
|
47
46
|
# set a minimum size
|
48
47
|
da.set_size_request(100, 100)
|
49
48
|
|
50
49
|
frame.add(da)
|
51
50
|
|
52
|
-
da.signal_connect(
|
53
|
-
|
51
|
+
da.signal_connect("draw") do |widget, event|
|
52
|
+
checkerboard_draw(widget, event)
|
54
53
|
end
|
55
54
|
|
56
55
|
## Create the scribble area
|
57
56
|
label = Gtk::Label.new
|
58
|
-
label.set_markup(
|
57
|
+
label.set_markup("<u>Scribble area</u>")
|
59
58
|
vbox.pack_start(label, :expand => false, :fill => false, :padding => 0)
|
60
|
-
|
59
|
+
|
61
60
|
frame = Gtk::Frame.new
|
62
61
|
frame.shadow_type = :in
|
63
62
|
vbox.pack_start(frame, :expand => true, :fill => true, :padding => 0)
|
64
|
-
|
63
|
+
|
65
64
|
da = Gtk::DrawingArea.new
|
66
65
|
# set a minimum size
|
67
66
|
da.set_size_request(100, 100)
|
@@ -69,42 +68,34 @@ module Demo
|
|
69
68
|
frame.add(da)
|
70
69
|
|
71
70
|
# Signals used to handle backing pixmap
|
72
|
-
da.signal_connect(
|
73
|
-
|
71
|
+
da.signal_connect("draw") do |*args|
|
72
|
+
scribble_draw(*args)
|
74
73
|
end
|
75
|
-
da.signal_connect(
|
76
|
-
|
74
|
+
da.signal_connect("configure-event") do |widget, event|
|
75
|
+
scribble_configure_event(widget)
|
77
76
|
end
|
78
|
-
|
77
|
+
|
79
78
|
# Event signals
|
80
|
-
da.signal_connect(
|
81
|
-
|
79
|
+
da.signal_connect("motion-notify-event") do |*args|
|
80
|
+
scribble_motion_notify_event(*args)
|
82
81
|
end
|
83
|
-
da.signal_connect(
|
84
|
-
|
82
|
+
da.signal_connect("button-press-event") do |*args|
|
83
|
+
scribble_button_press_event(*args)
|
85
84
|
end
|
86
|
-
|
85
|
+
|
87
86
|
# Ask to receive events the drawing area doesn't normally
|
88
87
|
# subscribe to
|
89
88
|
da.events |= (Gdk::Event::LEAVE_NOTIFY_MASK |
|
90
|
-
|
91
|
-
|
92
|
-
|
89
|
+
Gdk::Event::BUTTON_PRESS_MASK |
|
90
|
+
Gdk::Event::POINTER_MOTION_MASK |
|
91
|
+
Gdk::Event::POINTER_MOTION_HINT_MASK)
|
93
92
|
end
|
94
93
|
|
95
|
-
# Create a new
|
94
|
+
# Create a new surface of the appropriate size to store our scribbles
|
96
95
|
def scribble_configure_event(widget)
|
97
|
-
@
|
98
|
-
|
99
|
-
|
100
|
-
-1)
|
101
|
-
|
102
|
-
# Initialize the pixmap to white
|
103
|
-
@pixmap.draw_rectangle(widget.style.white_gc,
|
104
|
-
true,
|
105
|
-
0, 0,
|
106
|
-
widget.allocation.width,
|
107
|
-
widget.allocation.height)
|
96
|
+
@cairo_context = widget.window.create_cairo_context
|
97
|
+
@cairo_context.set_source_rgb(1, 1, 1)
|
98
|
+
@cairo_context.paint
|
108
99
|
|
109
100
|
# We've handled the configure event, no need for further processing.
|
110
101
|
return true
|
@@ -112,41 +103,32 @@ module Demo
|
|
112
103
|
|
113
104
|
CHECK_SIZE = 10
|
114
105
|
SPACING = 2
|
115
|
-
def
|
116
|
-
# At the start of
|
106
|
+
def checkerboard_draw(da, cairo_context)
|
107
|
+
# At the start of a draw handler, a clip region of event.area
|
117
108
|
# is set on the window, and event.area has been cleared to the
|
118
109
|
# widget's background color. The docs for
|
119
110
|
# gdk_window_begin_paint_region give more details on how this
|
120
111
|
# works.
|
121
|
-
|
122
|
-
|
123
|
-
# It would be a bit more efficient to keep these
|
124
|
-
# GC's around instead of recreating on each expose, but
|
125
|
-
# this is the lazy/slow way.
|
126
|
-
gc1 = Gdk::GC.new(da.window)
|
127
|
-
gc1.rgb_fg_color = Gdk::Color.new(30000, 0, 30000)
|
128
|
-
|
129
|
-
gc2 = Gdk::GC.new(da.window)
|
130
|
-
gc2.rgb_fg_color = Gdk::Color.new(65535, 65535, 65535)
|
131
112
|
|
132
113
|
xcount = 0
|
114
|
+
width = da.allocated_width
|
115
|
+
height = da.allocated_height
|
133
116
|
SPACING.step(da.allocation.width, CHECK_SIZE + SPACING) do |i|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
xcount += 1
|
117
|
+
ycount = xcount % 2; # start with even/odd depending on row
|
118
|
+
SPACING.step(da.allocation.height, CHECK_SIZE + SPACING) do |j|
|
119
|
+
if ycount % 2 == 1
|
120
|
+
cairo_context.set_source_rgb(0.45777, 0, 0.45777)
|
121
|
+
else
|
122
|
+
cairo_context.set_source_rgb(1, 1, 1)
|
123
|
+
end
|
124
|
+
|
125
|
+
# If we're outside the clip, this will do nothing.
|
126
|
+
cairo_context.fill do
|
127
|
+
cairo_context.rectangle(i, j, CHECK_SIZE, CHECK_SIZE)
|
128
|
+
end
|
129
|
+
ycount += 1
|
130
|
+
end
|
131
|
+
xcount += 1
|
150
132
|
end
|
151
133
|
# return true because we've handled this event, so no
|
152
134
|
# further processing is required.
|
@@ -154,43 +136,36 @@ module Demo
|
|
154
136
|
return true
|
155
137
|
end
|
156
138
|
|
157
|
-
# Redraw the screen from the
|
158
|
-
def
|
159
|
-
|
160
|
-
|
161
|
-
# is whether the GC has an inappropriate clip region set.
|
162
|
-
widget.window.draw_drawable(widget.style.fg_gc(widget.state),
|
163
|
-
@pixmap,
|
164
|
-
# Only copy the area that was exposed.
|
165
|
-
event.area.x, event.area.y,
|
166
|
-
event.area.x, event.area.y,
|
167
|
-
event.area.width, event.area.height)
|
139
|
+
# Redraw the screen from the surface
|
140
|
+
def scribble_draw(widget, event)
|
141
|
+
event.set_source(@cairo_context.target)
|
142
|
+
event.paint
|
168
143
|
return false
|
169
144
|
end
|
170
145
|
|
171
|
-
|
172
|
-
|
146
|
+
# Draw a rectangle on the screen
|
173
147
|
def draw_brush(widget, x, y)
|
174
148
|
update_rect = Gdk::Rectangle.new(x - 3, y - 3, 6, 6)
|
175
149
|
|
176
|
-
# Paint to the
|
177
|
-
@
|
178
|
-
|
179
|
-
|
180
|
-
|
150
|
+
# Paint to the surface, where we store our state
|
151
|
+
@cairo_context.fill do
|
152
|
+
@cairo_context.set_source_rgb(0, 0, 0)
|
153
|
+
@cairo_context.rectangle(update_rect.x,
|
154
|
+
update_rect.y,
|
155
|
+
update_rect.width,
|
156
|
+
update_rect.height)
|
157
|
+
end
|
181
158
|
|
182
159
|
# Now invalidate the affected region of the drawing area.
|
183
160
|
widget.window.invalidate(update_rect, false)
|
184
161
|
end
|
185
162
|
|
186
163
|
def scribble_button_press_event(widget, event)
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
end
|
191
|
-
|
164
|
+
# paranoia check, in case we haven't gotten a configure event
|
165
|
+
return false unless @cairo_context
|
166
|
+
|
192
167
|
if event.button == 1
|
193
|
-
|
168
|
+
draw_brush(widget, event.x, event.y)
|
194
169
|
end
|
195
170
|
|
196
171
|
# We've handled the event, stop processing
|
@@ -198,10 +173,8 @@ module Demo
|
|
198
173
|
end
|
199
174
|
|
200
175
|
def scribble_motion_notify_event(widget, event)
|
201
|
-
|
202
|
-
|
203
|
-
return false
|
204
|
-
end
|
176
|
+
# paranoia check, in case we haven't gotten a configure event
|
177
|
+
return false unless @cairo_context
|
205
178
|
|
206
179
|
# This call is very important; it requests the next motion event.
|
207
180
|
# If you don't call Gdk::Window#pointer you'll only get
|
@@ -212,11 +185,13 @@ module Demo
|
|
212
185
|
# By requesting the next event as we handle the current one,
|
213
186
|
# we avoid getting a huge number of events faster than we
|
214
187
|
# can cope.
|
215
|
-
|
216
|
-
win, x, y, state = event.window.pointer
|
217
188
|
|
218
|
-
|
219
|
-
|
189
|
+
# NOTE: Gdk::EventMotion#window will be restored from Ruby/GDK3 2.1.1.
|
190
|
+
# win, x, y, state = event.window.get_device_position(event.device)
|
191
|
+
win, x, y, state = widget.window.get_device_position(event.device)
|
192
|
+
|
193
|
+
if (state & :button1_mask) != 0
|
194
|
+
draw_brush(widget, x, y)
|
220
195
|
end
|
221
196
|
|
222
197
|
# We've handled it, stop processing
|