-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example TempConvert.c #11
Comments
Regarding NIUPC module uses PIhandle (pointer to Ihandle, *Ihandle in C). NIUP module uses Text_t, Button_t, Label_t, etc. types. They can be casted to PIhandle type and used in SetAttribute function you used But there is better wayEach NIUP object created by Text(), Label(), Button() etc. can set attribute by calling function on object Setting attribute var someText = Text()
someText.value = "lorem ipsum dolorem" # in case there is only one parameter or string
# or
someText.value("lorem ipsum dolorem")
# in case there are multiple parmaters then `attribute=` function can't be used, has to be one with ()
someText.bgcolor(128,0,128) # R G B, type checked for integers
# or
someText.bgcolor("128 0 128") # as string
# or
someText.bgcolor = "128 0 128" # as string
# this is same as
SetAttribute(cast[PIhandle](someText), cstring("BGCOLOR"), cstring("128 0 128"))
# which you have to use if you are calling NIUPC (C like) API Single string parameter is supported for all attributes. You can check in NIUP cource for specific control what function overloads exists, e.g. bgcolor(int, int, int, int) Same for callbacks proc txt_celcius_cb(ih: PIhandle):cint {.cdecl.} =
echo "this is txt celsius callback"
return IUP_DEFAULT
someText.valuechanged_cb = txt_celcius_cb
# or
someText.valuechanged_cb(txt_celcius_cb) You can check signature of callback function in NIUP source: Highlighted is callback function signature which matches Other callback may have other signatures, it is important to use correct ones or app will crash. proc my_k_any_cb(ih: PIhandle, c: cint):cint {.cdecl.} =
echo "this is k_any callback"
return IUP_DEFAULT For description of parameters it's best to go to IUP documentation. PS your callbacks don't do anything, just set up some variables which get optimized away. PPS in Nim you can use var num = 3
echo $num |
Trying to re-create tempConvert.c using niup library
I get errors trying to SetAtrribute
`ot <Text_t, string, string>
but expected one of:
proc SetAttribute(ih: PIhandle; name: cstring; value: cstring)
first type mismatch at position: 1
required type for ih: PIhandle
but expression 'textLabel_c' is of type: Text_t
expression: SetAttribute(textLabel_c, "value", "")
In the example do you have to SetStrf to convert to a string? or do I need to parseString? `
The text was updated successfully, but these errors were encountered: