-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdw.h
2263 lines (2044 loc) · 81.2 KB
/
dw.h
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
/* $Id$ */
#ifndef _H_DW
#define _H_DW
#ifdef __cplusplus
extern "C" {
#endif
/* Dynamic Windows version numbers */
#define DW_MAJOR_VERSION 3
#define DW_MINOR_VERSION 4
#define DW_SUB_VERSION 0
/* General application type defines */
#if defined(__IOS__) || defined(__ANDROID__)
#define DW_MOBILE 1
#endif
#define DW_HOME_URL "http://dwindows.netlabs.org"
/* Support for API deprecation in supported compilers */
#ifndef __has_attribute
# define __has_attribute(x) 0
#endif
#ifndef __has_extension
# define __has_extension __has_feature
#endif
#ifndef __has_feature
# define __has_feature(x) 0
#endif
#ifndef __GNUC_PREREQ
# if defined(__GNUC__) && defined(__GNUC_MINOR__)
# define __GNUC_PREREQ(maj, min) ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
# else
# define __GNUC_PREREQ(maj, min) 0
# endif
#endif
/* Visual C */
#if defined(_MSC_VER)
# if _MSC_VER >= 1400
# define DW_DEPRECATED(func, message) __declspec(deprecated(message)) func
# endif
/* Clang or GCC */
#elif __has_extension(attribute_deprecated_with_message) || __GNUC_PREREQ(4, 5)
# define DW_DEPRECATED(func, message) func __attribute__((deprecated (message)))
#elif __has_extension(attribute_deprecated) || __GNUC_PREREQ(3, 1)
# define DW_DEPRECATED(func, message) func __attribute__((deprecated))
#endif
/* Compiler without deprecation support */
#ifndef DW_DEPRECATED
#define DW_DEPRECATED(func, message) func
#endif
/* Support for unused variables in supported compilers */
#if __has_attribute(unused) || __GNUC_PREREQ(2, 95)
#define DW_UNUSED(x) x __attribute__((__unused__))
#else
#define DW_UNUSED(x) x
#endif
#include <stdarg.h>
/* These corespond to the entries in the color
* arrays in the Win32 dw.c, they are also the
* same as DOS ANSI colors.
*/
#define DW_CLR_BLACK 0
#define DW_CLR_DARKRED 1
#define DW_CLR_DARKGREEN 2
#define DW_CLR_BROWN 3
#define DW_CLR_DARKBLUE 4
#define DW_CLR_DARKPINK 5
#define DW_CLR_DARKCYAN 6
#define DW_CLR_PALEGRAY 7
#define DW_CLR_DARKGRAY 8
#define DW_CLR_RED 9
#define DW_CLR_GREEN 10
#define DW_CLR_YELLOW 11
#define DW_CLR_BLUE 12
#define DW_CLR_PINK 13
#define DW_CLR_CYAN 14
#define DW_CLR_WHITE 15
#define DW_CLR_DEFAULT 16
/* Signal handler defines */
#define DW_SIGNAL_CONFIGURE "configure_event"
#define DW_SIGNAL_KEY_PRESS "key_press_event"
#define DW_SIGNAL_BUTTON_PRESS "button_press_event"
#define DW_SIGNAL_BUTTON_RELEASE "button_release_event"
#define DW_SIGNAL_MOTION_NOTIFY "motion_notify_event"
#define DW_SIGNAL_DELETE "delete_event"
#define DW_SIGNAL_EXPOSE "expose_event"
#define DW_SIGNAL_CLICKED "clicked"
#define DW_SIGNAL_ITEM_ENTER "container-select"
#define DW_SIGNAL_ITEM_CONTEXT "container-context"
#define DW_SIGNAL_ITEM_SELECT "tree-select"
#define DW_SIGNAL_LIST_SELECT "item-select"
#define DW_SIGNAL_SET_FOCUS "set-focus"
#define DW_SIGNAL_VALUE_CHANGED "value_changed"
#define DW_SIGNAL_SWITCH_PAGE "switch-page"
#define DW_SIGNAL_COLUMN_CLICK "click-column"
#define DW_SIGNAL_TREE_EXPAND "tree-expand"
#define DW_SIGNAL_HTML_CHANGED "html-changed"
#define DW_SIGNAL_HTML_RESULT "html-result"
#define DW_SIGNAL_HTML_MESSAGE "html-message"
/* status of menu items */
#define DW_MIS_ENABLED 1
#define DW_MIS_DISABLED (1 << 1)
#define DW_MIS_CHECKED (1 << 2)
#define DW_MIS_UNCHECKED (1 << 3)
/* Gravity */
#define DW_GRAV_TOP 0
#define DW_GRAV_LEFT 0
#define DW_GRAV_CENTER 1
#define DW_GRAV_RIGHT 2
#define DW_GRAV_BOTTOM 2
#define DW_GRAV_OBSTACLES (1 << 10)
/* Control size constants */
#define DW_SIZE_AUTO -1
#if defined(__OS2__) || defined(__WIN32__) || defined(__MAC__) || defined(__IOS__) || defined(__EMX__) || defined(__ANDROID__) || defined(__TEMPLATE__)
/* Non-GTK platforms */
#ifdef __OS2__
# if (defined(__IBMC__) || defined(__WATCOMC__) || defined(_System)) && !defined(API)
# define API _System
# endif
#endif
/* Used internally */
#define _DW_TYPE_BOX 0
#define _DW_TYPE_ITEM 1
#define _DW_SPLITBAR_WIDTH 4
#define _DW_SIZE_STATIC 0
#define _DW_SIZE_EXPAND 1
typedef struct _user_data
{
struct _user_data *next;
void *data;
char *varname;
} UserData;
/* OS/2 Specific section */
#if defined(__OS2__) || defined(__EMX__)
#define INCL_DOS
#define INCL_WIN
#define INCL_GPI
#include <os2.h>
#define HTIMER_TYPEDEFED 1
#define DW_DT_LEFT DT_LEFT
#define DW_DT_QUERYEXTENT DT_QUERYEXTENT
#define DW_DT_UNDERSCORE DT_UNDERSCORE
#define DW_DT_STRIKEOUT DT_STRIKEOUT
#define DW_DT_TEXTATTRS DT_TEXTATTRS
#define DW_DT_EXTERNALLEADING DT_EXTERNALLEADING
#define DW_DT_CENTER DT_CENTER
#define DW_DT_RIGHT DT_RIGHT
#define DW_DT_TOP DT_TOP
#define DW_DT_VCENTER DT_VCENTER
#define DW_DT_BOTTOM DT_BOTTOM
#define DW_DT_HALFTONE DT_HALFTONE
#define DW_DT_MNEMONIC DT_MNEMONIC
#define DW_DT_WORDBREAK DT_WORDBREAK
#define DW_DT_ERASERECT DT_ERASERECT
#ifndef FCF_CLOSEBUTTON
#define FCF_CLOSEBUTTON 0x04000000L
#endif
#define DW_FCF_CLOSEBUTTON 0
#define DW_FCF_TITLEBAR FCF_TITLEBAR
#define DW_FCF_SYSMENU (FCF_SYSMENU | FCF_CLOSEBUTTON)
#define DW_FCF_MENU FCF_MENU
#define DW_FCF_SIZEBORDER FCF_SIZEBORDER
#define DW_FCF_MINBUTTON FCF_MINBUTTON
#define DW_FCF_MAXBUTTON FCF_MAXBUTTON
#define DW_FCF_MINMAX FCF_MINMAX
#define DW_FCF_DLGBORDER FCF_DLGBORDER
#define DW_FCF_BORDER FCF_BORDER
#define DW_FCF_TASKLIST FCF_TASKLIST
#define DW_FCF_NOMOVEWITHOWNER FCF_NOMOVEWITHOWNER
#define DW_FCF_SYSMODAL FCF_SYSMODAL
#define DW_FCF_HIDEBUTTON FCF_HIDEBUTTON
#define DW_FCF_HIDEMAX FCF_HIDEMAX
#define DW_FCF_AUTOICON FCF_AUTOICON
#define DW_FCF_MAXIMIZE WS_MAXIMIZED
#define DW_FCF_MINIMIZE WS_MINIMIZED
#define DW_FCF_TEXTURED 0
#define DW_FCF_FULLSCREEN 0
#define DW_CFA_BITMAPORICON CFA_BITMAPORICON
#define DW_CFA_STRING CFA_STRING
#define DW_CFA_ULONG CFA_ULONG
#define DW_CFA_TIME CFA_TIME
#define DW_CFA_DATE CFA_DATE
#define DW_CFA_CENTER CFA_CENTER
#define DW_CFA_LEFT CFA_LEFT
#define DW_CFA_RIGHT CFA_RIGHT
#define DW_CFA_HORZSEPARATOR CFA_HORZSEPARATOR
#define DW_CFA_SEPARATOR CFA_SEPARATOR
#define DW_CFA_STRINGANDICON 0
#define DW_CRA_SELECTED CRA_SELECTED
#define DW_CRA_CURSORED CRA_CURSORED
#define DW_CR_RETDATA (1 << 10)
#define DW_LS_MULTIPLESEL LS_MULTIPLESEL
#define DW_LIT_NONE -1
#define DW_MLE_CASESENSITIVE MLFSEARCH_CASESENSITIVE
#define DW_POINTER_DEFAULT 0
#define DW_POINTER_ARROW SPTR_ARROW
#define DW_POINTER_CLOCK SPTR_WAIT
#define DW_POINTER_QUESTION SPTR_ICONQUESTION
#define DW_BS_NOBORDER BS_NOBORDER
/* flag values for dw_messagebox() */
#define DW_MB_OK MB_OK
#define DW_MB_OKCANCEL MB_OKCANCEL
#define DW_MB_YESNO MB_YESNO
#define DW_MB_YESNOCANCEL MB_YESNOCANCEL
#define DW_MB_WARNING MB_WARNING
#define DW_MB_ERROR MB_ERROR
#define DW_MB_INFORMATION MB_INFORMATION
#define DW_MB_QUESTION MB_QUERY
/* Virtual Key Codes */
#define VK_LBUTTON VK_BUTTON1
#define VK_RBUTTON VK_BUTTON2
#define VK_MBUTTON VK_BUTTON3
#define VK_RETURN VK_NEWLINE
#define VK_SNAPSHOT VK_PRINTSCRN
#define VK_CANCEL VK_BREAK
#define VK_CAPITAL VK_CAPSLOCK
#define VK_ESCAPE VK_ESC
#define VK_PRIOR VK_PAGEUP
#define VK_NEXT VK_PAGEDOWN
#define VK_SELECT 133
#define VK_EXECUTE 134
#define VK_PRINT 135
#define VK_HELP 136
#define VK_LWIN 137
#define VK_RWIN 138
#define VK_MULTIPLY ('*' + 128)
#define VK_ADD ('+' + 128)
#define VK_SEPARATOR 141
#define VK_SUBTRACT ('-' + 128)
#define VK_DECIMAL ('.' + 128)
#define VK_DIVIDE ('/' + 128)
#define VK_SCROLL VK_SCRLLOCK
#define VK_LSHIFT VK_SHIFT
#define VK_RSHIFT 147
#define VK_LCONTROL VK_CTRL
#define VK_RCONTROL 149
#define VK_NUMPAD0 ('0' + 128)
#define VK_NUMPAD1 ('1' + 128)
#define VK_NUMPAD2 ('2' + 128)
#define VK_NUMPAD3 ('3' + 128)
#define VK_NUMPAD4 ('4' + 128)
#define VK_NUMPAD5 ('5' + 128)
#define VK_NUMPAD6 ('6' + 128)
#define VK_NUMPAD7 ('7' + 128)
#define VK_NUMPAD8 ('8' + 128)
#define VK_NUMPAD9 ('9' + 128)
#define VK_BACK VK_BACKSPACE
#define VK_LMENU VK_MENU
#define VK_RMENU VK_MENU
#define BUBBLE_HELP_MAX 256
typedef struct _window_data {
PFNWP oldproc;
UserData *root;
HWND clickdefault;
ULONG flags;
void *data;
char bubbletext[BUBBLE_HELP_MAX];
} WindowData;
typedef struct _hpixmap {
unsigned long width, height;
HDC hdc;
HPS hps;
HBITMAP hbm;
HWND handle, font;
unsigned long transcolor;
int depth;
} *HPIXMAP;
typedef void *HTREEITEM;
typedef HWND HMENUI;
typedef HMODULE HMOD;
typedef unsigned short UWORD;
typedef unsigned long HSHM;
typedef unsigned long HICN;
extern HAB dwhab;
extern HMQ dwhmq;
#include <stdio.h>
/* Mostly safe but slow snprintf() for compilers that don't have it...
* like VisualAge. So we can write safe code and still use VAC to test.
*/
#if defined(__IBMC__) && !defined(snprintf)
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
static int _dw_snprintf(char *str, size_t size, const char *format, ...)
{
va_list args;
char *outbuf = calloc(1, size + strlen(format) + 1024);
int retval = -1;
if(outbuf)
{
va_start(args, format);
vsprintf(outbuf, format, args);
va_end(args);
retval = strlen(outbuf);
strncpy(str, outbuf, size);
free(outbuf);
}
return retval;
}
#define snprintf _dw_snprintf
#endif
#endif
#if defined(__MAC__) || defined (__IOS__)
/* MacOS and iOS specific section */
#include <pthread.h>
#include <dlfcn.h>
/* Unfortunately we can't import Cocoa.h or
* UIKit.h from C code, so we have to instead
* use opaque types and use the values from
* the headers here directly without using the
* symbolic names.
*/
#define TRUE 1
#define FALSE 0
typedef void *HWND;
#ifdef __IOS__
typedef void *HTIMER;
#define HTIMER_TYPEDEFED 1
#endif
typedef void *HSHM;
typedef unsigned long ULONG;
typedef long LONG;
typedef unsigned short USHORT;
typedef short SHORT;
typedef unsigned short UWORD;
typedef short WORD ;
typedef unsigned char UCHAR;
typedef char CHAR;
typedef unsigned UINT;
typedef int INT;
typedef pthread_mutex_t *HMTX;
typedef struct _dw_unix_event {
pthread_mutex_t mutex;
pthread_cond_t event;
pthread_t thread;
int alive;
int posted;
} *HEV;
typedef pthread_t DWTID;
typedef void * HMOD;
struct _dw_unix_shm {
int fd;
char *path;
int sid;
int size;
};
typedef void *HTREEITEM;
typedef void *HMENUI;
typedef void *HICN;
typedef struct _window_data {
UserData *root;
HWND clickdefault;
ULONG flags;
void *data;
} WindowData;
typedef struct _hpixmap {
unsigned long width, height;
void *image, *font;
HWND handle;
} *HPIXMAP;
void _dw_pool_drain(void);
#define DW_DT_LEFT 0 /* NSTextAlignmentLeft */
#define DW_DT_QUERYEXTENT 0
#define DW_DT_UNDERSCORE 0
#define DW_DT_STRIKEOUT 0
#define DW_DT_TEXTATTRS 0
#define DW_DT_EXTERNALLEADING 0
#if defined(__aarch64__) || defined(__IOS__)
#define DW_DT_CENTER 1 /* NSTextAlignmentCenter */
#define DW_DT_RIGHT 2 /* NSTextAlignmentRight */
#else
#define DW_DT_CENTER 2 /* NSTextAlignmentCenter */
#define DW_DT_RIGHT 1 /* NSTextAlignmentRight */
#endif
#define DW_DT_TOP 0
#define DW_DT_VCENTER (1 << 10)
#define DW_DT_BOTTOM 0
#define DW_DT_HALFTONE 0
#define DW_DT_MNEMONIC 0
#define DW_DT_WORDBREAK (1 << 11)
#define DW_DT_ERASERECT 0
#define DW_FCF_CLOSEBUTTON (1 << 1) /* NSWindowStyleMaskClosable */
#define DW_FCF_TITLEBAR (1 << 0) /* NSWindowStyleMaskTitled */
#define DW_FCF_SYSMENU (1 << 1) /* NSWindowStyleMaskClosable */
#define DW_FCF_MENU 0
#define DW_FCF_SIZEBORDER (1 << 3) /* NSWindowStyleMaskResizable */
#define DW_FCF_MINBUTTON (1 << 2) /* NSWindowStyleMaskMiniaturizable */
#define DW_FCF_MAXBUTTON 0
#define DW_FCF_MINMAX (1 << 2) /* NSWindowStyleMaskMiniaturizable */
#define DW_FCF_DLGBORDER 0
#define DW_FCF_BORDER 0
#define DW_FCF_TASKLIST 0
#define DW_FCF_NOMOVEWITHOWNER 0
#define DW_FCF_SYSMODAL 0
#define DW_FCF_HIDEBUTTON 0
#define DW_FCF_HIDEMAX 0
#define DW_FCF_AUTOICON 0
#define DW_FCF_MAXIMIZE 0
#define DW_FCF_MINIMIZE 0
#define DW_FCF_TEXTURED (1 << 8) /* NSWindowStyleMaskTexturedBackground */
#define DW_FCF_FULLSCREEN (1 << 4)
#define DW_CFA_BITMAPORICON 1
#define DW_CFA_STRING (1 << 1)
#define DW_CFA_ULONG (1 << 2)
#define DW_CFA_TIME (1 << 3)
#define DW_CFA_DATE (1 << 4)
#define DW_CFA_CENTER (1 << 5)
#define DW_CFA_LEFT (1 << 6)
#define DW_CFA_RIGHT (1 << 7)
#define DW_CFA_STRINGANDICON (1 << 8)
#define DW_CFA_HORZSEPARATOR 0
#define DW_CFA_SEPARATOR 0
#define DW_CRA_SELECTED 1
#define DW_CRA_CURSORED (1 << 1)
#define DW_CR_RETDATA (1 << 10)
#define DW_LS_MULTIPLESEL 1
#define DW_LIT_NONE -1
#define DW_MLE_CASESENSITIVE 2 /* NSLiteralSearch */
#define DW_BS_NOBORDER 1
#define DW_POINTER_DEFAULT 0
#define DW_POINTER_ARROW 1
#define DW_POINTER_CLOCK 2
#define DW_POINTER_QUESTION 3
#define HWND_DESKTOP ((HWND)0)
/* flag values for dw_messagebox() */
#define DW_MB_OK (1 << 1)
#define DW_MB_OKCANCEL (1 << 2)
#define DW_MB_YESNO (1 << 3)
#define DW_MB_YESNOCANCEL (1 << 4)
#define DW_MB_WARNING (1 << 10)
#define DW_MB_ERROR (1 << 11)
#define DW_MB_INFORMATION (1 << 12)
#define DW_MB_QUESTION (1 << 13)
/* Virtual Key Codes */
#define VK_LBUTTON 0xFF10 /* TODO */
#define VK_RBUTTON 0xFF11 /* TODO */
#define VK_CANCEL 0xFF12 /* TODO */
#define VK_MBUTTON 0xFF13 /* TODO */
#define VK_BACK 0x7F
#define VK_TAB 0x09
#define VK_CLEAR 71
#define VK_RETURN 13
#define VK_MENU 0xF735 /* NSMenuFunctionKey */
#define VK_PAUSE 0xF730 /* NSPauseFunctionKey */
#define VK_CAPITAL 57
#define VK_ESCAPE 0x1B
#define VK_SPACE ' '
#define VK_PRIOR 0xF72C /* NSPageUpFunctionKey */
#define VK_NEXT 0xF72D /* NSPageDownFunctionKey */
#define VK_END 0xF72B /* NSEndFunctionKey */
#define VK_HOME 0xF729 /* NSHomeFunctionKey */
#define VK_LEFT 0xF702 /* NSLeftArrowFunctionKey */
#define VK_UP 0xF700 /* NSUpArrowFunctionKey */
#define VK_RIGHT 0xF703 /* NSRightArrowFunctionKey */
#define VK_DOWN 0xF701 /* NSDownArrowFunctionKey */
#define VK_SELECT 0xF741 /* NSSelectFunctionKey */
#define VK_PRINT 0xF738 /* NSPrintFunctionKey */
#define VK_EXECUTE 0xF742 /* NSExecuteFunctionKey */
#define VK_SNAPSHOT 0xF72E /* NSPrintScreenFunctionKey */
#define VK_INSERT 0xF727 /* NSInsertFunctionKey */
#define VK_DELETE 0xF728 /* NSDeleteFunctionKey */
#define VK_HELP 0xF746 /* NSHelpFunctionKey */
#define VK_LWIN 55
#define VK_RWIN 0xFF14 /* TODO */
#define VK_NUMPAD0 82
#define VK_NUMPAD1 83
#define VK_NUMPAD2 84
#define VK_NUMPAD3 85
#define VK_NUMPAD4 86
#define VK_NUMPAD5 87
#define VK_NUMPAD6 88
#define VK_NUMPAD7 89
#define VK_NUMPAD8 91
#define VK_NUMPAD9 92
#define VK_MULTIPLY 67
#define VK_ADD 69
#define VK_SEPARATOR 0xFF15 /* TODO */
#define VK_SUBTRACT 78
#define VK_DECIMAL 65
#define VK_DIVIDE 75
#define VK_F1 0xF704 /* NSF1FunctionKey */
#define VK_F2 0xF705 /* NSF2FunctionKey */
#define VK_F3 0xF706 /* NSF3FunctionKey */
#define VK_F4 0xF707 /* NSF4FunctionKey */
#define VK_F5 0xF708 /* NSF5FunctionKey */
#define VK_F6 0xF709 /* NSF6FunctionKey */
#define VK_F7 0xF70A /* NSF7FunctionKey */
#define VK_F8 0xF70B /* NSF8FunctionKey */
#define VK_F9 0xF70C /* NSF9FunctionKey */
#define VK_F10 0xF70D /* NSF10FunctionKey */
#define VK_F11 0xF70E /* NSF11FunctionKey */
#define VK_F12 0xF70F /* NSF12FunctionKey */
#define VK_F13 0xF710 /* NSF13FunctionKey */
#define VK_F14 0xF711 /* NSF14FunctionKey */
#define VK_F15 0xF712 /* NSF15FunctionKey */
#define VK_F16 0xF713 /* NSF16FunctionKey */
#define VK_F17 0xF714 /* NSF17FunctionKey */
#define VK_F18 0xF715 /* NSF18FunctionKey */
#define VK_F19 0xF716 /* NSF19FunctionKey */
#define VK_F20 0xF717 /* NSF20FunctionKey */
#define VK_F21 0xF718 /* NSF21FunctionKey */
#define VK_F22 0xF719 /* NSF22FunctionKey */
#define VK_F23 0xF71A /* NSF23FunctionKey */
#define VK_F24 0xF71B /* NSF24FunctionKey */
#define VK_NUMLOCK 0xFF16 /* TODO */
#define VK_SCROLL 0xF72F /* NSScrollLockFunctionKey */
#define VK_LSHIFT 56
#define VK_RSHIFT 60
#define VK_LCONTROL 59
#define VK_RCONTROL 62
#define VK_LMENU 0xF735 /* NSMenuFunctionKey */
#define VK_RMENU 0xF735 /* NSMenuFunctionKey */
/* Key Modifiers */
#define KC_CTRL (1 << 18) /* NSControlKeyMask */
#define KC_SHIFT (1 << 17) /* NSShiftKeyMask */
#define KC_ALT (1 << 19) /* NSAlternateKeyMask */
#endif
/* Windows specific section */
#if defined(__WIN32__)
#include <winsock2.h>
#include <windows.h>
#include <commctrl.h>
#if defined(MSVC) && !defined(API)
# if defined(__MINGW32__) && defined(BUILD_DLL)
# define API __cdecl __declspec(dllexport)
# else
# define API __cdecl
#endif
#define DWSIGNAL __cdecl
#endif
#define DW_DT_LEFT SS_LEFTNOWORDWRAP
#define DW_DT_QUERYEXTENT 0
#define DW_DT_UNDERSCORE 0
#define DW_DT_STRIKEOUT 0
#define DW_DT_TEXTATTRS 0
#define DW_DT_EXTERNALLEADING 0
#define DW_DT_CENTER SS_CENTER
#define DW_DT_RIGHT SS_RIGHT
#define DW_DT_TOP 0
#define DW_DT_VCENTER (1 << 29)
#define DW_DT_BOTTOM 0
#define DW_DT_HALFTONE 0
#define DW_DT_MNEMONIC 0
#define DW_DT_WORDBREAK (1 << 28)
#define DW_DT_ERASERECT 0
#define DW_FCF_CLOSEBUTTON 0
#define DW_FCF_TITLEBAR WS_CAPTION
#define DW_FCF_SYSMENU WS_SYSMENU
#define DW_FCF_MENU 0
#define DW_FCF_SIZEBORDER WS_THICKFRAME
#define DW_FCF_MINBUTTON WS_MINIMIZEBOX
#define DW_FCF_MAXBUTTON WS_MAXIMIZEBOX
#define DW_FCF_MINMAX (WS_MINIMIZEBOX|WS_MAXIMIZEBOX)
#define DW_FCF_DLGBORDER WS_DLGFRAME
#define DW_FCF_BORDER WS_BORDER
#define DW_FCF_TASKLIST (1 << 1)
#define DW_FCF_NOMOVEWITHOWNER 0
#define DW_FCF_SYSMODAL 0
#define DW_FCF_HIDEBUTTON WS_MINIMIZEBOX
#define DW_FCF_HIDEMAX (WS_MINIMIZEBOX|WS_MAXIMIZEBOX)
#define DW_FCF_AUTOICON 0
#define DW_FCF_MAXIMIZE WS_MAXIMIZE
#define DW_FCF_MINIMIZE WS_MINIMIZE
#define DW_FCF_COMPOSITED 1
#define DW_FCF_TEXTURED 0
#define DW_FCF_FULLSCREEN (1 << 2)
#define DW_CFA_BITMAPORICON 1
#define DW_CFA_STRING (1 << 1)
#define DW_CFA_ULONG (1 << 2)
#define DW_CFA_TIME (1 << 3)
#define DW_CFA_DATE (1 << 4)
#define DW_CFA_CENTER (1 << 5)
#define DW_CFA_LEFT (1 << 6)
#define DW_CFA_RIGHT (1 << 7)
#define DW_CFA_STRINGANDICON (1 << 8)
#define DW_CFA_HORZSEPARATOR 0
#define DW_CFA_SEPARATOR 0
#define DW_CRA_SELECTED LVNI_SELECTED
#define DW_CRA_CURSORED LVNI_FOCUSED
#define DW_CR_RETDATA (1 << 10)
#define DW_LS_MULTIPLESEL LBS_MULTIPLESEL
#define DW_LIT_NONE -1
#define DW_MLE_CASESENSITIVE 1
#define DW_BS_NOBORDER BS_FLAT
#define DW_POINTER_DEFAULT 0
#define DW_POINTER_ARROW 32512
#define DW_POINTER_CLOCK 32514
#define DW_POINTER_QUESTION 32651
/* flag values for dw_messagebox() */
#define DW_MB_OK MB_OK
#define DW_MB_OKCANCEL MB_OKCANCEL
#define DW_MB_YESNO MB_YESNO
#define DW_MB_YESNOCANCEL MB_YESNOCANCEL
#define DW_MB_WARNING MB_ICONWARNING
#define DW_MB_ERROR MB_ICONERROR
#define DW_MB_INFORMATION MB_ICONINFORMATION
#define DW_MB_QUESTION MB_ICONQUESTION
/* Key Modifiers */
#define KC_CTRL (1)
#define KC_SHIFT (1 << 1)
#define KC_ALT (1 << 2)
typedef struct _color {
int fore;
int back;
HWND combo, buddy;
ULONG style;
RECT rect;
HWND clickdefault;
HBRUSH hbrush;
HFONT hfont;
HMENU hmenu;
char fontname[128];
WNDPROC pOldProc;
UserData *root;
} ColorInfo;
typedef struct _notebookpage {
ColorInfo cinfo;
TC_ITEM item;
HWND hwnd;
int realid;
} NotebookPage;
typedef HANDLE HMTX;
typedef HANDLE HEV;
typedef HANDLE HMOD;
typedef HANDLE HSHM;
typedef HANDLE HICN;
typedef struct _container {
ColorInfo cinfo;
ULONG *flags;
ULONG columns;
COLORREF odd, even;
} ContainerInfo;
typedef struct _hpixmap {
unsigned long width, height;
HBITMAP hbm;
HDC hdc;
unsigned long transcolor;
HWND handle;
void *bits;
unsigned long depth;
HFONT font;
} *HPIXMAP;
typedef HWND HMENUI;
#endif
/* Android section */
#if defined(__ANDROID__)
#include <jni.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <limits.h>
#include <pthread.h>
/* Can remove this for your port when you know where MAX_PATH is */
#ifndef MAX_PATH
#define MAX_PATH 260
#endif
#define TRUE 1
#define FALSE 0
typedef jobject HWND;
typedef jobject HTIMER;
#define HTIMER_TYPEDEFED 1
typedef unsigned long ULONG;
typedef long LONG;
typedef unsigned short USHORT;
typedef short SHORT;
typedef unsigned short UWORD;
typedef short WORD ;
typedef unsigned char UCHAR;
typedef char CHAR;
typedef unsigned UINT;
typedef int INT;
typedef pthread_mutex_t *HMTX;
typedef struct _dw_unix_event {
pthread_mutex_t mutex;
pthread_cond_t event;
pthread_t thread;
int alive;
int posted;
} *HEV;
typedef pthread_t DWTID;
typedef void * HMOD;
struct _dw_unix_shm {
int fd;
char *path;
int sid;
int size;
};
typedef void *HSHM;
typedef jobject HTREEITEM;
typedef HWND HMENUI;
typedef jobject HICN;
typedef struct _window_data {
UserData *root;
HWND clickdefault;
ULONG flags;
void *data;
} WindowData;
typedef struct _hpixmap {
unsigned long width, height;
jobject bitmap;
jobject typeface;
int fontsize;
HWND handle;
} *HPIXMAP;
#define DW_DT_LEFT 3 /* Gravity.LEFT */
#define DW_DT_QUERYEXTENT 0
#define DW_DT_UNDERSCORE 0
#define DW_DT_STRIKEOUT 0
#define DW_DT_TEXTATTRS 0
#define DW_DT_EXTERNALLEADING 0
#define DW_DT_CENTER 1 /* Gravity.CENTER_HORIZONTAL */
#define DW_DT_RIGHT 5 /* Gravity.RIGHT */
#define DW_DT_TOP 48 /* Gravity.TOP */
#define DW_DT_VCENTER 16 /* Gravity.CENTER_VERTICAL */
#define DW_DT_BOTTOM 80 /* Gravity.BOTTOM */
#define DW_DT_HALFTONE 0
#define DW_DT_MNEMONIC 0
#define DW_DT_WORDBREAK 0
#define DW_DT_ERASERECT 0
#define DW_FCF_CLOSEBUTTON 1
#define DW_FCF_TITLEBAR (1 << 1)
#define DW_FCF_SYSMENU DW_FCF_CLOSEBUTTON
#define DW_FCF_MENU 0
#define DW_FCF_SIZEBORDER 0
#define DW_FCF_MINBUTTON 0
#define DW_FCF_MAXBUTTON 0
#define DW_FCF_MINMAX (DW_FCF_MINBUTTON|DW_FCF_MAXBUTTON)
#define DW_FCF_DLGBORDER 0
#define DW_FCF_BORDER 0
#define DW_FCF_TASKLIST 0
#define DW_FCF_NOMOVEWITHOWNER 0
#define DW_FCF_SYSMODAL 0
#define DW_FCF_HIDEBUTTON 0
#define DW_FCF_HIDEMAX 0
#define DW_FCF_AUTOICON 0
#define DW_FCF_MAXIMIZE 0
#define DW_FCF_MINIMIZE 0
#define DW_FCF_TEXTURED 0
#define DW_FCF_FULLSCREEN 0
#define DW_CFA_BITMAPORICON 1
#define DW_CFA_STRING (1 << 1)
#define DW_CFA_ULONG (1 << 2)
#define DW_CFA_TIME (1 << 3)
#define DW_CFA_DATE (1 << 4)
#define DW_CFA_CENTER (1 << 5)
#define DW_CFA_LEFT (1 << 6)
#define DW_CFA_RIGHT (1 << 7)
#define DW_CFA_STRINGANDICON (1 << 8)
#define DW_CFA_HORZSEPARATOR 0
#define DW_CFA_SEPARATOR 0
#define DW_CRA_SELECTED 1
#define DW_CRA_CURSORED (1 << 1)
#define DW_CR_RETDATA (1 << 10)
#define DW_LS_MULTIPLESEL 1
#define DW_LIT_NONE -1
#define DW_MLE_CASESENSITIVE 1
#define DW_BS_NOBORDER 1
#define DW_POINTER_DEFAULT 0
#define DW_POINTER_ARROW 0
#define DW_POINTER_CLOCK 0
#define DW_POINTER_QUESTION 0
#define HWND_DESKTOP ((HWND)0)
/* flag values for dw_messagebox() */
#define DW_MB_OK (1 << 1)
#define DW_MB_OKCANCEL (1 << 2)
#define DW_MB_YESNO (1 << 3)
#define DW_MB_YESNOCANCEL (1 << 4)
#define DW_MB_WARNING (1 << 10)
#define DW_MB_ERROR (1 << 11)
#define DW_MB_INFORMATION (1 << 12)
#define DW_MB_QUESTION (1 << 13)
/* Virtual Key Codes */
#define VK_LBUTTON 1000
#define VK_RBUTTON 1001
#define VK_CANCEL 1002
#define VK_MBUTTON 1003
#define VK_BACK 4 /* KeyEvent.KEYCODE_BACK */
#define VK_TAB 61 /* KeyEvent.KEYCODE_TAB */
#define VK_CLEAR 28 /* KeyEvent.KEYCODE_CLEAR */
#define VK_RETURN 66 /* KeyEvent.KEYCODE_ENTER */
#define VK_MENU 82 /* KeyEvent.KEYCODE_MENU */
#define VK_PAUSE 121 /* KeyEvent.KEYCODE_BREAK */
#define VK_CAPITAL 115 /* KeyEvent.KEYCODE_CAPS_LOCK */
#define VK_ESCAPE 111 /* KeyEvent.KEYCODE_ESCAPE */
#define VK_SPACE 62 /* KeyEvent.KEYCODE_SPACE */
#define VK_PRIOR 92 /* KeyEvent.KEYCODE_PAGE_UP */
#define VK_NEXT 93 /* KeyEvent.KEYCODE_PAGE_DOWN */
#define VK_END 123 /* KeyEvent.KEYCODE_MOVE_END */
#define VK_HOME 122 /* KeyEvent.KEYCODE_MOVE_HOME */
#define VK_LEFT 21 /* KeyEvent.KEYCODE_DPAD_LEFT */
#define VK_UP 19 /* KeyEvent.KEYCODE_DPAD_UP */
#define VK_RIGHT 22 /* KeyEvent.KEYCODE_DPAD_RIGHT */
#define VK_DOWN 20 /* KeyEvent.KEYCODE_DPAD_DOWN */
#define VK_SELECT 1004
#define VK_PRINT 1005
#define VK_EXECUTE 1006
#define VK_SNAPSHOT 120 /* KeyEvent.KEYCODE_SYSRQ */
#define VK_INSERT 124 /* KeyEvent.KEYCODE_INSERT */
#define VK_DELETE 67 /* KeyEvent.KEYCODE_DEL */
#define VK_HELP 259 /* KeyEvent.KEYCODE_HELP */
#define VK_LWIN 1007
#define VK_RWIN 1008
#define VK_NUMPAD0 7 /* KeyEvent.KEYCODE_0 */
#define VK_NUMPAD1 8 /* KeyEvent.KEYCODE_1 */
#define VK_NUMPAD2 9 /* KeyEvent.KEYCODE_2 */
#define VK_NUMPAD3 10 /* KeyEvent.KEYCODE_3 */
#define VK_NUMPAD4 11 /* KeyEvent.KEYCODE_4 */
#define VK_NUMPAD5 12 /* KeyEvent.KEYCODE_5 */
#define VK_NUMPAD6 13 /* KeyEvent.KEYCODE_6 */
#define VK_NUMPAD7 14 /* KeyEvent.KEYCODE_7 */
#define VK_NUMPAD8 15 /* KeyEvent.KEYCODE_8 */
#define VK_NUMPAD9 16 /* KeyEvent.KEYCODE_9 */
#define VK_MULTIPLY 155 /* KeyEvent.KEYCODE_NUMPAD_MULTIPLY */
#define VK_ADD 157 /* KeyEvent.KEYCODE_NUMPAD_ADD */
#define VK_SEPARATOR 1009
#define VK_SUBTRACT 156 /* KeyEvent.KEYCODE_NUMPAD_SUBTRACT */
#define VK_DECIMAL 158 /* KeyEvent.KEYCODE_NUMPAD_DOT */
#define VK_DIVIDE 154 /* KeyEvent.KEYCODE_NUMPAD_DIVIDE */
#define VK_F1 131 /* KeyEvent.KEYCODE_F1 */
#define VK_F2 132 /* KeyEvent.KEYCODE_F2 */
#define VK_F3 133 /* KeyEvent.KEYCODE_F3 */
#define VK_F4 134 /* KeyEvent.KEYCODE_F4 */
#define VK_F5 135 /* KeyEvent.KEYCODE_F5 */
#define VK_F6 136 /* KeyEvent.KEYCODE_F6 */
#define VK_F7 137 /* KeyEvent.KEYCODE_F7 */
#define VK_F8 138 /* KeyEvent.KEYCODE_F8 */
#define VK_F9 139 /* KeyEvent.KEYCODE_F9 */
#define VK_F10 140 /* KeyEvent.KEYCODE_F10 */
#define VK_F11 141 /* KeyEvent.KEYCODE_F11 */
#define VK_F12 142 /* KeyEvent.KEYCODE_F12 */
#define VK_F13 1010
#define VK_F14 1011
#define VK_F15 1012
#define VK_F16 1014
#define VK_F17 1015
#define VK_F18 1016
#define VK_F19 1017
#define VK_F20 1018
#define VK_F21 1019
#define VK_F22 1020
#define VK_F23 1021
#define VK_F24 1022
#define VK_NUMLOCK 143 /* KeyEvent.KEYCODE_NUMLOCK */
#define VK_SCROLL 116 /* KeyEvent.KEYCODE_SCROLL_LOCK */
#define VK_LSHIFT 59 /* KeyEvent.KEYCODE_SHIFT_LEFT */
#define VK_RSHIFT 60 /* KeyEvent.KEYCODE_SHIFT_RIGHT */
#define VK_LCONTROL 113 /* KeyEvent.KEYCODE_CTRL_LEFT */
#define VK_RCONTROL 114 /* KeyEvent.KEYCODE_CTRL_RIGHT */
#define VK_LMENU 117 /* KeyEvent.KEYCODE_META_LEFT */
#define VK_RMENU 118 /* KeyEvent.KEYCODE_META_RIGHT */
/* Key Modifiers */
#define KC_CTRL 28672 /* KeyEvent.META_CTRL_MASK */
#define KC_SHIFT 193 /* KeyEvent.META_SHIFT_MASK */
#define KC_ALT 458752 /* KeyEvent.META_META_MASK */
#endif
/* Template section, framework for new platform ports */
#if defined(__TEMPLATE__)
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <limits.h>
/* Can remove this for your port when you know where MAX_PATH is */
#ifndef MAX_PATH
#define MAX_PATH 260
#endif
#define TRUE 1
#define FALSE 0
typedef void *HWND;
typedef unsigned long ULONG;
typedef long LONG;
typedef unsigned short USHORT;
typedef short SHORT;
typedef unsigned short UWORD;
typedef short WORD ;
typedef unsigned char UCHAR;
typedef char CHAR;
typedef unsigned UINT;
typedef int INT;
typedef void *HMTX;
typedef void *HEV;
typedef void *HSHM;
typedef void *HMOD;
typedef void *HTREEITEM;