/* IupGetParam: Example in C
Shows a dialog with all the possible fields.
*/
#include <stdlib.h>
#include <stdio.h>
#include <iup.h>
// #include <iupcontrols.h>
int param_action(Ihandle* dialog, int param_index, void* user_data)
{
switch(param_index)
{
case IUP_GETPARAM_BUTTON1:
printf("Button1 (OK)\n");
break;
case IUP_GETPARAM_INIT:
printf("Init\n");
break;
case IUP_GETPARAM_BUTTON2:
printf("Button2 (Cancel)\n");
break;
case IUP_GETPARAM_BUTTON3:
printf("Button3 (Help)\n");
break;
default:
{
Ihandle* param;
char param_str[50];
sprintf(param_str, "PARAM%d", param_index);
param = (Ihandle*)IupGetAttribute(dialog, param_str);
printf("%s = %s\n", param_str, IupGetAttribute(param, "VALUE"));
break;
}
}
return 1;
}
int main(int argc, char **argv)
{
int pboolean = 1;
int pinteger = 3456;
float preal = 3.543f;
int pinteger2 = 192;
float preal2 = 0.5f;
float pangle = 90;
char pstring[100] = "string text";
char pcolor[100] = "255 0 128";
int plist = 2;
char pstring2[200] = "second text\nsecond line";
char pfile_name[500] = "test.jpg";
IupOpen(&argc, &argv);
// IupControlsOpen(); /* so we can show the IupDial, but can be tested without it */
// IupSetLanguage("ENGLISH");
if (!IupGetParam("Title", param_action, 0,
"Boolean: %b[No,Yes]{Boolean Tip}\n"
"Integer: %i{Integer Tip}\n"
"Real 1: %r{Real Tip}\n"
"Sep1 %t\n"
"Integer: %i[0,255]{Integer Tip 2}\n"
"Real 2: %r[-1.5,1.5]{Real Tip 2}\n"
"Sep2 %t\n"
"Angle: %a[0,360]{Angle Tip}\n"
"String: %s{String Tip}\n"
"List: %l|item1|item2|item3|{List Tip}\n"
"File: %f[OPEN|*.bmp;*.jpg|CURRENT|NO|NO]{File Tip}\n"
"Color: %c{Color Tip}\n"
"Sep3 %t\n"
"Multiline: %m{Multiline Tip}\n",
&pboolean, &pinteger, &preal, &pinteger2, &preal2, &pangle, pstring, &plist, pfile_name, pcolor, pstring2, NULL))
return IUP_DEFAULT;
IupMessagef("IupGetParam",
"Boolean Value: %d\n"
"Integer: %d\n"
"Real 1: %g\n"
"Integer: %d\n"
"Real 2: %g\n"
"Angle: %g\n"
"String: %s\n"
"List Index: %d\n"
"FileName: %s\n"
"Color: %s\n"
"Multiline: %s",
pboolean, pinteger, (double)preal, pinteger2, (double)preal2, (double)pangle, pstring, plist, pfile_name, pcolor, pstring2);
IupClose();
return EXIT_SUCCESS;
}
your hint using the -l option was extremely helpful for me. I simply did not understand the meaning before.
include "$/inc/console.inc"
includepath "iup/"
extern lib "IUP/iup.dll" cdecl
include "iup.h"
'overriding const unsigned char* pixmap
Ihandle* IupImage (int width, int height, byte *pixmap);
Ihandle* IupImageRGB (int width, int height, byte *pixmap);
Ihandle* IupImageRGBA (int width, int height, byte *pixmap);
$ filename "cbox1.exe"
'include "$/inc/RTL32.inc"
'include "$/inc/console.inc"
includepath "iup/"
extern lib "IUP/iup.dll" cdecl
include "iup.h"
'overriding const unsigned char* pixmap in iup.h
Ihandle* IupImage (int width, int height, byte *pixmap)
Ihandle* IupImageRGB (int width, int height, byte *pixmap)
Ihandle* IupImageRGBA (int width, int height, byte *pixmap)
end extern
extern cdecl
cr=chr(13,10)
byte img_bits1[] =>
{
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1
,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1
,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1
,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1
,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1
,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1
,1,1,1,1,1,1,1,1,1,2,2,2,2,2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,1,3,3,3,3,0,0,0,3,3,3,3,3,3,3,3,3
,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3
,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3
,2,2,2,2,2,2,2,3,3,3,3,3,3,3,1,1,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,3,3,3,3,3,3,3,3,1,1,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
}
function createtree() as sys
sys tree = IupTree()
IupSetAttributes(tree, "FONT=COURIER_NORMAL_12, NAME=Figures,
RASTERSIZE=180x180, CX=600, CY=10" )
return tree
end function
sub func_1 ()
sys cbox, cnv_1, dlg, img,
frm_1, frm_2, frm_3, hbox, ctrl_1,
list_1, list_2, list_3, text_1, ml_1
img = IupImage(32,32, @img_bits1)
IupSetHandle ("img1", img)
IupSetAttribute (img, "0", "0 0 0")
IupSetAttribute (img, "1", "BGCOLOR")
IupSetAttribute (img, "2", "255 0 0")
img = IupImage(32,32, @img_bits2)
IupSetHandle ("img2", img)
IupSetAttribute (img, "0", "0 0 0")
IupSetAttribute (img, "1", "0 255 0")
IupSetAttribute (img, "2", "BGCOLOR")
IupSetAttribute (img, "3", "255 0 0")
'bottom-up
b1=IupButton("Button Text",NULL) : b2=IupButton("",NULL) : b3=IupButton("",NULL)
IupSetAttribute(b1, "CINDEX","1")
IupSetAttributes(b2, "IMAGE=img1, CINDEX=2")
IupSetAttributes(b3, "IMAGE=img1,IMPRESS=img2,CINDEX=3")
vbox1 = IupVbox(b1,b2,b3,NULL)
frm_1 = IupFrame(vbox1)
IupSetAttributes(frm_1,"TITLE=IupButton, CX=10, CY=180")
'bottom-up
l1=IupLabel("Label Text") : l2=IupLabel(NULL) : l3=IupLabel(NULL)
IupSetAttribute(l1, "CINDEX","1")
IupSetAttributes(l2, "SEPARATOR=HORIZONTAL,CINDEX=2")
IupSetAttributes(l3, "IMAGE=img1,CINDEX=3")
vbox2 = IupVbox(l1, l2, l3, NULL)
frm_2 = IupFrame(vbox2)
IupSetAttributes(frm_2,"TITLE=IupLabel, CX=200, CY=250")
'bottom-up
'checkboxes
t1=IupToggle("Toggle Text", NULL) : t2=IupToggle("", NULL)
IupSetAttributes(t1, "VALUE=ON, CINDEX=1")
IupSetAttributes(t2, "IMAGE=img1, IMPRESS=img2, CINDEX=2")
'show verical
vb1=IupVbox(t1, t2, NULL)
'radios
t3=IupToggle("Toggle Text", NULL) : t4=IupToggle("Toggle Text", NULL)
IupSetAttributes(t3, "CINDEX=3")
IupSetAttributes(t4, "CINDEX=4")
'show vertical
vb2=IupVbox(t3,t4)
'change to radios
radio=IupRadio(vb2)
'frame them
frame=IupFrame(radio)
IupSetAttribute(frame, "TITLE", "IupRadio")
vbox3=IupVbox(vb1,frame, NULL)
frm_3=IupFrame(vbox3)
IupSetAttribute(frm_3,"TITLE","IupToggle")
IupSetAttribute(frm_3,"CX","400")
IupSetAttribute(frm_3,"CY","250")
text_1 = IupText( NULL)
IupSetAttribute(text_1,"VALUE","IupText Text")
IupSetAttributes(text_1,"SIZE=80x, CINDEX=1, CX=10, CY=100")
ml_1 = IupMultiLine( NULL)
IupSetAttribute(ml_1,"VALUE","IupMultiline Text" & cr & "Second Line" & cr & "Third Line" & cr)
IupSetAttributes(ml_1,"SIZE=80x60, CINDEX=1, CX=200, CY=100")
list_1 = IupList( NULL)
IupSetAttributes(list_1,"VALUE=1, CINDEX=1, CX=10, CY=10")
IupSetAttribute(list_1,"1","Item 1 Text")
IupSetAttribute(list_1,"2","Item 2 Text")
IupSetAttribute(list_1,"3","Item 3 Text")
list_2 = IupList( NULL)
IupSetAttributeS(list_2,"DROPDOWN=YES, VALUE=2, CINDEX=2, CX=200, CY=10")
IupSetAttribute(list_2,"1","Item 1 Text")
IupSetAttribute(list_2,"2","Item 2 Text")
IupSetAttribute(list_2,"3","Item 3 Text")
list_3 = IupList( NULL)
IupSetAttributes(list_3,"EDITBOX=YES, VALUE=3, CINDEX=3, CX=400, CY=10")
IupSetAttribute(list_3,"1","Item 1 Text")
IupSetAttribute(list_3,"2","Item 2 Text")
IupSetAttribute(list_3,"3","Item 3 Text")
cnv_1 = IupCanvas( NULL)
IupSetAttributes(cnv_1,"RASTERSIZE=100x100, POSX=0, POSY=0, CX=400, CY=150")
IupSetAttribute(cnv_1,"BGCOLOR","128 255 0") 'green
ctrl_1 = IupVal(NULL)
IupSetAttributes(ctrl_1,"CX=600, CY=200")
cbox = IupCbox(
text_1,
ml_1,
list_1,
list_2,
list_3,
cnv_1,
ctrl_1,
createtree(),
frm_1,
frm_2,
frm_3,
NULL)
IupSetAttribute(cbox,"SIZE","480x200")
hbox = IupHbox(cbox, NULL)
IupSetAttribute(hbox, "MARGIN"," 10x10")
dlg = IupDialog(hbox)
IupSetHandle("dlg",dlg)
IupSetAttribute(dlg,"TITLE","Cbox Test")
end sub
sub main()
IupOpen(0,0)
func_1()
IupShowXY(IupGetHandle("dlg"),IUP_CENTER,IUP_CENTER)
IupMainLoop()
IupClose()
end sub
main()
Hi
May i ask about web browser with iUP?
i think that John present one written in SciptBasic
Hurrah! I found my bug (as always my weakness using pointers).