Reference Guide > W Routines > WtResource Function
  

WtResource Function
Queries, creates, saves, or modifies the widget resource database.
Usage
value = WtResource([resvar])
Input Parameters
resvar(optional) A string containing a resource variable specification in the resource database.
Returned Value
value — The returned value depends on the input parameter and/or the use of keywords as shown in Returned Values.
 
Table 19-5: Returned Values
Value Returned
Parameter or Keyword Used
A string containing the value associated with resvar; a null string, if resvar isn’t found; or the default value specified.
resvar, or resvar with Default keyword
An integer value of 1 indicating success, or 0 indicating failure.
Add, Load, or Save keywords
String containing resource specification widget.
Spec keyword
Keywords
Add — A string containing a name: value resource specification to merge into the resource database in the current session. If the resource specification already exists in the application, the Add keyword takes precedence.
Default — (Used only if resvar is specified.) A string specifying a default value for the resource variable in resvar. If resvar doesn’t match anything in the resource database, this default value is returned.
Load — A string specifying the pathname of a resource file to be merged with the existing resource database. If the resource file was specified in the application, the use of the Load keyword takes precedence.
Save — A string specifying the pathname of the resource file in which to save the currently defined resources in the resource database. If the file specified already exists, the contents will be overwritten.
Spec — Used to specify a widget ID. The resource variable specification of the widget is returned.
Discussion
WtResource gives direct access to the widget resource database from PV‑WAVE Widgets and Widget Toolbox applications. Resources loaded or added using WtResource are used from then on by all subsequently created PV‑WAVE Widgets. The resource specifications merged into the resource database using either the Load or Add keywords supercede existing definitions.
 
note
Rogue Wave has ported a subset of the Widget Toolbox (Wt) functionality that is available for Motif to Microsoft Windows. Because the Widget Toolbox under Windows is not a complete implementation, we recommend that Windows developers use the PV‑WAVE Widgets (Ww) layer or the VDA Tools when developing GUI applications.
Examples
The following example shows how a resource specification added during a session takes precedence over the existing definition.
; The existing resource specification in the database.
myapp*background: red
; Add keyword changes color to blue instead. For the rest of the
; session, or until it is redefined, the background color will
; be blue.
value = WtResource(ADD='myapp*background: blue')
In the next example, the syntax for using the Load keyword is illustrated.
; This merges the resources found in the specified file with the 
; existing resource database. 
value = WtResource(LOAD='/usr/mydir/myapp/myapp.ad') 
This example shows how to request a value associated with a resource name.
; This usage returns value associated with the resource variable
; specified. The Default keyword is used to return the value 'my 
; label', if the named resource doesn't exist.
value = WtResource('myapp*mybutton.label', Default='my label')
An example for writing all defined resources to a file is:
value = WtResource(SAVE='/usr/mydir/myapp/myapp.newad')
To request the resource variable specification of a particular widget identified by its associated widget ID, use:
value = WtResource(SPEC=widget_id)
See Also
WwResource
For detailed information on GUI development, refer to the PV‑WAVE Application Developer’s Guide.
For more information about how to write an application program based on PV‑WAVE Widgets, refer to Using Wave Widgets in the PV‑WAVE Application Developer’s Guide.

Version 2017.1
Copyright © 2019, Rogue Wave Software, Inc. All Rights Reserved.