-
Notifications
You must be signed in to change notification settings - Fork 0
/
iup.lua
1737 lines (1365 loc) · 45.9 KB
/
iup.lua
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
-----------------------------------------------------------
-- Binding for IUP v3.12.0
-----------------------------------------------------------
local ffi = require 'ffi'
local jit = require 'jit'
local const = {}
const.name = 'IUP - Portable User Interface'
const.copyright = 'Copyright (C) 1994-2014 Tecgraf, PUC-Rio.'
const.description = 'Multi-platform toolkit for building graphical user interfaces.'
const.version = '3.12'
const.version_number = 312000
const.version_date = '2014/11/19'
const.error = 1
const.noerror = 0
const.opened = -1
const.invalid = -1
const.invalid_id = -10
const.ignore = -1
const.default = -2
const.close = -3
const.continue = -4
const.center = 0xFFFF
const.left = 0xFFFE
const.right = 0xFFFD
const.mousepos = 0xFFFC
const.current = 0xFFFB
const.centerparent = 0xFFFA
const.top = const.left
const.bottom = const.right
-- enum{IUP_SHOW, IUP_RESTORE, IUP_MINIMIZE, IUP_MAXIMIZE, IUP_HIDE};
-- enum{IUP_SBUP, IUP_SBDN, IUP_SBPGUP, IUP_SBPGDN, IUP_SBPOSV, IUP_SBDRAGV,
-- IUP_SBLEFT, IUP_SBRIGHT, IUP_SBPGLEFT, IUP_SBPGRIGHT, IUP_SBPOSH, IUP_SBDRAGH};
const.button1 = '1'
const.button2 = '2'
const.button3 = '3'
const.button4 = '4'
const.button5 = '5'
const.mask_float = '[+/-]?(/d+/.?/d*|/./d+)'
const.mask_ufloat = '(/d+/.?/d*|/./d+)'
const.mask_efloat = '[+/-]?(/d+/.?/d*|/./d+)([eE][+/-]?/d+)?'
const.mask_int = '[+/-]?/d+'
const.mask_uint = '/d+'
const.getparam_ok = -1
const.getparam_init = -2
const.getparam_cancel = -3
const.getparam_help = -4
local function get_const(value)
if type(value) == 'string' then
if const[value] then
return const[value]
else
error('unknown const name', 3)
end
end
return value
end
local header = [[
typedef struct Ihandle_ Ihandle;
typedef int (*Icallback)(Ihandle*);
typedef int (*Iparamcb)(Ihandle* dialog, int param_index, void* user_data);
int IupOpen (int *argc, char ***argv);
void IupClose (void);
void IupImageLibOpen (void);
int IupMainLoop (void);
int IupLoopStep (void);
int IupLoopStepWait (void);
int IupMainLoopLevel (void);
void IupFlush (void);
void IupExitLoop (void);
int IupRecordInput(const char* filename, int mode);
int IupPlayInput(const char* filename);
void IupUpdate (Ihandle* ih);
void IupUpdateChildren(Ihandle* ih);
void IupRedraw (Ihandle* ih, int children);
void IupRefresh (Ihandle* ih);
void IupRefreshChildren(Ihandle* ih);
int IupHelp (const char* url);
char* IupLoad (const char *filename);
char* IupLoadBuffer (const char *buffer);
char* IupVersion (void);
char* IupVersionDate (void);
int IupVersionNumber (void);
void IupSetLanguage (const char *lng);
char* IupGetLanguage (void);
void IupSetLanguageString(const char* name, const char* str);
void IupStoreLanguageString(const char* name, const char* str);
char* IupGetLanguageString(const char* name);
void IupSetLanguagePack(Ihandle* ih);
void IupDestroy (Ihandle* ih);
void IupDetach (Ihandle* child);
Ihandle* IupAppend (Ihandle* ih, Ihandle* child);
Ihandle* IupInsert (Ihandle* ih, Ihandle* ref_child, Ihandle* child);
Ihandle* IupGetChild (Ihandle* ih, int pos);
int IupGetChildPos (Ihandle* ih, Ihandle* child);
int IupGetChildCount(Ihandle* ih);
Ihandle* IupGetNextChild (Ihandle* ih, Ihandle* child);
Ihandle* IupGetBrother (Ihandle* ih);
Ihandle* IupGetParent (Ihandle* ih);
Ihandle* IupGetDialog (Ihandle* ih);
Ihandle* IupGetDialogChild(Ihandle* ih, const char* name);
int IupReparent (Ihandle* ih, Ihandle* new_parent, Ihandle* ref_child);
int IupPopup (Ihandle* ih, int x, int y);
int IupShow (Ihandle* ih);
int IupShowXY (Ihandle* ih, int x, int y);
int IupHide (Ihandle* ih);
int IupMap (Ihandle* ih);
void IupUnmap (Ihandle *ih);
void IupResetAttribute(Ihandle *ih, const char* name);
int IupGetAllAttributes(Ihandle* ih, char** names, int n);
Ihandle* IupSetAtt(const char* handle_name, Ihandle* ih, const char* name, ...);
Ihandle* IupSetAttributes (Ihandle* ih, const char *str);
char* IupGetAttributes (Ihandle* ih);
void IupSetAttribute (Ihandle* ih, const char* name, const char* value);
void IupSetStrAttribute(Ihandle* ih, const char* name, const char* value);
void IupSetStrf (Ihandle* ih, const char* name, const char* format, ...);
void IupSetInt (Ihandle* ih, const char* name, int value);
void IupSetFloat (Ihandle* ih, const char* name, float value);
void IupSetDouble (Ihandle* ih, const char* name, double value);
void IupSetRGB (Ihandle *ih, const char* name, unsigned char r, unsigned char g, unsigned char b);
char* IupGetAttribute(Ihandle* ih, const char* name);
int IupGetInt (Ihandle* ih, const char* name);
int IupGetInt2 (Ihandle* ih, const char* name);
int IupGetIntInt (Ihandle *ih, const char* name, int *i1, int *i2);
float IupGetFloat (Ihandle* ih, const char* name);
double IupGetDouble(Ihandle* ih, const char* name);
void IupGetRGB (Ihandle *ih, const char* name, unsigned char *r, unsigned char *g, unsigned char *b);
void IupSetAttributeId(Ihandle *ih, const char* name, int id, const char *value);
void IupSetStrAttributeId(Ihandle *ih, const char* name, int id, const char *value);
void IupSetStrfId(Ihandle *ih, const char* name, int id, const char* format, ...);
void IupSetIntId(Ihandle* ih, const char* name, int id, int value);
void IupSetFloatId(Ihandle* ih, const char* name, int id, float value);
void IupSetDoubleId(Ihandle* ih, const char* name, int id, double value);
void IupSetRGBId(Ihandle *ih, const char* name, int id, unsigned char r, unsigned char g, unsigned char b);
char* IupGetAttributeId(Ihandle *ih, const char* name, int id);
int IupGetIntId(Ihandle *ih, const char* name, int id);
float IupGetFloatId(Ihandle *ih, const char* name, int id);
double IupGetDoubleId(Ihandle *ih, const char* name, int id);
void IupGetRGBId(Ihandle *ih, const char* name, int id, unsigned char *r, unsigned char *g, unsigned char *b);
void IupSetAttributeId2(Ihandle* ih, const char* name, int lin, int col, const char* value);
void IupSetStrAttributeId2(Ihandle* ih, const char* name, int lin, int col, const char* value);
void IupSetStrfId2(Ihandle* ih, const char* name, int lin, int col, const char* format, ...);
void IupSetIntId2(Ihandle* ih, const char* name, int lin, int col, int value);
void IupSetFloatId2(Ihandle* ih, const char* name, int lin, int col, float value);
void IupSetDoubleId2(Ihandle* ih, const char* name, int lin, int col, double value);
void IupSetRGBId2(Ihandle *ih, const char* name, int lin, int col, unsigned char r, unsigned char g, unsigned char b);
char* IupGetAttributeId2(Ihandle* ih, const char* name, int lin, int col);
int IupGetIntId2(Ihandle* ih, const char* name, int lin, int col);
float IupGetFloatId2(Ihandle* ih, const char* name, int lin, int col);
double IupGetDoubleId2(Ihandle* ih, const char* name, int lin, int col);
void IupGetRGBId2(Ihandle *ih, const char* name, int lin, int col, unsigned char *r, unsigned char *g, unsigned char *b);
void IupSetGlobal (const char* name, const char* value);
void IupSetStrGlobal(const char* name, const char* value);
char* IupGetGlobal (const char* name);
Ihandle* IupSetFocus (Ihandle* ih);
Ihandle* IupGetFocus (void);
Ihandle* IupPreviousField(Ihandle* ih);
Ihandle* IupNextField (Ihandle* ih);
Icallback IupGetCallback (Ihandle* ih, const char *name);
Icallback IupSetCallback (Ihandle* ih, const char *name, Icallback func);
Ihandle* IupSetCallbacks(Ihandle* ih, const char *name, Icallback func, ...);
Icallback IupGetFunction(const char *name);
Icallback IupSetFunction(const char *name, Icallback func);
Ihandle* IupGetHandle (const char *name);
Ihandle* IupSetHandle (const char *name, Ihandle* ih);
int IupGetAllNames (char** names, int n);
int IupGetAllDialogs(char** names, int n);
char* IupGetName (Ihandle* ih);
void IupSetAttributeHandle(Ihandle* ih, const char* name, Ihandle* ih_named);
Ihandle* IupGetAttributeHandle(Ihandle* ih, const char* name);
char* IupGetClassName(Ihandle* ih);
char* IupGetClassType(Ihandle* ih);
int IupGetAllClasses(char** names, int n);
int IupGetClassAttributes(const char* classname, char** names, int n);
int IupGetClassCallbacks(const char* classname, char** names, int n);
void IupSaveClassAttributes(Ihandle* ih);
void IupCopyClassAttributes(Ihandle* src_ih, Ihandle* dst_ih);
void IupSetClassDefaultAttribute(const char* classname, const char *name, const char* value);
int IupClassMatch(Ihandle* ih, const char* classname);
Ihandle* IupCreate (const char *classname);
Ihandle* IupCreatev(const char *classname, void* *params);
Ihandle* IupCreatep(const char *classname, void *first, ...);
/************************************************************************/
/* Elements */
/************************************************************************/
Ihandle* IupFill (void);
Ihandle* IupRadio (Ihandle* child);
Ihandle* IupVbox (Ihandle* child, ...);
Ihandle* IupVboxv (Ihandle* *children);
Ihandle* IupZbox (Ihandle* child, ...);
Ihandle* IupZboxv (Ihandle* *children);
Ihandle* IupHbox (Ihandle* child,...);
Ihandle* IupHboxv (Ihandle* *children);
Ihandle* IupNormalizer (Ihandle* ih_first, ...);
Ihandle* IupNormalizerv(Ihandle* *ih_list);
Ihandle* IupCbox (Ihandle* child, ...);
Ihandle* IupCboxv (Ihandle* *children);
Ihandle* IupSbox (Ihandle *child);
Ihandle* IupSplit (Ihandle* child1, Ihandle* child2);
Ihandle* IupScrollBox (Ihandle* child);
Ihandle* IupGridBox (Ihandle* child, ...);
Ihandle* IupGridBoxv (Ihandle **children);
Ihandle* IupExpander (Ihandle *child);
Ihandle* IupDetachBox (Ihandle *child);
Ihandle* IupBackgroundBox(Ihandle *child);
Ihandle* IupFrame (Ihandle* child);
Ihandle* IupImage (int width, int height, const unsigned char *pixmap);
Ihandle* IupImageRGB (int width, int height, const unsigned char *pixmap);
Ihandle* IupImageRGBA (int width, int height, const unsigned char *pixmap);
Ihandle* IupItem (const char* title, const char* action);
Ihandle* IupSubmenu (const char* title, Ihandle* child);
Ihandle* IupSeparator (void);
Ihandle* IupMenu (Ihandle* child,...);
Ihandle* IupMenuv (Ihandle* *children);
Ihandle* IupButton (const char* title, const char* action);
Ihandle* IupCanvas (const char* action);
Ihandle* IupDialog (Ihandle* child);
Ihandle* IupUser (void);
Ihandle* IupLabel (const char* title);
Ihandle* IupList (const char* action);
Ihandle* IupText (const char* action);
Ihandle* IupMultiLine (const char* action);
Ihandle* IupToggle (const char* title, const char* action);
Ihandle* IupTimer (void);
Ihandle* IupClipboard (void);
Ihandle* IupProgressBar(void);
Ihandle* IupVal (const char *type);
Ihandle* IupTabs (Ihandle* child, ...);
Ihandle* IupTabsv (Ihandle* *children);
Ihandle* IupTree (void);
Ihandle* IupLink (const char* url, const char* title);
/************************************************************************/
/* Utilities */
/************************************************************************/
/* IupImage utility */
int IupSaveImageAsText(Ihandle* ih, const char* file_name, const char* format, const char* name);
/* IupText and IupScintilla utilities */
void IupTextConvertLinColToPos(Ihandle* ih, int lin, int col, int *pos);
void IupTextConvertPosToLinCol(Ihandle* ih, int pos, int *lin, int *col);
/* IupText, IupList, IupTree, IupMatrix and IupScintilla utility */
int IupConvertXYToPos(Ihandle* ih, int x, int y);
/* IupTree utilities */
int IupTreeSetUserId(Ihandle* ih, int id, void* userid);
void* IupTreeGetUserId(Ihandle* ih, int id);
int IupTreeGetId(Ihandle* ih, void *userid);
void IupTreeSetAttributeHandle(Ihandle* ih, const char* name, int id, Ihandle* ih_named);
/************************************************************************/
/* Pre-definided dialogs */
/************************************************************************/
Ihandle* IupFileDlg(void);
Ihandle* IupMessageDlg(void);
Ihandle* IupColorDlg(void);
Ihandle* IupFontDlg(void);
Ihandle* IupProgressDlg(void);
int IupGetFile(char *arq);
void IupMessage(const char *title, const char *msg);
void IupMessagef(const char *title, const char *format, ...);
int IupAlarm(const char *title, const char *msg, const char *b1, const char *b2, const char *b3);
int IupScanf(const char *format, ...);
int IupListDialog(int type, const char *title, int size, const char** list,
int op, int max_col, int max_lin, int* marks);
int IupGetText(const char* title, char* text);
int IupGetColor(int x, int y, unsigned char* r, unsigned char* g, unsigned char* b);
int IupGetParam(const char* title, Iparamcb action, void* user_data, const char* format,...);
int IupGetParamv(const char* title, Iparamcb action, void* user_data, const char* format, int param_count, int param_extra, void** param_data);
Ihandle* IupLayoutDialog(Ihandle* dialog);
Ihandle* IupElementPropertiesDialog(Ihandle* elem);
]]
local bind = {}
local help = {}
local mod = {}
function mod.open()
-- skip argc and argv
return bind.IupOpen(nil, nil)
end
function mod.close()
bind.IupClose()
end
function mod.image_lib_open()
bind.IupImageLibOpen()
end
function mod.main_loop()
return bind.IupMainLoop()
end
function mod.loop_step()
return bind.IupLoopStep()
end
function mod.loop_step_wait()
return bind.IupLoopStepWait()
end
function mod.main_loop_level()
return bind.IupMainLoopLevel()
end
function mod.flush()
bind.IupFlush()
end
function mod.exit_loop()
bind.IupExitLoop()
end
function mod.record_input(filename, mode)
return bind.IupRecordInput(filename, mode)
end
function mod.play_input(filename)
return bind.IupPlayInput(filename)
end
function mod.update(ih)
bind.IupUpdate(ih)
end
function mod.update_children(ih)
bind.IupUpdateChildren(ih)
end
function mod.redraw(ih, children)
bind.IupRedraw(ih, children)
end
function mod.refresh(ih)
bind.IupRefresh(ih)
end
function mod.refresh_children(ih)
bind.IupRefreshChildren(ih)
end
function mod.help(url)
return bind.IupHelp(url)
end
function mod.load(filename)
local err = bind.IupLoad(filename)
return (err ~= nil) and ffi.string(err) or nil
end
function mod.load_buffer(buffer)
local err = bind.IupLoadBuffer(buffer)
return (err ~= nil) and ffi.string(err) or nil
end
function mod.version()
return ffi.string(bind.IupVersion())
end
function mod.version_date()
return ffi.string(bind.IupVersionDate())
end
function mod.version_number()
return bind.IupVersionNumber()
end
function mod.set_language(lng)
bind.IupSetLanguage(lng)
end
function mod.get_language()
return ffi.string(bind.IupGetLanguage())
end
function mod.set_language_string(name, str)
bind.IupSetLanguageString(name, str)
end
function mod.store_language_string(name, str)
bind.IupStoreLanguageString(name, str)
end
function mod.get_language_string(name)
return ffi.string(bind.IupGetLanguageString(name))
end
function mod.set_language_pack(ih)
bind.IupSetLanguagePack(ih)
end
function mod.destroy(ih)
bind.IupDestroy(ih)
end
function mod.detach(child)
bind.IupDetach(child)
end
function mod.append(ih, child)
return bind.IupAppend(ih, child)
end
function mod.insert(ih, ref_child, child)
return bind.IupInsert(ih, ref_child, child)
end
function mod.get_child(ih, pos)
return bind.IupGetChild(ih, pos)
end
function mod.get_child_pos(ih, child)
return bind.IupGetChildPos(ih, child)
end
function mod.get_child_count(ih)
return bind.IupGetChildCount(ih)
end
function mod.get_next_child(ih, child)
return bind.IupGetNextChild(ih, child)
end
function mod.get_brother(ih)
return bind.IupGetBrother(ih)
end
function mod.get_parent(ih)
return bind.IupGetParent(ih)
end
function mod.get_dialog(ih)
return bind.IupGetDialog(ih)
end
function mod.get_dialog_child(ih, name)
return bind.IupGetDialogChild(ih, name)
end
function mod.reparent(ih, new_parent, ref_child)
return bind.IupReparent(ih, new_parent, ref_child)
end
function mod.popup(ih, x, y)
return bind.IupPopup(ih, x, y)
end
function mod.show(ih)
return bind.IupShow(ih)
end
function mod.show_xy(ih, x, y)
return bind.IupShowXY(ih, x, y)
end
function mod.hide(ih)
return bind.IupHide(ih)
end
function mod.map(ih)
return bind.IupMap(ih)
end
function mod.unmap(ih)
bind.IupUnmap(ih)
end
function mod.reset_attribute(ih, name)
bind.IupResetAttribute(ih, name)
end
function mod.get_all_attributes(ih)
local count = bind.IupGetAllAttributes(ih, nil, 0)
local cdata = ffi.new('char*[?]', count)
bind.IupGetAllAttributes(ih, cdata, count)
local attributes = {}
for i = 0, count - 1 do
-- invalid count fix
if cdata[i] ~= nil then
table.insert(attributes, ffi.string(cdata[i]))
end
end
return attributes
end
function mod.set_att(handle_name, ih, name, ...)
name = help.attrname(name)
return bind.IupSetAtt(handle_name, ih, name, help.vararg(...))
end
function mod.set_attributes(ih, str)
return bind.IupSetAttributes(ih, str)
end
function mod.get_attributes(ih)
return ffi.string(bind.IupGetAttributes(ih))
end
function mod.set_attribute(ih, name, value)
name = help.attrname(name)
value = help.attrvalue(value)
bind.IupSetAttribute(ih, name, value)
end
function mod.set_str_attribute(ih, name, value)
name = help.attrname(name)
bind.IupSetStrAttribute(ih, name, value)
end
function mod.set_strf(ih, name, format, ...)
name = help.attrname(name)
local value = string.format(format, ...)
bind.IupSetAttribute(ih, name, value)
end
function mod.set_int(ih, name, value)
name = help.attrname(name)
bind.IupSetInt(ih, name, value)
end
function mod.set_float(ih, name, value)
name = help.attrname(name)
bind.IupSetFloat(ih, name, value)
end
function mod.set_double(ih, name, value)
name = help.attrname(name)
bind.IupSetDouble(ih, name, value)
end
function mod.set_rgb(ih, name, r, g, b)
name = help.attrname(name)
bind.IupSetRGB(ih, name, r, g, b)
end
function mod.get_attribute(ih, name)
name = help.attrname(name)
return ffi.string(bind.IupGetAttribute(ih, name))
end
function mod.get_int(ih, name)
name = help.attrname(name)
return bind.IupGetInt(ih, name)
end
function mod.get_int2(ih, name)
name = help.attrname(name)
return bind.IupGetInt2(ih, name)
end
function mod.get_int_int(ih, name)
name = help.attrname(name)
local i1 = ffi.new('int[1]')
local i2 = ffi.new('int[1]')
bind.IupGetIntInt(ih, name, i1, i2)
return i1[0], i2[0]
end
function mod.get_float(ih, name)
name = help.attrname(name)
return bind.IupGetFloat(ih, name)
end
function mod.get_double(ih, name)
name = help.attrname(name)
return bind.IupGetDouble(ih, name)
end
function mod.get_rgb(ih, name)
name = help.attrname(name)
local r = ffi.new('unsigned char[1]')
local g = ffi.new('unsigned char[1]')
local b = ffi.new('unsigned char[1]')
bind.IupGetRGB(ih, name, r, g, b)
return r[0], g[0], b[0]
end
function mod.set_attribute_id(ih, name, id, value)
name = help.attrname(name)
bind.IupSetAttributeId(ih, name, id, value)
end
function mod.set_str_attribute_id(ih, name, id, value)
name = help.attrname(name)
bind.IupSetStrAttributeId(ih, name, id, value)
end
function mod.set_strf_id(ih, name, id, format, ...)
name = help.attrname(name)
local value = string.format(format, ...)
bind.IupSetAttributeId(ih, name, id, value)
end
function mod.set_int_id(ih, name, id, value)
name = help.attrname(name)
bind.IupSetIntId(ih, name, id, value)
end
function mod.set_float_id(ih, name, id, value)
name = help.attrname(name)
bind.IupSetFloatId(ih, name, id, value)
end
function mod.set_double_id(ih, name, id, value)
name = help.attrname(name)
bind.IupSetDoubleId(ih, name, id, value)
end
function mod.set_rgb_id(ih, name, id, r, g, b)
name = help.attrname(name)
bind.IupSetRGBId(ih, name, id, r, g, b)
end
function mod.get_attribute_id(ih, name, id)
name = help.attrname(name)
return ffi.string(bind.IupGetAttributeId(ih, name, id))
end
function mod.get_int_id(ih, name, id)
name = help.attrname(name)
return bind.IupGetIntId(ih, name, id)
end
function mod.get_float_id(ih, name, id)
name = help.attrname(name)
return bind.IupGetFloatId(ih, name, id)
end
function mod.get_double_id(ih, name, id)
name = help.attrname(name)
return bind.IupGetDoubleId(ih, name, id)
end
function mod.get_rgb_id(ih, name, id)
name = help.attrname(name)
local r = ffi.new('unsigned char[1]')
local g = ffi.new('unsigned char[1]')
local b = ffi.new('unsigned char[1]')
bind.IupGetRGBId(ih, name, id, r, g, b)
return r[0], g[0], b[0]
end
function mod.set_attribute_id2(ih, name, lin, col, value)
name = help.attrname(name)
bind.IupSetAttributeId2(ih, name, lin, col, value)
end
function mod.set_str_attribute_id2(ih, name, lin, col, value)
name = help.attrname(name)
bind.IupSetStrAttributeId2(ih, name, lin, col, value)
end
function mod.set_strf_id2(ih, name, lin, col, format, ...)
name = help.attrname(name)
local value = string.format(format, ...)
bind.IupSetAttributeId2(ih, name, lin, col, value)
end
function mod.set_int_id2(ih, name, lin, col, value)
name = help.attrname(name)
bind.IupSetIntId2(ih, name, lin, col, value)
end
function mod.set_float_id2(ih, name, lin, col, value)
name = help.attrname(name)
bind.IupSetFloatId2(ih, name, lin, col, value)
end
function mod.set_double_id2(ih, name, lin, col, value)
name = help.attrname(name)
bind.IupSetDoubleId2(ih, name, lin, col, value)
end
function mod.set_rgb_id2(ih, name, lin, col, r, g, b)
name = help.attrname(name)
bind.IupSetRGBId2(ih, name, lin, col, r, g, b)
end
function mod.get_attribute_id2(ih, name, lin, col)
name = help.attrname(name)
return ffi.string(bind.IupGetAttributeId2(ih, name, lin, col))
end
function mod.get_int_id2(ih, name, lin, col)
name = help.attrname(name)
return bind.IupGetIntId2(ih, name, lin, col)
end
function mod.get_float_id2(ih, name, lin, col)
name = help.attrname(name)
return bind.IupGetFloatId2(ih, name, lin, col)
end
function mod.get_double_id2(ih, name, lin, col)
name = help.attrname(name)
return bind.IupGetDoubleId2(ih, name, lin, col)
end
function mod.get_rgb_id2(ih, name, lin, col)
name = help.attrname(name)
local r = ffi.new('unsigned char[1]')
local g = ffi.new('unsigned char[1]')
local b = ffi.new('unsigned char[1]')
bind.IupGetRGBId2(ih, name, lin, col, r, g, b)
return r[0], g[0], b[0]
end
function mod.set_global(name, value)
name = help.attrname(name)
bind.IupSetGlobal(name, value)
end
function mod.set_str_global(name, value)
name = help.attrname(name)
bind.IupSetStrGlobal(name, value)
end
function mod.get_global(name)
name = help.attrname(name)
return ffi.string(bind.IupGetGlobal(name))
end
function mod.set_focus(ih)
return bind.IupSetFocus(ih)
end
function mod.get_focus()
return bind.IupGetFocus()
end
function mod.previous_field(ih)
return bind.IupPreviousField(ih)
end
function mod.next_field(ih)
return bind.IupNextField(ih)
end
function mod.get_callback(ih, name)
name = help.attrname(name)
return bind.IupGetCallback(ih, name)
end
function mod.set_callback(ih, name, func)
-- Icallback IupSetCallback (Ihandle* ih, const char *name, Icallback func)
name = help.attrname(name)
return bind.IupSetCallback(ih, name, ffi.cast('Icallback',func))
end
function mod.set_callbacks(ih, name, func, ...)
-- Ihandle* IupSetCallbacks(Ihandle* ih, const char *name, Icallback func, ...)
return bind.IupSetCallbacks(ih, name, func, ...)
end
function mod.get_function(name)
name = help.attrname(name)
return bind.IupGetFunction(name)
end
function mod.set_function(name, func)
-- Icallback IupSetFunction(const char *name, Icallback func)
name = help.attrname(name)
return bind.IupSetFunction(name, func)
end
function mod.get_handle(name)
return bind.IupGetHandle(name)
end
function mod.set_handle(name, ih)
return bind.IupSetHandle(name, ih)
end
function mod.get_all_names()
local count = bind.IupGetAllNames(nil, 0)
local cdata = ffi.new('char*[?]', count)
bind.IupGetAllNames(cdata, count)
local names = {}
for i = 0, count - 1 do
table.insert(names, ffi.string(cdata[i]))
end
return names
end
function mod.get_all_dialogs()
local count = bind.IupGetAllDialogs(nil, 0)
local cdata = ffi.new('char*[?]', count)
bind.IupGetAllDialogs(cdata, count)
local dialogs = {}
for i = 0, count - 1 do
table.insert(dialogs, ffi.string(cdata[i]))
end
return dialogs
end
function mod.get_name(ih)
local r = bind.IupGetName(ih)
return (r ~= nil) and ffi.string(r) or nil
end
function mod.set_attribute_handle(ih, name, ih_named)
name = help.attrname(name)
bind.IupSetAttributeHandle(ih, name, ih_named)
end
function mod.get_attribute_handle(ih, name)
name = help.attrname(name)
return bind.IupGetAttributeHandle(ih, name)
end
function mod.get_class_name(ih)
return ffi.string(bind.IupGetClassName(ih))
end
function mod.get_class_type(ih)
return ffi.string(bind.IupGetClassType(ih))
end
function mod.get_all_classes()
local count = bind.IupGetAllClasses(nil, 0)
local cdata = ffi.new('char*[?]', count)
bind.IupGetAllClasses(cdata, count)
local classes = {}
for i = 0, count - 1 do
table.insert(classes, ffi.string(cdata[i]))
end
return classes
end
function mod.get_class_attributes(classname)
local count = bind.IupGetClassAttributes(classname, nil, 0)
-- class not found
if count == -1 then
return
end
local cdata = ffi.new('char*[?]', count)
bind.IupGetClassAttributes(classname, cdata, count)
local attributes = {}
for i = 0, count - 1 do
-- invalid count fix
if cdata[i] ~= nil then
table.insert(attributes, ffi.string(cdata[i]))
end
end
return attributes
end
function mod.get_class_callbacks(classname)
local count = bind.IupGetClassCallbacks(classname, nil, 0)
-- class not found
if count == -1 then
return
end
local cdata = ffi.new('char*[?]', count)
bind.IupGetClassCallbacks(classname, cdata, count)
local callbacks = {}
for i = 0, count - 1 do
-- invalid count fix
if cdata[i] ~= nil then
table.insert(callbacks, ffi.string(cdata[i]))
end
end
return callbacks
end
function mod.save_class_attributes(ih)
bind.IupSaveClassAttributes(ih)
end
function mod.copy_class_attributes(src_ih, dst_ih)
bind.IupCopyClassAttributes(src_ih, dst_ih)
end
function mod.set_class_default_attribute(classname, name, value)
name = help.attrname(name)
bind.IupSetClassDefaultAttribute(classname, name, value)
end
function mod.class_match(ih, classname)
return bind.IupClassMatch(ih, classname)
end
function mod.create(classname)
return bind.IupCreate(classname)
end
function mod.createv(classname, params)
params = help.vararr('void*', params)
return bind.IupCreatev(classname, params)
end
function mod.createp(classname, first, ...)
return bind.IupCreatep(classname, first, help.vararg(...))
end
function mod.fill()
return bind.IupFill()
end
function mod.radio(child)
return bind.IupRadio(child)
end
function mod.vbox(child, ...)
return bind.IupVbox(child, help.vararg(...))
end
function mod.vboxv(children)
children = help.vararr('Ihandle*', children)