summaryrefslogtreecommitdiffstats
path: root/kate/kjswrapper/samples/katekjstest1.js
blob: a8b061b59d0028ed81fddba89fff34d45e01cbfe (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/****************************************************************
		First configuration page
****************************************************************/
function Page1 (tqparentWidget) {
		this.defaults=function() {
			alert("Defaults has been called");
		}
		this.apply=function() {
			alert("Apply has been called");
		}
		this.reset=function() {
			alert("Reset defaults has been called");
		}
		box=new QVBox(tqparentWidget);
		this.button1=new QPushButton(box);
		this.button1.text="P1 Button 1";
		this.button1.show();
		this.button2=new QPushButton(box);
		this.button2.text="P1 Button 2";
		this.button2.show();
		box.show();	
}
Page1.name="Page1"
Page1.fullName="Test1/Page1";

/****************************************************************
		Second configuration page
****************************************************************/

function Page2 (tqparentWidget) {
		box=new QVBox(tqparentWidget);
		this.button1=new QPushButton(box);
		this.button1.text="P2 Button 1";
		this.button1.show();
		this.button2=new QPushButton(box);
		this.button2.text="P2Button 2";
		this.button2.show();
		box.show();
}
Page2.name="Page2";
Page2.fullName="Test1/Page2";

/****************************************************************
		Third configuration page
****************************************************************/

function Page3 (tqparentWidget) {
		box=new QVBox(tqparentWidget);
		this.button1=new QPushButton(box);
		this.button1.text="P3 Button 1";
		this.button1.show();
		this.button2=new QPushButton(box);
		this.button2.text="P3 Button 2";
		this.button2.show();
		box.show();
}
Page3.name="Page3";
Page3.fullName="Test1/Page3";


/****************************************************************
		First toolview
****************************************************************/

function MyToolView1 (mainwindow,tqparentwidget) {
	tqparentwidget.caption="This is my first JS Toolview";
	tqparentwidget.icon=StdIcons.BarIcon("yes");

	this.lv = new KListView( tqparentwidget );

	this.lv.addColumn('Pix');
	this.lv.addColumn('One');
	this.lv.addColumn('Two');
	this.lv.addColumn('Three');

	this.lv.insertItem( StdIcons.BarIcon("no"), 'Something', "Nothing", "Thing" );
	this.lv.insertItem( StdIcons.BarIcon("no"), 'Something', "Nothing", "Thing" );
	this.lv.insertItem( StdIcons.BarIcon("no"), 'Something', "Nothing", "Thing" );
	this.lv.insertItem( StdIcons.BarIcon("no"), 'Something', "Nothing", "Thing" );

	this.changed=function() {
		alert("Item changed");
		KATE.DocumentManager.activeDocument().insertText(0,0,"TEST");
	}
	this.lv.connect(this.lv,'selectionChanged()',this,'changed');


	this.mw=mainwindow;
	this.cleanup=function() {
		alert("Cleanup MyToolView1");
	}

}
MyToolView1.startPosition=KATE.ToolView.Right;
MyToolView1.name="myfirstjstoolview"


/****************************************************************
		Second toolview
****************************************************************/

function MyToolView2 (mainwindow,tqparentwidget) {
	tqparentwidget.caption="This is my second JS Toolview";
	tqparentwidget.icon=StdIcons.BarIcon("no");

	this.lb=new QListBox(tqparentwidget);
	this.mainwindow=mainwindow;
	this.cleanup=function() {
		alert("Cleanup MyToolView2");
	}
}
MyToolView2.startPosition=KATE.ToolView.Left;
MyToolView2.name="mysecondjstoolview"



/****************************************************************
		NewWindow callback
****************************************************************/

function newWindowCallBack(mainwindow) {
	alert("New Window has been created");
/*
	anotherToolView = function  (mainwindow,tqparentwidget) {
		tqparentwidget.caption="This is my third JS Toolview";
		tqparentwidget.icon=StdIcons.BarIcon("kate");

		this.lb=new QListBox(tqparentwidget);
		this.mainwindow=mainwindow;
		this.cleanup=function() {
			alert("Cleanup MyToolView3");
		}
	}
	anotherToolView.startPosition=KATE.ToolView.Left;
	anotherToolView.name="mythirdjsoolview"
	mainwindow.createToolView(anotherToolView);*/
}

/****************************************************************
		WindowRemoved callback
****************************************************************/
function windowRemovedCallBack(mainwindow) {
	alert("Window has been removed");
}






/****************************************************************
		Initialization
****************************************************************/

cpc=new Array();
cpc.push(Page1);
cpc.push(Page2);
setConfigPages(cpc);
//setConfigPages(Page3);
//addConfigPage(Page3);

tvc=new Array();
tvc.push(MyToolView1);
tvc.push(MyToolView2);
setWindowConfiguration(tvc,newWindowCallBack,windowRemovedCallBack);
//setWindowConfiguration(MyToolView1,newWindowCallBack,windowRemovedCallBack);