File: sheet.i

package info (click to toggle)
enthought-traits-ui 2.0.5-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 15,204 kB
  • ctags: 9,623
  • sloc: python: 45,547; sh: 32; makefile: 19
file content (2776 lines) | stat: -rw-r--r-- 135,695 bytes parent folder | download | duplicates (2)
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
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
%define DOCSTRING
"Classes for implementing a spreadsheet-like control, based on wxGrid"
%enddef

%module(package="wx", docstring=DOCSTRING) sheet

%{
#include <wx/sheet/sheet.h>

#include <iostream>

#include "wx/wxPython/wxPython.h"
#include "wx/wxPython/pyclasses.h"
%}

// import the wxPython interfaces
%import windows.i
%pythoncode { wx = _core }
%pythoncode { __docfilter__ = wx.__DocFilter(globals()) }

%include _sheet_rename.i

MAKE_CONST_WXSTRING_NOSWIG(EmptyString);
MAKE_CONST_WXSTRING_NOSWIG(PanelNameStr);
MAKE_CONST_WXSTRING_NOSWIG(DefaultDateTimeFormat);


//---------------------------------------------------------------------------
// Macros, similar to what's in helpers.h, to aid in the creation of
// virtual methods that are able to make callbacks to Python.  Many of these
// are specific to wxGrid and so are kept here to reduce the mess in helpers.h
// a bit.


%{
#define PYCALLBACK_GCA_COORDKIND(PCLASS, CBNAME)                               \
    wxSheetCellAttr CBNAME(wxSheetCoords coords, wxSheetAttr_Type c) {        \
        wxSheetCellAttr rval;                                            \
        bool found;                                                             \
        wxPyBlock_t blocked = wxPyBeginBlockThreads();                            \
        if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \
            PyObject* ro;                                                       \
            wxSheetCellAttr* ptr;                                                \
            ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iii)", coords, c)); \
            if (ro) {                                                           \
                if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxSheetCellAttr")))    \
                    rval = *ptr;                                                 \
                Py_DECREF(ro);                                                  \
            }                                                                   \
        }                                                                       \
        wxPyEndBlockThreads(blocked);                                             \
        if (! found)                                                            \
            return PCLASS::CBNAME(coords, c);                                     \
        return rval;                                                            \
    }                                                                           \
    wxSheetCellAttr base_##CBNAME(wxSheetCoords coords, wxSheetAttr_Type c) { \
        return PCLASS::CBNAME(coords, c);                                         \
    }



#define PYCALLBACK__GCACOORD(PCLASS, CBNAME)                                   \
    void CBNAME(wxSheetCoords coords, const wxSheetCellAttr& attr, wxSheetAttr_Type kind) {                           \
        wxPyBlock_t blocked = wxPyBeginBlockThreads();                                                \
        bool found;                                                             \
        if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \
            wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", coords, attr, kind));  \
        }                                                                       \
        wxPyEndBlockThreads(blocked);                                                  \
        if (! found)                                                            \
            PCLASS::CBNAME(coords, attr, kind);                                         \
    }                                                                           \
    void base_##CBNAME(wxSheetCoords coords, const wxSheetCellAttr& attr, wxSheetAttr_Type kind) {                    \
        PCLASS::CBNAME(coords, attr, kind);                                             \
    }



#define PYCALLBACK__GCAINT(PCLASS, CBNAME)                                      \
    void CBNAME(wxSheetCellAttr *attr, int val) {                                \
        wxPyBlock_t blocked = wxPyBeginBlockThreads();                                                \
        bool found;                                                             \
        if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \
            wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", attr, val));    \
            Py_DECREF(obj);                                                     \
        }                                                                       \
        wxPyEndBlockThreads(blocked);                                             \
        if (! found)                                                            \
            PCLASS::CBNAME(attr, val);                                          \
    }                                                                           \
    void base_##CBNAME(wxSheetCellAttr *attr, int val) {                         \
        PCLASS::CBNAME(attr, val);                                              \
    }



#define PYCALLBACK_INT__pure(CBNAME)                                            \
    int  CBNAME() {                                                             \
		std::cout << "PYCALLBACK_INT__pure " << m_myInst.m_self << "::" << #CBNAME << std::endl; \
        wxPyBlock_t blocked = wxPyBeginBlockThreads();                          \
        int rval = 0;                                                           \
        if (wxPyCBH_findCallback(m_myInst, #CBNAME))							\
        {																		\
			std::cout << "   found callback" << std::endl;                      \
            rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()"));         \
        }																		\
        wxPyEndBlockThreads(blocked);                                           \
        return rval;                                                            \
    }



#define PYCALLBACK_BOOL_COORD_pure(CBNAME)                                     \
    bool CBNAME(wxSheetCoords coords) {                                                 \
		std::cout << "PYCALLBACK_BOOL_COORD_pure #CBNAME" << std::endl; \
        wxPyBlock_t blocked = wxPyBeginBlockThreads();                            \
        bool rval = 0;                                                          \
        if (wxPyCBH_findCallback(m_myInst, #CBNAME))                            \
            rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",coords));   \
        wxPyEndBlockThreads(blocked);                                             \
        return rval;                                                            \
    }


#define PYCALLBACK_STRING_COORD_pure(CBNAME)                                   \
    wxString CBNAME(wxSheetCoords coords) {                                             \
		std::cout << "PYCALLBACK_STRING_COORD_pure " << #CBNAME << std::endl; \
        wxPyBlock_t blocked = wxPyBeginBlockThreads();                                                \
        wxString rval;                                                          \
        if (wxPyCBH_findCallback(m_myInst, #CBNAME)) {                          \
            PyObject* ro;                                                       \
            ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",coords));  \
            if (ro) {                                                           \
                rval = Py2wxString(ro);                                         \
                Py_DECREF(ro);                                                  \
            }                                                                   \
        }                                                                       \
        wxPyEndBlockThreads(blocked);                                                  \
        return rval;                                                            \
    }


#define PYCALLBACK__COORDSTRING_pure(CBNAME)                                   \
    void CBNAME(wxSheetCoords coords, const wxString& c) {                              \
		std::cout << "PYCALLBACK__COORDSTRING_pure " << #CBNAME << std::endl; \
        wxPyBlock_t blocked = wxPyBeginBlockThreads();                                                \
        if (wxPyCBH_findCallback(m_myInst, #CBNAME)) {                          \
            PyObject* s = wx2PyString(c);                                       \
            rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",coords,s));\
            Py_DECREF(s);                                                       \
        }                                                                       \
        wxPyEndBlockThreads(blocked);                                                  \
    }


#define PYCALLBACK_STRING_COORD(PCLASS, CBNAME)                                \
    wxString CBNAME(wxSheetCoords coords) {                                             \
		std::cout << "PYCALLBACK_STRING_COORD " << #CBNAME << std::endl; \
        bool found;                                                             \
        wxPyBlock_t blocked = wxPyBeginBlockThreads();                                                \
        wxString rval;                                                          \
        if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \
            PyObject* ro;                                                       \
            ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",coords));  \
            if (ro) {                                                           \
                rval = Py2wxString(ro);                                         \
                Py_DECREF(ro);                                                  \
            }                                                                   \
        }                                                                       \
        wxPyEndBlockThreads(blocked);                                                  \
        if (! found)                                                            \
            rval = PCLASS::CBNAME(coords);                                        \
        return rval;                                                            \
    }                                                                           \
    wxString base_##CBNAME(wxSheetCoords coords) {                                      \
        return PCLASS::CBNAME(coords);                                            \
    }


#define PYCALLBACK_BOOL_COORDSTRING(PCLASS, CBNAME)                            \
    bool CBNAME(wxSheetCoords coords, const wxString& c)  {                             \
		std::cout << "PYCALLBACK_BOOL_COORDSTRING " << #CBNAME << std::endl; \
        bool rval = 0;                                                          \
        bool found;                                                             \
        wxPyBlock_t blocked = wxPyBeginBlockThreads();                                                \
        if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \
            PyObject* s = wx2PyString(c);                                       \
            rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",coords,s));\
            Py_DECREF(s);                                                       \
        }                                                                       \
        wxPyEndBlockThreads(blocked);                                                  \
        if (! found)                                                            \
            rval = PCLASS::CBNAME(coords,c);                                       \
        return rval;                                                            \
    }                                                                           \
    bool base_##CBNAME(wxSheetCoords coords, const wxString& c) {                       \
        return PCLASS::CBNAME(coords,c);                                           \
    }




#define PYCALLBACK_LONG_COORD(PCLASS, CBNAME)                                  \
    long CBNAME(wxSheetCoords coords)  {                                                \
		std::cout << "PYCALLBACK_LONG_COORD " << #CBNAME << std::endl; \
        long rval;                                                              \
        bool found;                                                             \
        wxPyBlock_t blocked = wxPyBeginBlockThreads();                            \
        if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \
            rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", coords));  \
        wxPyEndBlockThreads(blocked);                                             \
        if (! found)                                                            \
            rval = PCLASS::CBNAME(coords);                                         \
        return rval;                                                            \
    }                                                                           \
    long base_##CBNAME(wxSheetCoords coords) {                                          \
        return PCLASS::CBNAME(coords);                                             \
    }



#define PYCALLBACK_BOOL_COORD(PCLASS, CBNAME)                                  \
    bool CBNAME(wxSheetCoords coords)  {                                                \
		std::cout << "PYCALLBACK_BOOL_COORD " << #CBNAME << std::endl; \
        bool rval = 0;                                                          \
        bool found;                                                             \
        wxPyBlock_t blocked = wxPyBeginBlockThreads();                            \
        if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \
            rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", coords));  \
        wxPyEndBlockThreads(blocked);                                             \
        if (! found)                                                            \
            rval = PCLASS::CBNAME(coords);                                         \
        return rval;                                                            \
    }                                                                           \
    bool base_##CBNAME(wxSheetCoords coords) {                                          \
        return PCLASS::CBNAME(coords);                                             \
    }



#define PYCALLBACK_DOUBLE_COORD(PCLASS, CBNAME)                                \
    double CBNAME(wxSheetCoords coords) {                                               \
		std::cout << "PYCALLBACK_DOUBLE_COORD " << #CBNAME << std::endl; \
        bool found;                                                             \
        wxPyBlock_t blocked = wxPyBeginBlockThreads();                            \
        double rval;                                                            \
        if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \
            PyObject* ro;                                                       \
            ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",coords));  \
            if (ro) {                                                           \
                PyObject* str = PyObject_Str(ro);                               \
                rval = PyFloat_AsDouble(str);                                   \
                Py_DECREF(ro);   Py_DECREF(str);                                \
            }                                                                   \
        }                                                                       \
        wxPyEndBlockThreads(blocked);                                                  \
        if (! found)                                                            \
            rval = PCLASS::CBNAME(a, b);                                        \
        return rval;                                                            \
    }                                                                           \
    double base_##CBNAME(wxSheetCoords coords) {                                        \
        return PCLASS::CBNAME(a, b);                                            \
    }



#define PYCALLBACK__(PCLASS, CBNAME)                                            \
    void CBNAME()  {                                                            \
		std::cout << "PYCALLBACK__ " << #PCLASS << "::" << #CBNAME << std::endl; \
        bool found;                                                             \
        wxPyBlock_t blocked = wxPyBeginBlockThreads();                                                \
        if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \
            wxPyCBH_callCallback(m_myInst, Py_BuildValue("()"));                \
        wxPyEndBlockThreads(blocked);                                                  \
        if (! found)                                                            \
            PCLASS::CBNAME();                                                   \
    }                                                                           \
    void base_##CBNAME() {                                                      \
        PCLASS::CBNAME();                                                       \
    }




#define PYCALLBACK_BOOL_SIZETSIZET(PCLASS, CBNAME)                              \
    bool CBNAME(size_t a, size_t b)  {                                          \
		std::cout << "PYCALLBACK_BOOL_SIZETSIZET " << #PCLASS << "::" << #CBNAME << std::endl; \
        bool rval = 0;                                                          \
        bool found;                                                             \
        wxPyBlock_t blocked = wxPyBeginBlockThreads();                                                \
        if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \
            rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b));  \
        wxPyEndBlockThreads(blocked);                                                  \
        if (! found)                                                            \
            rval = PCLASS::CBNAME(coords);                                         \
        return rval;                                                            \
    }                                                                           \
    bool base_##CBNAME(size_t a, size_t b) {                                    \
        return PCLASS::CBNAME(a,b);                                             \
    }



#define PYCALLBACK_BOOL_SIZET(PCLASS, CBNAME)                                   \
    bool CBNAME(size_t a)  {                                                    \
		std::cout << "PYCALLBACK_BOOL_SIZET " << #PCLASS << "::" << #CBNAME << std::endl; \
        bool rval = 0;                                                          \
        bool found;                                                             \
        wxPyBlock_t blocked = wxPyBeginBlockThreads();                                                \
        if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \
            rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)", a));     \
        wxPyEndBlockThreads(blocked);                                                  \
        if (! found)                                                            \
            rval = PCLASS::CBNAME(a);                                           \
        return rval;                                                            \
    }                                                                           \
    bool base_##CBNAME(size_t a) {                                              \
        return PCLASS::CBNAME(a);                                               \
    }


#define PYCALLBACK_STRING_INT(PCLASS, CBNAME)                                   \
    wxString CBNAME(int a) {                                                    \
		std::cout << "PYCALLBACK_STRING_INT " << #PCLASS << "::" << #CBNAME << std::endl; \
        bool found;                                                             \
        wxPyBlock_t blocked = wxPyBeginBlockThreads();                                                \
        wxString rval;                                                          \
        if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \
            PyObject* ro;                                                       \
            ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(i)",a));     \
            if (ro) {                                                           \
                rval = Py2wxString(ro);                                         \
                Py_DECREF(ro);                                                  \
            }                                                                   \
        }                                                                       \
        wxPyEndBlockThreads(blocked);                                                  \
        if (! found)                                                            \
            rval = PCLASS::CBNAME(a);                                           \
        return rval;                                                            \
    }                                                                           \
    wxString base_##CBNAME(int a) {                                             \
        return PCLASS::CBNAME(a);                                               \
    }


#define PYCALLBACK__INTSTRING(PCLASS, CBNAME)                                   \
    void CBNAME(int a, const wxString& c)  {                                    \
		std::cout << "PYCALLBACK__INTSTRING " << #PCLASS << "::" << #CBNAME << std::endl; \
        bool found;                                                             \
        wxPyBlock_t blocked = wxPyBeginBlockThreads();                                                \
        if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) {                \
            PyObject* s = wx2PyString(c);                                       \
            wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iO)",a,s));          \
            Py_DECREF(s);                                                       \
        }                                                                       \
        wxPyEndBlockThreads(blocked);                                                  \
        if (! found)                                                            \
            PCLASS::CBNAME(a,c);                                                \
    }                                                                           \
    void base_##CBNAME(int a, const wxString& c) {                              \
        PCLASS::CBNAME(a,c);                                                    \
    }




#define PYCALLBACK_BOOL_(PCLASS, CBNAME)                                        \
    bool CBNAME()  {                                                            \
		std::cout << "PYCALLBACK_BOOL_ " << #PCLASS << "::" << #CBNAME << std::endl; \
        bool rval = 0;                                                          \
        bool found;                                                             \
        wxPyBlock_t blocked = wxPyBeginBlockThreads();                                                \
        if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \
            rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("()"));         \
        wxPyEndBlockThreads(blocked);                                                  \
        if (! found)                                                            \
            rval = PCLASS::CBNAME();                                            \
        return rval;                                                            \
    }                                                                           \
    bool base_##CBNAME() {                                                      \
        return PCLASS::CBNAME();                                                \
    }



#define PYCALLBACK__SIZETINT(PCLASS, CBNAME)                                    \
    void CBNAME(size_t a, int b)  {                                             \
		std::cout << "PYCALLBACK__SIZETINT " << #PCLASS << "::" << #CBNAME << std::endl; \
        bool found;                                                             \
        wxPyBlock_t blocked = wxPyBeginBlockThreads();                                                \
        if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \
            wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", a,b));         \
        wxPyEndBlockThreads(blocked);                                                  \
        if (! found)                                                            \
            PCLASS::CBNAME(a,b);                                                \
    }                                                                           \
    void base_##CBNAME(size_t a, int b) {                                       \
        PCLASS::CBNAME(a,b);                                                    \
    }




#define PYCALLBACK__COORDLONG(PCLASS, CBNAME)                                  \
    void CBNAME(wxSheetCoords coords, long c)  {                                        \
		std::cout << "PYCALLBACK__COORDLONG " << #PCLASS << "::" << #CBNAME << std::endl; \
        bool found;                                                             \
        wxPyBlock_t blocked = wxPyBeginBlockThreads();                                                \
        if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \
            wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", coords,c));      \
        wxPyEndBlockThreads(blocked);                                                  \
        if (! found)                                                            \
            PCLASS::CBNAME(coords,c);                                              \
    }                                                                           \
    void base_##CBNAME(wxSheetCoords coords, long c) {                                  \
        PCLASS::CBNAME(coords,c);                                                  \
    }




#define PYCALLBACK__COORDDOUBLE(PCLASS, CBNAME)                                \
    void CBNAME(wxSheetCoords coords, double c)  {                                      \
		std::cout << "PYCALLBACK__COORDDOUBLE " << #PCLASS << "::" << #CBNAME << std::endl; \
        bool found;                                                             \
        wxPyBlock_t blocked = wxPyBeginBlockThreads();                                                \
        if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \
            wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iif)", coords,c));      \
        wxPyEndBlockThreads(blocked);                                                  \
        if (! found)                                                            \
            PCLASS::CBNAME(coords,c);                                              \
    }                                                                           \
    void base_##CBNAME(wxSheetCoords coords, double c) {                                \
        PCLASS::CBNAME(coords,c);                                                  \
    }



#define PYCALLBACK__COORDBOOL(PCLASS, CBNAME)                                  \
    void CBNAME(wxSheetCoords coords, bool c)  {                                        \
		std::cout << "PYCALLBACK__COORDBOOL " << #PCLASS << "::" << #CBNAME << std::endl; \
        bool found;                                                             \
        wxPyBlock_t blocked = wxPyBeginBlockThreads();                                                \
        if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME)))                  \
            wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", coords,c));      \
        wxPyEndBlockThreads(blocked);                                                  \
        if (! found)                                                            \
            PCLASS::CBNAME(a,b,c);                                              \
    }                                                                           \
    void base_##CBNAME(wxSheetCoords coords, bool c) {                                  \
        PCLASS::CBNAME(coords,c);                                                  \
    }




%}

//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------

#define wxSHEET_VALUE_STRING     "string"
#define wxSHEET_VALUE_BOOL       "bool"
#define wxSHEET_VALUE_NUMBER     "long"
#define wxSHEET_VALUE_FLOAT      "double"
#define wxSHEET_VALUE_CHOICE     "choice"
#define wxSHEET_VALUE_TEXT       "string"
#define wxSHEET_VALUE_LONG       "long"
#define wxSHEET_VALUE_CHOICEINT  "choiceint"
#define wxSHEET_VALUE_DATETIME   "datetime"

enum wxSheetUpdate_Type
{
    wxSHEET_UpdateNone           = 0x0000, // update nothing
    
    wxSHEET_UpdateGridCellValues = 0x0001, // update the grid cell data container
    wxSHEET_UpdateRowLabelValues = 0x0002, // update the row label data container
    wxSHEET_UpdateColLabelValues = 0x0004, // update the col label data container
    wxSHEET_UpdateLabelValues    = wxSHEET_UpdateRowLabelValues|wxSHEET_UpdateColLabelValues, // update the label containers    
    wxSHEET_UpdateValues         = wxSHEET_UpdateGridCellValues|wxSHEET_UpdateLabelValues,
    
    wxSHEET_UpdateSpanned        = 0x0008, // update the spanned cells
    
    wxSHEET_UpdateGridCellAttrs  = 0x0010, // update grid cell attributes
    wxSHEET_UpdateRowLabelAttrs  = 0x0020, // update row label attributes
    wxSHEET_UpdateColLabelAttrs  = 0x0040, // update col label attributes
    wxSHEET_UpdateLabelAttrs     = wxSHEET_UpdateRowLabelAttrs|wxSHEET_UpdateColLabelAttrs,
    wxSHEET_UpdateAttributes     = wxSHEET_UpdateGridCellAttrs|wxSHEET_UpdateLabelAttrs, // update the attr container
    
    wxSHEET_UpdateSelection      = 0x0100, // update the selection
    
    wxSHEET_UpdateAll            = (wxSHEET_UpdateValues|wxSHEET_UpdateSpanned|wxSHEET_UpdateAttributes|wxSHEET_UpdateSelection),
    wxSHEET_UpdateType_Mask      = wxSHEET_UpdateAll
};

enum wxSheetSelectionMode_Type 
{
	wxSHEET_SelectNone  = 0x0001, // don't allow selections by mouse or keyboard
								// direct calls to the selections work however
	wxSHEET_SelectCells = 0x0002, // single cells, blocks, rows, and cols
	wxSHEET_SelectRows  = 0x0004, // only rows can be selected
	wxSHEET_SelectCols  = 0x0008  // only cols can be selected
};
%pythoncode {
SelectNone    = wxSHEET_SelectNone;
SelectCells   = wxSHEET_SelectCells
SelectRows    = wxSHEET_SelectRows
SelectColumns = wxSHEET_SelectCols
}

enum wxSheetAttr_Type    
{
    wxSHEET_AttrDefault = 0x00010, 
    wxSHEET_AttrCell    = 0x00020, 
    wxSHEET_AttrRow     = 0x00040, 
    wxSHEET_AttrCol     = 0x00080, 
    wxSHEET_AttrAny     = wxSHEET_AttrDefault|wxSHEET_AttrCell|wxSHEET_AttrRow|wxSHEET_AttrCol,    
    wxSHEET_AttrType_Mask = wxSHEET_AttrAny
};



%typemap(out) wxArraySheetBlock& {
    $result = PyList_New(0);
    size_t idx;
    for (idx = 0; idx < (*$1).GetCount(); idx += 1) {
        wxSheetBlock& block = (*$1).Item(idx);
        PyObject* obj = SWIG_NewPointerObj((void *)(&block), SWIGTYPE_p_wxSheetBlock, 0);
        PyList_Append($result, obj);
        Py_DECREF(obj);
    }
}

%typemap(out) wxPoint {
	$result = PyTuple_New(2);
    PyTuple_SET_ITEM($result, 0, PyInt_FromLong($1.x));
    PyTuple_SET_ITEM($result, 1, PyInt_FromLong($1.y));
}	
	
class wxSheetCoords
{
public:
    wxSheetCoords();
    wxSheetCoords( int row, int col );
    
    int  GetRow() const;
    int  GetCol() const;

    void SetRow( int row );
    void SetCol( int col );
    void Set( int row, int col );

    wxSheetCoords& ShiftRow( int row );
    wxSheetCoords& ShiftCol( int col );
    wxSheetCoords& Shift( int rows, int cols );
    void SwapRowCol();

    wxSheetCoords GetShifted( int rows, int cols ) const;
    wxSheetCoords GetSwapped() const;

    wxSheetCoords SheetToRowLabel()    const;
    wxSheetCoords SheetToColLabel()    const;
    wxSheetCoords SheetToCornerLabel() const;
    
    bool UpdateRows( size_t row, int numRows );
    bool UpdateCols( size_t col, int numCols );
    
    wxSheetCoords operator+(const wxSheetCoords& c);
    wxSheetCoords operator-(const wxSheetCoords& c);
    wxSheetCoords& operator+=(const wxSheetCoords& c);
    wxSheetCoords& operator-=(const wxSheetCoords& c);
    bool operator == (const wxSheetCoords& other) const;
    bool operator != (const wxSheetCoords& other) const;
    bool operator <  (const wxSheetCoords& other) const;
    bool operator <= (const wxSheetCoords& other) const;
    bool operator >  (const wxSheetCoords& other) const;
    bool operator >= (const wxSheetCoords& other) const;

    int m_row;
    int m_col;    
};
	

class wxSheetChildWindow : public wxWindow
{
public:
    wxSheetChildWindow( wxSheet *parent, wxWindowID id = wxID_ANY,
                        const wxPoint &pos = wxDefaultPosition, 
                        const wxSize &size = wxDefaultSize,
                        long style = wxWANTS_CHARS|wxBORDER_NONE|wxCLIP_CHILDREN,
                        const wxString& name = wxT("wxSheetChildWindow") );

    // implementation
    void OnPaint( wxPaintEvent& event );
    void OnMouse( wxMouseEvent& event );
    void OnKeyAndChar( wxKeyEvent& event );
    void OnFocus( wxFocusEvent& event );
    void OnEraseBackground( wxEraseEvent& ); 

    wxSheet* GetOwner() const { return m_owner; }
    
    wxSheet *m_owner;
    int      m_mouseCursor; // remember the last cursor set for this window  
    
    %extend {
		wxWindow* CastAsWxWindow()
		{
			return static_cast<wxWindow*>(self);
		}
	}
      
};

/*
class wxSheetRefData : public wxObjectRefData
{
public:
    wxSheetRefData();
    virtual ~wxSheetRefData();\
    
    // Find/Add/Remove sheets that share this data - used for wxSheetSplitter
    int  FindSheet(wxSheet* sheet) const;
    bool HasSheet(wxSheet* sheet) const;
    void AddSheet(wxSheet* sheet);
    void RemoveSheet(wxSheet* sheet);
    wxSheet *GetSheet(size_t n) const;
    size_t GetSheetCount() const;

};
*/

MustHaveApp(wxSheet);

class wxSheet : public wxWindow
{
public:
    wxSheet( wxWindow *parent, wxWindowID id,
             const wxPoint& pos = wxDefaultPosition,
             const wxSize& size = wxDefaultSize,
             long style = wxWANTS_CHARS,
             const wxString& name = wxT("wxSheet") );

    bool Create( wxWindow *parent, wxWindowID id,
                 const wxPoint& pos = wxDefaultPosition,
                 const wxSize& size = wxDefaultSize,
                 long style = wxWANTS_CHARS,
                 const wxString& name = wxT("wxSheet") );                 

    virtual ~wxSheet();
    virtual bool Destroy();    

    // ref another wxSheet's ref data - see usage in wxSheetSplitter
    void RefSheet(wxSheet* otherSheet);
    // Create a new wxSheet with same parent, used for wxSheetSplitter.
    //   override this so that the top left sheet in the splitter can return
    //   a "new MySheet" for the other sheets as necessary
    //   This is one of the few ways for the splitter to create new sheets.
    virtual wxSheet* Clone(wxWindowID id = wxID_ANY);

    // override wxWindow::Enable to ensure proper refresh
    virtual bool Enable(bool enable = true);

    // ------------------------------------------------------------------------
    // Create/Set/Get wxSheetTable - the underlying data to be displayed

    wxSheetTable* GetTable() const { return GetSheetRefData()->m_table; }
    // Set your own table derived from wxSheetTable, if takeOwnership the
    //   the table will be deleted when this window is destroyed
    bool SetTable( wxSheetTable *table, bool takeOwnership );  
    
    // Create a wxSheetTable using string data containers to use
    //   see this function to see how to setup the table and use SetTable 
    //   for the case where you want to customize things
    //   This function exists to show how to  create and assign tables
    bool CreateGrid( int numRows, int numCols, int options = 0 );

    // ------------------------------------------------------------------------
    // Dimensions of the number of cells on the sheet and helper cell functions
    
    int GetNumberRows() const { return GetSheetRefData()->m_rowEdges.GetCount(); }
    int GetNumberCols() const { return GetSheetRefData()->m_colEdges.GetCount(); }

    // Is the coords anywhere in labels or grid, -1 to GetNumberRows/Cols()-1
    bool ContainsCell( const wxSheetCoords& coords ) const 
        { return (coords.m_row >= -1) && (coords.m_col >= -1) &&
                 (coords.m_row < GetNumberRows()) && 
                 (coords.m_col < GetNumberCols()); }
                 
    // returns true if the coords are within the grid cells of the sheet
    bool ContainsGridRow( int row ) const { return (row >= 0) && (row < GetNumberRows()); }
    bool ContainsGridCol( int col ) const { return (col >= 0) && (col < GetNumberCols()); }
    bool ContainsGridCell( const wxSheetCoords& coords ) const
        { return ContainsGridRow(coords.m_row) && ContainsGridCol(coords.m_col); }

    // returns true if the coords are within the row/col label cells
    bool ContainsRowLabelCell( const wxSheetCoords& coords ) const
        { return (coords.m_col == -1) && ContainsGridRow(coords.m_row); }
    bool ContainsColLabelCell( const wxSheetCoords& coords ) const
        { return (coords.m_row == -1) && ContainsGridCol(coords.m_col); }

    // static helper functions to determine what type of cell it is, not check validity
        
    static bool IsGridCell(const wxSheetCoords& coords);
    static bool IsLabelCell(const wxSheetCoords& coords);
    static bool IsRowLabelCell(const wxSheetCoords& coords);
    static bool IsColLabelCell(const wxSheetCoords& coords);
    static bool IsCornerLabelCell(const wxSheetCoords& coords);
    
    // Get an enum value of what window the coords are meant for
//    static wxSheetCell_Type GetCellCoordsType(const wxSheetCoords& coords);
        
    // "clear" the contents of the grid (depends on table's Clear() function)
    //   the string implementations clear the cell values, not the # rows/cols
    void ClearValues(int update = wxSHEET_UpdateValues); 
        
    // Insert/Add/DeleteRows/Cols to the grid cells
    //   update contains or'ed values of enum wxSheetUpdate_Type.
    //   you proabably want UpdateAll unless you ensure that no problems will occur
    //   or you will update some other way
    bool InsertRows( size_t row, size_t numRows, int update = wxSHEET_UpdateAll );
    bool AppendRows( size_t numRows, int update = wxSHEET_UpdateAll );
    bool DeleteRows( size_t row, size_t numRows, int update = wxSHEET_UpdateAll );
        
    bool InsertCols( size_t col, size_t numCols, int update = wxSHEET_UpdateAll );
    bool AppendCols( size_t numCols, int update = wxSHEET_UpdateAll );
    bool DeleteCols( size_t col, size_t numCols, int update = wxSHEET_UpdateAll );

    // Set exactly the number of rows or cols, these functions Append or
    // Delete rows/cols to/from the end. If you are setting attributes for 
    // particular cells/rows/cols you probably won't want to use these
    bool SetNumberRows( size_t rows, int update = wxSHEET_UpdateAll );
    bool SetNumberCols( size_t cols, int update = wxSHEET_UpdateAll );
    bool SetNumberCells( size_t rows, size_t cols, int update = wxSHEET_UpdateAll );
    
    // Inserting/Appending/Deleting rows/cols functions are forwarded here
    //   and then sent to the wxSheetTable::UpdateRows/Cols functions.
    //   numRows/Cols > 0 : InsertRows/Cols at row/col else if < 0 delete
    //   row/col == GetNumberRows/Cols && numRows/Cols > 0 to append to end
    virtual bool UpdateRows( size_t row, int numRows, int update = wxSHEET_UpdateAll );
    virtual bool UpdateCols( size_t col, int numCols, int update = wxSHEET_UpdateAll );
        
    // ------------------------------------------------------------------------
    // Dimensions of the row and column sizes
    
    // Get/Set the default height/width of newly created rows/cols
    //   if resizeExisting then resize all to match the newly set default
    int  GetDefaultRowHeight() const { return GetSheetRefData()->m_rowEdges.GetDefaultSize(); }
    int  GetDefaultColWidth()  const { return GetSheetRefData()->m_colEdges.GetDefaultSize(); }
    void SetDefaultRowHeight( int height, bool resizeExistingRows = false );
    void SetDefaultColWidth( int width, bool resizeExistingCols = false );
    
    // Get/Set the absolute min row/col width/height, 0 for no min size
    //   Call during grid creation, existing rows/cols are not resized
    //   This value is used when dragging cell size with the mouse if no 
    //   particular min size for a row/col has been set
    int  GetMinimalAcceptableRowHeight() const { return GetSheetRefData()->m_rowEdges.GetMinAllowedSize(); }
    int  GetMinimalAcceptableColWidth()  const { return GetSheetRefData()->m_colEdges.GetMinAllowedSize(); }
    void SetMinimalAcceptableRowHeight(int height) { GetSheetRefData()->m_rowEdges.SetMinAllowedSize(height); }
    void SetMinimalAcceptableColWidth(int width)   { GetSheetRefData()->m_colEdges.SetMinAllowedSize(width); }

    // Don't allow specific rows/cols to be resized smaller than this
    //   Call during grid creation, existing rows/cols are not resized
    //   The setting is cleared to default val if width/height is < min acceptable
    int  GetMinimalRowHeight(int row) const { return GetSheetRefData()->m_rowEdges.GetMinSize(row); }
    int  GetMinimalColWidth(int col) const  { return GetSheetRefData()->m_colEdges.GetMinSize(col); }
    void SetMinimalRowHeight(int row, int height) { GetSheetRefData()->m_rowEdges.SetMinSize(row, height); }
    void SetMinimalColWidth(int col, int width)   { GetSheetRefData()->m_colEdges.SetMinSize(col, width); }

    // Set the height of a row or width of a col, -1 notation for labels
    //  use height/width = -1 to autosize from the row/col labels
    void SetRowHeight( int row, int height );
    void SetColWidth(  int col, int width );
    
    // Get the height/top/bottom for rows, uses -1 notation
    int GetRowHeight(int row) const;
    int GetRowTop(int row) const;
    int GetRowBottom(int row) const;
    // Get the width/left/right for cols, uses -1 notation
    int GetColWidth(int col) const;
    int GetColLeft(int col) const;
    int GetColRight(int col) const;
    // Get the width, height of a cell as a wxSize, -1 notation
    //  this does not include spanned cells
    wxSize GetCellSize(const wxSheetCoords& coords) const;
        
    // does the cell have a non-zero width and height, may not be visible, -1 notation
    bool IsCellShown( const wxSheetCoords& coords ) const;
       
    // grid may occupy more space than needed for its rows/columns, this
    // function allows to set how big this margin space is
    void SetMargins(int width, int height)
        { GetSheetRefData()->m_marginSize.x = wxMax(0, width); 
          GetSheetRefData()->m_marginSize.y = wxMax(0, height); }
    
    // Get the renderer's best size for the cell, uses -1 notation
    wxSize GetCellBestSize(const wxSheetCoords& coords, wxDC *dc = NULL) const;
    // Get the best height of a row or the best width of a col using the 
    //   renderer's best size, iterating though all cells in the row or col.
    int GetRowBestHeight(int row) const;
    int GetColBestWidth(int col) const;

    // ------------------------------------------------------------------------
    // Row/Col label size

    // Get the fixed initial size of the width of row labels or height of col labels
    int GetDefaultRowLabelWidth()  const { return WXSHEET_DEFAULT_ROW_LABEL_WIDTH; }
    int GetDefaultColLabelHeight() const { return WXSHEET_DEFAULT_COL_LABEL_HEIGHT; }

    // Get/Set the row/col label widths, 
    //   if zero_not_shown and row/col & corner not shown return 0
    int  GetRowLabelWidth(bool zero_not_shown = true)  const;
    int  GetColLabelHeight(bool zero_not_shown = true) const;
    void SetRowLabelWidth( int width );
    void SetColLabelHeight( int height );

    // ------------------------------------------------------------------------
    // Auto sizing of the row/col widths/heights
    
    // automatically size the col/row to fit to its contents, if setAsMin, 
    // this optimal width will also be set as minimal width for this column
    // returns the width or height used.
    int AutoSizeRow( int row, bool setAsMin = true );
    int AutoSizeCol( int col, bool setAsMin = true );

    // auto size all columns (very ineffective for big grids!)
    void AutoSizeRows( bool setAsMin = true );
    void AutoSizeCols( bool setAsMin = true );

    // auto size the grid, that is make the columns/rows of the "right" size
    // and also set the grid size to just fit its contents
    void AutoSize( bool setAsMin = true );

    // autosize row height depending on label text
    void AutoSizeRowLabelHeight( int row );
    // autosize column width depending on label text
    void AutoSizeColLabelWidth( int col );

    // Force the col widths to be of equal size so that they fit within the 
    // the window size. This is maintained even when the window is resized. 
    // The col widths will not be sized less than min_width in pixels. 
    // Use this if you know that the window will be of a reasonable size to 
    // fit the cols, but you don't want to track the EVT_SIZE yourself.
    // use a min_width = 0 to turn it off
    void SetEqualColWidths(int min_width);
    
    // ------------------------------------------------------------------------
    // Row/Col drag resizing enabled or disabled
    //
    // if CanDragRow/ColSize the rows/cols can be resized by the mouse
    // if CanDragGridSize you can resize the rows/cols in the grid window
    //   else you resize in the label windows (if CanDragRow/ColSize is true)
    
    void EnableDragRowSize( bool enable = true );
    void EnableDragColSize( bool enable = true );
    void EnableDragGridSize(bool enable = true );
    void DisableDragRowSize();
    void DisableDragColSize();
    void DisableDragGridSize();
    bool CanDragRowSize()  const;
    bool CanDragColSize()  const;
    bool CanDragGridSize() const;
    
    // Directly set the dragging of the cell size use wxSheetDragCellSize_Type enums
    void SetDragCellSize( int type );
    void SetDragCellSize( int type, bool enable );
    int GetDragCellSize() const;
    
    // ------------------------------------------------------------------------
    // Grid line, cell highlight, selection colouring

    // Draw the grid lines, wxHORIZONAL | wxVERTICAL (wxBOTH), 0 for none
    void EnableGridLines( int dir = wxBOTH );
    int  GridLinesEnabled() const;
    
    const wxColour& GetGridLineColour() const;
    void            SetGridLineColour( const wxColour& colour );
    
    const wxColour& GetCursorCellHighlightColour();
    int             GetCursorCellHighlightPenWidth()   const;
    int             GetCursorCellHighlightROPenWidth() const;
    void            SetCursorCellHighlightColour( const wxColour& colour );
    void            SetCursorCellHighlightPenWidth(int width);
    void            SetCursorCellHighlightROPenWidth(int width);

    // get/set the colour bounding the labels to give 3-D effect
    const wxColour& GetLabelOutlineColour() const;
    void            SetLabelOutlineColour( const wxColour& colour );
    
    const wxColour& GetSelectionBackground() const;
    const wxColour& GetSelectionForeground() const;
    void            SetSelectionBackground(const wxColour& c);
    void            SetSelectionForeground(const wxColour& c);
    
    // ------------------------------------------------------------------------
    // Span, cells can span across multiple cells, hiding cells below
    //
    // Normally cells are of size 1x1, but they can be larger. 
    // The other cells can still have values and attributes, but they
    // will not be used since GetCellOwner is used for most coord operations
    // so that the underlying cell values and attributes are ignored.
    // The span for the owner cell is 1x1 or larger, the span for other
    // cells contained within the spanned block have a cell span of <= 0, such 
    // that coords + GetCellSpan() = the owner cell
    //
    // You can completely override this functionality if you provide 
    //   HasSpannedCells, GetCellBlock, SetCellSpan

    // Are there any spanned cells at all?
    virtual bool HasSpannedCells() const;
    
    // if cell is part of a spanning cell, return owner's coords else input coords
    wxSheetCoords GetCellOwner( const wxSheetCoords& coords ) const;    
    // Get a block of the cell, unless a spanned cell it's of size 1,1
    //   note: the top left of block is the owner cell of coords
    virtual wxSheetBlock GetCellBlock( const wxSheetCoords& coords ) const;
    // Get the span of a cell, the owner (top right) cell always has a span of 
    //  (1, 1) or greater. The other cells in a spanned block will have a span 
    //  (<1, <1) such that, coords + coordsSpan = ownerCoords
    wxSheetCoords GetCellSpan( const wxSheetCoords& coords ) const;
    // Set the span of a cell, must be 1x1 or greater, 
    // To remove a spanned cell set it to a cell of size 1x1
    // For grid cells the whole block must be contained within the grid cells 
    //  and if the block intersects a previously spanned cell block the top left 
    //  corners must match up. 
    // Row and Col labels can span cells as well, spanned row labels must have a
    //  width of 1 and a height of >= 1, col labels a height of 1 and width >= 1
    virtual void SetCellSpan( const wxSheetBlock& block );
    void SetCellSpan( const wxSheetCoords& coords, const wxSheetCoords& numRowsCols );

    // Get a pointer to the spanned blocks to iterate through, may return NULL.
    const wxSheetSelection* GetSpannedBlocks() const;
    
    // ------------------------------------------------------------------------
    // Get/Set attributes for the cells, row, col, corner labels

    // See wxSheetAttr_Type for a description of the type of attribute

    // The coords are specified as
    //   Grid area    : (0 <= row < GetNumberRows), (0 <= col < GetNumberCols)
    //   Corner label : row = col = -1
    //   Row labels   : (0 <= row < GetNumberRows), col = -1
    //   Col labels   : row = -1, (0 <= col < GetNumberCols)
    
    // For the wxSHEET_AttrDefault type the coords should be contained within the 
    //   size of the sheet, but the particular values are not used.
    //   see const wxGridCellSheetCoords = (0,0) for example
    //   wxRowLabelSheetCoords, wxColLabelSheetCoords, wxCornerLabelSheetCoords
    
    // To completely override this you may provide alternate 
    // GetOrCreateAttr, GetAttr, and SetAttr functions.  

    // Make sure that the last default attr of initAttr is defAttr
    //   This is called internally when you call SetAttr and should not be
    //   needed unless you want to specially chain together attributes.
    bool InitAttr( wxSheetCellAttr& initAttr, const wxSheetCellAttr& defAttr ) const;

    // Get an attribute for the coords if it exists or create a new one 
    // and put it into the table which puts it in the attr provider.
    // The type may be only be wxSHEET_AttrDefault/Cell/Row/Col for the grid cells
    // and wxSHEET_AttrDefault/Cell for the labels
    virtual wxSheetCellAttr GetOrCreateAttr( const wxSheetCoords& coords, 
                                             wxSheetAttr_Type type ) const;
 
    // Get the attribute for any area depending on the coords and type
    // returns a valid attr if the coords are valid and type = wxSHEET_AttrAny
    // The type may be only be wxSHEET_AttrDefault/Cell/Row/Col/Any for the grid cells
    // and wxSHEET_AttrDefault/Cell/Any for the labels
    virtual wxSheetCellAttr GetAttr( const wxSheetCoords& coords, 
                                     wxSheetAttr_Type type = wxSHEET_AttrAny) const;
    // Set the attribute for any area depending on the coords
    // The type may be only be wxSHEET_AttrDefault/Cell/Row/Col for the grid cells
    // and wxSHEET_AttrDefault/Cell for the labels
    virtual void SetAttr(const wxSheetCoords& coords, const wxSheetCellAttr& attr,
                         wxSheetAttr_Type type );

    // ------ Simplified functions for accessing the attributes ---------------
    // Get an attribute for the grid coords, returning a cell/row/col attr or
    //   if multiple attr for the coords an attr that's merged, or the def attr
    wxSheetCellAttr GetGridAttr(const wxSheetCoords& coords) const;

    // Get a specific Cell/Row/Col attr for the coords in the grid
    //   if none set returns wxNullSheetCellAttr
    wxSheetCellAttr GetGridCellAttr(const wxSheetCoords& coords) const;
    wxSheetCellAttr GetGridRowAttr(int row) const;
    wxSheetCellAttr GetGridColAttr(int col) const;
    // Set a specific Cell/Row/Col attr for coords, row/col only apply to the grid
    void SetGridCellAttr(const wxSheetCoords& coords, const wxSheetCellAttr& attr);
    void SetGridRowAttr(int row, const wxSheetCellAttr& attr);
    void SetGridColAttr(int col, const wxSheetCellAttr& attr);

    // Get the row/col/corner label attributes, if one is not set for the 
    //  particular coords, returns the default one. (note: only one corner attr)
    //  if you want the particular attr use GetRow/ColLabelCellAttr
    wxSheetCellAttr GetRowLabelAttr(int row) const;
    wxSheetCellAttr GetColLabelAttr(int col) const;
    wxSheetCellAttr GetCornerLabelAttr() const;

    // Get a specific attr the row/col/corner label cell
    //   if none set returns wxNullSheetCellAttr
    wxSheetCellAttr GetRowLabelCellAttr(int row) const;
    wxSheetCellAttr GetColLabelCellAttr(int col) const;
    // Set a specific attribute for particular row/col/corner label cell
    void SetRowLabelCellAttr(int row, const wxSheetCellAttr& attr);
    void SetColLabelCellAttr(int col, const wxSheetCellAttr& attr);
    void SetCornerLabelAttr(const wxSheetCellAttr& attr);
   
    // Get/Set default attributes for the areas (only one corner attr)
    //  For setting, wxSheetCellAttr::UpdateWith is called with the current default 
    //  attr so you so need only set the values that you want to change.
    wxSheetCellAttr GetDefaultAttr(const wxSheetCoords& coords) const;
    wxSheetCellAttr GetDefaultGridCellAttr() const;
    wxSheetCellAttr GetDefaultRowLabelAttr() const;
    wxSheetCellAttr GetDefaultColLabelAttr() const;
    void SetDefaultAttr(const wxSheetCoords& coords, const wxSheetCellAttr& attr);
    void SetDefaultGridCellAttr(const wxSheetCellAttr& attr);
    void SetDefaultRowLabelAttr(const wxSheetCellAttr& attr);
    void SetDefaultColLabelAttr(const wxSheetCellAttr& attr);
    
    // These are convienience functions, if for example you want to subclass the
    //  table and modify and return default attr "on the fly" for each cell.
    //  Please use the standard methods if at all possible.
    const wxSheetCellAttr& DoGetDefaultGridAttr() const;
    const wxSheetCellAttr& DoGetDefaultRowLabelAttr() const;
    const wxSheetCellAttr& DoGetDefaultColLabelAttr() const;
    const wxSheetCellAttr& DoGetDefaultCornerLabelAttr() const;
    
    // Get/Set particular attributes for any type of cell/row/col anywhere
    //  The default is to get the attr val for type=wxSHEET_AttrAny meaning that
    //  it'll find a set attr first or return the default attr value as a last resort. 
    //  For GetXXX you will receive an an error message if you specify a 
    //  particular wxSHEET_AttrCell/Row/Col, but there isn't an attribute set
    const wxColour& GetAttrBackgroundColour( const wxSheetCoords& coords, wxSheetAttr_Type type = wxSHEET_AttrAny ) const;
    const wxColour& GetAttrForegoundColour( const wxSheetCoords& coords, wxSheetAttr_Type type = wxSHEET_AttrAny ) const;
    const wxFont&   GetAttrFont( const wxSheetCoords& coords, wxSheetAttr_Type type = wxSHEET_AttrAny ) const;
    int             GetAttrAlignment( const wxSheetCoords& coords, wxSheetAttr_Type type = wxSHEET_AttrAny ) const;
    int             GetAttrOrientation( const wxSheetCoords& coords, wxSheetAttr_Type type = wxSHEET_AttrAny ) const;
    int             GetAttrLevel( const wxSheetCoords& coords, wxSheetAttr_Type type = wxSHEET_AttrAny ) const;
    bool            GetAttrOverflow( const wxSheetCoords& coords, wxSheetAttr_Type type = wxSHEET_AttrAny ) const;
    bool            GetAttrOverflowMarker( const wxSheetCoords& coords, wxSheetAttr_Type type = wxSHEET_AttrAny ) const;
    bool            GetAttrShowEditor( const wxSheetCoords& coords, wxSheetAttr_Type type = wxSHEET_AttrAny ) const;
    bool            GetAttrReadOnly( const wxSheetCoords& coords, wxSheetAttr_Type type = wxSHEET_AttrAny ) const;
    wxSheetCellRenderer GetAttrRenderer( const wxSheetCoords& coords, wxSheetAttr_Type type = wxSHEET_AttrAny ) const;
    wxSheetCellEditor   GetAttrEditor( const wxSheetCoords& coords, wxSheetAttr_Type type = wxSHEET_AttrAny ) const;
    
    // Set attributes for a particular cell/row/col, relies on GetOrCreateAttr()
    //  so it creates and adds the attr to the attr provider if there wasn't one
    //  after setting the particular value.
    //  The type may be only be wxSHEET_AttrDefault/Cell/Row/Col 
    void SetAttrBackgroundColour( const wxSheetCoords& coords, const wxColour& colour, wxSheetAttr_Type type = wxSHEET_AttrCell );
    void SetAttrForegroundColour( const wxSheetCoords& coords, const wxColour& colour, wxSheetAttr_Type type = wxSHEET_AttrCell );
    void SetAttrFont( const wxSheetCoords& coords, const wxFont& font, wxSheetAttr_Type type = wxSHEET_AttrCell );
    void SetAttrAlignment( const wxSheetCoords& coords, int align, wxSheetAttr_Type type = wxSHEET_AttrCell );
    void SetAttrOrientation( const wxSheetCoords& coords, int orientation, wxSheetAttr_Type type = wxSHEET_AttrCell );
    void SetAttrLevel( const wxSheetCoords& coords, int level, wxSheetAttr_Type type = wxSHEET_AttrCell );
    void SetAttrOverflow( const wxSheetCoords& coords, bool allow, wxSheetAttr_Type type = wxSHEET_AttrCell );
    void SetAttrOverflowMarker( const wxSheetCoords& coords, bool draw_marker, wxSheetAttr_Type type = wxSHEET_AttrCell );
    void SetAttrShowEditor( const wxSheetCoords& coords, bool show_editor, wxSheetAttr_Type type = wxSHEET_AttrCell );
    void SetAttrReadOnly( const wxSheetCoords& coords, bool isReadOnly, wxSheetAttr_Type type = wxSHEET_AttrCell );
    void SetAttrRenderer( const wxSheetCoords& coords, const wxSheetCellRenderer &renderer, wxSheetAttr_Type type = wxSHEET_AttrCell );
    void SetAttrEditor( const wxSheetCoords& coords, const wxSheetCellEditor &editor, wxSheetAttr_Type type = wxSHEET_AttrCell );

    // helper functions that use SetColAttr to set renderer type
    // set the format for the data in the column: default is string
    void SetColFormatBool(int col);
    void SetColFormatNumber(int col);
    void SetColFormatFloat(int col, int width = -1, int precision = -1);
    void SetColFormatCustom(int col, const wxString& typeName);

    // ------------------------------------------------------------------------
    // Get/Set cell, row, col, and corner label values
    // To completely override this you need only provide Get/SetCellValue
    
    // Get/Set cell value, uses coords = -1 notation for row/col/corner labels
    virtual wxString GetCellValue( const wxSheetCoords& coords );
    virtual void SetCellValue( const wxSheetCoords& coords, const wxString& value );
    
    // Is this cell empty, see wxSheetTable
    virtual bool HasCellValue( const wxSheetCoords& coords );
    
    wxString GetRowLabelValue( int row );
    wxString GetColLabelValue( int col );
    void     SetRowLabelValue( int row, const wxString& value );
    void     SetColLabelValue( int col, const wxString& value );

    wxString GetCornerLabelValue();
    void     SetCornerLabelValue(const wxString& value);
    
    // ------------------------------------------------------------------------
    // Register mapping between data types to Renderers/Editors

    // I don't fully understand the reasoning for these, it's some sort of 
    //  string registry for the editors and renderers. 
    //  It's not clear to me why this is useful. - John Labenski

    void RegisterDataType( const wxString& typeName,
                           const wxSheetCellRenderer& renderer,
                           const wxSheetCellEditor& editor );

    virtual wxSheetCellEditor   GetDefaultEditorForType(const wxString& typeName) const;
    virtual wxSheetCellRenderer GetDefaultRendererForType(const wxString& typeName) const;
    
    // FIXME what is the point of these?
    virtual wxSheetCellEditor   GetDefaultEditorForCell(const wxSheetCoords& coords) const;
    virtual wxSheetCellRenderer GetDefaultRendererForCell(const wxSheetCoords& coords) const;

    // ------------------------------------------------------------------------
    // Cursor movement and visibility functions

    // Check to see if a cell is either wholly visible (the default arg)
    //   or at least partially visible, uses -1 notation for labels
    bool IsCellVisible( const wxSheetCoords& coords, bool wholeCellVisible = true ) const;
    bool IsRowVisible( int row, bool wholeRowVisible = true ) const;
    bool IsColVisible( int col, bool wholeColVisible = true ) const;
    // Make this cell visible, uses -1 notation, will not unhide label windows
    void MakeCellVisible( const wxSheetCoords& coords );

    // Get/Set cursor cell, this is the "current" cell where a highlight is drawn.
    //  The cursor only applies to the grid cells.
    const wxSheetCoords& GetGridCursorCell() const;
    int  GetGridCursorRow() const;
    int  GetGridCursorCol() const;
    void SetGridCursorCell( const wxSheetCoords& coords );
    
    // These are simplified methods for moving the cursor, mostly used internally
    //  for handling key press movements.
    bool MoveCursorUp( bool expandSelection );
    bool MoveCursorDown( bool expandSelection );
    bool MoveCursorLeft( bool expandSelection );
    bool MoveCursorRight( bool expandSelection );
    bool MoveCursorUpBlock( bool expandSelection );
    bool MoveCursorDownBlock( bool expandSelection );
    bool MoveCursorLeftBlock( bool expandSelection );
    bool MoveCursorRightBlock( bool expandSelection );
    bool MoveCursorUpPage( bool expandSelection );
    bool MoveCursorDownPage( bool expandSelection );

    virtual bool DoMoveCursor( const wxSheetCoords& relCoords, bool expandSelection ); 
    virtual bool DoMoveCursorBlock( const wxSheetCoords& relDir, bool expandSelection );
    virtual bool DoMoveCursorUpDownPage( bool page_up, bool expandSelection );
    
    // ------------------------------------------------------------------------
    // Cell/Row/Col selection and deselection, you can only select grid cells.

    // Note: A selection to the # of rows/cols means that the whole row/col is
    //   selected. Otherwise the right/bottom is rows/cols - 1, ie. contained
    //   within the actual number of cells.
    //   If sendEvt a wxEVT_SHEET_RANGE_SELECTED is sent, the SELECTING event
    //     should have been sent by the caller and if vetoed not call these.
    //   All functions (De)Select/Row/Col/Cell, SelectAll go to (De)SelectBlock.
    //   ClearSelection deselects everything and sends a single event with
    //   wxSheetBlock(0,0,rows,cols) to imply everything is cleared.
    
    // To override the selection mechanism you only need to override,
    // HasSelection, IsBlockSelected, SelectBlock, DeSelectBlock, and ClearSelection.
    
    // Is there any selection, if selecting, includes the active selection block
    //   which is not yet part of underlying selection system
    virtual bool HasSelection(bool selecting = true) const;
    // Are these coords within either the selecting block or selection
    virtual bool IsCellSelected( const wxSheetCoords& coords ) const;
    virtual bool IsRowSelected( int row ) const;
    virtual bool IsColSelected( int col ) const;
    virtual bool IsBlockSelected( const wxSheetBlock& block ) const;
    // Are we currently in the middle of a selection
    bool IsSelecting() const;

    void SetSelectionMode(wxSheetSelectionMode_Type selmode);
    int  GetSelectionMode() const;
    bool HasSelectionMode(int mode);

    virtual bool SelectRow( int row, bool addToSelected = false, bool sendEvt = false );
    virtual bool SelectRows( int rowTop, int rowBottom, bool addToSelected = false, bool sendEvt = false );
    virtual bool SelectCol( int col, bool addToSelected = false, bool sendEvt = false );
    virtual bool SelectCols( int colLeft, int colRight, bool addToSelected = false, bool sendEvt = false );
    virtual bool SelectCell( const wxSheetCoords& coords, bool addToSelected = false, bool sendEvt = false );
    virtual bool SelectBlock( const wxSheetBlock& block, bool addToSelected = false, bool sendEvt = false );
    // selects everything to numRows, numCols
    virtual bool SelectAll(bool sendEvt = false);

    virtual bool DeselectRow( int row, bool sendEvt = false );
    virtual bool DeselectRows( int rowTop, int rowBottom, bool sendEvt = false );
    virtual bool DeselectCol( int col, bool sendEvt = false );
    virtual bool DeselectCols( int colLeft, int colRight, bool sendEvt = false );
    virtual bool DeselectCell( const wxSheetCoords& coords, bool sendEvt = false );
    virtual bool DeselectBlock( const wxSheetBlock& block, bool sendEvt = false );
    // clears selection, single deselect event numRows, numCols
    virtual bool ClearSelection(bool send_event = false);

    // toggle the selection of a single cell, row, or col 
    // addToSelected applies to a selection only, ignored if a deselection
    virtual bool ToggleCellSelection( const wxSheetCoords& coords, 
                                      bool addToSelected = false, bool sendEvt = false );
    virtual bool ToggleRowSelection( int row, bool addToSelected = false, bool sendEvt = false );
    virtual bool ToggleColSelection( int col, bool addToSelected = false, bool sendEvt = false );
    
    // Get a pointer to the selection mechanism. You are free to do what you 
    //  want with it, do a ForceRefresh to update the grid when done.
    wxSheetSelection* GetSelection() const;
    
    // During a selection this is the selecting block, else empty
    const wxSheetBlock& GetSelectingBlock() const;
    const wxSheetCoords& GetSelectingAnchor() const;

    // These are internal use functions to highlight a block during mouse
    //  dragging or keyboard selecting
    void SetSelectingBlock(const wxSheetBlock& selectingBlock);
    void SetSelectingAnchor(const wxSheetCoords& selectingAnchor);
    
    // while selecting set and draw m_selectingBlock highlight and clear up last
    virtual void HighlightSelectingBlock( const wxSheetBlock& selectingBlock );
    void HighlightSelectingBlock( const wxSheetCoords& cornerCell,
                                  const wxSheetCoords& otherCell );
    
    // ------------------------------------------------------------------------
    // Copy/Paste functionality for strings (Experimental)
    
    // Copy the current selection using CopyCurrentSelectionInternal then
    //  to the wxClipboard using CopyInternalSelectionToClipboard
    bool CopyCurrentSelectionToClipboard(bool copy_cursor = true,
                                         const wxChar& colSep = wxT('\t'));
    // Copy the current selection to an internal copied selection mechanism 
    //  storing both the positions and values of the selected cells, if no 
    //  selection and copy_cursor then just copy the cursor value
    bool CopyCurrentSelectionInternal(bool copy_cursor = true);
    // Copy the internal selection to the wxClipboard as both a string using 
    //  colSep to separate columns and as an internal representation for 
    //  pasting back into the wxSheet.
    bool CopyInternalSelectionToClipboard(const wxChar& colSep = wxT('\t'));
    // Returns the internal selection as a suitable string to be put into the clipboard.
    //   uses colSep for cols and \n for rows, called by CopySelectionToClipboard
    wxString CopyInternalSelectionToString(const wxChar& colSep = wxT('\t'));

    // Copies the given string (perhaps from the clipboard) to the internal copied 
    //   selection uses colSep for cols and \n for rows, used by PasteFromClipboard
    bool CopyStringToSelection(const wxString& value, const wxChar& colSep = wxT('\t'));
    
    // Tries to get the clipboard data as wxSheet's clipboard data 
    // representation else use CopyStringToSelection to convert a string 
    //  using colSep as the column separator and \n as row separator.
    //  If coords are wxNullSheetCoords, use current cursor position.
    bool PasteFromClipboard(const wxSheetCoords &topLeft = wxNullSheetCoords,
                            const wxChar& colSep = wxT('\t'));
    // Paste the internal copied selection at the topLeft coords or if 
    //  topLeft = wxNullSheetCoords then if IsSelection use the upper right of 
    //  the current selection and only paste into currently selected cells. 
    //  If no selection the the cursor is the topLeft cell. 
    virtual bool PasteInternalCopiedSelection(const wxSheetCoords &topLeft = wxNullSheetCoords);
    // Are the cells being pasted right now, use this in the table's 
    //    SetCellValue and AppendXXX to differentiate between a user typing
    bool CurrentlyPasting() const;
    
    // ------------------------------------------------------------------------
    // Edit control functions (mostly used internally)
    
    // Is/Make the whole sheet editable or readonly 
    // FIXME - make EnableEditing an enum for the different windows
    bool IsEditable() const { return GetSheetRefData()->m_editable; }
    void EnableEditing( bool edit );

    // enable and show the editor control at the coords, returns sucess, ie. !vetoed
    bool EnableCellEditControl( const wxSheetCoords& coords );
    // hide and disable the editor and save the value if save_value, returns sucess, ie. !vetoed
    bool DisableCellEditControl( bool save_value );
    // is this cell valid and editable
    bool CanEnableCellControl(const wxSheetCoords& coords) const;
    // is the cell editor created (may not be shown though)
    bool IsCellEditControlCreated() const;
    // is the cell editor valid and shown
    bool IsCellEditControlShown() const;

    // Create and show the appropriate editor at the EnableCellEditControl coords
    //  this is called internally by EnableCellEditControl, but if you call 
    //  HideCellEditControl and if IsCellEditControlCreated then you can reshow 
    //  it with this, returns sucess
    bool ShowCellEditControl();
    // Hide the editor, doesn't destroy it (use DisableCellEditControl)
    //  check if IsCellEditControlShown first, returns sucess
    bool HideCellEditControl();
    // Save the value of the editor, check IsCellEditControlEnabled() first
    void SaveEditControlValue();

    // Get the current editor, !Ok() if !IsCellEditControlCreated()
    const wxSheetCellEditor& GetEditControl() const { return GetSheetRefData()->m_cellEditor; }
    // These are the coords of the editor, check IsCellEditControlCreated before using
    const wxSheetCoords& GetEditControlCoords() const { return GetSheetRefData()->m_cellEditorCoords; }
    
    // ------------------------------------------------------------------------
    // Drawing functions
    
    // Code that does a lot of grid modification can be enclosed
    // between BeginBatch() and EndBatch() calls to avoid screen flicker
    // EndBatch's refresh = false will not refresh when batchCount is 0
    void BeginBatch();
    void EndBatch(bool refresh=true);
    int  GetBatchCount();
    
    // Use ForceRefresh, rather than wxWindow::Refresh(), to force an
    // immediate repainting of the grid. No effect if GetBatchCount() > 0
    // This function is necessary because wxSheet has a minimal OnPaint()
    // handler to reduce screen flicker.
    void ForceRefresh();
    
    // *** Use these redrawing functions to ensure refed sheets are redrawn ***
    
    // Refresh a single cell, can also draw cells for labels using -1 notation
    // does nothing if cell !visible, or GetBatchCount != 0
    // if single_cell then literally draw only the single cell, else draw the
    // cell to left in case the overflow marker needs to be drawn and the 
    // cells to the right in case this cell overflows.
    void RefreshCell(const wxSheetCoords& coords, bool single_cell = true);
    // Refresh a block of cells in any/all of the windows by chopping up the block, 
    //   uses -1 notation to refresh labels
    void RefreshBlock(const wxSheetBlock& block);
    // Refresh a single row, row = -1 refreshes all col labels, 
    // does nothing if row !visible, or GetBatchCount != 0
    void RefreshRow(int row);
    // Refresh a single col, col = -1 refreshes all row labels, 
    // does nothing if col !visible, or GetBatchCount != 0
    void RefreshCol(int col);
    // Refresh is called using a rect surrounding the block
    // does nothing if block IsEmpty, !visible, or GetBatchCount != 0
    void RefreshGridCellBlock( const wxSheetBlock& block );
    // After SetAttr call this can appropriately refresh the wxSheet areas
    void RefreshAttrChange(const wxSheetCoords& coords, wxSheetAttr_Type type);

    // ************************************************************************
    // Drawing implementation - not for general use

    // Refresh an area of the window that calculates the smaller rects for
    //  each individual window (row/col/corner...) and calls Refresh(subRect)
    //  The rect is the logical rect, not the scrolled device rect
    virtual void Refresh(bool eraseb = true, const wxRect* rect = NULL);
    
    // These directly call wxWindow::Refresh for the appropriate windows
    //   The input rect doesn't have to be clipped to the visible window since
    //   this function takes care of that, but it should be in client coords. 
    void RefreshGridWindow(bool eraseb = true, const wxRect* rect = NULL);
    void RefreshRowLabelWindow(bool eraseb = true, const wxRect* rect = NULL);
    void RefreshColLabelWindow(bool eraseb = true, const wxRect* rect = NULL);
    void RefreshCornerLabelWindow(bool eraseb = true, const wxRect* rect = NULL);

    //    Don't use these if you plan to use the splitter since they only act 
    //    on this sheet.

    // These functions are called by the OnPaint handler of these windows
    //   use these to add "extra touches" before or after redrawing.
    //   The dc should be prepared before calling these.
    virtual void PaintGridWindow( wxDC& dc, const wxRegion& reg );
    virtual void PaintRowLabelWindow( wxDC& dc, const wxRegion& reg );
    virtual void PaintColLabelWindow( wxDC& dc, const wxRegion& reg );
    virtual void PaintCornerLabelWindow( wxDC& dc, const wxRegion& reg );
    virtual void PaintSheetWindow( wxDC& dc, const wxRegion& reg );
    
    // draws a bunch of blocks of grid cells onto the given DC
    virtual void DrawGridCells( wxDC& dc, const wxSheetSelection& blockSel );
    // Draw the area below and to right of grid up to scrollbars
    virtual void DrawGridSpace( wxDC& dc );
    // draw the border around a single cell
    virtual void DrawCellBorder( wxDC& dc, const wxSheetCoords& coords );
    // Draw all the grid lines in the region
    virtual void DrawAllGridLines( wxDC& dc, const wxRegion& reg );
    // Draw a single cell
    virtual void DrawCell( wxDC& dc, const wxSheetCoords& coords );
    // Calls DrawCursorCellHighlight if contained within this selection
    virtual void DrawCursorHighlight( wxDC& dc, const wxSheetSelection& blockSel );
    // Draw the cursor cell highlight
    virtual void DrawCursorCellHighlight(wxDC& dc, const wxSheetCellAttr &attr);

    // draw wxSheetRowLabelWindow labels
    virtual void DrawRowLabels( wxDC& dc, const wxArrayInt& rows );
    // draw wxSheetColLabelWindow labels
    virtual void DrawColLabels( wxDC& dc, const wxArrayInt& cols );
    // draw wxSheetCornerLabelWindow label
    virtual void DrawCornerLabel( wxDC& dc );

    // Draw the row/col resizing marker and if newDragPos != -1, set the 
    //  new position of the marker
    virtual void DrawRowColResizingMarker( int newDragPos = -1 );

    // Draw the splitter button in the rectangle
    virtual void DrawSplitterButton(wxDC &dc, const wxRect& rect);

    // Calculate the Row/ColLabels and Cells exposed for the wxRegion
    //   returns false if none, used for redrawing windows
    bool CalcRowLabelsExposed( const wxRegion& reg, wxArrayInt& rows ) const;
    bool CalcColLabelsExposed( const wxRegion& reg, wxArrayInt& cols ) const;
    bool CalcCellsExposed( const wxRegion& reg, wxSheetSelection& blockSel ) const;
    int  FindOverflowCell( const wxSheetCoords& coords, wxDC& dc );

    // helper drawing functions
    void DrawTextRectangle( wxDC& dc, const wxString& value, const wxRect& rect,
                            int alignment = wxALIGN_LEFT|wxALIGN_TOP,
                            int textOrientation = wxHORIZONTAL );

    void DrawTextRectangle( wxDC& dc, const wxArrayString& lines, const wxRect&,
                            int alignment = wxALIGN_LEFT|wxALIGN_TOP,
                            int textOrientation = wxHORIZONTAL );

    // Split string by '\n' and add to array, returning the number of lines
    //  returns 0 for empty string.
    int StringToLines( const wxString& value, wxArrayString& lines ) const;
    // Get the size of the lines drawn horizontally, returns true if size > 0
    bool GetTextBoxSize( wxDC& dc, const wxArrayString& lines,
                         long *width, long *height ) const;

    // ------------------------------------------------------------------------
    // Geometry utility functions, pixel <-> cell etc
    
    // Note that all of these functions work with the logical coordinates of
    // grid cells and labels so you will need to convert from device
    // coordinates for mouse events etc. 
    // clipToMinMax means that the return value will be within the grid cells 
    // if !clipToMinMax and out of bounds it returns -1.
    // Use ContainsGridXXX to verify validity, -1 doesn't mean label
    wxSheetCoords XYToGridCell( int x, int y, bool clipToMinMax = false ) const;
    int YToGridRow( int y, bool clipToMinMax = false ) const;
    int XToGridCol( int x, bool clipToMinMax = false ) const;

    // return the row/col number that the x/y coord is near the edge of, or
    // -1 if not near an edge. edge_size is +- pixels to cell edge
    // Use ContainsGridXXX to verify validity, -1 doesn't mean label
    int YToEdgeOfGridRow( int y, int edge_size = WXSHEET_LABEL_EDGE_ZONE ) const;
    int XToEdgeOfGridCol( int x, int edge_size = WXSHEET_LABEL_EDGE_ZONE ) const;

    // Get a rect bounding the cell, handles spanning cells and the label 
    //  windows using the -1 notation, getDeviceRect calls CalcScrolledRect
    wxRect CellToRect( const wxSheetCoords& coords, bool getDeviceRect = false ) const;
    // Get a rect bounding the block, handles label windows using the -1 notation, 
    //  getDeviceRect calls CalcScrolledRect
    wxRect BlockToRect( const wxSheetBlock& block, bool getDeviceRect = false ) const;

    // Expand the block by unioning with intersecting spanned cells
    wxSheetBlock ExpandSpannedBlock( const wxSheetBlock& block ) const;
    
    // Convert the block of cells into a wxRect in device coords, expands the
    //  block to contain spanned cells if expand_spanned. 
    //  These functions do handle label cells, but if you span the block from a label
    //  into the grid then the rect will overlap the windows, probably not what you want.
    wxRect BlockToDeviceRect( const wxSheetBlock& block, bool expand_spanned = true ) const; 
    wxRect BlockToLogicalRect( const wxSheetBlock& block, bool expand_spanned = true ) const;

    // Convert the rect in pixels into a block of cells for the grid
    //   if wholeCell then only include cells in the block that are 
    //   wholly contained by the rect
    wxSheetBlock LogicalGridRectToBlock(const wxRect &rect, bool wholeCell = false) const;

    // get a block containing all the currently (partially/fully) visible cells
    wxSheetBlock GetVisibleGridCellsBlock(bool wholeCellVisible = false) const;

    // Align the size of an object inside the rect using wxALIGN enums
    //   if inside then align it to the left if it would have overflown
    //   always pins size to left hand side
    static wxPoint AlignInRect( int align, const wxRect& rect, const wxSize& size, bool inside=true );
        
    // ------------------------------------------------------------------------
    // Scrolling for the window, everything is done with pixels
    //   there is no need for scroll units and they only cause sizing problems

    // Get the scrolled origin of the grid in pixels
    const wxPoint& GetGridOrigin() const { return m_gridOrigin; }
    // Set the absolute scrolled origin of the grid window in pixels 
    //  this checks validity and ensures proper positioning. 
    //  Use x or y = -1 to not change the origin in the x or y direction
    //  Unless setting from a scrollbar event use adjustScrollBars=true
    virtual void SetGridOrigin(int x, int y, bool adjustScrollBars = true, bool sendEvt=false);
    void SetGridOrigin(const wxPoint& pt, bool adjustScrollBars = true, bool sendEvt=false);
        
    // Get the virtual size of the grid in pixels, includes extra width/height,
    //   but does not include the row/col labels width/height.
    wxSize GetGridVirtualSize(bool add_margin=true) const;

    // Get the full size of the sheet which is the width/height of the row/col
    //   labels + the virtual size of the grid.
    wxSize GetSheetVirtualSize(bool add_margin=true) const;

    // Get the extent of the grid, which is the max of the virtual size and 
    //  actual grid window size. Therefore, this may be larger than the virtual
    //  size if the grid is smaller than the containing window. 
    wxSize GetGridExtent() const;

    // Same as wxScrolledWindow Calc(Un)ScrolledPosition
    void CalcScrolledPosition(int x, int y, int *xx, int *yy) const;
    void CalcUnscrolledPosition(int x, int y, int *xx, int *yy) const;
    wxPoint CalcScrolledPosition(const wxPoint& pt) const;
    wxPoint CalcUnscrolledPosition(const wxPoint& pt) const;

    // returns the scrolled position of the rect, logical -> device coords
    wxRect CalcScrolledRect(const wxRect &r) const;
    // returns the unscrolled position of the rect, device -> logical coords
    wxRect CalcUnscrolledRect(const wxRect &r) const;

    // Adjust the scrollbars to match the size/origin of the grid window
    //   call this after SetScrollBarMode
    virtual void AdjustScrollbars(bool calc_win_sizes = true);

    enum SB_Mode
    {
        SB_AS_NEEDED    = 0x0,  // Show the scrollbars as needed
        SB_HORIZ_NEVER  = 0x1,  // Never show horiz scrollbar, even if needed  
        SB_VERT_NEVER   = 0x2,  // Never show vert scrollbar, even if needed  
        SB_NEVER        = SB_HORIZ_NEVER | SB_VERT_NEVER,  
        SB_HORIZ_ALWAYS = 0x4,  // Always show horiz scrollbar
        SB_VERT_ALWAYS  = 0x8,  // Always show vert scrollbar
        SB_ALWAYS       = SB_HORIZ_ALWAYS | SB_VERT_ALWAYS, 
        
        SB_HORIZ_MASK   = SB_HORIZ_NEVER|SB_HORIZ_ALWAYS,
        SB_VERT_MASK    = SB_VERT_NEVER|SB_VERT_ALWAYS
    };
    
    int GetScrollBarMode() const;
    void SetScrollBarMode(int mode);
    void SetHorizontalScrollBarMode(int mode);
    void SetVerticalScrollBarMode(int mode);

    bool NeedsVerticalScrollBar()   const;
    bool NeedsHorizontalScrollBar() const;
    
    // SetDeviceOrigin for the wxDC as appropriate for these windows
    
    virtual void PrepareGridDC( wxDC& dc );
    virtual void PrepareRowLabelDC( wxDC& dc );
    virtual void PrepareColLabelDC( wxDC& dc );

    // ------------------------------------------------------------------------
    // Splitting of the grid window - note that the sheet does not split at all
    //   and that only a wxEVT_SHEET_SPLIT_BEGIN event is sent to notify the 
    //   parent that splitting should take place, see wxSheetSplitter.
    //   The "splitter" is just two small rectangles at the top of the vertical 
    //   scrollbar and right of the horizontal scrollbar. They're only shown
    //   when the scrollbars are shown and if splitting is enabled. 
    //   Call CalcWindowSizes after setting to update the display.

    // Are the splitter buttons enabled to be shown as necessary
    bool GetEnableSplitVertically()   const;
    bool GetEnableSplitHorizontally() const;
    // Enable or disable showing the splitter buttons
    void EnableSplitVertically(bool can_split);
    void EnableSplitHorizontally(bool can_split);
    
    // ------------------------------------------------------------------------
    // implementation

    // helper function to set only the horiz or vert component of orig_align
    //   returns modified alignment, doesn't modify any bits not in wxAlignment
    //   use -1 for hAlign/vAlign to not modify that direction
    static int SetAlignment(int orig_align, int hAlign, int vAlign);

    // Do any of the windows of the wxSheet have the focus?
    bool HasFocus() const;
    
    // Accessors for component windows
    wxSheetChildWindow* GetGridWindow()        const;
    wxSheetChildWindow* GetRowLabelWindow()    const;
    wxSheetChildWindow* GetColLabelWindow()    const;
    wxSheetChildWindow* GetCornerLabelWindow() const;
    // Get the window with these coords, uses -1 notation
    wxWindow* GetWindowForCoords( const wxSheetCoords& coords ) const;

    // ------ event handlers
    void OnMouse( wxMouseEvent& event );
    void OnMouseWheel( wxMouseEvent& event );
    
    void ProcessSheetMouseEvent( wxMouseEvent& event );
    void ProcessRowLabelMouseEvent( wxMouseEvent& event );
    void ProcessColLabelMouseEvent( wxMouseEvent& event );
    void ProcessCornerLabelMouseEvent( wxMouseEvent& event );
    void ProcessGridCellMouseEvent( wxMouseEvent& event );
    
    void OnScroll( wxScrollEvent& event );

    // End the row/col dragging, returns true if width/height have changed
    bool DoEndDragResizeRowCol();

    // ------ control types
    enum 
    { 
        wxSHEET_TEXTCTRL = 2100,
        wxSHEET_CHECKBOX,
        wxSHEET_CHOICE,
        wxSHEET_COMBOBOX 
    };
    
    enum 
    {
        ID_HORIZ_SCROLLBAR = 1,
        ID_VERT_SCROLLBAR,
        ID_MOUSE_DRAG_TIMER,
        ID_GRID_WINDOW,
        ID_ROW_LABEL_WINDOW,
        ID_COL_LABEL_WINDOW,
        ID_CORNER_LABEL_WINDOW
    };

    virtual void CalcWindowSizes(bool adjustScrollBars = true);
    virtual void Fit(); // overridden wxWindow methods

    // Get the ref counted data the sheet uses, *please* try to not access this
    //  directly if a functions exists to do it for you.
    wxSheetRefData* GetSheetRefData() const;
    
    // Create and send wxSheetXXXEvent depending on type and fill extra data
    //   from a wxKeyEvent or wxMouseEvent (if NULL all keydown are set false)
    // returns EVT_VETOED/SKIPPED/CLAIMED
    enum 
    {
        EVT_VETOED  = -1,  // veto was called on the event
        EVT_SKIPPED = 0,   // no evt handler found or evt was Skip()ed
        EVT_CLAIMED = 1    // event was handled and not Skip()ed
    };
    int SendEvent( const wxEventType type, const wxSheetCoords& coords, 
                   wxEvent* mouseOrKeyEvt = NULL, 
                   const wxString& cmdString = wxEmptyString, int cmd_int = 0);
    int SendCellSizeEvent( const wxEventType type, const wxSheetCoords& coords,
                           int new_size, wxEvent* mouseOrKeyEvt = NULL );
    int SendRangeSelectEvent( const wxEventType type, const wxSheetBlock& block,
                              bool selecting, bool add, wxEvent* mouseOrKeyEvt = NULL );
    int SendEditorCreatedEvent( const wxEventType type, const wxSheetCoords& coords, 
                                wxWindow* ctrl );
        
    // Just send the event returning EVT_VETOED/SKIPPED/CLAIMED
    int DoSendEvent( wxSheetEvent* event );

    enum MouseCursorMode
    {
        WXSHEET_CURSOR_SELECT_CELL = 0x0001,
        WXSHEET_CURSOR_SELECT_ROW  = 0x0002,
        WXSHEET_CURSOR_SELECT_COL  = 0x0004,
        WXSHEET_CURSOR_SELECTING   = WXSHEET_CURSOR_SELECT_CELL|WXSHEET_CURSOR_SELECT_ROW|WXSHEET_CURSOR_SELECT_COL,
        WXSHEET_CURSOR_RESIZE_ROW  = 0x0008,
        WXSHEET_CURSOR_RESIZE_COL  = 0x0010,
        WXSHEET_CURSOR_RESIZING    = WXSHEET_CURSOR_RESIZE_ROW|WXSHEET_CURSOR_RESIZE_COL,
        WXSHEET_CURSOR_SPLIT_VERTICAL   = 0x0020,
        WXSHEET_CURSOR_SPLIT_HORIZONTAL = 0x0040,
        WXSHEET_CURSOR_SPLITTING        = WXSHEET_CURSOR_SPLIT_VERTICAL|WXSHEET_CURSOR_SPLIT_HORIZONTAL
    };
    // Set the m_mouseCursor for the wxCursor and m_mouseCursorMode for behavior
    // you should always use it and not set m_mouseCursor[Mode] directly!
    void SetMouseCursorMode( MouseCursorMode mode, wxWindow *win );
    // Get the mouse cursor mode, &ed with mask, default returns original value
    int GetMouseCursorMode(int mask = ~0) const { return (m_mouseCursorMode & mask); }
    // Is the mouse cursor in the mode?
    bool HasMouseCursorMode(int mode) const { return GetMouseCursorMode(mode) != 0; }
    
    // Set the window that has capture, releases the previous one if necessary
    // always use this, set with NULL to release mouse
    void SetCaptureWindow( wxWindow *win );
    wxWindow *GetCaptureWindow() const;
    
    %extend {
		wxWindow* CastAsWxWindow()
		{
			return static_cast<wxWindow*>(self);
		}
	}

    %extend {
		wxEvtHandler* CastAsWxEvtHandler()
		{
			return static_cast<wxEvtHandler*>(self);
		}
	}
    
};

// ----------------------------------------------------------------------------
// wxSheetEvent
// ----------------------------------------------------------------------------
class wxSheetEvent : public wxNotifyEvent
{
public:
    wxSheetEvent(wxWindowID id = 0, wxEventType type = wxEVT_NULL, 
                 wxObject* obj = NULL,
                 const wxSheetCoords &coords = wxNullSheetCoords, 
                 const wxPoint &pos = wxPoint(-1, -1), bool sel = true);

    wxSheetEvent(const wxSheetEvent& event) : wxNotifyEvent(event), 
                     m_coords(event.m_coords), 
                     m_pos(event.m_pos), m_scrPos(event.m_scrPos),
                     m_selecting(event.m_selecting), 
                     m_control(event.m_control), m_shift(event.m_shift),
                     m_alt(event.m_alt), m_meta(event.m_meta), 
                     m_evtWin(event.m_evtWin) { }

    int  GetRow() const { return m_coords.m_row; }
    int  GetCol() const { return m_coords.m_col; }
    const wxSheetCoords& GetCoords() const { return m_coords; }
    const wxPoint& GetPosition() const { return m_pos; }
    bool Selecting()   const { return m_selecting; }
    bool ControlDown() const { return m_control; }
    bool ShiftDown()   const { return m_shift; }
    bool AltDown()     const { return m_alt; }
    bool MetaDown()    const { return m_meta; }

    // Get the event relative to the window that it occured in.
    //   Scrolls the position so the pt is relative to the top left.
    const wxPoint& GetScrolledPosition() const { return m_scrPos; }
    // Get the window that the event originally occured in.
    //   (for mouse and key events) 
    //   example for wxEVT_SHEET_CELL_RIGHT_UP
    //   if (evt.GetEventWindow()) 
    //       evt.GetEventWindow()->PopupMenu(menu, evt.GetScrolledPosition());
    wxWindow* GetEventWindow() const { return m_evtWin; }

    // implementation
    
    // Setup the Ctrl/Shift/Alt/Meta keysDown from a wxKeyEvent or wxMouseEvent
    // Also sets mouse position, but the GetEventObject must be of type wxSheet
    bool SetKeysDownMousePos(wxEvent *mouseOrKeyEvent);

    virtual wxEvent *Clone() const { return new wxSheetEvent(*this); }
    
    wxSheetCoords m_coords;
    wxPoint       m_pos;
    wxPoint       m_scrPos;
    bool m_selecting;
    bool m_control;
    bool m_shift;
    bool m_alt;
    bool m_meta;
    wxWindow *m_evtWin;
};

// ----------------------------------------------------------------------------
// wxSheetCellSizeEvent - wxEVT_SHEET_ROW/COL_SIZE/ING/ED
// ----------------------------------------------------------------------------
class wxSheetCellSizeEvent : public wxSheetEvent
{
public:
    wxSheetCellSizeEvent( wxWindowID id = 0, wxEventType type = wxEVT_NULL, 
                          wxObject* obj = NULL, 
                          const wxSheetCoords &coords = wxNullSheetCoords,
                          int size = 0 );

    wxSheetCellSizeEvent(const wxSheetCellSizeEvent& event) 
        : wxSheetEvent(event) { }

    int GetSize() const { return GetInt(); }
   
    // implementation
    virtual wxEvent *Clone() const { return new wxSheetCellSizeEvent(*this); }
};

class wxSheetRangeSelectEvent : public wxSheetEvent
{
public:
    wxSheetRangeSelectEvent( wxWindowID id = 0, wxEventType type = wxEVT_NULL, 
                             wxObject* obj = NULL,
                             const wxSheetBlock& block = wxNullSheetBlock, 
                             bool sel = false, bool add_to_sel = false );

    wxSheetRangeSelectEvent(const wxSheetRangeSelectEvent& event) 
        : wxSheetEvent(event), m_block(event.m_block), m_add(event.m_add) { }

    const wxSheetBlock& GetBlock() const { return m_block; }
    bool GetAddToSelection() const       { return m_add; }
    
    void SetBlock( const wxSheetBlock& block ) { m_block = block; }

    // wxPoint GetPosition() is unused
    // int GetCoords/Row/Col() is unused
    
    // implementation
    virtual wxEvent *Clone() const { return new wxSheetRangeSelectEvent(*this); }
    
    wxSheetBlock m_block;
    bool m_add;
};

class wxSheetEditorCreatedEvent : public wxCommandEvent 
{
public:
    wxSheetEditorCreatedEvent( wxWindowID id = 0, wxEventType type = wxEVT_NULL, 
                               wxObject* obj = NULL,
                               const wxSheetCoords& coords = wxNullSheetCoords, 
                               wxWindow* ctrl = NULL );

    wxSheetEditorCreatedEvent(const wxSheetEditorCreatedEvent& evt) 
        : wxCommandEvent(evt), m_coords(evt.m_coords), m_ctrl(evt.m_ctrl) { }


    const wxSheetCoords& GetCoords() const { return m_coords; }
    wxWindow* GetControl() const           { return m_ctrl; }
    
    void SetCoords(const wxSheetCoords& coords) { m_coords = coords; }
    void SetControl(wxWindow* ctrl)             { m_ctrl = ctrl; }

    // implementation
    virtual wxEvent *Clone() const { return new wxSheetEditorCreatedEvent(*this); }

    wxSheetCoords m_coords;
    wxWindow*     m_ctrl;
};

class wxSheetCellAttr : public wxObject
{
public:

    // if create then create with ref data
    wxSheetCellAttr( bool create = false );
    // make a refed copy of the other attribute
    wxSheetCellAttr( const wxSheetCellAttr& attr ) : wxObject() { Ref(attr); }

    // Recreate the ref data, unrefing the old
    bool Create();
    void Destroy() { UnRef(); }
    inline bool Ok() const { return m_refData != NULL; }

    // Makes a full new unrefed copy of the other, this doesn't have to be created
    bool Copy(const wxSheetCellAttr& other);
    // Copies the values from the other, but only if the other has them, this must be created
    bool UpdateWith(const wxSheetCellAttr& other);
    // Merges this with the other, copy values of other only this doesn't have them
    bool MergeWith(const wxSheetCellAttr &mergefrom);
    
    // setters
    void SetForegroundColour(const wxColour& foreColour);
    void SetBackgroundColour(const wxColour& backColour);
    void SetFont(const wxFont& font);
    // wxSheetAttrAlign_Type
    void SetAlignment(int align);
    void SetAlignment(int horzAlign, int vertAlign);
    // wxSheetAttrOrientation_Type
    void SetOrientation(int orientation);
    void SetLevel(wxSheetAttrLevel_Type level);
    void SetOverflow(bool allow);
    void SetOverflowMarker(bool draw_marker);
    void SetShowEditor(bool show_editor);
    void SetReadOnly(bool isReadOnly);
    void SetRenderer(const wxSheetCellRenderer& renderer);
    void SetEditor(const wxSheetCellEditor& editor);
    void SetKind(wxSheetAttr_Type kind);

    // validation
    bool HasForegoundColour() const;
    bool HasBackgroundColour() const;
    bool HasFont() const;
    bool HasAlignment() const;
    bool HasOrientation() const;
    bool HasLevel() const;
    bool HasOverflowMode() const;
    bool HasOverflowMarkerMode() const;
    bool HasShowEditorMode() const;
    bool HasReadWriteMode() const;
    bool HasRenderer() const;
    bool HasEditor() const;
    bool HasDefaultAttr() const;
    // bool HasKind() const - always has kind, default is wxSHEET_AttrCell

    // does this attr define all the HasXXX properties, except DefaultAttr
    //   if this is true, it's a suitable default attr for an area
    bool IsComplete() const;  

    // accessors
    const wxColour& GetForegroundColour() const;
    const wxColour& GetBackgroundColour() const;
    const wxFont& GetFont() const;
    int GetAlignment() const;
    wxOrientation GetOrientation() const;
    wxSheetAttrLevel_Type GetLevel() const;
    bool GetOverflow() const;
    bool GetOverflowMarker() const;
    bool GetShowEditor() const;
    bool GetReadOnly() const;
    wxSheetCellRenderer GetRenderer(wxSheet* grid, const wxSheetCoords& coords) const;
    wxSheetCellEditor GetEditor(wxSheet* grid, const wxSheetCoords& coords) const;
    wxSheetAttr_Type GetKind() const;

    // any unset values of this attr are retrieved from the default attr
    // if you try to set the def attr to this, it's ignored
    // don't bother to link multiple attributes together in a loop, obviously.
    const wxSheetCellAttr& GetDefaultAttr() const;
    void SetDefaultAttr(const wxSheetCellAttr& defaultAttr);

    // operators
    bool operator == (const wxSheetCellAttr& obj) const { return m_refData == obj.m_refData; }
    bool operator != (const wxSheetCellAttr& obj) const { return m_refData != obj.m_refData; }
    
    wxSheetCellAttr Clone() const     { wxSheetCellAttr obj; obj.Copy(*this); return obj; }
    wxSheetCellAttr* NewClone() const { return new wxSheetCellAttr(Clone()); }

    // implementation
    void SetType(int type, int mask);
    int  GetType(int mask = ~0) const;
    bool HasType(int type) const { return GetType(type) != 0; }
};

class wxSheetCellEditor
{
public:

    wxSheetCellEditor( wxSheetCellEditorRefData *editor = NULL );
    wxSheetCellEditor( const wxSheetCellEditor& editor ) { Ref(editor); }

    void Destroy() { UnRef(); }
    bool Ok() const { return m_refData != NULL; }
    
    bool IsCreated() const;
    bool IsShown() const;
    
    wxWindow* GetControl() const;
    void SetControl(wxWindow* control);
    void DestroyControl();

    void CreateEditor(wxWindow* parent, wxWindowID id, 
                      wxEvtHandler* evtHandler, wxSheet* sheet);

    void SetSize(const wxRect& rect, const wxSheetCellAttr& attr);
    wxSize GetBestSize(wxSheet& sheet, const wxSheetCellAttr& attr,
                       const wxSheetCoords& coords) const;
    void Show(bool show, const wxSheetCellAttr &attr);
    void PaintBackground(wxSheet& sheet, const wxSheetCellAttr& attr, 
                         wxDC& dc, const wxRect& rect, 
                         const wxSheetCoords& coords, bool isSelected);
    
    void InitEditor(const wxSheetCoords& coords, const wxSheetCellAttr& attr, 
                    wxSheet* sheet);
    void BeginEdit(const wxSheetCoords& coords, wxSheet* sheet);
    bool EndEdit(const wxSheetCoords& coords, wxSheet* sheet);
    void ResetValue();

    bool IsAcceptedKey(wxKeyEvent& event);
    void StartingKey(wxKeyEvent& event);
    void StartingClick();
    void HandleReturn(wxKeyEvent& event);

    bool OnKeyDown(wxKeyEvent& event);
    bool OnChar(wxKeyEvent& event);

    void SetParameters(const wxString& params);
    
    wxString GetValue() const;
    wxString GetInitValue() const;

    bool Copy(const wxSheetCellEditor& other);    
    
    // operators
    bool operator == (const wxSheetCellEditor& obj) const { return m_refData == obj.m_refData; }
    bool operator != (const wxSheetCellEditor& obj) const { return m_refData != obj.m_refData; }
    wxSheetCellEditor Clone() const     { wxSheetCellEditor obj; obj.Copy(*this); return obj; }
    wxSheetCellEditor* NewClone() const { return new wxSheetCellEditor(Clone()); }
};

// The C++ version of wxPySheetCellEditor
%{
class wxPySheetCellEditor : public wxSheetCellEditor
{
public:
    wxPySheetCellEditor() : wxSheetCellEditor() {}

    void Create(wxWindow* parent, wxWindowID id, wxEvtHandler* evtHandler) {
        wxPyBlock_t blocked = wxPyBeginBlockThreads();
        if (wxPyCBH_findCallback(m_myInst, "Create")) {
            PyObject* po = wxPyMake_wxObject(parent,false);
            PyObject* eo = wxPyMake_wxObject(evtHandler,false);

            wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OiO)", po, id, eo));
            Py_DECREF(po);
            Py_DECREF(eo);
        }
        wxPyEndBlockThreads(blocked);
    }


    void BeginEdit(int row, int col, wxSheet* grid) {
        wxPyBlock_t blocked = wxPyBeginBlockThreads();
        if (wxPyCBH_findCallback(m_myInst, "BeginEdit")) {
            PyObject* go = wxPyMake_wxObject(grid,false);
            wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)", row, col, go));
            Py_DECREF(go);
        }
        wxPyEndBlockThreads(blocked);
    }


    bool EndEdit(int row, int col, wxSheet* grid) {
        bool rv = false;
        wxPyBlock_t blocked = wxPyBeginBlockThreads();
        if (wxPyCBH_findCallback(m_myInst, "EndEdit")) {
            PyObject* go = wxPyMake_wxObject(grid,false);
            rv = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)", row, col, go));
            Py_DECREF(go);
        }
        wxPyEndBlockThreads(blocked);
        return rv;
    }


    wxSheetCellEditor* Clone() const {
        wxSheetCellEditor* rval = NULL;
        wxPyBlock_t blocked = wxPyBeginBlockThreads();
        if (wxPyCBH_findCallback(m_myInst, "Clone")) {
            PyObject* ro;
            wxSheetCellEditor* ptr;
            ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()"));
            if (ro) {
                if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxSheetCellEditor")))
                    rval = ptr;
                Py_DECREF(ro);
            }
        }
        wxPyEndBlockThreads(blocked);
        return rval;
    }
    
    void SetSize(const wxRect& rect, const wxSheetCellAttr& attr)
    {
        bool found;
        wxPyBlock_t blocked = wxPyBeginBlockThreads();
        if ((found = wxPyCBH_findCallback(m_myInst, "SetSize"))) {
            wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", rect, attr));
        }
        wxPyEndBlockThreads(blocked);
        if (! found)
            wxSheetCellEditor::SetSize(rect, attr);
    }
    void base_SetSize(const wxRect& rect, const wxSheetCellAttr& attr)
	{
		wxSheetCellEditor::SetSize(rect, attr);
	}

    void Show(bool show, wxSheetCellAttr *attr) {
        bool found;
        wxPyBlock_t blocked = wxPyBeginBlockThreads();
        if ((found = wxPyCBH_findCallback(m_myInst, "Show"))) {
            wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)", show, attr));
        }
        wxPyEndBlockThreads(blocked);
        if (! found)
            wxSheetCellEditor::Show(show, attr);
    }
    void base_Show(bool show, wxSheetCellAttr *attr) {
        wxSheetCellEditor::Show(show, attr);
    }


    void PaintBackground(wxSheet& sheet, const wxSheetCellAttr& attr, 
                                        wxDC& dc, const wxRect& rect, 
                                        const wxSheetCoords& coords, bool isSelected) {
        bool found;
        wxPyBlock_t blocked = wxPyBeginBlockThreads();
        if ((found = wxPyCBH_findCallback(m_myInst, "PaintBackground)"))) {
            PyObject* ro = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);

            wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)", ro, attr));

            Py_DECREF(ro);
        }
        wxPyEndBlockThreads(blocked);
        if (! found)
            wxSheetCellEditor::PaintBackground(sheet, attr, dc, rect, coords, isSelected);
    }
    void base_PaintBackground(wxSheet& sheet, const wxSheetCellAttr& attr, 
                                        wxDC& dc, const wxRect& rect, 
                                        const wxSheetCoords& coords, bool isSelected) {
        wxSheetCellEditor::PaintBackground(sheet, attr, dc, rect, coords, isSelected);
    }


    DEC_PYCALLBACK___pure(Reset);
    DEC_PYCALLBACK_bool_any(IsAcceptedKey, wxKeyEvent);
    DEC_PYCALLBACK__any(StartingKey, wxKeyEvent);
    DEC_PYCALLBACK__any(HandleReturn, wxKeyEvent);
    DEC_PYCALLBACK__(StartingClick);
    DEC_PYCALLBACK__(Destroy);
    DEC_PYCALLBACK__STRING(SetParameters);
    DEC_PYCALLBACK_STRING__constpure(GetValue);

    PYPRIVATE;
};


IMP_PYCALLBACK__STRING( wxPySheetCellEditor, wxSheetCellEditor, SetParameters);
IMP_PYCALLBACK___pure(wxPySheetCellEditor, wxSheetCellEditor, Reset);
IMP_PYCALLBACK_bool_any(wxPySheetCellEditor, wxSheetCellEditor, IsAcceptedKey, wxKeyEvent);
IMP_PYCALLBACK__any(wxPySheetCellEditor, wxSheetCellEditor, StartingKey, wxKeyEvent);
IMP_PYCALLBACK__any(wxPySheetCellEditor, wxSheetCellEditor, HandleReturn, wxKeyEvent);
IMP_PYCALLBACK__(wxPySheetCellEditor, wxSheetCellEditor, StartingClick);
IMP_PYCALLBACK__(wxPySheetCellEditor, wxSheetCellEditor, Destroy);
IMP_PYCALLBACK_STRING__constpure(wxPySheetCellEditor, wxSheetCellEditor, GetValue);

%}

// Let SWIG know about it so it can create the Python version
class wxPySheetCellEditor : public wxSheetCellEditor {
public:
    %pythonAppend wxPySheetCellEditor  "self._setCallbackInfo(self, PySheetCellEditor)"

    wxPySheetCellEditor();
    void _setCallbackInfo(PyObject* self, PyObject* _class);

    void base_SetSize(const wxRect& rect, const wxSheetCellAttr& attr);
    void base_Show(bool show, wxSheetCellAttr *attr);
    void base_PaintBackground(wxSheet& sheet, const wxSheetCellAttr& attr, 
                                        wxDC& dc, const wxRect& rect, 
                                        const wxSheetCoords& coords, bool isSelected);
    bool base_IsAcceptedKey(wxKeyEvent& event);
    void base_StartingKey(wxKeyEvent& event);
    void base_StartingClick();
    void base_HandleReturn(wxKeyEvent& event);
    void base_Destroy();
    void base_SetParameters(const wxString& params);
};

class wxSheetCellRenderer : public wxObject
{
public:
    wxSheetCellRenderer(wxSheetCellRendererRefData *renderer = NULL);
    wxSheetCellRenderer( const wxSheetCellRenderer& renderer );

    void Destroy();

    bool Ok() const;
    
    // draw the given cell on the provided DC inside the given rectangle
    // using the style specified by the attribute and the default or selected
    // state corresponding to the isSelected value.
    void Draw(wxSheet& sheet, const wxSheetCellAttr& attr, 
              wxDC& dc, const wxRect& rect, 
              const wxSheetCoords& coords, bool isSelected);

    // get the preferred size of the cell for its contents
    wxSize GetBestSize(wxSheet& sheet, const wxSheetCellAttr& attr,
                       wxDC& dc, const wxSheetCoords& coords);

    // interpret renderer parameters: arbitrary string whose interpretation is
    // left to the derived classes
    void SetParameters(const wxString& params);
  
    bool Copy(const wxSheetCellRenderer& other);    

    // operators
    bool operator == (const wxSheetCellRenderer& obj) const { return m_refData == obj.m_refData; }
    bool operator != (const wxSheetCellRenderer& obj) const { return m_refData != obj.m_refData; }

//    wxSheetCellRenderer Clone() const     { wxSheetCellRenderer obj; obj.Copy(*this); return obj; }
    wxSheetCellRenderer* NewClone() const { return new wxSheetCellRenderer(Clone()); }   
};

%{
class wxPySheetCellRenderer : public wxSheetCellRenderer
{
    wxPySheetCellRenderer() : wxSheetCellRenderer() {};

    // Implement Python callback aware virtual methods
    void Draw(wxSheet& grid, wxSheetCellAttr& attr,
              wxDC& dc, const wxRect& rect,
              const wxSheetCoords& coords, bool isSelected) {
        wxPyBlock_t blocked = wxPyBeginBlockThreads();
        if (wxPyCBH_findCallback(m_myInst, "Draw")) {
            PyObject* go = wxPyMake_wxObject(&grid,false);
            PyObject* dco = wxPyMake_wxObject(&dc,false);
            PyObject* ao = wxPyMake_wxObject(&attr,false);
            PyObject* co = SWIG_NewPointerObj((void *)(&coords), SWIGTYPE_p_wxSheetCoords, 0);
            PyObject* ro = wxPyConstructObject((void*)&rect, wxT("wxRect"), 0);

            wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOOOOi)", go, ao, dco, ro,
                                                         co, isSelected));
            Py_DECREF(go);
            Py_DECREF(ao);
            Py_DECREF(dco);
            Py_DECREF(ro);
            Py_DECREF(co);
        }
        wxPyEndBlockThreads(blocked);
    }

    wxSize GetBestSize(wxSheet& grid, wxSheetCellAttr& attr, wxDC& dc,
                       const wxSheetCoords& coords) {
        wxSize rval;
        wxPyBlock_t blocked = wxPyBeginBlockThreads();
        if (wxPyCBH_findCallback(m_myInst, "GetBestSize")) {
            PyObject* ro;
            wxSize*   ptr;
            PyObject* go = wxPyMake_wxObject(&grid,false);
            PyObject* dco = wxPyMake_wxObject(&dc,false);
            PyObject* co = SWIG_NewPointerObj((void *)(&coords), SWIGTYPE_p_wxSheetCoords, 0);
            PyObject* ao = wxPyMake_wxObject(&attr,false);

            ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OOOO)",
                                                                 go, ao, dco,
                                                                 co));
            Py_DECREF(go);
            Py_DECREF(ao);
            Py_DECREF(dco);
            Py_DECREF(co);

            if (ro) {
                const char* errmsg = "GetBestSize should return a 2-tuple of integers or a wxSize object.";
                if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxSize"))) {
                    rval = *ptr;
                }
                else if (PySequence_Check(ro) && PyObject_Length(ro) == 2) {
                    PyObject* o1 = PySequence_GetItem(ro, 0);
                    PyObject* o2 = PySequence_GetItem(ro, 1);
                    if (PyNumber_Check(o1) && PyNumber_Check(o2))
                        rval = wxSize(PyInt_AsLong(o1), PyInt_AsLong(o2));
                    else
                        PyErr_SetString(PyExc_TypeError, errmsg);
                    Py_DECREF(o1);
                    Py_DECREF(o2);
                }
                else {
                    PyErr_SetString(PyExc_TypeError, errmsg);
                }
                Py_DECREF(ro);
            }
        }
        wxPyEndBlockThreads(blocked);
        return rval;
    }

    wxSheetCellRenderer *NewClone() const {
        wxSheetCellRenderer* rval = NULL;
        wxPyBlock_t blocked = wxPyBeginBlockThreads();
        if (wxPyCBH_findCallback(m_myInst, "NewClone")) {
            PyObject* ro;
            wxSheetCellRenderer* ptr;
            ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()"));
            if (ro) {
                if (wxPyConvertSwigPtr(ro, (void **)&ptr, wxT("wxSheetCellRenderer")))
                    rval = ptr;
                Py_DECREF(ro);
            }
        }
        wxPyEndBlockThreads(blocked);
        return rval;
    }

    DEC_PYCALLBACK__STRING(SetParameters);

    PYPRIVATE;
};

IMP_PYCALLBACK__STRING( wxPySheetCellRenderer, wxSheetCellRenderer, SetParameters);
%}

class wxPySheetCellRenderer : public wxSheetCellRenderer
{
    %pythonAppend wxPySheetCellRenderer  "self._setCallbackInfo(self, PySheetCellRenderer)"

    wxPySheetCellRenderer();
    void _setCallbackInfo(PyObject* self, PyObject* _class);

    void base_SetParameters(const wxString& params);
};

class wxSheetTable : public wxObject, public wxClientDataContainer
{
public:
    wxSheetTable( wxSheet *sheet = NULL );
    virtual ~wxSheetTable();

    virtual void SetView( wxSheet *sheet );
    virtual wxSheet* GetView();

    virtual int GetNumberRows();
    virtual int GetNumberCols();
    
    bool ContainsGridRow( int row );
    bool ContainsGridCol( int col );
    bool ContainsGridCell(const wxSheetCoords& coords);
    bool ContainsRowLabelCell( const wxSheetCoords& coords );
    bool ContainsColLabelCell( const wxSheetCoords& coords );
    
    virtual wxString GetValue( const wxSheetCoords& coords );
    virtual void SetValue( const wxSheetCoords& coords, const wxString& value );
    virtual bool HasValue( const wxSheetCoords& coords );
    virtual int GetFirstNonEmptyColToLeft( const wxSheetCoords& coords );

    virtual void ClearValues(int update = wxSHEET_UpdateValues);
        
    wxString GetDefaultRowLabelValue( int row ) const;
    wxString GetDefaultColLabelValue( int col ) const;
        
    virtual long   GetValueAsLong( const wxSheetCoords& coords );
    virtual double GetValueAsDouble( const wxSheetCoords& coords );
    virtual bool   GetValueAsBool( const wxSheetCoords& coords );

    virtual void SetValueAsLong( const wxSheetCoords& coords, long value );
    virtual void SetValueAsDouble( const wxSheetCoords& coords, double value );
    virtual void SetValueAsBool( const wxSheetCoords& coords, bool value );

    virtual void* GetValueAsCustom( const wxSheetCoords& coords, const wxString& typeName );
    virtual void  SetValueAsCustom( const wxSheetCoords& coords, const wxString& typeName, void* value );
    
    virtual bool CanGetValueAs( const wxSheetCoords& coords, const wxString& typeName );
    virtual bool CanSetValueAs( const wxSheetCoords& coords, const wxString& typeName );

    virtual wxString GetTypeName( const wxSheetCoords& coords );

    virtual wxSheetValueProviderBase* GetGridCellValueProvider() const { return m_gridCellValues; }
    virtual wxSheetValueProviderBase* GetRowLabelValueProvider() const { return m_rowLabelValues; }
    virtual wxSheetValueProviderBase* GetColLabelValueProvider() const { return m_colLabelValues; }
    void SetGridCellValueProvider(wxSheetValueProviderBase* gridCellValues, bool is_owner);
    void SetRowLabelValueProvider(wxSheetValueProviderBase* rowLabelValues, bool is_owner);
    void SetColLabelValueProvider(wxSheetValueProviderBase* colLabelValues, bool is_owner);

    virtual wxSheetCellAttr GetAttr( const wxSheetCoords& coords,
                                     wxSheetAttr_Type kind );
    
    virtual void SetAttr( const wxSheetCoords& coords, 
                          const wxSheetCellAttr &attr, 
                          wxSheetAttr_Type kind );

    virtual wxSheetCellAttrProvider* GetAttrProvider() const { return m_attrProvider; }
    void SetAttrProvider(wxSheetCellAttrProvider *attrProvider, bool is_owner);
    
    virtual bool HasSpannedCells();
    virtual wxSheetBlock GetCellBlock( const wxSheetCoords& coords );
    virtual void SetCellSpan( const wxSheetBlock& block );

    virtual wxSheetSelection* GetSpannedBlocks() const { return m_spannedCells; }
    void SetSpannedBlocks(wxSheetSelection *spannedCells, bool is_owner);

    virtual bool UpdateRows( size_t row, int numRows, int update = wxSHEET_UpdateAll );
    virtual bool UpdateCols( size_t col, int numCols, int update = wxSHEET_UpdateAll );

    virtual bool UpdateSheetRowsCols(int update = wxSHEET_UpdateAll );
};

// Python-aware version
%{
class wxPySheetTableBase : public wxSheetTable
{
public:
    wxPySheetTableBase() : wxSheetTable() {}

    PYCALLBACK_INT__pure(GetNumberRows);
    PYCALLBACK_INT__pure(GetNumberCols);
    PYCALLBACK_BOOL_COORD_pure(IsEmptyCell);
    PYCALLBACK_STRING_COORD(wxSheetTable, GetTypeName);
    PYCALLBACK_BOOL_COORDSTRING(wxSheetTable, CanGetValueAs);
    PYCALLBACK_BOOL_COORDSTRING(wxSheetTable, CanSetValueAs);
//    PYCALLBACK__(wxSheetTable, Clear);
//    PYCALLBACK_BOOL_SIZETSIZET(wxSheetTable, InsertRows);
//    PYCALLBACK_BOOL_SIZETSIZET(wxSheetTable, DeleteRows);
//    PYCALLBACK_BOOL_SIZETSIZET(wxSheetTable, InsertCols);
//    PYCALLBACK_BOOL_SIZETSIZET(wxSheetTable, DeleteCols);
//    PYCALLBACK_BOOL_SIZET(wxSheetTable, AppendRows);
//    PYCALLBACK_BOOL_SIZET(wxSheetTable, AppendCols);
//    PYCALLBACK_STRING_INT(wxSheetTable, GetRowLabelValue);
//    PYCALLBACK_STRING_INT(wxSheetTable, GetColLabelValue);
//    PYCALLBACK__INTSTRING(wxSheetTable, SetRowLabelValue);
//    PYCALLBACK__INTSTRING(wxSheetTable, SetColLabelValue);
//    PYCALLBACK_BOOL_(wxSheetTable, CanHaveAttributes);
    PYCALLBACK_GCA_COORDKIND(wxSheetTable, GetAttr);
    PYCALLBACK__GCACOORD(wxSheetTable, SetAttr);
//    PYCALLBACK__GCAINT(wxSheetTable, SetRowAttr);
//    PYCALLBACK__GCAINT(wxSheetTable, SetColAttr);


	void Clear() 
	{ 
		std::cout << "wxPySheetTableBase::Clear" << std::endl;
		GetGridCellValueProvider()->Clear(); 
	}

    wxString GetRowLabelValue( int row ) 
    { 
		std::cout << "wxPySheetTableBase::GetRowLabelValue" << std::endl;
		return GetRowLabelValueProvider()->GetValue( wxSheetCoords(row, 0) ); 
	}
    
    wxString GetColLabelValue( int col ) 
    { 
		std::cout << "wxPySheetTableBase::GetColLabelValue" << std::endl;
		GetColLabelValueProvider()->GetValue( wxSheetCoords(0, col) );
	}

    wxString SetRowLabelValue( int row, const wxString& value ) 
    { 
		std::cout << "wxPySheetTableBase::SetRowLabelValue" << std::endl;
		GetRowLabelValueProvider()->SetValue( wxSheetCoords(row, 0), value ); 
	}
	
    wxString SetColLabelValue( int col, const wxString& value ) 
    { 
		std::cout << "wxPySheetTableBase::SetColLabelValue" << std::endl;
		GetColLabelValueProvider()->SetValue( wxSheetCoords(0, col), value ); 
	}


    wxString GetValue(int row, int col) {
		std::cout << "wxPySheetTableBase::GetValue" << std::endl;
        wxPyBlock_t blocked = wxPyBeginBlockThreads();
        wxString rval;
        if (wxPyCBH_findCallback(m_myInst, "GetValue")) {
            PyObject* ro;
            ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)",row,col));
            if (ro) {
                if (!PyString_Check(ro) && !PyUnicode_Check(ro)) {
                    PyObject* old = ro;
                    ro = PyObject_Str(ro);
                    Py_DECREF(old);
                }
                rval = Py2wxString(ro);
                Py_DECREF(ro);
            }
        }
        wxPyEndBlockThreads(blocked);
        return rval;
    }

    void SetValue(int row, int col, const wxString& val) 
    {
		std::cout << "wxPySheetTableBase::SetValue" << std::endl;
        wxPyBlock_t blocked = wxPyBeginBlockThreads();
        if (wxPyCBH_findCallback(m_myInst, "SetValue")) 
        {
            PyObject* s = wx2PyString(val);
            wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiO)",row,col,s));
            Py_DECREF(s);
		}
        wxPyEndBlockThreads(blocked);
	}


    // Map the Get/Set methods for the standard non-string types to
    // the GetValue and SetValue python methods.
    long GetValueAsLong( int row, int col ) {
        long rval = 0;
        wxPyBlock_t blocked = wxPyBeginBlockThreads();
        if (wxPyCBH_findCallback(m_myInst, "GetValue")) {
            PyObject* ro;
            PyObject* num;
            ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)", row, col));
            if (ro && PyNumber_Check(ro)) {
                num = PyNumber_Int(ro);
                if (num) {
                    rval = PyInt_AsLong(num);
                    Py_DECREF(num);
                }
                Py_DECREF(ro);
            }
        }
        wxPyEndBlockThreads(blocked);
        return rval;
    }

    double GetValueAsDouble( int row, int col ) {
        double rval = 0.0;
        wxPyBlock_t blocked = wxPyBeginBlockThreads();
        if (wxPyCBH_findCallback(m_myInst, "GetValue")) {
            PyObject* ro;
            PyObject* num;
            ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(ii)", row, col));
            if (ro && PyNumber_Check(ro)) {
                num = PyNumber_Float(ro);
                if (num) {
                    rval = PyFloat_AsDouble(num);
                    Py_DECREF(num);
                }
                Py_DECREF(ro);
            }
        }
        wxPyEndBlockThreads(blocked);
        return rval;
    }

    bool GetValueAsBool( int row, int col ) {
        return (bool)GetValueAsLong(row, col);
    }

    void SetValueAsLong( int row, int col, long value ) {
        wxPyBlock_t blocked = wxPyBeginBlockThreads();
        if (wxPyCBH_findCallback(m_myInst, "SetValue")) {
            wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iii)", row, col, value));
        }
        wxPyEndBlockThreads(blocked);
    }

    void SetValueAsDouble( int row, int col, double value ) {
        wxPyBlock_t blocked = wxPyBeginBlockThreads();
        if (wxPyCBH_findCallback(m_myInst, "SetValue")) {
            wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iid)", row, col, value));
        }
        wxPyEndBlockThreads(blocked);
    }

    void SetValueAsBool( int row, int col, bool value ) {
        SetValueAsLong( row, col, (long)value );
    }


    PYPRIVATE;
};
%}


// The python-aware version get's SWIGified
class wxPySheetTableBase : public wxSheetTable
{
public:
	%pythonAppend wxPySheetTableBase "self._setCallbackInfo(self, PySheetTableBase)"
    wxPySheetTableBase();
    void _setCallbackInfo(PyObject* self, PyObject* _class);

    %extend { void Destroy() { delete self; } }

    wxString base_GetTypeName( wxSheetCoords coords );
    bool base_CanGetValueAs( wxSheetCoords coords, const wxString& typeName );
    bool base_CanSetValueAs( wxSheetCoords coords, const wxString& typeName );
/*    
    bool base_InsertRows( size_t pos = 0, size_t numRows = 1 );
    bool base_AppendRows( size_t numRows = 1 );
    bool base_DeleteRows( size_t pos = 0, size_t numRows = 1 );
    bool base_InsertCols( size_t pos = 0, size_t numCols = 1 );
    bool base_AppendCols( size_t numCols = 1 );
    bool base_DeleteCols( size_t pos = 0, size_t numCols = 1 );
*/
    
//    bool base_CanHaveAttributes();
    wxSheetCellAttr base_GetAttr( const wxSheetCoords& coords, 
                                       wxSheetAttr_Type kind );
    void base_SetAttr(const wxSheetCoords& coords, 
                            const wxSheetCellAttr& attr, wxSheetAttr_Type kind);
//    void base_SetRowAttr(wxSheetCellAttr *attr, int row);
//    void base_SetColAttr(wxSheetCellAttr *attr, int col);
};


class wxSheetBlock
{
public:    
    wxSheetBlock();
    wxSheetBlock(int row, int col, int height, int width);
    wxSheetBlock( const wxSheetCoords& coords1, 
                  const wxSheetCoords& coords2, bool make_upright = true );
    wxSheetBlock( const wxSheetCoords& tl, int height, int width ); 

    int GetLeft()   const;
    int GetRight()  const;
    int GetTop()    const;
    int GetBottom() const;
    int GetWidth()  const;
    int GetHeight() const;

    wxSheetCoords GetLeftTop()     const;
    wxSheetCoords GetLeftBottom()  const;
    wxSheetCoords GetRightTop()    const;
    wxSheetCoords GetRightBottom() const;
    
    wxSheetCoords GetSize() const;
    
    wxArraySheetCoords GetArrayCoords() const;
    
    void SetLeft( int left );
    void SetTop( int top );
    void SetRight( int right );
    void SetBottom( int bottom );
    void SetWidth( int width );
    void SetHeight( int height );
    
    void SetLeftTop(const wxSheetCoords& lt);
    void SetLeftBottom(const wxSheetCoords& lb);
    void SetRightTop(const wxSheetCoords& rt);
    void SetRightBottom(const wxSheetCoords& rb);

    void SetLeftCoord( int left );
    void SetTopCoord( int top );
    void SetRightCoord( int right );
    void SetBottomCoord( int bottom );

    void SetLeftTopCoords(const wxSheetCoords& lt);
    void SetLeftBottomCoords(const wxSheetCoords& lb);
    void SetRightTopCoords(const wxSheetCoords& rt);
    void SetRightBottomCoords(const wxSheetCoords& rb);
    
    void Set( int row, int col, int height, int width );
    void SetCoords( int top, int left, int bottom, int right );
    void SetSize(const wxSheetCoords& size) { m_height = size.m_row; m_width = size.m_col; }
    
    // Get a block of this that is upright
    wxSheetBlock GetAligned() const;
    
    bool IsEmpty() const;
    bool IsOneCell() const;
    
    bool Contains( int row, int col ) const;
    bool Contains( const wxSheetCoords &coord ) const;
    bool Contains( const wxSheetBlock &b ) const;
    bool Intersects( const wxSheetBlock &b ) const;
    wxSheetBlock Intersect( const wxSheetBlock &other ) const;

    wxSheetBlock Union( const wxSheetBlock &other ) const;
    
    wxSheetBlock ExpandUnion( const wxSheetBlock &other ) const;
    
    bool Touches(const wxSheetBlock &block) const;
        
    int SideMatches(const wxSheetBlock& block) const;
    
    bool Combine(const wxSheetBlock &block);
                 
    int Combine( const wxSheetBlock &block, 
                  wxSheetBlock &top, wxSheetBlock &bottom, 
                  wxSheetBlock &left, wxSheetBlock &right ) const;

    int Delete( const wxSheetBlock &block, 
                 wxSheetBlock &top,  wxSheetBlock &bottom, 
                 wxSheetBlock &left, wxSheetBlock &right ) const;

    bool UpdateRows( size_t row, int numRows );
    bool UpdateCols( size_t col, int numCols );

    // operators
    bool operator == (const wxSheetBlock& b) const;
    bool operator != (const wxSheetBlock& b) const;

    int CmpTopLeft(const wxSheetBlock& b) const; 
    int CmpBottomRight(const wxSheetBlock& b) const;

    bool operator <  (const wxSheetBlock& b) const; 
    bool operator <= (const wxSheetBlock& other) const;
    bool operator >  (const wxSheetBlock& other) const;
    bool operator >= (const wxSheetBlock& other) const;
    
};

class wxSheetSelection : public wxObject
{
public:
    wxSheetSelection( int options = wxSHEET_SELECTION_NONE );
    wxSheetSelection( const wxSheetSelection& other );
    wxSheetSelection( const wxSheetBlock& block, 
                      int options = wxSHEET_SELECTION_NONE );
    
    void Copy(const wxSheetSelection &source);

    int GetNumberRows() const;
    int GetNumberCols() const;

    int GetOptions() const;
    void SetOptions(int options);
    
    bool HasSelection() const;
    int  GetCount() const;
    bool IsMinimzed() const;
    
    bool Clear(); 
    bool Empty(); 

    const wxArraySheetBlock& GetBlockArray() const;

    const wxSheetBlock& GetBlock( size_t index ) const;
    const wxSheetBlock& Item( size_t index ) const;
    
    const wxSheetBlock& GetBoundingBlock() const;
    void SetBoundingBlock(const wxSheetBlock& block);
    
    bool Contains( int row, int col ) const;
    bool Contains( const wxSheetCoords &c ) const;
    bool Contains( const wxSheetBlock &b ) const;

    int Index( int row, int col ) const;
    int Index( const wxSheetCoords &c ) const;
    int Index( const wxSheetBlock &b ) const;
    int IndexIntersects( const wxSheetBlock &b ) const;
    
    bool SelectBlock( const wxSheetBlock &block, bool combine_now = true, 
                      wxArraySheetBlock *addedBlocks = NULL );    
    bool DeselectBlock( const wxSheetBlock &block, bool combine_now = true,
                        wxArraySheetBlock *deletedBlocks = NULL );

    bool UpdateRows( size_t row, int numRows );
    bool UpdateCols( size_t col, int numCols );

    int IndexForInsert(const wxSheetBlock& block) const;
    int FindTopRow(int row) const;
    bool Minimize();
};

%constant wxEventType wxEVT_SHEET_VIEW_CHANGED;
%constant wxEventType wxEVT_SHEET_SELECTING_CELL;
%constant wxEventType wxEVT_SHEET_SELECTED_CELL;
%constant wxEventType wxEVT_SHEET_CELL_LEFT_DOWN;
%constant wxEventType wxEVT_SHEET_CELL_RIGHT_DOWN;
%constant wxEventType wxEVT_SHEET_CELL_LEFT_UP;
%constant wxEventType wxEVT_SHEET_CELL_RIGHT_UP;
%constant wxEventType wxEVT_SHEET_CELL_LEFT_DCLICK;
%constant wxEventType wxEVT_SHEET_CELL_RIGHT_DCLICK;
%constant wxEventType wxEVT_SHEET_LABEL_LEFT_DOWN;
%constant wxEventType wxEVT_SHEET_LABEL_RIGHT_DOWN;
%constant wxEventType wxEVT_SHEET_LABEL_LEFT_UP;
%constant wxEventType wxEVT_SHEET_LABEL_RIGHT_UP;
%constant wxEventType wxEVT_SHEET_LABEL_LEFT_DCLICK;
%constant wxEventType wxEVT_SHEET_LABEL_RIGHT_DCLICK;
%constant wxEventType wxEVT_SHEET_ROW_SIZE;
%constant wxEventType wxEVT_SHEET_ROW_SIZING;
%constant wxEventType wxEVT_SHEET_ROW_SIZED;
%constant wxEventType wxEVT_SHEET_COL_SIZE;
%constant wxEventType wxEVT_SHEET_COL_SIZING;
%constant wxEventType wxEVT_SHEET_COL_SIZED;
%constant wxEventType wxEVT_SHEET_RANGE_SELECTING;
%constant wxEventType wxEVT_SHEET_RANGE_SELECTED;
%constant wxEventType wxEVT_SHEET_CELL_VALUE_CHANGING;
%constant wxEventType wxEVT_SHEET_CELL_VALUE_CHANGED;
%constant wxEventType wxEVT_SHEET_EDITOR_ENABLED;
%constant wxEventType wxEVT_SHEET_EDITOR_DISABLED;
%constant wxEventType wxEVT_SHEET_EDITOR_CREATED;




%pythoncode {
EVT_SHEET_VIEW_CHANGED        = wx.PyEventBinder( wxEVT_SHEET_VIEW_CHANGED)
EVT_SHEET_SELECTING_CELL      = wx.PyEventBinder( wxEVT_SHEET_SELECTING_CELL)
EVT_SHEET_SELECTED_CELL       = wx.PyEventBinder( wxEVT_SHEET_SELECTED_CELL)
EVT_SHEET_CELL_LEFT_DOWN      = wx.PyEventBinder( wxEVT_SHEET_CELL_LEFT_DOWN)
EVT_SHEET_CELL_RIGHT_DOWN     = wx.PyEventBinder( wxEVT_SHEET_CELL_RIGHT_DOWN)
EVT_SHEET_CELL_LEFT_UP        = wx.PyEventBinder( wxEVT_SHEET_CELL_LEFT_UP)
EVT_SHEET_CELL_RIGHT_UP       = wx.PyEventBinder( wxEVT_SHEET_CELL_RIGHT_UP)
EVT_SHEET_CELL_LEFT_DCLICK    = wx.PyEventBinder( wxEVT_SHEET_CELL_LEFT_DCLICK)
EVT_SHEET_CELL_RIGHT_DCLICK   = wx.PyEventBinder( wxEVT_SHEET_CELL_RIGHT_DCLICK)
EVT_SHEET_LABEL_LEFT_DOWN     = wx.PyEventBinder( wxEVT_SHEET_LABEL_LEFT_DOWN)
EVT_SHEET_LABEL_RIGHT_DOWN    = wx.PyEventBinder( wxEVT_SHEET_LABEL_RIGHT_DOWN)
EVT_SHEET_LABEL_LEFT_UP       = wx.PyEventBinder( wxEVT_SHEET_LABEL_LEFT_UP)
EVT_SHEET_LABEL_RIGHT_UP      = wx.PyEventBinder( wxEVT_SHEET_LABEL_RIGHT_UP)
EVT_SHEET_LABEL_LEFT_DCLICK   = wx.PyEventBinder( wxEVT_SHEET_LABEL_LEFT_DCLICK)
EVT_SHEET_LABEL_RIGHT_DCLICK  = wx.PyEventBinder( wxEVT_SHEET_LABEL_RIGHT_DCLICK)
EVT_SHEET_ROW_SIZE            = wx.PyEventBinder( wxEVT_SHEET_ROW_SIZE)
EVT_SHEET_ROW_SIZING          = wx.PyEventBinder( wxEVT_SHEET_ROW_SIZING)
EVT_SHEET_ROW_SIZED           = wx.PyEventBinder( wxEVT_SHEET_ROW_SIZED)
EVT_SHEET_COL_SIZE            = wx.PyEventBinder( wxEVT_SHEET_COL_SIZE)
EVT_SHEET_COL_SIZING          = wx.PyEventBinder( wxEVT_SHEET_COL_SIZING)
EVT_SHEET_COL_SIZED           = wx.PyEventBinder( wxEVT_SHEET_COL_SIZED)
EVT_SHEET_RANGE_SELECTING     = wx.PyEventBinder( wxEVT_SHEET_RANGE_SELECTING)
EVT_SHEET_RANGE_SELECTED      = wx.PyEventBinder( wxEVT_SHEET_RANGE_SELECTED)
EVT_SHEET_CELL_VALUE_CHANGING = wx.PyEventBinder( wxEVT_SHEET_CELL_VALUE_CHANGING)
EVT_SHEET_CELL_VALUE_CHANGED  = wx.PyEventBinder( wxEVT_SHEET_CELL_VALUE_CHANGED)
EVT_SHEET_EDITOR_ENABLED      = wx.PyEventBinder( wxEVT_SHEET_EDITOR_ENABLED)
EVT_SHEET_EDITOR_DISABLED     = wx.PyEventBinder( wxEVT_SHEET_EDITOR_DISABLED)
EVT_SHEET_EDITOR_CREATED      = wx.PyEventBinder( wxEVT_SHEET_EDITOR_CREATED)


%# The same as above but with the ability to specify an identifier

EVT_SHEET_CMD_VIEW_CHANGED        = wx.PyEventBinder( wxEVT_SHEET_VIEW_CHANGED,        1 )
EVT_SHEET_CMD_SELECTING_CELL      = wx.PyEventBinder( wxEVT_SHEET_SELECTING_CELL,      1 )
EVT_SHEET_CMD_SELECTED_CELL       = wx.PyEventBinder( wxEVT_SHEET_SELECTED_CELL,       1 )
EVT_SHEET_CMD_CELL_LEFT_DOWN      = wx.PyEventBinder( wxEVT_SHEET_CELL_LEFT_DOWN,      1 )
EVT_SHEET_CMD_CELL_RIGHT_DOWN     = wx.PyEventBinder( wxEVT_SHEET_CELL_RIGHT_DOWN,     1 )
EVT_SHEET_CMD_CELL_LEFT_UP        = wx.PyEventBinder( wxEVT_SHEET_CELL_LEFT_UP,        1 )
EVT_SHEET_CMD_CELL_RIGHT_UP       = wx.PyEventBinder( wxEVT_SHEET_CELL_RIGHT_UP,       1 )
EVT_SHEET_CMD_CELL_LEFT_DCLICK    = wx.PyEventBinder( wxEVT_SHEET_CELL_LEFT_DCLICK,    1 )
EVT_SHEET_CMD_CELL_RIGHT_DCLICK   = wx.PyEventBinder( wxEVT_SHEET_CELL_RIGHT_DCLICK,   1 )
EVT_SHEET_CMD_LABEL_LEFT_DOWN     = wx.PyEventBinder( wxEVT_SHEET_LABEL_LEFT_DOWN,     1 )
EVT_SHEET_CMD_LABEL_RIGHT_DOWN    = wx.PyEventBinder( wxEVT_SHEET_LABEL_RIGHT_DOWN,    1 )
EVT_SHEET_CMD_LABEL_LEFT_UP       = wx.PyEventBinder( wxEVT_SHEET_LABEL_LEFT_UP,       1 )
EVT_SHEET_CMD_LABEL_RIGHT_UP      = wx.PyEventBinder( wxEVT_SHEET_LABEL_RIGHT_UP,      1 )
EVT_SHEET_CMD_LABEL_LEFT_DCLICK   = wx.PyEventBinder( wxEVT_SHEET_LABEL_LEFT_DCLICK,   1 )
EVT_SHEET_CMD_LABEL_RIGHT_DCLICK  = wx.PyEventBinder( wxEVT_SHEET_LABEL_RIGHT_DCLICK,  1 )
EVT_SHEET_CMD_ROW_SIZE            = wx.PyEventBinder( wxEVT_SHEET_ROW_SIZE,    1 )
EVT_SHEET_CMD_ROW_SIZING          = wx.PyEventBinder( wxEVT_SHEET_ROW_SIZING,  1 )
EVT_SHEET_CMD_ROW_SIZED           = wx.PyEventBinder( wxEVT_SHEET_ROW_SIZED,   1 )
EVT_SHEET_CMD_COL_SIZE            = wx.PyEventBinder( wxEVT_SHEET_COL_SIZE,    1 )
EVT_SHEET_CMD_COL_SIZING          = wx.PyEventBinder( wxEVT_SHEET_COL_SIZING,  1 )
EVT_SHEET_CMD_COL_SIZED           = wx.PyEventBinder( wxEVT_SHEET_COL_SIZED,   1 )
EVT_SHEET_CMD_RANGE_SELECTING     = wx.PyEventBinder( wxEVT_SHEET_RANGE_SELECTING, 1 )
EVT_SHEET_CMD_RANGE_SELECTED      = wx.PyEventBinder( wxEVT_SHEET_RANGE_SELECTED,  1 )
EVT_SHEET_CMD_CELL_VALUE_CHANGING = wx.PyEventBinder( wxEVT_SHEET_CELL_VALUE_CHANGING,  1 )
EVT_SHEET_CMD_CELL_VALUE_CHANGED  = wx.PyEventBinder( wxEVT_SHEET_CELL_VALUE_CHANGED,   1 )
EVT_SHEET_CMD_EDITOR_ENABLED      = wx.PyEventBinder( wxEVT_SHEET_EDITOR_ENABLED,       1 )
EVT_SHEET_CMD_EDITOR_DISABLED     = wx.PyEventBinder( wxEVT_SHEET_EDITOR_DISABLED,      1 )
EVT_SHEET_CMD_EDITOR_CREATED      = wx.PyEventBinder( wxEVT_SHEET_EDITOR_CREATED, 1 )

}

//---------------------------------------------------------------------------

%init %{
%}

//---------------------------------------------------------------------------
//---------------------------------------------------------------------------