It is currently Sun Nov 29, 2020 5:48 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: IUP GUI Toolkit
PostPosted: Tue Mar 10, 2020 4:18 am 
Offline
Enthusiast
Enthusiast

Joined: Wed Mar 11, 2009 4:06 pm
Posts: 327
Location: NL
Possibly useful for some.

http://webserver2.tecgraf.puc-rio.br/iup/

Include file h-iup.pb:
Code:
EnableExplicit

;{*** iup.h

#IUP_NAME = "IUP - Portable User Interface"
#IUP_DESCRIPTION = "Multi-platform Toolkit for Building Graphical User Interfaces"
#IUP_COPYRIGHT = "Copyright (C) 1994-2019 Tecgraf/PUC-Rio"
#IUP_VERSION = "3.28"
#IUP_VERSION_NUMBER = 328000
#IUP_VERSION_DATE = "2019/12/13"

;** Common Flags and Return Values
#IUP_ERROR = 1
#IUP_NOERROR = 0
#IUP_OPENED = -1
#IUP_INVALID = -1
#IUP_INVALID_ID = -10

;** Callback Return Values
#IUP_IGNORE = -1
#IUP_DEFAULT = -2
#IUP_CLOSE = -3
#IUP_CONTINUE = -4

;** IupPopup and IupShowXY Parameter Values
#IUP_CENTER = $FFFF
#IUP_LEFT = $FFFE
#IUP_RIGHT = $FFFD
#IUP_MOUSEPOS = $FFFC
#IUP_CURRENT = $FFFB
#IUP_CENTERPARENT = $FFFA
#IUP_TOP = #IUP_LEFT
#IUP_BOTTOM = #IUP_RIGHT

;** SHOW_CB Callback Values
Enumeration
  #IUP_SHOW
  #IUP_RESTORE
  #IUP_MINIMIZE
  #IUP_MAXIMIZE
  #IUP_HIDE
EndEnumeration

;** SCROLL_CB Callback Values
Enumeration
  #IUP_SBUP
  #IUP_SBDN
  #IUP_SBPGUP
  #IUP_SBPGDN
  #IUP_SBPOSV
  #IUP_SBDRAGV
  #IUP_SBLEFT
  #IUP_SBRIGHT
  #IUP_SBPGLEFT
  #IUP_SBPGRIGHT
  #IUP_SBPOSH
  #IUP_SBDRAGH
EndEnumeration

;** Mouse Button Values and Macros
#IUP_BUTTON1 = '1'
#IUP_BUTTON2 = '2'
#IUP_BUTTON3 = '3'
#IUP_BUTTON4 = '4'
#IUP_BUTTON5 = '5'
Macro iup_isshift(_s) _s[0]=='S': EndMacro
Macro iup_iscontrol(_s) _s[1]=='C' : EndMacro
Macro iup_isbutton1(_s) _s[2]=='1' : EndMacro
Macro iup_isbutton2(_s) _s[3]=='2' : EndMacro
Macro iup_isbutton3(_s) _s[4]=='3' : EndMacro
Macro iup_isdouble(_s) _s[5]=='D' : EndMacro
Macro iup_isalt(_s) _s[6]=='A' : EndMacro
Macro iup_issys(_s) _s[7]=='Y' : EndMacro
Macro iup_isbutton4(_s) _s[8]=='4' : EndMacro
Macro iup_isbutton5(_s) _s[9]=='5' : EndMacro

;** Pre-Defined Masks
#IUP_MASK_FLOAT = "[+/-]?(/d+/.?/d*|/./d+)"
#IUP_MASK_UFLOAT = "(/d+/.?/d*|/./d+)"
#IUP_MASK_EFLOAT = "[+/-]?(/d+/.?/d*|/./d+)([eE][+/-]?/d+)?"
#IUP_MASK_UEFLOAT = "(/d+/.?/d*|/./d+)([eE][+/-]?/d+)?"
#IUP_MASK_FLOATCOMMA = "[+/-]?(/d+/,?/d*|/,/d+)"
#IUP_MASK_UFLOATCOMMA = "(/d+/,?/d*|/,/d+)"
#IUP_MASK_INT = "[+/-]?/d+"
#IUP_MASK_UINT = "/d+"

;** IupGetParam Callback situations
#IUP_GETPARAM_BUTTON1 = -1
#IUP_GETPARAM_INIT = -2
#IUP_GETPARAM_BUTTON2 = -3
#IUP_GETPARAM_BUTTON3 = -4
#IUP_GETPARAM_CLOSE = -5
#IUP_GETPARAM_MAP = -6
#IUP_GETPARAM_OK = #IUP_GETPARAM_BUTTON1
#IUP_GETPARAM_CANCEL = #IUP_GETPARAM_BUTTON2
#IUP_GETPARAM_HELP = #IUP_GETPARAM_BUTTON3

;** Used by IupColorbar
#IUP_PRIMARY = -1
#IUP_SECONDARY = -2

;** Record Input Modes
Enumeration
  #IUP_RECBINARY
  #IUP_RECTEXT
EndEnumeration

ImportC "C:\Dev\iup-3.28_Win32_dll15_lib\iup.lib"
  ;** Main API
  IupOpen.l(*argc = 0, *argv = 0)
  IupClose()
  IupIsOpened.l()
  IupImageLibOpen()
  IupMainLoop.l()
  IupLoopStep.l()
  IupLoopStepWait.l()
  IupMainLoopLevel.l()
  IupFlush()
  IupExitLoop()
  IupPostMessage(*ih, s.p-utf8, i.l, d.d, *p)
  IupRecordInput.l(filename.p-utf8, mode.l)
  IupPlayInput.l(filename.p-utf8)
  IupUpdate(*ih)
  IupUpdateChildren(*ih)
  IupRedraw(*ih, children.l)
  IupRefresh(*ih)
  IupRefreshChildren(*ih)
  IupExecute.l(filename.p-utf8, parameters.p-utf8)
  IupExecuteWait.l(filename.p-utf8, parameters.p-utf8)
  IupHelp.l(url.p-utf8)
  ;IupLog(type.p-utf8, format.p-utf8, ....?)
  _IupLoad.i(filename.p-utf8) As "_IupLoad"
  _IupLoadBuffer.i(buffer.p-utf8) As "_IupLoadBuffer"
  _IupVersion.i() As "_IupVersion"
  _IupVersionDate.i() As "_IupVersionDate"
  IupVersionNumber.l()
  IupVersionShow()
  IupSetLanguage(lng.p-utf8)
  _IupGetLanguage.i() As "_IupGetLanguage"
  IupSetLanguageString(name.p-utf8, str.p-utf8)
  IupStoreLanguageString(name.p-utf8, str.p-utf8)
  _IupGetLanguageString.i(name.p-utf8) As "_IupGetLanguageString"
  IupSetLanguagePack(*ih)
  IupDestroy(*ih)
  IupDetach(*child)
  IupAppend.i(*ih, *child)
  IupInsert.i(*ih, *ref_child, *child)
  IupGetChild.i(*ih, pos.l)
  IupGetChildPos.l(*ih, *child)
  IupGetChildCount.l(*ih)
  IupGetNextChild.i(*ih, *child)
  IupGetBrother.i(*ih)
  IupGetParent.i(*ih)
  IupGetDialog.i(*ih)
  IupGetDialogChild.i(*ih, name.p-utf8)
  IupReparent.l(*ih, *new_parent, *ref_child)
  IupPopup.l(*ih, x.l, y.l)
  IupShow.l(*ih)
  IupShowXY.l(*ih, x.l, y.l)
  IupHide.l(*ih)
  IupMap.l(*ih)
  IupUnmap(*ih)
  IupResetAttribute(*ih, name.p-utf8)
  IupGetAllAttributes.l(*ih, *names, n.l)
  IupCopyAttributes(*src_ih, *dst_ih)
  ;IupSetAtt.i(handle_name.p-utf8, *ih, name.p-utf8, ....?)
  IupSetAttributes.i(*ih, str.p-utf8)
  _IupGetAttributes.i(*ih) As "_IupGetAttributes"
  IupSetAttribute(*ih, name.p-utf8, value.p-utf8)
  IupSetAttributePtr(*ih, name.p-utf8, value) As "_IupSetAttribute"
  IupSetStrAttribute(*ih, name.p-utf8, value.p-utf8)
  IupSetStrAttributePtr(*ih, name.p-utf8, value) As "_IupSetStrAttribute"
  ;IupSetStrf(*ih, name.p-utf8, format.p-utf8, ....?)
  IupSetInt(*ih, name.p-utf8, value.l)
  IupSetFloat(*ih, name.p-utf8, value.f)
  IupSetDouble(*ih, name.p-utf8, value.d)
  IupSetRGB(*ih, name.p-utf8, r.a, g.a, b.a)
  _IupGetAttribute.i(*ih, name.p-utf8) As "_IupGetAttribute"
  IupGetAttributePtr(*ih, name.p-utf8) As "_IupGetAttribute"
  IupGetInt.l(*ih, name.p-utf8)
  IupGetInt2.l(*ih, name.p-utf8)
  IupGetIntInt.l(*ih, name.p-utf8, *i1, *i2)
  IupGetFloat.f(*ih, name.p-utf8)
  IupGetDouble.d(*ih, name.p-utf8)
  IupGetRGB(*ih, name.p-utf8, *r, *g, *b)
  IupSetAttributeId(*ih, name.p-utf8, id.l, value.p-utf8)
  IupSetStrAttributeId(*ih, name.p-utf8, id.l, value.p-utf8)
  ;IupSetStrfId(*ih, name.p-utf8, id.l, format.p-utf8, ....?)
  IupSetIntId(*ih, name.p-utf8, id.l, value.l)
  IupSetFloatId(*ih, name.p-utf8, id.l, value.f)
  IupSetDoubleId(*ih, name.p-utf8, id.l, value.d)
  IupSetRGBId(*ih, name.p-utf8, id.l, r.a, g.a, b.a)
  _IupGetAttributeId.i(*ih, name.p-utf8, id.l) As "_IupGetAttributeId"
  IupGetIntId.l(*ih, name.p-utf8, id.l)
  IupGetFloatId.f(*ih, name.p-utf8, id.l)
  IupGetDoubleId.d(*ih, name.p-utf8, id.l)
  IupGetRGBId(*ih, name.p-utf8, id.l, *r, *g, *b)
  IupSetAttributeId2(*ih, name.p-utf8, lin.l, col.l, value.p-utf8)
  IupSetStrAttributeId2(*ih, name.p-utf8, lin.l, col.l, value.p-utf8)
  ;IupSetStrfId2(*ih, name.p-utf8, lin.l, col.l, format.p-utf8, ....?)
  IupSetIntId2(*ih, name.p-utf8, lin.l, col.l, value.l)
  IupSetFloatId2(*ih, name.p-utf8, lin.l, col.l, value.f)
  IupSetDoubleId2(*ih, name.p-utf8, lin.l, col.l, value.d)
  IupSetRGBId2(*ih, name.p-utf8, lin.l, col.l, r.a, g.a, b.a)
  _IupGetAttributeId2.i(*ih, name.p-utf8, lin.l, col.l) As "_IupGetAttributeId2"
  IupGetIntId2.l(*ih, name.p-utf8, lin.l, col.l)
  IupGetFloatId2.f(*ih, name.p-utf8, lin.l, col.l)
  IupGetDoubleId2.d(*ih, name.p-utf8, lin.l, col.l)
  IupGetRGBId2(*ih, name.p-utf8, lin.l, col.l, *r, *g, *b)
  IupSetGlobal(name.p-utf8, value.p-utf8)
  IupSetStrGlobal(name.p-utf8, value.p-utf8)
  _IupGetGlobal.i(name.p-utf8) As "_IupGetGlobal"
  IupSetFocus.i(*ih)
  IupGetFocus.i()
  IupPreviousField.i(*ih)
  IupNextField.i(*ih)
  IupGetCallback.i(*ih, name.p-utf8)
  IupSetCallback.i(*ih, name.p-utf8, *func)
  ;IupSetCallbacks.i(*ih, name.p-utf8, func.?, ....?)
  ;IupGetFunction.?(name.p-utf8)
  ;IupSetFunction.?(name.p-utf8, func.?)
  IupGetHandle.i(name.p-utf8)
  IupSetHandle.i(name.p-utf8, *ih)
  IupGetAllNames.l(*names, n.l)
  IupGetAllDialogs.l(*names, n.l)
  _IupGetName.i(*ih) As "_IupGetName"
  IupSetAttributeHandle(*ih, name.p-utf8, *ih_named)
  IupGetAttributeHandle.i(*ih, name.p-utf8)
  IupSetAttributeHandleId(*ih, name.p-utf8, id.l, *ih_named)
  IupGetAttributeHandleId.i(*ih, name.p-utf8, id.l)
  IupSetAttributeHandleId2(*ih, name.p-utf8, lin.l, col.l, *ih_named)
  IupGetAttributeHandleId2.i(*ih, name.p-utf8, lin.l, col.l)
  _IupGetClassName.i(*ih) As "_IupGetClassName"
  _IupGetClassType.i(*ih) As "_IupGetClassType"
  IupGetAllClasses.l(*names, n.l)
  IupGetClassAttributes.l(classname.p-utf8, *names, n.l)
  IupGetClassCallbacks.l(classname.p-utf8, *names, n.l)
  IupSaveClassAttributes(*ih)
  IupCopyClassAttributes(*src_ih, *dst_ih)
  IupSetClassDefaultAttribute(classname.p-utf8, name.p-utf8, value.p-utf8)
  IupClassMatch.l(*ih, classname.p-utf8)
  IupCreate.i(classname.p-utf8)
  IupCreatev.i(classname.p-utf8, *params)
  IupCreatep.i(classname.p-utf8, p1 = 0, p2 = 0, p3 = 0, p4 = 0, p5 = 0, p6 = 0, p7= 0, p8 = 0)
 
  ;** Elements
  IupFill.i()
  IupSpace.i()
  IupRadio.i(*child)
  IupVbox.i(p1 = 0, p2 = 0, p3 = 0, p4 = 0, p5 = 0, p6 = 0, p7= 0, p8 = 0)
  IupVboxv.i(*children)
  IupZbox.i(p1 = 0, p2 = 0, p3 = 0, p4 = 0, p5 = 0, p6 = 0, p7= 0, p8 = 0)
  IupZboxv.i(*children)
  IupHbox.i(p1 = 0, p2 = 0, p3 = 0, p4 = 0, p5 = 0, p6 = 0, p7= 0, p8 = 0)
  IupHboxv.i(*children)
  IupNormalizer.i(p1 = 0, p2 = 0, p3 = 0, p4 = 0, p5 = 0, p6 = 0, p7= 0, p8 = 0)
  IupNormalizerv.i(*ih_list)
  IupCbox.i(p1 = 0, p2 = 0, p3 = 0, p4 = 0, p5 = 0, p6 = 0, p7= 0, p8 = 0)
  IupCboxv.i(*children)
  IupSbox.i(*child)
  IupSplit.i(*child1, *child2)
  IupScrollBox.i(*child)
  IupFlatScrollBox.i(*child)
  IupGridBox.i(p1 = 0, p2 = 0, p3 = 0, p4 = 0, p5 = 0, p6 = 0, p7= 0, p8 = 0)
  IupGridBoxv.i(*children)
  IupMultiBox.i(p1 = 0, p2 = 0, p3 = 0, p4 = 0, p5 = 0, p6 = 0, p7= 0, p8 = 0)
  IupMultiBoxv.i(*children)
  IupExpander.i(*child)
  IupDetachBox.i(*child)
  IupBackgroundBox.i(*child)
  IupFrame.i(*child)
  IupFlatFrame.i(*child)
  IupImage.i(width.l, height.l, *pixels)
  IupImageRGB.i(width.l, height.l, *pixels)
  IupImageRGBA.i(width.l, height.l, *pixels)
  IupItem.i(title.p-utf8, action.p-utf8)
  IupSubmenu.i(title.p-utf8, *child)
  IupSeparator.i()
  IupMenu.i(p1 = 0, p2 = 0, p3 = 0, p4 = 0, p5 = 0, p6 = 0, p7= 0, p8 = 0)
  IupMenuv.i(*children)
  IupButton.i(title.p-utf8, action.p-utf8)
  IupFlatButton.i(title.p-utf8)
  IupFlatToggle.i(title.p-utf8)
  IupDropButton.i(*dropchild)
  IupFlatLabel.i(title.p-utf8)
  IupFlatSeparator.i()
  IupCanvas.i(action.p-utf8)
  IupDialog.i(*child)
  IupUser.i()
  IupThread.i()
  IupLabel.i(title.p-utf8)
  IupList.i(action.p-utf8)
  IupFlatList.i()
  IupText.i(action.p-utf8)
  IupMultiLine.i(action.p-utf8)
  IupToggle.i(title.p-utf8, action.p-utf8)
  IupTimer.i()
  IupClipboard.i()
  IupProgressBar.i()
  IupVal.i(type.p-utf8)
  IupFlatVal.i(type.p-utf8)
  IupTabs.i(p1 = 0, p2 = 0, p3 = 0, p4 = 0, p5 = 0, p6 = 0, p7= 0, p8 = 0)
  IupTabsv.i(*children)
  IupFlatTabs.i(p1 = 0, p2 = 0, p3 = 0, p4 = 0, p5 = 0, p6 = 0, p7= 0, p8 = 0)
  IupFlatTabsv.i(*children)
  IupTree.i()
  IupLink.i(url.p-utf8, title.p-utf8)
  IupAnimatedLabel.i(*animation)
  IupDatePick.i()
  IupCalendar.i()
  IupColorbar.i()
  IupGauge.i()
  IupDial.i(type.p-utf8)
  IupColorBrowser.i()
  IupSpin.i()
  IupSpinbox.i(*child)
 
  ;** Utilities
  IupStringCompare.l(str1.p-utf8, str2.p-utf8, casesensitive.l, lexicographic.l)
  IupSaveImageAsText.l(*ih, filename.p-utf8, format.p-utf8, name.p-utf8)
  IupImageGetHandle.i(name.p-utf8)
  IupTextConvertLinColToPos(*ih, lin.l, col.l, *pos)
  IupTextConvertPosToLinCol(*ih, pos.l, *lin, *col)
  IupConvertXYToPos.l(*ih, x.l, y.l)
  IupStoreGlobal(name.p-utf8, value.p-utf8)
  IupStoreAttribute(*ih, name.p-utf8, value.p-utf8)
  ;IupSetfAttribute(*ih, name.p-utf8, format.p-utf8, ....?)
  IupStoreAttributeId(*ih, name.p-utf8, id.l, value.p-utf8)
  ;IupSetfAttributeId(*ih, name.p-utf8, id.l, f.p-utf8, ....?)
  IupStoreAttributeId2(*ih, name.p-utf8, lin.l, col.l, value.p-utf8)
  ;IupSetfAttributeId2(*ih, name.p-utf8, lin.l, col.l, format.p-utf8, ....?)
  IupTreeSetUserId.l(*ih, id.l, *userid)
  IupTreeGetUserId.i(*ih, id.l)
  IupTreeGetId.l(*ih, *userid)
  IupTreeSetAttributeHandle(*ih, name.p-utf8, id.l, *ih_named)
 
  ;** Pre-defined dialogs
  IupFileDlg.i()
  IupMessageDlg.i()
  IupColorDlg.i()
  IupFontDlg.i()
  IupProgressDlg.i()
  IupGetFile.l(*arq)
  IupMessage(title.p-utf8, msg.p-utf8)
  ;IupMessagef(title.p-utf8, format.p-utf8, ....?)
  IupMessageError(*parent, message.p-utf8)
  IupMessageAlarm.l(*parent, title.p-utf8, message.p-utf8, buttons.p-utf8)
  IupAlarm.l(title.p-utf8, msg.p-utf8, b1.p-utf8, b2.p-utf8, b3.p-utf8)
  ;IupScanf.l(format.p-utf8, ....?)
  IupListDialog.l(type.l, title.p-utf8, size.l, *list, op.l, max_col.l, max_lin.l, *marks)
  IupGetText.l(title.p-utf8, *text, maxsize.l)
  IupGetColor.l(x.l, y.l, *r, *g, *b)
  IupGetParam.l(title.p-utf8, *action, *user_data, format.p-utf8, p1 = 0, p2 = 0, p3 = 0, p4 = 0, p5 = 0, p6 = 0, p7= 0, p8 = 0, p9 = 0, p10 = 0, p11 = 0, p12 = 0, p13 = 0, p14 = 0, p15 = 0, p16 = 0, p17 = 0, p18 = 0, p19 = 0, p20 = 0)
  IupGetParamv.l(title.p-utf8, *action, *user_data, format.p-utf8, param_count.l, param_extra.l, *param_data)
  IupParam.i(format.p-utf8)
  IupParamBox.i(p1 = 0, p2 = 0, p3 = 0, p4 = 0, p5 = 0, p6 = 0, p7= 0, p8 = 0)
  IupParamBoxv.i(*param_array)
  IupLayoutDialog.i(*dialog)
  IupElementPropertiesDialog.i(*parent, *elem)
  IupGlobalsDialog.i()
  IupClassInfoDialog.i(*parent)
 
  ;** iupdraw.h
  IupDrawBegin(*ih)
  IupDrawEnd(*ih)
  IupDrawSetClipRect(*ih, x1.l, y1.l, x2.l, y2.l)
  IupDrawGetClipRect(*ih, *x1, *y1, *x2, *y2)
  IupDrawResetClip(*ih)
  IupDrawParentBackground(*ih)
  IupDrawLine(*ih, x1.l, y1.l, x2.l, y2.l)
  IupDrawRectangle(*ih, x1.l, y1.l, x2.l, y2.l)
  IupDrawArc(*ih, x1.l, y1.l, x2.l, y2.l, a1.d, a2.d)
  IupDrawPolygon(*ih, *points, count.l)
  IupDrawText(*ih, text.p-utf8, len.l, x.l, y.l, w.l, h.l)
  IupDrawImage(*ih, name.p-utf8, x.l, y.l, w.l, h.l)
  IupDrawSelectRect(*ih, x1.l, y1.l, x2.l, y2.l)
  IupDrawFocusRect(*ih, x1.l, y1.l, x2.l, y2.l)
  IupDrawGetSize(*ih, *w, *h)
  IupDrawGetTextSize(*ih, text.p-utf8, len.l, *w, *h)
  IupDrawGetImageInfo(name.p-utf8, *w, *h, *bpp) 
EndImport

Macro IupLoad(filename): PeekS(_IupLoad(filename), -1, #PB_UTF8): EndMacro
Macro IupLoadBuffer(buffer): PeekS(_IupLoadBuffer(buffer), -1, #PB_UTF8): EndMacro
Macro IupVersion(): PeekS(_IupVersion(), -1, #PB_UTF8): EndMacro
Macro IupVersionDate(): PeekS(_IupVersionDate(), -1, #PB_UTF8): EndMacro
Macro IupGetLanguage(): PeekS(_IupGetLanguage(), -1, #PB_UTF8): EndMacro
Macro IupGetLanguageString(name): PeekS(_IupGetLanguageString(name), -1, #PB_UTF8): EndMacro
Macro IupGetAttributes(ih): PeekS(_IupGetAttributes(ih), -1, #PB_UTF8): EndMacro
Macro IupGetAttribute(ih, name): PeekS(_IupGetAttribute(ih, name), -1, #PB_UTF8): EndMacro
Macro IupGetAttributeId(ih, name, id): PeekS(_IupGetAttributeId(ih, name, id), -1, #PB_UTF8): EndMacro
Macro IupGetAttributeId2(ih, name, lin, col): PeekS(_IupGetAttributeId2(ih, name, lin, col), -1, #PB_UTF8): EndMacro
Macro IupGetGlobal(name): PeekS(_IupGetGlobal(name), -1, #PB_UTF8): EndMacro
Macro IupGetName(ih): PeekS(_IupGetName(ih), -1, #PB_UTF8): EndMacro
Macro IupGetClassName(ih): PeekS(_IupGetClassName(ih), -1, #PB_UTF8): EndMacro
Macro IupGetClassType(ih): PeekS(_IupGetClassType(ih), -1, #PB_UTF8): EndMacro
;}

;{*** iupcontrols.h

ImportC "C:\Dev\iup-3.28_Win32_dll15_lib\iupcontrols.lib"
  IupControlsOpen.l()
  IupCells.i()
  IupMatrix.i(action.p-utf8)
  IupMatrixList.i()
  IupMatrixEx.i()
  IupMatrixSetFormula(*ih, col.l, formula.p-utf8, init.p-utf8)
  IupMatrixSetDynamic(*ih, init.p-utf8)
EndImport
;}

;**

IupSetAttribute(0, "UTF8MODE", "YES")

Macro PeekUTF8(p)
  PeekS(@p, -1, #PB_UTF8)
EndMacro

Macro PokeUTF8(p, v)
  p = Space(StringByteLength(v, #PB_UTF8) / SizeOf(Character) +1): PokeS(@p, v, -1, #PB_UTF8)
  ;Debug p
  ;Debug PeekUTF8(p)
EndMacro

Macro ProtectedUTF8(p, v, byteSize=0)
  CompilerIf byteSize > 0
    Protected p.s = RSet("", byteSize / 2 +1, Chr(0)): PokeS(@p, v, -1, #PB_UTF8)
  CompilerElse
    Protected p.s = Space(StringByteLength(v, #PB_UTF8) / SizeOf(Character) +1): PokeS(@p, v, -1, #PB_UTF8)
  CompilerEndIf
EndMacro


Some examples:
Code:
XIncludeFile "h-iup.pb"

; http://webserver2.tecgraf.puc-rio.br/iup/

; Download 32 or 64 bit dynamic library binaries from here:
; IUP http://sourceforge.net/projects/iup/files/
; .lib files are used for ImportC statements (binding), .dll files are moved into appropriate folder (C:\Windows\System32 (64 bit), C:\Windows\SysWOW64 (32 bit), MS-logic) or saved next to executable.
;  CHM help file https://www.tecgraf.puc-rio.br/iup/download/iup.chm
;  PERL help: https://metacpan.org/pod/distribution/IUP/lib/IUP.pod

;; IM http://sourceforge.net/projects/imtoolkit/files/
;; CD http://sourceforge.net/projects/canvasdraw/files/

; IUP uses UTF-8 internally. PB uses UTF-16. IUP frequently uses pointers to strings in the main program.
; p-utf8 automatically converts to UTF-8, but they are temporary variables which can cause problems in some situations because of those pointers.
; Use IupSetStrAttribute when setting visible attributes, which makes a copy of the value instead of using a pointer.
; The PeekUTF8 (create UTF-16 from UTF-8), PokeUTF8 (create UTF-8 from UTF-16) and ProtectedUTF8 (delcare UTF-8 string) helper macro's can also be used if needed which creates an UTF-8 string in PB.


;**
; IupOpen(0, 0);
; IupMessage("Hello World", "Begrüßenภาษาไทย!");
; IupClose();

;{** http://webserver2.tecgraf.puc-rio.br/iup/en/tutorial/tutorial2.html#Improving_the_Layout

; ProcedureC btn_exit_cb( *self )
;   ProcedureReturn #IUP_CLOSE
; EndProcedure
;
; Define dlg, button, label, vbox
;
; IupOpen()
; label = IupLabel("Hello world from IUP.");
; button = IupButton("OK", #Null$)
;
; Dim ctrls(2)
; ctrls(0) = label
; ctrls(1) = button
; ctrls(2) = 0
; vbox = IupVboxv(@ctrls())
; IupSetAttribute(vbox, "ALIGNMENT", "ACENTER")
; IupSetAttribute(vbox, "GAP", "10")
; IupSetAttribute(vbox, "MARGIN", "10x10")
;   
; dlg = IupDialog(vbox);
;
; IupSetStrAttribute(dlg, "TITLE", "Begrüßenภาษาไทย!")
; Define p.s = IupGetAttribute(dlg, "TITLE")
; Debug p
;
; IupSetCallback(button, "ACTION", @btn_exit_cb())
; IupShowXY(dlg, #IUP_CENTER, #IUP_CENTER)
; IupMainLoop()
; IupClose()
;}

;{** http://webserver2.tecgraf.puc-rio.br/iup/en/tutorial/tutorial3.html

; Define dlg, multitext, vbox
;
; IupOpen(0, 0)
;
; multitext = IupText(#Null$)
; Dim p(1)
; p(0) = multitext
; p(1) = #Null
; vbox = IupVboxv(@p())
; IupSetAttribute(multitext, "MULTILINE", "YES")
; IupSetAttribute(multitext, "EXPAND", "YES")
;
; dlg = IupDialog(vbox)
; IupSetAttribute(dlg, "TITLE", "Simple Notepad")
; IupSetAttribute(dlg, "SIZE", "QUARTERxQUARTER")
;
; IupShowXY(dlg, #IUP_CENTER, #IUP_CENTER)
; IupSetAttribute(dlg, "USERSIZE", #Null$)
;
; IupMainLoop();
;
; IupClose();
;}

;{** Counter http://webserver2.tecgraf.puc-rio.br/iup/en/7gui/7gui.html#task1

; ProcedureC btn_count_cb(self)
;   Protected text = IupGetDialogChild(self, "TEXT")
;   Protected value = IupGetInt(text, "VALUE")     
;   value +1
;   IupSetInt(text, "VALUE", value)
;
;   ProcedureReturn #IUP_DEFAULT
; EndProcedure
;
; Define dlg, button, text, hbox;
;
; IupOpen()
;   
; button = IupButton("Count", #Null$);
; IupSetAttribute(button, "SIZE", "60");
; text = IupText(#Null$);
; IupSetAttribute(text, "SIZE", "60");
; IupSetAttribute(text, "NAME", "TEXT");
; IupSetAttribute(text, "READONLY", "YES");
; Dim ctrl(2)
; ctrl(0) = text
; ctrl(1) = button
; ctrl(2) = 0
; hbox = IupHboxv(ctrl());
; hbox = IupHbox(text, button, 0);
; IupSetAttribute(hbox, "MARGIN", "10x10");
; IupSetAttribute(hbox, "GAP", "10");
; dlg = IupDialog(hbox);
; IupSetStrAttribute(dlg, "TITLE", "Counter");
; IupSetInt(text, "VALUE", 0);
; IupSetCallback(button, "ACTION", @btn_count_cb());
;
; IupShowXY(dlg, #IUP_CENTER, #IUP_CENTER);
;
; IupMainLoop();
;
; IupClose();
;}

;{** http://webserver2.tecgraf.puc-rio.br/iup/examples/C/matrixlist.c

; ProcedureC imagevaluechanged_cb(self, item, state)
;    Debug "imagevaluechanged_cb(item=" + item + ", state=" + state
;    ProcedureReturn #IUP_DEFAULT
; EndProcedure
;
; ProcedureC listclick_cb(self, lin, col, *status)
;   ;char* value = IupGetAttributeId(self, "", lin);
;   ;If (!value) value = "NULL";
;   ;printf("listclick_cb(%d, %d)\n", lin, col);
;   ;printf("  VALUE%d:%d = %s\n", lin, col, value);
;   ProcedureReturn #IUP_DEFAULT;
; EndProcedure
;
; ProcedureC listaction_cb(self, item, state)
;   Debug "listaction_cb(item=" + item + ", state="+ state
;   ProcedureReturn #IUP_DEFAULT
; EndProcedure
;
; Define dlg, mlist;
; IupOpen();       
; IupControlsOpen();
;
; mlist = IupMatrixList();
; IupSetInt(mlist, "COUNT", 10);
; IupSetInt(mlist, "VISIBLELINES", 9);
; IupSetAttribute(mlist, "COLUMNORDER", "LABEL:COLOR:IMAGE");
; ;  IupSetAttribute(mlist, "COLUMNORDER", "LABEL:COLOR");
; ;  IupSetAttribute(mlist, "COLUMNORDER", "LABEL");
; ;  IupSetAttribute(mlist, "ACTIVE", "NO");
; ;  IupSetAttribute(mlist, "FOCUSCOLOR", "BGCOLOR");
; IupSetAttribute(mlist, "SHOWDELETE", "Yes");
; ;  IupSetAttribute(mlist, "EXPAND", "Yes");
;
; IupSetAttribute(mlist, "EDITABLE", "Yes");
; IupSetCallback(mlist,"LISTCLICK_CB", @listclick_cb());
; IupSetCallback(mlist,"LISTACTION_CB",@listaction_cb());
; IupSetCallback(mlist, "IMAGEVALUECHANGED_CB", @imagevaluechanged_cb());
;
; ; /* Bluish style */
; If #True
;   ;IupSetStrAttribute(mlist, "TITLE", "Test") ; Bug reported, will be fixed in next version
;   Define *uValue = UTF8("Test")
;   IupSetStrAttributePtr(mlist, "TITLE", *uValue);
;   ;FreeMemory(*uValue)  ; Value is not copied (bug), so FreeMemory causes problems
;   
;   IupSetStrAttribute(mlist, "BGCOLOR", "220 230 240");
;   IupSetStrAttribute(mlist, "FRAMECOLOR", "120 140 160");
;   IupSetStrAttribute(mlist, "ITEMBGCOLOR0", "120 140 160");
;   IupSetStrAttribute(mlist, "ITEMFGCOLOR0", "255 255 255");
; EndIf
;
; IupSetStrAttribute(mlist, "1", "AAA");
; IupSetStrAttribute(mlist, "2", "BBB");
; IupSetStrAttribute(mlist, "3", "CCC");
; IupSetStrAttribute(mlist, "4", "DDD");
; IupSetStrAttribute(mlist, "5", "EEE");
; IupSetStrAttribute(mlist, "6", "FFF");
; IupSetStrAttribute(mlist, "7", "GGG");
; IupSetStrAttribute(mlist, "8", "HHH");
; IupSetStrAttribute(mlist, "9", "III");
; IupSetStrAttribute(mlist, "10","JJJ");
;
; IupSetAttribute(mlist, "COLOR1", "255 0 0");
; IupSetAttribute(mlist, "COLOR2", "255 255 0");
; ;IupSetAttribute(mlist, "COLOR3", "0 255 0");
; IupSetAttribute(mlist, "COLOR4", "0 255 255");
; IupSetAttribute(mlist, "COLOR5", "0 0 255");
; IupSetAttribute(mlist, "COLOR6", "255 0 255");
; IupSetAttribute(mlist, "COLOR7", "255 128 0");
; IupSetAttribute(mlist, "COLOR8", "255 128 128");
; IupSetAttribute(mlist, "COLOR9", "0 255 128");
; IupSetAttribute(mlist, "COLOR10", "128 255 128");
;
; IupSetAttribute(mlist, "ITEMACTIVE3", "NO");
; IupSetAttribute(mlist, "ITEMACTIVE7", "NO");
; IupSetAttribute(mlist, "ITEMACTIVE8", "NO");
;
; IupSetAttribute(mlist, "IMAGEACTIVE9", "No");
;
; IupSetAttribute(mlist, "IMAGEVALUE1", "ON");
; IupSetAttribute(mlist, "IMAGEVALUE2", "ON");
; IupSetAttribute(mlist, "IMAGEVALUE3", "ON");
;
; dlg = IupDialog(IupVbox(mlist, #Null$));
; IupSetStrAttribute(dlg, "TITLE", "IupMatrixList");
; IupSetAttribute(dlg, "MARGIN", "10x10");
; ;  IupSetAttribute(dlg, "FONT", "Helvetica, 24");
; IupShowXY(dlg, #IUP_CENTER, #IUP_CENTER);
;
; IupSetStrAttribute(mlist, "APPENDITEM","KKK");
;
; IupMainLoop();
; IupClose(); 
;}

;{** https://webserver2.tecgraf.puc-rio.br/iup/en/dlg/iupgetparam.html

Procedure Test()
  Protected pboolean = 1, pinteger = 3456, preal.f = 3.543, pinteger2 = 192, preal2.f = 0.5, pangle.f = 90
  ProtectedUTF8(pstring, "string text"): ProtectedUTF8(pfont, "Courier, 24"): ProtectedUTF8(pcolor, "255 0 128")
  Protected plist = 2, poptions = 1
  ProtectedUTF8(pstring2, ~"second text\nsecond line"): ProtectedUTF8(file_name, "test.jpg", 1024)
 
  If Not IupGetParam("Title", 0, 0,
                     ~"Bt %u[, MyCancel, Help!]\n" +
                     ~"Boolean: %b[No,Yes]\n" +
                     ~"Integer: %i\n" +
                     ~"Real 1: %r\n" +
                     ~"Sep1 %t\n" +
                     ~"Integer: %i[0,255]\n" +
                     ~"Real 2: %r[-1.5,1.5,0.05]\n" +
                     ~"Sep2 %t\n" +
                     ~"Angle: %a[0,360]\n" +
                     ~"String: %s\n" +
                     ~"Options: %o|item0|item1|item2|\n" +
                     ~"List: %l|item0|item1|item2|item3|item4|item5|item6|\n" +
                     ~"File: %f[OPEN|*.bmp;*.jpg|CURRENT|NO|NO]\n" +
                     ~"Color: %c{Color Tip}\n" +
                     ~"Font: %n\nSep3 %t\n" +
                     ~"Multiline: %m\n",
                     @pboolean, @pinteger, @preal, @pinteger2, @preal2, @pangle, pstring,
                     @poptions, @plist, file_name, pcolor, pfont, pstring2)
    Goto _Cleanup
  EndIf
  Debug preal
  Debug PeekUTF8(file_name)
  _Cleanup:
  ;
EndProcedure
IupOpen()
Test()
IupClose()
;}


Last edited by Rinzwind on Wed Mar 11, 2020 6:27 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: IUP GUI Toolkit
PostPosted: Tue Mar 10, 2020 2:26 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Apr 26, 2003 2:15 pm
Posts: 896
Location: Cuernavaca, Mexico
Thanks Rinzwind.. very interesting.

Just tested using you're last example... Procedure Test()

If I stick with the defaults and press the OK button.. everything is fine but if I choose another .JPG file...
in my case: F:\Latest Home\BitmapBob\JPG Files\Bugs.jpg

the result:
[07:14:41] Waiting for executable to start...
[07:14:41] Executable type: Windows - x86 (32bit, Unicode)
[07:14:41] Executable started.
[07:15:38] [ERROR] h-iup.pb (Line: 683)
[07:15:38] [ERROR] Invalid memory access. (read error at address 39178850)

I've added some file information at the top of h-iup.pb, so disregard the actual line number.

The problem occurs at:
If Not IupGetParam("Title", 0, 0,....


I'm thinking PokeUTF8 can't handle the length of the filename (see above)

Thanks again. :)

_________________
- It was too lonely at the top.

Current Machine: Win 10 Pro 64-bit, Dual Xeon E5-2670, 64 gigs ram, Geforce GTX 1660 Ti w/6 gigs ram


Top
 Profile  
Reply with quote  
 Post subject: Re: IUP GUI Toolkit
PostPosted: Wed Mar 11, 2020 6:25 am 
Offline
Enthusiast
Enthusiast

Joined: Wed Mar 11, 2009 4:06 pm
Posts: 327
Location: NL
Hmm that has to do with the fact that the string should be pre-allocated.

"The function does not allocate memory space to store strings entered by the user. Therefore, the string value parameter must be large enough to receive the user input. If you want to set a maximum size for the string you can set the param attribute MAXSTR, inside the callback when param_index=IUP_GETPARAM_INIT (since 3.6)."

One way would be this:

Code:
Macro ProtectedUTF8(p, v, byteSize=0)
  CompilerIf byteSize > 0
    Protected p.s = RSet("", byteSize / 2 +1, Chr(0)): PokeS(@p, v, -1, #PB_UTF8)
  CompilerElse
    Protected p.s = Space(StringByteLength(v, #PB_UTF8) / SizeOf(Character) +1): PokeS(@p, v, -1, #PB_UTF8)
  CompilerEndIf
EndMacro

(the +1 is there for specified sizes like 3 bytes. That would need 2 'characters' to fit and thus would be 4 bytes at the end)

and use it as
Code:
ProtectedUTF8(file_name, "test.jpg", 1024)


Ofcourse you can also use the PB function UTF8() which returns a UTF8 memory representation of passed string, but using PB strings for UTF8 you don't need to worry about allocating and freeing them.

Anyway, IupGetParam one is a specific case, because this is a quick setup dialog function. Normally strings are returned with GetStrAttribute and set with SetStrAttribute.


Top
 Profile  
Reply with quote  
 Post subject: Re: IUP GUI Toolkit
PostPosted: Wed Mar 11, 2020 12:42 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 4798
Location: Lyon - France
For me i obtain that, when i close the GUI with one of my image
Quote:
3.54299998283386
Nounours vitrine.jpg
Is it the good behavior ? What effect can i expect ? :oops:
Meanwhile,there are horizontal rotate super button 8)

_________________
ImageThe happiness is a road...
Not a destination


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye