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
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
|
# Claro Graphics - an abstraction layer for native UI libraries
#
# $Id$
#
# The contents of this file are subject to the Mozilla Public License
# Version 1.1 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
# License for the specific language governing rights and limitations
# under the License.
#
# See the LICENSE file for more details.
#
## Wrapper for the Claro GUI library.
## This wrapper calls ``claro_base_init`` and ``claro_graphics_init``
## automatically on startup, so you don't have to do it and in fact cannot do
## it because they are not exported.
{.deadCodeElim: on.}
when defined(windows):
const
clarodll = "claro.dll"
elif defined(macosx):
const
clarodll = "libclaro.dylib"
else:
const
clarodll = "libclaro.so"
import cairo
type
Node* {.pure.} = object
next*: ptr Node
prev*: ptr Node # pointer to real structure
data*: pointer
List* {.pure.} = object
head*: ptr Node
tail*: ptr Node
count*: int32
{.deprecated: [TNode: Node, TList: List].}
proc list_init*(){.cdecl, importc: "list_init", dynlib: clarodll.}
proc list_create*(list: ptr List){.cdecl, importc: "list_create",
dynlib: clarodll.}
proc node_create*(): ptr Node{.cdecl, importc: "node_create",
dynlib: clarodll.}
proc node_free*(n: ptr Node){.cdecl, importc: "node_free", dynlib: clarodll.}
proc node_add*(data: pointer, n: ptr Node, L: ptr List){.cdecl,
importc: "node_add", dynlib: clarodll.}
proc node_prepend*(data: pointer, n: ptr Node, L: ptr List){.cdecl,
importc: "node_prepend", dynlib: clarodll.}
proc node_del*(n: ptr Node, L: ptr List){.cdecl, importc: "node_del",
dynlib: clarodll.}
proc node_find*(data: pointer, L: ptr List): ptr Node{.cdecl,
importc: "node_find", dynlib: clarodll.}
proc node_move*(n: ptr Node, oldlist: ptr List, newlist: ptr List){.
cdecl, importc: "node_move", dynlib: clarodll.}
type
ClaroObj*{.pure, inheritable.} = object
typ*: array[0..64 - 1, char]
destroy_pending*: cint
event_handlers*: List
children*: List
parent*: ptr ClaroObj
appdata*: pointer # !! this is for APPLICATION USE ONLY !!
Event*{.pure.} = object
obj*: ptr ClaroObj # the object which this event was sent to
name*: array[0..64 - 1, char]
handled*: cint
arg_num*: cint # number of arguments
format*: array[0..16 - 1, char] # format of the arguments sent
arglist*: ptr pointer # list of args, as per format.
EventFunc* = proc (obj: ptr ClaroObj, event: ptr Event){.cdecl.}
EventIfaceFunc* = proc (obj: ptr ClaroObj, event: ptr Event,
data: pointer){.cdecl.}
EventHandler*{.pure.} = object
typ*: array[0..32 - 1, char]
data*: pointer
fun*: EventFunc # the function that handles this event
{.deprecated: [TEvent: Event, TEventFunc: EventFunc, TClaroObj: ClaroObj,
TEventIfaceFunc: EventIfaceFunc, TEventHandler: EventHandler].}
# #define event_handler(n) void n ( ClaroObj *object, event_t *event )
#CLVEXP list_t object_list;
proc object_init*(){.cdecl, importc: "object_init", dynlib: clarodll.}
proc object_override_next_size*(size: cint){.cdecl,
importc: "object_override_next_size", dynlib: clarodll.}
## Overrides the size of next object to be created, providing the
## size is more than is requested by default.
##
## `size` specifies the full size, which is greater than both ClaroObj
## and the size that will be requested automatically.
proc event_get_arg_ptr*(e: ptr Event, arg: cint): pointer{.cdecl,
importc: "event_get_arg_ptr", dynlib: clarodll.}
proc event_get_arg_double*(e: ptr Event, arg: cint): cdouble{.cdecl,
importc: "event_get_arg_double", dynlib: clarodll.}
proc event_get_arg_int*(e: ptr Event, arg: cint): cint{.cdecl,
importc: "event_get_arg_int", dynlib: clarodll.}
proc object_create*(parent: ptr ClaroObj, size: int32,
typ: cstring): ptr ClaroObj{.
cdecl, importc: "object_create", dynlib: clarodll.}
proc object_destroy*(obj: ptr ClaroObj){.cdecl, importc: "object_destroy",
dynlib: clarodll.}
proc object_set_parent*(obj: ptr ClaroObj, parent: ptr ClaroObj){.cdecl,
importc: "object_set_parent", dynlib: clarodll.}
##define object_cmptype(o,t) (!strcmp(((ClaroObj *)o)->type,t))
# event functions
proc object_addhandler*(obj: ptr ClaroObj, event: cstring,
fun: EventFunc){.cdecl,
importc: "object_addhandler", dynlib: clarodll.}
proc object_addhandler_interface*(obj: ptr ClaroObj, event: cstring,
fun: EventFunc, data: pointer){.cdecl,
importc: "object_addhandler_interface", dynlib: clarodll.}
proc event_send*(obj: ptr ClaroObj, event: cstring, fmt: cstring): cint{.
varargs, cdecl, importc: "event_send", dynlib: clarodll.}
proc event_get_name*(event: ptr Event): cstring{.cdecl,
importc: "event_get_name", dynlib: clarodll.}
proc claro_base_init(){.cdecl, importc: "claro_base_init", dynlib: clarodll.}
proc claro_loop*(){.cdecl, importc: "claro_loop", dynlib: clarodll.}
proc claro_run*(){.cdecl, importc: "claro_run", dynlib: clarodll.}
proc claro_shutdown*(){.cdecl, importc: "claro_shutdown", dynlib: clarodll.}
proc mssleep*(ms: cint){.cdecl, importc: "mssleep", dynlib: clarodll.}
proc claro_graphics_init(){.cdecl, importc: "claro_graphics_init",
dynlib: clarodll.}
const
cWidgetNoBorder* = (1 shl 24)
cWidgetCustomDraw* = (1 shl 25)
type
Bounds*{.pure.} = object
x*: cint
y*: cint
w*: cint
h*: cint
owner*: ptr ClaroObj
{.deprecated: [TBounds: Bounds].}
const
cSizeRequestChanged* = 1
type
Font*{.pure.} = object
used*: cint
face*: cstring
size*: cint
weight*: cint
slant*: cint
decoration*: cint
native*: pointer
Color*{.pure.} = object
used*: cint
r*: cfloat
g*: cfloat
b*: cfloat
a*: cfloat
Widget* {.pure.} = object of ClaroObj
size_req*: ptr Bounds
size*: Bounds
size_ct*: Bounds
supports_alpha*: cint
size_flags*: cint
flags*: cint
visible*: cint
notify_flags*: cint
font*: Font
native*: pointer # native widget
ndata*: pointer # additional native data
container*: pointer # native widget container (if not ->native)
naddress*: array[0..3, pointer] # addressed for something
# we override or need to remember
{.deprecated: [TFont: Font, TColor: Color, TWidget: Widget].}
proc clipboard_set_text*(w: ptr Widget, text: cstring): cint{.cdecl,
importc: "clipboard_set_text", dynlib: clarodll.}
## Sets the (text) clipboard to the specified text value.
##
## `w` The widget requesting the action, some platforms may use this value.
## `text` The text to place in the clipboard.
## returns 1 on success, 0 on failure.
const
cNotifyMouse* = 1'i32
cNotifyKey* = 2'i32
cFontSlantNormal* = 0
cFontSlantItalic* = 1
cFontWeightNormal* = 0
cFontWeightBold* = 1
cFontDecorationNormal* = 0
cFontDecorationUnderline* = 1
proc widget_set_font*(widget: ptr ClaroObj, face: cstring, size: cint,
weight: cint, slant: cint, decoration: cint){.cdecl,
importc: "widget_set_font", dynlib: clarodll.}
## Sets the font details of the specified widget.
##
## `widget` A widget
## `face` Font face string
## `size` Size of the font in pixels
## `weight` The weight of the font
## `slant` The sland of the font
## `decoration` The decoration of the font
proc widget_font_string_width*(widget: ptr ClaroObj, text: cstring,
chars: cint): cint {.
cdecl, importc: "widget_font_string_width", dynlib: clarodll.}
## Calculates the pixel width of the text in the widget's font.
## `chars` is the number of characters of text to calculate. Return value
## is the width of the specified text in pixels.
const
CLARO_APPLICATION* = "claro.graphics"
type
Image* {.pure.} = object of ClaroObj
width*: cint
height*: cint
native*: pointer
native2*: pointer
native3*: pointer
icon*: pointer
{.deprecated: [TImage: Image].}
proc image_load*(parent: ptr ClaroObj, file: cstring): ptr Image{.cdecl,
importc: "image_load", dynlib: clarodll.}
## Loads an image from a file and returns a new image object.
##
## The supported formats depend on the platform.
## The main effort is to ensure that PNG images will always work.
## Generally, JPEGs and possibly GIFs will also work.
##
## `Parent` object (usually the application's main window), can be nil.
proc image_load_inline_png*(parent: ptr ClaroObj, data: cstring,
len: cint): ptr Image{.cdecl,
importc: "image_load_inline_png", dynlib: clarodll.}
## Loads an image from inline data and returns a new image object.
## `Parent` object (usually the application's main window), can be nil.
## data raw PNG image
## len size of data
when true:
discard
else:
# status icons are not supported on all platforms yet:
type
StatusIcon* {.pure.} = object of ClaroObj
icon*: ptr Image
native*: pointer
native2*: pointer
{.deprecated: [TStatusIcon: StatusIcon].}
#*
# \brief Creates a status icon
#
# \param parent Parent object (usually the application's main window),
# can be NULL.
# \param image The image object for the icon NOT NULL
# \param flags Flags
# \return New status_icon_t object
#
proc status_icon_create*(parent: ptr ClaroObj, icon: ptr Image,
flags: cint): ptr StatusIcon {.
cdecl, importc: "status_icon_create", dynlib: clarodll.}
#*
# \brief sets the status icon's image
#
# \param status Status Icon
# \param image The image object for the icon
#
proc status_icon_set_icon*(status: ptr StatusIcon, icon: ptr Image){.cdecl,
importc: "status_icon_set_icon", dynlib: clarodll.}
#*
# \brief sets the status icons's menu
#
# \param status Status Icon
# \param menu The menu object for the popup menu
#
proc status_icon_set_menu*(status: ptr StatusIcon, menu: ptr ClaroObj){.cdecl,
importc: "status_icon_set_menu", dynlib: clarodll.}
#*
# \brief sets the status icon's visibility
#
# \param status Status Icon
# \param visible whether the status icon is visible or not
#
proc status_icon_set_visible*(status: ptr StatusIcon, visible: cint){.cdecl,
importc: "status_icon_set_visible", dynlib: clarodll.}
#*
# \brief sets the status icon's tooltip
#
# \param status Status Icon
# \param tooltip Tooltip string
#
proc status_icon_set_tooltip*(status: ptr StatusIcon, tooltip: cstring){.cdecl,
importc: "status_icon_set_tooltip", dynlib: clarodll.}
#*
# \brief Makes the specified widget visible.
#
# \param widget A widget
#
proc widget_show*(widget: ptr Widget){.cdecl, importc: "widget_show",
dynlib: clarodll.}
#*
# \brief Makes the specified widget invisible.
#
# \param widget A widget
#
proc widget_hide*(widget: ptr Widget){.cdecl, importc: "widget_hide",
dynlib: clarodll.}
#*
# \brief Enables the widget, allowing focus
#
# \param widget A widget
#
proc widget_enable*(widget: ptr Widget){.cdecl, importc: "widget_enable",
dynlib: clarodll.}
#*
# \brief Disables the widget
# When disabled, a widget appears greyed and cannot
# receive focus.
#
# \param widget A widget
#
proc widget_disable*(widget: ptr Widget){.cdecl, importc: "widget_disable",
dynlib: clarodll.}
#*
# \brief Give focus to the specified widget
#
# \param widget A widget
#
proc widget_focus*(widget: ptr Widget){.cdecl, importc: "widget_focus",
dynlib: clarodll.}
#*
# \brief Closes a widget
#
# Requests that a widget be closed by the platform code.
# This may or may not result in immediate destruction of the widget,
# however the actual Claro widget object will remain valid until at
# least the next loop iteration.
#
# \param widget A widget
#
proc widget_close*(widget: ptr Widget){.cdecl, importc: "widget_close",
dynlib: clarodll.}
#*
# \brief Retrieve the screen offset of the specified widget.
#
# Retrieves the X and Y screen positions of the widget.
#
# \param widget A widget
# \param dx Pointer to the location to place the X position.
# \param dy Pointer to the location to place the Y position.
#
proc widget_screen_offset*(widget: ptr Widget, dx: ptr cint, dy: ptr cint){.
cdecl, importc: "widget_screen_offset", dynlib: clarodll.}
#*
# \brief Sets the additional notify events that should be sent.
#
# For performance reasons, some events, like mouse and key events,
# are not sent by default. By specifying such events here, you can
# elect to receive these events.
#
# \param widget A widget
# \param flags Any number of cWidgetNotify flags ORed together.
#
proc widget_set_notify*(widget: ptr Widget, flags: cint){.cdecl,
importc: "widget_set_notify", dynlib: clarodll.}
type
CursorType* {.size: sizeof(cint).} = enum
cCursorNormal = 0,
cCursorTextEdit = 1,
cCursorWait = 2,
cCursorPoint = 3
{.deprecated: [TCursorType: CursorType].}
#*
# \brief Sets the mouse cursor for the widget
#
# \param widget A widget
# \param cursor A valid cCursor* value
#
proc widget_set_cursor*(widget: ptr Widget, cursor: CursorType){.cdecl,
importc: "widget_set_cursor", dynlib: clarodll.}
#*
# \brief Retrieves the key pressed in a key notify event.
#
# \param widget A widget
# \param event An event resource
# \return The keycode of the key pressed.
#
proc widget_get_notify_key*(widget: ptr Widget, event: ptr Event): cint{.
cdecl, importc: "widget_get_notify_key", dynlib: clarodll.}
#*
# \brief Updates the bounds structure with new values
#
# This function should \b always be used instead of setting the
# members manually. In the future, there may be a \b real reason
# for this.
#
# \param bounds A bounds structure
# \param x The new X position
# \param y The new Y position
# \param w The new width
# \param h The new height
#
proc bounds_set*(bounds: ptr Bounds, x: cint, y: cint, w: cint, h: cint){.
cdecl, importc: "bounds_set", dynlib: clarodll.}
#*
# \brief Create a new bounds object
#
# Creates a new bounds_t for the specified bounds.
#
# \param x X position
# \param y Y position
# \param w Width
# \param h Height
# \return A new bounds_t structure
#
proc new_bounds*(x: cint, y: cint, w: cint, h: cint): ptr Bounds{.cdecl,
importc: "new_bounds", dynlib: clarodll.}
proc get_req_bounds*(widget: ptr Widget): ptr Bounds{.cdecl,
importc: "get_req_bounds", dynlib: clarodll.}
var
noBoundsVar: Bounds # set to all zero which is correct
template noBounds*: expr = (addr(bind noBoundsVar))
#* \internal
# \brief Internal pre-inititalisation hook
#
# \param widget A widget
#
proc widget_pre_init*(widget: ptr Widget){.cdecl, importc: "widget_pre_init",
dynlib: clarodll.}
#* \internal
# \brief Internal post-inititalisation hook
#
# \param widget A widget
#
proc widget_post_init*(widget: ptr Widget){.cdecl,
importc: "widget_post_init", dynlib: clarodll.}
#* \internal
# \brief Internal resize event handler
#
# \param obj An object
# \param event An event resource
#
proc widget_resized_handle*(obj: ptr Widget, event: ptr Event){.cdecl,
importc: "widget_resized_handle", dynlib: clarodll.}
# CLVEXP bounds_t no_bounds;
#* \internal
# \brief Internal default widget creation function
#
# \param parent The parent of the widget
# \param widget_size The size in bytes of the widget's structure
# \param widget_name The object type of the widget (claro.graphics.widgets.*)
# \param size_req The initial bounds of the widget
# \param flags Widget flags
# \param creator The platform function that will be called to actually create
# the widget natively.
# \return A new widget object
#
type
CgraphicsCreateFunction* = proc (widget: ptr Widget) {.cdecl.}
{.deprecated: [TcgraphicsCreateFunction: CgraphicsCreateFunction].}
proc newdefault*(parent: ptr Widget, widget_size: int,
widget_name: cstring, size_req: ptr Bounds, flags: cint,
creator: CgraphicsCreateFunction): ptr Widget{.cdecl,
importc: "default_widget_create", dynlib: clarodll.}
#* \internal
# \brief Retrieves the native container of the widget's children
#
# \param widget A widget
# \return A pointer to the native widget that will hold w's children
#
proc widget_get_container*(widget: ptr Widget): pointer{.cdecl,
importc: "widget_get_container", dynlib: clarodll.}
#* \internal
# \brief Sets the content size of the widget.
#
# \param widget A widget
# \param w New width of the content area of the widget
# \param h New height of the content area of the widget
# \param event Whether to send a content_size event
#
proc widget_set_content_size*(widget: ptr Widget, w: cint, h: cint,
event: cint){.cdecl,
importc: "widget_set_content_size", dynlib: clarodll.}
#* \internal
# \brief Sets the size of the widget.
#
# \param widget A widget
# \param w New width of the widget
# \param h New height of the widget
# \param event Whether to send a resize event
#
proc widget_set_size*(widget: ptr Widget, w: cint, h: cint, event: cint){.
cdecl, importc: "widget_set_size", dynlib: clarodll.}
#* \internal
# \brief Sets the position of the widget's content area.
#
# \param widget A widget
# \param x New X position of the widget's content area
# \param y New Y position of the widget's content area
# \param event Whether to send a content_move event
#
proc widget_set_content_position*(widget: ptr Widget, x: cint, y: cint,
event: cint){.cdecl,
importc: "widget_set_content_position", dynlib: clarodll.}
#* \internal
# \brief Sets the position of the widget.
#
# \param widget A widget
# \param x New X position of the widget's content area
# \param y New Y position of the widget's content area
# \param event Whether to send a moved event
#
proc widget_set_position*(widget: ptr Widget, x: cint, y: cint, event: cint){.
cdecl, importc: "widget_set_position", dynlib: clarodll.}
#* \internal
# \brief Sends a destroy event to the specified widget.
#
# You should use widget_close() in application code instead.
#
# \param widget A widget
#
proc widget_destroy*(widget: ptr Widget){.cdecl, importc: "widget_destroy",
dynlib: clarodll.}
type
OpenglWidget* {.pure.} = object of Widget
gldata*: pointer
{.deprecated: [TOpenglWidget: OpenglWidget].}
# functions
#*
# \brief Creates a OpenGL widget
#
# \param parent The parent widget of this widget, NOT NULL.
# \param bounds The initial bounds of this widget, or NO_BOUNDS.
# \param flags Widget flags.
# \return A new OpenGL widget object.
#
proc newopengl*(parent: ptr ClaroObj, bounds: ptr Bounds,
flags: cint): ptr OpenglWidget {.
cdecl, importc: "opengl_widget_create", dynlib: clarodll.}
#*
# \brief Flips the front and back buffers
#
# \param widget A valid OpenGL widget object
#
proc opengl_flip*(widget: ptr OpenglWidget) {.cdecl, importc: "opengl_flip",
dynlib: clarodll.}
#*
# \brief Activates this OpenGL widget's context
#
# \param widget A valid OpenGL widget object
#
proc opengl_activate*(widget: ptr OpenglWidget) {.
cdecl, importc: "opengl_activate", dynlib: clarodll.}
type
Button* {.pure.} = object of Widget
text*: array[0..256-1, char]
{.deprecated: [TButton: Button].}
# functions
#*
# \brief Creates a Button widget
#
# \param parent The parent widget of this widget, NOT NULL.
# \param bounds The initial bounds of this widget, or NO_BOUNDS.
# \param flags Widget flags.
# \return A new Button widget object.
#
proc newbutton*(parent: ptr ClaroObj, bounds: ptr Bounds,
flags: cint): ptr Button {.
cdecl, importc: "button_widget_create", dynlib: clarodll.}
#*
# \brief Creates a Button widget with a label
#
# \param parent The parent widget of this widget, NOT NULL.
# \param bounds The initial bounds of this widget, or NO_BOUNDS.
# \param flags Widget flags.
# \param label The label for the button
# \return A new Button widget object.
#
proc newbutton*(parent: ptr ClaroObj,
bounds: ptr Bounds, flags: cint,
label: cstring): ptr Button{.cdecl,
importc: "button_widget_create_with_label", dynlib: clarodll.}
#*
# \brief Changes the label of the button
#
# \param obj A valid Button widget object
# \param label The new label for the button
#
proc button_set_text*(obj: ptr Button, label: cstring){.cdecl,
importc: "button_set_label", dynlib: clarodll.}
#*
# \brief Changes the image of the button
#
# \warning This function is not implemented yet and is not portable.
# Do not use it.
#
# \param obj A valid Button widget object
# \param image The new image for the button
#
proc button_set_image*(obj: ptr Button, image: ptr Image){.cdecl,
importc: "button_set_image", dynlib: clarodll.}
const
CTEXT_SLANT_NORMAL* = cFontSlantNormal
CTEXT_SLANT_ITALIC* = cFontSlantItalic
CTEXT_WEIGHT_NORMAL* = cFontWeightNormal
CTEXT_WEIGHT_BOLD* = cFontWeightBold
CTEXT_EXTRA_NONE* = cFontDecorationNormal
CTEXT_EXTRA_UNDERLINE* = cFontDecorationUnderline
# END OLD
type
Canvas*{.pure.} = object of Widget
surface*: cairo.PSurface
cr*: cairo.PContext
surfdata*: pointer
fontdata*: pointer
font_height*: cint
fr*: cfloat
fg*: cfloat
fb*: cfloat
fa*: cfloat
br*: cfloat
bg*: cfloat
bb*: cfloat
ba*: cfloat
charsize*: array[0..256 - 1, cairo.TTextExtents]
csz_loaded*: cint
fontsize*: cint
{.deprecated: [TCanvas: Canvas].}
# functions
#*
# \brief Creates a Canvas widget
#
# \param parent The parent widget of this widget, NOT NULL.
# \param bounds The initial bounds of this widget, or NO_BOUNDS.
# \param flags Widget flags.
# \return A new Canvas widget object.
#
proc newcanvas*(parent: ptr ClaroObj, bounds: ptr Bounds,
flags: cint): ptr Canvas{.
cdecl, importc: "canvas_widget_create", dynlib: clarodll.}
#*
# \brief Invalidates and redraws a canvas widget
#
# \param widget A valid Canvas widget object.
#
proc canvas_redraw*(widget: ptr Canvas){.cdecl, importc: "canvas_redraw",
dynlib: clarodll.}
# claro text functions
#*
# \brief Set the current text color
#
# \param widget A valid Canvas widget object.
# \param r Red component (0.0 - 1.0)
# \param g Green component (0.0 - 1.0)
# \param b Blue component (0.0 - 1.0)
# \param a Alpha component (0.0 - 1.0)
#
proc canvas_set_text_color*(widget: ptr Canvas, r: cdouble, g: cdouble,
b: cdouble, a: cdouble){.cdecl,
importc: "canvas_set_text_color", dynlib: clarodll.}
#*
# \brief Set the current text background color
#
# \param widget A valid Canvas widget object.
# \param r Red component (0.0 - 1.0)
# \param g Green component (0.0 - 1.0)
# \param b Blue component (0.0 - 1.0)
# \param a Alpha component (0.0 - 1.0)
#
proc canvas_set_text_bgcolor*(widget: ptr Canvas, r: cdouble, g: cdouble,
b: cdouble, a: cdouble){.cdecl,
importc: "canvas_set_text_bgcolor", dynlib: clarodll.}
#*
# \brief Set the current canvas font
#
# \param widget A valid Canvas widget object.
# \param face The font face
# \param size The font height in pixels
# \param weight The weight of the font
# \param slant The slant of the font
# \param decoration Font decorations
#
proc canvas_set_text_font*(widget: ptr Canvas, face: cstring, size: cint,
weight: cint, slant: cint, decoration: cint){.cdecl,
importc: "canvas_set_text_font", dynlib: clarodll.}
#*
# \brief Calculates the width of the specified text
#
# \param widget A valid Canvas widget object.
# \param text The text to calulate the length of
# \param len The number of characters of text to calulcate
# \return Width of the text in pixels
#
proc canvas_text_width*(widget: ptr Canvas, text: cstring, len: cint): cint{.
cdecl, importc: "canvas_text_width", dynlib: clarodll.}
#*
# \brief Calculates the width of the specified text's bounding box
#
# \param widget A valid Canvas widget object.
# \param text The text to calulate the length of
# \param len The number of characters of text to calulcate
# \return Width of the text's bounding box in pixels
#
proc canvas_text_box_width*(widget: ptr Canvas, text: cstring,
len: cint): cint{.
cdecl, importc: "canvas_text_box_width", dynlib: clarodll.}
#*
# \brief Calculates the number of characters of text that can be displayed
# before width pixels.
#
# \param widget A valid Canvas widget object.
# \param text The text to calulate the length of
# \param width The width to fit the text in
# \return The number of characters of text that will fit in width pixels.
#
proc canvas_text_display_count*(widget: ptr Canvas, text: cstring,
width: cint): cint{.cdecl,
importc: "canvas_text_display_count", dynlib: clarodll.}
#*
# \brief Displays the specified text on the canvas
#
# \param widget A valid Canvas widget object.
# \param x The X position at which the text will be drawn
# \param y The Y position at which the text will be drawn
# \param text The text to calulate the length of
# \param len The number of characters of text to calulcate
#
proc canvas_show_text*(widget: ptr Canvas, x: cint, y: cint, text: cstring,
len: cint){.cdecl, importc: "canvas_show_text",
dynlib: clarodll.}
#*
# \brief Draws a filled rectangle
#
# \param widget A valid Canvas widget object.
# \param x The X position at which the rectangle will start
# \param y The Y position at which the rectangle will start
# \param w The width of the rectangle
# \param h The height of the rectangle
# \param r Red component (0.0 - 1.0)
# \param g Green component (0.0 - 1.0)
# \param b Blue component (0.0 - 1.0)
# \param a Alpha component (0.0 - 1.0)
#
proc canvas_fill_rect*(widget: ptr Canvas, x: cint, y: cint, w: cint,
h: cint, r, g, b, a: cdouble){.
cdecl, importc: "canvas_fill_rect", dynlib: clarodll.}
#*
# \brief Draws the specified image on the canvas
#
# \param widget A valid Canvas widget object.
# \param image The image to draw
# \param x The X position at which the image will be drawn
# \param y The Y position at which the image will be drawn
#
proc canvas_draw_image*(widget: ptr Canvas, image: ptr Image, x: cint,
y: cint){.cdecl, importc: "canvas_draw_image",
dynlib: clarodll.}
# claro "extensions" of cairo
#* \internal
# \brief Internal claro extension of cairo text functions
#
proc canvas_cairo_buffered_text_width*(widget: ptr Canvas,
text: cstring, len: cint): cint{.cdecl,
importc: "canvas_cairo_buffered_text_width", dynlib: clarodll.}
#* \internal
# \brief Internal claro extension of cairo text functions
#
proc canvas_cairo_buffered_text_display_count*(widget: ptr Canvas,
text: cstring, width: cint): cint{.cdecl,
importc: "canvas_cairo_buffered_text_display_count",
dynlib: clarodll.}
proc canvas_get_cairo_context*(widget: ptr Canvas): cairo.PContext {.cdecl,
importc: "canvas_get_cairo_context", dynlib: clarodll.}
type
CheckBox*{.pure.} = object of Widget
text*: array[0..256-1, char]
checked*: cint
{.deprecated: [TCheckBox: CheckBox].}
#*
# \brief Creates a Checkbox widget
#
# \param parent The parent widget of this widget, NOT NULL.
# \param bounds The initial bounds of this widget, or NO_BOUNDS.
# \param flags Widget flags.
# \return A new Checkbox widget object.
#
proc newcheckbox*(parent: ptr ClaroObj, bounds: ptr Bounds,
flags: cint): ptr CheckBox{.
cdecl, importc: "checkbox_widget_create", dynlib: clarodll.}
#*
# \brief Creates a Checkbox widget with a label
#
# \param parent The parent widget of this widget, NOT NULL.
# \param bounds The initial bounds of this widget, or NO_BOUNDS.
# \param flags Widget flags.
# \param label The label for the checkbox
# \return A new Checkbox widget object.
#
proc newcheckbox*(parent: ptr ClaroObj,
bounds: ptr Bounds, flags: cint,
label: cstring): ptr CheckBox {.cdecl,
importc: "checkbox_widget_create_with_label", dynlib: clarodll.}
#*
# \brief Sets a new label for the Checkbox widget
#
# \param obj A valid Checkbox widget object.
# \param label The new label for the checkbox
#
proc checkbox_set_text*(obj: ptr CheckBox, label: cstring){.cdecl,
importc: "checkbox_set_label", dynlib: clarodll.}
#*
# \brief Retrieves the checkbox's check state
#
# \param obj A valid Checkbox widget object.
# \return 1 if the checkbox is checked, otherwise 0
#
proc checkbox_checked*(obj: ptr CheckBox): cint{.cdecl,
importc: "checkbox_get_checked", dynlib: clarodll.}
#*
# \brief Sets the checkbox's checked state
#
# \param obj A valid Checkbox widget object.
# \param checked 1 if the checkbox should become checked, otherwise 0
#
proc checkbox_set_checked*(obj: ptr CheckBox, checked: cint){.cdecl,
importc: "checkbox_set_checked", dynlib: clarodll.}
#*
# List items define items in a list_widget
#
type
ListItem*{.pure.} = object of ClaroObj
row*: cint
native*: pointer
nativeid*: int
menu*: ptr ClaroObj
enabled*: cint
data*: ptr pointer
ListItemChildren*: List
ListItemParent*: ptr List
parent_item*: ptr ListItem # drawing related info, not always required
text_color*: Color
sel_text_color*: Color
back_color*: Color
sel_back_color*: Color
font*: Font
ListWidget* {.pure.} = object of Widget ## List widget, base for
## widgets containing items
columns*: cint
coltypes*: ptr cint
items*: List
Combo*{.pure.} = object of ListWidget
selected*: ptr ListItem
{.deprecated: [TListItem: ListItem, TListWidget: ListWidget, TCombo: Combo].}
# functions
#*
# \brief Creates a Combo widget
#
# \param parent The parent widget of this widget, NOT NULL.
# \param bounds The initial bounds of this widget, or NO_BOUNDS.
# \param flags Widget flags.
# \return A new Combo widget object.
#
proc newcombo*(parent: ptr ClaroObj, bounds: ptr Bounds,
flags: cint): ptr Combo{.
cdecl, importc: "combo_widget_create", dynlib: clarodll.}
#*
# \brief Append a row to a Combo widget
#
# \param combo A valid Combo widget object.
# \param text The text for the item.
# \return A new list item.
#
proc combo_append_row*(combo: ptr Combo, text: cstring): ptr ListItem {.
cdecl, importc: "combo_append_row", dynlib: clarodll.}
#*
# \brief Insert a row at the specified position into a Combo widget
#
# \param combo A valid Combo widget object.
# \param pos The index at which this item will be placed.
# \param text The text for the item.
# \return A new list item.
#
proc combo_insert_row*(combo: ptr Combo, pos: cint,
text: cstring): ptr ListItem {.
cdecl, importc: "combo_insert_row", dynlib: clarodll.}
#*
# \brief Move a row in a Combo widget
#
# \param combo A valid Combo widget object.
# \param item A valid list item
# \param row New position to place this item
#
proc combo_move_row*(combo: ptr Combo, item: ptr ListItem, row: cint){.
cdecl, importc: "combo_move_row", dynlib: clarodll.}
#*
# \brief Remove a row from a Combo widget
#
# \param combo A valid Combo widget object.
# \param item A valid list item
#
proc combo_remove_row*(combo: ptr Combo, item: ptr ListItem){.cdecl,
importc: "combo_remove_row", dynlib: clarodll.}
#*
# \brief Returns the currently selected Combo item
#
# \param obj A valid Combo widget object.
# \return The currently selected Combo item, or NULL if no item is selected.
#
proc combo_get_selected*(obj: ptr Combo): ptr ListItem{.cdecl,
importc: "combo_get_selected", dynlib: clarodll.}
#*
# \brief Returns the number of rows in a Combo widget
#
# \param obj A valid Combo widget object.
# \return Number of rows
#
proc combo_get_rows*(obj: ptr Combo): cint{.cdecl,
importc: "combo_get_rows", dynlib: clarodll.}
#*
# \brief Selects a row in a Combo widget
#
# \param obj A valid Combo widget object.
# \param item A valid list item
#
proc combo_select_item*(obj: ptr Combo, item: ptr ListItem){.cdecl,
importc: "combo_select_item", dynlib: clarodll.}
#*
# \brief Removes all entries from a Combo widget
#
# \param obj A valid Combo widget object.
#
proc combo_clear*(obj: ptr Combo){.cdecl, importc: "combo_clear",
dynlib: clarodll.}
type
ContainerWidget* {.pure.} = object of Widget
{.deprecated: [TContainerWidget: ContainerWidget].}
# functions
#*
# \brief Creates a Container widget
#
# \param parent The parent widget of this widget, NOT NULL.
# \param bounds The initial bounds of this widget, or NO_BOUNDS.
# \param flags Widget flags.
# \return A new Container widget object.
#
proc newcontainer*(parent: ptr ClaroObj, bounds: ptr Bounds,
flags: cint): ptr ContainerWidget{.
cdecl, importc: "container_widget_create", dynlib: clarodll.}
proc newdialog*(parent: ptr ClaroObj, bounds: ptr Bounds, format: cstring,
flags: cint): ptr ClaroObj{.cdecl,
importc: "dialog_widget_create", dynlib: clarodll.}
proc dialog_set_text*(obj: ptr ClaroObj, text: cstring){.cdecl,
importc: "dialog_set_text", dynlib: clarodll.}
proc dialog_set_default_icon*(typ: cstring, file: cstring){.cdecl,
importc: "dialog_set_default_icon", dynlib: clarodll.}
proc dialog_get_default_icon*(dialog_type: cint): cstring{.cdecl,
importc: "dialog_get_default_icon", dynlib: clarodll.}
proc dialog_warning*(format: cstring, text: cstring): cint{.cdecl,
importc: "dialog_warning", dynlib: clarodll.}
proc dialog_info*(format: cstring, text: cstring): cint{.cdecl,
importc: "dialog_info", dynlib: clarodll.}
proc dialog_error*(format: cstring, text: cstring): cint{.cdecl,
importc: "dialog_error", dynlib: clarodll.}
proc dialog_other*(format: cstring, text: cstring, default_icon: cstring): cint{.
cdecl, importc: "dialog_other", dynlib: clarodll.}
type
FontDialog* {.pure.} = object of Widget
selected*: Font
{.deprecated: [TFontDialog: FontDialog].}
# functions
#*
# \brief Creates a Font Selection widget
#
# \param parent The parent widget of this widget, NOT NULL.
# \param flags Widget flags.
# \return A new Font Selection widget object.
#
proc newFontDialog*(parent: ptr ClaroObj, flags: cint): ptr FontDialog {.
cdecl, importc: "font_dialog_widget_create", dynlib: clarodll.}
#*
# \brief Changes the selected font
#
# \param obj A valid Font Selection widget object
# \param font The name of the font
#
proc font_dialog_set_font*(obj: ptr FontDialog, face: cstring, size: cint,
weight: cint, slant: cint, decoration: cint){.cdecl,
importc: "font_dialog_set_font", dynlib: clarodll.}
#*
# \brief Returns a structure representing the currently selected font
#
# \param obj A valid Font Selection widget object
# \return A font_t structure containing information about the selected font.
#
proc font_dialog_get_font*(obj: ptr FontDialog): ptr Font{.cdecl,
importc: "font_dialog_get_font", dynlib: clarodll.}
type
Frame* {.pure.} = object of Widget
text*: array[0..256-1, char]
{.deprecated: [TFrame: Frame].}
#*
# \brief Creates a Frame widget
#
# \param parent The parent widget of this widget, NOT NULL.
# \param bounds The initial bounds of this widget, or NO_BOUNDS.
# \param flags Widget flags.
# \return A new Frame widget object.
#
proc newframe*(parent: ptr ClaroObj, bounds: ptr Bounds,
flags: cint): ptr Frame{.
cdecl, importc: "frame_widget_create", dynlib: clarodll.}
#*
# \brief Creates a Frame widget with a label
#
# \param parent The parent widget of this widget, NOT NULL.
# \param bounds The initial bounds of this widget, or NO_BOUNDS.
# \param flags Widget flags.
# \param label The initial label for the frame
# \return A new Frame widget object.
#
proc newframe*(parent: ptr ClaroObj, bounds: ptr Bounds, flags: cint,
label: cstring): ptr Frame {.cdecl,
importc: "frame_widget_create_with_label", dynlib: clarodll.}
#*
# \brief Creates a Container widget
#
# \param parent The parent widget of this widget, NOT NULL.
# \param bounds The initial bounds of this widget, or NO_BOUNDS.
# \param flags Widget flags.
# \return A new Container widget object.
#
proc frame_set_text*(frame: ptr Frame, label: cstring){.cdecl,
importc: "frame_set_label", dynlib: clarodll.}
type
ImageWidget* {.pure.} = object of Widget
src*: ptr Image
{.deprecated: [TImageWidget: ImageWidget].}
#*
# \brief Creates an Image widget
#
# \param parent The parent widget of this widget, NOT NULL.
# \param bounds The initial bounds of this widget, or NO_BOUNDS.
# \param flags Widget flags.
# \return A new Image widget object.
#
proc newimageWidget*(parent: ptr ClaroObj, bounds: ptr Bounds,
flags: cint): ptr ImageWidget{.
cdecl, importc: "image_widget_create", dynlib: clarodll.}
#*
# \brief Creates an Image widget with an image
#
# \param parent The parent widget of this widget, NOT NULL.
# \param bounds The initial bounds of this widget, or NO_BOUNDS.
# \param flags Widget flags.
# \param image A valid Image object.
# \return A new Image widget object.
#
proc newimageWidget*(parent: ptr ClaroObj,
bounds: ptr Bounds, flags: cint,
image: ptr Image): ptr ImageWidget{.cdecl,
importc: "image_widget_create_with_image", dynlib: clarodll.}
#*
# \brief Sets the image object of the image widget
#
# \param image A valid image widget
# \param src The source image object
#
proc image_set_image*(image: ptr ImageWidget, src: ptr Image){.cdecl,
importc: "image_set_image", dynlib: clarodll.}
type
Label*{.pure.} = object of Widget
text*: array[0..256-1, char]
CLabelJustify* = enum
cLabelLeft = 0x00000001, cLabelRight = 0x00000002,
cLabelCenter = 0x00000004, cLabelFill = 0x00000008
{.deprecated: [TLabel: Label, TcLabelJustify: CLabelJustify].}
#*
# \brief Creates a Label widget
#
# \param parent The parent widget of this widget, NOT NULL.
# \param bounds The initial bounds of this widget, or NO_BOUNDS.
# \param flags Widget flags.
# \return A new Label widget object.
#
proc newlabel*(parent: ptr ClaroObj, bounds: ptr Bounds,
flags: cint): ptr Label{.
cdecl, importc: "label_widget_create", dynlib: clarodll.}
#*
# \brief Creates a Label widget
#
# \param parent The parent widget of this widget, NOT NULL.
# \param bounds The initial bounds of this widget, or NO_BOUNDS.
# \param flags Widget flags.
# \return A new Label widget object.
#
proc newLabel*(parent: ptr ClaroObj,
bounds: ptr Bounds, flags: cint,
text: cstring): ptr Label{.cdecl,
importc: "label_widget_create_with_text", dynlib: clarodll.}
#*
# \brief Sets the text of a label widget
#
# \param obj A valid label widget
# \param text The text this label widget will show
#
proc label_set_text*(obj: ptr Label, text: cstring){.cdecl,
importc: "label_set_text", dynlib: clarodll.}
#*
# \brief Sets the alignment/justification of a label
#
# \param obj A valid label widget
# \param text The justification (see cLabelJustify enum)
#
proc label_set_justify*(obj: ptr Label, flags: cint){.cdecl,
importc: "label_set_justify", dynlib: clarodll.}
const
CLIST_TYPE_PTR* = 0
CLIST_TYPE_STRING* = 1
CLIST_TYPE_INT* = 2
CLIST_TYPE_UINT* = 3
CLIST_TYPE_DOUBLE* = 4
# functions
#*
# \brief Initialises a list_widget_t derivative's storage space.
#
# \param obj list widget
# \param col_num number of columns to be used
# \param cols An array of col_num integers, specifying the
# types of the columns.
#
proc list_widget_init_ptr*(obj: ptr ListWidget, col_num: cint,
cols: ptr cint) {.cdecl,
importc: "list_widget_init_ptr", dynlib: clarodll.}
#*
# \brief Copies and passes on the arg list to list_widget_init_ptr.
#
# \param obj list widget
# \param col_num number of columns to be used
# \param argpi A pointer to a va_list to parse
#
#proc list_widget_init_vaptr*(obj: ptr ClaroObj, col_num: cunsignedint,
# argpi: va_list){.cdecl,
# importc: "list_widget_init_vaptr", dynlib: clarodll.}
#*
# Shortcut function, simply calls list_widget_init_ptr with
# it's own arguments, and a pointer to the first variable argument.
#
proc list_widget_init*(obj: ptr ListWidget, col_num: cint){.varargs,
cdecl, importc: "list_widget_init", dynlib: clarodll.}
#*
# \brief Inserts a row to a list under parent at the position specified.
#
# \param list list to insert item in
# \param parent item in tree to be used as parent. NULL specifies
# that it should be a root node.
# \param row item will be inserted before the item currently at
# this position. -1 specifies an append.
# \param argp points to the first element of an array containing
# the column data as specified by the types in list_widget_init.
#
#*
# Shortcut function, calls list_widget_row_insert_ptr with
# it's own arguments, a position at the end of the list, and
# a pointer to the first variable argument.
#
proc list_widget_row_append*(list: ptr ListWidget,
parent: ptr ListItem): ptr ListItem{.
varargs, cdecl, importc: "list_widget_row_append", dynlib: clarodll.}
#*
# Shortcut function, calls list_widget_row_insert_ptr with
# it's own arguments, and a pointer to the first variable argument.
#
proc list_widget_row_insert*(list: ptr ListWidget, parent: ptr ListItem,
pos: cint): ptr ListItem {.varargs, cdecl,
importc: "list_widget_row_insert", dynlib: clarodll.}
#*
# \brief Removes a row from a list
#
# \param list List widget to operate on
# \param item The item to remove
#
proc list_widget_row_remove*(list: ptr ListWidget, item: ptr ListItem){.
cdecl, importc: "list_widget_row_remove", dynlib: clarodll.}
#*
# \brief Moves a row to a new position in the list
#
# \param list List widget to operate on
# \param item The item to move
# \param row Row position to place item before. Passing the current
# position will result in no change.
#
proc list_widget_row_move*(list: ptr ListWidget, item: ptr ListItem,
row: cint){.cdecl, importc: "list_widget_row_move",
dynlib: clarodll.}
#*
# \brief Return the nth row under parent in the list
#
# \param list List widget search
# \param parent Parent of the item
# \param row Row index of item to return
#
proc list_widget_get_row*(list: ptr ListWidget, parent: ptr ListItem,
row: cint): ptr ListItem{.cdecl,
importc: "list_widget_get_row", dynlib: clarodll.}
#*
# \brief Edit items of a row in the list.
#
# \param list List widget to edit
# \param item Row to modify
# \param args num,val,...,-1 where num is the column and val is the new
# value of the column's type. Terminate with -1.
# Don't forget the -1.
#
#*
# \brief Edit items of a row in the list.
#
# \param list List-based (list_widget_t) object
# \param item Row to modify
# \param ... num,val,...,-1 where num is the column and val is the new
# value of the column's type. Terminate with -1.
# Don't forget the -1.
#
proc list_widget_edit_row*(list: ptr ListWidget, item: ptr ListItem){.
varargs, cdecl, importc: "list_widget_edit_row", dynlib: clarodll.}
#*
# \brief Set the text color of an item.
# This is currently only supported by the TreeView widget.
#
# \param item Target list item
# \param r Red component between 0.0 and 1.0
# \param g Green component between 0.0 and 1.0
# \param b Blue component between 0.0 and 1.0
# \param a Alpha component between 0.0 and 1.0 (reserved for future use,
# should be 1.0)
#
proc list_item_set_text_color*(item: ptr ListItem, r: cfloat, g: cfloat,
b: cfloat, a: cfloat){.cdecl,
importc: "list_item_set_text_color", dynlib: clarodll.}
#*
# \brief Set the text background color of an item.
# This is currently only supported by the TreeView widget.
#
# \param item Target list item
# \param r Red component between 0.0 and 1.0
# \param g Green component between 0.0 and 1.0
# \param b Blue component between 0.0 and 1.0
# \param a Alpha component between 0.0 and 1.0 (reserved for future use,
# should be 1.0)
#
proc list_item_set_text_bgcolor*(item: ptr ListItem, r: cfloat, g: cfloat,
b: cfloat, a: cfloat){.cdecl,
importc: "list_item_set_text_bgcolor", dynlib: clarodll.}
#*
# \brief Set the text color of a selected item.
# This is currently only supported by the TreeView widget.
#
# \param item Target list item
# \param r Red component between 0.0 and 1.0
# \param g Green component between 0.0 and 1.0
# \param b Blue component between 0.0 and 1.0
# \param a Alpha component between 0.0 and 1.0 (reserved for future use,
# should be 1.0)
#
proc list_item_set_sel_text_color*(item: ptr ListItem, r: cfloat, g: cfloat,
b: cfloat, a: cfloat){.cdecl,
importc: "list_item_set_sel_text_color", dynlib: clarodll.}
#*
# \brief Set the text background color of a selected item.
# This is currently only supported by the TreeView widget.
#
# \param item Target list item
# \param r Red component between 0.0 and 1.0
# \param g Green component between 0.0 and 1.0
# \param b Blue component between 0.0 and 1.0
# \param a Alpha component between 0.0 and 1.0 (reserved for future use,
# should be 1.0)
#
proc list_item_set_sel_text_bgcolor*(item: ptr ListItem, r: cfloat,
g: cfloat, b: cfloat, a: cfloat){.cdecl,
importc: "list_item_set_sel_text_bgcolor", dynlib: clarodll.}
#*
# \brief Set the font details of the specified item.
#
# \param item Target list item
# \param weight The weight of the font
# \param slant The slant of the font
# \param decoration Font decorations
#
proc list_item_set_font_extra*(item: ptr ListItem, weight: cint,
slant: cint, decoration: cint){.cdecl,
importc: "list_item_set_font_extra", dynlib: clarodll.}
type
Listbox* {.pure.} = object of ListWidget
selected*: ptr ListItem
{.deprecated: [TListbox: Listbox].}
# functions
#*
# \brief Creates a ListBox widget
#
# \param parent The parent widget of this widget, NOT NULL.
# \param bounds The initial bounds of this widget, or NO_BOUNDS.
# \param flags Widget flags.
# \return A new ListBox widget object.
#
proc newlistbox*(parent: ptr ClaroObj, bounds: ptr Bounds,
flags: cint): ptr Listbox{.
cdecl, importc: "listbox_widget_create", dynlib: clarodll.}
#*
# \brief Insert a row at the specified position into a ListBox widget
#
# \param listbox A valid ListBox widget object.
# \param pos The index at which this item will be placed.
# \param text The text for the item.
# \return A new list item.
#
proc listbox_insert_row*(listbox: ptr Listbox, pos: cint,
text: cstring): ptr ListItem{.
cdecl, importc: "listbox_insert_row", dynlib: clarodll.}
#*
# \brief Append a row to a ListBox widget
#
# \param listbox A valid ListBox widget object.
# \param text The text for the item.
# \return A new list item.
#
proc listbox_append_row*(listbox: ptr Listbox, text: cstring): ptr ListItem{.
cdecl, importc: "listbox_append_row", dynlib: clarodll.}
#*
# \brief Move a row in a ListBox widget
#
# \param listbox A valid ListBox widget object.
# \param item A valid list item
# \param row New position to place this item
#
proc listbox_move_row*(listbox: ptr Listbox, item: ptr ListItem, row: cint){.
cdecl, importc: "listbox_move_row", dynlib: clarodll.}
#*
# \brief Remove a row from a ListBox widget
#
# \param listbox A valid ListBox widget object.
# \param item A valid list item
#
proc listbox_remove_row*(listbox: ptr Listbox, item: ptr ListItem){.cdecl,
importc: "listbox_remove_row", dynlib: clarodll.}
#*
# \brief Returns the currently selected ListBox item
#
# \param obj A valid ListBox widget object.
# \return The currently selected ListBox item, or NULL if no item is selected.
#
proc listbox_get_selected*(obj: ptr Listbox): ptr ListItem{.cdecl,
importc: "listbox_get_selected", dynlib: clarodll.}
#*
# \brief Returns the number of rows in a ListBox widget
#
# \param obj A valid ListBox widget object.
# \return Number of rows
#
proc listbox_get_rows*(obj: ptr Listbox): cint{.cdecl,
importc: "listbox_get_rows", dynlib: clarodll.}
#*
# \brief Selects a row in a ListBox widget
#
# \param obj A valid ListBox widget object.
# \param item A valid list item
#
proc listbox_select_item*(obj: ptr Listbox, item: ptr ListItem){.cdecl,
importc: "listbox_select_item", dynlib: clarodll.}
const
cListViewTypeNone* = 0
cListViewTypeText* = 1
cListViewTypeCheckBox* = 2
cListViewTypeProgress* = 3
# whole row checkboxes.. will we really need this? hmm.
const
cListViewRowCheckBoxes* = 1
type
Listview* {.pure.} = object of ListWidget
titles*: cstringArray
nativep*: pointer
selected*: ptr ListItem
{.deprecated: [TListview: Listview].}
# functions
#*
# \brief Creates a ListView widget
#
# \param parent The parent widget of this widget, NOT NULL.
# \param bounds The initial bounds of this widget, or NO_BOUNDS.
# \param flags Widget flags.
# \param columns The number of columns in the listview
# \param ... specifies the titles and types of each column.
# ("Enable",cListViewTypeCheckBox,"Title",cListViewTypeText,...)
# \return A new ListView widget object.
#
proc newlistview*(parent: ptr ClaroObj, bounds: ptr Bounds, columns: cint,
flags: cint): ptr Listview {.varargs, cdecl,
importc: "listview_widget_create", dynlib: clarodll.}
#*
# \brief Append a row to a ListView widget
#
# \param listview A valid ListView widget object.
# \param ... A list of values for each column
# \return A new list item.
#
proc listview_append_row*(listview: ptr Listview): ptr ListItem{.varargs,
cdecl, importc: "listview_append_row", dynlib: clarodll.}
#*
# \brief Insert a row at the specified position into a ListView widget
#
# \param listview A valid ListView widget object.
# \param pos The index at which this item will be placed.
# \param ... A list of values for each column
# \return A new list item.
#
proc listview_insert_row*(listview: ptr Listview, pos: cint): ptr ListItem{.
varargs, cdecl, importc: "listview_insert_row", dynlib: clarodll.}
#*
# \brief Move a row in a ListView widget
#
# \param listview A valid ListView widget object.
# \param item A valid list item
# \param row New position to place this item
#
proc listview_move_row*(listview: ptr Listview, item: ptr ListItem,
row: cint){.cdecl, importc: "listview_move_row",
dynlib: clarodll.}
#*
# \brief Remove a row from a ListView widget
#
# \param listview A valid ListView widget object.
# \param item A valid list item
#
proc listview_remove_row*(listview: ptr Listview, item: ptr ListItem){.
cdecl, importc: "listview_remove_row", dynlib: clarodll.}
#*
# \brief Returns the currently selected ListView item
#
# \param obj A valid ListView widget object.
# \return The currently selected ListView item, or NULL if no item is selected.
#
proc listview_get_selected*(obj: ptr Listview): ptr ListItem{.cdecl,
importc: "listview_get_selected", dynlib: clarodll.}
#*
# \brief Returns the number of rows in a ListView widget
#
# \param obj A valid ListView widget object.
# \return Number of rows
#
proc listview_get_rows*(obj: ptr Listview): cint{.cdecl,
importc: "listview_get_rows", dynlib: clarodll.}
#*
# \brief Selects a row in a ListView widget
#
# \param obj A valid ListView widget object.
# \param item A valid list item
#
proc listview_select_item*(obj: ptr Listview, item: ptr ListItem){.cdecl,
importc: "listview_select_item", dynlib: clarodll.}
const
cMenuPopupAtCursor* = 1
type
Menu* {.pure.} = object of ListWidget
{.deprecated: [TMenu: Menu].}
#*
# \brief Creates a Menu widget
#
# \param parent The parent widget of this widget, NOT NULL.
# \param flags Widget flags.
# \return A new Menu widget object.
#
proc newmenu*(parent: ptr ClaroObj, flags: cint): ptr Menu {.cdecl,
importc: "menu_widget_create", dynlib: clarodll.}
#*
# \brief Append a row to a Menu widget
#
# \param menu A valid Menu widget object.
# \param parent The item to place the new item under, or NULL for a root item.
# \param image An image object, or NULL.
# \param title A string title, or NULL.
# \return A new list item.
#
proc menu_append_item*(menu: ptr Menu, parent: ptr ListItem,
image: ptr Image, title: cstring): ptr ListItem{.
cdecl, importc: "menu_append_item", dynlib: clarodll.}
#*
# \brief Insert a row into a Menu widget
#
# \param menu A valid Menu widget object.
# \param parent The item to place the new item under, or NULL for a root item.
# \param pos The position at which to insert this item
# \param image An image object, or NULL.
# \param title A string title, or NULL.
# \return A new list item.
#
proc menu_insert_item*(menu: ptr Menu, parent: ptr ListItem, pos: cint,
image: ptr Image, title: cstring): ptr ListItem{.
cdecl, importc: "menu_insert_item", dynlib: clarodll.}
#*
# \brief Append a separator to a Menu widget
#
# \param menu A valid Menu widget object.
# \param parent The item to place the new item under, or NULL for a root item.
# \return A new list item.
#
proc menu_append_separator*(menu: ptr Menu,
parent: ptr ListItem): ptr ListItem{.
cdecl, importc: "menu_append_separator", dynlib: clarodll.}
#*
# \brief Insert a separator into a Menu widget
#
# \param menu A valid Menu widget object.
# \param parent The item to place the new item under, or NULL for a root item.
# \param pos The position at which to insert this item
# \return A new list item.
#
proc menu_insert_separator*(menu: ptr Menu, parent: ptr ListItem,
pos: cint): ptr ListItem{.cdecl,
importc: "menu_insert_separator", dynlib: clarodll.}
#*
# \brief Move a row in a Menu widget
#
# \param menu A valid Menu widget object.
# \param item A valid list item
# \param row New position to place this item
#
proc menu_move_item*(menu: ptr Menu, item: ptr ListItem, row: cint){.
cdecl, importc: "menu_move_item", dynlib: clarodll.}
#*
# \brief Remove a row from a Menu widget
#
# \param menu A valid Menu widget object.
# \param item A valid list item
#
proc menu_remove_item*(menu: ptr Menu, item: ptr ListItem){.cdecl,
importc: "menu_remove_item", dynlib: clarodll.}
#*
# \brief Returns the number of rows in a Menu widget
#
# \param obj A valid Menu widget object.
# \param parent Item whose children count to return,
# or NULL for root item count.
# \return Number of rows
#
proc menu_item_count*(obj: ptr Menu, parent: ptr ListItem): cint{.
cdecl, importc: "menu_item_count", dynlib: clarodll.}
#*
# \brief Disables a menu item (no focus and greyed out)
#
# \param menu A valid Menu widget object.
# \param item A valid list item
#
proc menu_disable_item*(menu: ptr Menu, item: ptr ListItem){.cdecl,
importc: "menu_disable_item", dynlib: clarodll.}
#*
# \brief Enables a menu item (allows focus and not greyed out)
#
# \param menu A valid Menu widget object.
# \param item A valid list item
#
proc menu_enable_item*(menu: ptr Menu, item: ptr ListItem){.cdecl,
importc: "menu_enable_item", dynlib: clarodll.}
#*
# \brief Pops up the menu at the position specified
#
# \param menu A valid Menu widget object.
# \param x The X position
# \param y The Y position
# \param flags Flags
#
proc menu_popup*(menu: ptr Menu, x: cint, y: cint, flags: cint){.cdecl,
importc: "menu_popup", dynlib: clarodll.}
#
# Menu modifiers
#
const
cModifierShift* = 1 shl 0
cModifierCommand* = 1 shl 1
type
Menubar* {.pure.} = object of ListWidget
{.deprecated: [TMenubar: Menubar].}
#*
# \brief Creates a MenuBar widget
#
# \param parent The parent widget of this widget, NOT NULL.
# \param flags Widget flags.
# \return A new MenuBar widget object.
#
proc newmenubar*(parent: ptr ClaroObj, flags: cint): ptr Menubar {.cdecl,
importc: "menubar_widget_create", dynlib: clarodll.}
#*
# \brief Add a key binding to a menu items
#
# \param menubar A valid MenuBar widget object.
# \param item The item
# \param utf8_key The key to use, NOT NULL.
# \param modifier The modifier key, or 0.
#
proc menubar_add_key_binding*(menubar: ptr Menubar, item: ptr ListItem,
utf8_key: cstring, modifier: cint){.cdecl,
importc: "menubar_add_key_binding", dynlib: clarodll.}
#*
# \brief Append a row to a MenuBar widget
#
# \param menubar A valid MenuBar widget object.
# \param parent The item to place the new item under, or NULL for a root item.
# \param image An image object, or NULL.
# \param title A string title, or NULL.
# \return A new list item.
#
proc menubar_append_item*(menubar: ptr Menubar, parent: ptr ListItem,
image: ptr Image, title: cstring): ptr ListItem{.
cdecl, importc: "menubar_append_item", dynlib: clarodll.}
#*
# \brief Insert a row into a MenuBar widget
#
# \param menubar A valid MenuBar widget object.
# \param parent The item to place the new item under, or NULL for a root item.
# \param pos The position at which to insert this item
# \param image An image object, or NULL.
# \param title A string title, or NULL.
# \return A new list item.
#
proc menubar_insert_item*(menubar: ptr Menubar, parent: ptr ListItem,
pos: cint, image: ptr Image,
title: cstring): ptr ListItem{.
cdecl, importc: "menubar_insert_item", dynlib: clarodll.}
#*
# \brief Append a separator to a MenuBar widget
#
# \param menubar A valid MenuBar widget object.
# \param parent The item to place the new item under, or NULL for a root item.
# \return A new list item.
#
proc menubar_append_separator*(menubar: ptr Menubar,
parent: ptr ListItem): ptr ListItem{.
cdecl, importc: "menubar_append_separator", dynlib: clarodll.}
#*
# \brief Insert a separator into a MenuBar widget
#
# \param menubar A valid MenuBar widget object.
# \param parent The item to place the new item under, or NULL for a root item.
# \param pos The position at which to insert this item
# \return A new list item.
#
proc menubar_insert_separator*(menubar: ptr Menubar, parent: ptr ListItem,
pos: cint): ptr ListItem{.cdecl,
importc: "menubar_insert_separator", dynlib: clarodll.}
#*
# \brief Move a row in a MenuBar widget
#
# \param menubar A valid MenuBar widget object.
# \param item A valid list item
# \param row New position to place this item
#
proc menubar_move_item*(menubar: ptr Menubar, item: ptr ListItem,
row: cint){.cdecl, importc: "menubar_move_item",
dynlib: clarodll.}
#*
# \brief Remove a row from a MenuBar widget
#
# \param menubar A valid MenuBar widget object.
# \param item A valid list item
#
proc menubar_remove_item*(menubar: ptr Menubar, item: ptr ListItem) {.
cdecl, importc: "menubar_remove_item", dynlib: clarodll.}
#*
# \brief Returns the number of rows in a MenuBar widget
#
# \param obj A valid MenuBar widget object.
# \param parent Item whose children count to return, or NULL for root
# item count.
# \return Number of rows
#
proc menubar_item_count*(obj: ptr Menubar, parent: ptr ListItem): cint{.
cdecl, importc: "menubar_item_count", dynlib: clarodll.}
#*
# \brief Disables a menu item (no focus and greyed out)
#
# \param menubar A valid MenuBar widget object.
# \param item A valid list item
#
proc menubar_disable_item*(menubar: ptr Menubar, item: ptr ListItem){.
cdecl, importc: "menubar_disable_item", dynlib: clarodll.}
#*
# \brief Enables a menu item (allows focus and not greyed out)
#
# \param menubar A valid MenuBar widget object.
# \param item A valid list item
#
proc menubar_enable_item*(menubar: ptr Menubar, item: ptr ListItem){.
cdecl, importc: "menubar_enable_item", dynlib: clarodll.}
type
Progress* {.pure.} = object of Widget
CProgressStyle* = enum
cProgressLeftRight = 0x00000000, cProgressRightLeft = 0x00000001,
cProgressTopBottom = 0x00000002, cProgressBottomTop = 0x00000004
{.deprecated: [TProgress: Progress, TcProgressStyle: CProgressStyle].}
#*
# \brief Creates a Progress widget
#
# \param parent The parent widget of this widget, NOT NULL.
# \param bounds The initial bounds of this widget, or NO_BOUNDS.
# \param flags Widget flags.
# \return A new Progress widget object.
#
proc newprogress*(parent: ptr ClaroObj, bounds: ptr Bounds,
flags: cint): ptr Progress {.
cdecl, importc: "progress_widget_create", dynlib: clarodll.}
#*
# \brief Sets the value of a progress widget
#
# \param progress A valid progress widget object
# \param percentage Progress value
#
proc progress_set_level*(progress: ptr Progress, percentage: cdouble){.cdecl,
importc: "progress_set_level", dynlib: clarodll.}
#*
# \brief Sets the orientation of a progress widget
#
# \param progress A valid progress widget object
# \param flags One of the cProgressStyle values
#
proc progress_set_orientation*(progress: ptr Progress, flags: cint){.cdecl,
importc: "progress_set_orientation", dynlib: clarodll.}
type
RadioGroup* {.pure.} = object of ClaroObj
buttons*: List
selected*: ptr ClaroObj
ndata*: pointer
RadioButton* {.pure.} = object of Widget
text*: array[0..256-1, char]
group*: ptr RadioGroup
{.deprecated: [TRadioGroup: RadioGroup, TRadioButton: RadioButton].}
#*
# \brief Creates a Radio Group widget
#
# \param parent The parent widget of this widget, NOT NULL.
# \param flags Widget flags.
# \return A new Radio Group widget object.
#
proc newRadiogroup*(parent: ptr ClaroObj, flags: cint): ptr RadioGroup {.
cdecl, importc: "radiogroup_create", dynlib: clarodll.}
#*
# \brief Creates a Radio Button widget
#
# \param parent The parent widget of this widget, NOT NULL.
# \param group A valid Radio Group widget object
# \param bounds The initial bounds of this widget, or NO_BOUNDS.
# \param label The label of the radio widget
# \param flags Widget flags.
# \return A new Radio Button widget object.
#
proc newradiobutton*(parent: ptr ClaroObj, group: ptr RadioGroup,
bounds: ptr Bounds, label: cstring,
flags: cint): ptr RadioButton{.
cdecl, importc: "radiobutton_widget_create", dynlib: clarodll.}
#*
# \brief Set the label of a Radio Button
#
# \param obj A valid Radio Button widget
# \param label The new label for the Radio Button
#
proc radiobutton_set_text*(obj: ptr RadioButton, label: cstring){.cdecl,
importc: "radiobutton_set_label", dynlib: clarodll.}
#*
# \brief Set the group of a Radio Button
#
# \param rbutton A valid Radio Button widget
# \param group A valid Radio Group widget object
#
proc radiobutton_set_group*(rbutton: ptr RadioButton, group: ptr RadioGroup){.
cdecl, importc: "radiobutton_set_group", dynlib: clarodll.}
const
CLARO_SCROLLBAR_MAXIMUM* = 256
type
Scrollbar* {.pure.} = object of Widget
min*: cint
max*: cint
pagesize*: cint
{.deprecated: [TScrollbar: Scrollbar].}
const
cScrollbarHorizontal* = 0
cScrollbarVertical* = 1
# functions
#*
# \brief Creates a ScrollBar widget
#
# \param parent The parent widget of this widget, NOT NULL.
# \param bounds The initial bounds of this widget, or NO_BOUNDS.
# \param flags Widget flags.
# \return A new ScrollBar widget object.
#
proc newscrollbar*(parent: ptr ClaroObj, bounds: ptr Bounds,
flags: cint): ptr Scrollbar{.
cdecl, importc: "scrollbar_widget_create", dynlib: clarodll.}
#*
# \brief Returns the width that scrollbars should be on this platform
#
# \return Width of vertical scrollbars
#
proc scrollbar_get_sys_width*(): cint{.cdecl,
importc: "scrollbar_get_sys_width",
dynlib: clarodll.}
#*
# \brief Sets the range of a ScrollBar widget
#
# \param w A valid ScrollBar widget object
# \param min The minimum value
# \param max The maximum value
#
proc scrollbar_set_range*(w: ptr Scrollbar, min: cint, max: cint){.cdecl,
importc: "scrollbar_set_range", dynlib: clarodll.}
#*
# \brief Sets the position of a ScrollBar widget
#
# \param w A valid ScrollBar widget object
# \param pos The new position
#
proc scrollbar_set_pos*(w: ptr Scrollbar, pos: cint){.cdecl,
importc: "scrollbar_set_pos", dynlib: clarodll.}
#*
# \brief Gets the position of a ScrollBar widget
#
# \param w A valid ScrollBar widget object
# \return The current position
#
proc scrollbar_get_pos*(w: ptr Scrollbar): cint{.cdecl,
importc: "scrollbar_get_pos", dynlib: clarodll.}
#*
# \brief Sets the page size of a ScrollBar widget
#
# \param w A valid ScrollBar widget object
# \param pagesize The size of a page (the number of units visible at one time)
#
proc scrollbar_set_pagesize*(w: ptr Scrollbar, pagesize: cint){.cdecl,
importc: "scrollbar_set_pagesize", dynlib: clarodll.}
type
CSplitterChildren* = enum
cSplitterFirst = 0, cSplitterSecond = 1
SplitterChild* {.pure.} = object
flex*: cint
size*: cint
w*: ptr Widget
Splitter* {.pure.} = object of Widget
pair*: array[0..1, SplitterChild]
{.deprecated: [TcSplitterChildren: CSplitterChildren, TSplitter: Splitter,
TSplitterChild: SplitterChild].}
const
cSplitterHorizontal* = 0
cSplitterVertical* = 1
# functions
#*
# \brief Creates a Splitter widget
#
# \param parent The parent widget of this widget, NOT NULL.
# \param bounds The initial bounds of this widget, or NO_BOUNDS.
# \param flags Widget flags.
# \return A new Splitter widget object.
#
proc newsplitter*(parent: ptr ClaroObj, bounds: ptr Bounds,
flags: cint): ptr Splitter{.
cdecl, importc: "splitter_widget_create", dynlib: clarodll.}
#*
# \brief Sets the sizing information of a child
#
# \param splitter A valid splitter widget object
# \param child The child number, either cSplitterFirst or cSplitterSecond.
# \param flex 1 if this child should receive extra space as the splitter
# expands, 0 if not
# \param size The size of this child
#
proc splitter_set_info*(splitter: ptr Splitter, child: cint, flex: cint,
size: cint){.cdecl, importc: "splitter_set_info",
dynlib: clarodll.}
type
Statusbar* {.pure.} = object of Widget
text*: array[0..256 - 1, char]
{.deprecated: [TStatusbar: Statusbar].}
#*
# \brief Creates a StatusBar widget
#
# \param parent The parent widget of this widget, NOT NULL.
# \param flags Widget flags.
# \return A new StatusBar widget object.
#
proc newstatusbar*(parent: ptr ClaroObj, flags: cint): ptr Statusbar {.cdecl,
importc: "statusbar_widget_create", dynlib: clarodll.}
#*
# \brief Sets the text of a statusbar
#
# \param obj A valid StatusBar widget
# \param text The new text
#
proc statusbar_set_text*(obj: ptr Statusbar, text: cstring){.cdecl,
importc: "statusbar_set_text", dynlib: clarodll.}
#*
# \brief obtains a stock image
#
# \param stock_id The string ID of the stock image, NOT NULL.
# \return The Image object.
#
proc stock_get_image*(stock_id: cstring): ptr Image{.cdecl,
importc: "stock_get_image", dynlib: clarodll.}
#*
# \brief adds a stock id image
#
# \param stock_id The string ID of the stock image, NOT NULL.
# \param img The Image object to add.
# \return The Image object.
#
proc stock_add_image*(stock_id: cstring, img: ptr Image){.cdecl,
importc: "stock_add_image", dynlib: clarodll.}
const
CLARO_TEXTAREA_MAXIMUM = (1024 * 1024)
type
TextArea* {.pure.} = object of Widget
text*: array[0..CLARO_TEXTAREA_MAXIMUM - 1, char]
{.deprecated: [TTextArea: TextArea].}
#*
# \brief Creates a TextArea widget
#
# \param parent The parent widget of this widget, NOT NULL.
# \param bounds The initial bounds of this widget, or NO_BOUNDS.
# \param flags Widget flags.
# \return A new TextArea widget object.
#
proc newtextarea*(parent: ptr ClaroObj, bounds: ptr Bounds,
flags: cint): ptr TextArea{.
cdecl, importc: "textarea_widget_create", dynlib: clarodll.}
#*
# \brief Sets the text of a textarea
#
# \param obj A valid TextArea widget
# \param text The new text
#
proc textarea_set_text*(obj: ptr TextArea, text: cstring){.cdecl,
importc: "textarea_set_text", dynlib: clarodll.}
#*
# \brief Retrieve the text of a textarea
#
# \param obj A valid TextArea widget
# \return Pointer to an internal reference of the text. Should not be changed.
#
proc textarea_get_text*(obj: ptr TextArea): cstring{.cdecl,
importc: "textarea_get_text", dynlib: clarodll.}
const
CLARO_TEXTBOX_MAXIMUM = 8192
type
TextBox* {.pure.} = object of Widget
text*: array[0..CLARO_TEXTBOX_MAXIMUM-1, char]
{.deprecated: [TTextBox: TextBox].}
const
cTextBoxTypePassword* = 1
# functions
#*
# \brief Creates a TextBox widget
#
# \param parent The parent widget of this widget, NOT NULL.
# \param bounds The initial bounds of this widget, or NO_BOUNDS.
# \param flags Widget flags.
# \return A new TextBox widget object.
#
proc newtextbox*(parent: ptr ClaroObj, bounds: ptr Bounds,
flags: cint): ptr TextBox{.
cdecl, importc: "textbox_widget_create", dynlib: clarodll.}
#*
# \brief Sets the text of a textbox
#
# \param obj A valid TextBox widget
# \param text The new text
#
proc textbox_set_text*(obj: ptr TextBox, text: cstring){.cdecl,
importc: "textbox_set_text", dynlib: clarodll.}
#*
# \brief Retrieve the text of a textbox
#
# \param obj A valid TextBox widget
# \return Pointer to an internal reference of the text. Should not be changed.
#
proc textbox_get_text*(obj: ptr TextBox): cstring{.cdecl,
importc: "textbox_get_text", dynlib: clarodll.}
#*
# \brief Retrieve the cursor position inside a textbox
#
# \param obj A valid TextBox widget
# \return Cursor position inside TextBox
#
proc textbox_get_pos*(obj: ptr TextBox): cint{.cdecl,
importc: "textbox_get_pos", dynlib: clarodll.}
#*
# \brief Sets the cursor position inside a textbox
#
# \param obj A valid TextBox widget
# \param pos New cursor position inside TextBox
#
proc textbox_set_pos*(obj: ptr TextBox, pos: cint){.cdecl,
importc: "textbox_set_pos", dynlib: clarodll.}
const
cToolbarShowText* = 1
cToolbarShowImages* = 2
cToolbarShowBoth* = 3
cToolbarAutoSizeButtons* = 4
type
Toolbar* {.pure.} = object of ListWidget
{.deprecated: [TToolbar: Toolbar].}
#*
# \brief Creates a ToolBar widget
#
# \param parent The parent widget of this widget, NOT NULL.
# \param flags Widget flags.
# \return A new ToolBar widget object.
#
proc newtoolbar*(parent: ptr ClaroObj, flags: cint): ptr Toolbar{.cdecl,
importc: "toolbar_widget_create", dynlib: clarodll.}
#*
# \brief Append a row to a ToolBar widget
#
# \param toolbar A valid ToolBar widget object.
# \param image An image object, or NULL.
# \param title A string title, or NULL.
# \param tooltip A string tooltip, or NULL.
# \return A new list item.
#
proc toolbar_append_icon*(toolbar: ptr Toolbar, image: ptr Image,
title: cstring, tooltip: cstring): ptr ListItem{.
cdecl, importc: "toolbar_append_icon", dynlib: clarodll.}
#*
# \brief Insert a row into a ToolBar widget
#
# \param toolbar A valid ToolBar widget object.
# \param pos The position at which to insert this item
# \param image An image object, or NULL.
# \param title A string title, or NULL.
# \param tooltip A string tooltip, or NULL.
# \return A new list item.
#
proc toolbar_insert_icon*(toolbar: ptr Toolbar, pos: cint,
image: ptr Image, title: cstring,
tooltip: cstring): ptr ListItem{.
cdecl, importc: "toolbar_insert_icon", dynlib: clarodll.}
#*
# \brief Append a separator to a ToolBar widget
#
# \param toolbar A valid ToolBar widget object.
# \return A new list item.
#
proc toolbar_append_separator*(toolbar: ptr Toolbar): ptr ListItem{.cdecl,
importc: "toolbar_append_separator", dynlib: clarodll.}
#*
# \brief Insert a separator into a ToolBar widget
#
# \param toolbar A valid ToolBar widget object.
# \param pos The position at which to insert this item
# \return A new list item.
#
proc toolbar_insert_separator*(toolbar: ptr Toolbar,
pos: cint): ptr ListItem {.
cdecl, importc: "toolbar_insert_separator", dynlib: clarodll.}
#*
# \brief Assign a menu widget to an item.
#
# This will show a small down arrow next to the item
# that will open this menu.
#
# \param toolbar A valid ToolBar widget object.
# \param item Toolbar item the menu is for.
# \param menu Menu widget object, or NULL to remove a menu.
#
proc toolbar_set_item_menu*(toolbar: ptr Toolbar, item: ptr ListItem,
menu: ptr Menu){.cdecl,
importc: "toolbar_set_item_menu", dynlib: clarodll.}
#*
# \brief Move a row in a ToolBar widget
#
# \param toolbar A valid ToolBar widget object.
# \param item A valid list item
# \param row New position to place this item
#
proc toolbar_move_icon*(toolbar: ptr Toolbar, item: ptr ListItem,
row: cint){.cdecl, importc: "toolbar_move_icon",
dynlib: clarodll.}
#*
# \brief Remove a row from a ToolBar widget
#
# \param toolbar A valid ToolBar widget object.
# \param item A valid list item
#
proc toolbar_remove_icon*(toolbar: ptr Toolbar, item: ptr ListItem){.
cdecl, importc: "toolbar_remove_icon", dynlib: clarodll.}
#*
# \brief Returns the number of rows in a ToolBar widget
#
# \param obj A valid ToolBar widget object.
# \return Number of rows
#
proc toolbar_item_count*(obj: ptr Toolbar): cint{.cdecl,
importc: "toolbar_item_count", dynlib: clarodll.}
#*
# \brief TreeView widget
#
type
Treeview* {.pure.} = object of ListWidget
selected*: ptr ListItem
{.deprecated: [TTreeview: Treeview].}
# functions
#*
# \brief Creates a TreeView widget
#
# \param parent The parent widget of this widget, NOT NULL.
# \param bounds The initial bounds of this widget, or NO_BOUNDS.
# \param flags Widget flags.
# \return A new TreeView widget object.
#
proc newtreeview*(parent: ptr ClaroObj, bounds: ptr Bounds,
flags: cint): ptr Treeview{.
cdecl, importc: "treeview_widget_create", dynlib: clarodll.}
#*
# \brief Append a row to a TreeView
#
# \param treeview A valid TreeView widget object.
# \param parent The item under which to place the new item, or NULL for a root node.
# \param image An image to go to the left of the item, or NULL for no image.
# \param title The text for the item.
# \return A new list item.
#
proc treeview_append_row*(treeview: ptr Treeview, parent: ptr ListItem,
image: ptr Image, title: cstring): ptr ListItem{.
cdecl, importc: "treeview_append_row", dynlib: clarodll.}
#*
# \brief Insert a row at the specified position into a TreeView
#
# \param treeview A valid TreeView widget object.
# \param parent The item under which to place the new item, or NULL for a root node.
# \param pos The index at which this item will be placed.
# \param image An image to go to the left of the item, or NULL for no image.
# \param title The text for the item.
# \return A new list item.
#
proc treeview_insert_row*(treeview: ptr Treeview, parent: ptr ListItem,
pos: cint, image: ptr Image,
title: cstring): ptr ListItem{.
cdecl, importc: "treeview_insert_row", dynlib: clarodll.}
#*
# \brief Move a row in a TreeView
#
# \param treeview A valid TreeView widget object.
# \param item A valid list item
# \param row New position to place this item
#
proc treeview_move_row*(treeview: ptr Treeview, item: ptr ListItem,
row: cint){.cdecl, importc: "treeview_move_row",
dynlib: clarodll.}
#*
# \brief Remove a row from a TreeView
#
# \param treeview A valid TreeView widget object.
# \param item A valid list item
#
proc treeview_remove_row*(treeview: ptr Treeview, item: ptr ListItem){.
cdecl, importc: "treeview_remove_row", dynlib: clarodll.}
#*
# \brief Expand a row in a TreeView
#
# \param treeview A valid TreeView widget object.
# \param item A valid list item
#
proc treeview_expand*(treeview: ptr Treeview, item: ptr ListItem){.cdecl,
importc: "treeview_expand", dynlib: clarodll.}
#*
# \brief Collapse a row in a TreeView
#
# \param treeview A valid TreeView widget object.
# \param item A valid list item
#
proc treeview_collapse*(treeview: ptr Treeview, item: ptr ListItem){.cdecl,
importc: "treeview_collapse", dynlib: clarodll.}
#*
# \brief Returns the currently selected TreeView item
#
# \param obj A valid TreeView widget object.
# \return The currently selected TreeView item, or NULL if no item is selected.
#
proc treeview_get_selected*(obj: ptr Treeview): ptr ListItem{.cdecl,
importc: "treeview_get_selected", dynlib: clarodll.}
#*
# \brief Returns the number of rows in a TreeView
#
# \param obj A valid TreeView widget object.
# \param parent Return the number of children of this item, or the number of
# root items if NULL
# \return Number of rows
#
proc treeview_get_rows*(obj: ptr Treeview, parent: ptr ListItem): cint{.
cdecl, importc: "treeview_get_rows", dynlib: clarodll.}
#*
# \brief Selects a row in a TreeView
#
# \param obj A valid TreeView widget object.
# \param item A valid list item
#
proc treeview_select_item*(obj: ptr Treeview, item: ptr ListItem){.cdecl,
importc: "treeview_select_item", dynlib: clarodll.}
const
cWindowModalDialog* = 1
cWindowCenterParent* = 2
cWindowNoResizing* = 4
type
Window* {.pure.} = object of Widget
title*: array[0..512 - 1, char]
icon*: ptr Image
menubar*: ptr Widget
workspace*: ptr Widget
exsp_tools*: cint
exsp_status*: cint
exsp_init*: cint
{.deprecated: [TWindow: Window].}
const
cWindowFixedSize* = 1
# functions
#*
# \brief Creates a Window widget
#
# \param parent The parent widget of this widget, NOT NULL.
# \param bounds The initial bounds of this widget, or NO_BOUNDS.
# \param flags Widget flags.
# \return A new Window widget object.
#
proc newwindow*(parent: ptr ClaroObj, bounds: ptr Bounds,
flags: cint): ptr Window {.
cdecl, importc: "window_widget_create", dynlib: clarodll.}
#*
# \brief Sets a Window's title
#
# \param w A valid Window widget object
# \param title The new title for the window
#
proc window_set_title*(w: ptr Window, title: cstring){.cdecl,
importc: "window_set_title", dynlib: clarodll.}
#*
# \brief Makes a window visible
#
# \param w A valid Window widget object
#
proc window_show*(w: ptr Window){.cdecl, importc: "window_show",
dynlib: clarodll.}
#*
# \brief Makes a window invisible
#
# \param w A valid Window widget object
#
proc window_hide*(w: ptr Window){.cdecl, importc: "window_hide",
dynlib: clarodll.}
#*
# \brief Gives focus to a window
#
# \param w A valid Window widget object
#
proc window_focus*(w: ptr Window){.cdecl, importc: "window_focus",
dynlib: clarodll.}
#*
# \brief Maximises a window
#
# \param w A valid Window widget object
#
proc window_maximize*(w: ptr Window){.cdecl, importc: "window_maximise",
dynlib: clarodll.}
#*
# \brief Minimises a window
#
# \param w A valid Window widget object
#
proc window_minimize*(w: ptr Window){.cdecl, importc: "window_minimise",
dynlib: clarodll.}
#*
# \brief Restores a window
#
# \param w A valid Window widget object
#
proc window_restore*(w: ptr Window){.cdecl, importc: "window_restore",
dynlib: clarodll.}
#*
# \brief Sets a window's icon
#
# \param w A valid Window widget object
# \param icon A valid Image object
#
proc window_set_icon*(w: ptr Window, icon: ptr Image){.cdecl,
importc: "window_set_icon", dynlib: clarodll.}
const
cWorkspaceTileHorizontally* = 0
cWorkspaceTileVertically* = 1
type
Workspace*{.pure.} = object of Widget
WorkspaceWindow*{.pure.} = object of Widget
icon*: ptr Image
title*: array[0..512 - 1, char]
workspace*: ptr Workspace
{.deprecated: [TWorkspace: Workspace, TWorkspaceWindow: WorkspaceWindow].}
# functions (workspace)
#*
# \brief Creates a Workspace widget
#
# \param parent The parent widget of this widget, NOT NULL.
# \param bounds The initial bounds of this widget, or NO_BOUNDS.
# \param flags Widget flags.
# \return A new Workspace widget object.
#
proc newworkspace*(parent: ptr ClaroObj, bounds: ptr Bounds,
flags: cint): ptr Workspace{.
cdecl, importc: "workspace_widget_create", dynlib: clarodll.}
#*
# \brief Sets the active (visible) workspace child
#
# \param workspace A valid workspace widget
# \param child A valid workspace window widget
#
proc workspace_set_active*(workspace: ptr Workspace, child: ptr ClaroObj){.
cdecl, importc: "workspace_set_active", dynlib: clarodll.}
#*
# \brief Returns the active (visible) workspace child
#
# \param workspace A valid workspace widget
# \return The active workspace window widget
#
proc workspace_get_active*(workspace: ptr Workspace): ptr Workspace{.cdecl,
importc: "workspace_get_active", dynlib: clarodll.}
#*
# \brief Cascades all workspace windows
#
# \param workspace A valid workspace widget
#
proc workspace_cascade*(workspace: ptr Workspace){.cdecl,
importc: "workspace_cascade", dynlib: clarodll.}
#*
# \brief Tiles all workspace windows
#
# \param workspace A valid workspace widget
# \param dir The direction to tile child widgets
#
proc workspace_tile*(workspace: ptr Workspace, dir: cint){.cdecl,
importc: "workspace_tile", dynlib: clarodll.}
# functions (workspace_window)
#*
# \brief Creates a Workspace widget
#
# \param parent The parent widget of this widget, NOT NULL.
# \param bounds The initial bounds of this widget, or NO_BOUNDS.
# \param flags Widget flags.
# \return A new Workspace widget object.
#
proc newWorkspaceWindow*(parent: ptr ClaroObj,
bounds: ptr Bounds,
flags: cint): ptr WorkspaceWindow{.
cdecl, importc: "workspace_window_widget_create", dynlib: clarodll.}
#*
# \brief Sets the title of a Workspace Window widget
#
# \param window A valid Workspace Window widget
# \param title The new title for the widget
#
proc workspace_window_set_title*(window: ptr WorkspaceWindow,
title: cstring){.cdecl,
importc: "workspace_window_set_title", dynlib: clarodll.}
#*
# \brief Makes a Workspace Window widget visible
#
# \param window A valid Workspace Window widget
#
proc workspace_window_show*(window: ptr WorkspaceWindow){.cdecl,
importc: "workspace_window_show", dynlib: clarodll.}
#*
# \brief Makes a Workspace Window widget invisible
#
# \param window A valid Workspace Window widget
#
proc workspace_window_hide*(window: ptr WorkspaceWindow){.cdecl,
importc: "workspace_window_hide", dynlib: clarodll.}
#*
# \brief Restores a Workspace Window widget
#
# \param window A valid Workspace Window widget
#
proc workspace_window_restore*(window: ptr WorkspaceWindow){.cdecl,
importc: "workspace_window_restore", dynlib: clarodll.}
# American spelling
#*
# \brief Minimises a Workspace Window widget
#
# \param window A valid Workspace Window widget
#
proc workspace_window_minimize*(window: ptr WorkspaceWindow){.cdecl,
importc: "workspace_window_minimise", dynlib: clarodll.}
#*
# \brief Maxmimises a Workspace Window widget
#
# \param window A valid Workspace Window widget
#
proc workspace_window_maximize*(window: ptr WorkspaceWindow){.cdecl,
importc: "workspace_window_maximise", dynlib: clarodll.}
#*
# \brief Sets the icon of a Workspace Window widget
#
# \param window A valid Workspace Window widget
# \param icon A valid Image object.
#
proc workspace_window_set_icon*(w: ptr WorkspaceWindow, icon: ptr Image){.
cdecl, importc: "workspace_window_set_icon", dynlib: clarodll.}
claro_base_init()
claro_graphics_init()
when not defined(testing) and isMainModule:
var w = newWindow(nil, newBounds(100, 100, 230, 230), 0)
window_set_title(w, "Hello, World!")
var t = newTextbox(w, new_bounds(10, 10, 210, -1), 0)
widget_set_notify(t, cNotifyKey)
textbox_set_text(t, "Yeehaw!")
var b = newButton(w, new_bounds(40, 45, 150, -1), 0, "Push my button!")
proc push_my_button(obj: ptr ClaroObj, event: ptr Event) {.cdecl.} =
textbox_set_text(t, "You pushed my button!")
var button = cast[ptr Button](obj)
button_set_text(button, "Ouch!")
object_addhandler(b, "pushed", push_my_button)
window_show(w)
window_focus(w)
claro_loop()
|