-
Notifications
You must be signed in to change notification settings - Fork 50
/
nigui.nim
executable file
·2948 lines (2211 loc) · 95 KB
/
nigui.nim
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
# NiGui - main file
# This file contains all common code except extra widgets.
# All public procedures are declared here.
# Platform-specific code will added by "include".
# Templates for "include":
template useWindows(): bool = defined(windows) and not defined(forceGtk)
template useGtk(): bool = not useWindows()
# ========================================================================================
#
# Public Declaration
#
# ========================================================================================
# ----------------------------------------------------------------------------------------
# Simple Types
# ----------------------------------------------------------------------------------------
type
Layout* = enum
Layout_Horizontal
Layout_Vertical
XAlign* = enum
XAlign_Left
XAlign_Right
XAlign_Center
XAlign_Spread
YAlign* = enum
YAlign_Top
YAlign_Bottom
YAlign_Center
YAlign_Spread
XTextAlign* = enum
XTextAlign_Left
XTextAlign_Right
XTextAlign_Center
YTextAlign* = enum
YTextAlign_Top
YTextAlign_Bottom
YTextAlign_Center
WidthMode* = enum
WidthMode_Static
WidthMode_Auto
WidthMode_Fill
WidthMode_Expand
HeightMode* = enum
HeightMode_Static
HeightMode_Auto
HeightMode_Fill
HeightMode_Expand
MouseButton* = enum
MouseButton_Left
MouseButton_Middle
MouseButton_Right
Color* = object
red*: byte
green*: byte
blue*: byte
alpha*: byte
Spacing* = object
left*: int
right*: int
top*: int
bottom*: int
Timer* = distinct int
Key* = enum
# Keys with same value than Unicode:
Key_None = 0
Key_Backspace = 8
Key_Tab = 9
Key_Return = 13
Key_Pause = 19
Key_CapsLock = 20
Key_Escape = 27
Key_Space = 32
Key_ExclamationMark = 33
Key_DoubleQuotes = 34
Key_NumberSign = 35
Key_Dollar = 36
Key_Percent = 37
Key_Ampersand = 38
Key_OpenParen = 40
Key_CloseParen = 41
Key_Plus = 43
Key_Comma = 44
Key_Minus = 45
Key_Point = 46
Key_Divide = 47
Key_Number0 = 48
Key_Number1 = 49
Key_Number2 = 50
Key_Number3 = 51
Key_Number4 = 52
Key_Number5 = 53
Key_Number6 = 54
Key_Number7 = 55
Key_Number8 = 56
Key_Number9 = 57
Key_Less = 60
Key_Equal = 61
Key_Greater = 62
Key_QuestionMark = 63
Key_AtSign = 64
Key_A = 65
Key_B = 66
Key_C = 67
Key_D = 68
Key_E = 69
Key_F = 70
Key_G = 71
Key_H = 72
Key_I = 73
Key_J = 74
Key_K = 75
Key_L = 76
Key_M = 77
Key_N = 78
Key_O = 79
Key_P = 80
Key_Q = 81
Key_R = 82
Key_S = 83
Key_T = 84
Key_U = 85
Key_V = 86
Key_W = 87
Key_X = 88
Key_Y = 89
Key_Z = 90
Key_SuperL = 91
Key_SuperR = 92
Key_ContextMenu = 93
Key_Circumflex = 94
Key_Numpad0 = 96
Key_Numpad1 = 97
Key_Numpad2 = 98
Key_Numpad3 = 99
Key_Numpad4 = 100
Key_Numpad5 = 101
Key_Numpad6 = 102
Key_Numpad7 = 103
Key_Numpad8 = 104
Key_Numpad9 = 105
Key_NumpadMultiply = 106
Key_NumpadAdd = 107
Key_NumpadSeparator = 108
Key_NumpadSubtract = 109
Key_NumpadDecimal = 110
Key_NumpadDivide = 111
Key_F1 = 112
Key_F2 = 113
Key_F3 = 114
Key_F4 = 115
Key_F5 = 116
Key_F6 = 117
Key_F7 = 118
Key_F8 = 119
Key_F9 = 120
Key_F10 = 121
Key_F11 = 122
Key_F12 = 123
Key_F13 = 124
Key_F14 = 125
Key_F15 = 126
Key_F16 = 127
Key_F17 = 128
Key_F18 = 129
Key_F19 = 130
Key_F20 = 131
Key_F21 = 132
Key_F22 = 133
Key_F23 = 134
Key_F24 = 135
Key_NumLock = 144
Key_ScrollLock = 145
Key_AE = 196
Key_OE = 214
Key_UE = 220
Key_SharpS = 223
# Not part of Unicode:
Key_Insert = 1000
Key_Delete
Key_Left
Key_Right
Key_Up
Key_Down
Key_Home
Key_End
Key_PageUp
Key_PageDown
Key_ControlL
Key_ControlR
Key_AltL
Key_AltR
Key_ShiftL
Key_ShiftR
Key_Print
Key_NumpadEnter
Key_AltGr
InterpolationMode* = enum
InterpolationMode_Default
InterpolationMode_NearestNeighbor
InterpolationMode_Bilinear
const
inactiveTimer* = 0
# ----------------------------------------------------------------------------------------
# Widget Types 1/3
# ----------------------------------------------------------------------------------------
type
# Window base type:
Window* = ref object of RootObj
fDisposed: bool
fTitle: string
fVisible: bool
fMinimized: bool
fAlwaysOnTop: bool
fWidth, fHeight: int
fMinWidth, fMinHeight: int
fResizable: bool
fClientWidth, fClientHeight: int
fX, fY: int
fControl: Control
fIconPath: string
fOnDispose: WindowDisposeProc
fOnCloseClick: CloseClickProc
fOnResize: ResizeProc
fOnDropFiles: DropFilesProc
fOnKeyDown: KeyboardProc
# Control base type:
Control* = ref object of RootObj
fDisposed: bool
fParentControl: Control # is nil or object of ContainerImpl
fParentWindow: Window # only set for top level widget
fIndex: int
fVisible: bool
fWidth, fHeight: int
fX, fY: int
fWidthMode: WidthMode
fHeightMode: HeightMode
fMinWidth, fMinHeight: int
fMaxWidth, fMaxHeight: int
fXScrollEnabled, fYScrollEnabled: bool
fXScrollPos, fYScrollPos: int
fScrollableWidth, fScrollableHeight: int
fFontFamily: string
fFontSize: float
fFontBold: bool
fTextColor: Color
fBackgroundColor: Color
fUseDefaultFontFamily: bool
fUseDefaultFontSize: bool
fUseDefaultTextColor: bool
fUseDefaultBackgroundColor: bool
fCanvas: Canvas
fOnDispose: ControlDisposeProc
fOnDraw: DrawProc
fOnMouseButtonDown: MouseButtonProc
fOnMouseButtonUp: MouseButtonProc
fOnClick: ClickProc
fOnMouseMove: MouseMoveProc
fOnMouseEnter: MouseMoveProc
fOnMouseLeave: MouseMoveProc
fOnKeyDown: KeyboardProc
tag*: string
# Drawing:
Canvas* = ref object of RootObj
fWidth: int
fHeight: int
fFontFamily: string
fFontSize: float
fFontBold: bool
fTextColor: Color
fLineColor: Color
fLineWidth: float
fAreaColor: Color
fInterpolationMode: InterpolationMode
Image* = ref object of RootObj
fCanvas: Canvas
# Window events:
WindowDisposeEvent* = ref object
window*: Window
WindowDisposeProc* = proc(event: WindowDisposeEvent)
CloseClickEvent* = ref object
window*: Window
CloseClickProc* = proc(event: CloseClickEvent)
ResizeEvent* = ref object
window*: Window
ResizeProc* = proc(event: ResizeEvent)
DropFilesEvent* = ref object
window*: Window
files*: seq[string]
DropFilesProc* = proc(event: DropFilesEvent)
KeyboardEvent* = ref object
window*: Window
control*: Control
key*: Key
unicode*: int
character*: string # UTF-8 character
handled*: bool
KeyboardProc* = proc(event: KeyboardEvent)
# Control events:
ControlDisposeEvent* = ref object
control*: Control
ControlDisposeProc* = proc(event: ControlDisposeEvent)
DrawEvent* = ref object
control*: Control
DrawProc* = proc(event: DrawEvent)
MouseEvent* = ref object
control*: Control
button*: MouseButton
x*: int
y*: int
MouseButtonProc* = proc(event: MouseEvent)
MouseMoveProc* = proc(event: MouseEvent)
MouseEnterProc* = proc(event: MouseEvent)
MouseLeaveProc* = proc(event: MouseEvent)
ClickEvent* = ref object
control*: Control
ClickProc* = proc(event: ClickEvent)
TextChangeEvent* = ref object
control*: Control
TextChangeProc* = proc(event: TextChangeEvent)
ToggleEvent* = ref object
control*: Control
ToggleProc* = proc(event: ToggleEvent)
ComboBoxChangeEvent* = ref object
control*: Control
ComboBoxChangeProc* = proc(event: ComboBoxChangeEvent)
# Other events:
ErrorHandlerProc* = proc()
TimerEvent* = ref object
timer*: Timer
data*: pointer
TimerProc* = proc(event: TimerEvent)
# Platform-specific extension of Window and Control:
when useWindows(): include "nigui/private/windows/platform_types1"
when useGtk(): include "nigui/private/gtk3/platform_types1"
# ----------------------------------------------------------------------------------------
# Widget Types 2/3
# ----------------------------------------------------------------------------------------
type
# Basic controls:
Container* = ref object of ControlImpl
fFrame: Frame
fChildControls: seq[Control]
Frame* = ref object of ControlImpl
fText: string
Button* = ref object of ControlImpl
fText: string
fEnabled: bool
Checkbox* = ref object of ControlImpl
fText: string
fEnabled: bool
fOnToggle: ToggleProc
ComboBox* = ref object of ControlImpl
fEnabled: bool
fOptions: seq[string]
fOnChange: ComboBoxChangeProc
Label* = ref object of ControlImpl
fText: string
fXTextAlign: XTextAlign
fYTextAlign: YTextAlign
ProgressBar* = ref object of ControlImpl
fValue: float # should be between 0.0 and 1.0
TextBox* = ref object of ControlImpl
fEditable: bool
fOnTextChange: TextChangeProc
# Platform-specific extension:
when useWindows(): include "nigui/private/windows/platform_types2"
when useGtk(): include "nigui/private/gtk3/platform_types2"
# ----------------------------------------------------------------------------------------
# Widget Types 3/3
# ----------------------------------------------------------------------------------------
type
LayoutContainer* = ref object of ContainerImpl
fLayout: Layout
fXAlign: XAlign
fYAlign: YAlign
fPadding: int
fSpacing: int
TextArea* = ref object of NativeTextBox
fWrap: bool
# Platform-specific extension:
when useWindows(): include "nigui/private/windows/platform_types3"
when useGtk(): include "nigui/private/gtk3/platform_types3"
# ----------------------------------------------------------------------------------------
# Global Variables
# ----------------------------------------------------------------------------------------
var
quitOnLastWindowClose* = true
clickMaxXYMove* = 20
# dummy type and object, needed to use get/set properties
type App = object
running*: bool
var app*: App
# ----------------------------------------------------------------------------------------
# Global/App Procedures
# ----------------------------------------------------------------------------------------
proc init*(app: App)
proc run*(app: var App)
proc quit*(app: var App, quitApp: bool = false)
proc processEvents*(app: App)
proc sleep*(app: App, milliSeconds: float)
proc queueMain*(app: App, fn: proc()) ## \
## Queues `fn` to be executed on the GUI thread and returns immediately.
##
## This is the only function that can be safely called from other threads, and it must be called from a `{.gcsafe.}:` block.
## Before a thread that has called this function returns, it should wait for all queued funcitons to be executed:
##
## .. code-block:: nim
## while app.queued() > 0:
## discard
proc queued*(app: App): int ## \
## Returns the number of functions queued to be executed on the GUI thread.
proc errorHandler*(app: App): ErrorHandlerProc
proc `errorHandler=`*(app: App, errorHandler: ErrorHandlerProc)
proc defaultBackgroundColor*(app: App): Color
proc `defaultBackgroundColor=`*(app: App, color: Color)
proc defaultTextColor*(app: App): Color
proc `defaultTextColor=`*(app: App, color: Color)
proc defaultFontFamily*(app: App): string
proc `defaultFontFamily=`*(app: App, fontFamily: string)
proc defaultFontSize*(app: App): float
proc `defaultFontSize=`*(app: App, fontSize: float)
proc clipboardText*(app: App): string
proc `clipboardText=`*(app: App, text: string)
proc rgb*(red, green, blue: byte, alpha: byte = 255): Color
proc isDown*(key: Key): bool
proc downKeys*(): seq[Key]
proc scaleToDpi*(val: int): int
proc scaleToDpi*(val: float): float
proc convertLineBreaks*(str: string): string
# ----------------------------------------------------------------------------------------
# Dialogs
# ----------------------------------------------------------------------------------------
proc alert*(window: Window, message: string, title = "Message") {.discardable.}
type OpenFileDialog* = ref object
title*: string
directory*: string
multiple*: bool
files*: seq[string]
proc newOpenFileDialog*(): OpenFileDialog
method run*(dialog: OpenFileDialog) {.base.}
type SaveFileDialog* = ref object
title*: string
directory*: string
defaultExtension*: string
defaultName*: string
file*: string
proc newSaveFileDialog*(): SaveFileDialog
method run*(dialog: SaveFileDialog) {.base.}
type SelectDirectoryDialog* = ref object
title*: string
startDirectory*: string
selectedDirectory*: string
proc newSelectDirectoryDialog*(): SelectDirectoryDialog
method run*(dialog: SelectDirectoryDialog) {.base.}
# ----------------------------------------------------------------------------------------
# Timers
# ----------------------------------------------------------------------------------------
proc startTimer*(milliSeconds: int, timerProc: TimerProc, data: pointer = nil): Timer {.discardable.}
proc startRepeatingTimer*(milliSeconds: int, timerProc: TimerProc, data: pointer = nil): Timer {.discardable.}
proc stop*(timer: var Timer)
# ----------------------------------------------------------------------------------------
# Canvas
# ----------------------------------------------------------------------------------------
proc newCanvas*(control: Control = nil): CanvasImpl
method destroy*(canvas: Canvas) {.base, locks: "unknown".}
method width*(canvas: Canvas): int {.base.}
method height*(canvas: Canvas): int {.base.}
method fontFamily*(canvas: Canvas): string {.base.}
method `fontFamily=`*(canvas: Canvas, fontFamily: string) {.base, locks: "unknown".}
method fontSize*(canvas: Canvas): float {.base.}
method `fontSize=`*(canvas: Canvas, fontSize: float) {.base, locks: "unknown".}
method fontBold*(canvas: Canvas): bool {.base.}
method `fontBold=`*(canvas: Canvas, fontBold: bool) {.base, locks: "unknown".}
method textColor*(canvas: Canvas): Color {.base.}
method `textColor=`*(canvas: Canvas, color: Color) {.base, locks: "unknown".}
method lineColor*(canvas: Canvas): Color {.base.}
method `lineColor=`*(canvas: Canvas, color: Color) {.base, locks: "unknown".}
method lineWidth*(canvas: Canvas): float {.base.}
method `lineWidth=`*(canvas: Canvas, width: float) {.base.}
method areaColor*(canvas: Canvas): Color {.base.}
method `areaColor=`*(canvas: Canvas, color: Color) {.base, locks: "unknown".}
method drawText*(canvas: Canvas, text: string, x, y = 0) {.base.}
method drawTextCentered*(canvas: Canvas, text: string, x, y = 0, width, height = -1) {.base.}
method drawLine*(canvas: Canvas, x1, y1, x2, y2: int) {.base.}
method drawRectArea*(canvas: Canvas, x, y, width, height: int) {.base.}
method drawRectOutline*(canvas: Canvas, x, y, width, height: int) {.base.}
method drawEllipseArea*(canvas: Canvas, x, y, width, height: int) {.base.}
method drawEllipseOutline*(canvas: Canvas, x, y, width, height: int) {.base.}
method drawArcOutline*(canvas: Canvas, centerX, centerY: int, radius, startAngle, sweepAngle: float) {.base.}
method fill*(canvas: Canvas) {.base.}
method drawImage*(canvas: Canvas, image: Image, x, y = 0, width, height = -1) {.base.}
method setPixel*(canvas: Canvas, x, y: int, color: Color) {.base.}
method getTextLineWidth*(canvas: Canvas, text: string): int {.base, locks: "unknown".}
method getTextLineHeight*(canvas: Canvas): int {.base, locks: "unknown".}
method getTextWidth*(canvas: Canvas, text: string): int {.base.}
method interpolationMode*(canvas: Canvas): InterpolationMode {.base.}
method `interpolationMode=`*(canvas: Canvas, mode: InterpolationMode) {.base.}
# ----------------------------------------------------------------------------------------
# Image
# ----------------------------------------------------------------------------------------
proc newImage*(): Image
method resize*(image: Image, width, height: int) {.base.}
method loadFromFile*(image: Image, filePath: string) {.base.}
method saveToBitmapFile*(image: Image, filePath: string) {.base.}
method saveToPngFile*(image: Image, filePath: string) {.base.}
method saveToJpegFile*(image: Image, filePath: string, quality = 80) {.base.}
method width*(image: Image): int {.base.}
method height*(image: Image): int {.base.}
method canvas*(image: Image): Canvas {.base.}
method beginPixelDataAccess*(image: Image): ptr UncheckedArray[byte] {.base.}
method endPixelDataAccess*(image: Image) {.base.}
# ----------------------------------------------------------------------------------------
# Window
# ----------------------------------------------------------------------------------------
proc newWindow*(title: string = ""): Window ## \
## Constructor for a Window object.
## If the title is empty, it will be set to the application filename.
proc init*(window: WindowImpl) ## \
## Initialize a WindowImpl object.
## Only needed for own constructors.
proc dispose*(window: var Window)
method dispose*(window: Window) {.base.}
proc disposed*(window: Window): bool
method visible*(window: Window): bool {.base.}
method `visible=`*(window: Window, visible: bool) {.base.}
method show*(window: Window) {.base.}
method showModal*(window: Window, parent: Window) {.base.}
method hide*(window: Window) {.base.}
method minimized*(window: Window): bool {.base.}
method `minimized=`*(window: Window, minimized: bool) {.base.}
method minimize*(window: Window) {.base.}
method alwaysOnTop*(window: Window): bool {.base.}
method `alwaysOnTop=`*(window: Window, alwaysOnTop: bool) {.base.}
method control*(window: Window): Control {.base.}
method `control=`*(window: Window, control: Control) {.base, locks: "unknown".}
method add*(window: Window, control: Control) {.base.}
method title*(window: Window): string {.base.}
method `title=`*(window: Window, title: string) {.base, locks: "unknown".}
method x*(window: Window): int {.base.}
method `x=`*(window: Window, x: int) {.base, locks: "unknown".}
method y*(window: Window): int {.base.}
method `y=`*(window: Window, y: int) {.base, locks: "unknown".}
method centerOnScreen*(window: Window) {.base, locks: "unknown".}
method width*(window: Window): int {.base.}
method `width=`*(window: Window, width: int) {.base, locks: "unknown".}
method height*(window: Window): int {.base.}
method `height=`*(window: Window, height: int) {.base, locks: "unknown".}
method minWidth*(window: Window): int {.base.}
method `minWidth=`*(window: Window, minWidth: int) {.base, locks: "unknown".}
method minHeight*(window: Window): int {.base.}
method `minHeight=`*(window: Window, minHeight: int) {.base, locks: "unknown".}
method resizable*(window: Window): bool {.base.}
method `resizable=`*(window: Window, resizable: bool) {.base, locks: "unknown".}
method clientWidth*(window: Window): int {.base.}
method clientHeight*(window: Window): int {.base.}
method iconPath*(window: Window): string {.base.}
method `iconPath=`*(window: Window, iconPath: string) {.base, locks: "unknown".}
method mousePosition*(window: Window): tuple[x, y: int] {.base.} ## \
## Returns the mouse pointer position relative to the given window
method closeClick*(window: Window) {.base.}
method handleResizeEvent*(window: Window, event: ResizeEvent) {.base.}
method handleKeyDownEvent*(window: Window, event: KeyboardEvent) {.base.}
method handleDropFilesEvent*(window: Window, event: DropFilesEvent) {.base.}
method onDispose*(window: Window): WindowDisposeProc {.base.}
method `onDispose=`*(window: Window, callback: WindowDisposeProc) {.base.}
method onCloseClick*(window: Window): CloseClickProc {.base.}
method `onCloseClick=`*(window: Window, callback: CloseClickProc) {.base.}
method onResize*(window: Window): ResizeProc {.base.}
method `onResize=`*(window: Window, callback: ResizeProc) {.base.}
method onDropFiles*(window: Window): DropFilesProc {.base.}
method `onDropFiles=`*(window: Window, callback: DropFilesProc) {.base.}
method onKeyDown*(window: Window): KeyboardProc {.base.}
method `onKeyDown=`*(window: Window, callback: KeyboardProc) {.base.}
# ----------------------------------------------------------------------------------------
# Control
# ----------------------------------------------------------------------------------------
proc newControl*(): Control
proc init*(control: Control)
proc init*(control: ControlImpl)
proc dispose*(control: var Control)
method dispose*(control: Control) {.base.}
proc disposed*(control: Control): bool
method visible*(control: Control): bool {.base.}
method `visible=`*(control: Control, visible: bool) {.base.}
method show*(control: Control) {.base.}
method hide*(control: Control) {.base.}
# Allow the outside to walk over child widgets
method childControls*(control: Control): seq[Control] {.base.}
method parentControl*(control: Control): Control {.base.}
method parentWindow*(control: Control): WindowImpl {.base.}
method width*(control: Control): int {.base.}
# Set the control's width to a fixed value (sets widthMode to fixed)
method `width=`*(control: Control, width: int) {.base.}
method height*(control: Control): int {.base.}
# Set the control's height to a fixed value (sets heightMode to fixed)
method `height=`*(control: Control, height: int) {.base.}
method minWidth*(control: Control): int {.base, locks: "unknown".}
method `minWidth=`*(control: Control, minWidth: int) {.base.}
method minHeight*(control: Control): int {.base, locks: "unknown".}
method `minHeight=`*(control: Control, minHeight: int) {.base.}
method maxWidth*(control: Control): int {.base.}
method `maxWidth=`*(control: Control, maxWidth: int) {.base.}
method maxHeight*(control: Control): int {.base.}
method `maxHeight=`*(control: Control, maxHeight: int) {.base.}
# Set the control's width and height without changing widthMode or heightMode
method setSize*(control: Control, width, height: int) {.base.}
method x*(control: Control): int {.base.}
method `x=`*(control: Control, x: int) {.base.}
method y*(control: Control): int {.base.}
method `y=`*(control: Control, y: int) {.base.}
method setPosition*(control: Control, x, y: int) {.base, locks: "unknown".}
method naturalWidth*(control: Control): int {.base, locks: "unknown".}
method naturalHeight*(control: Control): int {.base, locks: "unknown".}
method wantedWidth*(control: Control): int {.base.}
method wantedHeight*(control: Control): int {.base.}
method mousePosition*(control: Control): tuple[x, y: int] {.base.} ## \
## Returns the mouse pointer position relative to the given control
method focus*(control: Control) {.base.}
method getTextLineWidth*(control: Control, text: string): int {.base, locks: "unknown".}
method getTextLineHeight*(control: Control): int {.base, locks: "unknown".}
method getTextWidth*(control: Control, text: string): int {.base.}
method `widthMode=`*(control: Control, mode: WidthMode) {.base.}
method widthMode*(control: Control): WidthMode {.base.}
method heightMode*(control: Control): HeightMode {.base.}
method `heightMode=`*(control: Control, mode: HeightMode) {.base.}
method visibleWidth*(control: Control): int {.base.}
method visibleHeight*(control: Control): int {.base.}
method xScrollPos*(control: Control): int {.base.}
method `xScrollPos=`*(control: Control, xScrollPos: int) {.base, locks: "unknown".}
method yScrollPos*(control: Control): int {.base.}
method `yScrollPos=`*(control: Control, yScrollPos: int) {.base, locks: "unknown".}
method scrollableWidth*(control: Control): int {.base.}
method `scrollableWidth=`*(control: Control, scrollableWidth: int) {.base.}
method scrollableHeight*(control: Control): int {.base.}
method `scrollableHeight=`*(control: Control, scrollableHeight: int) {.base.}
method fontFamily*(control: Control): string {.base.}
method `fontFamily=`*(control: Control, fontFamily: string) {.base.}
method setFontFamily*(control: Control, fontFamily: string) {.base.}
method fontSize*(control: Control): float {.base.}
method `fontSize=`*(control: Control, fontSize: float) {.base.}
method setFontSize*(control: Control, fontSize: float) {.base, locks: "unknown".}
method fontBold*(control: Control): bool {.base.}
method `fontBold=`*(control: Control, fontBold: bool) {.base.}
method setFontBold*(control: Control, fontBold: bool) {.base, locks: "unknown".}
method backgroundColor*(control: Control): Color {.base.}
method `backgroundColor=`*(control: Control, color: Color) {.base.}
method setBackgroundColor*(control: Control, color: Color) {.base.}
method initStyle*(control: Control) {.base.}
method textColor*(control: Control): Color {.base.}
method `textColor=`*(control: Control, color: Color) {.base.}
method setTextColor*(control: Control, color: Color) {.base.}
method forceRedraw*(control: Control) {.base.}
method canvas*(control: Control): Canvas {.base.}
method handleDrawEvent*(control: Control, event: DrawEvent) {.base.}
method handleMouseButtonDownEvent*(control: Control, event: MouseEvent) {.base.}
method handleMouseButtonUpEvent*(control: Control, event: MouseEvent) {.base.}
method handleClickEvent*(control: Control, event: ClickEvent) {.base.}
method handleKeyDownEvent*(control: Control, event: KeyboardEvent) {.base.}
method onDispose*(control: Control): ControlDisposeProc {.base.}
method `onDispose=`*(control: Control, callback: ControlDisposeProc) {.base.}
method onDraw*(control: Control): DrawProc {.base.}
method `onDraw=`*(control: Control, callback: DrawProc) {.base.}
method onMouseButtonDown*(control: Control): MouseButtonProc {.base.}
method `onMouseButtonDown=`*(control: Control, callback: MouseButtonProc) {.base.}
method onMouseButtonUp*(control: Control): MouseButtonProc {.base.}
method `onMouseButtonUp=`*(control: Control, callback: MouseButtonProc) {.base.}
method onMouseMove*(control: Control): MouseMoveProc {.base.}
method `onMouseMove=`*(control: Control, callback: MouseMoveProc) {.base.}
method onMouseEnter*(control: Control): MouseEnterProc {.base.}
method `onMouseEnter=`*(control: Control, callback: MouseEnterProc) {.base.}
method onMouseLeave*(control: Control): MouseLeaveProc {.base.}
method `onMouseLeave=`*(control: Control, callback: MouseLeaveProc) {.base.}
method onClick*(control: Control): ClickProc {.base.}
method `onClick=`*(control: Control, callback: ClickProc) {.base.}
method onKeyDown*(control: Control): KeyboardProc {.base.}
method `onKeyDown=`*(control: Control, callback: KeyboardProc) {.base.}
# ----------------------------------------------------------------------------------------
# Container
# ----------------------------------------------------------------------------------------
proc newContainer*(): Container
proc init*(container: Container)
proc init*(container: ContainerImpl)
method frame*(container: Container): Frame {.base.}
method `frame=`*(container: Container, frame: Frame) {.base.}
method add*(container: Container, control: Control) {.base.}
method remove*(container: Container, control: Control) {.base, locks: "unknown".}
method getPadding*(container: Container): Spacing {.base.}
method setInnerSize*(container: Container, width, height: int) {.base, locks: "unknown".}
# ----------------------------------------------------------------------------------------
# LayoutContainer
# ----------------------------------------------------------------------------------------
proc newLayoutContainer*(layout: Layout): LayoutContainer
method layout*(container: LayoutContainer): Layout {.base.}
method `layout=`*(container: LayoutContainer, layout: Layout) {.base.}
method xAlign*(container: LayoutContainer): XAlign {.base.}
method `xAlign=`*(container: LayoutContainer, xAlign: XAlign) {.base.}
method yAlign*(container: LayoutContainer): YAlign {.base.}
method `yAlign=`*(container: LayoutContainer, yAlign: YAlign) {.base.}
method padding*(container: LayoutContainer): int {.base.}
method `padding=`*(container: LayoutContainer, padding: int) {.base.}
method spacing*(container: LayoutContainer): int {.base.}
method `spacing=`*(container: LayoutContainer, spacing: int) {.base.}
# ----------------------------------------------------------------------------------------
# Frame
# ----------------------------------------------------------------------------------------
proc newFrame*(text = ""): Frame
proc init*(frame: Frame)
proc init*(frame: NativeFrame)
method text*(frame: Frame): string {.base.}
method `text=`*(frame: Frame, text: string) {.base, locks: "unknown".}
method getPadding*(frame: Frame): Spacing {.base, locks: "unknown".}
# ----------------------------------------------------------------------------------------
# Button
# ----------------------------------------------------------------------------------------
proc newButton*(text = ""): Button
proc init*(button: Button)
proc init*(button: NativeButton)
method text*(button: Button): string {.base.}
method `text=`*(button: Button, text: string) {.base.}
method enabled*(button: Button): bool {.base.}
method `enabled=`*(button: Button, enabled: bool) {.base.}
# ----------------------------------------------------------------------------------------
# Checkbox
# ----------------------------------------------------------------------------------------
proc newCheckbox*(text = ""): Checkbox
proc init*(checkbox: Checkbox)
proc init*(checkbox: NativeCheckbox)