
Rebuilding the Demo Host Software
A-14
The following code creates the "Connection" frame inside the current
widget, and adds the first two elements—the text and field in the first row.
Some formatting statements have been omitted to simplify this example.
WID( widgets.Group( $w, SWT.NONE ) );
$w.setText( "Connection" ); // $w = current widget
var gl = layout.GridLayout( 2, false );
$w.setLayout( gl );
WID( widgets.Label( $w, SWT.NONE ) );
$w.setText( " Status" );
END();
w["txtStatus"] = WID( widgets.Text( $w, SWT.BORDER | SWT.CENTER |
SWT.READ_ONLY ) );
$w.setLayoutData( GD( 164, SWT.DEFAULT ) );
END();
This code creates the "Connection" group, sets its label text
appropriately, and gives it a grid layout of 2 columns per row. The function
that creates a new layout is GridLayout( <#columns>, <make cols equal
width> ).
All widgets, when created, as a first argument take the reference of the
containing widget. With our macro-like functions, it is always "$w". The
second argument to a widget usually defines some attribute(s), such as
whether it has a border or how is its text justified.
We then add a label, "Status", and create a text box to contain the
connection status. The connection status text could be placed in another
label like "Status", because we can change the text of any widget
dynamically, but we use a text box for an aesthetic effect. We make the
textbox have a border, have its text center-aligned, and be read only; we
also record its reference in myWidgets["txtStatus"], where "w" is a short
alias for "myWidgets". In the next line, we say that the grid cell where the
text box is should be 164 pixels wide and have the default height
(determined by the textbox's font and font size).
To learn which widgets are available and which properties they have, see
the following web page. This site has a picture of each widget, its API
syntax, and an example code snippet.
http://www.eclipse.org/swt/widgets
Содержание TMS320DM6437
Страница 1: ...TMS320DM6437 DVDP Getting Started Guide Literature Number SPRUEV6 July 2007 ...
Страница 20: ...2 8 ...
Страница 34: ...3 14 ...
Страница 40: ...4 6 ...
Страница 63: ......
Страница 64: ...Spectrum Digital Inc 509108 0001B ...