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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [itcl/] [itk/] [doc/] [Widget.n] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
'\"
2
'\" Copyright (c) 1993-1998  Lucent Technologies, Inc.
3
'\"
4
'\" See the file "license.terms" for information on usage and redistribution
5
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
6
'\"
7
'\" RCS: $Id: Widget.n,v 1.1.1.1 2002-01-16 10:24:47 markom Exp $
8
'\"
9
.so man.macros
10
.TH Widget n 3.0 itk "[incr\ Tk]"
11
.BS
12
'\" Note:  do not modify the .SH NAME line immediately below!
13
.SH NAME
14
Widget \- base class for mega-widgets within a frame
15
.SH "INHERITANCE"
16
itk::Archetype <- itk::Widget
17
.SH "STANDARD OPTIONS"
18
.LP
19
.nf
20
.ta 4c 8c 12c
21
\fBbackground\fR        \fBcursor\fR
22
.fi
23
.LP
24
See the "options" manual entry for details on the standard options.
25
.BE
26
 
27
.SH DESCRIPTION
28
.PP
29
The \fBWidget\fR class inherits everything from the \fBArchetype\fR
30
class, and adds a Tk frame called the "hull" component to represent
31
the body of the mega-widget.  The window class name for the hull
32
is set to the most-specific class name for the mega-widget.
33
The protected variable \fBitk_interior\fR contains the window
34
path name for the "hull" component.  Derived classes specialize
35
this widget by packing other widget components into the hull.
36
.PP
37
Since the hull for the \fBWidget\fR class is implemented with a
38
Tk frame, mega-widgets in the \fBWidget\fR class can be packed
39
into other frames and toplevels.
40
 
41
.SH "COMPONENTS"
42
.LP
43
.nf
44
Name:   \fBhull\fR
45
Class:  \fBFrame\fR
46
.fi
47
.IP
48
The "hull" component acts as the body for the entire mega-widget.
49
Other components are packed into the hull to further specialize
50
the widget.
51
 
52
.SH EXAMPLE
53
.PP
54
The following example implements a simple \fBTextDisplay\fR
55
mega-widget.  It creates a read-only display of text with
56
a text widget and a scrollbar.
57
.CS
58
option add *TextDisplay.wrap none widgetDefault
59
option add *TextDisplay.textBackground ivory widgetDefault
60
option add *TextDisplay.width 40 widgetDefault
61
option add *TextDisplay.height 10 widgetDefault
62
 
63
class TextDisplay {
64
    inherit itk::Widget
65
 
66
    constructor {args} {
67
        itk_component add text {
68
            text $itk_interior.info -state disabled \
69
                -yscrollcommand [code $itk_interior.sbar set]
70
        } {
71
            usual
72
            keep -tabs -wrap -width -height
73
            rename -background -textbackground textBackground Background
74
        }
75
        pack $itk_component(text) -side left -expand yes -fill both
76
 
77
        itk_component add scrollbar {
78
            scrollbar $itk_interior.sbar \
79
                -command [code $itk_interior.info yview]
80
        }
81
        pack $itk_component(scrollbar) -side right -fill y
82
 
83
        eval itk_initialize $args
84
    }
85
 
86
    public method display {info}
87
    public method append {info}
88
}
89
 
90
body TextDisplay::display {info} {
91
    $itk_component(text) configure -state normal
92
    $itk_component(text) delete 1.0 end
93
    $itk_component(text) insert 1.0 $info
94
    $itk_component(text) configure -state disabled
95
}
96
 
97
body TextDisplay::append {info} {
98
    $itk_component(text) configure -state normal
99
    $itk_component(text) insert end $info
100
    $itk_component(text) configure -state disabled
101
}
102
 
103
usual TextDisplay {
104
    keep -background -cursor -foreground -font
105
    keep -activebackground -activerelief
106
    keep -highlightcolor -highlightthickness
107
    keep -insertbackground -insertborderwidth -insertwidth
108
    keep -insertontime -insertofftime
109
    keep -selectbackground -selectborderwidth -selectforeground
110
    keep -textbackground -troughcolor
111
}
112
 
113
#
114
# EXAMPLE:  Display the /etc/passwd file
115
#
116
TextDisplay .file -background red
117
pack .file
118
 
119
\&.file display [exec cat /etc/passwd]
120
.CE
121
 
122
.SH KEYWORDS
123
itk, Archetype, Widget, mega-widget

powered by: WebSVN 2.1.0

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