summaryrefslogtreecommitdiffstats
path: root/kjsembed/docs/examples/customwidget/custom_widget.js
blob: c9df7f297788352bbd545e8203caa21a5ec12da6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env kjscmd

//
// Script demonstrating how to create a custom widget.
//

function createField( parent )
{
    var hbox = new TQHBox( box, 'hb' );

    var label = new TQLabel( hbox );
    label.text = 'Filename:';
    var ed = new TQLineEdit( hbox, 'lineed' );
    ed.text = './my_file.txt';
    var pb = new TQPushButton( hbox, 'button' );
    pb.text = 'Br&owse';
    var led = new KLed( hbox, 'led' );
}

function createGroup( parent )
{
    var grp = new TQGroupBox( box, 'grp' );
    grp.columns = 1;
    grp.title = 'A TQGroupBox';
	
    var cb1 = new TQCheckBox( grp, 'check1' );
    var cb2 = new TQCheckBox( grp, 'check2' );
    cb1.text = 'Check Box One';
    cb2.text = 'Check Box Two';

    return grp;
}

// Outer layout
var box = new TQVBox();
box.margin = 6;

// Title
var ttl = new TQLabel( box, 'title' );
ttl.text = '<qt><center><h3>KJSEmbed Object Creation Demo</h3></center><hr></qt>';

// Named field
createField( box );

// Text editor
var l = new TQLabel( box, 'tl' );
l.txt = 'Editable Text Widget:';
var txt = new TQTextEdit( box, 'text_edit' );
txt.text = '<qt>This is an editable text widget created from <i>Javascript</i> using the '
         + '<b>KJSEmbed</b> library. As you can see, the facilities are powerful enough '
         + 'for many useful applications to be found.</qt>';

// Group of check boxes
var grp = createGroup( box );

box.show();
application.exec();