OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tix/] [man/] [DItem.html] - Blame information for rev 1774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
 
2
 
3
 
4
<TITLE>Tix Display Items</TITLE>
5
<Center><H2>Tix Display Items</H2></Center><hr>
6
 
7
</pre><HR>
8
</pre><H3>DESCRIPTION</H3>
9
The Tix <B>Display Items</B></I> and <B>Display Types</B></I> are devised to
10
solve a general problem: many Tix widgets (both existing and planned
11
ones) display many items of many types simutaneously.
12
<P>
13
For example, a hierarchical listbox widget (HList) can display items
14
of images, plain text and subwindows in the form of a
15
hierarchy. Another widget, the tabular listbox, (TList, currently
16
planned and will be released in Tix 4.1) also display items of the
17
same types, although it arranges the items in a tabular form. Yet
18
another widget, the spreadsheet widget, also displays similar types
19
items, but in yet another format.
20
<P>
21
In these examples, the display items in different widgets are only
22
different in how they are arranged by the <B>host widget</B></I>. In Tix,
23
display items are clearly separated from the host widgets. The
24
advantage is two-fold: first, the creation and configuration of
25
display items become uniform across different host widgets. Second,
26
new display item types can be added without the need to modify the
27
existing host widgets.
28
<P>
29
In a way, Tix display items are similar to the items inside Tk
30
the canvas widget. However, unlike the Tix display items, the canvas
31
items are not independent of the canvas widget; this makes it
32
impossible to use the canvas items inside other types of TK widgets.
33
<P>
34
The appearance of a display item is controlled by a set of
35
<I>attributes</I></B>. It is observed that each the attributes usually fall
36
into one of two categroies: "<I>individual</I></B>" or
37
"<I>collective</I></B>". For example, the text items inside a HList widget
38
may all display a different text string; however, in most cases, the
39
text items share the same color, font and spacing. Instead of keeping
40
a duplicated version of the same attributes inside each display item,
41
it will be advantageous to put the collective attributes in a
42
special object called a <B>display style</B></I>. First, there is the space
43
concern: a host widget may have many thousands of items; keeping
44
dupilcated attributes will be very wasteful. Second, when it becomes
45
necessary to change a collective attribute, such as changing all the
46
change only the display style object than to modify all the text
47
items one by one.
48
<P>
49
The attributes of the a display item are thus stored in two places: it
50
has a set of <B>item options</B></I> to store its individual attributes. Each
51
display item is also associated with a <I>display style</I></B>, which specifies
52
the collective attributes of all items associated with itself.
53
<P>
54
The division between the individual and collective attributes are
55
fixed and cannot be changed. Thus, when it becomes necessary for some
56
items to differ in their collective attributes, two or more <B>display
57
styles</B></I> can be used. For example, suppose you want to display two
58
columns of text items inside an HList widget, one column in red and
59
the other in blue. You can create a TextStyle object called "red",
60
which defines a red foreground, and another called "blue", which
61
defines a blue foreground. You can then associate all text items of
62
the first column to "red" and the second column to "blue".
63
</pre><H3>DISPLAY ITEM TYPES AND OPTIONS</H3>
64
Currently there are three types of display items: <B>text</B></I>,
65
<B>imagetext</B></I> and <B>window</B></I>.
66
</pre><H3>IMAGETEXT ITEMS</H3>
67
Display items of the type <B>imagetext</B></I> are used to display an image
68
together with a text string. Imagetext items support the following options:
69
<P>
70
<B>ITEM OPTIONS</B></I>
71
<P>
72
<UL>
73
<P>
74
<pre><code><code><code>
75
Name:           <B>bitmap</B></I>
76
Class:          <B>Bitmap</B></I>
77
Switch:         <B>-bitmap</B></I>
78
</code></code></code></pre>
79
<UL>
80
Specifies the bitmap to display in the item.
81
</UL>
82
<P>
83
<pre><code><code><code>
84
Name:           <B>image</B></I>
85
Class:          <B>Image</B></I>
86
Switch:         <B>-image</B></I>
87
</code></code></code></pre>
88
<UL>
89
Specifies the image to display in the item. When both the
90
<B>-bitmap</B></I> and <B>-image</B></I> options are specified, only the image
91
will be displayed.
92
</UL>
93
<P>
94
<pre><code><code><code>
95
Name:           <B>imageTextStyle</B></I>
96
Class:          <B>ImageTextStyle</B></I>
97
Switch:         <B>-style</B></I>
98
</code></code></code></pre>
99
<UL>
100
Specifies the display style to use for this item. Must be the
101
name of a <B>imagetext</B></I> display style that has already be created by
102
the <B>tixDisplayStyle(n)</B></I> command.
103
</UL>
104
<P>
105
<pre><code><code><code>
106
Name:           <B>showImage</B></I>
107
Class:          <B>ShowImage</B></I>
108
Switch:         <B>-showimage</B></I>
109
</code></code></code></pre>
110
<UL>
111
A Boolean value that specifies whether the image/bitmap should be
112
displayed.
113
</UL>
114
<P>
115
<pre><code><code><code>
116
Name:           <B>showText</B></I>
117
Class:          <B>ShowText</B></I>
118
Switch:         <B>-showtext</B></I>
119
</code></code></code></pre>
120
<UL>
121
A Boolean value that specifies whether the text string should be
122
displayed.
123
</UL>
124
<P>
125
<pre><code><code><code>
126
Name:           <B>text</B></I>
127
Class:          <B>Text</B></I>
128
Switch:         <B>-text</B></I>
129
</code></code></code></pre>
130
<UL>
131
Specifies the text string to display in the item.
132
</UL>
133
<P>
134
<pre><code><code><code>
135
Name:           <B>underline</B></I>
136
Class:          <B>Underline</B></I>
137
Switch:         <B>-underline</B></I>
138
</code></code></code></pre>
139
<UL>
140
Specifies the integer index of a character to underline in the text
141
string in the item.  0 corresponds to the first character of the text
142
displayed in the widget, 1 to the next character, and so on.
143
</UL>
144
</UL>
145
<P>
146
<B>STYLE OPTIONS</B></I>
147
<P>
148
The style information of <B>imagetext</B></I> items are stored in the
149
<B>imagetext</B></I> display style. The following options are supported:
150
<UL>
151
<P>
152
<B>STANDARD OPTIONS</B></I>
153
<P>
154
\fC
155
<pre><code><code><code>
156
activeBackground        activeForeground
157
anchor                  background
158
disabledBackground      disabledForeground
159
foreground              font
160
justify                 padX
161
padY                    selectBackground
162
selectForeground        wrapLength
163
</code></code></code></pre>
164
</B></I>
165
<P>
166
See the <B>options(n)</B></I> manual entry for details on the standard
167
options.
168
<P>
169
<P>
170
<B>STYLE-SPECIFIC OPTIONS</B></I>
171
<P>
172
<P>
173
<pre><code><code><code>
174
Name:           <B>gap</B></I>
175
Class:          <B>Gap</B></I>
176
Switch:         <B>-gap</B></I>
177
</code></code></code></pre>
178
<UL>
179
Specifies the distance between the bitmap/image and the text string,
180
in number of pixels.
181
</UL>
182
</UL>
183
</pre><H3>TEXT ITEMS</H3>
184
Display items of the type <B>text</B></I> are used to display a text string
185
in a widget. Text items support the following options:
186
<P>
187
<B>ITEM OPTIONS</B></I>
188
<P>
189
<UL>
190
<P>
191
<pre><code><code><code>
192
Name:           <B>textStyle</B></I>
193
Class:          <B>TextStyle</B></I>
194
Switch:         <B>-style</B></I>
195
</code></code></code></pre>
196
<UL>
197
Specifies the display style to use for this text item. Must be the
198
name of a <B>text</B></I> display style that has already be created by the
199
<B>tixDisplayStyle(n)</B></I> command.
200
</UL>
201
<P>
202
<pre><code><code><code>
203
Name:           <B>text</B></I>
204
Class:          <B>Text</B></I>
205
Switch:         <B>-text</B></I>
206
</code></code></code></pre>
207
<UL>
208
Specifies the text string to display in the item.
209
</UL>
210
<P>
211
<pre><code><code><code>
212
Name:           <B>underline</B></I>
213
Class:          <B>Underline</B></I>
214
Switch:         <B>-underline</B></I>
215
</code></code></code></pre>
216
<UL>
217
Specifies the integer index of a character to underline in the item.
218
 
219
widget, 1 to the next character, and so on.
220
</UL>
221
</UL>
222
<B>STYLE OPTIONS</B></I>
223
<P>
224
<UL>
225
<P>
226
<B>STANDARD OPTIONS</B></I>
227
<P>
228
\fC
229
<pre><code><code><code>
230
activeBackground        activeForeground
231
anchor                  background
232
disabledBackground      disabledForeground
233
foreground              font
234
justify                 padX
235
padY                    selectBackground
236
selectForeground        wrapLength
237
</code></code></code></pre>
238
</B></I>
239
<P>
240
See the <B>options(n)</B></I> manual entry for details on the standard
241
options.
242
<P>
243
</UL>
244
</pre><H3>WINDOW ITEMS</H3>
245
Display items of the type <B>window</B></I> are used to display a
246
sub-window in a widget. <B>Window</B></I> items support the following
247
options:
248
<P>
249
<B>ITEM OPTIONS</B></I>
250
<P>
251
<UL>
252
<P>
253
<pre><code><code><code>
254
Name:           <B>windowStyle</B></I>
255
Class:          <B>WindowStyle</B></I>
256
Switch:         <B>-style</B></I>
257
</code></code></code></pre>
258
<UL>
259
Specifies the display style to use for this window item. Must be the
260
name of a <B>window</B></I> display style that has already be created by
261
the <B>tixDisplayStyle(n)</B></I> command.
262
</UL>
263
<P>
264
<pre><code><code><code>
265
Name:           <B>window</B></I>
266
Class:          <B>Window</B></I>
267
Switch:         <B>-window</B></I>
268
Alias:          <B>-widget</B></I>
269
</code></code></code></pre>
270
<UL>
271
Specifies the sub-window to display in the item.
272
</UL>
273
</UL>
274
<B>STYLE OPTIONS</B></I>
275
<P>
276
<UL>
277
<B>STANDARD OPTIONS</B></I>
278
<P>
279
\fC
280
<pre><code><code><code>
281
anchor
282
padX            padY
283
<P>
284
</code></code></code></pre>
285
See the <B>options(n)</B></I> manual entry for details on the standard
286
options.
287
<P>
288
</UL>
289
</pre><H3>CREATING DISPLAY ITEMS</H3>
290
Display items do not exist on their and thus they cannot be created
291
independently of the widgets they reside in. As a rule, display items
292
are created by special widget commands of their "host" widgets. For
293
example, the HList widgets has a command <B>item</B></I> which can be used
294
to create new display items. The following code creates a new imagetext
295
item at the third column of the entry foo inside an HList widget:
296
<P>
297
\fC
298
<pre><code><code><code>
299
 tixHList .h -columns 3
300
 .h add foo
301
 .h item create foo 2 -itemtype imagetext -text Hello -image image1
302
</code></code></code></pre>
303
<P>
304
</B></I>
305
The <B>item create</B></I> command of the HList widget accepts a variable
306
number of arguments. The special argument <B>-itemtype</B></I> specifies
307
which type of display item to create. Options that are valid for this
308
type of display items can then be specified by one or more
309
<I>option-value</I></B> pairs.
310
<P>
311
After the display item is created, they can then be configured or
312
destroyed using the commands provided by the host widget. For example,
313
the HList widget has the command <B>item configure</B></I>, <B>item cget</B></I>
314
and <B>item delete</B></I> for accessing the display items.
315
</pre><H3>CREATING AND MANIPULATING DISPLAY STYLES</H3>
316
Display styles are created by the command <B>tixDisplayStyle</B></I>:
317
</pre><H3>SYNOPSIS</H3>
318
<B>tixDisplayStyle<I> <I>itemType</I></B> ?<I>-stylename name</I></B>? ?<I>-refwindow pathName</I></B>? ?<I>options value ...</I></B>?
319
<P>
320
<I>itemType</I></B> must be one of the existing display items types such as
321
<B>text</B></I>, <B>imagetext</B></I>, <B>window</B></I> or any new types added by
322
the user. Additional arguments can be given in one or more
323
<I>option-value</I></B> pairs. <I>option</I></B> can be any of the valid option
324
for this display style or any of the following:
325
<P>
326
<UL>
327
<DL>
328
<DT> <B>-stylename <I>name</I></B>
329
</I></B>
330
<DD> Specifies a name for this style. If unspecified, then a default name
331
will be chosen for this style.
332
</DL>
333
<DL>
334
<DT> <B>-refwindow <I>pathName</I></B>
335
</I></B>
336
<DD> Specifies a window to use for determine the default values of the
337
display type. If unspecified, the main window will be used. Default
338
values for the display types can be set via the options database. The
339
following example sets the <B>-disablebackground</B></I> and
340
<B>-disabledforeground</B></I> options of a <B>text</B></I> display style via
341
the option database:
342
\fC
343
</DL>
344
<pre><code><code><code>
345
option add *table.list*disabledForeground blue
346
option add *table.list*disabledBackground darkgray
347
tixDisplayStyle text -refwindow .table.list -fg red
348
</code></code></code></pre>
349
</B></I>
350
By using the option database to set the options of the display styles,
351
we can advoid hard-coding the option values and give the user more
352
flexibility in customization. See option(n) for a detailed description
353
of the option database.
354
</pre><H3>STYLE COMMAND</H3>
355
<P>
356
The <B>tixDisplayStyle</B></I> command creates a new Tcl command whose name is the
357
same as the name of the newly created display style.  This command
358
may be used to invoke various operations on the display style.  It has the
359
following general form:
360
<pre>
361
<I>styleName option </I></B>?<I>arg arg ...</I></B>?
362
<P>
363
</pre>
364
<I>styleName</I></B> is the name of the command. <I>Option</I></B> and the
365
<I>arg</I></B>s determine the exact behavior of the command. The following
366
commands are possible:
367
<DL>
368
<DT> <I>styleName <B>cget</B></I> <I>option</I></B>
369
</I></B>
370
<DD> Returns the current value of the configuration option given by
371
<I>option</I></B>. <I>Option</I></B> may have any of the valid options of this
372
display style.
373
</DL>
374
<DL>
375
<DT> <I>styleName <B>configure</B></I> ?<I>option</I></B>? <I>?value option value ...</I></B>?
376
</I></B>
377
<DD> Query or modify the configuration options of the display style.  If no
378
<I>option</I></B> is specified, returns a list describing all of the
379
available options for <I>styleName</I></B> (see <B>Tk_ConfigureInfo</B></I> for
380
information on the format of this list). If <I>option</I></B> is specified
381
with no <I>value</I></B>, then the command returns a list describing the
382
one named option (this list will be identical to the corresponding
383
sublist of the value returned if no <I>option</I></B> is specified).  If
384
one or more <I>option-value</I></B> pairs are specified, then the command
385
modifies the given option(s) to have the given value(s); in this case
386
the command returns an empty string. <I>Option</I></B> may have any of the
387
valid options of this display style.
388
</DL>
389
<DL>
390
<DT> <I>styleName <B>delete</B></I>
391
</I></B>
392
<DD> Destroy this display style object.
393
</DL>
394
</pre><H3>EXAMPLE</H3>
395
The following example creates two columns of data in a HList
396
widget. The first column is in red and the second column in blue. The
397
colors of the columns are controlled by two different <B>text</B></I>
398
styles. Also, the anchor and font of the second column is chosen so
399
that the income data is aligned properly.
400
<P>
401
\fC
402
<pre><code><code><code>
403
set courier -*-courier-medium-r-*-*-14-*-*-*-*-*-*-*
404
tixHList .h -columns 2; pack .h
405
set red  [tixDisplayStyle text -fg #800000]
406
set blue [tixDisplayStyle text -fg #000080 -anchor e -font $courier]
407
 
408
foreach n {{Joe $10,000} {Peter $20,000} {Raj $90,000} {Zinh $0}} {
409
    set entry [.h addchild {}]
410
    .h item create $entry 0 -itemtype text \\
411
        -text [lindex $n 0] -style $red
412
    .h item create $entry 1 -itemtype text \\
413
        -text [lindex $n 1] -style $blue
414
}
415
</code></code></code></pre>
416
<P>
417
</B></I>
418
 
419
<hr><i>Last modified Sun Jan 19 22:34:21 EST 1997 </i> ---
420
<i>Serial 853731297</i>

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.