summaryrefslogtreecommitdiff
path: root/mwidget/test.bmx
blob: f8d8a1906a72113d649cf73612edaea54e20841a (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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
' $Id$
Strict
Import noddybox.mwidget

Incbin "icons.png"
Incbin "toolbar.png"

Const SUBCLASS:Int=False
Const TESTTIMER:Int=False

Global top:TMWindow
Global tabs:TMTabber
Global ok:TMButton
Global cancel:TMButton

Global check:TMCheckbox

Global radio1:TMRadioButton
Global radio2:TMRadioButton
Global radio3:TMRadioButton

Global radios:TMRadioButtonSet

Global txtfield:TMTextField
Global txtarea:TMTextArea

Global list:TMListBox

Global icons:TIconStrip=LoadIconStrip("incbin::icons.png")

Global html:TMHTMLView
Global html_url:TMTextField
Global html_go:TMButton
Global html_back:TMButton
Global html_forward:TMButton

Local slider1:TMSlider
Local slider2:TMSlider

Global tree:TMTreeView

Global tree_node:TMTextField
Global tree_add:TMButton
Global tree_remove:TMButton
Global tree_count:TMButton

Global menu:TMMenu
Global popup:TMMenu

Global menu_path:TMTextField
Global menu_name:TMTextField
Global menu_add:TMButton
Global menu_remove:TMButton
Global menu_check:TMButton
Global menu_uncheck:TMButton
Global menu_enable:TMButton
Global menu_disable:TMButton
Global menu_popup:TMButton
Global menu_status:TMLabel

Global canvas:TMCanvas

Global canvas_mx:Int
Global canvas_my:Int

Global toolbar:TMToolbar

Global panel:TMPanel
Global panel_kd:TMLabel
Global panel_ku:TMLabel
Global panel_k:TMLabel
Global panel_prog:TMProgressBar
Global panel_button:TMButton


'
' CALLBACK FUNCTION VERSION
'
Function OnTimer(w:TMWidget)
	w.Text("(Callback) Test Managed Widgets -- " + CurrentTime() + " " + CurrentDate())
End Function

Function OnClose(o:TMWidget)
	Local w:TMWindow=TMWindow(o)
	w.closed=Confirm("(Callback) Really quit?")
End Function

Function OnMove(o:TMWidget, x:Int, y:Int)
	Local w:TMWindow=TMWindow(o)
	w.StatusText("(Callback) "+x+","+y)
End Function

Function OnResize(o:TMWidget, x:Int, y:Int)
	Local w:TMWindow=TMWindow(o)
	w.StatusText("(Callback) ["+x+","+y+"]")
End Function

Function OnDrop(w:TMWidget, path:String)
	Notify("Dropped~n" + path)
End Function
	
Function OnPress_OK(o:TMWidget)
	top.Close()
End Function

Function OnPress_Cancel(o:TMWidget)
	Notify("Cancel pressed -- text='" + txtfield.GetText() + "'")
End Function

Function OnPress_Check(o:TMWidget, checked:Int)
	Notify("Ticked - " + checked)
End Function

Function OnSelected_Radio(o:TMWidget, index:Int)
	Notify("Radio changed - " + index)
End Function 

Function OnTextChanged_Field(o:TMWidget, txt:String)
	top.StatusText(MilliSecs() + " -- " + txt)
End Function

Function ShowAreaStatus(o:TMWidget)
	Local t:TMTextArea=TMTextArea(o)
	Local s:String=""
	s:+"Pos: " + t.GetCursorColumn() + "," + t.GetCursorRow() + "   "
	s:+"Len: " + t.GetLength() + "   "
	s:+"[Sel: " + t.GetSelectionLength() + "," + t.GetSelectionRows() +"]"
	top.StatusText(MilliSecs() + " -- " + s)
End Function

Function OnMenu_Area(o:TMWidget)
	Notify("No menu!")
End Function

Function ShowChangedInt(o:TMWidget, val:Int)
	top.StatusText(MilliSecs() + " -- " + val)
End Function

Function OnForward(o:TMWidget)
	html.Forward()
End Function

Function OnBack(o:TMWidget)
	html.Back()
End Function

Function OnGO(o:TMWidget)
	html.Go(html_url.GetText())
End Function

Function OnPageLoaded(o:TMWidget, url:String)
	top.StatusText(MilliSecs() + " -- Loaded " + url)
End Function

Function OnSelectURL(o:TMWidget, url:String)
	html_url.Text(url)
End Function

Function OnSelected_Tree(o:TMWidget, path:String, tag:Object)
	top.StatusText(MilliSecs() + " -- Selected " + path + " (" + tag.ToString() + ")")
End Function 

Function OnClicked_Tree(o:TMWidget, path:String, tag:Object)
	top.StatusText(MilliSecs() + " -- Clicked " + path + " (" + tag.ToString() + ")")
End Function 

Function OnExpanded_Tree(o:TMWidget, path:String, tag:Object)
	top.StatusText(MilliSecs() + " -- Expanded " + path + " (" + tag.ToString() + ")")
End Function 

Function OnCollapsed_Tree(o:TMWidget, path:String, tag:Object)
	top.StatusText(MilliSecs() + " -- Collapsed " + path + " (" + tag.ToString() + ")")
End Function 

Function OnMenu_Tree(o:TMWidget, path:String, tag:Object)
	top.StatusText(MilliSecs() + " -- Menu " + path + " (" + tag.ToString() + ")")
End Function 

Function OnRedraw_Canvas(w:TMWidget)
	Local c:TMCanvas=TMCanvas(w)
	c.SetupGraphics()
	SetColor(Rand(100,200),Rand(100,200),Rand(100,200))
	DrawRect(0,0,w.Width(),w.Height())
	Flip
End Function 

Function OnMouseEnter_Canvas(w:TMWidget)
	SetPointer(POINTER_CROSS)
End Function 

Function OnMouseLeave_Canvas(w:TMWidget)
	SetPointer(POINTER_DEFAULT)
End Function 

Function OnButtonDown_Canvas(w:TMWidget, b:Int)
	Local c:TMCanvas=TMCanvas(w)
	c.SetupGraphics()
	SetColor(255,255,255)
	DrawLine(w.Width(),w.Height(),canvas_mx,canvas_my)
	Flip()
	top.StatusText(MilliSecs() + " -- Button Down " + b)
End Function 

Function OnButtonUp_Canvas(w:TMWidget, b:Int)
	Local c:TMCanvas=TMCanvas(w)
	c.SetupGraphics()
	SetColor(0,0,0)
	DrawLine(w.Width(),w.Height(),canvas_mx,canvas_my)
	Flip()
	top.StatusText(MilliSecs() + " -- Button Up " + b)
End Function 

Function OnMouseMove_Canvas(w:TMWidget, x:Int, y:Int)
	canvas_mx=x
	canvas_my=y
	top.StatusText(MilliSecs() + " -- Mouse move " + x + "," + y)
End Function 

Function OnMouseWheel_Canvas(w:TMWidget, b:Int)
	top.StatusText(MilliSecs() + " -- Mouse wheel " + b)
End Function 

Function OnKeyDown_Canvas(w:TMWidget, b:Int)
	Local c:TMCanvas=TMCanvas(w)
	SetColor(0,0,0)
	DrawRect(0,0,600,19)
	c.SetupGraphics()
	SetColor(255,255,255)
	DrawText(MilliSecs() + " -- Key down " + b,0,0)
	Flip()
End Function 

Function OnKeyUp_Canvas(w:TMWidget, b:Int)
	Local c:TMCanvas=TMCanvas(w)
	c.SetupGraphics()
	SetColor(0,0,0)
	DrawRect(0,20,600,19)
	SetColor(255,255,255)
	DrawText(MilliSecs() + " -- Key up " + b,0,20)
	Flip()
End Function 

Function OnKey_Canvas(w:TMWidget, b:Int)
	Local c:TMCanvas=TMCanvas(w)
	c.SetupGraphics()
	SetColor(0,0,0)
	DrawRect(0,40,600,19)
	SetColor(255,255,255)
	DrawText(MilliSecs() + " -- Key " + b + "(" + Chr(b) + ")",0,40)
	Flip()
End Function 

Function OnSelected_Toolbar(w:TMWidget, i:Int)
	Local tb:TMToolbar=TMToolbar(w)
	top.StatusText(MilliSecs() + " -- Toolbar " + i)
	toolbar.ItemEnabled(1,Not i=0)
End Function

Function OnButtonDown_Panel(w:TMWidget, b:Int)
	top.StatusText(MilliSecs() + " -- Panel Button Down " + b)
End Function 

Function OnButtonUp_Panel(w:TMWidget, b:Int)
	top.StatusText(MilliSecs() + " -- Panel Button Up " + b)
End Function 

Function OnMouseMove_Panel(w:TMWidget, x:Int, y:Int)
	panel_prog.SetValue(Double(x)/Double(w.Width()))
	top.StatusText(MilliSecs() + " -- Panel Mouse move " + x + "," + y)
End Function 

Function OnMouseWheel_Panel(w:TMWidget, b:Int)
	top.StatusText(MilliSecs() + " -- Panel Mouse wheel " + b)
End Function 

Function OnKeyDown_Panel(w:TMWidget, b:Int)
	panel_kd.Text(MilliSecs() + " -- Panel Key down " + b)
End Function 

Function OnKeyUp_Panel(w:TMWidget, b:Int)
	panel_ku.Text(MilliSecs() + " -- Panel Key up " + b)
End Function 

Function OnKey_Panel(w:TMWidget, b:Int)
	panel_k.Text(MilliSecs() + " -- Panel Key " + b + "(" + Chr(b) + ")")
End Function 

'
' SUBCLASS VERSION
'
Type MyApp Extends TMWindow
	Method OnTimer()
		Text("Test Managed Widgets -- " + CurrentTime() + " " + CurrentDate())
	End Method
	
	Method OnClose()
		closed=Confirm("Really quit?")
	End Method
	
	Method OnMove(x:Int, y:Int)
		StatusText(x+","+y)
	End Method

	Method OnResize(x:Int, y:Int)
		StatusText("["+x+","+y+"]")
	End Method
	
	Method OnDrop(path:String)
		Notify("Dropped~n" + path)
	End Method
End Type

Type MyOK Extends TMButton
	Method OnPress()
		top.Close()
	End Method
End Type

Type MyCancel Extends TMButton
	Method OnPress()
		Notify("Cancel pressed -- text='" + txtfield.GetText() + "'")
	End Method
End Type

Type MyCheck Extends TMCheckbox
	Method OnPress(checked:Int)
		Notify("Ticked - " + checked)
	End Method
End Type

Type MyRadio Extends TMRadioButtonSet
	Method OnSelected(index:Int)
		Notify("Radio changed - " + index)
	End Method
End Type

Type MyTextField Extends TMTextField
	Method OnTextChanged(txt:String)
		top.StatusText(MilliSecs() + " -- " + txt)
	End Method
End Type

Type MyTextArea Extends TMTextArea
	Method SetStatus()
		Local s:String=""
		s:+"Pos: " + GetCursorColumn() + "," + GetCursorRow() + "   "
		s:+"Len: " + GetLength() + "   "
		s:+"[Sel: " + GetSelectionLength() + "," + GetSelectionRows() +"]"
		top.StatusText(MilliSecs() + " -- " + s)
	End Method
	Method OnTextChanged()
		SetStatus()
	End Method

	Method OnSelection()
		SetStatus()
	End Method
	
	Method OnMenu()
		Notify("No menu!")
	End Method
End Type

Type MySlider Extends TMSlider
	Method OnValueChanged(val:Int)
		top.StatusText(MilliSecs() + " -- " + val)
	End Method
End Type

Type MyList Extends TMListBox
	Method OnIndexChanged(index:Int)
		top.StatusText(MilliSecs() + " -- " + index)
	End Method
End Type

Type MyForward Extends TMButton
	Method OnPress()
		html.Forward()
	End Method
End Type

Type MyBack Extends TMButton
	Method OnPress()
		html.Back()
	End Method
End Type

Type MyGo Extends TMButton
	Method OnPress()
		html.Go(html_url.GetText())
	End Method
End Type

Type MyHTML Extends TMHTMLView
	Method OnPageLoaded(url:String)
		top.StatusText(MilliSecs() + " -- Loaded " + url)
	End Method
	
	Method OnSelectURL(url:String)
		html_url.Text(url)
	End Method
End Type

Type MyTree Extends TMTreeView
	Method OnSelected(path:String, tag:Object)
		top.StatusText(MilliSecs() + " -- Selected " + path + " (" + tag.ToString() + ")")
	End Method

	Method OnClicked(path:String, tag:Object)
		top.StatusText(MilliSecs() + " -- Clicked " + path + " (" + tag.ToString() + ")")
	End Method

	Method OnExpanded(path:String, tag:Object)
		top.StatusText(MilliSecs() + " -- Expanded " + path + " (" + tag.ToString() + ")")
	End Method

	Method OnCollapsed(path:String, tag:Object)
		top.StatusText(MilliSecs() + " -- Collapsed " + path + " (" + tag.ToString() + ")")
	End Method

	Method OnMenu(path:String, tag:Object)
		top.StatusText(MilliSecs() + " -- Menu " + path + " (" + tag.ToString() + ")")
	End Method
End Type

Type MyCanvas Extends TMCanvas
	Field mx:Int
	Field my:Int
	
	Method OnRedraw()
		SetupGraphics()
		SetColor(Rand(100,200),Rand(100,200),Rand(100,200))
		DrawRect(0,0,Width(),Height())
		Flip
	End Method
	
	Method OnMouseEnter()
		SetPointer(POINTER_CROSS)
	End Method
	
	Method OnMouseLeave()
		SetPointer(POINTER_DEFAULT)
	End Method
	
	Method OnButtonDown(b:Int)
		SetupGraphics()
		SetColor(255,255,255)
		DrawLine(0,0,mx,my)
		Flip()
		top.StatusText(MilliSecs() + " -- Button Down " + b)
	End Method
	
	Method OnButtonUp(b:Int)
		SetupGraphics()
		SetColor(0,0,0)
		DrawLine(0,0,mx,my)
		Flip()
		top.StatusText(MilliSecs() + " -- Button Up " + b)
	End Method
	
	Method OnMouseMove(x:Int, y:Int)
		mx=x
		my=y
		top.StatusText(MilliSecs() + " -- Mouse move " + x + "," + y)
	End Method
	
	Method OnMouseWheel(b:Int)
		top.StatusText(MilliSecs() + " -- Mouse wheel " + b)
	End Method
	
	Method OnKeyDown(b:Int)
		SetupGraphics()
		SetColor(0,0,0)
		DrawRect(0,0,600,19)
		SetColor(255,255,255)
		DrawText(MilliSecs() + " -- Key down " + b,0,0)
		Flip()
	End Method
	
	Method OnKeyUp(b:Int)
		SetupGraphics()
		SetColor(0,0,0)
		DrawRect(0,20,600,19)
		SetColor(255,255,255)
		DrawText(MilliSecs() + " -- Key up " + b,0,20)
		Flip()
	End Method
	
	Method OnKey(b:Int)
		SetupGraphics()
		SetColor(0,0,0)
		DrawRect(0,40,600,19)
		SetColor(255,255,255)
		DrawText(MilliSecs() + " -- Key " + b + "(" + Chr(b) + ")",0,40)
		Flip()
	End Method
End Type

Type MyToolbar Extends TMToolbar
	Method OnSelected(i:Int)
		top.StatusText(MilliSecs() + " -- Toolbar " + i)
		ItemEnabled(1,Not i=0)
	End Method
End Type

Type MyPanel Extends TMPanel

	Method OnMouseEnter()
		SetPointer(POINTER_CROSS)
	End Method
	
	Method OnMouseLeave()
		SetPointer(POINTER_DEFAULT)
	End Method
	
	Method OnButtonDown(b:Int)
		top.StatusText(MilliSecs() + " -- Panel Button Down " + b)
	End Method
	
	Method OnButtonUp(b:Int)
		top.StatusText(MilliSecs() + " -- Panel Button Up " + b)
	End Method
	
	Method OnMouseMove(x:Int, y:Int)
		panel_prog.SetValue(Double(x)/Double(Width()))
		top.StatusText(MilliSecs() + " -- Panel Mouse move " + x + "," + y)
	End Method
	
	Method OnMouseWheel(b:Int)
		top.StatusText(MilliSecs() + " -- Panel Mouse wheel " + b)
	End Method
	
	Method OnKeyDown(b:Int)
		panel_kd.Text(MilliSecs() + " -- Panel Key down " + b)
	End Method
	
	Method OnKeyUp(b:Int)
		panel_ku.Text(MilliSecs() + " -- Panel Key up " + b)
	End Method
	
	Method OnKey(b:Int)
		panel_k.Text(MilliSecs() + " -- Panel Key " + b + "(" + Chr(b) + ")")
	End Method
End Type

'
' ALWAYS SUBCLASSES
'
Type AddToTree Extends TMButton
	Method OnPress()
		tree.Set(tree_node.GetText(),StripDir(tree_node.GetText()))
	End Method
End Type

Type RemoveFromTree Extends TMButton
	Method OnPress()
		tree.Remove(tree_node.GetText())
	End Method
End Type

Type CountTree Extends TMButton
	Method OnPress()
		Local path:String=tree_node.GetText()
		Notify("Children of " + path + " = " + tree.CountChildren(path))
	End Method
End Type

Type AddToMenu Extends TMButton
	Method OnPress()
		menu.Set(menu_path.GetText(),menu_name.GetText(),MenuCallback)
	End Method
End Type

Type RemoveFromMenu Extends TMButton
	Method OnPress()
		menu.Remove(menu_path.GetText())
	End Method
End Type

Type MenuCheck Extends TMButton
	Method OnPress()
		menu.Check(menu_path.GetText(),True)
	End Method
End Type

Type MenuUncheck Extends TMButton
	Method OnPress()
		menu.Check(menu_path.GetText(),False)
	End Method
End Type

Type MenuEnable Extends TMButton
	Method OnPress()
		menu.Enable(menu_path.GetText(),True)
	End Method
End Type

Type MenuDisable Extends TMButton
	Method OnPress()
		menu.Enable(menu_path.GetText(),False)
	End Method
End Type

Type MenuPopup Extends TMButton
	Method OnPress()
		popup.Popup(Self)
	End Method
End Type

Type MyMenu Extends TMMenu
	Method OnMenuItem(path:String, tag:Object)
		menu_status.Text(MilliSecs() + " -- Selected " + path + " (" + tag.ToString() + ") check=" + IsChecked(path))
	End Method
End Type

Type MyPanelButton Extends TMButton
	Method OnPress()
		Notify("Pressed")
	End Method
End Type

'
' ALWAYS CALLBACKS
'
Function MenuCallback(m:TMMenu, path:String, tag:Object)
	top.StatusText(MilliSecs() + " -- Selected " + path + " (" + tag.ToString() + ") check=" + m.IsChecked(path))
End Function

Function PopupMenuCallback(m:TMMenu, path:String, tag:Object)
	top.StatusText(MilliSecs() + " -- Selected popup " + path + " (" + tag.ToString() + ") check=" + m.IsChecked(path))
End Function

'
' TEST
'

If SUBCLASS
	top=New MyApp.Create("Test Managed Widgets",100,100,640,400,Null,WINDOW_TITLEBAR|WINDOW_CLIENTCOORDS|WINDOW_STATUS|WINDOW_RESIZABLE|WINDOW_MENU|WINDOW_ACCEPTFILES)
Else
	top=New TMWindow.Create("Test Managed Widgets",100,100,640,400,Null,WINDOW_TITLEBAR|WINDOW_CLIENTCOORDS|WINDOW_STATUS|WINDOW_RESIZABLE|WINDOW_MENU|WINDOW_ACCEPTFILES)
	top.OnCloseEvent.Add(OnClose)
	top.OnTimerEvent.Add(OnTimer)
	top.OnMoveEvent.Add(OnMove)
	top.OnResizeEvent.Add(OnResize)
	top.OnDropEvent.Add(OnDrop)
EndIf

top.MinSize(top.Width(),top.Height())

tabs=New TMTabber.Create(0,30,640,370,top)
tabs.SetIconStrip(icons)
tabs.AddItem(CreateListEntry("Buttons",0,0,"Test different button types"))
tabs.AddItem(CreateListEntry("Text",0,1,"Test text entry fields"))
tabs.AddItem(CreateListEntry("Sliders",0,2,"Test sliders"))
tabs.AddItem(CreateListEntry("Lists",0,3,"Test list"))
tabs.AddItem(CreateListEntry("HTML",0,-1,"Test HTML view"))
tabs.AddItem(CreateListEntry("Tree View",0,-1,"Test tree view"))
tabs.AddItem(CreateListEntry("Menu",0,-1,"Test menus"))
tabs.AddItem(CreateListEntry("Canvas",0,-1,"Test canvas"))
tabs.AddItem(CreateListEntry("Panel",0,-1,"Test panel"))

If SUBCLASS
	ok=New MyOK.CreateOK("OK",10,300,80,30,tabs)
	cancel=New MyCancel.CreateCancel("Cancel",100,300,80,30,tabs)
	
	check=New MyCheck.Create("Checkbox",10,10,100,20,tabs)
	
	radio1=New TMRadioButton.Create("Radio 1",10,30,100,20,tabs)
	radio2=New TMRadioButton.Create("Radio 2",10,50,100,20,tabs)
	radio3=New TMRadioButton.Create("Radio 3",10,70,100,20,tabs)
	
	radio1.Checked(True)
	
	radios=New MyRadio.Create([radio1,radio2,radio3])

	txtfield=New MyTextField.Create(90,10,80,20,tabs)
	txtarea=New MyTextArea.Create(10,40,620,300,tabs)

	slider1=New MySlider.Create(10,10,15,300,tabs,SLIDER_VERTICAL|SLIDER_SCROLLBAR)
	slider2=New MySlider.Create(30,10,300,15,tabs,SLIDER_HORIZONTAL|SLIDER_TRACKBAR)
	
	list=New MyList.Create(10,10,300,300,tabs)

	html=New MyHTML.Create(10,10,620,280,tabs,HTMLVIEW_NOCONTEXTMENU|HTMLVIEW_NONAVIGATE)
	html_url=New TMTextField.Create(10,300,620,20,tabs)
	html_go=New MyGo.Create("GO",10,325,90,20,tabs)
	html_back=New MyBack.Create("Back",110,325,90,20,tabs)
	html_forward=New MyForward.Create("Forward",210,325,90,20,tabs)
	
	tree=New MyTree.Create(10,10,620,250,tabs)
	
	canvas=New MyCanvas.Create(10,10,620,320,tabs)
	
	toolbar=New MyToolbar.Create("incbin::toolbar.png",top)

	panel=New MyPanel.Create(10,10,620,320,tabs,PANEL_ACTIVE,"Panel")
	
Else
	ok=New TMButton.CreateOK("OK",10,300,80,30,tabs)
	cancel=New TMButton.CreateCancel("Cancel",100,300,80,30,tabs)
	
	check=New TMCheckbox.Create("Checkbox",10,10,100,20,tabs)
	
	radio1=New TMRadioButton.Create("Radio 1",10,30,100,20,tabs)
	radio2=New TMRadioButton.Create("Radio 2",10,50,100,20,tabs)
	radio3=New TMRadioButton.Create("Radio 3",10,70,100,20,tabs)
	
	radio1.Checked(True)
	
	radios=New TMRadioButtonSet.Create([radio1,radio2,radio3])

	txtfield=New TMTextField.Create(90,10,80,20,tabs)
	txtarea=New TMTextArea.Create(10,40,620,300,tabs)

	slider1=New MySlider.Create(10,10,15,300,tabs,SLIDER_VERTICAL|SLIDER_SCROLLBAR)
	slider2=New MySlider.Create(30,10,300,15,tabs,SLIDER_HORIZONTAL|SLIDER_TRACKBAR)
	
	list=New TMListBox.Create(10,10,300,300,tabs)

	html=New TMHTMLView.Create(10,10,620,280,tabs,HTMLVIEW_NOCONTEXTMENU|HTMLVIEW_NONAVIGATE)
	html_url=New TMTextField.Create(10,300,620,20,tabs)
	html_go=New TMButton.Create("GO",10,325,90,20,tabs)
	html_back=New TMButton.Create("Back",110,325,90,20,tabs)
	html_forward=New TMButton.Create("Forward",210,325,90,20,tabs)

	tree=New TMTreeView.Create(10,10,620,250,tabs)
	
	canvas=New TMCanvas.Create(10,10,620,320,tabs)
	
	toolbar=New TMToolbar.Create("incbin::toolbar.png",top)
	
	panel=New TMPanel.Create(10,10,620,320,tabs,PANEL_ACTIVE,"Panel")

	ok.OnPressEvent.Add(OnPress_OK)
	cancel.OnPressEvent.Add(OnPress_Cancel)
	check.OnPressEvent.Add(OnPress_Check)
	
	radios.OnSelectedEvent.Add(OnSelected_Radio)
	
	txtfield.OnTextChangedEvent.Add(OnTextChanged_Field)
	txtarea.OnTextChangedEvent.Add(ShowAreaStatus)
	txtarea.OnSelectionEvent.Add(ShowAreaStatus)
	txtarea.OnMenuEvent.Add(OnMenu_Area)
	
	slider1.OnValueChangedEvent.Add(ShowChangedInt)
	slider2.OnValueChangedEvent.Add(ShowChangedInt)
	list.OnIndexChangedEvent.Add(ShowChangedInt)
	
	html.OnPageLoadedEvent.Add(OnPageLoaded)
	html.OnSelectURLEvent.Add(OnSelectURL)
	html_go.OnPressEvent.Add(OnGO)
	html_forward.OnPressEvent.Add(OnForward)
	html_back.OnPressEvent.Add(OnBack)

	tree.OnSelectedEvent.Add(OnSelected_Tree)
	tree.OnClickedEvent.Add(OnClicked_Tree)
	tree.OnExpandedEvent.Add(OnExpanded_Tree)
	tree.OnCollapsedEvent.Add(OnCollapsed_Tree)
	tree.OnMenuEvent.Add(OnMenu_Tree)
	
	canvas.OnRedrawEvent.Add(OnRedraw_Canvas)
	canvas.OnMouseEnterEvent.Add(OnMouseEnter_Canvas)
	canvas.OnMouseLeaveEvent.Add(OnMouseLeave_Canvas)
	canvas.OnButtonDownEvent.Add(OnButtonDown_Canvas)
	canvas.OnButtonUpEvent.Add(OnButtonUp_Canvas)
	canvas.OnMouseWheelEvent.Add(OnMouseWheel_Canvas)
	canvas.OnMouseMoveEvent.Add(OnMouseMove_Canvas)
	canvas.OnKeyDownEvent.Add(OnKeyDown_Canvas)
	canvas.OnKeyUpEvent.Add(OnKeyUp_Canvas)
	canvas.OnKeyEvent.Add(OnKey_Canvas)
	
	toolbar.OnSelectedEvent.Add(OnSelected_Toolbar)

	panel.OnMouseEnterEvent.Add(OnMouseEnter_Canvas)
	panel.OnMouseLeaveEvent.Add(OnMouseLeave_Canvas)
	panel.OnButtonDownEvent.Add(OnButtonDown_Panel)
	panel.OnButtonUpEvent.Add(OnButtonUp_Panel)
	panel.OnMouseWheelEvent.Add(OnMouseWheel_Panel)
	panel.OnMouseMoveEvent.Add(OnMouseMove_Panel)
	panel.OnKeyDownEvent.Add(OnKeyDown_Panel)
	panel.OnKeyUpEvent.Add(OnKeyUp_Panel)
	panel.OnKeyEvent.Add(OnKey_Panel)
	
EndIf

panel_kd=New TMLabel.Create("Key down",10,10,320,20,panel)
panel_ku=New TMLabel.Create("Key up",10,40,320,20,panel)
panel_k=New TMLabel.Create("Key",10,70,320,20,panel)

panel_prog=New TMProgressBar.Create(10,100,320,10,panel)
panel_button=New MyPanelButton.Create("Button",10,120,100,20,panel)

Local label:TMLabel=New TMLabel.Create("Label:",10,10,80,20,tabs)

list.SetIconStrip(icons)
list.AddItem(CreateListEntry("Item 1",0,0))
list.AddItem(CreateListEntry("Item 2",0,1))
list.AddItem(CreateListEntry("Item 3",0,2))
list.AddItem(CreateListEntry("Item 4",0,3))

list.ItemEnabled(2,False)

tabs.ItemEnabled(4,True)
tabs.ItemEnabled(5,False)
tabs.ItemEnabled(6,False)

list.SetSelectedIndex(0)

'tree.SetIconStrip(icons)
tree.BeginUpdate()
tree.Set("/dir1","Dir1",0)
tree.Set("/dir2","Dir2",1)
tree.Set("/dir1/ent1","Ent1",2)
tree.Set("/dir1/ent2","Ent2",3)
tree.Set("/dir1/ent3","Ent3",3)
tree.Set("/dir1/ent3","Ent3 (Edit)",3)
tree.EndUpdate()

html.Go("http://www.noddybox.demon.co.uk")

tree_node=New TMTextField.Create(10,280,300,20,tabs)
tree_add=New AddToTree.Create("Add",320,280,80,20,tabs)
tree_remove=New RemoveFromTree.Create("Remove",420,280,80,20,tabs)
tree_count=New CountTree.Create("Count",520,280,80,20,tabs)

menu=New MyMenu.CreateWindowMenu(top)
popup=New MyMenu.CreatePopupMenu()

popup.Set("/menu1","Menu 1")
popup.Set("/menu2","Menu 2")
popup.Set("/menu1/opt1","Opt 1.1",PopupMenuCallback)
popup.Set("/menu1/opt2","Opt 1.2",PopupMenuCallback)
popup.Set("/menu2/opt1","Opt 2.1",PopupMenuCallback)

menu.Set("/file","File")
menu.Set("/file/quit","Quit",MenuCallback)

menu_status=New TMLabel.Create("",10,10,600,20,tabs)
menu_path=New TMTextField.Create(10,30,300,20,tabs)
menu_name=New TMTextField.Create(320,30,300,20,tabs)
menu_add=New AddToMenu.Create("Add",10,60,100,20,tabs)
menu_remove=New RemoveFromMenu.Create("Remove",200,60,100,20,tabs)
menu_check=New MenuCheck.Create("Check",10,90,100,20,tabs)
menu_uncheck=New MenuUncheck.Create("Uncheck",200,90,100,20,tabs)
menu_enable=New MenuEnable.Create("Enable",10,120,100,20,tabs)
menu_disable=New MenuDisable.Create("Disable",200,120,100,20,tabs)
menu_popup=New MenuPopup.Create("Popup",10,150,100,20,tabs)

toolbar.SetTooltips(["Tip1","Tip2","","Tip3","Tip4"])

toolbar.AddItem(0,0,"Tip5")
toolbar.AddItem(1,0,"Tip6")
toolbar.AddItem(3,0,"Tip7")
toolbar.AddItem(4,0,"Tip8")

tabs.SetPages([ ..
				[TMWidget(ok),TMWidget(cancel),TMWidget(check),TMWidget(radio1),TMWidget(radio2),TMWidget(radio3)], ..
				[TMWidget(label),TMWidget(txtfield),TMWidget(txtarea)], ..
				[TMWidget(slider1),TMWidget(slider2)], ..
				[TMWidget(list)], ..
				[TMWidget(html), TMWidget(html_url), TMWidget(html_go), TMWidget(html_back), TMWidget(html_forward)], ..
				[TMWidget(tree), TMWidget(tree_node), TMWidget(tree_add), TMWidget(tree_remove), TMWidget(tree_count)], ..
				[TMWidget(menu_status), TMWidget(menu_path), TMWidget(menu_name), TMWidget(menu_add), TMWidget(menu_remove), TMWidget(menu_check), TMWidget(menu_uncheck), TMWidget(menu_enable), TMWidget(menu_disable), TMWidget(menu_popup)], ..
				[TMWidget(canvas)], ..
				[TMWidget(panel)] ..
			])


tabs.SetSelectedIndex(0)

If TESTTIMER
	top.SetTimer(1)
EndIf

MWidgetMainLoop(top)

End