| 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 "OPTION 1" |
| 132 | .TH OPTION 1 "2000-12-30" "perl v5.8.0" "User Contributed Perl Documentation" |
| 133 | .SH "NAME" |
| 134 | option \- Using the option database in Perl/Tk |
| 135 | .SH "SYNOPSIS" |
| 136 | .IX Header "SYNOPSIS" |
| 137 | \&\ \fI$widget\fR\->\fBwidgetClass\fR(\fBName\fR=>\fIname\fR, \fB\-class\fR=>\fIclass\fR); |
| 138 | .PP |
| 139 | \&\ \fI$widget\fR\->\fBPathName\fR; |
| 140 | .PP |
| 141 | \&\ \fI$widget\fR\->\fBoptionAdd\fR(\fIpattern\fR=>\fIvalue \fR ?,\fIpriority\fR?); |
| 142 | .PP |
| 143 | \&\ \fI$widget\fR\->\fBoptionClear\fR; |
| 144 | .PP |
| 145 | \&\ \fI$widget\fR\->\fBoptionGet\fR(\fIname, class\fR); |
| 146 | .PP |
| 147 | \&\ \fI$widget\fR\->\fBoptionReadfile\fR(\fIfileName\fR ?,\fIpriority\fR?); |
| 148 | .SH "DESCRIPTION" |
| 149 | .IX Header "DESCRIPTION" |
| 150 | The option database (also known as the \fIresource database\fR or the |
| 151 | \&\fIapplication defaults database\fR) is a set of rules for applying |
| 152 | default options to widgets. Users and system administrators can |
| 153 | set up these rules to customize the appearance of applications |
| 154 | without changing any application code; for example, a user might |
| 155 | set up personal foreground and background colors, or a site |
| 156 | might use fonts associated with visual or language preferences. |
| 157 | Different window managers (and implementations of them) have implemented |
| 158 | the database differently, but most Xt-based window managers use the |
| 159 | \&\fI.Xdefaults\fR file or the \fIxrdb\fR utility to manage user preferences; |
| 160 | some use both, and/or implement a more complex set of site, user and |
| 161 | application databases. Check your site documentation for these topics |
| 162 | or your window manager's \fB\s-1RESOURCE_MANAGER\s0\fR property. |
| 163 | .Sh "Being a good citizen" |
| 164 | .IX Subsection "Being a good citizen" |
| 165 | For most applications, the option database \*(L"just works.\*(R" The \fBoption...\fR |
| 166 | methods are for applications that need to do something unusual, such as |
| 167 | add new rules or test an option's default. Even in such cases, the |
| 168 | application should provide for user preferences. |
| 169 | Do not hardcode widget options without a \fBvery\fR good reason. |
| 170 | All users have their own tastes and they are all different. |
| 171 | They choose a special font in a special size and have often spend a |
| 172 | lot of time working out a color scheme that they will love until death. |
| 173 | When you respect their choices they will enjoy working with your |
| 174 | applications much more. Don't destroy the common look and feel of a |
| 175 | personal desktop. |
| 176 | .Sh "Option rules and widget identification" |
| 177 | .IX Subsection "Option rules and widget identification" |
| 178 | All widgets in an application are identified hierarchically by \fIpathname\fR, |
| 179 | starting from the \fBMainWindow\fR and passing through each widget used to create |
| 180 | the endpoint. The path elements are \fIwidget names\fR, much like the elements |
| 181 | of a file path from the root directory to a file. The rules in the option |
| 182 | database are patterns that are matched against a widget's \fIpathname\fR to |
| 183 | determine which defaults apply. |
| 184 | When a widget is created, the \fBName\fR option can be |
| 185 | used to assign the widget's name and thus create a distinctive path |
| 186 | for widgets in an application. If the \fBName\fR option isn't given, |
| 187 | Perl/Tk assigns a default name based on the type of widget; a |
| 188 | \&\fBMainWindow\fR's default name is the \fBappname\fR. These defaults are fine |
| 189 | for most widgets, so don't feel you need to find a meaningful name for |
| 190 | every widget you create. |
| 191 | A widget must have a distinctive name to allow users to tailor its |
| 192 | options independently of other widgets in an application. For instance, |
| 193 | to create a \fBText\fR widget that will |
| 194 | have special options assigned to it, give it a name such as: |
| 195 | .PP |
| 196 | .Vb 1 |
| 197 | \& $text = $mw->Text(Name => 'importantText'); |
| 198 | .Ve |
| 199 | .PP |
| 200 | You can then tailor the widget's attributes with a rule in the option |
| 201 | database such as: |
| 202 | .PP |
| 203 | .Vb 1 |
| 204 | \& *importantText*foreground: red |
| 205 | .Ve |
| 206 | .PP |
| 207 | The \fIclass\fR attribute identifies groups of widgets, usually within an |
| 208 | application but also to group similar widgets among different applications. |
| 209 | One typically assigns a class to a \fBTopLevel\fR or \fBFrame\fR so that the |
| 210 | class will apply to all of that widget's children. To extend the example, |
| 211 | we could be more specific about the importantText widget |
| 212 | by giving its frame a class: |
| 213 | .PP |
| 214 | .Vb 2 |
| 215 | \& $frame = $mw->Frame(-class => 'Urgent'); |
| 216 | \& $text = $frame->Text(Name => 'importantText'); |
| 217 | .Ve |
| 218 | .PP |
| 219 | Then the resource pattern can be specified as so: |
| 220 | .PP |
| 221 | .Vb 1 |
| 222 | \& *Urgent*importantText*foreground: red |
| 223 | .Ve |
| 224 | .PP |
| 225 | Similarly, the pattern \f(CW\*(C`*Urgent*background: cyan\*(C'\fR would apply to all |
| 226 | widgets in the frame. |
| 227 | .SH "METHODS" |
| 228 | .IX Header "METHODS" |
| 229 | .IP "\fI$widget\fR\->\fBwidgetClass\fR(\fBName\fR=>\fIname\fR, \fB\-class\fR=>\fIclass\fR);" 4 |
| 230 | .IX Item "$widget->widgetClass(Name=>name, -class=>class);" |
| 231 | Identify a new widget with \fIname\fR and/or \fIclass\fR. |
| 232 | \&\fBName\fR specifies the path element for the widget; names generally begin with a |
| 233 | lowercase letter. \fB\-class\fR specifies the class for the widget and its |
| 234 | children; classes generally begin with an uppercase letter. |
| 235 | If not specified, Perl/Tk will assign a unique default name to each widget. |
| 236 | Only \fBMainWindow\fR widgets have a default class, made by uppercasing the |
| 237 | first letter of the application name. |
| 238 | .IP "\fI$widget\fR\->\fBPathName\fR;" 4 |
| 239 | .IX Item "$widget->PathName;" |
| 240 | The \fBPathName\fR method returns the widget's \fIpathname\fR, which uniquely |
| 241 | identifies the widget within the application. |
| 242 | .IP "\fI$widget\fR\->\fBoptionAdd\fR(\fIpattern\fR=>\fIvalue \fR?, \fIpriority\fR?);" 4 |
| 243 | .IX Item "$widget->optionAdd(pattern=>value ?, priority?);" |
| 244 | The \fBoptionAdd\fR method adds a new option to the database. |
| 245 | \&\fIPattern\fR contains the option being specified, and consists of |
| 246 | names and/or classes separated by asterisks or dots, in the usual |
| 247 | X format. \fIValue\fR contains a text string to associate with |
| 248 | \&\fIpattern\fR; this is the value that will be returned in calls to |
| 249 | the \fBoptionGet\fR method. If \fIpriority\fR is specified, it indicates |
| 250 | the priority level for this option (see below for legal values); |
| 251 | it defaults to \fBinteractive\fR. This method always returns an empty |
| 252 | string. |
| 253 | .IP "\fI$widget\fR\->\fBoptionClear\fR;" 4 |
| 254 | .IX Item "$widget->optionClear;" |
| 255 | The \fBoptionClear\fR method clears the option database. Default |
| 256 | options (from the \fB\s-1RESOURCE_MANAGER\s0\fR property or the \fB.Xdefaults\fR |
| 257 | file) will be reloaded automatically the next time an option is |
| 258 | added to the database or removed from it. This method always returns |
| 259 | an empty string. |
| 260 | .IP "\fI$widget\fR\->\fBoptionGet\fR(\fIname,class\fR);" 4 |
| 261 | .IX Item "$widget->optionGet(name,class);" |
| 262 | The \fBoptionGet\fR method returns the value of the option specified for |
| 263 | \&\fI$widget\fR under \fIname\fR and \fIclass\fR. To look up the option, |
| 264 | \&\fBoptionGet\fR matches the patterns in the resource database against |
| 265 | \&\fI$widget\fR's \fIpathname\fR along with the class of \fI$widget\fR |
| 266 | (or its parent if \fI$widget\fR has no class specified). The widget's |
| 267 | class and name are options set when the widget is created (not |
| 268 | related to class in the sense of bless); the \fBMainWindow\fR's name |
| 269 | is the \fBappname\fR and its class is (by default) derived from the name |
| 270 | of the script. |
| 271 | .Sp |
| 272 | If several entries in the option database match \fI$widget\fR's \fIpathname\fR, |
| 273 | \&\fIname\fR, and \fIclass\fR, then the method returns whichever was created with |
| 274 | highest \fIpriority\fR level. If there are several matching |
| 275 | entries at the same priority level, then it returns whichever entry |
| 276 | was \fImost recently entered\fR into the option database. If there are |
| 277 | no matching entries, then the empty string is returned. |
| 278 | .IP "\fI$widget\fR\->\fBoptionReadfile\fR(\fIfileName\fR?,\fIpriority\fR?);" 4 |
| 279 | .IX Item "$widget->optionReadfile(fileName?,priority?);" |
| 280 | The \fBoptionReadfile\fR method reads \fIfileName\fR, which should have the |
| 281 | standard format for an X resource database such as \fB.Xdefaults\fR, and |
| 282 | adds all the options specified in that file to the option database. |
| 283 | If \fIpriority\fR is specified, it indicates the priority level at which |
| 284 | to enter the options; \fIpriority\fR defaults to \fBinteractive\fR. |
| 285 | .Sp |
| 286 | The \fIpriority\fR arguments to the \fBoption\fR methods are |
| 287 | normally specified symbolically using one of the following values: |
| 288 | .RS 4 |
| 289 | .IP "\fBwidgetDefault\fR" 8 |
| 290 | .IX Item "widgetDefault" |
| 291 | Level 20. Used for default values hard-coded into widgets. |
| 292 | .IP "\fBstartupFile\fR" 8 |
| 293 | .IX Item "startupFile" |
| 294 | Level 40. Used for options specified in application-specific |
| 295 | startup files. |
| 296 | .IP "\fBuserDefault\fR" 8 |
| 297 | .IX Item "userDefault" |
| 298 | Level 60. Used for options specified in user-specific defaults |
| 299 | files, such as \fB.Xdefaults\fR, resource databases loaded into |
| 300 | the X server, or user-specific startup files. |
| 301 | .IP "\fBinteractive\fR" 8 |
| 302 | .IX Item "interactive" |
| 303 | Level 80. Used for options specified interactively after the application |
| 304 | starts running. If \fIpriority\fR isn't specified, it defaults to |
| 305 | this level. |
| 306 | .RE |
| 307 | .RS 4 |
| 308 | .Sp |
| 309 | Any of the above keywords may be abbreviated. In addition, priorities |
| 310 | may be specified numerically using integers between 0 and 100, |
| 311 | inclusive. The numeric form is probably a bad idea except for new priority |
| 312 | levels other than the ones given above. |
| 313 | .RE |
| 314 | .SH "BUGS" |
| 315 | .IX Header "BUGS" |
| 316 | The priority scheme used by core Tk is not the same as used by normal Xlib |
| 317 | routines. In particular is assumes that the order of the entries is defined, |
| 318 | but user commands like \fBxrdb \-merge\fR can change the order. |
| 319 | .SH "SEE ALSO" |
| 320 | .IX Header "SEE ALSO" |
| 321 | Tk::Xrm |
| 322 | .SH "KEYWORDS" |
| 323 | .IX Header "KEYWORDS" |
| 324 | database, option, priority, retrieve |