File: devguide-15.html

package info (click to toggle)
sketch 0.6.13-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 5,284 kB
  • ctags: 8,453
  • sloc: python: 34,711; ansic: 16,543; makefile: 83; sh: 26
file content (100 lines) | stat: -rw-r--r-- 4,501 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<html>
<head>
<title>Developer's Guide: The class Selectable</title>
</head>
<body bgcolor=white text=black link=blue vlink=navy alink=red>
<TABLE WIDTH="100%">
<TR>
<TH ALIGN="left" WIDTH="33%"><img SRC="Images/arrow-left.png" WIDTH="16" HEIGHT="16" ALIGN="top" ALT="Prev"></TH>
<TH ALIGN="center" WIDTH="33%"><img SRC="Images/arrow-up.png" WIDTH="16" HEIGHT="16" ALIGN="top" ALT="Up"></TH>
<TH ALIGN="right" WIDTH="33%"><img SRC="Images/arrow-right.png" WIDTH="16" HEIGHT="16" ALIGN="top" ALT="Next"></TH>
</TR>
<TR>
<TD ALIGN="left"><A HREF="devguide-14.html">The class Protocols</A></TD>
<TD ALIGN="center"><A HREF="devguide-9.html">The Document and Graphics Classes</A></TD>
<TD ALIGN="right"><A HREF="devguide-16.html">The class Primitive</A></TD>
</TR>
</TABLE>
<HR NOSHADE>
<H2><FONT face="Helvetica,Arial"><A NAME="N1"></A>The class <A NAME="N2"></A><tt>Selectable</tt></font></H2>

<P>The class <tt>Selectable</tt> defines the interface for objects that can
be selected with the mouse. This includes tests for whether the object
is hit by a mouse click and methods for the handles.</P>


<H3><FONT face="Helvetica,Arial"><A NAME="N3"></A>The Selection Mechanism</font></H3>

<P>Yet to be written...</P>



<H3><FONT face="Helvetica,Arial"><A NAME="N4"></A>Methods</font></H3>

<P>A <tt>Selectable</tt> object has these methods:</P>
<P>
<DL>

<DT><B><A NAME="N5"></A><tt>Hit(<i>p</i>, <i>rect</i>, <i>device</i>
[, <i>clip</i>])</tt></B><DD>
<P>Return true if clicking at <i>p</i> (a <A HREF="devguide-5.html">point object</A>) should select the object. The
parameter <i>device</i> is a graphics device that
can convert points between <A HREF="devguide-4.html">document
coordinates and window coordinates</A>. <i>p</i> is always given in
document coordinates.</P>
<P><i>rect</i> is a <A HREF="devguide-6.html">rect object</A> in
doc-coordinates that describes a small area around <i>p</i> (a
few pixels wide). A point of the object should be considered
`hit' if it lies inside this rectangle.</P>
<P>The <i>device</i> parameter is necessary, because clicking on a
special point should have some tolerance, so that `missing' by a
few pixels still selects that point. Unfortunately, pixels are
screen coordinates and the object's coordinates are document
coordinates, so conversion between the two is sometimes
necessary. <i>device</i> has some methods for this and also for
testing if certain primitives are hit. Currently <i>device</i> is
an instance of <tt>HitTestDevice</tt></P>
<P>The optional parameter <i>clip</i> is only provided if the object
is used as a clip mask. If it is provided its value is 1.
Objects that can be used as clip masks (their <CODE>is_clip</CODE> flag
is true) should test whether <i>p</i> is inside of the object
regardless of whether they are filled or not. Objects that
cannot be used as clip masks don't need to accept it.</P>

<DT><B><A NAME="N6"></A><tt>SelectSubobject(<i>p</i>, <i>rect</i>, <i>device</i>[, <i>path</i>])</tt></B><DD>
<P>When the parent decides that one of its children (or one of the
child's descendants) is to be selected (this is determined using
the children's bounding rects and their <tt>Hit</tt> methods), it
calls this method to ask the child for details.</P>
<P>Normally, self should be returned (this is also the default
behavior). To select a subobject, return selection info
relative to self as a single tuple of selection info. (see
selinfo.py) </P>
<P>Compound objects like groups and layers override this method to
let the user select their children.</P>
<P>As in <A HREF="#N5"><tt>Hit</tt></A>, <i>p</i> and <i>rect</i> describe a
point and a small tolerance rectangle around it, and <i>device</i>
is a <tt>HitTestDevice</tt>. The optional argument
<i>path</i> is useful only for compound objects  but
has to be accepted by all graphics objects. </P>

</DL>
</P>



<HR NOSHADE>
<TABLE WIDTH="100%">
<TR>
<TD ALIGN="left"><A HREF="devguide-14.html">The class Protocols</A></TD>
<TD ALIGN="center"><A HREF="devguide-9.html">The Document and Graphics Classes</A></TD>
<TD ALIGN="right"><A HREF="devguide-16.html">The class Primitive</A></TD>
</TR>
<TR>
<TH ALIGN="left" WIDTH="33%"><img SRC="Images/arrow-left.png" WIDTH="16" HEIGHT="16" ALIGN="top" ALT="Prev"></TH>
<TH ALIGN="center" WIDTH="33%"><img SRC="Images/arrow-up.png" WIDTH="16" HEIGHT="16" ALIGN="top" ALT="Up"></TH>
<TH ALIGN="right" WIDTH="33%"><img SRC="Images/arrow-right.png" WIDTH="16" HEIGHT="16" ALIGN="top" ALT="Next"></TH>
</TR>
</TABLE>
</body>
</html>