include "$/inc/console.inc"
typedef sys Icallback
includepath "iup\"
extern lib "IUP/iup.dll" cdecl
#define IUP_DEFAULT -2
#define IUP_CENTER 0xFFFF /* 65535 */
! IupOpen (sys argc,argv) as int
! IupClose ()
! IupMainLoop () as int
! IupShowXY (sys ih, int x, int y) as int
! IupSetAttribute (sys ih, string name, string value)
! IupStoreAttribute(sys ih, string name, string value)
! IupSetFunction(string name, Icallback func) as Icallback
! IupSetCallback (sys ih, string name, Icallback func) as Icallback
! IupCanvas (string action) as sys
! IupDialog (sys child) as sys
end extern
extern cdecl
static int idle_count = 0
function idle()
print "IDLE_ACTION( count = " idle_count ")" & cr
idle_count++
// if (idle_count == 10000)
// return IUP_IGNORE
return IUP_DEFAULT
end function
function motion_cb(sys ih) as int callback
print "MOTION_CB()" & cr
if (idle_count > 15000) then
IupSetFunction ("IDLE_ACTION", NULL)
end if
return IUP_DEFAULT
end function
sub IdleTest()
sys dlg, canvas
canvas = IupCanvas(NULL)
IupSetCallback(canvas, "MOTION_CB", @motion_cb)
dlg = IupDialog(canvas)
IupSetAttribute(dlg, "TITLE", "Idle Test")
IupSetAttribute(dlg, "RASTERSIZE", "500x500")
' IupStoreAttribute(dlg, "TITLE", "Idle Test")
' IupStoreAttribute(dlg, "RASTERSIZE", "500x500")
IupShowXY(dlg, IUP_CENTER, IUP_CENTER)
IupSetFunction ("IDLE_ACTION", @idle)
end sub
sub main()
IupOpen(0,0)
IdleTest()
IupMainLoop()
IupClose()
end sub
main()
I am not at all familiar with IUP. John is the expert.
BTW I noticed that you added a folder \tests in the latest OxygenBasic.zip. Was this done intentionally?
includepath "iup\"
extern lib "IUP/iup.dll" cdecl
! IupOpen (sys argc,argv) as int
! IupClose ()
! IupMessage (char *title, char *msg)
! IupMessagef (char *title, char *format, ...)
! IupScanf (char *format, ...) as int
end extern
/*
includepath "iup/"
extern lib "IUP/iup.dll" cdecl
include "iup.h"
*/
extern cdecl
% lf = chr(10) '\n' ??
% crlf = chr(13,10)
sub ScanfTest()
int result
int integr = 12
float real = 0.001f ' 1e-3f
char text[300]="This is a vector of characters"
char *fmt =
' {
' "IupScanf Example\n" &
' "Text: %300.5%s\n" &
' "Real: %20.10%g\n" &
' "Integer: %20.10%d\n"
' }
"IupScanf Example\nText: %300.5%s\nReal: %20.10%g\nInteger: %20.10%d\n"
' "IupScanf Example" lf "Text: %300.5%s" lf "Real: %20.10%g" lf "Integer: %20.10%d" lf
' does not work?
IupMessagef("Before IupScanf","Text: %s" lf "Real: %f" lf "Integer: %d" ,
text, real, integr )
' does not work?
result = IupScanf(fmt, text, &real, &integr)
if result = -1 then
IupMessage("IupScanf","Operation canceled")
else
' IupMessagef("IupScanf","Text: %s\nReal: %f\nInteger: %d\nFields read successfully: %d",text,real,integr,result)
IupMessagef("IupScanf","Text: %s" lf "Real: %f" lf "Integer: %d" lf "Fields read successfully: %d",
text,real,integr,result)
end if
end sub
sub main()
IupOpen(0,0)
ScanfTest()
IupClose()
end sub
main()
PS: Yes, o2 will accept IUP headers undoctored.
It is recommended that new applications use the IupGetParam dialog instead.
But what is the bug? IupGetparam is widely used around here.
'getcolor2.o2bas
include "$/inc/console.inc"
includepath "iup\"
extern lib "IUP/iup.dll" cdecl
include "iup.h"
'int IupOpen (int *argc, char ***argv);
'void IupClose (void);
'int IupGetColor(int x, int y, unsigned char* r, unsigned char* g, unsigned char* b);
end extern
extern cdecl
/*
' will not work at all
sub GetColorTest()
byte r = 10, g = 100, b = 25
if IupGetColor(100, 100, &r, &g, &b) then
print "RGB = " r "," g "," b " Hex=[" hex(r) "," hex(g) "," hex(b) "]" &
cr &"Enter ..." & cr
end if
end sub
sub main()
IupOpen(0,0)
GetColorTest()
IupClose()
end sub
main()
waitkey()
*/
' returns false result
IupOpen(0,0)
byte r = 10, g = 100, b = 25
int result=IupGetColor(100, 100, &r, &g, &b)
if result then
print "RGB = " r "," g "," b " Hex=[" hex(r) "," hex(g) "," hex(b) "]" &
cr &"Enter ..." & cr
end if
IupClose()
waitkey()
Also added are two demos (tabs.o2bas, zbox.o2bas) which use LED files. These are simple text files which can be used for creating dialogs and controls. The callback events are then handled in the main .o2bas files. Using LED files is indeed an interesting option.
In LED, attributes and expressions follow this form:
elem = element[attribute1=value1,attribute2=value2,...](...expression...)
The names of the elements must not contain the “iup†prefix
#jfdemo1H Example in LED
servercombo = LIST [DROPDOWN=YES, SIZE=120x, EXPAND=HORIZONTAL, VALUE=1] (NULL)
btnFetch = BUTTON [SIZE = 50x] ("Fetch",NULL)
btnAbout = BUTTON [SIZE = 50x] ("About",NULL)
btnClear = BUTTON [SIZE = 50x] ("Clear",NULL)
btnExit = BUTTON [SIZE = 50x] ("E&xit", quit_cb)
serverList = LIST [EXPAND=YES, VISIBLELINES=1] (NULL)
textbox = TEXT [MULTILINE=YES, EXPAND=YES] (NULL)
lable = LABEL [SIZE=x12] ("Enter Word to Search For:")
entry = TEXT [EXPAND=HORIZONTAL] (NULL)
btnSearch = BUTTON [SIZE=50x] ("Search", NULL)
chkAll = TOGGLE [VALUE=ON, SIZE=x12] ("ALL", NULL)
chkUTF = TOGGLE [SIZE=x12] ("UTF-8", NULL)
win = DIALOG [TITLE=Thesaurus, SIZE=500x300]
(
VBOX [MARGIN=10x10]
(
HBOX [GAP=10]
( FRAME [TITLE=Servers, EXPAND=YES]
( HBOX [GAP=5] ( servercombo, btnFetch ) ) ,
FRAME [TITLE=Controls]
( HBOX [MARGIN=6x6, GAP=5] ( btnAbout, btnClear, btnExit ) )
) ,
FRAME [TITLE=Dictionaries]
( serverList ) ,
FRAME [TITLE=Translation]
( textbox) ,
HBOX [GAP=10] ( lable, entry, btnSearch, chkAll, chkUTF )
)
)
it seems that Scriptbasic can also handle IUP in Linux. This is of course a very nice feature. Is there a downloadable version of Scriptbasic for Windows too?
Hi All,
We just released IUP version 3.15.
We would like to highlight some of the new features:
- New: "iup_class_cbs.hpp" header with macros to help creation of callbacks as methods in C++.
- New: global hot key (Alt+Ctrl+Shft+L) to show the current dialog layout in a IupLayoutDialog dialog.
- New: Tutorial section in the documentation. It is still under construction but already has several topics completed.
- New: IupFlatButton control that mimics a IupButton but does not have native system decorations.
- New: IupConfig support in Lua.
You can find the complete list of changes and files for download at:
http://www.tecgraf.puc-rio.br/iup/
and
http://iup.sourceforge.net/
Best Regards,
Antonio Scuri
You should be fast asleep. Are you nocturnal?
# ==============================================================================
#cardfile
# ==============================================================================
btn_prior = BUTTON[SIZE = 50x15]("<< Prior",NULL)
btn_next = BUTTON[SIZE = 50x15]("Next >>",NULL)
btn_find = BUTTON[SIZE = 50x15]("Find",NULL)
btn_add = BUTTON[SIZE = 50x15]("Add",NULL)
btn_update = BUTTON[SIZE = 50x15]("Update",NULL)
btn_delete = BUTTON[SIZE = 50x15]("Delete",NULL)
btn_print = BUTTON[SIZE = 50x15]("Print",NULL)
btn_cancel = BUTTON[SIZE = 50x15]("Dismiss",NULL)
# ==============================================================================
id_index = LABEL[]("0 / 0")
entry_company = TEXT[EXPAND = HORIZONTAL](NULL)
entry_last = TEXT[EXPAND = HORIZONTAL](NULL)
entry_first = TEXT[EXPAND = HORIZONTAL](NULL)
entry_add1 = TEXT[EXPAND = HORIZONTAL](NULL)
entry_add2 = TEXT[EXPAND = HORIZONTAL](NULL)
entry_add3 = TEXT[EXPAND = HORIZONTAL](NULL)
entry_city = TEXT[EXPAND = HORIZONTAL](NULL)
entry_state = TEXT[SIZE = 120x](NULL)
entry_zip = TEXT[SIZE = 80x](NULL)
cbo_country = LIST[DROPDOWN=YES, SIZE=100x,VALUE=1](NULL)
entry_phone = TEXT[SIZE=70x](NULL)
entry_fax = TEXT[SIZE=70x](NULL)
entry_email = TEXT[EXPAND = HORIZONTAL](NULL)
entry_www = TEXT[EXPAND = HORIZONTAL](NULL)
entry_comments = TEXT[MULTILINE=YES, EXPAND=YES](NULL)
# ==============================================================================
cardfile = DIALOG[ USERSIZE = 750x563, TITLE = "Card File", RASTERSIZE = 750x563]
(
VBOX[MARGIN = 5x5]
(
HBOX[GAP = 5]
(
FILL(),
LABEL[TITLE = " Record No."](""),id_index
),
FRAME[TITLE = Company]
(
entry_company
),
HBOX[GAP = 5]
(
FRAME[TITLE = "Last Name"]
(
entry_last
),
FRAME[TITLE = "First Name"]
(
entry_first
)
),
FRAME[TITLE = "Address"]
(
VBOX[GAP = 5]
(
entry_add1,
entry_add2,
entry_add3
)
),
HBOX[GAP = 5]
(
FRAME[TITLE = "City"]
(
entry_city
),
FRAME[ TITLE = "State / Province"]
(
entry_state
),
FRAME[TITLE = "Zip or Postal Code"]
(
entry_zip
),
FRAME[TITLE = "Country"]
(
cbo_country
)
),
HBOX[GAP = 5]
(
FRAME[TITLE = "Phone"]
(
entry_phone
),
FRAME[TITLE = "Fax"]
(
entry_fax
),
FRAME[TITLE = "Email"]
(
entry_email
),
FRAME[TITLE = "www"]
(
entry_www
)
),
FRAME[TITLE = "Comments"]
(
TEXT[EXPAND = YES,MULTILINE = YES,NAME = entry_comments](do_nothing)
),
HBOX[GAP = 10]
(
FILL(),
btn_prior,btn_next,btn_find,btn_add,btn_update,btn_delete,btn_print,btn_cancel,
FILL()
)
)
)
dim as string cardfile_led = quote
-cardfile-
# ==============================================================================
#cardfile
# ==============================================================================
btn_prior = BUTTON[SIZE = 50x15]("<< Prior", message_cb)
btn_next = BUTTON[SIZE = 50x15]("Next >>",message_cb)
btn_find = BUTTON[SIZE = 50x15]("Find",message_cb)
btn_add = BUTTON[SIZE = 50x15]("Add",message_cb)
btn_update = BUTTON[SIZE = 50x15]("Update",message_cb)
btn_delete = BUTTON[SIZE = 50x15]("Delete",message_cb)
btn_print = BUTTON[SIZE = 50x15]("Print",message_cb)
btn_cancel = BUTTON[SIZE = 50x15]("Dismiss", cancel_cb)
# ==============================================================================
id_index = LABEL[]("0 / 0")
entry_company = TEXT[EXPAND = HORIZONTAL](NULL)
entry_last = TEXT[EXPAND = HORIZONTAL](NULL)
entry_first = TEXT[EXPAND = HORIZONTAL](NULL)
entry_add1 = TEXT[EXPAND = HORIZONTAL](NULL)
entry_add2 = TEXT[EXPAND = HORIZONTAL](NULL)
entry_add3 = TEXT[EXPAND = HORIZONTAL](NULL)
entry_city = TEXT[EXPAND = HORIZONTAL](NULL)
entry_state = TEXT[SIZE = 120x](NULL)
entry_zip = TEXT[SIZE = 80x](NULL)
cbo_country = LIST[DROPDOWN=YES, SIZE=100x,VALUE=1](NULL)
entry_phone = TEXT[SIZE=70x](NULL)
entry_fax = TEXT[SIZE=70x](NULL)
entry_email = TEXT[EXPAND = HORIZONTAL](NULL)
entry_www = TEXT[EXPAND = HORIZONTAL](NULL)
entry_comments = TEXT[MULTILINE=YES, EXPAND=YES](NULL)
# ==============================================================================
cardfile = DIALOG[ USERSIZE = 750x563, TITLE = "Card File", RASTERSIZE = 750x563]
(
VBOX[MARGIN = 5x5]
(
HBOX[GAP = 5]
(
FILL(),
LABEL[TITLE = " Record No."](""),id_index
),
FRAME[TITLE = Company]
(
entry_company
),
HBOX[GAP = 5]
(
FRAME[TITLE = "Last Name"]
(
entry_last
),
FRAME[TITLE = "First Name"]
(
entry_first
)
),
FRAME[TITLE = "Address"]
(
VBOX[GAP = 5]
(
entry_add1,
entry_add2,
entry_add3
)
),
HBOX[GAP = 5]
(
FRAME[TITLE = "City"]
(
entry_city
),
FRAME[ TITLE = "State / Province"]
(
entry_state
),
FRAME[TITLE = "Zip or Postal Code"]
(
entry_zip
),
FRAME[TITLE = "Country"]
(
cbo_country
)
),
HBOX[GAP = 5]
(
FRAME[TITLE = "Phone"]
(
entry_phone
),
FRAME[TITLE = "Fax"]
(
entry_fax
),
FRAME[TITLE = "Email"]
(
entry_email
),
FRAME[TITLE = "www"]
(
entry_www
)
),
FRAME[TITLE = "Comments"]
(
TEXT[EXPAND = YES,MULTILINE = YES,NAME = entry_comments](do_nothing)
),
HBOX[GAP = 10]
(
FILL(),
btn_prior,btn_next,btn_find,btn_add,btn_update,btn_delete,btn_print,btn_cancel,
FILL()
)
)
)
-cardfile-
Iup::Open
Iup::ImageLibOpen
Iup::SetGlobal("DEFAULTFONT", "Helvetica, 10")
Iup::LoadBuffer LED
Iup::Show(Iup::GetHandle("cardfile"))
Iup::MainLoop
Iup::Close
Are uploaded files deleted automatically after some time?who ...what ..where ?
/*
* IupWebBrowser sample
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <iup.h>
#include <iupweb.h>
#ifndef WIN32
static int history_cb(Ihandle* ih)
{
int i;
char str[50];
int back = IupGetInt(ih, "BACKCOUNT");
int fwrd = IupGetInt(ih, "FORWARDCOUNT");
printf("HISTORY ITEMS\n");
for(i = -(back); i < 0; i++)
{
sprintf(str, "ITEMHISTORY%d", i);
printf("Backward %02d: %s\n", i, IupGetAttribute(ih, str));
}
sprintf(str, "ITEMHISTORY%d", 0);
printf("Current %02d: %s\n", 0, IupGetAttribute(ih, str));
for(i = 1; i <= fwrd; i++)
{
sprintf(str, "ITEMHISTORY%d", i);
printf("Forward %02d: %s\n", i, IupGetAttribute(ih, str));
}
return IUP_DEFAULT;
}
#endif
static int navigate_cb(Ihandle* self, char* url)
{
printf("NAVIGATE_CB: %s\n", url);
(void)self;
if (strstr(url, "download")!=NULL)
return IUP_IGNORE;
return IUP_DEFAULT;
}
static int error_cb(Ihandle* self, char* url)
{
printf("ERROR_CB: %s\n", url);
(void)self;
return IUP_DEFAULT;
}
static int completed_cb(Ihandle* self, char* url)
{
printf("COMPLETED_CB: %s\n", url);
(void)self;
return IUP_DEFAULT;
}
static int newwindow_cb(Ihandle* self, char* url)
{
printf("NEWWINDOW_CB: %s\n", url);
IupSetAttribute(self, "VALUE", url);
return IUP_DEFAULT;
}
static int back_cb(Ihandle* self)
{
Ihandle* web = (Ihandle*)IupGetAttribute(self, "MY_WEB");
IupSetAttribute(web, "BACKFORWARD", "-1");
// printf("zoom=%s\n", IupGetAttribute(web, "ZOOM"));
return IUP_DEFAULT;
}
static int forward_cb(Ihandle* self)
{
Ihandle* web = (Ihandle*)IupGetAttribute(self, "MY_WEB");
IupSetAttribute(web, "BACKFORWARD", "1");
// IupSetAttribute(web, "ZOOM", "200");
return IUP_DEFAULT;
}
static int stop_cb(Ihandle* self)
{
Ihandle* web = (Ihandle*)IupGetAttribute(self, "MY_WEB");
IupSetAttribute(web, "STOP", NULL);
return IUP_DEFAULT;
}
static int reload_cb(Ihandle* self)
{
Ihandle* web = (Ihandle*)IupGetAttribute(self, "MY_WEB");
IupSetAttribute(web, "RELOAD", NULL);
//TEST:
// printf("STATUS=%s\n", IupGetAttribute(web, "STATUS"));
return IUP_DEFAULT;
}
static int load_cb(Ihandle* self)
{
Ihandle* txt = (Ihandle*)IupGetAttribute(self, "MY_TEXT");
Ihandle* web = (Ihandle*)IupGetAttribute(self, "MY_WEB");
IupSetAttribute(web, "VALUE", IupGetAttribute(txt, "VALUE"));
//TESTS:
// IupSetAttribute(txt, "VALUE", IupGetAttribute(web, "VALUE"));
// IupSetAttribute(web, "HTML", "<html><body><b>Hello</b>, World!</body></html>");
// IupSetAttribute(web, "VALUE", "http://www.microsoft.com");
return IUP_DEFAULT;
}
void WebBrowserTest(void)
{
Ihandle *txt, *dlg, *web;
Ihandle *btLoad, *btReload, *btBack, *btForward, *btStop;
#ifndef WIN32
Ihandle *history;
#endif
IupWebBrowserOpen();
// Creates an instance of the WebBrowser control
web = IupWebBrowser();
// Creates a dialog containing the control
dlg = IupDialog(IupVbox(IupHbox(btBack = IupButton("Back", NULL),
btForward = IupButton("Forward", NULL),
txt = IupText(""),
btLoad = IupButton("Load", NULL),
btReload = IupButton("Reload", NULL),
btStop = IupButton("Stop", NULL),
#ifndef WIN32
history = IupButton("History", NULL),
#endif
NULL),
web, NULL));
IupSetAttribute(dlg, "TITLE", "IupWebBrowser");
IupSetAttribute(dlg, "MY_TEXT", (char*)txt);
IupSetAttribute(dlg, "MY_WEB", (char*)web);
IupSetAttribute(dlg, "RASTERSIZE", "800x600");
IupSetAttribute(dlg, "MARGIN", "10x10");
IupSetAttribute(dlg, "GAP", "10");
//IupSetAttribute(web, "HTML", "<html><body><b>Hello</b>World!</body></html>");
// IupSetAttribute(txt, "VALUE", "My HTML");
IupSetAttribute(txt, "VALUE", "http://www.tecgraf.puc-rio.br/iup");
// IupSetAttribute(txt, "VALUE", "file:///D:/tecgraf/iup/html/index.html");
IupSetAttribute(web, "VALUE", IupGetAttribute(txt, "VALUE"));
IupSetAttributeHandle(dlg, "DEFAULTENTER", btLoad);
IupSetAttribute(txt, "EXPAND", "HORIZONTAL");
IupSetCallback(btLoad, "ACTION", (Icallback)load_cb);
IupSetCallback(btReload, "ACTION", (Icallback)reload_cb);
IupSetCallback(btBack, "ACTION", (Icallback)back_cb);
IupSetCallback(btForward, "ACTION", (Icallback)forward_cb);
IupSetCallback(btStop, "ACTION", (Icallback)stop_cb);
#ifndef WIN32
IupSetCallback(history, "ACTION", (Icallback)history_cb);
#endif
IupSetCallback(web, "NEWWINDOW_CB", (Icallback)newwindow_cb);
IupSetCallback(web, "NAVIGATE_CB", (Icallback)navigate_cb);
IupSetCallback(web, "ERROR_CB", (Icallback)error_cb);
IupSetCallback(web, "COMPLETED_CB", (Icallback)completed_cb);
// Shows dialog
IupShow(dlg);
}
int main(int argc, char* argv[])
{
IupOpen(&argc, &argv);
WebBrowserTest();
IupMainLoop();
IupClose();
return EXIT_SUCCESS;
}
QuoteAre uploaded files deleted automatically after some time?who ...what ..where ?
I doubt that some files are deleted automatically ,but maybe im wrong...
anyway ...
i don't like this Iup BUT only in one case
if i remeber there is a built in Iup - browser ?
and IF...what web layer use this web browser?