-
Notifications
You must be signed in to change notification settings - Fork 1
/
Widget.CB
830 lines (503 loc) · 18.6 KB
/
Widget.CB
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
Const API_WIDGET_PLAYERSCORE = 1
Const API_WIDGET_TIMER = 2
Const API_WIDGET_LIST = 3
Const API_WIDGET_LISTITEM = 4
Const MAIN_WIDGET_TYPES = 4
//oudot arvot ettei sekoitu ruutukoodinaattien kanssa
Const API_POSITION_TOP = -1000000
Const API_POSITION_BOTTOM = -1000001
Const API_POSITION_LEFT = -1000002
Const API_POSITION_RIGHT = -1000003
Const API_POSITION_TOPLEFT = -1000004
Const API_POSITION_TOPRIGHT = -1000005
Const API_POSITION_BOTTOMLEFT = -1000006
Const API_POSITION_BOTTOMRIGHT = -1000007
Const API_POSITION_CENTER = -1000008
Const API_ORIENTATION_HORIZONTAL = 0
Const API_ORIENTATION_VERTICAL = 1
Const API_WD_TIMER_START = 0
Const API_WD_TIMER_TIME = 1
Const API_WD_LIST_ITEMS = 0
Const API_WD_LIST_ORIENTATION = 1
Const API_WD_LIST_VISIBLEITEMCOUNT = 2
Const API_WD_LIST_LISTITEM_WIDTH = 3
Const API_WD_LIST_LISTITEM_HEIGHT = 4
Const API_WD_LISTITEM_LIST = 0
Const API_WD_LISTITEM_TEXT = 1
Const API_WD_LISTITEM_TEXT_X = 2
Const API_WD_LISTITEM_TEXT_Y = 3
Const API_WD_LISTITEM_IMAGE = 4
Const API_WD_LISTITEM_IMAGE_X = 5
Const API_WD_LISTITEM_IMAGE_Y = 6
Const MAIN_TEMPLATE_LISTITEM_TEXT_X = 0
Const MAIN_TEMPLATE_LISTITEM_TEXT_Y = 1
Const MAIN_TEMPLATE_LISTITEM_IMAGE_X = 2
Const MAIN_TEMPLATE_LISTITEM_IMAGE_Y = 3
Const MAIN_TEMPLATE_LISTITEM_WIDTH = 4
Const MAIN_TEMPLATE_LISTITEM_HEIGHT = 5
Const MAIN_TEMPLATE_LISTITEM_STYLE = 6
Type MAIN_Widget
Field x
Field y
Field position
Field width
Field height
Field img
Field widgetType
Field visible
Field widgetData
Field hover
EndType
//Lisää widgetin annetulla tyypillä ja asettaa sen näkyvyyden
Function API_AddWidget(widgetType,visible=1)
If (widgetType > 0 And widgetType <= MAIN_WIDGET_TYPES) Then
w.MAIN_Widget = New(MAIN_Widget)
w\widgetType = widgetType
w\x = 0
w\y = 0
w\widgetData = MakeMEMBlock(4)
w\visible = (visible = 1)
w\hover = 0
If widgetType = API_WIDGET_PLAYERSCORE Then
w\width = API_RenderW
w\height = 40
ElseIf widgetType = API_WIDGET_TIMER Then
w\width = 205
w\height = 40
ElseIf widgetType = API_WIDGET_LIST Then
// you should use API_WidgetList
w\width = 200
w\height = API_RenderH
ElseIf widgetType = API_WIDGET_LISTITEM Then
// you should use API_WidgetList
w\width = 200
w\height = 20
EndIf
//w\img = API_MakeImage(w\width,w\height)
Return ConvertToInteger(w)
EndIf
Return 0
EndFunction
//Luo ja palauttaa uuden lista templaten
Function API_WidgetListTemplate(textX=2,textY=2,imageX=0,imageY=0,width=100,height=20,style=-1)
template = MakeMEMBlock(7*4)
MAIN_MemInt(template, MAIN_TEMPLATE_LISTITEM_TEXT_X, textX)
template = MAIN_MemChangedAddress
MAIN_MemInt(template, MAIN_TEMPLATE_LISTITEM_TEXT_Y, textY)
template = MAIN_MemChangedAddress
MAIN_MemInt(template, MAIN_TEMPLATE_LISTITEM_IMAGE_X, imageX)
template = MAIN_MemChangedAddress
MAIN_MemInt(template, MAIN_TEMPLATE_LISTITEM_IMAGE_Y, imageY)
template = MAIN_MemChangedAddress
MAIN_MemInt(template, MAIN_TEMPLATE_LISTITEM_WIDTH, width)
template = MAIN_MemChangedAddress
MAIN_MemInt(template, MAIN_TEMPLATE_LISTITEM_HEIGHT, height)
template = MAIN_MemChangedAddress
MAIN_MemInt(template, MAIN_TEMPLATE_LISTITEM_STYLE, style)
template = MAIN_MemChangedAddress
Return template
EndFunction
//Luo ja palauttaa uuden listadatan
Function API_WidgetListItemData(txt$, images$="", separator$ = ",")
If Right(txt$,1) = separator$ Then txt$ = Left(txt$,Len(txt$)-1)
If Right(images$,1) = separator$ Then images$ = Left(images$,Len(images$)-1)
listItemData = MakeMEMBlock(4)
listItemTexts = CountWords(txt$, separator$)
listItemImages = CountWords(images$, separator$)
listItemAmount = Max(listItemImages,listItemTexts)
For i=1 To listItemAmount
mem = MakeMEMBlock(8)
If i <= listItemTexts Then
word$ = GetWord(txt$,i,separator$)
MAIN_MemString(mem, API_WD_LISTITEM_TEXT, word$)
Else
MAIN_MemString(mem, API_WD_LISTITEM_TEXT, "")
EndIf
mem = MAIN_MemChangedAddress
If i <= listItemImages Then
img = Int(GetWord(images$,i,separator$))
MAIN_MemInt(mem, API_WD_LISTITEM_IMAGE, img)
Else
MAIN_MemInt(mem, API_WD_LISTITEM_IMAGE, 0)
EndIf
mem = MAIN_MemChangedAddress
MAIN_MemInt(listItemData, (i-1), mem)
listItemData = MAIN_MemChangedAddress
Next i
//LIB_PrintMEMBlockData(listItemData,"2","ii","listitemData","Text Image")
Return listItemData
EndFunction
//Luo ja palauttaa uuden listawidgetin
//poistaa annetut data ja template muistipalat
Function API_WidgetList(listItemData, listItemTemplate, listOrientation, position, y = 0)
If listItemData <> 0 And listItemTemplate <> 0 Then
listWidget = API_AddWidget(API_WIDGET_LIST)
w.MAIN_Widget = ConvertToType(listWidget)
w\position = position
w\y = y
listItemDataSize = MEMBlockSize(listItemData)
listItemTextX = MAIN_MemInt(listItemTemplate,MAIN_TEMPLATE_LISTITEM_TEXT_X)
listItemTemplate = MAIN_MemChangedAddress
listItemTextY = MAIN_MemInt(listItemTemplate,MAIN_TEMPLATE_LISTITEM_TEXT_Y)
listItemTemplate = MAIN_MemChangedAddress
listItemImageX = MAIN_MemInt(listItemTemplate,MAIN_TEMPLATE_LISTITEM_IMAGE_X)
listItemTemplate = MAIN_MemChangedAddress
listItemImageY = MAIN_MemInt(listItemTemplate,MAIN_TEMPLATE_LISTITEM_IMAGE_Y)
listItemTemplate = MAIN_MemChangedAddress
listItemWidth = MAIN_MemInt(listItemTemplate,MAIN_TEMPLATE_LISTITEM_WIDTH)
listItemTemplate = MAIN_MemChangedAddress
listItemHeight = MAIN_MemInt(listItemTemplate,MAIN_TEMPLATE_LISTITEM_HEIGHT)
listItemTemplate = MAIN_MemChangedAddress
DeleteMEMBlock listItemTemplate
API_WidgetInt(listWidget,API_WD_LIST_LISTITEM_WIDTH,listItemWidth)
API_WidgetInt(listWidget,API_WD_LIST_LISTITEM_HEIGHT,listItemHeight)
API_WidgetInt(listWidget,API_WD_LIST_ORIENTATION,listOrientation)
listItems = MakeMEMBlock(listItemDataSize)
For i=0 To listItemDataSize-1 Step 4
listItem = PeekInt(listItemData,i)
If listItem <> 0 Then
listItemWidget = API_AddWidget(API_WIDGET_LISTITEM)
API_WidgetInt(listItemWidget,API_WD_LISTITEM_LIST,listWidget)
w2.MAIN_Widget = ConvertToType(listItemWidget)
w2\height = listItemHeight
w2\width = listItemWidth
st$ = MAIN_MemString(listItem, API_WD_LISTITEM_TEXT)
listItem = MAIN_MemChangedAddress
img = MAIN_MemInt(listItem, API_WD_LISTITEM_IMAGE)
listItem = MAIN_MemChangedAddress
API_WidgetString(listItemWidget, API_WD_LISTITEM_TEXT, st$)
API_WidgetInt(listItemWidget, API_WD_LISTITEM_TEXT_X, listItemTextX)
API_WidgetInt(listItemWidget, API_WD_LISTITEM_TEXT_Y, listItemTextY)
API_WidgetInt(listItemWidget, API_WD_LISTITEM_IMAGE, img)
API_WidgetInt(listItemWidget, API_WD_LISTITEM_IMAGE_X, listItemImageX)
API_WidgetInt(listItemWidget, API_WD_LISTITEM_IMAGE_Y, listItemImageY)
DeleteMEMBlock listItem
PokeInt listItems, i, listItemWidget
EndIf
Next i
DeleteMEMBlock listItemData
API_WidgetInt(listWidget,API_WD_LIST_ITEMS,listItems)
MAIN_UpdateWidget(listWidget)
Return listWidget
EndIf
Return 0
EndFunction
Function API_GetListitem(listWidget, listItemNumber)
If listWidget <> 0 Then
w.MAIN_Widget = ConvertToType(listWidget)
If w <> NULL Then
listItems = API_WidgetInt(listWidget, API_WD_LIST_ITEMS)
If listItems <> 0 Then
If listItemNumber * 4 < MEMBlockSize(listItems) Then Return PeekInt(listItems, listItemNumber * 4)
EndIf
EndIf
EndIf
Return 0
EndFunction
Function MAIN_MouseOnWidget(widget)
If widget <> 0 Then
w.MAIN_Widget = ConvertToType(widget)
If w <> NULL Then
If w\visible Then
mx = MAIN_MouseX()
my = MAIN_MouseY()
w\hover = (mx >= w\x And mx < w\x + w\width And my >= w\y And my < w\y + w\height)
Else
w\hover = 0
EndIf
Return w\hover
EndIf
EndIf
Return 0
EndFunction
//Asettaa tai palauttaa kokonaisluvun
Function API_WidgetInt(widget, dataField, value$ = "NAN")
w.MAIN_Widget = ConvertToType(widget)
iValue = MAIN_MemInt(w\widgetData, dataField, value$)
w\widgetData = MAIN_MemChangedAddress
Return iValue
EndFunction
//Asettaa tai palauttaa liukuluvun
Function API_WidgetFloat(widget, dataField, value$ = "NAN")
w.MAIN_Widget = ConvertToType(widget)
fValue# = MAIN_MemFloat(w\widgetData, dataField, value$)
w\widgetData = MAIN_MemChangedAddress
Return fValue#
EndFunction
//Asettaa tai palauttaa merkkijonon
Function API_WidgetString(widget, dataField, value$ = "TOIVOTAANettäEItuleTÖRMÄYKSIÄtämänMERKKIJONONkanssa!!")
w.MAIN_Widget = ConvertToType(widget)
value$ = MAIN_MemString(w\widgetData, dataField, value$)
w\widgetData = MAIN_MemChangedAddress
Return value$
EndFunction
//Asettaa tai vaihtaa widgetin näkyvyyden
Function API_ToggleWidget(widget, visible = -1)
If widget <> 0 Then
w.MAIN_Widget = ConvertToType(widget)
If w <> NULL Then
wasVisible = w\visible
If visible = -1 Then
w\visible = Not w\visible
Else
w\visible = (visible = 1)
EndIf
If wasVisible <> w\visible Then
If w\widgetType = API_WIDGET_LISTITEM Then
list = API_WidgetInt(widget, API_WD_LISTITEM_LIST)
MAIN_UpdateWidget(list)
ElseIf w\widgetType = API_WIDGET_LIST Then
MAIN_UpdateWidget(widget)
EndIf
EndIf
EndIf
EndIf
EndFunction
//Asettaa annetun widgetin paikoilleen
Function API_PositionWidget(widget, position = 0, y = 0)
If ( widget <> 0 ) Then
w.MAIN_Widget = ConvertToType(widget)
If ( w <> NULL ) Then
If (position < API_POSITION_TOP+1 And y = 0) Then
w\position = position
If position = API_POSITION_TOP Then
w\x = API_RenderW/2 - w\width/2
w\y = 0
ElseIf position = API_POSITION_BOTTOM Then
w\x = API_RenderW/2 - w\width/2
w\y = API_RenderH - w\height
ElseIf position = API_POSITION_LEFT Then
w\x = 0
w\y = API_RenderH/2 - w\height/2
ElseIf position = API_POSITION_RIGHT Then
w\x = API_RenderW - w\width
w\y = API_RenderH/2 - w\height/2
ElseIf position = API_POSITION_TOPLEFT Then
w\x = 0
w\y = 0
ElseIf position = API_POSITION_TOPRIGHT Then
w\x = API_RenderW - w\width
w\y = 0
ElseIf position = API_POSITION_BOTTOMLEFT Then
w\x = 0
w\y = API_RenderH - w\height
ElseIf position = API_POSITION_BOTTOMRIGHT Then
w\x = API_RenderW - w\width
w\y = API_RenderH - w\height
ElseIf position = API_POSITION_CENTER Then
w\x = API_RenderW/2 - w\width/2
w\y = API_RenderH/2 - w\height/2
EndIf
Else
w\position = 0
w\x = position
w\y = y
EndIf
EndIf
EndIf
EndFunction
//Piirtää näkyvät widgetit
Function MAIN_DrawWidgets(showAreas = 0)
fontNormal = API_LoadFont("Courier",12)
For w.MAIN_WIDGET = Each MAIN_Widget
If w\visible = 1 Then
If showAreas Then
Color cbwhite
Box w\x,w\y,w\width,w\height,0
EndIf
widget = ConvertToInteger(w)
If w\widgetType = API_WIDGET_PLAYERSCORE Then
If MAIN_PlayerAmount <> 0 Then
fontName = API_LoadFont("Deja Vu Sans Mono",14)
fontPoints = API_LoadFont("Deja Vu Sans Mono",30)
//Jos aiempaa ei löydy
If fontName = 0 Then fontName = API_LoadFont("Arial",14)
If fontPoints = 0 Then fontPoints = API_LoadFont("Arial",30)
widthPerPlayer = (w\width-10) / MAIN_PlayerAmount
number = 0
While number < MAIN_PlayerAmount
player = MAIN_PlayerData(number)
If player <> 0 Then
Color API_PlayerColor(number, RED), API_PlayerColor(number, GREEN), API_PlayerColor(number, BLUE)
SetFont fontName
name$ = API_PlayerName(number)
nameWidth = TextWidth(name$)
Text w\x + 5 + widthPerPlayer * number + widthPerPlayer / 2 - nameWidth / 2, w\y+25, name$
SetFont fontPoints
points$ = ""+API_PlayerPoints(number)
pointsWidth = TextWidth(points$)
Text w\x + 5 + widthPerPlayer * number + widthPerPlayer / 2 - pointsWidth / 2, w\y , points$
EndIf
number = number + 1
Wend
EndIf
ElseIf w\widgetType = API_WIDGET_TIMER Then
fontBig = API_LoadFont("OCR A Std",50)
If fontBig = 0 Then fontBig = API_LoadFont("Arial",50)
SetFont fontBig
Color cbwhite
start = API_WidgetInt(widget, API_WD_TIMER_START)
amount = API_WidgetInt(widget, API_WD_TIMER_TIME)
timeLeft = start + amount - API_Timer
If timeLeft > 0 Then
seconds$ = (timeLeft / 1000)
milliseconds$ = timeLeft - int(seconds$) * 1000
If Len(seconds$) = 1 Then seconds$ = "0"+seconds$
For i = 0 To 2-Len(milliseconds$)
milliseconds$ = "0"+milliseconds$
Next i
Text w\x,w\y,seconds$+":"+milliseconds$
Else
If (API_Timer / 350) Mod 2 = 0 Then
Color 255,0,0
Text w\x,w\y,"00:000"
EndIf
EndIf
ElseIf w\widgetType = API_WIDGET_LIST Then
Color 0,0,0
Box w\x, w\y, w\width, w\height
ElseIf w\widgetType = API_WIDGET_LISTITEM Then
SetFont fontNormal
Color 128,128,128
If w\hover Then Color cbwhite
Box w\x, w\y, w\width, w\height,0
txt$ = API_WidgetString(widget, API_WD_LISTITEM_TEXT)
If txt$ <> "" Then
x = API_WidgetInt(widget, API_WD_LISTITEM_TEXT_X)
y = API_WidgetInt(widget, API_WD_LISTITEM_TEXT_Y)
//TODO: Vaakasuuntaisen listan koon muutokset
txtHeight = LIB_RowText(txt$, w\x + x, w\y + y, w\x + w\width - x)
If ( txtHeight + y > w\height ) Then
MAIN_UpdateWidget(ConvertToInteger(w), -1, txtHeight + y)
EndIf
EndIf
img = API_WidgetInt(widget, API_WD_LISTITEM_IMAGE)
If img <> 0 Then
x = API_WidgetInt(widget, API_WD_LISTITEM_IMAGE_X)
y = API_WidgetInt(widget, API_WD_LISTITEM_IMAGE_Y)
DrawImage img, w\x + x, w\y + y
EndIf
EndIf
EndIf
Next w
SetFont fontNormal
EndFunction
//Päivittää listan esineet ja listan
Function MAIN_UpdateWidget(widget,width = -1, height = -1)
If widget <> 0 Then
w.MAIN_Widget = ConvertToType(widget)
If w <> NULL Then
oldWidth = w\width
oldHeight = w\height
If w\widgetType = API_WIDGET_LIST Then
listItems = API_WidgetInt(widget, API_WD_LIST_ITEMS)
If listItems Then
visibleCount = 0
visibleWidth = 0
visibleHeight = 0
For i=0 To MEMBlockSize(listItems)-1 Step 4
listItem = PeekInt(listItems,i)
w2.MAIN_Widget = ConvertToType(listItem)
If w\visible And w2\visible Then
visibleCount = visibleCount + 1
visibleWidth = visibleWidth + w2\width
visibleHeight = visibleHeight + w2\height
Else
w2\visible = 0
EndIf
Next i
API_WidgetInt(widget, API_WD_LIST_VISIBLEITEMCOUNT,visibleCount)
If visibleCount = 0 Then w\visible = 0
If w\visible Then
listItemWidth = API_WidgetInt(widget, API_WD_LIST_LISTITEM_WIDTH)
listItemHeight = API_WidgetInt(widget, API_WD_LIST_LISTITEM_HEIGHT)
//selvitä uusi koko
listOrientation = API_WidgetInt(widget, API_WD_LIST_ORIENTATION)
If listOrientation = API_ORIENTATION_HORIZONTAL Then
w\width = visibleWidth
w\height = listItemHeight
ElseIf listOrientation = API_ORIENTATION_VERTICAL Then
w\width = listItemWidth
w\height = visibleHeight
EndIf
//siirrä lista paikoilleen jos koko muuttunut
If w\width <> oldWidth Or w\height <> oldHeight Then
If w\position <> 0 Then API_PositionWidget(widget,w\position) Else API_PositionWidget(widget, w\x, w\y)
EndIf
visibleCount = 0
visibleWidth = 0
visibleHeight = 0
// päivitä listitemit
For i=0 To MEMBlockSize(listItems)-1 Step 4
listItem = PeekInt(listItems,i)
w2.MAIN_Widget = ConvertToType(listItem)
If w2\visible Then
If listOrientation = API_ORIENTATION_HORIZONTAL Then
w2\x = w\x + visibleWidth
w2\y = w\y
//w2\width = listItemWidth
w2\height = listItemHeight
ElseIf listOrientation = API_ORIENTATION_VERTICAL Then
w2\x = w\x
w2\y = w\y + visibleHeight
w2\width = listItemWidth
//w2\height = listItemHeight
EndIf
visibleWidth = visibleWidth + w2\width
visibleHeight = visibleHeight + w2\height
visibleCount = visibleCount + 1
EndIf
Next i
EndIf
EndIf
ElseIf w\widgetType = API_WIDGET_LISTITEM
list = API_WidgetInt(widget, API_WD_LISTITEM_LIST)
If list Then
listOrientation = API_WidgetInt(list, API_WD_LIST_ORIENTATION)
If width > 0 Then w\width = width
If height > 0 Then w\height = height
If listOrientation = API_ORIENTATION_HORIZONTAL Then
If height > 0 Then API_WidgetInt(list, API_WD_LIST_LISTITEM_HEIGHT, height)
ElseIf listOrientation = API_ORIENTATION_VERTICAL Then
If width > 0 Then API_WidgetInt(list, API_WD_LIST_LISTITEM_WIDTH, width)
EndIf
MAIN_UpdateWidget(list)
EndIf
Else
If ( w\visible) Then
If width > 0 Then w\width = width
If height > 0 Then w\height = height
If w\width <> oldWidth Or w\height <> oldHeight Then
If w\position <> 0 Then API_PositionWidget(widget,w\position) Else API_PositionWidget(widget, w\x, w\y)
EndIf
EndIf
EndIf
EndIf
EndIf
EndFunction
//Poistaa widgetin
Function MAIN_DeleteWidget(widget)
If widget <> 0 Then
w.MAIN_Widget = ConvertToType(widget)
If w <> NULL Then
If w\widgetType = API_WIDGET_LIST Then
listItems = API_WidgetInt(widget, API_WD_LIST_ITEMS)
If listItems <> 0 Then
For i=0 To MEMBlockSize(listItems)-1 Step 4
listItem = PeekInt(listItems,i)
MAIN_DeleteWidget(listItem)
Next i
DeleteMEMBlock listItems
EndIf
EndIf
If w\widgetData <> 0 Then DeleteMEMBlock w\widgetData
Delete w
EndIf
EndIf
End Function
//Poistaa kaikki widgetit
Function MAIN_DeleteWidgets()
For w.MAIN_WIDGET = Each MAIN_Widget
MAIN_DeleteWidget(ConvertToInteger(w))
Next w
End Function