summaryrefslogtreecommitdiffstats
path: root/kjsembed/docs/examples/customwidget/custom_widget.js
blob: dbab2d8f342795d28d6dcbf7fc678cec5f3366c8 (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 QHBox( box, 'hb' );

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

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

    return grp;
}

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

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

// Named field
createField( box );

// Text editor
var l = new QLabel( box, 'tl' );
l.txt = 'Editable Text Widget:';
var txt = new QTextEdit( 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();