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 | % (` | '¯/ |_¯ |¯\
%\ W X \_) | /_,|__ |¯\ . E R L
%%
%%
%% Copyright Ericsson AB 2008-2013. All Rights Reserved.
%%
%%
%% Whitespace Beautified by ScriptCulture © 2018
%% Sit Back · Feet Up · Learn wxErlang
%% For use as a reference only
%% www.scriptculture.com
%% Not check-summed
%% wx 1.8
%%
%% Licensed under the Apache License,
%% Version 2.0 (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.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by
%% applicable law or agreed to in writing, software
%% distributed under the License is distributed
%% on an "AS IS" BASIS, WITHOUT WARRANTIES
%% OR CONDITIONS OF ANY KIND, either
%% express or implied. See the
%% License for the specific
%% language governing
%% permissions and
%% limitations
%% under the
%% License.
%%%%%%%
%%%%
%%%%%
%% @doc See external documentation: <a href="http://www.wxwidgets.org/manuals/2.8.12/wx_wxsizer.html">wxSizer</a>.
%% @type wxSizer().
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% \/ Overarching Sizers Overview @ Bottom
%%
%% OVERVIEW
%% ––––––––
%% wxSizer is the abstract base class used for laying out
%% subwindows in a window. You cannot use wxSizer directly; instead,
%% you will have to use one of the sizer classes derived from it.
%% Currently there are wxBoxSizer,
%% wxStaticBoxSizer, wxGridSizer wxFlexGridSizer and wxGridBagSizer.
%%
%% The layout algorithm used by sizers in wxWidgets is closely related to
%% layout in other GUI toolkits, such as Java's AWT, the GTK toolkit
%% or the Qt toolkit. It is based upon the idea of the individual
%% subwindows reporting their minimal required size and their
%% ability to get stretched if the size of the parent window
%% has changed. This will most often mean that the programmer
%% does not set the original size of a dialog in the beginning,
%% rather the dialog will be assigned a sizer and this sizer will
%% be queried about the recommended size. The sizer in turn will
%% query its children, which can be normal windows, empty space or
%% other sizers, so that a hierarchy of sizers can be constructed.
%% Note that wxSizer does not derive from wxWindow and thus does not
%% interfere with tab ordering and requires very little resources compared
%% to a real window on screen.
%%
%% What makes sizers so well fitted for use in wxWidgets is the fact that
%% every control reports its own minimal size and the algorithm can handle
%% differences in font sizes or different window (dialog item) sizes on
%% different platforms without problems. If e.g. the standard font as well
%% as the overall design of Motif widgets requires more space than on Windows,
%% the initial dialog size will automatically be bigger on Motif than on Windows.
%%
%% Sizers may also be used to control the layout of custom drawn items on the
%% window. The Add, Insert, and Prepend functions return a pointer to the
%% newly added wxSizerItem. Just add empty space of the desired size and
%% attributes, and then use the wxSizerItem::GetRect method to determine
%% where the drawing operations should take place.
%%
%% Please notice that sizers, like child windows, are owned by the library
%% and will be deleted by it which implies that they must be allocated on
%% the heap. However if you create a sizer and do not add it to another
%% sizer or window, the library wouldn't be able to delete such an orphan
%% sizer and in this, and only this, case it should be deleted explicitly.
%%
%%
%%
%% See Also:
%% —————————
%%
%%
%%
-module(wxSizer).
-include("wxe.hrl").
-export([add/2,add/3,add/4,addSpacer/2,addStretchSpacer/1,addStretchSpacer/2,
calcMin/1,clear/1,clear/2,detach/2,fit/2,fitInside/2,getChildren/1,getItem/2,
getItem/3,getMinSize/1,getPosition/1,getSize/1,hide/2,hide/3,insert/3,
insert/4,insert/5,insertSpacer/3,insertStretchSpacer/2,insertStretchSpacer/3,
isShown/2,layout/1,prepend/2,prepend/3,prepend/4,prependSpacer/2,prependStretchSpacer/1,
prependStretchSpacer/2,recalcSizes/1,remove/2,replace/3,replace/4,
setDimension/5,setItemMinSize/3,setItemMinSize/4,setMinSize/2,setMinSize/3,
setSizeHints/2,setVirtualSizeHints/2,show/2,show/3]).
%% inherited exports
-export([parent_class/1]).
-export_type([wxSizer/0]).
%% @hidden
parent_class(_Class) -> erlang:error({badtype, ?MODULE}).
-type wxSizer() :: wx:wx_object().
%·%% ADD %%·%
%%
%% See below...
%% @equiv add(This,Window, [])
-spec add(This, Window) -> wxSizerItem:wxSizerItem()
when
This :: wxSizer(),
Window :: wxWindow:wxWindow()
| wxSizer().
add(This,Window)
when
is_record(This, wx_ref),
is_record(Window, wx_ref) -> add(This,Window, []).
%·%% ADD %%·%
%% See below...
%% Return Value:
%% See Also:
%%*%%*%%
-spec add(This, Width, Height) -> wxSizerItem:wxSizerItem()
when
This :: wxSizer(),
Width :: integer(),
Height :: integer();
(This, Window, [Option]) -> wxSizerItem:wxSizerItem()
when
This :: wxSizer(),
Window :: wxWindow:wxWindow()
| wxSizer(),
Option :: {proportion, integer()}
| {flag, integer()}
| {border, integer()}
| {userData, wx:wx_object()};
(This, Window, Flags) -> wxSizerItem:wxSizerItem()
when
This :: wxSizer(),
Window :: wxWindow:wxWindow()
| wxSizer(),
Flags :: wxSizerFlags:wxSizerFlags().
add(This,Width,Height)
when
is_record(This, wx_ref),
is_integer(Width),
is_integer(Height) -> add(This,Width,Height, []);
add(#wx_ref{type=ThisT,ref=ThisRef},
#wx_ref{type=WindowT,ref=WindowRef},
Options)
when
is_list(Options) ->
?CLASS(ThisT,wxSizer),
WindowOP =
case
?CLASS_T(WindowT,wxWindow) of
true ->
?wxSizer_Add_2_1;
_ -> ?CLASS(WindowT,wxSizer),
?wxSizer_Add_2_0
end,
MOpts = fun({proportion, Proportion}, Acc) -> [<<1:32/?UI,Proportion:32/?UI>>|Acc];
({flag, Flag}, Acc) -> [<<2:32/?UI,Flag:32/?UI>>|Acc];
({border, Border}, Acc) -> [<<3:32/?UI,Border:32/?UI>>|Acc];
({userData, #wx_ref{type=UserDataT,ref=UserDataRef}}, Acc) -> ?CLASS(UserDataT,wx),[<<4:32/?UI,UserDataRef:32/?UI>>|Acc];
(BadOpt, _) -> erlang:error({badoption, BadOpt})
end,
BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)),
wxe_util:call(WindowOP,
<<ThisRef:32/?UI,WindowRef:32/?UI, BinOpt/binary>>);
add(#wx_ref{type=ThisT,ref=ThisRef},
#wx_ref{type=WindowT,ref=WindowRef},
#wx_ref{type=FlagsT,ref=FlagsRef}) ->
?CLASS(ThisT,wxSizer),
WindowOP =
case
?CLASS_T(WindowT,wxWindow)
of
true ->
?CLASS(FlagsT,wxSizerFlags),
?wxSizer_Add_2_3;
_ ->
?CLASS(WindowT,wxSizer),
?CLASS(FlagsT,wxSizerFlags),
?wxSizer_Add_2_2
end,
wxe_util:call(WindowOP,
<<ThisRef:32/?UI,WindowRef:32/?UI,FlagsRef:32/?UI>>).
%·%% ADD %%·%
%%
%% Appends a child to the sizer. wxSizer itself is an abstract class,
%% but the parameters are equivalent in the derived classes that you will
%% instantiate to use it so they are described here:
%%
%% window
%%
%% The window to be added to the sizer.
%% Its initial size (either set explicitly by the user or calculated
%% internally when using wxDefaultSize) is interpreted as the minimal
%% and in many cases also the initial size.
%%
%% sizer
%%
%% The (child-)sizer to be added to the sizer.
%% This allows placing a child sizer in a sizer and thus to
%% create hierarchies of sizers (typically a vertical box as the
%% top sizer and several horizontal boxes on the level beneath).
%%
%% width and height
%%
%% The dimension of a spacer to be added to the sizer.
%% Adding spacers to sizers gives more flexibility in the design
%% of dialogs; imagine for example a horizontal box with two buttons
%% at the bottom of a dialog: you might want to insert a space between
%% the two buttons and make that space stretchable using the proportion
%% flag and the result will be that the left button will be aligned with
%% the left side of the dialog and the right button with the right side -
%% the space in between will shrink and grow with the dialog.
%%
%% proportion
%%
%% Although the meaning of this parameter is undefined in wxSizer,
%% it is used in wxBoxSizer to indicate if a child of a sizer can change
%% its size in the main orientation of the wxBoxSizer - where 0 stands for
%% not changeable and a value of more than zero is interpreted relative to
%% the value of other children of the same wxBoxSizer. For example, you
%% might have a horizontal wxBoxSizer with three children, two of which
%% are supposed to change their size with the sizer.
%% Then the two stretchable windows would get a value of 1 each to
%% make them grow and shrink equally with the sizer's horizontal dimension.
%%
%% flag
%%
%% This parameter can be used to set a number of flags which can be
%% combined using the binary OR operator |. Two main behaviours are
%% defined using these flags. One is the border around a window: the
%% border parameter determines the border width whereas the flags
%% given here determine which side(s) of the item that the border
%% will be added. The other flags determine how the sizer item
%% behaves when the space allotted to the sizer changes, and is
%% somewhat dependent on the specific kind of sizer used.
%%
%% wxTOP
%% wxBOTTOM
%% wxLEFT
%% wxRIGHT
%% wxALL These flags are used to specify which side(s)
%% of the sizer item the border width will apply to.
%%
%% wxEXPAND The item will be expanded to fill the space assigned
%% to the item.
%%
%% wxSHAPED The item will be expanded as much as possible while
%% also maintaining its aspect ratio
%%
%% wxFIXED_MINSIZE Normally wxSizers will use GetAdjustedBestSize to
%% determine what the minimal size of window items
%% should be, and will use that size to calculate the
%% layout. This allows layouts to adjust when an item
%% changes and its best size becomes different. If you
%% would rather have a window item stay the size it
%% started with then use wxFIXED_MINSIZE.
%%
%% wxRESERVE_SPACE_EVEN_IF_HIDDEN
%% Normally wxSizers don't allocate space for hidden
%% windows or other items. This flag overrides this
%% behavior so that sufficient space is allocated for
%% the window even if it isn't visible. This makes it
%% possible to dynamically show and hide controls
%% without resizing parent dialog, for example.
%% This function is new since wxWidgets version 2.8.8
%%
%% wxALIGN_LEFT The wxALIGN flags allow you to specify the alignment
%% wxALIGN_RIGHT of the item within the space allotted to it by the sizer,
%% wxALIGN_TOP adjusted for the border if any.
%% wxALIGN_BOTTOM
%% wxALIGN_CENTER wxALIGN_CENTRE
%% wxALIGN_CENTER_VERTICAL wxALIGN_CENTRE_VERTICAL
%% wxALIGN_CENTER_HORIZONTAL wxALIGN_CENTRE_HORIZONTAL
%%
%%
%% border
%%
%% Determines the border width, if the flag parameter is set to include
%% any border flag.
%%
%% userData
%%
%% Allows an extra object to be attached to the sizer item,
%% for use in derived classes when sizing information is more
%% complex than the proportion and flag will allow for.
%%
%% flags
%%
%% A wxSizerFlags object that enables you to specify most of the
%% above parameters more conveniently.
%%
%% Return Value:
%% See Also:
%%*%%*%%
-spec add(This, Width, Height, [Option]) -> wxSizerItem:wxSizerItem()
when
This :: wxSizer(),
Width :: integer(),
Height :: integer(),
Option :: {proportion, integer()}
| {flag, integer()}
| {border, integer()}
| {userData, wx:wx_object()}.
add(#wx_ref{type=ThisT,ref=ThisRef}, Width, Height, Options)
when
is_integer(Width),
is_integer(Height),
is_list(Options) ->
?CLASS(ThisT,wxSizer),
MOpts = fun({proportion, Proportion}, Acc) -> [<<1:32/?UI,Proportion:32/?UI>>|Acc];
({flag, Flag}, Acc) -> [<<2:32/?UI,Flag:32/?UI>>|Acc];
({border, Border}, Acc) -> [<<3:32/?UI,Border:32/?UI>>|Acc];
({userData, #wx_ref{type=UserDataT,ref=UserDataRef}}, Acc) -> ?CLASS(UserDataT,wx),[<<4:32/?UI,UserDataRef:32/?UI>>|Acc];
(BadOpt, _) -> erlang:error({badoption, BadOpt})
end,
BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)),
wxe_util:call(?wxSizer_Add_3,
<<ThisRef:32/?UI,Width:32/?UI,Height:32/?UI, 0:32,BinOpt/binary>>).
%·%% ADD SPACER %%·%
%%
%% Adds non-stretchable space to the sizer.
%% More readable way of calling Add(size, size, 0).
%%
%% Return Value:
%% See Also:
%%*%%*%%
-spec addSpacer(This, Size) -> wxSizerItem:wxSizerItem()
when
This :: wxSizer(),
Size :: integer().
addSpacer(#wx_ref{type=ThisT,ref=ThisRef}, Size)
when
is_integer(Size) ->
?CLASS(ThisT,wxSizer),
wxe_util:call(?wxSizer_AddSpacer,
<<ThisRef:32/?UI,Size:32/?UI>>).
%·%% ADD STRETCH SPACER %%·%
%%
%% See below...
%% @equiv addStretchSpacer(This, [])
-spec addStretchSpacer(This) -> wxSizerItem:wxSizerItem()
when
This :: wxSizer().
addStretchSpacer(This)
when
is_record(This, wx_ref) -> addStretchSpacer(This, []).
%·%% ADD STRETCH SPACER %%·%
%%
%% Adds stretchable space to the sizer. More readable way of calling Add(0, 0, prop).
%%
%% Return Value:
%% See Also:
%%*%%*%%
-spec addStretchSpacer(This, [Option]) -> wxSizerItem:wxSizerItem()
when
This :: wxSizer(),
Option :: {prop, integer()}.
addStretchSpacer(#wx_ref{type=ThisT,ref=ThisRef}, Options)
when
is_list(Options) ->
?CLASS(ThisT,wxSizer),
MOpts = fun({prop, Prop}, Acc) -> [<<1:32/?UI,Prop:32/?UI>>|Acc];
(BadOpt, _) -> erlang:error({badoption, BadOpt})
end,
BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)),
wxe_util:call(?wxSizer_AddStretchSpacer,
<<ThisRef:32/?UI, 0:32,BinOpt/binary>>).
%·%% CALC MIN %%·%
%%
%% This method is abstract and has to be overwritten by any derived class.
%% Here, the sizer will do the actual calculation of its children minimal sizes.
%%
%% Return Value:
%% See Also:
%%*%%*%%
"http://www.wxwidgets.org/manuals/2.8.12/wx_wxsizer.html#wxsizercalcmin">external documentation</a>.
-spec calcMin(This) -> {W :: integer(), H :: integer()}
when
This :: wxSizer().
calcMin(#wx_ref{type=ThisT,ref=ThisRef}) ->
?CLASS(ThisT,wxSizer),
wxe_util:call(?wxSizer_CalcMin,
<<ThisRef:32/?UI>>).
%·%% CLEAR %%·%
%%
%% See below...
%% @equiv clear(This, [])
-spec clear(This) -> ok
when
This :: wxSizer().
clear(This)
when
is_record(This, wx_ref) -> clear(This, []).
%·%% CLEAR %%·%
%%
%% Detaches all children from the sizer.
%% If delete_windows is true then child windows will also be deleted.
%%
%% Return Value:
%% See Also:
%%*%%*%%
-spec clear(This, [Option]) -> ok
when
This :: wxSizer(),
Option :: {delete_windows, boolean()}.
clear(#wx_ref{type=ThisT,ref=ThisRef}, Options)
when
is_list(Options) ->
?CLASS(ThisT,wxSizer),
MOpts = fun({delete_windows, Delete_windows}, Acc) -> [<<1:32/?UI,(wxe_util:from_bool(Delete_windows)):32/?UI>>|Acc];
(BadOpt, _) -> erlang:error({badoption, BadOpt})
end,
BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)),
wxe_util:cast(?wxSizer_Clear,
<<ThisRef:32/?UI, 0:32,BinOpt/binary>>).
%·%% DETACH %%·%
%%
%% Detach a child from the sizer without destroying it.
%% window is the window to be detached, sizer is the equivalent sizer and
%% index is the position of the child in the sizer, typically 0 for the
%% first item. This method does not cause any layout or resizing to take
%% place, call wxSizer::Layout to update the layout "on screen" after
%% detaching a child from the sizer.
%%
%% Returns true if the child item was found and detached, false otherwise.
%%
%% Return Value: wxSizer:Remove
%% See Also:
%%*%%*%%
-spec detach(This, Index) -> boolean()
when
This :: wxSizer(),
Index :: integer();
(This, Window) -> boolean()
when
This :: wxSizer(),
Window :: wxWindow:wxWindow()
| wxSizer().
detach(#wx_ref{type=ThisT,ref=ThisRef}, Index)
when
is_integer(Index) ->
?CLASS(ThisT,wxSizer),
wxe_util:call(?wxSizer_Detach_1_0,
<<ThisRef:32/?UI,Index:32/?UI>>);
detach(#wx_ref{type=ThisT,ref=ThisRef},
#wx_ref{type=WindowT,ref=WindowRef}) ->
?CLASS(ThisT,wxSizer),
WindowOP =
case
?CLASS_T(WindowT,wxWindow)
of
true ->
?wxSizer_Detach_1_2;
_ ->
?CLASS(WindowT,wxSizer),
?wxSizer_Detach_1_1
end,
wxe_util:call(WindowOP,
<<ThisRef:32/?UI,WindowRef:32/?UI>>).
%·%% FIT %%·%
%%
%% Tell the sizer to resize the window to match the sizer's minimal size.
%% This is commonly done in the constructor of the window itself,
%% see sample in the description of wxBoxSizer. Returns the new size.
%%
%% For a top level window this is the total window size, not client size.
%%
%% Return Value:
%% See Also:
%%*%%*%%
-spec fit(This, Window) -> {W :: integer(), H :: integer()}
when
This :: wxSizer(),
Window :: wxWindow:wxWindow().
fit(#wx_ref{type=ThisT,ref=ThisRef},
#wx_ref{type=WindowT,ref=WindowRef}) ->
?CLASS(ThisT,wxSizer),
?CLASS(WindowT,wxWindow),
wxe_util:call(?wxSizer_Fit,
<<ThisRef:32/?UI,WindowRef:32/?UI>>).
%·%% FIT INSIDE %%·%
%%
%% Tell the sizer to resize the virtual size of the window to match the
%% sizer's minimal size. This will not alter the on screen size of the window,
%% but may cause the addition/removal/alteration of scrollbars required to
%% view the virtual area in windows which manage it.
%%
%% Return Value:
%% See Also: wxScrolledWindow::SetScrollbars, wxSizer::SetVirtualSizeHints
%%*%%*%%
-spec fitInside(This, Window) -> ok
when
This :: wxSizer(),
Window :: wxWindow:wxWindow().
fitInside(#wx_ref{type=ThisT,ref=ThisRef},
#wx_ref{type=WindowT,ref=WindowRef}) ->
?CLASS(ThisT,wxSizer),
?CLASS(WindowT,wxWindow),
wxe_util:cast(?wxSizer_FitInside,
<<ThisRef:32/?UI,WindowRef:32/?UI>>).
%·%% GET CHILDREN %%·%
%%
%% Returns the list of the items in this sizer.
%% The elements of type-safe wxList wxSizerItemList are objects of type w
%% xSizerItem *.
%%
%% Return Value:
%% See Also:
%%*%%*%%
-spec getChildren(This) -> [wxSizerItem:wxSizerItem()]
when
This :: wxSizer().
getChildren(#wx_ref{type=ThisT,ref=ThisRef}) ->
?CLASS(ThisT,wxSizer),
wxe_util:call(?wxSizer_GetChildren,
<<ThisRef:32/?UI>>).
%·%% GET ITEM / 2 %%·%
%%
%% See below...
%% Return Value:
%% See Also:
%%*%%*%%
-spec getItem(This, Window) -> wxSizerItem:wxSizerItem()
when
This :: wxSizer(),
Window :: wxWindow:wxWindow()
| wxSizer();
(This, Index) -> wxSizerItem:wxSizerItem()
when
This :: wxSizer(),
Index :: integer().
getItem(This,Window)
when
is_record(This, wx_ref),
is_record(Window, wx_ref) -> getItem(This,Window, []);
getItem(#wx_ref{type=ThisT,ref=ThisRef}, Index)
when
is_integer(Index) ->
?CLASS(ThisT,wxSizer),
wxe_util:call(?wxSizer_GetItem_1,
<<ThisRef:32/?UI,Index:32/?UI>>).
%·%% GET ITEM / 3 %%·%
%%
%% Finds item of the sizer which holds given window,
%% sizer or is located in sizer at position index. Use parameter
%% recursive to search in subsizers too.
%%
%% Returns pointer to item or NULL.
%%
%% Return Value:
%% See Also:
%%*%%*%%
-spec getItem(This, Window, [Option]) -> wxSizerItem:wxSizerItem()
when
This :: wxSizer(),
Window :: wxWindow:wxWindow()
| wxSizer(),
Option :: {recursive, boolean()}.
getItem(#wx_ref{type=ThisT,ref=ThisRef},
#wx_ref{type=WindowT,ref=WindowRef}, Options)
when
is_list(Options) ->
?CLASS(ThisT,wxSizer),
WindowOP =
case
?CLASS_T(WindowT,wxWindow)
of
true ->
?wxSizer_GetItem_2_1;
_ ->
?CLASS(WindowT,wxSizer),
?wxSizer_GetItem_2_0
end,
MOpts = fun({recursive, Recursive}, Acc) -> [<<1:32/?UI,(wxe_util:from_bool(Recursive)):32/?UI>>|Acc];
(BadOpt, _) -> erlang:error({badoption, BadOpt})
end,
BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)),
wxe_util:call(WindowOP,
<<ThisRef:32/?UI,WindowRef:32/?UI, BinOpt/binary>>).
%·%% GET SIZE %%·%
%%
%% Returns the current size of the sizer.
%%
%% Return Value:
%% See Also:
%%*%%*%%
"http://www.wxwidgets.org/manuals/2.8.12/wx_wxsizer.html#wxsizergetsize">external documentation</a>.
-spec getSize(This) -> {W :: integer(), H :: integer()}
when
This :: wxSizer().
getSize(#wx_ref{type=ThisT,ref=ThisRef}) ->
?CLASS(ThisT,wxSizer),
wxe_util:call(?wxSizer_GetSize,
<<ThisRef:32/?UI>>).
%·%% GET POSITION %%·%
%%
%% Returns the current position of the sizer.
%%
%% Return Value:
%% See Also:
%%*%%*%%
"http://www.wxwidgets.org/manuals/2.8.12/wx_wxsizer.html#wxsizergetposition">external documentation</a>.
-spec getPosition(This) -> {X :: integer(), Y :: integer()}
when
This :: wxSizer().
getPosition(#wx_ref{type=ThisT,ref=ThisRef}) ->
?CLASS(ThisT,wxSizer),
wxe_util:call(?wxSizer_GetPosition,
<<ThisRef:32/?UI>>).
%·%% GET MIN SIZE %%·%
%%
%% Returns the minimal size of the sizer. This is either the combined
%% minimal size of all the children and their borders or the minimal
%% size set by SetMinSize, depending on which is bigger.
%%
%% Note that the returned value is client size, not window size.
%% In particular, if you use the value to set toplevel window's minimal
%% or actual size, you should convert it using wxWindow::ClientToWindowSize
%% before passing it to wxWindow::SetMinSize or wxWindow::SetSize.
%%
%% Return Value:
%% See Also:
%%*%%*%%
-spec getMinSize(This) -> {W :: integer(), H :: integer()}
when
This :: wxSizer().
getMinSize(#wx_ref{type=ThisT,ref=ThisRef}) ->
?CLASS(ThisT,wxSizer),
wxe_util:call(?wxSizer_GetMinSize,
<<ThisRef:32/?UI>>).
%·%% HIDE %%·%
%%
%% See also...
%% Return Value:
%% See Also:
%%*%%*%%
-spec hide(This, Window) -> boolean()
when
This :: wxSizer(),
Window :: wxWindow:wxWindow()
| wxSizer();
(This, Index) -> boolean()
when
This :: wxSizer(),
Index :: integer().
hide(This,Window)
when
is_record(This, wx_ref),
is_record(Window, wx_ref) -> hide(This,Window, []);
hide(#wx_ref{type=ThisT,ref=ThisRef},Index)
when
is_integer(Index) ->
?CLASS(ThisT,wxSizer),
wxe_util:call(?wxSizer_Hide_1,
<<ThisRef:32/?UI,Index:32/?UI>>).
%·%% HIDE %%·%
%%
%% Hides the window, sizer, or item at index.
%% To make a sizer item disappear, use Hide() followed by Layout().
%% Use parameter recursive to hide elements found in subsizers.
%%
%% Returns true if the child item was found, false otherwise.
%%
%% Return Value:
%% See Also: wxSizer::IsShown, wxSizer::Show
%%*%%*%%
-spec hide(This, Window, [Option]) -> boolean()
when
This :: wxSizer(),
Window :: wxWindow:wxWindow()
| wxSizer(),
Option :: {recursive, boolean()}.
hide(#wx_ref{type=ThisT,ref=ThisRef},
#wx_ref{type=WindowT,ref=WindowRef}, Options)
when
is_list(Options) ->
?CLASS(ThisT,wxSizer),
WindowOP =
case
?CLASS_T(WindowT,wxWindow)
of
true ->
?wxSizer_Hide_2_1;
_ ->
?CLASS(WindowT,wxSizer),
?wxSizer_Hide_2_0
end,
MOpts = fun({recursive, Recursive}, Acc) -> [<<1:32/?UI,(wxe_util:from_bool(Recursive)):32/?UI>>|Acc];
(BadOpt, _) -> erlang:error({badoption, BadOpt})
end,
BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)),
wxe_util:call(WindowOP,
<<ThisRef:32/?UI,WindowRef:32/?UI, BinOpt/binary>>).
%·%% INSERT %%·%
%%
%% See below...
%% Return Value:
%% See Also:
%%*%%*%%
-spec insert(This, Index, Item) -> wxSizerItem:wxSizerItem()
when
This :: wxSizer(),
Index :: integer(), %% The position this child should assume in the sizer.
Item :: wxSizerItem:wxSizerItem().
insert(#wx_ref{type=ThisT,ref=ThisRef},
Index,
#wx_ref{type=ItemT,ref=ItemRef})
when
is_integer(Index) ->
?CLASS(ThisT,wxSizer),
?CLASS(ItemT,wxSizerItem),
wxe_util:call(?wxSizer_Insert_2,
<<ThisRef:32/?UI,Index:32/?UI,ItemRef:32/?UI>>).
%·%% INSERT %%·%
%%
%% See also...
%% Return Value:
%% See Also:
%%*%%*%%
-spec insert(This, Index, Width, Height) -> wxSizerItem:wxSizerItem()
when
This :: wxSizer(),
Index :: integer(), % The position this child should assume in the sizer.
Width :: integer(),
Height :: integer();
(This, Index, Window, [Option]) -> wxSizerItem:wxSizerItem()
when
This :: wxSizer(),
Index :: integer(), %% The position this child should assume in the sizer.
Window :: wxWindow:wxWindow()
| wxSizer(),
Option :: {proportion, integer()}
| {flag, integer()}
| {border, integer()}
| {userData, wx:wx_object()};
(This, Index, Window, Flags) -> wxSizerItem:wxSizerItem()
when
This :: wxSizer(),
Index :: integer(), %% The position this child should assume in the sizer.
Window :: wxWindow:wxWindow()
| wxSizer(),
Flags :: wxSizerFlags:wxSizerFlags().
insert(This,Index,Width,Height)
when
is_record(This, wx_ref),
is_integer(Index),
is_integer(Width),
is_integer(Height) -> insert(This,Index,Width,Height, []);
insert(#wx_ref{type=ThisT,ref=ThisRef}, Index,
#wx_ref{type=WindowT,ref=WindowRef}, Options)
when
is_integer(Index),
is_list(Options) ->
?CLASS(ThisT,wxSizer),
WindowOP =
case
?CLASS_T(WindowT,wxWindow)
of
true ->
?wxSizer_Insert_3_1;
_ ->
?CLASS(WindowT,wxSizer),
?wxSizer_Insert_3_0
end,
MOpts = fun({proportion, Proportion}, Acc) -> [<<1:32/?UI,Proportion:32/?UI>>|Acc];
({flag, Flag}, Acc) -> [<<2:32/?UI,Flag:32/?UI>>|Acc];
({border, Border}, Acc) -> [<<3:32/?UI,Border:32/?UI>>|Acc];
({userData, #wx_ref{type=UserDataT,ref=UserDataRef}}, Acc) -> ?CLASS(UserDataT,wx),[<<4:32/?UI,UserDataRef:32/?UI>>|Acc];
(BadOpt, _) -> erlang:error({badoption, BadOpt})
end,
BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)),
wxe_util:call(WindowOP,
<<ThisRef:32/?UI,Index:32/?UI,WindowRef:32/?UI, 0:32,BinOpt/binary>>);
insert(#wx_ref{type=ThisT,ref=ThisRef},Index,
#wx_ref{type=WindowT,ref=WindowRef},
#wx_ref{type=FlagsT,ref=FlagsRef})
when
is_integer(Index) ->
?CLASS(ThisT,wxSizer),
WindowOP =
case
?CLASS_T(WindowT,wxWindow)
of
true ->
?CLASS(FlagsT,wxSizerFlags),
?wxSizer_Insert_3_3;
_ ->
?CLASS(WindowT,wxSizer),
?CLASS(FlagsT,wxSizerFlags),
?wxSizer_Insert_3_2
end,
wxe_util:call(WindowOP,
<<ThisRef:32/?UI,Index:32/?UI,WindowRef:32/?UI,FlagsRef:32/?UI>>).
%·%% INSERT %%·%
%%
%% Insert a child into the sizer before any existing item at index.
%% See wxSizer::Add for the meaning of the other parameters.
%%
%%
%% Return Value:
%% See Also:
%%*%%*%%
-spec insert(This, Index, Width, Height, [Option]) -> wxSizerItem:wxSizerItem()
when
This :: wxSizer(),
Index :: integer(), %% The position this child should assume in the sizer.
Width :: integer(),
Height :: integer(),
Option :: {proportion, integer()}
| {flag, integer()}
| {border, integer()}
| {userData, wx:wx_object()}.
insert(#wx_ref{type=ThisT,ref=ThisRef}, Index, Width, Height, Options)
when
is_integer(Index),
is_integer(Width),
is_integer(Height),
is_list(Options) ->
?CLASS(ThisT,wxSizer),
MOpts = fun({proportion, Proportion}, Acc) -> [<<1:32/?UI,Proportion:32/?UI>>|Acc];
({flag, Flag}, Acc) -> [<<2:32/?UI,Flag:32/?UI>>|Acc];
({border, Border}, Acc) -> [<<3:32/?UI,Border:32/?UI>>|Acc];
({userData, #wx_ref{type=UserDataT,ref=UserDataRef}}, Acc) -> ?CLASS(UserDataT,wx),[<<4:32/?UI,UserDataRef:32/?UI>>|Acc];
(BadOpt, _) -> erlang:error({badoption, BadOpt})
end,
BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)),
wxe_util:call(?wxSizer_Insert_4,
<<ThisRef:32/?UI,Index:32/?UI,Width:32/?UI,Height:32/?UI, BinOpt/binary>>).
%·%% INSERT SPACER %%·%
%%
%% Inserts non-stretchable space to the sizer.
%% More readable way of calling Insert(size, size, 0).
%%
%% Return Value:
%% See Also:
%%*%%*%%
-spec insertSpacer(This, Index, Size) -> wxSizerItem:wxSizerItem()
when
This :: wxSizer(),
Index :: integer(),
Size :: integer().
insertSpacer(#wx_ref{type=ThisT,ref=ThisRef}, Index, Size)
when
is_integer(Index),
is_integer(Size) ->
?CLASS(ThisT,wxSizer),
wxe_util:call(?wxSizer_InsertSpacer,
<<ThisRef:32/?UI,Index:32/?UI,Size:32/?UI>>).
%·%% INSERT STRETCH SPACER %%·%
%%
%% See below...
%% @equiv insertStretchSpacer(This,Index, [])
-spec insertStretchSpacer(This, Index) -> wxSizerItem:wxSizerItem()
when
This :: wxSizer(),
Index :: integer().
insertStretchSpacer(This,Index)
when
is_record(This, wx_ref),
is_integer(Index) -> insertStretchSpacer(This,Index, []).
%·%% INSERT STRETCH SPACER %%·%
%%
%% Inserts stretchable space to the sizer.
%% More readable way of calling Insert(0, 0, prop).
%%
%% Return Value:
%% See Also:
%%*%%*%%
-spec insertStretchSpacer(This, Index, [Option]) -> wxSizerItem:wxSizerItem()
when
This :: wxSizer(),
Index :: integer(),
Option :: {prop, integer()}.
insertStretchSpacer(#wx_ref{type=ThisT,ref=ThisRef}, Index, Options)
when
is_integer(Index),
is_list(Options) ->
?CLASS(ThisT,wxSizer),
MOpts = fun({prop, Prop}, Acc) -> [<<1:32/?UI,Prop:32/?UI>>|Acc];
(BadOpt, _) -> erlang:error({badoption, BadOpt})
end,
BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)),
wxe_util:call(?wxSizer_InsertStretchSpacer,
<<ThisRef:32/?UI,Index:32/?UI, BinOpt/binary>>).
%·%% IS SHOWN %%·%
%%
%% Returns true if the window, sizer, or item at index is shown.
%%
%% Return Value:
%% See Also: wxSizer::Hide, wxSizer::Show
%%*%%*%%
-spec isShown(This, Index) -> boolean()
when
This :: wxSizer(),
Index :: integer();
(This, Window) -> boolean()
when
This :: wxSizer(),
Window :: wxWindow:wxWindow()
| wxSizer().
isShown(#wx_ref{type=ThisT,ref=ThisRef}, Index)
when
is_integer(Index) ->
?CLASS(ThisT,wxSizer),
wxe_util:call(?wxSizer_IsShown_1_0,
<<ThisRef:32/?UI,Index:32/?UI>>);
isShown(#wx_ref{type=ThisT,ref=ThisRef},
#wx_ref{type=WindowT,ref=WindowRef}) ->
?CLASS(ThisT,wxSizer),
WindowOP =
case
?CLASS_T(WindowT,wxWindow)
of
true ->
?wxSizer_IsShown_1_2;
_ ->
?CLASS(WindowT,wxSizer),
?wxSizer_IsShown_1_1
end,
wxe_util:call(WindowOP,
<<ThisRef:32/?UI,WindowRef:32/?UI>>).
%·%% LAYOUT %%·%
%%
%% Call this to force layout of the children anew,
%% e.g. after having added a child to or removed a child (window,
%% other sizer or space) from the sizer while keeping the current dimension.
%%
%% Return Value:
%% See Also:
%%*%%*%%
-spec layout(This) -> ok
when
This :: wxSizer().
layout(#wx_ref{type=ThisT,ref=ThisRef}) ->
?CLASS(ThisT,wxSizer),
wxe_util:cast(?wxSizer_Layout,
<<ThisRef:32/?UI>>).
%·%% PREPEND %%·%
%%
%%
%%
%% Return Value:
%% See Also:
%%*%%*%%
-spec prepend(This, Item) -> wxSizerItem:wxSizerItem()
when
This :: wxSizer(),
Item :: wxSizerItem:wxSizerItem().
prepend(#wx_ref{type=ThisT,ref=ThisRef},
#wx_ref{type=ItemT,ref=ItemRef}) ->
?CLASS(ThisT,wxSizer),
?CLASS(ItemT,wxSizerItem),
wxe_util:call(?wxSizer_Prepend_1,
<<ThisRef:32/?UI,ItemRef:32/?UI>>).
%·%% PREPEND %%·%
%%
%%
%%
%% Return Value:
%% See Also:
%%*%%*%%
-spec prepend(This, Width, Height) -> wxSizerItem:wxSizerItem()
when
This :: wxSizer(),
Width :: integer(),
Height :: integer();
(This, Window, [Option]) -> wxSizerItem:wxSizerItem()
when
This :: wxSizer(),
Window :: wxWindow:wxWindow()
| wxSizer(),
Option :: {proportion, integer()}
| {flag, integer()}
| {border, integer()}
| {userData, wx:wx_object()};
(This, Window, Flags) -> wxSizerItem:wxSizerItem()
when
This :: wxSizer(),
Window :: wxWindow:wxWindow()
| wxSizer(),
Flags :: wxSizerFlags:wxSizerFlags().
prepend(This,Width,Height)
when
is_record(This, wx_ref),
is_integer(Width),
is_integer(Height) -> prepend(This,Width,Height, []);
prepend(#wx_ref{type=ThisT,ref=ThisRef},
#wx_ref{type=WindowT,ref=WindowRef},
Options)
when
is_list(Options) ->
?CLASS(ThisT,wxSizer),
WindowOP =
case
?CLASS_T(WindowT,wxWindow)
of
true ->
?wxSizer_Prepend_2_1;
_ ->
?CLASS(WindowT,wxSizer),
?wxSizer_Prepend_2_0
end,
MOpts = fun({proportion, Proportion}, Acc) -> [<<1:32/?UI,Proportion:32/?UI>>|Acc];
({flag, Flag}, Acc) -> [<<2:32/?UI,Flag:32/?UI>>|Acc];
({border, Border}, Acc) -> [<<3:32/?UI,Border:32/?UI>>|Acc];
({userData, #wx_ref{type=UserDataT,ref=UserDataRef}}, Acc) -> ?CLASS(UserDataT,wx),[<<4:32/?UI,UserDataRef:32/?UI>>|Acc];
(BadOpt, _) -> erlang:error({badoption, BadOpt})
end,
BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)),
wxe_util:call(WindowOP,
<<ThisRef:32/?UI,WindowRef:32/?UI, BinOpt/binary>>);
prepend(#wx_ref{type=ThisT,ref=ThisRef},
#wx_ref{type=WindowT,ref=WindowRef},
#wx_ref{type=FlagsT,ref=FlagsRef}) ->
?CLASS(ThisT,wxSizer),
WindowOP =
case
?CLASS_T(WindowT,wxWindow)
of
true ->
?CLASS(FlagsT,wxSizerFlags),
?wxSizer_Prepend_2_3;
_ ->
?CLASS(WindowT,wxSizer),
?CLASS(FlagsT,wxSizerFlags),
?wxSizer_Prepend_2_2
end,
wxe_util:call(WindowOP,
<<ThisRef:32/?UI,WindowRef:32/?UI,FlagsRef:32/?UI>>).
%·%% PREPEND %%·%
%%
%% Same as wxSizer::Add, but prepends the items to the beginning of the
%% list of items (windows, subsizers or spaces) owned by this sizer.
%%
%% Return Value:
%% See Also:
%%*%%*%%
-spec prepend(This, Width, Height, [Option]) -> wxSizerItem:wxSizerItem()
when
This :: wxSizer(),
Width :: integer(),
Height :: integer(),
Option :: {proportion, integer()}
| {flag, integer()}
| {border, integer()}
| {userData, wx:wx_object()}.
prepend(#wx_ref{type=ThisT,ref=ThisRef}, Width, Height, Options)
when
is_integer(Width),
is_integer(Height),
is_list(Options) ->
?CLASS(ThisT,wxSizer),
MOpts = fun({proportion, Proportion}, Acc) -> [<<1:32/?UI,Proportion:32/?UI>>|Acc];
({flag, Flag}, Acc) -> [<<2:32/?UI,Flag:32/?UI>>|Acc];
({border, Border}, Acc) -> [<<3:32/?UI,Border:32/?UI>>|Acc];
({userData, #wx_ref{type=UserDataT,ref=UserDataRef}}, Acc) -> ?CLASS(UserDataT,wx),[<<4:32/?UI,UserDataRef:32/?UI>>|Acc];
(BadOpt, _) -> erlang:error({badoption, BadOpt})
end,
BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)),
wxe_util:call(?wxSizer_Prepend_3,
<<ThisRef:32/?UI,Width:32/?UI,Height:32/?UI, 0:32,BinOpt/binary>>).
%·%% PREPEND SPACER %%·%
%%
%% Prepends non-stretchable space to the sizer. More readable way of calling Prepend(size, size, 0).
%%
%% Return Value:
%% See Also:
%%*%%*%%
-spec prependSpacer(This, Size) -> wxSizerItem:wxSizerItem()
when
This :: wxSizer(),
Size :: integer().
prependSpacer(#wx_ref{type=ThisT,ref=ThisRef}, Size)
when
is_integer(Size) ->
?CLASS(ThisT,wxSizer),
wxe_util:call(?wxSizer_PrependSpacer,
<<ThisRef:32/?UI,Size:32/?UI>>).
%·%% PREPEND STRETCH SPACER / 1 %%·%
%%
%% See below...
%% @equiv prependStretchSpacer(This, [])
-spec prependStretchSpacer(This) -> wxSizerItem:wxSizerItem()
when
This :: wxSizer().
prependStretchSpacer(This)
when
is_record(This, wx_ref) -> prependStretchSpacer(This, []).
%·%% PREPEND STRETCH SPACER / 2 %%·%
%%
%% Prepends stretchable space to the sizer.
%% More readable way of calling Prepend(0, 0, prop).
%%
%% Return Value:
%% See Also:
%%*%%*%%
-spec prependStretchSpacer(This, [Option]) -> wxSizerItem:wxSizerItem()
when
This :: wxSizer(),
Option :: {prop, integer()}.
prependStretchSpacer(#wx_ref{type=ThisT,ref=ThisRef}, Options)
when
is_list(Options) ->
?CLASS(ThisT,wxSizer),
MOpts = fun({prop, Prop}, Acc) -> [<<1:32/?UI,Prop:32/?UI>>|Acc];
(BadOpt, _) -> erlang:error({badoption, BadOpt})
end,
BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)),
wxe_util:call(?wxSizer_PrependStretchSpacer,
<<ThisRef:32/?UI, 0:32,BinOpt/binary>>).
%·%% RECALC SIZES %%·%
%%
%% This method is abstract and has to be overwritten by any derived class.
%% Here, the sizer will do the actual calculation of its children's
%% positions and sizes.
%%
%% Return Value:
%% See Also:
%%*%%*%%
-spec recalcSizes(This) -> ok
when
This :: wxSizer().
recalcSizes(#wx_ref{type=ThisT,ref=ThisRef}) ->
?CLASS(ThisT,wxSizer),
wxe_util:cast(?wxSizer_RecalcSizes,
<<ThisRef:32/?UI>>).
%·%% REMOVE %%·%
%%
%% Removes a child from the sizer and destroys it if it is a sizer or a spacer,
%% but not if it is a window (because windows are owned by their parent window,
%% not the sizer). sizer is the wxSizer to be removed, index is the position
%% of the child in the sizer, e.g. 0 for the first item. This method does
%% not cause any layout or resizing to take place, call wxSizer:Layout to
%% update the layout "on screen" after removing a child from the sizer.
%%
%% NB: The method taking a wxWindow* parameter is deprecated as it does
%% not destroy the window as would usually be expected from Remove.
%% You should use wxSizer::Detach in new code instead.
%% There is currently no wxSizer method that will both detach and
%% destroy a wxWindow item.
%%
%% Returns true if the child item was found and removed, false otherwise.
%%
%% Return Value:
%% See Also:
%%*%%*%%
-spec remove(This, Index) -> boolean()
when
This :: wxSizer(),
Index :: integer();
(This, Sizer) -> boolean()
when
This :: wxSizer(),
Sizer :: wxSizer().
remove(#wx_ref{type=ThisT,ref=ThisRef}, Index)
when
is_integer(Index) ->
?CLASS(ThisT,wxSizer),
wxe_util:call(?wxSizer_Remove_1_0,
<<ThisRef:32/?UI,Index:32/?UI>>);
remove(#wx_ref{type=ThisT,ref=ThisRef},
#wx_ref{type=SizerT,ref=SizerRef}) ->
?CLASS(ThisT,wxSizer),
?CLASS(SizerT,wxSizer),
wxe_util:call(?wxSizer_Remove_1_1,
<<ThisRef:32/?UI,SizerRef:32/?UI>>).
%·%% REPLACE %%·%
%%
%% See also...
%% Return Value:
%% See Also:
%%*%%*%%
%%
-spec replace(This, Oldwin, Newwin) -> boolean()
when
This :: wxSizer(),
Oldwin :: wxWindow:wxWindow()
| wxSizer(),
Newwin :: wxWindow:wxWindow()
| wxSizer();
(This, Index, Newitem) -> boolean()
when
This :: wxSizer(),
Index :: integer(),
Newitem :: wxSizerItem:wxSizerItem().
replace(This, Oldwin, Newwin)
when
is_record(This, wx_ref),
is_record(Oldwin, wx_ref),
is_record(Newwin, wx_ref) -> replace(This,Oldwin,Newwin, []);
replace(#wx_ref{type=ThisT,ref=ThisRef},
Index,
#wx_ref{type=NewitemT,ref=NewitemRef})
when
is_integer(Index) ->
?CLASS(ThisT,wxSizer),
?CLASS(NewitemT,wxSizerItem),
wxe_util:call(?wxSizer_Replace_2,
<<ThisRef:32/?UI,Index:32/?UI,NewitemRef:32/?UI>>).
%·%% REPLACE %%·%
%%
%% Detaches the given oldwin, oldsz child from the sizer and replaces it with
%% the given window, sizer, or wxSizerItem.
%%
%% The detached child is removed only if it is a sizer or a spacer
%% (because windows are owned by their parent window, not the sizer).
%%
%% Use parameter recursive to search the given element
%% recursively in subsizers.
%%
%% This method does not cause any layout or resizing to take place,
%% call wxSizer::Layout to update the layout "on screen" after replacing a child from the sizer.
%%
%% Returns true if the child item was found and removed, false otherwise.
%%
%% Return Value:
%% See Also:
%%*%%*%%
-spec replace(This, Oldwin, Newwin, [Option]) -> boolean()
when
This :: wxSizer(),
Oldwin :: wxWindow:wxWindow() | wxSizer(),
Newwin :: wxWindow:wxWindow() | wxSizer(),
Option :: {recursive, boolean()}.
replace(#wx_ref{type=ThisT,ref=ThisRef},
#wx_ref{type=OldwinT,ref=OldwinRef},
#wx_ref{type=NewwinT,ref=NewwinRef}, Options)
when
is_list(Options) ->
?CLASS(ThisT,wxSizer),
OldwinOP =
case
?CLASS_T(OldwinT,wxWindow)
of
true ->
?CLASS(NewwinT,wxWindow),
?wxSizer_Replace_3_1;
_ ->
?CLASS(OldwinT,wxSizer),
?CLASS(NewwinT,wxSizer),
?wxSizer_Replace_3_0
end,
MOpts = fun({recursive, Recursive}, Acc) -> [<<1:32/?UI,(wxe_util:from_bool(Recursive)):32/?UI>>|Acc];
(BadOpt, _) -> erlang:error({badoption, BadOpt})
end,
BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)),
wxe_util:call(OldwinOP,
<<ThisRef:32/?UI,OldwinRef:32/?UI,NewwinRef:32/?UI, 0:32,BinOpt/binary>>).
%·%% SET DIMENSION %%·%
%%
%% Call this to force the sizer to take the given dimension and thus
%% force the items owned by the sizer to resize themselves according
%% to the rules defined by the parameter in the Add and Prepend methods.
%%
%% Return Value:
%% See Also:
%%*%%*%%
-spec setDimension(This, X, Y, Width, Height) -> ok
when
This :: wxSizer(),
X :: integer(),
Y :: integer(),
Width :: integer(),
Height :: integer().
setDimension(#wx_ref{type=ThisT,ref=ThisRef}, X, Y, Width, Height)
when
is_integer(X),
is_integer(Y),
is_integer(Width),
is_integer(Height) ->
?CLASS(ThisT,wxSizer),
wxe_util:cast(?wxSizer_SetDimension,
<<ThisRef:32/?UI,X:32/?UI,Y:32/?UI,Width:32/?UI,Height:32/?UI>>).
%·%% SET MIN SIZE %%·%
%%
%% Return Value:
%% See Also:
%%*%%*%%
-spec setMinSize(This, Size) -> ok
when
This :: wxSizer(),
Size :: {W :: integer(),
H :: integer()}.
setMinSize(#wx_ref{type=ThisT,ref=ThisRef}, {SizeW, SizeH})
when
is_integer(SizeW),
is_integer(SizeH) ->
?CLASS(ThisT,wxSizer),
wxe_util:cast(?wxSizer_SetMinSize_1,
<<ThisRef:32/?UI,SizeW:32/?UI,SizeH:32/?UI>>).
%·%% SET MIN SIZE %%·%
%%
%% Call this to give the sizer a minimal size.
%% Normally, the sizer will calculate its minimal size based purely on how
%% much space its children need. After calling this method GetMinSize
%% will return either the minimal size as requested by its children or the minimal size set here, depending on which is bigger.
%%
%%
%% Return Value:
%% See Also:
%%*%%*%%
-spec setMinSize(This, Width, Height) -> ok
when
This :: wxSizer(),
Width :: integer(),
Height :: integer().
setMinSize(#wx_ref{type=ThisT,ref=ThisRef}, Width, Height)
when
is_integer(Width),
is_integer(Height) ->
?CLASS(ThisT,wxSizer),
wxe_util:cast(?wxSizer_SetMinSize_2,
<<ThisRef:32/?UI,Width:32/?UI,Height:32/?UI>>).
%·%% SET ITEM MIN SIZE / 3 %%·%
%%
%% See below...
%% Return Value:
%% See Also:
%%*%%*%%
-spec setItemMinSize(This, Index, Size) -> boolean()
when
This :: wxSizer(),
Index :: integer(),
Size :: {W :: integer(),
H :: integer()};
(This, Window, Size) -> boolean()
when
This :: wxSizer(),
Window :: wxWindow:wxWindow()
| wxSizer(),
Size :: {W :: integer(),
H :: integer()}.
setItemMinSize(#wx_ref{type=ThisT,ref=ThisRef}, Index, {SizeW, SizeH})
when
is_integer(Index),
is_integer(SizeW),
is_integer(SizeH) ->
?CLASS(ThisT,wxSizer),
wxe_util:call(?wxSizer_SetItemMinSize_2_0,
<<ThisRef:32/?UI,Index:32/?UI,SizeW:32/?UI,SizeH:32/?UI>>);
setItemMinSize(#wx_ref{type=ThisT,ref=ThisRef},
#wx_ref{type=WindowT,ref=WindowRef},
{SizeW, SizeH})
when
is_integer(SizeW),
is_integer(SizeH) ->
?CLASS(ThisT,wxSizer),
WindowOP =
case
?CLASS_T(WindowT,wxWindow)
of
true ->
?wxSizer_SetItemMinSize_2_2;
_ ->
?CLASS(WindowT,wxSizer),
?wxSizer_SetItemMinSize_2_1
end,
wxe_util:call(WindowOP,
<<ThisRef:32/?UI,WindowRef:32/?UI,SizeW:32/?UI,SizeH:32/?UI>>).
%·%% SET ITEM MIN SIZE / 4 %%·%
%%
%% Set an item's minimum size by window, sizer, or position.
%% The item will be found recursively in the sizer's descendants.
%% This function enables an application to set the size of an item after initial creation.
%%
%% Return Value:
%% See Also:
%%*%%*%%
-spec setItemMinSize(This, Index, Width, Height) -> boolean()
when
This :: wxSizer(),
Index :: integer(),
Width :: integer(),
Height :: integer();
(This, Window, Width, Height) -> boolean()
when
This :: wxSizer(),
Window :: wxWindow:wxWindow()
| wxSizer(),
Width :: integer(),
Height :: integer().
setItemMinSize(#wx_ref{type=ThisT,ref=ThisRef}, Index, Width, Height)
when
is_integer(Index),
is_integer(Width),
is_integer(Height) ->
?CLASS(ThisT,wxSizer),
wxe_util:call(?wxSizer_SetItemMinSize_3_0,
<<ThisRef:32/?UI,Index:32/?UI,Width:32/?UI,Height:32/?UI>>);
setItemMinSize(#wx_ref{type=ThisT,ref=ThisRef},
#wx_ref{type=WindowT,ref=WindowRef},
Width,
Height)
when
is_integer(Width),
is_integer(Height) ->
?CLASS(ThisT,wxSizer),
WindowOP =
case
?CLASS_T(WindowT,wxWindow)
of
true ->
?wxSizer_SetItemMinSize_3_2;
_ ->
?CLASS(WindowT,wxSizer),
?wxSizer_SetItemMinSize_3_1
end,
wxe_util:call(WindowOP,
<<ThisRef:32/?UI,WindowRef:32/?UI,Width:32/?UI,Height:32/?UI>>).
%·%% SET SIZE HINTS %%·%
%%
%% This method first calls wxSizer::Fit and then SetSizeHints on the
%% window passed to it. This only makes sense when window is actually
%% a wxTopLevelWindow such as a wxFrame or a wxDialog, since SetSizeHints
%% only has any effect in these classes. It does nothing in normal windows
%% or controls.
%%
%% This method is commonly invoked in the constructor of a toplevel window
%% itself (see the sample in the description of wxBoxSizer) if the toplevel
%% window is resizable.
%%
%% Return Value:
%% See Also:
%%*%%*%%
-spec setSizeHints(This, Window) -> ok
when
This :: wxSizer(),
Window :: wxWindow:wxWindow().
setSizeHints(#wx_ref{type=ThisT,ref=ThisRef},
#wx_ref{type=WindowT,ref=WindowRef}) ->
?CLASS(ThisT,wxSizer),
?CLASS(WindowT,wxWindow),
wxe_util:cast(?wxSizer_SetSizeHints,
<<ThisRef:32/?UI,WindowRef:32/?UI>>).
%·%% SET VIRTUAL SIZE HINTS %%·%
%%
%% Tell the sizer to set the minimal size of the window virtual area to
%% match the sizer's minimal size. For windows with managed scrollbars
%% this will set them appropriately.
%%
%% Return Value:
%% See Also: wxScrolledWindow::SetScrollbars
%%*%%*%%
-spec setVirtualSizeHints(This, Window) -> ok
when
This :: wxSizer(),
Window :: wxWindow:wxWindow().
setVirtualSizeHints(#wx_ref{type=ThisT,ref=ThisRef},
#wx_ref{type=WindowT,ref=WindowRef}) ->
?CLASS(ThisT,wxSizer),
?CLASS(WindowT,wxWindow),
wxe_util:cast(?wxSizer_SetVirtualSizeHints,
<<ThisRef:32/?UI,WindowRef:32/?UI>>).
%·%% SHOW %%·%
%%
%% See below...
%% Return Value:
%% See Also: wxSizer::Hide, wxSizer::IsShown
%%*%%*%%
-spec show(This, Index) -> boolean()
when
This :: wxSizer(),
Index :: integer();
(This, Window) -> boolean()
when
This :: wxSizer(),
Window :: wxWindow:wxWindow()
| wxSizer();
(This, Show) -> ok
when
This :: wxSizer(),
Show :: boolean().
show(This,Index)
when
is_record(This, wx_ref),
is_integer(Index) -> show(This,Index, []);
show(This,Window)
when
is_record(This, wx_ref),
is_record(Window, wx_ref) -> show(This,Window, []);
show(#wx_ref{type=ThisT,ref=ThisRef}, Show)
when
is_boolean(Show) ->
?CLASS(ThisT,wxSizer),
wxe_util:cast(?wxSizer_Show_1,
<<ThisRef:32/?UI,(wxe_util:from_bool(Show)):32/?UI>>).
%·%% SHOW %%·%
%%
%% Shows or hides the window, sizer, or item at index.
%% To make a sizer item disappear or reappear, use Show() followed by Layout().
%% Use parameter recursive to show or hide elements found in subsizers.
%%
%% Returns true if the child item was found, false otherwise.
%%
%% Return Value:
%% See Also:
%%*%%*%%
-spec show(This, Index, [Option]) -> boolean()
when
This :: wxSizer(),
Index :: integer(),
Option :: {show, boolean()};
(This, Window, [Option]) -> boolean()
when
This :: wxSizer(),
Window :: wxWindow:wxWindow()
| wxSizer(),
Option :: {show, boolean()}
| {recursive, boolean()}.
show(#wx_ref{type=ThisT,ref=ThisRef}, Index, Options)
when
is_integer(Index),
is_list(Options) ->
?CLASS(ThisT,wxSizer),
MOpts = fun({show, Show}, Acc) -> [<<1:32/?UI,(wxe_util:from_bool(Show)):32/?UI>>|Acc];
(BadOpt, _) -> erlang:error({badoption, BadOpt})
end,
BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)),
wxe_util:call(?wxSizer_Show_2_0,
<<ThisRef:32/?UI,Index:32/?UI, BinOpt/binary>>);
show(#wx_ref{type=ThisT,ref=ThisRef},
#wx_ref{type=WindowT,ref=WindowRef},
Options)
when
is_list(Options) ->
?CLASS(ThisT,wxSizer),
WindowOP =
case
?CLASS_T(WindowT,wxWindow)
of
true ->
?wxSizer_Show_2_2;
_ ->
?CLASS(WindowT,wxSizer),
?wxSizer_Show_2_1
end,
MOpts = fun({show, Show}, Acc) -> [<<1:32/?UI,(wxe_util:from_bool(Show)):32/?UI>>|Acc];
({recursive, Recursive}, Acc) -> [<<2:32/?UI,(wxe_util:from_bool(Recursive)):32/?UI>>|Acc];
(BadOpt, _) -> erlang:error({badoption, BadOpt})
end,
BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)),
wxe_util:call(WindowOP,
<<ThisRef:32/?UI,WindowRef:32/?UI, BinOpt/binary>>).
%% ---------------------------------SIZER OVERVIEW---------------------------------
%%
%% Classes: wxSizer,
%% wxGridSizer,
%% wxFlexGridSizer,
%% wxBoxSizer,
%% wxStaticBoxSizer,
%%
%% GOOD PICS &
%% SOURCE LINK — http://docs.wxwidgets.org/2.8.12/wx_sizeroverview.html
%%
%% Sizers, as represented by the wxSizer class and its descendants in the wxWidgets
%% class hierarchy, have become the method of choice to define the layout of controls
%% in dialogs in wxWidgets because of their ability to create visually appealing
%% dialogs independent of the platform, taking into account the differences in size
%% and style of the individual controls. Unlike the original wxWidgets Dialog Editor,
%% editors such as wxDesigner, DialogBlocks, XRCed and wxWorkshop create dialogs
%% based exclusively on sizers, practically forcing the user to create platform
%% independent layouts without compromises.
%%
%% The next section describes and shows what can be done with sizers.
%% The following sections briefly describe how to program with
%% individual sizer classes.
%%
%% For information about the new wxWidgets resource system,
%% which can describe sizer-based dialogs, see the XML-based
%% resource system overview.
%%
%% SIZER TOPICS
%% ————————————
%% 1 · The idea behind sizers
%% 2 · Common Features
%% 3 · Hiding controls using sizers
%% 4 · Programming with wxBoxSizer
%% 5 · Programming with wxGridSizer
%% 6 · Programming with wxFlexGridSizer
%% 7 · Programming with wxStaticBoxSizer
%%
%% (1)— THE IDEA BEHIND SIZERS -(1)
%%
%% The layout algorithm used by sizers in wxWidgets is closely related to layout
%% systems in other GUI toolkits, such as Java's AWT, the GTK toolkit or the
%% Qt toolkit. It is based upon the idea of individual subwindows reporting
%% their minimal required size and their ability to get stretched if the size
%% of the parent window has changed. This will most often mean that the
%% programmer does not set the start-up size of a dialog, the dialog will
%% rather be assigned a sizer and this sizer will be queried about the
%% recommended size. This sizer in turn will query its children (which can
%% be normal windows, empty space or other sizers) so that a hierarchy of sizers
%% can be constructed. Note that wxSizer does not derive from wxWindow and thus
%% does not interfere with tab ordering and requires very few resources compared
%% to a real window on screen.
%%
%% What makes sizers so well fitted for use in wxWidgets is the fact that every
%% control reports its own minimal size and the algorithm can handle differences
%% in font sizes or different window (dialog item) sizes
%% on different platforms without problems.
%% For example, if the standard font as well as the overall design of
%% Linux/GTK widgets requires more space than on Windows, the initial
%% dialog size will automatically be bigger on Linux/GTK than on Windows.
%%
%% There are currently five different kinds of sizers available in wxWidgets.
%% Each represents either a certain way to lay out dialog items in a dialog
%% or it fulfills a special task such as wrapping a static box around a dialog
%% item (or another sizer). These sizers will be discussed one by one in the
%% text below. For more detailed information on how to use sizers
%% programmatically, please refer to the section Programming with Sizers.
%%
%%
%%
%% (2)—COMMON FEATURES-(2)
%%
%% All sizers are containers, that is,
%% they are used to lay out one dialog item (or several dialog items),
%% which they contain. Such items are sometimes referred to as the children
%% of the sizer. Independent of how the individual sizers lay out their children,
%% all children have certain features in common:
%%
%% · A minimal size:
%% This minimal size is usually identical to the initial size of the
%% controls and may either be set explicitly in the wxSize field of
%% the control constructor or may be calculated by wxWidgets, typically
%% by setting the height and/or the width of the item to -1.
%% Note that only some controls can calculate their size (such as a
%% checkbox) whereas others (such as a listbox) don't have any natural
%% width or height and thus require an explicit size. Some controls can
%% calculate their height, but not their width
%% (e.g. a single line text control)
%%
%% · A border:
%% The border is just empty space and is used to separate dialog
%% items in a dialog. This border can either be all around, or at
%% any combination of sides such as only above and below the control.
%% The thickness of this border must be set explicitly,
%% typically 5 points. The following samples show dialogs with
%% only one dialog item (a button) and a border of 0, 5, and 10 pixels
%% around the button.
%%
%% · An alignment:
%% Often, a dialog item is given more space than its minimal size plus its
%% border. Depending on what flags are used for the respective dialog item,
%% the dialog item can be made to fill out the available space entirely,
%% i.e. it will grow to a size larger than the minimal size,
%% or it will be moved to either the centre of the available space or
%% to either side of the space. The following sample shows a listbox and
%% three buttons in a horizontal box sizer; one button is centred,
%% one is aligned at the top, one is aligned at the bottom.
%%
%% · A stretch factor:
%% If a sizer contains more than one child and it is offered more space
%% than its children and their borders need, the question arises how to
%% distribute the surplus space among the children.
%% For this purpose, a stretch factor may be assigned to each child,
%% where the default value of 0 indicates that the child will not get
%% more space than its requested minimum size. A value of more than zero
%% is interpreted in relation to the sum of all stretch factors in the
%% children of the respective sizer, i.e. if two children get a stretch
%% factor of 1, they will get half the extra space each independent of
%% whether one control has a minimal sizer inferior to the other or not.
%% The following sample shows a dialog with three buttons, the first one
%% has a stretch factor of 1 and thus gets stretched, whereas the other
%% two buttons have a stretch factor of zero and keep their initial width.
%%
%% Within wxDesigner, this stretch factor gets set from the Option menu.
%%
%% (3)—HIDING CONTROLS USING SIZERS-(3)
%%
%% You can hide controls contained in sizers the same way you would hide any
%% control, using the wxWindow:Show method.
%%
%% However, wxSizer also offers a separate method which can tell the sizer not
%% to consider that control in its size calculations. To hide a window using
%% the sizer, call wxSizer::Show. You must then call Layout on the sizer to
%% force an update.
%%
%% This is useful when hiding parts of the interface, since you can avoid
%% removing the controls from the sizer and having to add them back later.
%%
%% Note: This is supported only by wxBoxSizer and wxFlexGridSizer.
%%
%%
%% + wxBoxSizer
%%
%% wxBoxSizer can lay out its children either vertically or horizontally,
%% depending on what flag is being used in its constructor. When using a
%% vertical sizer, each child can be centered, aligned to the right or aligned
%% to the left. Correspondingly, when using a horizontal sizer, each child
%% can be centered, aligned at the bottom or aligned at the top.
%% The stretch factor described in the last paragraph is used for
%% the main orientation, i.e. when using a horizontal box sizer,
%% the stretch factor determines how much the child can be stretched horizontally.
%% The following sample shows the same dialog as in the last sample,
%% only the box sizer is a vertical box sizer now.
%%
%%
%% + wxStaticBoxSizer
%%
%% wxStaticBoxSixer is the same as a wxBoxSizer, but surrounded by a static box.
%% Here is a sample:
%%
%%
%% + wxGridSizer
%%
%% wxGridSizer is a two-dimensional sizer. All children are given the same size,
%% which is the minimal size required by the biggest child, in this case the text
%% control in the left bottom border. Either the number of columns or the
%% number or rows is fixed and the grid sizer will grow in the
%% respectively other orientation if new children are added.
%%
%% For programming information, see wxGridSizer.
%%
%%
%% + wxFlexGridSizer
%%
%% Another two-dimensional sizer derived from wxGridSizer.
%% The width of each column and the height of each row are calculated
%% individually according to the minimal requirements from the respectively
%% biggest child. Additionally, columns and rows can be declared to be
%% stretchable if the sizer is assigned a size different from the one it
%% requested. The following sample shows the same dialog as the one above,
%% but using a flex grid sizer:
%%
%%
%% (4)—PROGRAMMING WITH WXBOXSIZER-(4)
%%
%% The basic idea behind a wxBoxSizer is that windows will most often be
%% laid out in rather simple basic geometry, typically in a row or a column
%% or several hierarchies of either.
%%
%% As an example, we will construct a dialog that will contain a text field
%% at the top and two buttons at the bottom. This can be seen as a top-hierarchy
%% lumn with the text at the top and buttons at the bottom and a low-hierarchy
%% row with an OK button to the left and a Cancel button to the right.
%% In many cases (particularly dialogs under Unix and normal frames) the main
%% window will be resizable by the user and this change of size will have to
%% get propagated to its children. In our case, we want the text area to grow
%% with the dialog, whereas the button shall have a fixed size.
%% In addition, there will be a thin border around all controls to make the
%% dialog look nice and - to make matter worse - the buttons shall be centred
%% as the width of the dialog changes.
%%
%% It is the unique feature of a box sizer, that it can grow in both
%% directions (height and width) but can distribute its growth in the main
%% direction (horizontal for a row) unevenly among its children.
%% In our example case, the vertical sizer is supposed to propagate all
%% its height changes to only the text area, not to the button area.
%% This is determined by the proportion parameter when adding a window
%% (or another sizer) to a sizer. It is interpreted as a weight factor,
%% i.e. it can be zero, indicating that the window may not be resized at all,
%% or above zero. If several windows have a value above zero,
%% the value is interpreted relative to the sum of all weight
%% factors of the sizer, so when adding two windows with a value of 1,
%% they will both get resized equally much and each half as much as the sizer owning them. Then what do we do when a column sizer changes its width? This behaviour is controlled by flags (the second parameter of the Add() function): Zero or no flag indicates that the window will preserve it is original size, wxGROW flag (same as wxEXPAND) forces the window to grow with the sizer, and wxSHAPED flag tells the window to change it is size proportionally, preserving original aspect ratio. When wxGROW flag is not used, the item can be aligned within available space. wxALIGN_LEFT, wxALIGN_TOP, wxALIGN_RIGHT, wxALIGN_BOTTOM, wxALIGN_CENTER_HORIZONTAL and wxALIGN_CENTER_VERTICAL do what they say. wxALIGN_CENTRE (same as wxALIGN_CENTER) is defined as (wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL). Default alignment is wxALIGN_LEFT | wxALIGN_TOP.
%%
%% As mentioned above, any window belonging to a sizer may have border,
%% and it can be specified which of the four sides may have this border,
%% using the wxTOP, wxLEFT, wxRIGHT and wxBOTTOM constants or wxALL for
%% all directions (and you may also use wxNORTH, wxWEST etc instead).
%% These flags can be used in combination with the alignment flags
%% above as the second parameter of the Add() method using the binary
%% or operator |. The sizer of the border also must be made known,
%% and it is the third parameter in the Add() method. This means,
%% that the entire behaviour of a sizer and its children can be
%% controlled by the three parameters of the Add() method.
%%
%% FOR A C++ example see the following link.
%%
%%
%%
%% (5)—PROGRAMMING WITH WXGRIDSIZER-(5)
%%
%% wxGridSizer is a sizer which lays out its children in a two-dimensional
%% table with all table fields having the same size, i.e. the width of each
%% field is the width of the widest child, the height of each field is the
%% height of the tallest child.
%%
%% (6)—PROGRAMMING WITH WXFLEXGRIDSIZER-(6)
%%
%% wxFlexGridSizer is a sizer which lays out its children in a two-dimensional
%% table with all table fields in one row having the same height and all fields
%% in one column having the same width, but all rows or all columns are not
%% necessarily the same height or width as in the wxGridSizer.
%%
%% (7)—PROGRAMMING WITH WXSTATICBOXSIZER-(7)
%%
%% wxStaticBoxSizer is a sizer derived from wxBoxSizer but adds a static box
%% around the sizer. Note that this static box has to be created separately.
%%
|