fxruby 1.6.1 → 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/doc/apes02.html +6 -6
- data/doc/apes03.html +11 -11
- data/doc/book.html +1 -1
- data/doc/build.html +63 -63
- data/doc/ch03s02.html +7 -7
- data/doc/ch03s03.html +18 -18
- data/doc/ch03s04.html +11 -11
- data/doc/ch03s05.html +14 -14
- data/doc/ch04s02.html +14 -14
- data/doc/ch04s03.html +15 -15
- data/doc/ch04s04.html +28 -28
- data/doc/ch05s02.html +49 -49
- data/doc/ch05s03.html +8 -8
- data/doc/changes.html +263 -193
- data/doc/clipboardtut.html +57 -45
- data/doc/cvs.html +10 -10
- data/doc/differences.html +4 -4
- data/doc/dragdroptut.html +50 -50
- data/doc/events.html +11 -11
- data/doc/examples.html +48 -48
- data/doc/gems.html +37 -37
- data/doc/goals.html +4 -4
- data/doc/implementation.html +4 -4
- data/doc/infosources.html +6 -6
- data/doc/library.html +19 -19
- data/doc/opengl.html +31 -31
- data/doc/pt01.html +1 -1
- data/doc/pt02.html +1 -1
- data/doc/scintilla.html +15 -15
- data/doc/style.css +3 -0
- data/doc/todo.html +5 -5
- data/doc/tutorial1.html +34 -34
- data/doc/unicode.html +56 -0
- data/ext/fox16/dialogs_wrap.cpp +38 -14
- data/ext/fox16/frames_wrap.cpp +856 -22
- data/ext/fox16/fx3d_wrap.cpp +169 -144
- data/ext/fox16/icons_wrap.cpp +24 -6
- data/ext/fox16/image_wrap.cpp +24 -6
- data/ext/fox16/label_wrap.cpp +23 -8
- data/ext/fox16/markfuncs.cpp +8 -1
- data/ext/fox16/mdi_wrap.cpp +53 -23
- data/ext/fox16/menu_wrap.cpp +43 -19
- data/ext/fox16/scintilla_wrap.cpp +31 -7
- data/ext/fox16/table_wrap.cpp +31 -7
- data/ext/fox16/text_wrap.cpp +31 -7
- data/ext/fox16/treelist_wrap.cpp +300 -276
- data/ext/fox16/ui_wrap.cpp +385 -26
- data/lib/fox16/aliases.rb +3 -0
- data/lib/fox16/version.rb +1 -1
- data/rdoc-sources/FXFoldingList.rb +2 -2
- data/tests/TC_FXDirList.rb +1 -1
- data/tests/TC_FXGLViewer.rb +2 -0
- data/tests/TC_FXHeader.rb +1 -1
- data/tests/TC_FXIconList.rb +1 -1
- data/tests/TC_FXId.rb +1 -1
- data/tests/TC_FXList.rb +1 -1
- data/tests/TC_FXListBox.rb +1 -1
- data/tests/TC_FXMenuCommand.rb +0 -14
- data/tests/TC_FXTable.rb +0 -32
- data/tests/TC_FXTableItem.rb +1 -1
- data/tests/TC_FXTreeList.rb +1 -1
- data/tests/TC_FXTreeListBox.rb +1 -1
- metadata +5 -4
data/doc/ch05s02.html
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
<html><head>
|
2
2
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
3
|
-
<title>Drag Sources</title><meta name="generator" content="DocBook XSL Stylesheets V1.
|
4
|
-
consisting of a main window widget (a <
|
5
|
-
instance) that parents an <
|
3
|
+
<title>Drag Sources</title><link rel="stylesheet" href="style.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.68.1"><link rel="start" href="book.html" title="Developing Graphical User Interfaces with FXRuby"><link rel="up" href="dragdroptut.html" title="Chapter 5. Drag and Drop"><link rel="prev" href="dragdroptut.html" title="Chapter 5. Drag and Drop"><link rel="next" href="ch05s03.html" title="Putting It All Together"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Drag Sources</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="dragdroptut.html">Prev</a> </td><th width="60%" align="center">Chapter 5. Drag and Drop</th><td width="20%" align="right"> <a accesskey="n" href="ch05s03.html">Next</a></td></tr></table><hr></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1353"></a>Drag Sources</h2></div></div></div><p>As before, we're going to start by presenting a skeleton application
|
4
|
+
consisting of a main window widget (a <code class="classname">DragSource</code>
|
5
|
+
instance) that parents an <code class="classname">FXCanvas</code> widget:</p><pre class="programlisting">require 'rubygems'
|
6
6
|
require_gem 'fxruby'
|
7
7
|
|
8
8
|
include Fox
|
@@ -45,22 +45,22 @@ if __FILE__ == $0
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
</pre
|
48
|
+
</pre><p>Since the main program (i.e. the part at the end) won't change for
|
49
49
|
the rest of the tutorial, I won't show that code anymore. Furthermore, the
|
50
|
-
<
|
51
|
-
the <
|
52
|
-
namely:</p><div class="itemizedlist"><ul type="disc"><li><p>We've defined a <
|
50
|
+
<code class="classname">DragSource</code> class has a few things in common with
|
51
|
+
the <code class="classname">DropSite</code> class from the previous example,
|
52
|
+
namely:</p><div class="itemizedlist"><ul type="disc"><li><p>We've defined a <code class="constant">SEL_PAINT</code> handler for the
|
53
53
|
canvas widget that just clears the canvas to its current background
|
54
54
|
color; and,</p></li><li><p>The drag type for colors
|
55
|
-
(<
|
56
|
-
<
|
55
|
+
(<code class="constant">FXWindow.colorType</code>) is registered in the
|
56
|
+
<code class="classname">DragSource</code>'s <code class="methodname">create()</code>
|
57
57
|
method.</p></li></ul></div><p>As before, you may want to run this basic version of the program to
|
58
58
|
be sure that it's working properly so far. You should simply see an empty
|
59
59
|
window with a red background.</p><p>Now for this application, we want a drag operation to begin when the
|
60
60
|
user presses the left mouse button inside the canvas and starts "dragging"
|
61
61
|
away from the canvas. So the first change we need to make is to add a
|
62
|
-
handler for the <
|
63
|
-
canvas:</p><
|
62
|
+
handler for the <code class="constant">SEL_LEFTBUTTONPRESS</code> message from the
|
63
|
+
canvas:</p><pre class="programlisting">@canvas.connect(SEL_LEFTBUTTONPRESS) {
|
64
64
|
#
|
65
65
|
# Capture (grab) the mouse when the button goes down, so that all future
|
66
66
|
# mouse events will be reported to this widget, even if those events occur
|
@@ -72,32 +72,32 @@ end
|
|
72
72
|
dragTypes = [FXWindow.colorType]
|
73
73
|
@canvas.beginDrag(dragTypes)
|
74
74
|
}
|
75
|
-
</pre
|
76
|
-
the <
|
77
|
-
The first is to call <
|
78
|
-
acts as the drag source. Calling <
|
75
|
+
</pre><p>Note that there are usually two things you're going to want to do in
|
76
|
+
the <code class="constant">SEL_LEFTBUTTONPRESS</code> handler for a drag source.
|
77
|
+
The first is to call <code class="methodname">grab()</code> on the window that
|
78
|
+
acts as the drag source. Calling <code class="methodname">grab()</code>
|
79
79
|
"captures" the mouse in the sense that subsequent mouse motion events will
|
80
80
|
be reported as if they occurred inside the grab window. This is important,
|
81
81
|
since in our case we're going to be dragging from this window to some
|
82
82
|
other window, possibly a window in a different application
|
83
83
|
altogether.</p><p>The second thing you'll want to do in the
|
84
|
-
<
|
85
|
-
call <
|
84
|
+
<code class="constant">SEL_LEFTBUTTONPRESS</code> handler for a drag source is to
|
85
|
+
call <code class="methodname">beginDrag()</code>. This not only kicks the
|
86
86
|
application into drag-and-drop mode, but also provides a way for you to
|
87
87
|
inform the system about the formats of data (i.e. the drag types) that
|
88
88
|
this drag source is able to provide. For this example, the drag source is
|
89
89
|
just going to offer one drag type.</p><p>Since releasing the left mouse button should end the drag operation,
|
90
90
|
it's important to also add a handler for the
|
91
|
-
<
|
91
|
+
<code class="constant">SEL_LEFTBUTTONRELEASE</code> message:</p><pre class="programlisting">@canvas.connect(SEL_LEFTBUTTONRELEASE) {
|
92
92
|
@canvas.ungrab
|
93
93
|
@canvas.endDrag
|
94
94
|
}
|
95
|
-
</pre
|
96
|
-
<
|
97
|
-
<
|
98
|
-
<
|
99
|
-
state.</p><p>The next change is to add a <
|
100
|
-
to handle mouse motion events during the drag operation:</p><
|
95
|
+
</pre><p>This is pretty much the mirror image of our
|
96
|
+
<code class="constant">SEL_LEFTBUTTONPRESS</code> handler. We call
|
97
|
+
<code class="methodname">ungrab()</code> to release the mouse capture, and
|
98
|
+
<code class="methodname">endDrag()</code> to clean up the drag-and-drop
|
99
|
+
state.</p><p>The next change is to add a <code class="constant">SEL_MOTION</code> handler,
|
100
|
+
to handle mouse motion events during the drag operation:</p><pre class="programlisting">@canvas.connect(SEL_MOTION) { |sender, sel, event|
|
101
101
|
if @canvas.dragging?
|
102
102
|
@canvas.handleDrag(event.root_x, event.root_y)
|
103
103
|
unless @canvas.didAccept == DRAG_REJECT
|
@@ -107,39 +107,39 @@ end
|
|
107
107
|
end
|
108
108
|
end
|
109
109
|
}
|
110
|
-
</pre
|
110
|
+
</pre><p>The <code class="methodname">dragging?</code> method returns true if we're
|
111
111
|
in the middle of a drag-and-drop operation for the drag source window,
|
112
|
-
i.e. after the call to <
|
113
|
-
call to <
|
112
|
+
i.e. after the call to <code class="methodname">beginDrag()</code> but before the
|
113
|
+
call to <code class="methodname">endDrag()</code>. If we're not currently
|
114
114
|
processing a drag operation, we're not really interested in mouse motion
|
115
115
|
events for the canvas.</p><p>If we <span class="emphasis"><em>are</em></span> processing a drag operation, however,
|
116
|
-
we need to call <
|
116
|
+
we need to call <code class="methodname">handleDrag()</code> on the drag source
|
117
117
|
window. FOX uses this information to send drag-and-drop messages (such as
|
118
|
-
<
|
119
|
-
and <
|
118
|
+
<code class="constant">SEL_DND_ENTER</code>, <code class="constant">SEL_DND_MOTION</code>
|
119
|
+
and <code class="constant">SEL_DND_LEAVE</code>) to the window that the mouse is
|
120
120
|
currently over. Note that the coordinates passed to
|
121
|
-
<
|
121
|
+
<code class="methodname">handleDrag()</code> are root window coordinates, and not
|
122
122
|
window-local coordinates.</p><p>Another good thing to consider doing here is to change the shape of
|
123
123
|
the cursor depending on the drop site's response to the drag-and-drop
|
124
124
|
messages from the drag source. For this example, we change the drag cursor
|
125
125
|
to one of FOX's built-in cursor shapes
|
126
|
-
(<
|
127
|
-
<
|
126
|
+
(<code class="constant">DEF_SWATCH_CURSOR</code>) if we get any response other than
|
127
|
+
<code class="constant">DRAG_REJECT</code> from the drop site. If the drop site
|
128
128
|
rejects this drag source's overtures, we instead change the drag cursor to
|
129
129
|
a cursor that resembles a stop sign
|
130
|
-
(<
|
130
|
+
(<code class="constant">DEF_DNDSTOP_CURSOR</code>).</p><p>I've purposely avoided suggesting that you run the program for the
|
131
131
|
last couple of changes, since until now there wasn't going to be any
|
132
132
|
visual indication that anything interesting was happening. But now you
|
133
133
|
should be able to run the application in its current state and see a few
|
134
134
|
things.</p><p>A first test is to confirm that the cursor shape changes to the
|
135
135
|
"stop" sign when you attempt to drag over some window that isn't willing
|
136
|
-
to accept a drop of the <
|
136
|
+
to accept a drop of the <code class="constant">FXWindow.colorType</code> drag type.
|
137
137
|
Start up one of the other FXRuby example programs (such as the
|
138
|
-
<
|
138
|
+
<code class="filename">scribble.rb</code> example) alongside your drag source
|
139
139
|
program, and then try "dragging" from the drag source's canvas onto the
|
140
140
|
Scribble program's canvas. During the drag attempt, the cursor should
|
141
141
|
maintain its shape as a "stop" sign since the canvas in the
|
142
|
-
<
|
142
|
+
<code class="filename">scribble.rb</code> example isn't drop-enabled.</p><p>Your next test can confirm that the cursor shape changes to the
|
143
143
|
"swatch" cursor (a small square) when you attempt to drag over a window
|
144
144
|
that is drop-enabled, and which is willing to accepts drops of this drag
|
145
145
|
type. The obvious choice is the example from the previous section (the
|
@@ -150,16 +150,16 @@ end
|
|
150
150
|
over a drop-enabled window, the cursor should change its shape.</p><p>The last (and most important) step is to actually complete the data
|
151
151
|
transfer. At any time during a drag-and-drop operation, a drop site may
|
152
152
|
request a copy of the drag-and-drop data by calling the
|
153
|
-
<
|
153
|
+
<code class="methodname">getDNDData()</code> method (as described in the previous
|
154
154
|
section). When this happens, FOX sends a
|
155
|
-
<
|
156
|
-
window, and so we now add a handler for that message:</p><
|
155
|
+
<code class="constant">SEL_DND_REQUEST</code> message to the current drag source
|
156
|
+
window, and so we now add a handler for that message:</p><pre class="programlisting">@canvas.connect(SEL_DND_REQUEST) { |sender, sel, event|
|
157
157
|
if event.target == FXWindow.colorType
|
158
158
|
@canvas.setDNDData(FROM_DRAGNDROP, FXWindow.colorType, Fox.fxencodeColorData(@canvas.backColor))
|
159
159
|
end
|
160
160
|
}
|
161
|
-
</pre
|
162
|
-
<
|
161
|
+
</pre><p>The first important thing to note here is that the
|
162
|
+
<code class="varname">target</code> field of the <code class="classname">FXEvent</code>
|
163
163
|
instance will contain the drag type requested by the drop site. If your
|
164
164
|
drag source offers its data in multiple formats, you definitely need to
|
165
165
|
check this in order to know how to package-up the data for transfer.
|
@@ -167,17 +167,17 @@ end
|
|
167
167
|
this example) it's still a good idea to check the requested type, since a
|
168
168
|
rogue drop site could ask for the data in some unexpected format.</p><p>Assuming that the drag type is as expected, the last step is send
|
169
169
|
the data to the drop site by calling
|
170
|
-
<
|
171
|
-
<
|
170
|
+
<code class="methodname">setDNDData()</code>. As with the call to
|
171
|
+
<code class="methodname">getDNDData()</code> for our previous drop site program,
|
172
172
|
you want to be sure to specify the origin of the data
|
173
|
-
(<
|
174
|
-
(<
|
173
|
+
(<code class="constant">FROM_DRAGNDROP</code>), the drag type
|
174
|
+
(<code class="constant">FXWindow.colorType</code>) and the data itself as a binary
|
175
175
|
string.</p><p>As a final test of the completed program, try dragging from this
|
176
176
|
window to some drop-enabled window (as described earlier). Now, when you
|
177
177
|
release the left mouse button to complete the "drop", the drop site should
|
178
178
|
change its color to red.</p><p>The complete program is listed below, and is included in the
|
179
|
-
<
|
180
|
-
name <
|
179
|
+
<code class="filename">examples</code> directory under the file
|
180
|
+
name <code class="filename">dragsource.rb</code>.</p><pre class="programlisting">require 'rubygems'
|
181
181
|
require_gem 'fxruby'
|
182
182
|
|
183
183
|
include Fox
|
@@ -259,4 +259,4 @@ if __FILE__ == $0
|
|
259
259
|
end
|
260
260
|
end
|
261
261
|
|
262
|
-
</pre></
|
262
|
+
</pre></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="dragdroptut.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="dragdroptut.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch05s03.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 5. Drag and Drop </td><td width="20%" align="center"><a accesskey="h" href="book.html">Home</a></td><td width="40%" align="right" valign="top"> Putting It All Together</td></tr></table></div></body></html>
|
data/doc/ch05s03.html
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
<html><head>
|
2
2
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
3
|
-
<title>Putting It All Together</title><meta name="generator" content="DocBook XSL Stylesheets V1.
|
3
|
+
<title>Putting It All Together</title><link rel="stylesheet" href="style.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.68.1"><link rel="start" href="book.html" title="Developing Graphical User Interfaces with FXRuby"><link rel="up" href="dragdroptut.html" title="Chapter 5. Drag and Drop"><link rel="prev" href="ch05s02.html" title="Drag Sources"><link rel="next" href="unicode.html" title="Chapter 6. Unicode and FXRuby"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Putting It All Together</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch05s02.html">Prev</a> </td><th width="60%" align="center">Chapter 5. Drag and Drop</th><td width="20%" align="right"> <a accesskey="n" href="unicode.html">Next</a></td></tr></table><hr></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1547"></a>Putting It All Together</h2></div></div></div><p>We've studied drag-and-drop enabled applications from two points of
|
4
4
|
view, that of a drag source and that of a drop site. But for most
|
5
5
|
applications, you'll want a window to act as both a drag source
|
6
6
|
<span class="emphasis"><em>and</em></span> a drop site. As it turns out, this is just a
|
@@ -8,11 +8,11 @@
|
|
8
8
|
sections.</p><p>If we use our completed drag source example program from the
|
9
9
|
previous section as a starting point, and then compare it to the drop site
|
10
10
|
example from the first section, it is apparent that the only "pieces"
|
11
|
-
missing are:</p><div class="itemizedlist"><ul type="disc"><li><p>A call to <
|
12
|
-
<
|
13
|
-
and,</p></li><li><p>A handler for the <
|
11
|
+
missing are:</p><div class="itemizedlist"><ul type="disc"><li><p>A call to <code class="methodname">dropEnable()</code>, to make
|
12
|
+
<code class="classname">DragSource</code>'s canvas drop-enabled;</p></li><li><p>A handler for the <code class="constant">SEL_DND_MOTION</code> message;
|
13
|
+
and,</p></li><li><p>A handler for the <code class="constant">SEL_DND_DROP</code>
|
14
14
|
message.</p></li></ul></div><p>If you merge those three short bits of code from
|
15
|
-
<
|
15
|
+
<code class="filename">dropsite.rb</code> into <code class="filename">dragsource.rb</code>,
|
16
16
|
you should end up with a program that can act as both a drag source and a
|
17
17
|
drop site. To test this program, you should be able to start up two
|
18
18
|
separate copies side-by-side and then drag from one to the other. Since,
|
@@ -22,8 +22,8 @@
|
|
22
22
|
FXRuby example that has displays a color dialog) and drag colors back and
|
23
23
|
forth between all three programs. You could spend days doing this and
|
24
24
|
never leave the house.</p><p>The complete program is listed below, and is included in the
|
25
|
-
<
|
26
|
-
name <
|
25
|
+
<code class="filename">examples</code> directory under the file
|
26
|
+
name <code class="filename">dragdrop.rb</code>.</p><pre class="programlisting">require 'rubygems'
|
27
27
|
require_gem 'fxruby'
|
28
28
|
|
29
29
|
include Fox
|
@@ -125,4 +125,4 @@ if __FILE__ == $0
|
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
128
|
-
</pre></
|
128
|
+
</pre></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch05s02.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="dragdroptut.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="unicode.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Drag Sources </td><td width="20%" align="center"><a accesskey="h" href="book.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 6. Unicode and FXRuby</td></tr></table></div></body></html>
|