1Tk_CanvasTextInfo(3) Tk Library Procedures Tk_CanvasTextInfo(3)
2
3
4
5______________________________________________________________________________
6
8 Tk_CanvasTextInfo - additional information for managing text items in
9 canvases
10
12 #include <tk.h>
13
14 Tk_CanvasTextInfo *
15 Tk_CanvasGetTextInfo(canvas)
16
18 Tk_Canvas canvas (in) A token that identifies a particular
19 canvas widget.
20_________________________________________________________________
21
22
24 Textual canvas items are somewhat more complicated to manage than other
25 items, due to things like the selection and the input focus. Tk_Can‐
26 vasGetTextInfo may be invoked by a type manager to obtain additional
27 information needed for items that display text. The return value from
28 Tk_CanvasGetTextInfo is a pointer to a structure that is shared between
29 Tk and all the items that display text. The structure has the follow‐
30 ing form:
31 typedef struct Tk_CanvasTextInfo {
32 Tk_3DBorder selBorder;
33 int selBorderWidth;
34 XColor *selFgColorPtr;
35 Tk_Item *selItemPtr;
36 int selectFirst;
37 int selectLast;
38 Tk_Item *anchorItemPtr;
39 int selectAnchor;
40 Tk_3DBorder insertBorder;
41 int insertWidth;
42 int insertBorderWidth;
43 Tk_Item *focusItemPtr;
44 int gotFocus;
45 int cursorOn;
46 } Tk_CanvasTextInfo;
47 The selBorder field identifies a Tk_3DBorder that should be used for
48 drawing the background under selected text. selBorderWidth gives the
49 width of the raised border around selected text, in pixels. selFgCol‐
50 orPtr points to an XColor that describes the foreground color to be
51 used when drawing selected text. selItemPtr points to the item that is
52 currently selected, or NULL if there is no item selected or if the can‐
53 vas does not have the selection. selectFirst and selectLast give the
54 indices of the first and last selected characters in selItemPtr, as
55 returned by the indexProc for that item. anchorItemPtr points to the
56 item that currently has the selection anchor; this is not necessarily
57 the same as selItemPtr. selectAnchor is an index that identifies the
58 anchor position within anchorItemPtr. insertBorder contains a
59 Tk_3DBorder to use when drawing the insertion cursor; insertWidth
60 gives the total width of the insertion cursor in pixels, and insertBor‐
61 derWidth gives the width of the raised border around the insertion
62 cursor. focusItemPtr identifies the item that currently has the input
63 focus, or NULL if there is no such item. gotFocus is 1 if the canvas
64 widget has the input focus and 0 otherwise. cursorOn is 1 if the
65 insertion cursor should be drawn in focusItemPtr and 0 if it should not
66 be drawn; this field is toggled on and off by Tk to make the cursor
67 blink.
68
69 The structure returned by Tk_CanvasGetTextInfo is shared between Tk and
70 the type managers; typically the type manager calls Tk_CanvasGetTex‐
71 tInfo once when an item is created and then saves the pointer in the
72 item's record. Tk will update information in the Tk_CanvasTextInfo;
73 for example, a configure widget command might change the selBorder
74 field, or a select widget command might change the selectFirst field,
75 or Tk might change cursorOn in order to make the insertion cursor flash
76 on and off during successive redisplays.
77
78 Type managers should treat all of the fields of the Tk_CanvasTextInfo
79 structure as read-only, except for selItemPtr, selectFirst, selectLast,
80 and selectAnchor. Type managers may change selectFirst, selectLast,
81 and selectAnchor to adjust for insertions and deletions in the item
82 (but only if the item is the current owner of the selection or anchor,
83 as determined by selItemPtr or anchorItemPtr). If all of the selected
84 text in the item is deleted, the item should set selItemPtr to NULL to
85 indicate that there is no longer a selection.
86
87
89 canvas, focus, insertion cursor, selection, selection anchor, text
90
91
92
93Tk 4.0 Tk_CanvasTextInfo(3)