Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / man / man3 / Tk::mega.3
CommitLineData
86530b38
AT
1.\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13
2.\"
3.\" Standard preamble:
4.\" ========================================================================
5.de Sh \" Subsection heading
6.br
7.if t .Sp
8.ne 5
9.PP
10\fB\\$1\fR
11.PP
12..
13.de Sp \" Vertical space (when we can't use .PP)
14.if t .sp .5v
15.if n .sp
16..
17.de Vb \" Begin verbatim text
18.ft CW
19.nf
20.ne \\$1
21..
22.de Ve \" End verbatim text
23.ft R
24.fi
25..
26.\" Set up some character translations and predefined strings. \*(-- will
27.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28.\" double quote, and \*(R" will give a right double quote. | will give a
29.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
30.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
31.\" expand to `' in nroff, nothing in troff, for use with C<>.
32.tr \(*W-|\(bv\*(Tr
33.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34.ie n \{\
35. ds -- \(*W-
36. ds PI pi
37. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
39. ds L" ""
40. ds R" ""
41. ds C` ""
42. ds C' ""
43'br\}
44.el\{\
45. ds -- \|\(em\|
46. ds PI \(*p
47. ds L" ``
48. ds R" ''
49'br\}
50.\"
51.\" If the F register is turned on, we'll generate index entries on stderr for
52.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53.\" entries marked with X<> in POD. Of course, you'll have to process the
54.\" output yourself in some meaningful fashion.
55.if \nF \{\
56. de IX
57. tm Index:\\$1\t\\n%\t"\\$2"
58..
59. nr % 0
60. rr F
61.\}
62.\"
63.\" For nroff, turn off justification. Always turn off hyphenation; it makes
64.\" way too many mistakes in technical documents.
65.hy 0
66.if n .na
67.\"
68.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69.\" Fear. Run. Save yourself. No user-serviceable parts.
70. \" fudge factors for nroff and troff
71.if n \{\
72. ds #H 0
73. ds #V .8m
74. ds #F .3m
75. ds #[ \f1
76. ds #] \fP
77.\}
78.if t \{\
79. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80. ds #V .6m
81. ds #F 0
82. ds #[ \&
83. ds #] \&
84.\}
85. \" simple accents for nroff and troff
86.if n \{\
87. ds ' \&
88. ds ` \&
89. ds ^ \&
90. ds , \&
91. ds ~ ~
92. ds /
93.\}
94.if t \{\
95. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101.\}
102. \" troff and (daisy-wheel) nroff accents
103.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110.ds ae a\h'-(\w'a'u*4/10)'e
111.ds Ae A\h'-(\w'A'u*4/10)'E
112. \" corrections for vroff
113.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115. \" for low resolution devices (crt and lpr)
116.if \n(.H>23 .if \n(.V>19 \
117\{\
118. ds : e
119. ds 8 ss
120. ds o a
121. ds d- d\h'-1'\(ga
122. ds D- D\h'-1'\(hy
123. ds th \o'bp'
124. ds Th \o'LP'
125. ds ae ae
126. ds Ae AE
127.\}
128.rm #[ #] #H #V #F C
129.\" ========================================================================
130.\"
131.IX Title "MEGA 1"
132.TH MEGA 1 "2000-12-30" "perl v5.8.0" "User Contributed Perl Documentation"
133.SH "NAME"
134Tk::mega \- perl/Tk support to write widgets in perl
135.SH "SYNOPSIS"
136.IX Header "SYNOPSIS"
137\&\ \fBpackage Tk::\fR\fIWhatever\fR;
138.PP
139\&\ \fBConstruct Tk::\fR\fIValidFor\fR \fI'Whatever'\fR;
140.PP
141\&\ \fBsub ClassInit\fR { \fImy ($mega, \f(CI$args\fI) = \f(CI@_\fI; ...\fR }
142.PP
143For composite widget classes:
144.PP
145\&\ \fBsub Populate\fR { \fImy ($composite, \f(CI$args\fI) = \f(CI@_\fI; ...\fR }
146.PP
147For derived widget classes:
148.PP
149\&\ \fBsub InitObject\fR { \fImy ($derived, \f(CI$args\fI) = \f(CI@_\fI; ...\fR }
150.SH "DESCRIPTION"
151.IX Header "DESCRIPTION"
152The goal of the mega widget support of perl/Tk is to make it
153easy to write mega widgets that obey the same protocol and
154interface that the Tk core widgets support. There are two
155kinds of mega widgets:
156.IP "\(bu Composite Widgets" 4
157.IX Item "Composite Widgets"
158A composite widget is composed with one or more existing widgets.
159The composite widget looks to the user like a simple single widget.
160A well known example is the file selection box.
161.IP "\(bu Derived Widgets" 4
162.IX Item "Derived Widgets"
163A derived widget adds/modifies/removes properties and methods
164from a single widget (this widget may itself be a mega widget).
165.SH "MEGA WIDGET SUPPORT"
166.IX Header "MEGA WIDGET SUPPORT"
167.Sh "Advertise"
168.IX Subsection "Advertise"
169Give a subwidget a symbolic name.
170.PP
171Usage:
172.PP
173\&\ \fI$cw\fR\->\fBAdvertise\fR(\fBname\fR=>\fI$widget\fR);
174.PP
175Gives a subwidget \fI$widget\fR of the composite widget \fI$cw\fR the
176name \fBname\fR. One can retrieve the reference of an advertised subwidget
177with the Subwidget method.
178.PP
179\&\fBComment:\fR Mega Widget Writers: Please make sure to document the
180advertised widgets that are intended for \fIpublic\fR use.
181If there are none, document this fact, e.g.:
182.PP
183.Vb 1
184\& =head1 ADVERTISED WIDGETS
185.Ve
186.PP
187.Vb 1
188\& None.
189.Ve
190.Sh "Callback"
191.IX Subsection "Callback"
192Invoke a callback specified with an option.
193.PP
194Usage:
195.PP
196\&\ \fI$mega\fR\->\fBCallback\fR(\fI\-option\fR ?,\fIargs\fR ...?);
197.PP
198\&\fBCallback\fR executes the callback defined with
199\&\fI$mega\fR\->\fBConfigSpecs\fR(\fI\-option\fR, [\fB\s-1CALLBACK\s0\fR, ...]);
200If \fIargs\fR are given they are passed to the callback. If
201\&\fI\-option\fR is not defined it does nothing.
202.Sh "ClassInit"
203.IX Subsection "ClassInit"
204Initialization of the mega widget class.
205.PP
206Usage:
207.PP
208\&\ \fBsub ClassInit\fR { \fImy ($class, \f(CI$mw\fI) = \f(CI@_\fI;\fR ... }
209.PP
210\&\fBClassInit\fR is called once for \fIeach\fR MainWindow
211just before the first widget instance of a class is created in
212the widget tree of \fBMainWindow\fR.
213.PP
214\&\fBClassInit\fR is often used to define bindings and/or other
215resources shared by all instances, e.g., images.
216.PP
217Examples:
218.PP
219.Vb 3
220\& $mw->bind($class,"<Tab>", sub { my $w = shift; $w->Insert("\et"); $w->focus; $w->break});
221\& $mw->bind($class,"<Return>", ['Insert',"\en"]);
222\& $mw->bind($class,"<Delete>",'Delete');
223.Ve
224.PP
225Notice that \fI$class\fR is the class name (e.g. \fBTk::MyText\fR) and \fI$mw\fR is the mainwindow.
226.PP
227Don't forget to call \fI$class\fR\->\fBSUPER::ClassInit($mw)\fR in
228\&\fBClassInit\fR.
229.Sh "Component"
230.IX Subsection "Component"
231Convenience function to create subwidgets.
232.PP
233Usage:
234.PP
235.Vb 4
236\& $cw->Component('Whatever', 'AdvertisedName',
237\& -delegate => ['method1', 'method2', ...],
238\& ... Whatever widget options ...,
239\& );
240.Ve
241.PP
242\&\fBComponent\fR does several things for you with one call:
243.Sp
244.RS 4
245o Creates the widget
246.Sp
247o Advertises it with a given name (overridden by 'Name' option)
248.Sp
249o Delegates a set of methods to this widget (optional)
250.RE
251.PP
252Example:
253.PP
254.Vb 1
255\& $cw->Component('Button', 'quitButton', -command => sub{$mw->'destroy'});
256.Ve
257.Sh "ConfigSpecs"
258.IX Subsection "ConfigSpecs"
259Defines options and their treatment
260.PP
261Usage:
262.PP
263.Vb 5
264\& $cw->ConfigSpecs(
265\& -option => [ where, dbname, dbclass, default],
266\& ...,
267\& DEFAULT => [where],
268\& );
269.Ve
270.PP
271Defines the options of a mega widget and what actions
272are triggered by configure/cget of an option
273(see Tk::ConfigSpecs and Tk::Derived for details).
274.Sh "Construct"
275.IX Subsection "Construct"
276Make the new mega widget known to \fBTk\fR.
277.PP
278Usage:
279.PP
280\&\ \fBConstruct\fR \fIbaseclass\fR \fB'Name'\fR;
281.PP
282\&\fBConstruct\fR declares the new widget class so that your mega widget
283works like normal Perl/Tk widgets.
284.PP
285Examples:
286.PP
287\&\ \fBConstruct Tk::Widget\fR \fI'Whatever'\fR;
288\&\ \fBConstruct Tk::Menu\fR \fI'MyItem'\fR;
289.PP
290First example lets one use \fI$widget\fR\->\fBWhatever\fR to create
291new \fBWhatever\fR widget.
292.PP
293The second example restricts the usage of the \fBMyItem\fR constructor
294method to widgets that are derived from \fBMenu\fR:
295\&\fI$isamenu\fR\->\fIMyItem\fR.
296.Sh "CreateArgs"
297.IX Subsection "CreateArgs"
298Mess with options before any widget is created
299.PP
300\&\ \fBsub CreateArgs\fR { \fImy ($package, \f(CI$parent\fI, \f(CI$args\fI) = \f(CI@_\fI; ...; return \f(CI@newargs\fI;\fR }
301.PP
302\&\fI$package\fR is the package of the mega widget (e.g., \fBTk::MyText\fR,
303\&\fI$parent\fR the parent of the widget to be created and \f(CW$args\fR the hash
304reference to the options specified in the widget constructor call.
305.PP
306Don't forget to call \fI$package\fR\->\fBSUPER::CreateArgs\fR(\fI$parent\fR, \fI$args\fR) in
307\&\fBCreateArgs\fR.
308.Sh "Delegates"
309.IX Subsection "Delegates"
310Redirect a method of the mega widget to a subwidget of
311the composite widget
312.PP
313Usage:
314.PP
315.Vb 7
316\& $cw->Delegates(
317\& 'method1' => $subwidget1,
318\& 'method2' => 'advertived_name',
319\& ...,
320\& 'Construct' => $subwidget2,
321\& 'DEFAULT' => $subwidget3,
322\& );
323.Ve
324.PP
325The \fB'Construct'\fR delegation has a special meaning. After
326\&'Construct' is delegated all Widget constructors are redirected.
327E.g. after
328.PP
329\&\ \fI$mega\fR\->\fBDelegates\fR(\fB'Construct'\fR=>\fI$subframe\fR);
330.PP
331a \fI$mega\fR\->\fBButton\fR does really a \fI$subframe\fR\->\fBButton\fR
332so the created button is a child of \fI$subframe\fR and not \fI$mega\fR.
333.PP
334\&\fBComment:\fR Delegates works only with methods that \fI$cw\fR does
335not have itself.
336.Sh "InitObject"
337.IX Subsection "InitObject"
338Defines construction and interface of derived widgets.
339.PP
340Usage:
341.PP
342.Vb 4
343\& sub InitObject {
344\& my ($derived, $args) = @_;
345\& ...
346\& }
347.Ve
348.PP
349where \fI$derived\fR is the widget reference of the already created
350baseclass widget and \fI$args\fR is the reference to a hash of
351\&\fI\-option\-value\fR pairs.
352.PP
353\&\fBInitObject\fR is almost identical to Populate method.
354\&\fBPopulate\fR does some more 'magic' things useful for mega widgets
355with several widgets.
356.PP
357Don't forget to call \fI$derived\fR\->\fBSUPER::InitObject\fR(\fI$args\fR) in
358\&\fBInitObject\fR.
359.Sh "OnDestroy"
360.IX Subsection "OnDestroy"
361Define callback invoked when widget is destroyed.
362.PP
363Usage:
364.PP
365\&\ \fI$widget\fR\->\fBOnDestroy\fR(\fIcallback\fR);
366.PP
367\&\fBOnDestroy\fR installs a callback that's called
368when a widget is going to to be destroyed. Useful
369for special cleanup actions. It differs from a normal \fBdestroy\fR
370in that all the widget's data structures are still intact.
371.PP
372\&\fBComment:\fR This method could be used with any widgets not just
373for mega widgets. It's listed here because of it's usefulness.
374.Sh "Populate"
375.IX Subsection "Populate"
376Defines construction and interface of the composite
377widget.
378.PP
379Usage:
380.PP
381.Vb 4
382\& sub Populate {
383\& my ($mega, $args) = @_;
384\& ...
385\& }
386.Ve
387.PP
388where \fI$mega\fR is the widget reference of the already created baseclass
389widget and \fI$args\fR is the
390reference to a hash of \fI\-option\-value\fR pairs.
391.PP
392Most the other support function are normally used inside the \fBPopulate\fR
393subroutine.
394.PP
395Don't forget to call \fI$cw\fR\->\fBSUPER::Populate\fR(\fI$args\fR) in
396\&\fBPopulate\fR.
397.Sh "privateData"
398.IX Subsection "privateData"
399Set/get a private hash of a widget to storage
400composite internal data
401.PP
402Usage:
403.PP
404\&\ \fI$hashref\fR = \fI$mega\fR\->\fBprivateData\fR();
405.PP
406\&\ \fI$another\fR = \fI$mega\fR\->\fBprivateData\fR(\fIunique_key\fR|\fIpackage\fR);
407.Sh "Subwidget"
408.IX Subsection "Subwidget"
409Get the widget reference of an advertised subwidget.
410.PP
411\&\ \fI$subwidget\fR = \fI$cw\fR\->\fBSubwidget\fR(\fIname\fR);
412.PP
413\&\ \fI@subwidget\fR = \fI$cw\fR\->\fBSubwidget\fR(\fIname\fR ?,...?);
414.PP
415Returns the widget reference(s) of the subwidget known under the
416name \fIname\fR. See Advertise method how to define
417\&\fIname\fR for a subwidget.
418.PP
419\&\fBComment:\fR Mega Widget Users: Use \fBSubwidget\fR to get \fIonly\fR
420documented subwidgets.
421.SH "PITFALLS"
422.IX Header "PITFALLS"
423.IP "\(bu Resource \s-1DB\s0 class name" 4
424.IX Item "Resource DB class name"
425Some of the standard options use a resource date base class
426that is not equal to the resource database name. E.g.,
427.Sp
428.Vb 1
429\& Switch: Name: Class:
430.Ve
431.Sp
432.Vb 4
433\& -padx padX Pad
434\& -activerelief activeRelief Relief
435\& -activebackground activeBackground Foreground
436\& -status undef undef
437.Ve
438.Sp
439One should do the same when one defines one of these
440options via \fBConfigSpecs\fR.
441.IP "\(bu Method delegation" 4
442.IX Item "Method delegation"
443Redirecting methods to a subwidget with \fBDelegate\fR
444can only work if the base widget itself does have a
445method with this name. Therefore one can't ``\fIdelegate\fR''
446any of the methods listed in Tk::Widget.
447A common problematic method is \fBbind\fR. In this case
448one as to explicitely redirect the method.
449.Sp
450.Vb 6
451\& sub bind
452\& {
453\& my $mega = shift;
454\& my $to = $mega->privateData->{'my_bind_target'};
455\& $to->bind(@_);
456\& }
457.Ve
458.IP "\(bu privateData" 4
459.IX Item "privateData"
460Graham Barr wrote: ... It is probably
461more private than most people think. Not all calls to privateData will
462return that same \s-1HASH\s0 reference. The \s-1HASH\s0 reference that is returned
463depends on the package it was called from, a different \s-1HASH\s0 is returned
464for each package. This allows a widget to hold private data, but then
465if it is sub-classed the sub-class will get a different \s-1HASH\s0 and so not
466cause duplicate name clashes.
467.Sp
468But privateData does take an optional argument if you want to
469force which \s-1HASH\s0 is returned.
470.IP "\(bu Scrolled and Composite" 4
471.IX Item "Scrolled and Composite"
472\&\fBScrolled\fR(\fIKind\fR,...) constructor can not be used with \fBComposite\fR.
473One has to use \f(CW$cw\fR\->\fBComposite\fR(\fBScrl\fR\fIKind\fR => \fB'name'\fR, ...);
474.SH "MISSING"
475.IX Header "MISSING"
476Of course perl/Tk does not define support function for
477all necessities. Here's a short list of things you have to
478handle yourself:
479.IP "\(bu" 4
480no support to define construction-time only options.
481.IP "\(bu" 4
482no support to remove an option that is known to the
483base widget.
484.IP "\(bu" 4
485it's hard to define \fBundef\fR as fallback for an widget
486option that is not already \fBundef\fR.
487.IP "\(bu" 4
488Frame in perl/Tk carries magic and overhead not needed
489for composite widget class definition.
490.IP "\(bu" 4
491No support methods for bindings that are shared between all
492widgets of a composite widget (makes sense at all?)
493.SH "KEYWORDS"
494.IX Header "KEYWORDS"
495mega, composite, derived, widget
496.SH "SEE ALSO"
497.IX Header "SEE ALSO"
498Tk::composite
499Tk::ConfigSpecs
500Tk::option
501Tk::callbacks
502Tk::bind