1 /** \file
2  * \brief Name space for C++ high level API
3  *
4  * See Copyright Notice in iup.h
5  */
6 module iup.iup_plusD;
7 
8 //#define __IUP_PLUS_H
9 
10 import std.string : toStringz, fromStringz, empty;
11 
12 public import iup.iup;
13 public import iup.iupcontrols;
14 public import iup.iup_config;
15 
16 public import iup.iupkey;
17 public import iup.iupdraw;
18 
19 /+
20 
21 TODO check what's required for myproject:
22 
23 Timer (Handle) /* OK */
24 Config (Handle) /* OK, no CN */
25 
26 Fill (Control) /* OK, no CN */
27 Label (Control) /* OK */
28 List (Control)  /* OK */
29 Calendar (Control) /* OK */
30 Text (Control)  /* OK */
31 Button (Control)  /* OK */
32 Toggle (Control)  /* OK */
33 Matrix (Control)  /* OK */
34 MatrixList (Control)  /* OK */
35 
36 Vbox (Container)
37 Hbox (Container)
38 Expander (Container)
39 Tabs (Container)
40 Dialog (Container)
41 
42 +/
43 
44 
45 Handle[string] AA;
46 
47 
48 /+
49 #if 0 //TODO
50 
51 #ifdef _STRING_
52 std::string
53 #endif
54 void cdCanvasSetfAttribute(cdCanvas* canvas, const(char)* name, const(char)* format, ...);
55 void IupSetStrf(Ihandle* ih, const(char)* name, const(char)* format, ...);
56 void IupSetStrfId(Ihandle *ih, const(char)* name, int id, const(char)* format, ...);
57 void IupSetStrfId2(Ihandle* ih, const(char)* name, int lin, int col, const(char)* format, ...);
58 void IupMessagef(const(char)* title, const(char)* format, ...);
59 
60 int IupScanf(const(char)* format, ...);
61 int IupGetParam(const(char)* title, Iparamcb action, void* user_data, const(char)* format, ...);
62 int IupGetParamv(const(char)* title, Iparamcb action, void* user_data, const(char)* format, int param_count, int param_extra, void** param_data);
63 
64 Icallback IupGetCallback(Ihandle* ih, const(char)* name);
65 Icallback IupSetCallback(Ihandle* ih, const(char)* name, Icallback func);
66 
67 void IupTreeSetAttributeHandle(Ihandle* ih, const(char)* name, int id, Ihandle* ih_named);
68 
69 #endif
70 +/
71 
72 /** \brief Name space for C++ high level API
73  *
74  * \par
75  * Defines wrapper classes for all C structures.
76  *
77  * See \ref iup_plus.h
78  */
79 //namespace iup {
80 ////  char* Version() { return IupVersion(); }
81 ////  char* VersionDate() { return IupVersionDate(); }
82 ////  int VersionNumber() { return IupVersionNumber(); }
83 
84 ////  int Open(ref int argc, ref char** argv) { return IupOpen(&argc, &argv); }
85 int IupOpenD()
86 {
87     import core.runtime : Runtime;
88     return  IupOpen(&Runtime.cArgs.argc, &Runtime.cArgs.argv);
89 }
90 deprecated int IupOpenD(in string[] args) // ... main(string[] args) // C: int main(int argc, char **argv)
91 {
92 //  TODO check if there is a smarter (library supported?) solution to get from string[] to char*[]
93 //  passing local adresses/pointers seemed to work as well, but better not to; inform the GC not to collect
94 	import core.memory : GC;
95 	int*    argc_ptr = new int;
96 	char*** argv_ptr = new char**;
97 	GC.addRoot(/*cast(void*)*/argc_ptr);
98 	GC.setAttr(/*cast(void*)*/argc_ptr, GC.BlkAttr.NO_MOVE);
99 	GC.addRoot(/*cast(void*)*/argv_ptr);
100 	GC.setAttr(/*cast(void*)*/argv_ptr, GC.BlkAttr.NO_MOVE);
101 
102 	*argc_ptr = cast(int) args.length;
103 	char*[] args_carray;
104 	foreach (s; args)
105 		args_carray ~= cast(char*) s.toStringz;
106 	*argv_ptr = args_carray.ptr;
107 
108 	return IupOpen(argc_ptr, argv_ptr);
109 }
110 ////  void Close() { IupClose(); }
111 ////  void ImageLibOpen() { IupImageLibOpen(); }
112 
113 ////  int MainLoop() { return IupMainLoop(); }
114 ////  int LoopStep() { return IupLoopStep(); }
115 ////  int LoopStepWait() { return IupLoopStepWait(); }
116 ////  int MainLoopLevel() { return IupMainLoopLevel(); }
117 ////  void Flush() { IupFlush(); }
118 ////  void ExitLoop() { IupExitLoop(); }
119 
120 ////  int RecordInput(const(char)* filename, int mode) { return IupRecordInput(filename, mode); }
121 ////  int  PlayInput(const(char)* filename) { return IupPlayInput(filename); }
122 
123 ////  int Help(const(char)* url) { return IupHelp(url); }
124 ////  void Log(const(char)* type, const(char)* str) { IupLog(type, "%s", str); }
125 ////  const(char)* Load(const(char)* filename) { return IupLoad(filename); }
126 ////  const(char)* LoadBuffer(const(char)* buffer) { return IupLoadBuffer(buffer); }
127 
128 ////  void SetLanguage(const(char)* lng) { IupSetLanguage(lng); }
129 ////  const(char)* GetLanguage() { return IupGetLanguage(); }
130 ////  void SetLanguageString(const(char)* name, const(char)* str) { IupSetLanguageString(name, str); }
131 ////  void StoreLanguageString(const(char)* name, const(char)* str) { IupStoreLanguageString(name, str); }
132 ////  const(char)* GetLanguageString(const(char)* name) { return IupGetLanguageString(name); }
133 
134 ////  int GetAllClasses(char** names, int n) { return IupGetAllClasses(names, n); }
135 ////  int GetClassAttributes(const(char)* classname, char** names, int n) { return IupGetClassAttributes(classname, names, n); }
136 ////  int GetClassCallbacks(const(char)* classname, char** names, int n) { return IupGetClassCallbacks(classname, names, n); }
137 ////  void SetClassDefaultAttribute(const(char)* classname, const(char)* name, const(char)* value) { IupSetClassDefaultAttribute(classname, name, value); }
138 
139 ////  void SetGlobal(const(char)* name, const(char)* value) { IupSetGlobal(name, value); }
140 ////  void SetStringGlobal(const(char)* name, const(char)* value) { IupSetStrGlobal(name, value); }
141 ////  char* GetGlobal(const(char)* name) { return IupGetGlobal(name); }
142 
143 ////  int GetFile(char *arq) { return IupGetFile(arq); }
144 ////  void Message(const(char)* title, const(char)* msg) { IupMessage(title, msg); }
145 ////  int Alarm(const(char)* title, const(char)* msg, const(char)* b1, const(char)* b2, const(char)* b3) { return IupAlarm(title, msg, b1, b2, b3); }
146 ////  int ListDialog(int type, const(char)* title, int size, const(char)** list, int op, int max_col, int max_lin, int* marks) { return IupListDialog(type, title, size, list, op, max_col, max_lin, marks); }
147 ////  int GetText(const(char)* title, char* text, int maxsize = 10240) { return IupGetText(title, text, maxsize); }
148 ////  int GetColor(int x, int y, ubyte &r, ubyte &g, ubyte &b) { return IupGetColor(x, y, &r, &g, &b); }
149 
150 ////  int GetAllNames(char** names, int n) { return IupGetAllNames(names, n); }
151 ////  int GetAllDialogs(char** names, int n) { return IupGetAllDialogs(names, n); }
152 
153 enum FILL_TYPE {
154 	FILL_NONE,
155 	FILL_FRONT,
156 	FILL_BACK,
157 	FILL_BETWEEN,
158 	FILL_FRONT_AND_BACK,
159 	FILL_FRONT_AND_BETWEEN,
160 	FILL_BACK_AND_BETWEEN,
161 	FILL_FRONT_AND_BACK_AND_BETWEEN
162 }
163 
164 class /*Element*/ Handle // used as base class
165 {
166   private Ihandle* _ih;
167 
168   nothrow:
169 
170   /* forbidden */
171   private this() { this(cast(Ihandle*)null); }
172   /*private*/ this(Ihandle* ref_ih)  { _ih = ref_ih; }
173   this(/*Element*/Handle elem) { this(elem._ih); }
174 //  alias _ih this; // will only be usable within the class hierarchy, not from "outside"
175   // There is no destructor because all iup::Handle are just a reference to the Ihandle*,
176   // since several IUP elements are automatically destroyed when the dialog is destroyed
177   // So, to force an element to be destructed call the Destroy method
178 //  invariant() { assert(_ih != null); }
179 
180   @property Ihandle* GetHandle() @nogc { return _ih; }
181 
182   @property bool Failed() {
183     return _ih == null;
184   }
185 //alias  _     = GetHandle;
186 /*
187 Naming:
188 When (after Set/Get) Attribute/User comes first, parameter types are the same as Iup...-function, thus SetAttribute and IupSetAttribute have the same signature (except Ihandle* _ih)
189 When (after Set/Get) String/Integer/Double/RGB  signature has D types only
190 "mixed" SetStrAttr
191 */
192 //final void   SetUserData (const(char)* name,         void* data) @nogc  { IupSetAttribute(       _ih, name, cast(char*)data); } // hides the cast; explicitely cast and use SetAttribute instead
193   final void   SetAttribute(const(char)* name, const(char)* value) @nogc  { IupSetAttribute(       _ih, name,    value); }
194   final void   SetAttributeVALUE(              const(char)* value) @nogc  { IupSetAttribute(       _ih, "VALUE", value); }
195 //final void*  GetUserData (const(char)* name)                     @nogc  { return cast(void*)IupGetAttribute(_ih, name); }
196   final char*  GetAttribute(const(char)* name)                     @nogc  { return IupGetAttribute(_ih, name); }
197   final char*  GetAttributeVALUE()                                 @nogc  { return IupGetAttribute(_ih, "VALUE"); }
198 
199 // mixed C/D types to help with defining user attributes:
200   final void   SetAttributeStr(   string name, const(char)* value)        { IupSetAttribute(       _ih, name.toStringz, value); }
201   final char*  GetAttributeStr(   string name)                            { return IupGetAttribute(_ih, name.toStringz); }
202 //
203   final void   SetString(         string name,       string value)        { IupSetStrAttribute(    _ih, name.toStringz, value.toStringz); }
204   final void   SetStringVALUE(                       string value)        { IupSetStrAttribute(    _ih, "VALUE",        value.toStringz); }
205   final string GetString(         string name)                            { return IupGetAttribute(_ih, name.toStringz).fromStringz.idup; } // decoupled from C's string
206   final string GetStringVALUE()                                           { return IupGetAttribute(_ih, "VALUE"       ).fromStringz.idup; } // decoupled from C's string
207 
208   final void   SetInteger(        string name,          int value)        { IupSetInt(_ih, name.toStringz, value); }
209   final void   SetIntegerVALUE(                         int value)        { IupSetInt(_ih, "VALUE",        value); }
210   final int    GetInteger(        string name)                            { return IupGetInt(_ih, name.toStringz); }
211   final int    GetIntegerVALUE()                                          { return IupGetInt(_ih, "VALUE"); }
212 
213   final void   GetIntegerInteger( string name, out int i1, out int i2)    { IupGetIntInt(_ih, name.toStringz, &i1, &i2); }
214 
215   final void   SetDouble(         string name,       double value)        { IupSetDouble(_ih, name.toStringz, value); }
216   final void   SetDoubleVALUE(                       double value)        { IupSetDouble(_ih, "VALUE",        value); }
217   final double GetDouble(         string name)                            { return IupGetDouble(_ih, name.toStringz); }
218   final double GetDoubleVALUE()                                           { return IupGetDouble(_ih, "VALUE"); }
219   final void   SetRGB(            string name, ubyte r, ubyte g, ubyte b) { IupSetRGB(_ih, name.toStringz, r, g, b); }
220   final void   GetRGB(            string name, out ubyte r, out ubyte g, out ubyte b)  { IupGetRGB(_ih, name.toStringz, &r, &g, &b); }
221 ////
222 //final void   SetUserDataId (const(char)* name, int id, void* data) @nogc         {         IupSetAttributeId(_ih, name, id, cast(char*)data); }
223   final void   SetAttributeId(const(char)* name, int id, const(char)* value) @nogc {         IupSetAttributeId(_ih, name, id, value); }
224 //final void*  GetUserDataId (const(char)* name, int id) @nogc            { return cast(void*)IupGetAttributeId(_ih, name, id); }
225   final char*  GetAttributeId(const(char)* name, int id)            @nogc { return  IupGetAttributeId(_ih, name, id); }
226 
227   final void   SetStringId (    string name, int id, string value)        { IupSetStrAttributeId(_ih, name.toStringz, id, value.toStringz); }
228   final string GetStringId (    string name, int id)                      { return IupGetAttributeId(_ih, name.toStringz, id).fromStringz.idup; } // decoupled from C's string
229   final void   SetIntegerId(    string name, int id,    int value)        { IupSetIntId(_ih, name.toStringz, id, value); }
230   final int    GetIntegerId(    string name, int id)                      { return IupGetIntId(_ih, name.toStringz, id); }
231   final void   SetDoubleId (    string name, int id, double value)        { IupSetDoubleId(_ih, name.toStringz, id, value); }
232   final double GetDoubleId (    string name, int id)                      { return IupGetDoubleId(_ih, name.toStringz, id); }
233   final void   SetRGBId(        string name, int id, ubyte r, ubyte g, ubyte b)             { IupSetRGBId(_ih, name.toStringz, id, r, g, b); }
234   final void   GetRGBId(        string name, int id, out ubyte r, out ubyte g, out ubyte b) { IupGetRGBId(_ih, name.toStringz, id, &r, &g, &b); }
235 ////
236   final void   SetAttributeId2(const(char)* name, int lin, int col, const(char)* value) @nogc {        IupSetAttributeId2(_ih, name, lin, col, value); }
237   final char*  GetAttributeId2(const(char)* name, int lin, int col)                     @nogc { return IupGetAttributeId2(_ih, name, lin, col); }
238 //final void   SetUserDataId2 (const(char)* name, int lin, int col, void* data) @nogc { IupSetAttributeId2(_ih, name, lin, col, cast(char*)data); }
239 //final void*  GetUserDataId2 (const(char)* name, int lin, int col) @nogc             { return cast(void*)IupGetAttributeId2(_ih, name, lin, col); }
240 
241   final void   SetStringId2 (     string name, int lin, int col, string value) { IupSetStrAttributeId2(_ih, name.toStringz, lin, col, value.toStringz); }
242   final string GetStringId2 (     string name, int lin, int col)               { return IupGetAttributeId2(_ih, name.toStringz, lin, col).fromStringz.idup; } // decoupled from C's string
243   final void   SetIntegerId2(     string name, int lin, int col, int value)    { IupSetIntId2(_ih, name.toStringz, lin, col, value); }
244   final int    GetIntegerId2(     string name, int lin, int col)               { return IupGetIntId2(_ih, name.toStringz, lin, col); }
245   final void   SetDoubleId2 (     string name, int lin, int col, double value) { IupSetDoubleId2(_ih, name.toStringz, lin, col, value); }
246   final double GetDoubleId2 (     string name, int lin, int col)               { return IupGetDoubleId2(_ih, name.toStringz, lin, col); }
247   final void   SetRGBId2    (     string name, int lin, int col, ubyte r, ubyte g, ubyte b) { IupSetRGBId2(_ih, name.toStringz, lin, col, r, g, b); }
248   final void   GetRGBId2    (     string name, int lin, int col, out ubyte r, out ubyte g, out ubyte b) { IupGetRGBId2(_ih, name.toStringz, lin, col, &r, &g, &b); }
249 
250   /*Element*/Handle SetAttributes(const(char)* str) { return new /*Element*/Handle(IupSetAttributes(_ih, str)); }
251   final void   ResetAttribute(    string name)                                 { IupResetAttribute(_ih, name.toStringz); }
252   final int GetAllAttributes(ref string[] names/*, int n*/) {
253   	int n_max = IupGetAllAttributes(_ih, null, 0);
254     if (names is null /* || n==0*/)
255       return n_max;
256     else {
257       names.length = n_max;
258       char*[] arr = new char*[](n_max);
259       int res = IupGetAllAttributes(_ih, arr.ptr, n_max);
260       foreach(i, c; arr)
261         names[i] = c.fromStringz.idup;
262       return res;
263     }
264   }
265   final void SetAttributeHandle(string name, /*Element*/Handle elem) { IupSetAttributeHandle(_ih, name.toStringz, elem.GetHandle); }
266 //final /*Element*/Handle GetAttributeHandle(string name) { return new /*Element*/Handle(IupGetAttributeHandle(_ih, name.toStringz)); }
267   /*Element*/Handle GetAttributeHandle(const(char)* name) { return new /*Element*/Handle(IupGetAttributeHandle(_ih, name)); }
268   void SetAttributeHandleId(const(char)* name, int id, /*Element*/Handle elem) { IupSetAttributeHandleId(_ih, name, id, elem.GetHandle); }
269   /*Element*/Handle GetAttributeHandleId(const(char)* name, int id) { return new /*Element*/Handle(IupGetAttributeHandleId(_ih, name, id)); }
270   void SetAttributeHandleId2(const(char)* name, int lin, int col, /*Element*/Handle elem) { IupSetAttributeHandleId2(_ih, name, lin, col, elem.GetHandle); }
271   /*Element*/Handle GetAttributeHandleId2(const(char)* name, int lin, int col) { return new /*Element*/Handle(IupGetAttributeHandleId2(_ih, name, lin, col)); }
272 
273   Icallback GetCallback(const(char)* name) { return IupGetCallback(_ih, name); }
274 //  Icallback SetCallback(const(char)* name, Icallback func) { return IupSetCallback(_ih, name, func); }
275 
276   final void Destroy() @nogc { IupDestroy(_ih); }
277 
278   final int Map() @nogc { return IupMap(_ih); }
279   final void Unmap() @nogc { IupUnmap(_ih); }
280 
281   final string GetName() { return IupGetName(_ih).fromStringz.idup; } // decoupled from C's string
282 
283   final string GetClassName() { return IupGetClassName(_ih).fromStringz.idup; } // decoupled from C's string
284   final string GetClassType() { return IupGetClassType(_ih).fromStringz.idup; } // decoupled from C's string
285   final void SaveClassAttributes() @nogc { IupSaveClassAttributes(_ih); }
286   final void CopyClassAttributesTo(Handle dst) @nogc { IupCopyClassAttributes(_ih, dst._ih); }
287   final int ClassMatch(const(char)* classname) @nogc { return IupClassMatch(_ih, classname); }
288 
289   final Icallback SetCallback (const(char)* name, Icallback func) @nogc { return IupSetCallback(_ih, name, func); }
290 
291   final Handle SetHandle(const(char)* name) { return new Handle(IupSetHandle(name, _ih)); } // returned Handle's member _ih may be null
292   final Handle SetHandle(string       name) { return new Handle(IupSetHandle(name.toStringz, _ih)); } // returned Handle's member _ih may be null
293 
294   // Timer
295   void start() @nogc {}
296   void stop()  @nogc {}
297 // Dialog/Menu
298   int Popup(int x, int y) { return 0; }
299 // Dialog/Control
300   int Show() { return 0; }
301   int Hide() { return 0; }
302 
303 // Control
304   void Update() {}
305   void Redraw() {}
306   void Refresh() {}
307 // Container
308   void UpdateChildren() {}
309   void RedrawChildren() {}
310   void RefreshChildren() {}
311 
312 
313 } // class Handle
314 
315 Handle createHandle(Ihandle* ih)       nothrow { return new Handle(ih); } // createHandle was named GetHandle before
316 Handle createHandle(const(char)* name) nothrow { return new Handle(IupGetHandle(name)); }
317 Handle createHandle(string       name) nothrow { return new Handle(IupGetHandle(name.toStringz)); }
318 
319 //Handle SetHandle(const(char)* name, Handle handle) nothrow { return new Handle(IupSetHandle(name, handle.GetHandle())); } // returned Handle's member _ih may be null
320 //Handle SetHandle(string       name, Handle handle) nothrow { return new Handle(IupSetHandle(name.toStringz, handle.GetHandle())); } // returned Handle's member _ih may be null
321 void SetLanguagePack(Handle handle) @nogc nothrow { IupSetLanguagePack(handle.GetHandle()); }
322 
323 
324 class Control : Handle
325 {
326   nothrow:
327   private this(Ihandle* ih) { super(ih); }
328 //  alias _ih this;
329 
330   override void Update() { IupUpdate(_ih); }
331   override void Redraw() { IupRedraw(_ih, 1); }
332   override void Refresh() { IupRefresh(_ih); }
333 
334   final void Detach(Control child) { IupDetach(child._ih); }
335 
336   final Control GetBrother() {
337     return new Control(IupGetBrother(_ih));
338   }
339   final Container GetParent() {
340     if (_ih==null)
341       return new Container(null);
342     else {
343       Ihandle* ih_parent = IupGetParent(_ih);
344       try {
345         foreach (k, ref v; AA) {
346           Ihandle* ih_v = v.GetHandle;
347           if (ih_v!=null && ih_v==ih_parent)
348             return cast(Container)v;
349         }
350       }
351       catch (Exception e) { /* todo: handle exception */ }
352     }
353     return new Container(null);
354   }
355 
356   final Dialog  GetDialog() { return new Dialog(IupGetDialog(_ih)); }
357   final Control GetDialogChild(const(char)* name) { return new Control(IupGetDialogChild(_ih, name)); }
358   final int Reparent(Container new_parent, Control ref_child) { return IupReparent(_ih, new_parent.GetHandle(), ref_child.GetHandle()); }
359 
360 
361   final Control SetFocus() { return new Control(IupSetFocus(_ih)); }
362   final Control PreviousField() { return new Control(IupPreviousField(_ih)); }
363   final Control NextField() { return new Control(IupNextField(_ih)); }
364 
365 /* IupText and IupScintilla utilities */
366   final void ConvertLinColToPos(int lin, int col, out int pos) { IupTextConvertLinColToPos(_ih, lin, col, &pos); }
367   final void ConvertPosToLinCol(int pos, out int lin, out int col) { IupTextConvertPosToLinCol(_ih, pos, &lin, &col); }
368 
369 /* IupText, IupList, IupTree, IupMatrix and IupScintilla utility */
370   final int ConvertXYToPos(int x, int y) { return IupConvertXYToPos(_ih, x, y); }
371 
372   override int Show() { return IupShow(_ih); }
373   override int Hide() { return IupHide(_ih); }
374 }
375 
376 Control GetFocus() nothrow {
377   Ihandle* ih_focus = IupGetFocus();
378   if (ih_focus==null)
379     return new Control(null);
380   else {
381     try {
382       foreach (k, ref v; AA) {
383       	Ihandle* ih_v = v.GetHandle;
384         if (ih_v!=null && ih_v==ih_focus)
385           return cast(Control)v;
386       }
387     }
388     catch (Exception e) { /* todo: handle exception */ }
389     return new Control(null);
390   }
391 }
392 
393 class Container : Control
394 {
395   nothrow:
396 //  @disable this();
397   this(Ihandle* ih) { super(ih); }
398   this(Ihandle* ih, Control[] child_array, FILL_TYPE fill=FILL_TYPE.FILL_NONE) {
399     super(ih);
400 //    child_array ~= new Control(null);
401     int cnt = 0;
402 	with (FILL_TYPE) {
403       if (fill==FILL_FRONT || fill==FILL_FRONT_AND_BACK)
404         IupAppend(_ih, IupFill());
405       foreach (c; child_array) {
406         if ((fill==FILL_BETWEEN && cnt)|| fill==FILL_FRONT_AND_BETWEEN || (fill==FILL_BACK_AND_BETWEEN && cnt) || fill==FILL_FRONT_AND_BACK_AND_BETWEEN)
407           IupAppend(_ih, IupFill());
408         IupAppend(_ih, c.GetHandle());
409         ++cnt;
410       }
411       if (fill==FILL_BACK || fill==FILL_FRONT_AND_BACK || fill==FILL_BACK_AND_BETWEEN || fill==FILL_FRONT_AND_BACK_AND_BETWEEN)
412         IupAppend(_ih, IupFill());
413 	}
414   }
415 
416   this(Ihandle* ih, Control child0, Control child1 = null, Control child2 = null, Control child3 = null, Control child4 = null,
417   	Control child5 = null, Control child6 = null, Control child7 = null, Control child8 = null, Control child9 = null)
418   {
419     super(ih);
420     if (child0 !is null) IupAppend(_ih, child0.GetHandle());
421     if (child1 !is null) IupAppend(_ih, child1.GetHandle());
422     if (child2 !is null) IupAppend(_ih, child2.GetHandle());
423     if (child3 !is null) IupAppend(_ih, child3.GetHandle());
424     if (child4 !is null) IupAppend(_ih, child4.GetHandle());
425     if (child5 !is null) IupAppend(_ih, child5.GetHandle());
426     if (child6 !is null) IupAppend(_ih, child6.GetHandle());
427     if (child7 !is null) IupAppend(_ih, child7.GetHandle());
428     if (child8 !is null) IupAppend(_ih, child8.GetHandle());
429     if (child9 !is null) IupAppend(_ih, child9.GetHandle());
430   }
431 //  alias _ih this;
432 
433   Control Append(Control child) {
434     Ihandle* ih_child = child.GetHandle();
435     if (_ih==null || ih_child==null) // this has a null Ihandle*, etc.
436       return new Control(null);
437     Ihandle* ih_parent = IupAppend(_ih, ih_child);
438     if (ih_parent==null || _ih != ih_parent)
439       return new Control(null);
440     else {
441       try {
442         foreach (k, ref v; AA) {
443           if (v.GetHandle!=null && v.GetHandle==ih_parent)
444             return cast(Control)v;
445         }
446       }
447       catch (Exception e) { /* todo: handle exception */ }
448       return new Control(null);
449     }
450   }
451 
452   Control Insert(Control ref_child, Control child) {
453     if (_ih==null || ref_child.GetHandle()==null || child.GetHandle()==null) // this has a null Ihandle*, etc.
454       return new Control(null);
455     Ihandle* ih_parent = IupInsert(_ih, ref_child.GetHandle(), child.GetHandle());
456     if (ih_parent==null || _ih != ih_parent)
457       return new Control(null);
458     else { //lookup in AA
459       try {
460         foreach (k, ref v; AA) {
461           if (v.GetHandle!=null && v.GetHandle==ih_parent)
462             return cast(Control)v;
463         }
464       }
465       catch (Exception e) { /* todo: handle exception */ }
466       return new Control(null);
467     }
468   }
469   Control GetChild(int pos) { return new Control(IupGetChild(_ih, pos)); }
470   int GetChildPos(Control child) { return IupGetChildPos(_ih, child.GetHandle()); }
471   int GetChildCount() { return IupGetChildCount(_ih); }
472 
473   Control GetFirstChild() { return new Control(IupGetNextChild(_ih, null)); }
474   Control GetNextChild(Control ref_child) { return new Control(IupGetNextChild(_ih, ref_child.GetHandle())); }
475 
476   override void UpdateChildren() { IupUpdateChildren(_ih); }
477   override void RedrawChildren() { IupRedraw(_ih, 1); }
478   override void RefreshChildren() { IupRefreshChildren(_ih); }
479 }
480 
481 class Dialog : Container
482 {
483   private bool _autoDestroy;
484   nothrow:
485 //    Dialog(const Control& child) : Container(IupDialog(child.GetHandle())) { }
486 //  @disable this();
487   this(                             Ihandle* ih)   { this(false, ih); }
488   this(           bool autoDestroy, Ihandle* ih)   { super(ih); _autoDestroy = autoDestroy; }
489   this(           bool autoDestroy, Control child) { super(IupDialog(child.GetHandle())); _autoDestroy = autoDestroy; }
490   this(string CN, bool autoDestroy, Control child) { this(autoDestroy, child); if (!CN.empty) { AA[CN] = this; IupSetHandle(CN.toStringz, _ih); } }
491   ~this() { if (_autoDestroy) { Destroy(); /* TODO manage deleting from AA */ } }
492 //  alias _ih this;
493 
494   override int Popup(int x, int y) { return IupPopup(_ih, x, y); }
495   override int Show() { return IupShow(_ih); }
496   int ShowXY(int x, int y) { return IupShowXY(_ih, x, y); }
497 }
498 
499 Dialog LayoutDialog(Dialog dialog) nothrow { return new Dialog(IupLayoutDialog(dialog.GetHandle())); }
500 Dialog ElementPropertiesDialog(Control control) nothrow { return new Dialog(IupElementPropertiesDialog(control.GetHandle())); }
501 
502 void MessageError(Dialog parent, const(char)* message)
503     { IupMessageError(parent.GetHandle(), message); }
504 int MessageAlarm(Dialog parent, const(char)* title, const(char)* message, const(char)* buttons)
505     { return IupMessageAlarm(parent.GetHandle(), title, message, buttons); }
506 
507 
508 class Menu : Container
509 {
510   nothrow:
511   this() { super(IupMenu(null)); }
512   this(Control child) { super(IupMenu(child.GetHandle(), null)); }
513   this(Control child0, Control child1 = null, Control child2 = null, Control child3 = null, Control child4 = null,
514     Control child5 = null, Control child6 = null, Control child7 = null, Control child8 = null, Control child9 = null)
515       { super(IupMenu(null), child0, child1, child2, child3, child4, child5, child6, child7, child8, child9); }
516 ////  this(Control[] child_array) { super(IupMenu(null), child_array); }
517 
518   override int Popup(int x, int y) { return IupPopup(_ih, x, y); }
519 }
520 
521 version(IM) //#ifdef __IM_PLUS_H   // im.im_plusD is not ready to be published
522 {
523 public import iup.iupim : IupLoadImage, IupSaveImage, IupImageFromImImage, IupGetNativeHandleImage, IupGetImageNativeHandle;
524 public import im.im_plusD;
525 
526 class Image : Handle
527 {
528   nothrow:
529   this(const(char)* filename) { super(IupLoadImage(filename)); }
530   this(ref im.im_plusD.Image image) { super(IupImageFromImImage(image.GetHandle())); }
531 
532   int Save(const(char)* filename, const(char)* im_format) { return IupSaveImage(_ih, filename, im_format); }
533   int SaveAsText(const(char)* filename, const(char)* iup_format, const(char)* name) { return IupSaveImageAsText(_ih, filename, iup_format, name); }
534 }
535 
536 class Clipboard : Handle
537 {
538   nothrow:
539   this() { super(IupClipboard()); }
540 
541   void SetImage(ref im.im_plusD.Image image) { SetAttribute("NATIVEIMAGE", cast(const(char)*)IupGetImageNativeHandle(image.GetHandle())); }// SetUserData("NATIVEIMAGE", cast(const(char)*)IupGetImageNativeHandle(image.GetHandle()));
542 
543   im.im_plusD.Image GetImage() { return new im.im_plusD.Image(IupGetNativeHandleImage(GetAttribute("NATIVEIMAGE"))); }
544 }
545 //TODO imImage* IupImageToImImage(Ihandle* iup_image)
546 } // version(IM)
547 
548 
549 class User : Handle
550 {
551   nothrow:
552   this() { super(IupUser); }
553 }
554 
555 class Param : Handle
556 {
557   nothrow:
558   this(const(char)* format) { super(IupParam(format)); }
559 }
560 
561 class Timer : Handle
562 {
563   nothrow:
564   this()          { super(IupTimer); }
565   this(string CN) { this(); if (!CN.empty) { AA[CN] = this; IupSetHandle(CN.toStringz, _ih); } }
566 
567   override void start() @nogc { SetAttribute("RUN", "YES"); }
568   override void stop()  @nogc { SetAttribute("RUN", "NO"); }
569 }
570 
571 class MenuSeparator : Control
572 {
573   nothrow:
574   this() { super(IupSeparator()); }
575 }
576 
577 class MenuItem : Control
578 {
579   nothrow:
580   this(const(char)* title = null) { super(IupItem(title, null)); }
581 }
582 
583 class Canvas : Control
584 {
585   nothrow:
586   this() { super(IupCanvas(null)); }
587 
588   void DrawBegin() { IupDrawBegin(_ih); }
589   void DrawEnd() { IupDrawEnd(_ih); }
590   void DrawSetClipRect(int x1, int y1, int x2, int y2) { IupDrawSetClipRect(_ih, x1, y1, x2, y2); }
591   void DrawResetClip() { IupDrawResetClip(_ih); }
592   void DrawParentBackground() { IupDrawParentBackground(_ih); }
593   void DrawLine(int x1, int y1, int x2, int y2) { IupDrawLine(_ih, x1, y1, x2, y2); }
594   void DrawRectangle(int x1, int y1, int x2, int y2) { IupDrawRectangle(_ih, x1, y1, x2, y2); }
595   void DrawArc(int x1, int y1, int x2, int y2, double a1, double a2) { IupDrawArc(_ih, x1, y1, x2, y2, a1, a2); }
596   void DrawPolygon(int* points, int count) { IupDrawPolygon(_ih, points, count); }
597   void DrawText(const(char)* text, int len, int x, int y) { IupDrawText(_ih, text, len, x, y); }
598   void DrawImage(const(char)* name, int make_inactive, int x, int y) { IupDrawImage(_ih, name, make_inactive, x, y); }
599   void DrawSelectRect(int x1, int y1, int x2, int y2) { IupDrawSelectRect(_ih, x1, y1, x2, y2); }
600   void DrawFocusRect(int x1, int y1, int x2, int y2) { IupDrawFocusRect(_ih, x1, y1, x2, y2); }
601   void DrawGetSize(ref int w, ref int h) { IupDrawGetSize(_ih, &w, &h); }
602   void DrawGetTextSize(const(char)* str, ref int w, ref int h) { IupDrawGetTextSize(_ih, str, &w, &h); }
603   void DrawGetImageInfo(const(char)* name, ref int w, ref int h, ref int bpp) { IupDrawGetImageInfo(name, &w, &h, &bpp); }
604 }
605 
606 class Link : Control
607 {
608   nothrow:
609   this(const(char)* url = null, const(char)* title = null) { super(IupLink(url, title)); }
610 }
611 
612 class Label : Control
613 {
614   nothrow:
615   this(           const(char)* title = null) { super(IupLabel(title)); }
616   this(string CN, const(char)* title)        { this(title); if (!CN.empty) { AA[CN] = this; IupSetHandle(CN.toStringz, _ih); } }
617 }
618 
619 class Button : Control
620 {
621   nothrow:
622   this(           const(char)* title = null) { super(IupButton(title, null)); }
623   this(string CN, const(char)* title)        { this(title); if (!CN.empty) { AA[CN] = this; IupSetHandle(CN.toStringz, _ih); } }
624 }
625 
626 class FlatButton : Control
627 {
628   nothrow:
629   this(           const(char)* title = null) { super(IupFlatButton(title)); }
630   this(string CN, const(char)* title)        { this(title); if (!CN.empty) { AA[CN] = this; IupSetHandle(CN.toStringz, _ih); } }
631 }
632 
633 class AnimatedLabel : Control
634 {
635   nothrow:
636   this(           Ihandle* animation = null) { super(IupAnimatedLabel(animation)); }
637   this(string CN, Ihandle* animation)        { this(animation); if (!CN.empty) { AA[CN] = this; IupSetHandle(CN.toStringz, _ih); } }
638 }
639 
640 class Toggle : Control
641 {
642   nothrow:
643   this(           const(char)* title = null) { super(IupToggle(title, null /*no action set by constructor */)); }
644   this(string CN, const(char)* title)        { this(title); if (!CN.empty) { AA[CN] = this; IupSetHandle(CN.toStringz, _ih); } }
645 }
646 
647 class Fill : Control
648 {
649   nothrow:
650   this() { super(IupFill); }
651 }
652 
653 deprecated class Spin : Control
654 {
655   nothrow:
656   this() { super(IupSpin); }
657 }
658 
659 class Calendar : Control
660 {
661   nothrow:
662   this()          { super(IupCalendar); }
663   this(string CN) { this(); if (!CN.empty) { AA[CN] = this; IupSetHandle(CN.toStringz, _ih); } }
664 }
665 
666 class Tree : Control
667 {
668   nothrow:
669   this() { super(IupTree); }
670   this(string CN) { this(); if (!CN.empty) { AA[CN] = this; IupSetHandle(CN.toStringz, _ih); } }
671 
672   int SetUserId(int id, void* userid) { return IupTreeSetUserId(_ih, id, userid); }
673   void* GetUserId(int id) { return IupTreeGetUserId(_ih, id); }
674   int GetId(void* userid) { return IupTreeGetId(_ih, userid); }
675   void  SetAttributeHandle(const(char)* name, int id, Ihandle* ih_named) { IupSetAttributeHandleId(_ih, name, id, ih_named); }
676 }
677 
678 class Val : Control
679 {
680   nothrow:
681   this(const(char)* orientation = null) { super(IupVal(orientation)); }
682 }
683 
684 class ProgressBar : Control
685 {
686   nothrow:
687   this() { super(IupProgressBar); }
688 }
689 
690 class List : Control
691 {
692   nothrow:
693   this()          { super(IupList(null)); }
694   this(string CN) { this(); if (!CN.empty) { AA[CN] = this; IupSetHandle(CN.toStringz, _ih); } }
695 }
696 
697 class Text : Control
698 {
699   nothrow:
700   this()          { super(IupText(null)); }
701   this(string CN) { this(); if (!CN.empty) { AA[CN] = this; IupSetHandle(CN.toStringz, _ih); } }
702 }
703 
704 
705 class Split : Container
706 {
707   nothrow:
708   this()                               { super(IupSplit(null, null)); }
709   this(Control child)                  { super(IupSplit(child.GetHandle(), null)); }
710   this(Control child1, Control child2) { super(IupSplit(child1.GetHandle(), child2.GetHandle())); }
711 }
712 
713 class Submenu : Container
714 {
715   nothrow:
716   this(const(char)* title = null)         { super(IupSubmenu(title, null)); }
717   this(const(char)* title, Control child) { super(IupSubmenu(title, child.GetHandle())); }
718 }
719 
720 class Radio : Container
721 {
722   nothrow:
723   this()              { super(IupRadio(null)); }
724   this(Control child) { super(IupRadio(child.GetHandle())); }
725 }
726 
727 class Sbox : Container
728 {
729   nothrow:
730   this()              { super(IupSbox(null)); }
731   this(Control child) { super(IupSbox(child.GetHandle())); }
732 }
733 
734 class ScrollBox : Container
735 {
736   nothrow:
737   this()              { super(IupScrollBox(null)); }
738   this(Control child) { super(IupScrollBox(child.GetHandle())); }
739 }
740 
741 class FlatScrollBox : Container
742 {
743   nothrow:
744   this()              { super(IupFlatScrollBox(null)); }
745   this(Control child) { super(IupFlatScrollBox(child.GetHandle())); }
746   this(FlatScrollBox container) { super(container.GetHandle()); }
747   this(Ihandle* _ih)  { super(_ih); }
748 }
749 
750 class Expander : Container
751 {
752   nothrow:
753   this()              { super(IupExpander(null)); }
754   this(Control child) { super(IupExpander(child.GetHandle())); }
755 }
756 
757 class DetachBox : Container
758 {
759   nothrow:
760   this()              { super(IupDetachBox(null)); }
761   this(Control child) { super(IupDetachBox(child.GetHandle())); }
762 }
763 
764   class BackgroundBox : Container
765   {
766     nothrow:
767     this()              { super(IupBackgroundBox(null)); }
768     this(Control child) { super(IupBackgroundBox(child.GetHandle())); }
769 
770     void DrawBegin() { IupDrawBegin(_ih); }
771     void DrawEnd() { IupDrawEnd(_ih); }
772     void DrawSetClipRect(int x1, int y1, int x2, int y2) { IupDrawSetClipRect(_ih, x1, y1, x2, y2); }
773     void DrawResetClip() { IupDrawResetClip(_ih); }
774     void DrawParentBackground() { IupDrawParentBackground(_ih); }
775     void DrawLine(int x1, int y1, int x2, int y2) { IupDrawLine(_ih, x1, y1, x2, y2); }
776     void DrawRectangle(int x1, int y1, int x2, int y2) { IupDrawRectangle(_ih, x1, y1, x2, y2); }
777     void DrawArc(int x1, int y1, int x2, int y2, double a1, double a2) { IupDrawArc(_ih, x1, y1, x2, y2, a1, a2); }
778     void DrawPolygon(int* points, int count) { IupDrawPolygon(_ih, points, count); }
779     void DrawText(const(char)* text, int len, int x, int y) { IupDrawText(_ih, text, len, x, y); }
780     void DrawImage(const(char)* name, int make_inactive, int x, int y) { IupDrawImage(_ih, name, make_inactive, x, y); }
781     void DrawSelectRect(int x1, int y1, int x2, int y2) { IupDrawSelectRect(_ih, x1, y1, x2, y2); }
782     void DrawFocusRect(int x1, int y1, int x2, int y2) { IupDrawFocusRect(_ih, x1, y1, x2, y2); }
783     void DrawGetSize(ref int w, ref int h) { IupDrawGetSize(_ih, &w, &h); }
784     void DrawGetTextSize(const(char)* str, ref int w, ref int h) { IupDrawGetTextSize(_ih, str, &w, &h); }
785     void DrawGetImageInfo(const(char)* name, ref int w, ref int h, ref int bpp) { IupDrawGetImageInfo(name, &w, &h, &bpp); }
786   }
787 
788 class Frame : Container
789 {
790   nothrow:
791   this()              { super(IupFrame(null)); }
792   this(Control child) { super(IupFrame(child.GetHandle)); }
793 }
794 
795 
796 class FlatFrame : Container
797 {
798   nothrow:
799   this()              { super(IupFlatFrame(null)); }
800   this(Control child) { super(IupFlatFrame(child.GetHandle)); }
801 }
802 deprecated class Spinbox : Container
803 {
804   nothrow:
805   this()              { super(IupSpinbox(null)); }
806   this(Control child) { super(IupSpinbox(child.GetHandle())); }
807 }
808 
809 class Vbox : Container //TODO do care for last element/child=null
810 {
811   nothrow:
812   this()              { super(IupVbox(null)); }
813   this(Ihandle* ih)   { super(ih); } // temporarily
814   this(Control child) { super(IupVbox(child.GetHandle, null)); }
815   this(Control child0, Control child1 = null, Control child2 = null, Control child3 = null, Control child4 = null,
816     Control child5 = null, Control child6 = null, Control child7 = null, Control child8 = null, Control child9 = null)
817     { super(IupVbox(null), child0, child1, child2, child3, child4, child5, child6, child7, child8, child9); }
818 
819   this(           Control[] child_array, FILL_TYPE fill=FILL_TYPE.FILL_NONE) { super(IupVbox(null), child_array, fill); }
820   this(string CN, Control[] child_array, FILL_TYPE fill=FILL_TYPE.FILL_NONE) { this(child_array, fill); if (!CN.empty) { AA[CN] = this; IupSetHandle(CN.toStringz, _ih); } }
821 }
822 
823 class Hbox : Container
824 {
825   nothrow:
826   this()              { super(IupHbox(null)); }
827   this(Ihandle* ih)   { super(ih); } // temporarily
828   this(Control child) { super(IupHbox(child.GetHandle, null)); }
829 
830   this(Control child0, Control child1 = null, Control child2 = null, Control child3 = null, Control child4 = null,
831      Control child5 = null, Control child6 = null, Control child7 = null, Control child8 = null, Control child9 = null)
832     { super(IupHbox(null), child0, child1, child2, child3, child4, child5, child6, child7, child8, child9); }
833   this(string CN, Control child0, Control child1 = null, Control child2 = null, Control child3 = null, Control child4 = null,
834     Control child5 = null, Control child6 = null, Control child7 = null, Control child8 = null, Control child9 = null)
835     { this(child0, child1, child2, child3, child4, child5, child6, child7, child8, child9);
836       if (!CN.empty) { AA[CN] = this; IupSetHandle(CN.toStringz, _ih); } }
837 
838   this(           Control[] child_array, FILL_TYPE fill=FILL_TYPE.FILL_NONE) { super(IupHbox(null), child_array, fill); }
839   this(string CN, Control[] child_array, FILL_TYPE fill=FILL_TYPE.FILL_NONE) { this(child_array, fill); if (!CN.empty) { AA[CN] = this; IupSetHandle(CN.toStringz, _ih); } }
840 }
841 
842   class Zbox : Container
843   {
844     nothrow:
845     this() { super(IupZbox(null)); }
846     this(Control child) { super(IupZbox(child.GetHandle(), null)); }
847     this(Control child0, Control child1 = null, Control child2 = null, Control child3 = null, Control child4 = null,
848       Control child5 = null, Control child6 = null, Control child7 = null, Control child8 = null, Control child9 = null)
849       { super(IupZbox(null), child0, child1, child2, child3, child4, child5, child6, child7, child8, child9); }
850     this(Control[] child_array) { super(IupZbox(null), child_array); }
851   }
852 
853   class Cbox : Container
854   {
855     nothrow:
856     this() { super(IupCbox(null)); }
857     this(Control child) { super(IupCbox(child.GetHandle(), null)); }
858     this(Control child0, Control child1 = null, Control child2 = null, Control child3 = null, Control child4 = null,
859       Control child5 = null, Control child6 = null, Control child7 = null, Control child8 = null, Control child9 = null)
860       { super(IupCbox(null), child0, child1, child2, child3, child4, child5, child6, child7, child8, child9); }
861     this(Control[] child_array) { super(IupCbox(null), child_array); }
862   }
863 
864 
865 class Tabs : Container
866 {
867   nothrow:
868   this()                        { super(IupTabs(null)); }
869   this(Ihandle* ih)             { super(ih); } // temporarily
870   this(string CN, Ihandle* ih)  { super(ih); if (!CN.empty) { AA[CN] = this; IupSetHandle(CN.toStringz, _ih); } } // temporarily
871   this(Control child) { super(IupTabs(child.GetHandle(), null)); }
872   this(Control child0, Control child1 = null, Control child2 = null, Control child3 = null, Control child4 = null,
873     Control child5 = null, Control child6 = null, Control child7 = null, Control child8 = null, Control child9 = null)
874     { super(IupTabs(null), child0, child1, child2, child3, child4, child5, child6, child7, child8, child9); }
875   this(           Control[] child_array) { super(IupTabs(null), child_array); }
876   this(string CN, Control[] child_array) { this(child_array); if (!CN.empty) { AA[CN] = this; IupSetHandle(CN.toStringz, _ih); } }
877 }
878 
879 class GridBox : Container
880 {
881   nothrow:
882   this() { super(IupGridBox(null)); }
883   this(Control child) { super(IupGridBox(child.GetHandle(), null)); }
884   this(Control child0, Control child1 = null, Control child2 = null, Control child3 = null, Control child4 = null,
885     Control child5 = null, Control child6 = null, Control child7 = null, Control child8 = null, Control child9 = null)
886     { super(IupGridBox(null), child0, child1, child2, child3, child4, child5, child6, child7, child8, child9); }
887   this(Control[] child_array) { super(IupGridBox(null), child_array); }
888 }
889 
890 class ParamBox : Container
891 {
892   nothrow:
893   this() { super(IupParamBox(null)); }
894   this(Control child) { super(IupParamBox(child.GetHandle(), null)); }
895   this(Control child0, Control child1 = null, Control child2 = null, Control child3 = null, Control child4 = null,
896     Control child5 = null, Control child6 = null, Control child7 = null, Control child8 = null, Control child9 = null)
897     { super(IupParamBox(child0.GetHandle(), child1.GetHandle(), child2.GetHandle(), child3.GetHandle(), child4.GetHandle(),
898     child5.GetHandle(), child6.GetHandle(), child7.GetHandle(), child8.GetHandle(), child9.GetHandle(), null)); }
899 }
900 
901   class Normalizer : Container
902   {
903     nothrow:
904     this() { super(IupNormalizer(null)); }
905     this(Control child) { super(IupNormalizer(child.GetHandle(), null)); }
906     this(Control child0, Control child1 = null, Control child2 = null, Control child3 = null, Control child4 = null,
907       Control child5 = null, Control child6 = null, Control child7 = null, Control child8 = null, Control child9 = null)
908       { super(IupNormalizer(null), child0, child1, child2, child3, child4, child5, child6, child7, child8, child9); }
909     this(Control[] child_array) { super(IupNormalizer(null), child_array); }
910   }
911 
912 
913 class FileDialog : Dialog
914 {
915   nothrow:
916   this() { super(IupFileDlg); }
917 }
918 
919 class MessageDialog : Dialog
920 {
921   nothrow:
922   this(bool autoDestroy = true) { super(autoDestroy, IupMessageDlg()); }
923 }
924 
925 class ColorDialog : Dialog
926 {
927   nothrow:
928   this() { super(IupColorDlg); }
929 }
930 
931 class FontDialog : Dialog
932 {
933   nothrow:
934   this() { super(IupFontDlg); }
935 }
936 
937 class ProgressDialog : Dialog
938 {
939   nothrow:
940   this() { super(IupProgressDlg); }
941 }
942 
943 version(IUP_SCINTILLA)
944 {
945 class ScintillaDlg : Dialog
946 {
947   public import iup.iup_scintilla;
948   nothrow:
949   this() { super(IupScintillaDlg()); }
950 }
951 }
952 /+
953 #ifdef LUA_VERSION
954   public:
955     LuaScripterDlg(lua_State *L) : Dialog(IupLuaScripterDlg(L)) {}
956   };
957 #endif
958 +/
959 version(IUP_GL)
960 {
961   public import iup.iupgl;
962 
963   class GLCanvas : Control
964   {
965     nothrow:
966     this() { super(IupGLCanvas(null)); }
967 
968     static void Open() { IupGLCanvasOpen; }
969 
970     void MakeCurrent() { IupGLMakeCurrent(_ih); }
971     int IsCurrent() { return IupGLIsCurrent(_ih); }
972     void SwapBuffers() { IupGLSwapBuffers(_ih); }
973     void Palette(int index, float r, float g, float b) { IupGLPalette(_ih, index, r, g, b); }
974     void UseFont(int first, int count, int list_base) { IupGLUseFont(_ih, first, count, list_base); }
975 
976     static void Wait(int gl) { IupGLWait(gl); }
977   }
978 
979   class GLBackgroundBox : Container
980   {
981     nothrow:
982     this() { super(IupGLBackgroundBox(null)); }
983     this(Control child) { super(IupGLBackgroundBox(child.GetHandle)); }
984   }
985 }
986 /+
987   class Controls
988   {
989     static void Open() { IupControlsOpen(); }
990   }
991 +/
992 class Dial : Control
993 {
994   nothrow:
995   this(const(char)* orientation = null) { super(IupDial(orientation)); }
996 }
997 
998 class Gauge : Control
999 {
1000   nothrow:
1001   this() { super(IupGauge); }
1002 }
1003 
1004 class ColorBrowser : Control
1005 {
1006   nothrow:
1007   this() { super(IupColorBrowser); }
1008 }
1009 
1010 class Cells : Control
1011 {
1012   nothrow:
1013   this() { super(IupCells); }
1014 }
1015 
1016 class Colorbar : Control
1017 {
1018   nothrow:
1019   this() { super(IupColorbar); }
1020 }
1021 
1022 class Matrix : Control
1023 {
1024   nothrow:
1025   this()          { super(IupMatrix(null)); }
1026   this(string CN) { this(); if (!CN.empty) { AA[CN] = this; IupSetHandle(CN.toStringz, _ih); } }
1027 
1028 //  void SetFormula(int col, const(char)* formula, const(char)* init = null) { IupMatrixSetFormula(_ih, col, formula, init); }
1029 //  void SetDynamic(const(char)* init = null) { IupMatrixSetDynamic(_ih, init); }
1030 }
1031 
1032 class MatrixList : Control
1033 {
1034   nothrow:
1035   this()          { super(IupMatrixList); }
1036   this(string CN) { this(); if (!CN.empty) { AA[CN] = this; IupSetHandle(CN.toStringz, _ih); } }
1037 }
1038 
1039 version(none/*IUP_MATRIXEX*/) {
1040 /+
1041   public import iup.iupmatrixex;
1042 
1043   class MatrixEx : Control
1044   {
1045     nothrow:
1046     this() { super(IupMatrixEx); }
1047 
1048     static void Open() { IupMatrixExOpen; }
1049   }
1050 +/
1051 }
1052 
1053 version(IUP_GLCONTROLS)
1054 {
1055   public import iup.iupglcontrols;
1056 
1057 /+
1058   class GLControls
1059   {
1060     static void Open() { IupGLControlsOpen(); }
1061   }
1062 +/
1063 
1064   class GLSubCanvas : Control
1065   {
1066     nothrow:
1067     this() { super(IupGLSubCanvas); }
1068   }
1069 
1070   class GLSeparator : Control
1071   {
1072     nothrow:
1073     this() { super(IupGLSeparator); }
1074   }
1075 
1076   class GLProgressBar : Control
1077   {
1078     nothrow:
1079     this() { super(IupGLProgressBar); }
1080   }
1081 
1082   class GLVal : Control
1083   {
1084     nothrow:
1085     this() { super(IupGLVal); }
1086   }
1087 
1088   class GLLabel : Control
1089   {
1090     nothrow:
1091     this(const(char)* title = null) { super(IupGLLabel(title)); }
1092   }
1093 
1094   class GLButton : Control
1095   {
1096     nothrow:
1097     this(const(char)* title = null) { super(IupGLButton(title)); }
1098   }
1099 
1100   class GLToggle : Control
1101   {
1102     nothrow:
1103     this(const(char)* title = null) { super(IupGLToggle(title)); }
1104   }
1105 
1106   class GLLink : Control
1107   {
1108     nothrow:
1109     this(const(char)* url = null, const(char)* title = null) { super(IupGLLink(url, title)); }
1110   }
1111 
1112   class GLFrame : Container
1113   {
1114     nothrow:
1115     this(Control child) { super(IupGLFrame(child.GetHandle)); }
1116     this() { super(IupGLFrame(null)); }
1117   }
1118 
1119   class GLExpander : Container
1120   {
1121     nothrow:
1122     this(Control child) { super(IupGLExpander(child.GetHandle)); }
1123     this() { super(IupGLExpander(null)); }
1124   }
1125 
1126   class GLScrollBox : Container
1127   {
1128     nothrow:
1129     this(Control child) { super(IupGLScrollBox(child.GetHandle)); }
1130     this() { super(IupGLScrollBox(null)); }
1131   }
1132 
1133   class GLSizeBox : Container
1134   {
1135     nothrow:
1136     this(Control child) { super(IupGLSizeBox(child.GetHandle)); }
1137     this() { super(IupGLSizeBox(null)); }
1138   }
1139 
1140   class GLCanvasBox : Container
1141   {
1142     nothrow:
1143     this() { super(IupGLCanvasBox(null)); }
1144     this(Control child) { super(IupGLCanvasBox(child.GetHandle(), null)); }
1145     this(Control child0, Control child1 = null, Control child2 = null, Control child3 = null, Control child4 = null,
1146       Control child5 = null, Control child6 = null, Control child7 = null, Control child8 = null, Control child9 = null)
1147       { super(IupGLCanvasBox(null), child0, child1, child2, child3, child4, child5, child6, child7, child8, child9); }
1148     this(Control[] child_array) { super(IupGLCanvasBox(null), child_array); }
1149   }
1150 
1151 } // version(IUP_GLCONTROLS)
1152 
1153 version(IUP_PLOT) {
1154   public import iup.iup_plot;
1155 
1156   class Plot : Control
1157   {
1158     nothrow:
1159     this() { super(IupPlot); }
1160 
1161     static void Open() { IupPlotOpen; }
1162 
1163     void Begin(int strXdata) { IupPlotBegin(_ih, strXdata); }
1164     void Add(double x, double y) { IupPlotAdd(_ih, x, y); }
1165     void AddStr(const(char)* x, double y) { IupPlotAddStr(_ih, x, y); }
1166     void AddSegment(double x, double y) { IupPlotAddSegment(_ih, x, y); }
1167     int End() { return IupPlotEnd(_ih); }
1168 
1169     int LoadData(const(char)* filename, int strXdata) { return IupPlotLoadData(_ih, filename, strXdata); }
1170 
1171 //  int SetFormula(int sample_count, const(char)* formula, const(char)* init) { return IupPlotSetFormula(_ih, sample_count, formula, init); }
1172 
1173     void Insert(int ds_index, int sample_index, double x, double y) { IupPlotInsert(_ih, ds_index, sample_index, x, y); }
1174     void InsertStr(int ds_index, int sample_index, const(char)* x, double y) { IupPlotInsertStr(_ih, ds_index, sample_index, x, y); }
1175     void InsertSegment(int ds_index, int sample_index, double x, double y) { IupPlotInsertSegment(_ih, ds_index, sample_index, x, y); }
1176 
1177     void InsertStrSamples(int ds_index, int sample_index, const(char)** x, double* y, int count) { IupPlotInsertStrSamples(_ih, ds_index, sample_index, x, y, count); }
1178     void InsertSamples(int ds_index, int sample_index, double* x, double* y, int count) { IupPlotInsertSamples(_ih, ds_index, sample_index, x, y, count); }
1179 
1180     void AddSamples(int ds_index, double* x, double* y, int count) { IupPlotAddSamples(_ih, ds_index, x, y, count); }
1181     void AddStrSamples(int ds_index, const(char)** x, double* y, int count) { IupPlotAddStrSamples(_ih, ds_index, x, y, count); }
1182 
1183     void GetSample(int ds_index, int sample_index, ref double x, ref double y) { IupPlotGetSample(_ih, ds_index, sample_index, &x, &y); }
1184     void GetSampleStr(int ds_index, int sample_index, const(char)** x, ref double y) { IupPlotGetSampleStr(_ih, ds_index, sample_index, x, &y); }
1185     int GetSampleSelection(int ds_index, int sample_index) { return IupPlotGetSampleSelection(_ih, ds_index, sample_index); }
1186     double GetSampleExtra(int ds_index, int sample_index) { return IupPlotGetSampleExtra(_ih, ds_index, sample_index); }
1187     void SetSample(int ds_index, int sample_index, double x, double y) { IupPlotSetSample(_ih, ds_index, sample_index, x, y); }
1188     void SetSampleStr(int ds_index, int sample_index, const(char)* x, double y) { IupPlotSetSampleStr(_ih, ds_index, sample_index, x, y); }
1189     void SetSampleSelection(int ds_index, int sample_index, int selected) { IupPlotSetSampleSelection(_ih, ds_index, sample_index, selected); }
1190     void SetSampleExtra(int ds_index, int sample_index, double extra) { IupPlotSetSampleExtra(_ih, ds_index, sample_index, extra); }
1191 
1192     void Transform(double x, double y, ref double cnv_x, ref double cnv_y) { IupPlotTransform(_ih, x, y, &cnv_x, &cnv_y); }
1193     void TransformTo(double cnv_x, double cnv_y, ref double x, ref double y) { IupPlotTransformTo(_ih, cnv_x, cnv_y, &x, &y); }
1194 
1195     int FindSample(double cnv_x, double cnv_y, ref int ds_index, ref int sample_index) { return IupPlotFindSample(_ih, cnv_x, cnv_y, &ds_index, &sample_index); }
1196 
1197     version(CD) void PaintTo(cd.cd_plusD.Canvas cd_canvas) { IupPlotPaintTo(_ih, cd_canvas.GetHandle()); }
1198   } // class Plot
1199 } // version(IUP_PLOT)
1200 
1201 version(IUP_MGLPLOT) {
1202   import iup.iup_mglplot;
1203 
1204   class MglPlot : Control
1205   {
1206     nothrow:
1207     this() { super(IupMglPlot); }
1208 
1209     static void Open() { IupMglPlotOpen; }
1210 
1211     void Begin(int dim) { IupMglPlotBegin(_ih, dim); }
1212     void Add1D(const(char)* name, double y) { IupMglPlotAdd1D(_ih, name, y); }
1213     void Add2D(double x, double y) { IupMglPlotAdd2D(_ih, x, y); }
1214     void Add3D(double x, double y, double z) { IupMglPlotAdd3D(_ih, x, y, z); }
1215     int End() { return IupMglPlotEnd(_ih); }
1216 
1217     int NewDataSet(int dim) { return IupMglPlotNewDataSet(_ih, dim); }
1218 
1219     void Insert1D(int ds_index, int sample_index, const(char)** names, const double* y, int count) { IupMglPlotInsert1D(_ih, ds_index, sample_index, names, y, count); }
1220     void Insert2D(int ds_index, int sample_index, const double* x, const double* y, int count) { IupMglPlotInsert2D(_ih, ds_index, sample_index, x, y, count); }
1221     void Insert3D(int ds_index, int sample_index, const double* x, const double* y, const double* z, int count) { IupMglPlotInsert3D(_ih, ds_index, sample_index, x, y, z, count); }
1222 
1223     void Set1D(int ds_index, const(char)** names, const double* y, int count) { IupMglPlotSet1D(_ih, ds_index, names, y, count); }
1224     void Set2D(int ds_index, const double* x, const double* y, int count) { IupMglPlotSet2D(_ih, ds_index, x, y, count); }
1225     void Set3D(int ds_index, const double* x, const double* y, const double* z, int count) { IupMglPlotSet3D(_ih, ds_index, x, y, z, count); }
1226     void SetFormula(int ds_index, const(char)* formulaX, const(char)* formulaY, const(char)* formulaZ, int count) { IupMglPlotSetFormula(_ih, ds_index, formulaX, formulaY, formulaZ, count); }
1227 
1228     void SetData(int ds_index, const double* data, int count_x, int count_y, int count_z) { IupMglPlotSetData(_ih, ds_index, data, count_x, count_y, count_z); }
1229     void LoadData(int ds_index, const(char)* filename, int count_x, int count_y, int count_z) { IupMglPlotLoadData(_ih, ds_index, filename, count_x, count_y, count_z); }
1230     void SetFromFormula(int ds_index, const(char)* formula, int count_x, int count_y, int count_z) { IupMglPlotSetFromFormula(_ih, ds_index, formula, count_x, count_y, count_z); }
1231 
1232     void Transform(double x, double y, double z, ref int ix, ref int iy) { IupMglPlotTransform(_ih, x, y, z, &ix, &iy); }
1233     void TransformTo(int ix, int iy, ref double x, ref double y, ref double z) { IupMglPlotTransformTo(_ih, ix, iy, &x, &y, &z); }
1234 
1235     void DrawMark(double x, double y, double z) { IupMglPlotDrawMark(_ih, x, y, z); }
1236     void DrawLine(double x1, double y1, double z1, double x2, double y2, double z2) { IupMglPlotDrawLine(_ih, x1, y1, z1, x2, y2, z2); }
1237     void DrawText(const(char)* text, double x, double y, double z) { IupMglPlotDrawText(_ih, text, x, y, z); }
1238 
1239     void PaintTo(const(char)* format, int w, int h, double dpi, ubyte* data) { IupMglPlotPaintTo(_ih, format, w, h, dpi, cast(void*)data); }
1240     void PaintTo(const(char)* format, int w, int h, double dpi, const(char)* filename) { IupMglPlotPaintTo(_ih, format, w, h, dpi, cast(void*)filename); }
1241 
1242   }
1243 
1244   class MglLabel : Control
1245   {
1246     nothrow:
1247     this(const(char)* title) { super(IupMglLabel(title)); }
1248   }
1249 }
1250 
1251 version(Windows) { version(IUP_OLE) {
1252   public import iup.iupole;
1253 
1254   class OleControl : Control
1255   {
1256     nothrow:
1257     this(const(char)* progid) { super(IupOleControl(progid)); }
1258 
1259     static void Open() { IupOleControlOpen; }
1260  }
1261 } }
1262 
1263 version(IUP_WEB) {
1264   public import iup.iupweb;
1265 
1266   class WebBrowser : Control
1267   {
1268     nothrow:
1269     this() { super(IupWebBrowser); }
1270 
1271     static void Open() { IupWebBrowserOpen; }
1272   }
1273 }
1274 
1275 
1276 version(IUP_SCINTILLA) {
1277   public import iup.iup_scintilla;
1278 
1279   class Scintilla : Control
1280   {
1281     nothrow:
1282     this() { super(IupScintilla); }
1283 
1284     static void Open() { IupScintillaOpen; }
1285   }
1286 }
1287 
1288 version(IUP_TUIO) {
1289   public import iup.iuptuio;
1290 
1291   class TuioClient : Handle
1292   {
1293     nothrow:
1294     this(int port) { super(IupTuioClient(port)); }
1295 
1296     static void Open() { IupTuioOpen; }
1297   }
1298 }
1299 
1300 class Config : Handle
1301 {
1302   nothrow:
1303   this()          { super(IupConfig); }
1304 //  this(string CN) { this(); if (!CN.empty) { AA[CN] = this; IupSetHandle(CN.toStringz, _ih); } }
1305 
1306   int LoadConfig() { return IupConfigLoad(_ih); }
1307   int SaveConfig() { return IupConfigSave(_ih); }
1308 
1309   void SetVariableStrId(const(char)* group, const(char)* key, int id, const(char)* value) { IupConfigSetVariableStrId(_ih, group, key, id, value); }
1310   void SetVariableIntId(const(char)* group, const(char)* key, int id, int value) { IupConfigSetVariableIntId(_ih, group, key, id, value); }
1311   void SetVariableDoubleId(const(char)* group, const(char)* key, int id, double value) { IupConfigSetVariableDoubleId(_ih, group, key, id, value); }
1312   void SetVariableStr(const(char)* group, const(char)* key, const(char)* value) { IupConfigSetVariableStr(_ih, group, key, value); }
1313   void SetVariableInt(const(char)* group, const(char)* key, int value) { IupConfigSetVariableInt(_ih, group, key, value); }
1314   void SetVariableDouble(const(char)* group, const(char)* key, double value) { IupConfigSetVariableDouble(_ih, group, key, value); }
1315 
1316   char* GetVariableStr(const(char)* group, const(char)* key) { return cast(char*)IupConfigGetVariableStr(_ih, group, key); }
1317   int GetVariableInt(const(char)* group, const(char)* key) { return IupConfigGetVariableInt(_ih, group, key); }
1318   double GetVariableDouble(const(char)* group, const(char)* key) { return IupConfigGetVariableDouble(_ih, group, key); }
1319   char* GetVariableStrId(const(char)* group, const(char)* key, int id) { return cast(char*)IupConfigGetVariableStrId(_ih, group, key, id); }
1320   int GetVariableIntId(const(char)* group, const(char)* key, int id) { return IupConfigGetVariableIntId(_ih, group, key, id); }
1321   double GetVariableDoubleId(const(char)* group, const(char)* key, int id) { return IupConfigGetVariableDoubleId(_ih, group, key, id); }
1322 
1323   char* GetVariableStrDef(const(char)* group, const(char)* key, const(char)* def) { return cast(char*)IupConfigGetVariableStrDef(_ih, group, key, def); }
1324   int GetVariableIntDef(const(char)* group, const(char)* key, int def) { return IupConfigGetVariableIntDef(_ih, group, key, def); }
1325   double GetVariableDoubleDef(const(char)* group, const(char)* key, double def) { return IupConfigGetVariableDoubleDef(_ih, group, key, def); }
1326   char* GetVariableStrIdDef(const(char)* group, const(char)* key, int id, const(char)* def) { return cast(char*)IupConfigGetVariableStrIdDef(_ih, group, key, id, def); }
1327   int GetVariableIntIdDef(const(char)* group, const(char)* key, int id, int def) { return IupConfigGetVariableIntIdDef(_ih, group, key, id, def); }
1328   double GetVariableDoubleIdDef(const(char)* group, const(char)* key, int id, double def) { return IupConfigGetVariableDoubleIdDef(_ih, group, key, id, def); }
1329 
1330   void Copy(Config config2, const(char)* exclude_prefix) { IupConfigCopy(_ih, config2.GetHandle(), exclude_prefix); }
1331 
1332   void SetListVariable(const(char)* group, const(char)* key, const(char)* value, int add) { IupConfigSetListVariable(_ih, group, key, value, add); }
1333 
1334   void RecentInit(Menu menu, Icallback recent_cb, int max_recent) { IupConfigRecentInit(_ih, menu.GetHandle(), recent_cb, max_recent); }
1335   void RecentUpdate(const(char)* filename) { IupConfigRecentUpdate(_ih, filename); }
1336 
1337   void DialogShow(Dialog dialog, const(char)* name) { IupConfigDialogShow(_ih, dialog.GetHandle(), name); }
1338   void DialogClosed(Dialog dialog, const(char)* name) { IupConfigDialogClosed(_ih, dialog.GetHandle(), name); }
1339 }
1340 
1341 //} // namespace iup
1342 
1343 
1344 version(CD) //#ifdef __CD_PLUS_H
1345 { // was in C++ namespace cd
1346   import cd.cd_plusD;
1347 
1348   class CanvasIup : cd.cd_plusD.Canvas // public Canvas
1349   {
1350     nothrow:
1351     this(iup.iup_plusD.Canvas iup_canvas) { // CanvasIup(Iup::Canvas& iup_canvas) : Canvas() { ... }
1352       super();
1353       canvas = cdCreateCanvas(CD_IUP, iup_canvas.GetHandle());
1354     }
1355   }
1356 
1357   class CanvasIupDoubleBuffer : cd.cd_plusD.Canvas // public Canvas
1358   {
1359     nothrow:
1360     this(iup.iup_plusD.Canvas iup_canvas) { // CanvasIupDoubleBuffer(Iup::Canvas& iup_canvas) : Canvas() { ... }
1361       super();
1362       canvas = cdCreateCanvas(CD_IUPDBUFFER, iup_canvas.GetHandle());
1363     }
1364   }
1365 
1366   class CanvasIupDoubleBufferRGB : cd.cd_plusD.Canvas // public Canvas
1367   {
1368     nothrow:
1369     this(iup.iup_plusD.Canvas iup_canvas) { // CanvasIupDoubleBufferRGB(Iup::Canvas& iup_canvas) : Canvas() { ... }
1370       super();
1371       canvas = cdCreateCanvas(CD_IUPDBUFFERRGB, iup_canvas.GetHandle());
1372     }
1373   }
1374 } // version(CD)