28
28
for command line options and arguments. All applications written with the
29
29
X Toolkit Intrinsics automatically accept the following options: ...".
30
30
This module processes these command line options for perl/Tk applications
31
using the C<SetArguments> function.
31
using the C<SetArguments>() function.
33
33
This module can optionally be used to load initial resources explicitly via
34
function C<SetResources>, or from specified files (default: the standard X11
35
application-specific resource files) via function C<LoadResources>.
34
function C<SetResources>(), or from specified files (default: the standard X11
35
application-specific resource files) via function C<LoadResources>().
37
37
=head2 Command Line Options
134
134
=item System Application Defaults Files
136
136
System application defaults files may be specified via environment variable
137
$C<XFILESEARCHPATH> which, if set, contains a colon-separated list of file
137
$C<XFILESEARCHPATH> which, if set, contains a list of file patterns
138
(joined using the OS-dependent path delimiter, e.g. colon on B<UNIX>).
140
140
=item User Application Defaults Files
163
163
By default, command line options are extracted from @ARGV the first time
164
164
a MainWindow is created. The Tk::MainWindow constructor indirectly invokes
165
C<SetArguments> to do this.
169
Get the value of a configuration option specified via C<SetArguments>.
170
(C<cget> first invokes C<SetArguments> if it has not already been invoked.)
165
C<SetArguments>() to do this.
167
=item B<GetArguments> - Tk::CmdLine::GetArguments()
169
Get a list of the X11 options that have been processed by C<SetArguments>().
170
(C<GetArguments>() first invokes C<SetArguments>() if it has not already been invoked.)
172
=item B<cget> - Tk::CmdLine::cget([$option])
174
Get the value of a configuration option specified via C<SetArguments>().
175
(C<cget>() first invokes C<SetArguments>() if it has not already been invoked.)
172
177
Tk::CmdLine::cget([$option])
174
179
The valid options are: B<-class>, B<-name>, B<-screen> and B<-title>.
175
180
If no option is specified, B<-class> is implied.
177
A typical use of C<cget> might be to obtain the application class in order
178
to define the name of a resource file to be loaded in via C<LoadResources>.
182
A typical use of C<cget>() might be to obtain the application class in order
183
to define the name of a resource file to be loaded in via C<LoadResources>().
180
185
my $class = Tk::CmdLine::cget(); # process command line and return class
182
=item B<SetResources>
187
=item B<SetResources> - Tk::CmdLine::SetResources((\@resource | $resource) [, $priority])
184
189
Set the initial resources.
193
198
as defined in L<option|Tk::option>, to be associated with the resources
194
199
(default: I<userDefault>).
196
Note that C<SetResources> first invokes C<SetArguments> if it has not already
201
Note that C<SetResources>() first invokes C<SetArguments>() if it has not already
199
=item B<LoadResources>
204
=item B<LoadResources> - Tk::CmdLine::LoadResources([%options])
201
206
Load initial resources from one or more files.
207
212
[ -echo => $fileHandle ] );
209
214
[ B<-symbol> =E<gt> $symbol ] specifies the name of an environment variable
210
that, if set, defines a colon-separated list of one or more directories and/or
211
file patterns. $C<XUSERFILESEARCHPATH> is a special case.
215
that, if set, defines a list of one or more directories and/or file patterns
216
(joined using the OS-dependent path delimiter, e.g. colon on B<UNIX>).
217
$C<XUSERFILESEARCHPATH> is a special case.
212
218
If $C<XUSERFILESEARCHPATH> is not set, $C<XAPPLRESDIR> is checked instead.
213
219
If $C<XAPPLRESDIR> is not set, $C<HOME> is checked instead.
236
242
printed to the corresponding FileHandle (default: \*STDOUT) everytime a file
237
243
is examined / loaded.
239
If no B<-symbol> or B<-file> options are specified, C<LoadResources>
245
If no B<-symbol> or B<-file> options are specified, C<LoadResources>()
240
246
processes symbol $C<XFILESEARCHPATH> with priority I<startupFile> and
241
247
$C<XUSERFILESEARCHPATH> with priority I<userDefault>.
242
248
(Note that $C<XFILESEARCHPATH> and $C<XUSERFILESEARCHPATH> are supposed to
243
249
contain only patterns. $C<XAPPLRESDIR> and $C<HOME> are supposed to be a single
244
directory. C<LoadResources> does not check/care whether this is the case.)
250
directory. C<LoadResources>() does not check/care whether this is the case.)
246
For each set of FileSpecs, C<LoadResources> examines each FileSpec to
252
For each set of FileSpecs, C<LoadResources>() examines each FileSpec to
247
253
determine if the file exists and is readable. The first file that meets this
248
criteria is read in and C<SetResources> is invoked.
254
criteria is read in and C<SetResources>() is invoked.
250
Note that C<LoadResources> first invokes C<SetArguments> if it has not already
256
Note that C<LoadResources>() first invokes C<SetArguments>() if it has not already
257
263
This module is an object-oriented module whose methods can be invoked as object
258
264
methods, class methods or regular functions. This is accomplished via an
259
265
internally-maintained object reference which is created as necessary, and which
260
always points to the last object used. C<SetArguments>, C<SetResources> and
261
C<LoadResources> return the object reference.
266
always points to the last object used. C<SetArguments>(), C<SetResources>() and
267
C<LoadResources>() return the object reference.
281
287
@ARGV is processed by Tk::CmdLine before MainWindow creation.
282
288
An @ARGV of (--geometry=100x100 -opt1 a b c -bg red)
283
is equal to (-opt1 a b c) after C<SetArguments> is invoked.
289
is equal to (-opt1 a b c) after C<SetArguments>() is invoked.
389
395
=item B<XFILESEARCHPATH> (optional)
391
Colon-separated list of FileSpec patterns used in defining
392
system application defaults files.
397
List of FileSpec patterns
398
(joined using the OS-dependent path delimiter, e.g. colon on B<UNIX>)
399
used in defining system application defaults files.
394
401
=item B<XUSERFILESEARCHPATH> (optional)
396
Colon-separated list of FileSpec patterns used in defining
397
user application defaults files.
403
List of FileSpec patterns
404
(joined using the OS-dependent path delimiter, e.g. colon on B<UNIX>)
405
used in defining user application defaults files.
399
407
=item B<XAPPLRESDIR> (optional)
424
432
(previously the X11 options could not be specified in POSIX format and had to be
425
433
at the beginning of the array).
427
Added the C<SetResources> and C<LoadResources> functions to allow the definition
435
Added the C<SetResources>() and C<LoadResources>() functions to allow the definition
428
436
of resources prior to MainWindow creation.
440
2000.08.31 Ben Pavon E<lt>ben.pavon@hsc.hac.comE<gt>
442
Added the C<GetArguments>() method which returns the list of arguments that
443
have been processed by C<SetArguments>().
445
Modified C<LoadResources>() to split the symbols using the OS-dependent
446
path delimiter defined in the B<Config> module.
448
Modified C<LoadResources>() to eliminate a warning message when processing
449
patterns B<%l>, B<%C>, B<%S>.