Author Topic: Question about IUP  (Read 23229 times)

0 Members and 1 Guest are viewing this topic.

JRS

  • Guest
Re: Question about IUP
« Reply #60 on: December 23, 2015, 10:50:23 AM »
Here is James example on Windows 7 32 bit using Script BASIC. I handle callbacks a bit differently in Script BASIC.

Code: Script BASIC
  1. ' James Fuller IUP LED Example
  2.  
  3. LED = """
  4. # ==============================================================================
  5. #cardfile
  6. # ==============================================================================
  7. btn_prior = BUTTON[SIZE = 50x15]("<< Prior",NULL)
  8. btn_next =  BUTTON[SIZE = 50x15]("Next >>",NULL)
  9. btn_find =   BUTTON[SIZE = 50x15]("Find",NULL)
  10. btn_add  =   BUTTON[SIZE = 50x15]("Add",NULL)
  11. btn_update =  BUTTON[SIZE = 50x15]("Update",NULL)
  12. btn_delete =  BUTTON[SIZE = 50x15]("Delete",NULL)
  13. btn_print =  BUTTON[SIZE = 50x15]("Print",NULL)
  14. btn_cancel = BUTTON[SIZE = 50x15]("Dismiss",NULL)
  15. # ==============================================================================
  16. id_index = LABEL[]("0 / 0")
  17. entry_company = TEXT[EXPAND = HORIZONTAL](NULL)
  18. entry_last = TEXT[EXPAND = HORIZONTAL](NULL)
  19. entry_first = TEXT[EXPAND = HORIZONTAL](NULL)
  20. entry_add1 = TEXT[EXPAND = HORIZONTAL](NULL)
  21. entry_add2 = TEXT[EXPAND = HORIZONTAL](NULL)
  22. entry_add3 = TEXT[EXPAND = HORIZONTAL](NULL)
  23. entry_city = TEXT[EXPAND = HORIZONTAL](NULL)
  24. entry_state = TEXT[SIZE = 120x](NULL)
  25. entry_zip = TEXT[SIZE = 80x](NULL)
  26. cbo_country = LIST[DROPDOWN=YES, SIZE=100x,VALUE=1](NULL)
  27. entry_phone = TEXT[SIZE=70x](NULL)
  28. entry_fax = TEXT[SIZE=70x](NULL)
  29. entry_email = TEXT[EXPAND = HORIZONTAL](NULL)
  30. entry_www = TEXT[EXPAND = HORIZONTAL](NULL)
  31. entry_comments = TEXT[MULTILINE=YES, EXPAND=YES](NULL)
  32. # ==============================================================================
  33. cardfile = DIALOG[ USERSIZE = 750x563, TITLE = "Card File", RASTERSIZE = 750x563]
  34. (
  35.    VBOX[MARGIN = 5x5]
  36.    (
  37.        HBOX[GAP = 5]
  38.        (
  39.            FILL(),
  40.            LABEL[TITLE = " Record No."](""),id_index
  41.        ),
  42.        FRAME[TITLE = Company]
  43.        (
  44.             entry_company
  45.        ),
  46.        HBOX[GAP = 5]
  47.        (
  48.            FRAME[TITLE = "Last Name"]
  49.            (
  50.                entry_last
  51.            ),
  52.            FRAME[TITLE = "First Name"]
  53.            (
  54.                entry_first
  55.            )
  56.        ),
  57.        FRAME[TITLE = "Address"]
  58.        (
  59.            VBOX[GAP = 5]
  60.            (
  61.                entry_add1,
  62.                entry_add2,
  63.                entry_add3
  64.            )
  65.        ),
  66.        HBOX[GAP = 5]
  67.        (
  68.            FRAME[TITLE = "City"]
  69.            (
  70.                entry_city
  71.            ),
  72.            FRAME[ TITLE = "State / Province"]
  73.            (
  74.                 entry_state
  75.            ),
  76.            FRAME[TITLE = "Zip or Postal Code"]
  77.            (
  78.                entry_zip
  79.            ),
  80.            FRAME[TITLE = "Country"]
  81.            (
  82.                 cbo_country
  83.            )
  84.        ),
  85.        HBOX[GAP = 5]
  86.        (
  87.            FRAME[TITLE = "Phone"]
  88.            (
  89.                entry_phone
  90.            ),
  91.            FRAME[TITLE = "Fax"]
  92.            (
  93.                entry_fax
  94.            ),
  95.            FRAME[TITLE = "Email"]
  96.            (
  97.                entry_email
  98.            ),
  99.            FRAME[TITLE = "www"]
  100.            (
  101.                entry_www
  102.            )
  103.        ),
  104.        FRAME[TITLE = "Comments"]
  105.        (
  106.            TEXT[EXPAND = YES,MULTILINE = YES,NAME = entry_comments](do_nothing)
  107.        ),
  108.        HBOX[GAP = 10]
  109.        (
  110.            FILL(),
  111.            btn_prior,btn_next,btn_find,btn_add,btn_update,btn_delete,btn_print,btn_cancel,
  112.            FILL()
  113.        )
  114.    )
  115. )
  116. """
  117.  
  118. SUB Win_exit
  119.   Iup::ExitLoop = TRUE
  120. END SUB
  121.  
  122. IMPORT iup.bas
  123.  
  124. Iup::Open(0,0)
  125.  
  126. Iup::LoadBuffer(LED)
  127.  
  128. Iup::SetCallback(Iup::GetHandle("btn_cancel"), "ACTION", ADDRESS(Win_exit()))
  129.  
  130. Iup::Show(Iup::GetHandle("cardfile"))
  131.  
  132. Iup::MainLoop()
  133.  
  134. Iup::Close()
  135.  


.
« Last Edit: December 23, 2015, 11:35:37 PM by John »

JRS

  • Guest
Re: Question about IUP
« Reply #61 on: December 24, 2015, 01:18:07 PM »
I added default IUP graphics to the buttons. I also let the containers determine overall dialog size. (linux version)

Code: Script BASIC
  1. ' James Fuller IUP LED Example
  2.  
  3. IMPORT iup.bas
  4.  
  5. LED = """
  6. # ==============================================================================
  7. #cardfile
  8. # ==============================================================================
  9. btn_prior = BUTTON[SIZE = 50x15, IMAGE=IUP_ArrowLeft]("",NULL)
  10. btn_next =  BUTTON[SIZE = 50x15, IMAGE=IUP_ArrowRight]("",NULL)
  11. btn_find =   BUTTON[SIZE = 50x15, IMAGE=IUP_EditFind]("",NULL)
  12. btn_add  =   BUTTON[SIZE = 50x15, IMAGE=IUP_FileSave]("",NULL)
  13. btn_update =  BUTTON[SIZE = 50x15, IMAGE=IUP_NavigateRefresh]("",NULL)
  14. btn_delete =  BUTTON[SIZE = 50x15, IMAGE=IUP_EditErase]("",NULL)
  15. btn_print =  BUTTON[SIZE = 50x15, IMAGE=IUP_Print]("",NULL)
  16. btn_cancel = BUTTON[SIZE = 50x15, IMAGE=IUP_ActionCancel]("",NULL)
  17. # ==============================================================================
  18. id_index = LABEL[]("0 / 0")
  19. entry_company = TEXT[EXPAND = HORIZONTAL](NULL)
  20. entry_last = TEXT[EXPAND = HORIZONTAL](NULL)
  21. entry_first = TEXT[EXPAND = HORIZONTAL](NULL)
  22. entry_add1 = TEXT[EXPAND = HORIZONTAL](NULL)
  23. entry_add2 = TEXT[EXPAND = HORIZONTAL](NULL)
  24. entry_add3 = TEXT[EXPAND = HORIZONTAL](NULL)
  25. entry_city = TEXT[EXPAND = HORIZONTAL](NULL)
  26. entry_state = TEXT[SIZE = 120x](NULL)
  27. entry_zip = TEXT[SIZE = 80x](NULL)
  28. cbo_country = LIST[DROPDOWN=YES, SIZE=100x,VALUE=1](NULL)
  29. entry_phone = TEXT[SIZE=70x](NULL)
  30. entry_fax = TEXT[SIZE=70x](NULL)
  31. entry_email = TEXT[EXPAND = HORIZONTAL](NULL)
  32. entry_www = TEXT[EXPAND = HORIZONTAL](NULL)
  33. entry_comments = TEXT[MULTILINE=YES, EXPAND=YES](NULL)
  34. # ==============================================================================
  35. cardfile = DIALOG[TITLE = "Card File"]
  36. (
  37.    VBOX[MARGIN = 5x5]
  38.    (
  39.        HBOX[GAP = 5]
  40.        (
  41.            FILL(),
  42.            LABEL[TITLE = " Record No."](""),id_index
  43.        ),
  44.        FRAME[TITLE = Company]
  45.        (
  46.             entry_company
  47.        ),
  48.        HBOX[GAP = 5]
  49.        (
  50.            FRAME[TITLE = "Last Name"]
  51.            (
  52.                entry_last
  53.            ),
  54.            FRAME[TITLE = "First Name"]
  55.            (
  56.                entry_first
  57.            )
  58.        ),
  59.        FRAME[TITLE = "Address"]
  60.        (
  61.            VBOX[GAP = 5]
  62.            (
  63.                entry_add1,
  64.                entry_add2,
  65.                entry_add3
  66.            )
  67.        ),
  68.        HBOX[GAP = 5]
  69.        (
  70.            FRAME[TITLE = "City"]
  71.            (
  72.                entry_city
  73.            ),
  74.            FRAME[ TITLE = "State / Province"]
  75.            (
  76.                 entry_state
  77.            ),
  78.            FRAME[TITLE = "Zip or Postal Code"]
  79.            (
  80.                entry_zip
  81.            ),
  82.            FRAME[TITLE = "Country"]
  83.            (
  84.                 cbo_country
  85.            )
  86.        ),
  87.        HBOX[GAP = 5]
  88.        (
  89.            FRAME[TITLE = "Phone"]
  90.            (
  91.                entry_phone
  92.            ),
  93.            FRAME[TITLE = "Fax"]
  94.            (
  95.                entry_fax
  96.            ),
  97.            FRAME[TITLE = "Email"]
  98.            (
  99.                entry_email
  100.            ),
  101.            FRAME[TITLE = "www"]
  102.            (
  103.                entry_www
  104.            )
  105.        ),
  106.        FRAME[TITLE = "Comments"]
  107.        (
  108.            TEXT[EXPAND = YES,MULTILINE = YES,NAME = entry_comments](do_nothing)
  109.        ),
  110.        HBOX[GAP = 10]
  111.        (
  112.            FILL(),
  113.            btn_prior,btn_next,btn_find,btn_add,btn_update,btn_delete,btn_print,btn_cancel,
  114.            FILL()
  115.        )
  116.    )
  117. )
  118. """
  119. Iup::Open
  120. Iup::ImageLibOpen
  121.  
  122. Iup::LoadBuffer LED
  123.  
  124. Iup::Show(Iup::GetHandle("cardfile"))
  125.  
  126. Iup::MLoop
  127.  
  128. Iup::Close
  129.  


.
« Last Edit: December 25, 2015, 02:14:21 AM by John »

JRS

  • Guest
Re: Question about IUP
« Reply #62 on: December 25, 2015, 01:23:39 PM »
I added a call to set a common system font for both Windows and Linux version for the cross platform IUP examples I've posted. I'm using Helvetica font face which was the recommendation in the IUP docs for common ground (sizing) between platforms. I'm using 11 pt for Windows and 10 pt for Linux Gtk. If you plan to try this cross platform, your settings may be different based on your monitor and DPI on each platform. I don't even want to think how this is going to look on Windows 10.  :o

Code: [Select]
Iup::Open
Iup::ImageLibOpen
Iup::SetGlobal("DEFAULTFONT", "Helvetica, 10")
Iup::LoadBuffer LED

Iup::Show(Iup::GetHandle("cardfile"))

Iup::MainLoop

Iup::Close

.
« Last Edit: December 25, 2015, 02:29:13 PM by John »

JRS

  • Guest
Re: Question about IUP
« Reply #63 on: January 04, 2016, 09:14:06 PM »
Hi Roland,

How are things going with your O2 IUP adventures? It looks like James is chipping away at it based on posts to the IUP mailing list. It would be interesting to hear where he is going with IUP.


Arnold

  • Guest
Re: Question about IUP
« Reply #64 on: January 06, 2016, 08:58:23 AM »
Hi John,

I have not yet continued with IUP as I am still working on the Oxygen-BCX project which is still a fascinating matter. In the meantime I managed to work with accelerator keys, added the code for font and color dialog and at the moment I try to add memory based dialogs. Thanks to the help of Charles and Mike I advanced much more than I expected when I started this project. Three major controls and the code for sound must be added to the library, some bugs must be examined. Working a little bit at a snail's pace this will take some time. But then the library should be ready to pass the testing phase.

Roland

JRS

  • Guest
Re: Question about IUP
« Reply #65 on: January 06, 2016, 11:52:40 AM »
Roland,

I don't understand why anyone would take a funky BASIC to C translator written in itself and cripple O2 BASIC emulating it. James has spent years chasing the BCX dream. IUP and O2 is the best path IMHO.

@James: Try using IupStoreAttribute() rather than IupSetAttribute() with your PBCC issues.

John
« Last Edit: January 06, 2016, 10:30:43 PM by John »

Arnold

  • Guest
Re: Question about IUP
« Reply #66 on: January 07, 2016, 01:09:13 AM »
Hi John,

yes, IUP is a very powerful library. But with the already included examples in the Oxygen distribution and presented here it is already possible to do own researches.

BTW in the thread:

Exploring Iup Library version 3.14


I uploaded a zip file with Iup3.14 dlls and a zip file with lot of examples using an include file with wrapped Iup functions. These files seem not to be present any more. Are uploaded files deleted automatically after some time? The same happened to theForger Winapi examples which show many principles of WinApi programming using OxygenBasic.

The BCXgui library is not a translator of BCX to o2. It is a collection of selected BCX runtime functions for using Windows gui with OxygenBasic. If there would be a bcxgui.dll I would have used this. The advantage of using a runtime library written in O2 is that it can be modified and extended in the same language. I could have used different names for the functions or combined it with some other functionality but that would be cheating. (Some minimal modifications are necessary nevertheless).

Not all BCX functions are necessary as OxygenBasic has it's own powerful built-in functions set. And therefore I can run almost all BCX code with only minimal changes. The files work at least with 32 bit Windows Vista. Maybe this will be different with Windows 8.1 and Windows 10 but I am not yet to this point.

Roland


Aurel

  • Guest
Re: Question about IUP
« Reply #67 on: January 07, 2016, 05:07:44 AM »
Quote
Are 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?

Aurel

  • Guest
Re: Question about IUP
« Reply #68 on: January 07, 2016, 05:36:44 AM »
well...it looks that i need to translate this :
to oxygen...hmmm  ..maybe i will  ::)

Code: [Select]
/*
 * 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;
}

JRS

  • Guest
Re: Question about IUP
« Reply #69 on: January 07, 2016, 08:54:46 PM »
Quote
Are 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?

IUP is a framework and uses the OS native API. The IUP driver is what is unique to each OS.