1 module iup.iup; 2 3 enum const(char) * IUP_NAME = "IUP - Portable User Interface"; 4 enum const(char) * IUP_DESCRIPTION = "Multi-platform Toolkit for Building Graphical User Interfaces"; 5 enum const(char) * IUP_COPYRIGHT = "Copyright (C) 1994-2016 Tecgraf/PUC-Rio"; 6 enum const(char) * IUP_VERSION = "3.18" /* bug fixes are reported only by IupVersion functions */; 7 enum IUP_VERSION_NUMBER = 318000; 8 enum const(char) * IUP_VERSION_DATE = "2016/03/21" /* does not include bug fix releases */; 9 10 extern(C) { 11 struct Ihandle_; 12 alias Ihandle = Ihandle_; 13 alias Icallback = int function(Ihandle *); 14 15 /************************************************************************/ 16 /* Main API */ 17 /************************************************************************/ 18 19 int IupOpen (int *argc, char ***argv); 20 void IupClose (); 21 void IupImageLibOpen (); 22 23 int IupMainLoop (); 24 int IupLoopStep (); 25 int IupLoopStepWait (); 26 int IupMainLoopLevel (); 27 void IupFlush (); 28 void IupExitLoop (); 29 30 int IupRecordInput(const(char) * filename, int mode); 31 int IupPlayInput(const(char) * filename); 32 33 void IupUpdate (Ihandle* ih); 34 void IupUpdateChildren(Ihandle* ih); 35 void IupRedraw (Ihandle* ih, int children); 36 void IupRefresh (Ihandle* ih); 37 void IupRefreshChildren(Ihandle* ih); 38 39 int IupExecute(const(char) *filename, const(char) * parameters); 40 int IupHelp(const(char) * url); 41 42 char* IupLoad (const(char) *filename); 43 char* IupLoadBuffer (const(char) *buffer); 44 45 char* IupVersion (); 46 char* IupVersionDate (); 47 int IupVersionNumber (); 48 49 void IupSetLanguage (const(char) *lng); 50 char* IupGetLanguage (); 51 void IupSetLanguageString(const(char) * name, const(char) * str); 52 void IupStoreLanguageString(const(char) * name, const(char) * str); 53 char* IupGetLanguageString(const(char) * name); 54 void IupSetLanguagePack(Ihandle* ih); 55 56 void IupDestroy (Ihandle* ih); 57 void IupDetach (Ihandle* child); 58 Ihandle* IupAppend (Ihandle* ih, Ihandle* child); 59 Ihandle* IupInsert (Ihandle* ih, Ihandle* ref_child, Ihandle* child); 60 Ihandle* IupGetChild (Ihandle* ih, int pos); 61 int IupGetChildPos (Ihandle* ih, Ihandle* child); 62 int IupGetChildCount(Ihandle* ih); 63 Ihandle* IupGetNextChild (Ihandle* ih, Ihandle* child); 64 Ihandle* IupGetBrother (Ihandle* ih); 65 Ihandle* IupGetParent (Ihandle* ih); 66 Ihandle* IupGetDialog (Ihandle* ih); 67 Ihandle* IupGetDialogChild(Ihandle* ih, const(char) * name); 68 int IupReparent (Ihandle* ih, Ihandle* new_parent, Ihandle* ref_child); 69 70 int IupPopup (Ihandle* ih, int x, int y); 71 int IupShow (Ihandle* ih); 72 int IupShowXY (Ihandle* ih, int x, int y); 73 int IupHide (Ihandle* ih); 74 int IupMap (Ihandle* ih); 75 void IupUnmap (Ihandle *ih); 76 77 void IupResetAttribute(Ihandle *ih, const(char) * name); 78 int IupGetAllAttributes(Ihandle* ih, char** names, int n); 79 Ihandle* IupSetAtt(const(char) * handle_name, Ihandle* ih, const(char) * name, ...); 80 Ihandle* IupSetAttributes (Ihandle* ih, const(char) *str); 81 char* IupGetAttributes (Ihandle* ih); 82 83 void IupSetAttribute (Ihandle* ih, const(char) * name, const(char) * value); 84 void IupSetStrAttribute(Ihandle* ih, const(char) * name, const(char) * value); 85 void IupSetStrf (Ihandle* ih, const(char) * name, const(char) * format, ...); 86 void IupSetInt (Ihandle* ih, const(char) * name, int value); 87 void IupSetFloat (Ihandle* ih, const(char) * name, float value); 88 void IupSetDouble (Ihandle* ih, const(char) * name, double value); 89 void IupSetRGB (Ihandle *ih, const(char) * name, ubyte r, ubyte g, ubyte b); 90 91 char* IupGetAttribute(Ihandle* ih, const(char) * name); 92 int IupGetInt (Ihandle* ih, const(char) * name); 93 int IupGetInt2 (Ihandle* ih, const(char) * name); 94 int IupGetIntInt (Ihandle *ih, const(char) * name, int *i1, int *i2); 95 float IupGetFloat (Ihandle* ih, const(char) * name); 96 double IupGetDouble(Ihandle* ih, const(char) * name); 97 void IupGetRGB (Ihandle *ih, const(char) * name, ubyte *r, ubyte *g, ubyte *b); 98 99 void IupSetAttributeId(Ihandle *ih, const(char) * name, int id, const(char) *value); 100 void IupSetStrAttributeId(Ihandle *ih, const(char) * name, int id, const(char) *value); 101 void IupSetStrfId(Ihandle *ih, const(char) * name, int id, const(char) * format, ...); 102 void IupSetIntId(Ihandle* ih, const(char) * name, int id, int value); 103 void IupSetFloatId(Ihandle* ih, const(char) * name, int id, float value); 104 void IupSetDoubleId(Ihandle* ih, const(char) * name, int id, double value); 105 void IupSetRGBId(Ihandle *ih, const(char) * name, int id, ubyte r, ubyte g, ubyte b); 106 107 char* IupGetAttributeId(Ihandle *ih, const(char) * name, int id); 108 int IupGetIntId(Ihandle *ih, const(char) * name, int id); 109 float IupGetFloatId(Ihandle *ih, const(char) * name, int id); 110 double IupGetDoubleId(Ihandle *ih, const(char) * name, int id); 111 void IupGetRGBId(Ihandle *ih, const(char) * name, int id, ubyte *r, ubyte *g, ubyte *b); 112 113 void IupSetAttributeId2(Ihandle* ih, const(char) * name, int lin, int col, const(char) * value); 114 void IupSetStrAttributeId2(Ihandle* ih, const(char) * name, int lin, int col, const(char) * value); 115 void IupSetStrfId2(Ihandle* ih, const(char) * name, int lin, int col, const(char) * format, ...); 116 void IupSetIntId2(Ihandle* ih, const(char) * name, int lin, int col, int value); 117 void IupSetFloatId2(Ihandle* ih, const(char) * name, int lin, int col, float value); 118 void IupSetDoubleId2(Ihandle* ih, const(char) * name, int lin, int col, double value); 119 void IupSetRGBId2(Ihandle *ih, const(char) * name, int lin, int col, ubyte r, ubyte g, ubyte b); 120 121 char* IupGetAttributeId2(Ihandle* ih, const(char) * name, int lin, int col); 122 int IupGetIntId2(Ihandle* ih, const(char) * name, int lin, int col); 123 float IupGetFloatId2(Ihandle* ih, const(char) * name, int lin, int col); 124 double IupGetDoubleId2(Ihandle* ih, const(char) * name, int lin, int col); 125 void IupGetRGBId2(Ihandle *ih, const(char) * name, int lin, int col, ubyte *r, ubyte *g, ubyte *b); 126 127 void IupSetGlobal (const(char) * name, const(char) * value); 128 void IupSetStrGlobal(const(char) * name, const(char) * value); 129 char* IupGetGlobal (const(char) * name); 130 131 Ihandle* IupSetFocus (Ihandle* ih); 132 Ihandle* IupGetFocus (); 133 Ihandle* IupPreviousField(Ihandle* ih); 134 Ihandle* IupNextField (Ihandle* ih); 135 136 Icallback IupGetCallback (Ihandle* ih, const(char) *name); 137 Icallback IupSetCallback (Ihandle* ih, const(char) *name, Icallback func); 138 Ihandle* IupSetCallbacks(Ihandle* ih, const(char) *name, Icallback func, ...); 139 140 Icallback IupGetFunction(const(char) *name); 141 Icallback IupSetFunction(const(char) *name, Icallback func); 142 143 Ihandle* IupGetHandle (const(char) *name); 144 Ihandle* IupSetHandle (const(char) *name, Ihandle* ih); 145 int IupGetAllNames (char** names, int n); 146 int IupGetAllDialogs(char** names, int n); 147 char* IupGetName (Ihandle* ih); 148 149 void IupSetAttributeHandle(Ihandle* ih, const(char) * name, Ihandle* ih_named); 150 Ihandle* IupGetAttributeHandle(Ihandle* ih, const(char) * name); 151 152 char* IupGetClassName(Ihandle* ih); 153 char* IupGetClassType(Ihandle* ih); 154 int IupGetAllClasses(char** names, int n); 155 int IupGetClassAttributes(const(char) * classname, char** names, int n); 156 int IupGetClassCallbacks(const(char) * classname, char** names, int n); 157 void IupSaveClassAttributes(Ihandle* ih); 158 void IupCopyClassAttributes(Ihandle* src_ih, Ihandle* dst_ih); 159 void IupSetClassDefaultAttribute(const(char) * classname, const(char) *name, const(char) * value); 160 int IupClassMatch(Ihandle* ih, const(char) * classname); 161 162 Ihandle* IupCreate (const(char) *classname); 163 Ihandle* IupCreatev(const(char) *classname, void* *params); 164 Ihandle* IupCreatep(const(char) *classname, void *first, ...); 165 166 /************************************************************************/ 167 /* Elements */ 168 /************************************************************************/ 169 170 Ihandle* IupFill (); 171 Ihandle* IupRadio (Ihandle* child); 172 Ihandle* IupVbox (Ihandle* child, ...); 173 Ihandle* IupVboxv (Ihandle* *children); 174 Ihandle* IupZbox (Ihandle* child, ...); 175 Ihandle* IupZboxv (Ihandle* *children); 176 Ihandle* IupHbox (Ihandle* child,...); 177 Ihandle* IupHboxv (Ihandle* *children); 178 179 Ihandle* IupNormalizer (Ihandle* ih_first, ...); 180 Ihandle* IupNormalizerv(Ihandle* *ih_list); 181 182 Ihandle* IupCbox (Ihandle* child, ...); 183 Ihandle* IupCboxv (Ihandle* *children); 184 Ihandle* IupSbox (Ihandle *child); 185 Ihandle* IupSplit (Ihandle* child1, Ihandle* child2); 186 Ihandle* IupScrollBox (Ihandle* child); 187 Ihandle* IupGridBox (Ihandle* child, ...); 188 Ihandle* IupGridBoxv (Ihandle **children); 189 Ihandle* IupExpander (Ihandle *child); 190 Ihandle* IupDetachBox (Ihandle *child); 191 Ihandle* IupBackgroundBox(Ihandle *child); 192 193 Ihandle* IupFrame (Ihandle* child); 194 195 Ihandle* IupImage (int width, int height, const ubyte *pixmap); 196 Ihandle* IupImageRGB (int width, int height, const ubyte *pixmap); 197 Ihandle* IupImageRGBA (int width, int height, const ubyte *pixmap); 198 199 Ihandle* IupItem (const(char) * title, const(char) * action); 200 Ihandle* IupSubmenu (const(char) * title, Ihandle* child); 201 Ihandle* IupSeparator (); 202 Ihandle* IupMenu (Ihandle* child,...); 203 Ihandle* IupMenuv (Ihandle* *children); 204 205 Ihandle* IupButton (const(char) * title, const(char) * action); 206 Ihandle* IupCanvas (const(char) * action); 207 Ihandle* IupDialog (Ihandle* child); 208 Ihandle* IupUser (); 209 Ihandle* IupLabel (const(char) * title); 210 Ihandle* IupList (const(char) * action); 211 Ihandle* IupText (const(char) * action); 212 Ihandle* IupMultiLine (const(char) * action); 213 Ihandle* IupToggle (const(char) * title, const(char) * action); 214 Ihandle* IupTimer (); 215 Ihandle* IupClipboard (); 216 Ihandle* IupProgressBar(); 217 Ihandle* IupVal (const(char) *type); 218 Ihandle* IupTabs (Ihandle* child, ...); 219 Ihandle* IupTabsv (Ihandle* *children); 220 Ihandle* IupTree (); 221 Ihandle* IupLink (const(char) * url, const(char) * title); 222 Ihandle* IupFlatButton (const(char) * title); 223 Ihandle* IupAnimatedLabel(Ihandle* animation); 224 Ihandle* IupDatePick (); 225 Ihandle* IupCalendar (); 226 227 /* Old controls, use SPIN attribute of IupText */ 228 Ihandle* IupSpin (); 229 Ihandle* IupSpinbox (Ihandle* child); 230 231 232 /************************************************************************/ 233 /* Utilities */ 234 /************************************************************************/ 235 236 /* String compare utility */ 237 int IupStringCompare(const(char) * str1, const(char) * str2, int casesensitive, int lexicographic); 238 239 /* IupImage utility */ 240 int IupSaveImageAsText(Ihandle* ih, const(char) * file_name, const(char) * format, const(char) * name); 241 242 /* IupText and IupScintilla utilities */ 243 void IupTextConvertLinColToPos(Ihandle* ih, int lin, int col, int *pos); 244 void IupTextConvertPosToLinCol(Ihandle* ih, int pos, int *lin, int *col); 245 246 /* IupText, IupList, IupTree, IupMatrix and IupScintilla utility */ 247 int IupConvertXYToPos(Ihandle* ih, int x, int y); 248 249 /* IupTree utilities */ 250 int IupTreeSetUserId(Ihandle* ih, int id, void* userid); 251 void* IupTreeGetUserId(Ihandle* ih, int id); 252 int IupTreeGetId(Ihandle* ih, void *userid); 253 void IupTreeSetAttributeHandle(Ihandle* ih, const(char) * name, int id, Ihandle* ih_named); 254 255 256 /************************************************************************/ 257 /* Pre-defined dialogs */ 258 /************************************************************************/ 259 260 Ihandle* IupFileDlg(); 261 Ihandle* IupMessageDlg(); 262 Ihandle* IupColorDlg(); 263 Ihandle* IupFontDlg(); 264 Ihandle* IupProgressDlg(); 265 266 int IupGetFile(char *arq); 267 void IupMessage(const(char) *title, const(char) *msg); 268 void IupMessagef(const(char) *title, const(char) *format, ...); 269 int IupAlarm(const(char) *title, const(char) *msg, const(char) *b1, const(char) *b2, const(char) *b3); 270 int IupScanf(const(char) *format, ...); 271 int IupListDialog(int type, const(char) *title, int size, const(char) ** list, 272 int op, int max_col, int max_lin, int* marks); 273 int IupGetText(const(char) * title, char* text, int maxsize); 274 int IupGetColor(int x, int y, ubyte* r, ubyte* g, ubyte* b); 275 276 alias Iparamcb = int function(Ihandle* dialog, int param_index, void* user_data); 277 int IupGetParam(const(char) * title, Iparamcb action, void* user_data, const(char) * format,...); 278 int IupGetParamv(const(char) * title, Iparamcb action, void* user_data, const(char) * format, int param_count, int param_extra, void** param_data); 279 Ihandle* IupParamf(const(char) * format); 280 Ihandle* IupParamBox(Ihandle* parent, Ihandle** params, int count); 281 282 Ihandle* IupLayoutDialog(Ihandle* dialog); 283 Ihandle* IupElementPropertiesDialog(Ihandle* elem); 284 } 285 286 287 /************************************************************************/ 288 /* Common Flags and Return Values */ 289 /************************************************************************/ 290 enum IUP_ERROR = 1; 291 enum IUP_NOERROR = 0; 292 enum IUP_OPENED = -1; 293 enum IUP_INVALID = -1; 294 enum IUP_INVALID_ID = -10; 295 296 297 /************************************************************************/ 298 /* Callback Return Values */ 299 /************************************************************************/ 300 enum IUP_IGNORE = -1; 301 enum IUP_DEFAULT = -2; 302 enum IUP_CLOSE = -3; 303 enum IUP_CONTINUE = -4; 304 305 /************************************************************************/ 306 /* IupPopup and IupShowXY Parameter Values */ 307 /************************************************************************/ 308 enum IUP_CENTER = 0xFFFF /* 65535 */; 309 enum IUP_LEFT = 0xFFFE /* 65534 */; 310 enum IUP_RIGHT = 0xFFFD /* 65533 */; 311 enum IUP_MOUSEPOS = 0xFFFC /* 65532 */; 312 enum IUP_CURRENT = 0xFFFB /* 65531 */; 313 enum IUP_CENTERPARENT = 0xFFFA /* 65530 */; 314 enum IUP_TOP = IUP_LEFT; 315 enum IUP_BOTTOM = IUP_RIGHT; 316 317 /************************************************************************/ 318 /* SHOW_CB Callback Values */ 319 /************************************************************************/ 320 enum{IUP_SHOW, IUP_RESTORE, IUP_MINIMIZE, IUP_MAXIMIZE, IUP_HIDE}; 321 322 /************************************************************************/ 323 /* SCROLL_CB Callback Values */ 324 /************************************************************************/ 325 enum{IUP_SBUP, IUP_SBDN, IUP_SBPGUP, IUP_SBPGDN, IUP_SBPOSV, IUP_SBDRAGV, 326 IUP_SBLEFT, IUP_SBRIGHT, IUP_SBPGLEFT, IUP_SBPGRIGHT, IUP_SBPOSH, IUP_SBDRAGH}; 327 328 /************************************************************************/ 329 /* Mouse Button Values and Macros */ 330 /************************************************************************/ 331 enum IUP_BUTTON1 = '1'; 332 enum IUP_BUTTON2 = '2'; 333 enum IUP_BUTTON3 = '3'; 334 enum IUP_BUTTON4 = '4'; 335 enum IUP_BUTTON5 = '5'; 336 337 pragma(inline, true) { 338 auto iup_isshift(T)(T s) { return s[0] == 'S'; } 339 auto iup_iscontrol(T)(T s) { return s[1] == 'C'; } 340 auto iup_isbutton1(T)(T s) { return s[2] == '1'; } 341 auto iup_isbutton2(T)(T s) { return s[3] == '2'; } 342 auto iup_isbutton3(T)(T s) { return s[4] == '3'; } 343 auto iup_isdouble(T)(T s) { return s[5] == 'D'; } 344 auto iup_isalt(T)(T s) { return s[6] == 'A'; } 345 auto iup_issys(T)(T s) { return s[7] == 'Y'; } 346 auto iup_isbutton4(T)(T s) { return s[8] == '4'; } 347 auto iup_isbutton5(T)(T s) { return s[9] == '5'; } 348 } 349 350 /************************************************************************/ 351 /* Pre-Defined Masks */ 352 /************************************************************************/ 353 enum const(char) * IUP_MASK_FLOAT = "[+/-]?(/d+/.?/d*|/./d+)"; 354 enum const(char) * IUP_MASK_UFLOAT = "(/d+/.?/d*|/./d+)"; 355 enum const(char) * IUP_MASK_EFLOAT = "[+/-]?(/d+/.?/d*|/./d+)([eE][+/-]?/d+)?"; 356 enum const(char) * IUP_MASK_FLOATCOMMA = "[+/-]?(/d+/,?/d*|/,/d+)"; 357 enum const(char) * IUP_MASK_UFLOATCOMMA = "(/d+/,?/d*|/,/d+)"; 358 enum const(char) * IUP_MASK_INT = "[+/-]?/d+"; 359 enum const(char) * IUP_MASK_UINT = "/d+"; 360 361 362 /************************************************************************/ 363 /* IupGetParam Callback situations */ 364 /************************************************************************/ 365 enum IUP_GETPARAM_BUTTON1 = -1; 366 enum IUP_GETPARAM_INIT = -2; 367 enum IUP_GETPARAM_BUTTON2 = -3; 368 enum IUP_GETPARAM_BUTTON3 = -4; 369 enum IUP_GETPARAM_CLOSE = -5; 370 enum IUP_GETPARAM_OK = IUP_GETPARAM_BUTTON1; 371 enum IUP_GETPARAM_CANCEL = IUP_GETPARAM_BUTTON2; 372 enum IUP_GETPARAM_HELP = IUP_GETPARAM_BUTTON3; 373 374 375 /************************************************************************/ 376 /* Record Input Modes */ 377 /************************************************************************/ 378 enum {IUP_RECBINARY, IUP_RECTEXT}; 379