IUP 3.5 Windows / Linux (BSD too) GUI Headers Available

Headers, Bindings, Libraries for use with FreeBASIC, Please include example of use to help ensure they are tested and usable.
Post Reply
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: IUP 3.5 Windows / Linux (BSD too) GUI Headers Available

Post by D.J.Peters »

Aded many "optional" files marked as "_opt.bi"
iup_array_opt.bi, iup_assert_opt.bi, iup_attrib_opt.bi, iup_childtree_opt.bi, iup_classbase_opt.bi, iup_class_opt.bi,
iup_dlglist_opt.bi, iup_draw_opt.bi, iup_drvfont_opt.bi, iup_drvinfo_opt.bi, iup_drv_opt.bi, iup_extra_opt.bi,
iup_focus_opt.bi, iup_image_opt.bi, iup_key_opt.bi, iup_mask_opt.bi, iup_object_opt.bi, iup_register_opt.bi, iup_table_opt.bi

We can create our own IUP classes now.

Joshy

my first try (IupUserClass.bas and iupuserclass.bi in the download)

Code: Select all

#ifndef __IUPOVAL_BI__
#define __IUPOVAL_BI__

' simple example of a user defined IUP class

#include once "inc/iup_object_opt.bi"
#include once "inc/iup_register_opt.bi"
#include once "inc/iup_draw_opt.bi"

declare function OvalNewClass cdecl () as Iclass ptr

' register the NewClass function
sub IupOvalOpen cdecl()
  if (IupGetGlobal("_IUP_OVAL_OPEN")=0) then
    iupRegisterClass(OvalNewClass())
    IupSetGlobal("_IUP_OVAL_OPEN", "1")
  end if
end sub
' 
function IupOval cdecl ()as Ihandle ptr
  return IupCreatev("oval",NULL)
end function

' our private oval data
type OVAL_DATA
  as IDrawCanvas ptr dc
  as integer         nPoints
  as integer ptr     pPoints
end type

#define GETOVALDATA(v) dim as OVAL_DATA ptr v = cast(OVAL_DATA ptr,IupGetAttribute(ih, "_IUP_OVALDATA"))

function OvalResize_CB cdecl ( ih as Ihandle ptr, w as integer, h as integer) as integer
  '? "OvalDefaultResize_CB " w & " x " & h
  GETOVALDATA(pData)
  if pData then
    if pData->dc then
      ' a bug in IUP 3.5 need this
      pData->dc->w=w+1 
      pData->dc->h=h+1
      iupDrawUpdateSize(pData->dc)
    end if
  end if
  return IUP_DEFAULT
end function

function OvalRedraw_CB cdecl (ih as Ihandle ptr, x as single, y as single) as integer
  ' ? "OvalRedraw_CB"
  GETOVALDATA(pData)
  if pData then
    if pData->dc then
      iupDrawParentBackground(pData->dc)
      ' get the oval attribute number of points
      dim as integer nPoints=IupGetInt(ih, "NUMPOINTS")
      if nPoints<3 then nPoints=3
      ' the value changes since creation ?
      if (nPoints<>pData->nPoints) then
        ' reallocate the x,y points of the oval
        pData->pPoints=reallocate(pData->pPoints,nPoints*2 * sizeof(integer))
        pData->nPoints=nPoints
      end if
      ' the size are changed so we recalculate the x,y coods
      dim as single wstep = 6.14/pData->nPoints
      dim as single rad
      dim as single wr=(pData->dc->w-1)*0.5
      dim as single hr=(pData->dc->h-1)*0.5
      for i as integer = 0 to pData->nPoints-1
        pData->pPoints[i*2+0]=cos(rad)*wr+wr
        pData->pPoints[i*2+1]=sin(rad)*hr+hr
        rad+=wstep
      next
      iupDrawPolygon(pData->dc, pData->pPoints,pData->nPoints, 255,0,0, IUP_DRAW_FILL)
      iupDrawText(pData->dc,"OVAL",4, wr,hr, 0,0,255,"TIMES_BOLD_12")
      ' show the offscreen image 
      iupDrawFlush(pData->dc)
    end if  
  end if
  return IUP_DEFAULT
end function

function OvalCreateMethod cdecl(ih as Ihandle ptr, params as any ptr ptr) as integer
  '? "OvalCreateMethod"
  dim as OVAL_DATA ptr pData = callocate(sizeof(OVAL_DATA))
  IupSetAttribute(ih, "_IUP_OVALDATA", cptr(zstring ptr,pData))
  IupSetAttribute(ih, "NUMPOINTS", "32")
  IupSetCallback(ih, "RESIZE_CB", cast(Icallback,@OvalResize_CB) )
  IupSetCallback(ih, "ACTION"   , cast(Icallback,@OvalRedraw_CB))
  return IUP_NOERROR
end function

function OvalMapMethod cdecl (ih as Ihandle ptr) as integer
  '? "OvalMapMethod"
  GETOVALDATA(pData)
  if pData then
    if (pData->dc=NULL) then
      ' create offscreen image 
      pData->dc = iupDrawCreateCanvas(ih) 
      pData->nPoints = IupGetInt(ih, "NUMPOINTS")
      if pData->nPoints<3 then
        pData->nPoints=3
        IupStoreAttribute(ih, "NUMPOINTS",str(pData->nPoints))
      end if
      pData->pPoints = allocate(pData->nPoints*2*sizeof(integer))
    end if
  end if
  return IUP_NOERROR
end function

sub OvalUnMapMethod cdecl (ih as Ihandle ptr)
  '? "OvalUnMapMethod"
end sub

sub OvalDestroyMethod cdecl(ih as Ihandle ptr)
  '? "OvalUnMapMethod"
  GETOVALDATA(pData)
  if pData then 
    if (pData->dc) then 
      iupDrawKillCanvas(pData->dc)
      pData->dc = NULL
    end if
    if (pData->pPoints) then
      deallocate pData->pPoints: pData->pPoints=NULL
    end if
    deallocate pData 
    IupSetAttribute(ih, "_IUP_OVALDATA",NULL)
  end if

end sub

' here we create a new IUP class 
function OvalNewClass cdecl () as Iclass ptr
  dim as Iclass ptr ic = iupClassNew(iupRegisterFindClass("canvas"))

  ic->name = @"oval"
  ic->format = NULL 
  ic->nativetype = IUP_TYPECANVAS
  ic->childtype  = IUP_CHILDNONE
  ic->is_interactive = 1

  ic->New_    = @OvalNewClass
  ic->Create  = @OvalCreateMethod
  ic->Destroy = @OvalDestroyMethod
  ic->Map     = @OvalMapMethod
  ic->UnMap   = @OvalUnMapMethod

  return ic
end function
#endif ' __IUPOVAL_BI__
VANYA
Posts: 1834
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: IUP 3.5 Windows / Linux (BSD too) GUI Headers Available

Post by VANYA »

Excellent Joshy!
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: IUP 3.5 Windows / Linux (BSD too) GUI Headers Available

Post by D.J.Peters »

Drago wrote:Dear Joshy,

i did test with IUP and run into some trouble.
I am doing something wrong...or is this IUP behavior ?

Grüße
Rainer
Do you got it ?
If not try IupSetAttribute(dlg, "SHRINK", "YES")

Joshy

Code: Select all

' Includes ANSI C libraries
#include once "crt.bi"

' Includes IUP libraries
#include once "inc/iup.bi"


sub _init_ constructor
  IupOpen(0,0)
end sub

sub _exit_ destructor
  IupClose()
end sub

' Defines released button's image
dim shared as ubyte pixmap_release(...) = _
{ _
       1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, _
       1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2, _
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2, _
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2, _
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2, _
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2, _
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2, _
       1,1,3,3,3,3,3,3,4,4,3,3,3,3,2,2, _
       1,1,3,3,3,3,3,4,4,4,4,3,3,3,2,2, _
       1,1,3,3,3,3,3,4,4,4,4,3,3,3,2,2, _
       1,1,3,3,3,3,3,3,4,4,3,3,3,3,2,2, _
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2, _
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2, _
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2, _
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2, _
       1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, _
       2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 _
}

' Defines pressed button's image
dim shared as ubyte pixmap_press(...) = _
{ _
       1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, _
       1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2, _
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2, _
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2, _
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2, _
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2, _
       1,1,3,3,3,3,3,4,4,3,3,3,3,3,2,2, _
       1,1,3,3,3,3,4,4,4,4,3,3,3,3,2,2, _
       1,1,3,3,3,3,4,4,4,4,3,3,3,3,2,2, _
       1,1,3,3,3,3,3,4,4,3,3,3,3,3,2,2, _
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2, _
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2, _
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2, _
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2, _
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2, _
       1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, _
       2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 _
} 

' Defines inactive button's image
dim shared as ubyte pixmap_inactive(...) = _
{ _
       1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, _
       1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2, _
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2, _
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2, _
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2, _
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2, _
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2, _
       1,1,3,3,3,3,3,3,4,4,3,3,3,3,2,2, _
       1,1,3,3,3,3,3,4,4,4,4,3,3,3,2,2, _
       1,1,3,3,3,3,3,4,4,4,4,3,3,3,2,2, _
       1,1,3,3,3,3,3,3,4,4,3,3,3,3,2,2, _
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2, _
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2, _
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2, _
       1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2, _
       1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, _
       2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 _
}

function btn_on_off_cb cdecl (self as Ihandle ptr) as integer
  ' IUP handles
  dim as Ihandle ptr btn_image
    
  ' Recovers "btn_image" handle
  btn_image = IupGetHandle( "btn_image" )
  
  ' If the button with with image is active...
  if (strcmp( IupGetAttribute( btn_image, "ACTIVE" ), "YES" )=0) then
    ' Deactivates the button with image
    IupSetAttribute( btn_image, "ACTIVE","NO" )
  ' else it is inactive
  else
    ' Activates the button with image
    IupSetAttribute( btn_image, "ACTIVE", "YES" )
  end if

  ' Executed function successfully
  return IUP_DEFAULT
end function


function btn_image_button_cb cdecl (self as Ihandle ptr, b as integer, e as integer) as integer

  ' If the left button changed its state...
  if (b = IUP_BUTTON1) then
    ' IUP handles
    dim as Ihandle ptr text
    
    ' Recovers "text" handle
    text = IupGetHandle( "text" )
    
    ' If the button was pressed...
    if(e = 1) then
      ' Sets text's value
      IupSetAttribute( text, "VALUE", "Red button pressed" )
    
    ' else the button was released
    else       
      ' Sets text's value
      IupSetAttribute( text, "VALUE", "Red button released" )
    end if
  end if
  
  ' Executed function successfully
  return IUP_DEFAULT
end function


function btn_exit_cb cdecl ( self as Ihandle ptr) as integer
  ' Exits the program
  return IUP_CLOSE
end function

'
' main
'
var text = IupText( NULL )
IupSetAttribute( text, "EXPAND", "YES")
IupSetHandle ( "text", text )

var img_release = IupImage(16, 16, @pixmap_release(0))
IupSetAttribute( img_release, "1", "215 215 215" )
IupSetAttribute( img_release, "2", "40 40 40" )
IupSetAttribute( img_release, "3", "30 50 210" )
IupSetAttribute( img_release, "4", "240 0 0" )
IupSetHandle( "img_release", img_release )

var img_press = IupImage( 16, 16, @pixmap_press(0) )
IupSetAttribute( img_press, "1", "40 40 40" )
IupSetAttribute( img_press, "2", "215 215 215" )
IupSetAttribute( img_press, "3", "0 20 180" )
IupSetAttribute( img_press, "4", "210 0 0" )
IupSetHandle ( "img_press", img_press )

var img_inactive = IupImage( 16, 16, @pixmap_inactive(0) )
IupSetAttribute( img_inactive, "1", "215 215 215" )
IupSetAttribute( img_inactive, "2", "40 40 40" )
IupSetAttribute( img_inactive, "3", "100 100 100" )
IupSetAttribute( img_inactive, "4", "200 200 200" )
IupSetHandle ("img_inactive", img_inactive )

var btn_image = IupButton ( "Button with image", "btn_image")
IupSetAttribute( btn_image, "IMAGE"     , "img_release" )
IupSetAttribute( btn_image, "IMPRESS"   , "img_press"   )
IupSetAttribute( btn_image, "IMINACTIVE", "img_inactive")
IupSetAttribute( btn_image, "BUTTON_CB" , "btn_image_button")
IupSetHandle( "btn_image", btn_image )

var btn_big = IupButton( "Big useless button", "" )
IupSetAttribute( btn_big, "SIZE", "EIGHTHxEIGHTH" )

var btn_exit = IupButton( "Exit", "btn_exit")
var btn_on_off = IupButton( "on/off", "btn_on_off")

var hbox =IupHbox( btn_image, btn_on_off, btn_exit, NULL )
IupSetAttribute(hbox, "GAP", "5")

var frm1 = iupframe(hbox)
var frm2 = iupframe(text)
var frm3 = iupframe(btn_big)
var vbox = IupVbox( frm1, frm2, frm3, NULL)
IupSetAttribute(vbox, "EXPANDCHILDREN", "YES")
IupSetAttribute(vbox, "GAP", "5")

var dlg = IupDialog( vbox)                             
IupSetAttributes( dlg, "EXPAND = YES, TITLE = IUP-TEST, RESIZE = YES" )
IupSetAttributes( dlg, "MENUBOX = YES, MAXBOX = NO, MINBOX = NO" )
IupSetAttributes ( dlg, "SIZE=HALFxHALF" )
IupSetAttribute(dlg, "MARGIN", "10x10")
IupSetAttribute(dlg, "SHRINK", "YES")

IupSetCallback( btn_exit  , "ACTION", cast(Icallback,@btn_exit_cb ))
IupSetCallback( btn_on_off, "ACTION", cast(Icallback,@btn_on_off_cb ))
IupSetCallback( btn_image , "ACTION", cast(Icallback,@btn_image_button_cb ))

IupShowXY( dlg, IUP_CENTER, IUP_CENTER )
IupMainLoop()
AGS
Posts: 1284
Joined: Sep 25, 2007 0:26
Location: the Netherlands

Loading LED files using loadfile

Post by AGS »

I sent a bug report to the iup devs
(I found a small mistake in a LED example when
used in combination with LEDC) and got somewhat of a weird answer.

The LEDC compiler thing seems to be a bit outdated. The
LED files that come with the IUP distribution are all used
in combination with loadfile (not LEDC).

You can load a LED interface description from a file (or a string) without
using LEDC. The functions that parse led syntax and create
a gui from a LED description are

Code: Select all

function IupLoad  (byval filename as zstring ptr) as zstring ptr
function IupLoadBuffer  (byval buffer as zstring ptr) as zstring ptr
An example of using iupload (from the IUP website).

Content of the LED file (iupfiledlg.led)

Code: Select all

#IupFileDlg Example in Led 
#Shows a typical file-saving dialog. 

dlg = filedlg[TITLE="File save", DIALOGTYPE=SAVE, FILTER="*.bmp", FILTERINFO="Bitmap files"]()
And this is the BASIC file that uses the above LED file.

Code: Select all

#include "iup3/iup.bi"

function mymain(byval argc as integer, byval argv as zstring ptr ptr) as integer

  dim error_ as zstring ptr
  dim dlg as   Ihandle ptr

  IupOpen(@argc, @argv)
  
  /' Loads LED file '/
  error_ = IupLoad("iupfiledlg.led")
  if(error_) then  
    IupMessage("LED error", error_)
    return 1 
  end if

  dlg = IupGetHandle("dlg")
  IupPopup(dlg, IUP_CENTER, IUP_CENTER)

  dim status as integer 
  status = IupGetInt(dlg,"STATUS")
  select case status  
  case 1
      IupMessage("New file",IupGetAttribute(dlg, "VALUE"))
  case 0
      IupMessage("File already exists.",IupGetAttribute(dlg, "VALUE"))
  case -1
      IupMessage("IupFileDlg","Operation Canceled")
      return 1
  end select

  IupDestroy(dlg)
  IupClose()

  return 0

end function

mymain(__FB_ARGC__,__FB_ARGV__)
iupload assigns a name to every handle that corresponds
to the name as used in the LED file.

Callbacks are not set automagically. You have to do that
manually using iupsetcallback.

The example is a bit short(ish) but when writing longer
iup specifications the LED language can come in handy.

A long LED file that creates a dialog with menu and a matrix control

Code: Select all

#IupMatrix Example in Led 
#Creates a matrix with two columns and three lines. The dialog in which the matrix is located has an associated menu that allows changing titles, dimensions, colors, alignment, marking mode and edition mode, as well as inserting or removing a line or column. 


# initializing elements
# creating cancel button
cancel = button ( "Cancel", cancel_act )

# creating elements in the title menu
titulo_ok = button ( "OK", titulo_ok_act )
titulo_texto = text [ EXPAND = YES, BORDER = YES ] (titulo_texto_act)
dlg_titulo = dialog [ SIZE = EIGHTH, DEFAULTENTER = titulo_ok, DEFAULTESC = cancel ] ( titulo_texto )

# creating elements in the dimension menu
dimensao_ok = button ( "OK", dimensao_ok_act )
dimensao_texto = text [ EXPAND = YES, BORDER = YES, VALUE = 0, CARET = 2 ] (dimensao_texto_act)
dlg_dimensao = dialog [ SIZE =EIGHTH, DEFAULTENTER = dimensao_ok, DEFAULTESC = cancel ] ( dimensao_texto )

# initializing menu
# creating the items that compose the ‘titulos’ menu
titulogeral = item ( "Geral" , titulogeral_act )
titulocol = item ( "de Coluna" , titulocol_act )
titulolin = item ( "de Linha" , titulolin_act )

# creating the items that compose the ‘adicionar’ menu
adicionarcolesq = item ( "Coluna à esquerda", adicionarcolesq_act ) 
adicionarcoldir = item ( "Coluna à direita" , adicionarcoldir_act )
adicionarlinacima = item ( "Linha acima" , adicionarlinacima_act )
adicionarlinabaixo = item ( "Linha abaixo" , adicionarlinabaixo_act )

# creating the items that compose the ‘remover’ menu
removercolesq = item ( "Coluna à esquerda" , removercolesq_act )
removercoldir = item ( "Coluna à direita" , removercoldir_act )
removerlinacima = item ( "Linha acima" , removerlinacima_act )
removerlinabaixo = item ( "Linha abaixo" , removerlinabaixo_act )

# creating the items that compose the ‘dimensoes’ menu
altura = item ( "Altura", altura_act )
largura = item ( "Largura", largura_act )

# creating the items that compose the ‘alinhamento’ menu
alinesq = item ( "à Esquerda" , alinesq_act )
alincent = item ( "Centralizado" , alincent_act )
alindir = item ( "à Direita" , alindir_act )

# creating the items that compose the ‘marcacao’ menu
marcacao_multipla = item ( "Marcação múltipla" , marcacao_multipla_act )
marcacao_continua = item [VALUE = ON] ( "Marcação contínua" , marcacao_continua_act )
tamanho_editavel = item ( "Tamanho editável" , tamanho_editavel_act )

# creating the items in the ‘cor de frente’ menu
cor_de_frente_vermelha = item ( "Vermelho" , cor_de_frente_vermelha_act )
cor_de_frente_verde = item ( "Verde" , cor_de_frente_verde_act )
cor_de_frente_azul = item ( "Azul" , cor_de_frente_azul_act )
cor_de_frente_preta = item ( "Preto" , cor_de_frente_preta_act )
cor_de_frente_branca = item ( "Branco" , cor_de_frente_branca_act )

# creating the items in the ‘cor de fundo’ menu
cor_de_fundo_vermelha = item ( "Vermelho" , cor_de_fundo_vermelha_act )
cor_de_fundo_verde = item ( "Verde" , cor_de_fundo_verde_act )
cor_de_fundo_azul = item ( "Azul" , cor_de_fundo_azul_act )
cor_de_fundo_preta = item ( "Preto" , cor_de_fundo_preta_act )
cor_de_fundo_branca = item ( "Branco" , cor_de_fundo_branca_act )

# creating the ‘cor de frente’ submenu
cor_de_frente_menu = menu ( cor_de_frente_vermelha, cor_de_frente_verde, 
  cor_de_frente_azul, cor_de_frente_preta, cor_de_frente_branca )
cor_de_frente = submenu ( "de Frente" , cor_de_frente_menu )

# creating the ‘cor de fundo’ submenu
cor_de_fundo_menu = menu ( cor_de_fundo_vermelha, cor_de_fundo_verde, 
  cor_de_fundo_azul, cor_de_fundo_preta, cor_de_fundo_branca )
cor_de_fundo = submenu ( "de Fundo", cor_de_fundo_menu )

# creating the ‘titulos’ submenu
titulos_menu = menu ( titulogeral, titulocol, titulolin )
titulos = submenu ( "Títulos" ,titulos_menu )

# creating the ‘adicionar’ submenu
adicionar_menu = menu ( adicionarcolesq, adicionarcoldir, adicionarlinacima, adicionarlinabaixo )
adicionar = submenu ( "Adicionar" ,adicionar_menu )

# creating the ‘remover’ submenu
remover_menu = menu ( removercolesq, removercoldir, removerlinacima, removerlinabaixo )
remover = submenu ( "Remover" , remover_menu )

# creating the ‘dimensoes’ submenu
dimensoes_menu = menu ( altura, largura )
dimensoes = submenu ( "Dimensões" , dimensoes_menu )

# creating the ‘alinhamento’ submenu
alinhamento_menu = menu ( alinesq, alincent, alindir )
alinhamento = submenu ( "Alinhamento" , alinhamento_menu )

# creating the ‘marcacao’ submenu
configuracao_menu = menu ( marcacao_multipla, marcacao_continua, tamanho_editavel )
configuracao = submenu ( "Configuração" , configuracao_menu )

# creating the ‘alteracao_de_cor’ submenu
alteracao_de_cor_menu = menu ( cor_de_frente, cor_de_fundo )
alteracao_de_cor = submenu ( "Cor" , alteracao_de_cor_menu )

# creating the ‘alterar’ menu
alterar_menu = menu ( titulos, adicionar, remover, dimensoes, alinhamento, alteracao_de_cor, configuracao )

# creating the bar menu
alterar_submenu = submenu ( "Alterar" , alterar_menu )
main_menu = menu ( alterar_submenu )

#initializing matrix
matriz = MATRIX[NUMCOL=2, NUMLIN=3, NUMCOL_VISIBLE = 2, NUMLIN_VISIBLE = 3, MARKMODE = CELL, 0:0 = Inflação,
1:0 = Remédios, 2:0 = Alimentos, 3:0 = Energia, 0:1 = "Janeiro 2000", 0:2 = "Fevereiro 2000", 1:1 = 5.6, 2:1 = 2.2, 3:1 = 7.2, 1:2 = 4.5,
2:2 = 8.1, 3:2 = 3.4](NULL)

# places matrix inside a frame
moldura = frame ( matriz )

# places matrix in the dialog
dlg = dialog [TITLE = "IupMatrix", MENU = main_menu] ( moldura )
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: IUP 3.5 Windows / Linux (BSD too) GUI Headers Available

Post by D.J.Peters »

@AGS Yes i know it.
You can create really complex *.led files with the gui layout designer "LayoutDialog.bas"
(with the right mouse click you can add all kinds of Iup elements and edit it's attributes)

Joshy
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: IUP 3.5 Windows / Linux (BSD too) GUI Headers Available

Post by D.J.Peters »

Windows IUP 3.7
(see second post)

Joshy
AGS
Posts: 1284
Joined: Sep 25, 2007 0:26
Location: the Netherlands

IUP 3.7 header files

Post by AGS »

Nice, those 3.7 bindings. With declarators and all.

The only thing 'missing' are explicit byval specifiers.
Which is actually a non - issue as the lay out of the header files (and fb
syntax) is so strict that the following regular expression does the trick
of adding byval to all declarations:

find: (\w+\s+as\s+\w+)
replace: byval \1

Perhaps the above regex works for all declarations (I tried and it seems to
work IF applied to function/sub declarations only ((type/union members
match the same regex pattern as used for parameters)).

In case you are wondering why I care about the byval thing: I always compile
my code using option -w pedantic. The lack of byval gets me a ton of warnings (which
increases compilation time quite a bit). Anyways, it's nothing a well aimed
regex can't take care of.

Thans, thanks, thanks, D.J. Peeters, for the bindings.
Time to play around with iup 3.7!
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: IUP 3.5 Windows / Linux (BSD too) GUI Headers Available

Post by D.J.Peters »

I self don't need IUP 3.7.
Only IupScrollbox() is new i can emulate it with IupCanvas() .

pplot.bas and pplot_demo.bas can't be linked statical any more.

More a pain for me are if you use IupLoadImage() you must link with all DLL's also.

Joshy
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: IUP 3.5 Windows / Linux (BSD too) GUI Headers Available

Post by D.J.Peters »

First time i need a hint for the IUP layout.
I need a short grid made only with IupLabel() and IupText() (not with IupMatrix() )
both versions one with IupHBox() the other with IupVBox() look's a litle bit ugly.

May be i need "MARGIN" and or "GAP" to get the right result ?
Image
In the left child dialog the labels of the top and the textfields are ok but the labels of the left side are wrong
and in the right child dialog the labels of the top and the textfields are wrong.

Thank you for the right hint.

Joshy

Code: Select all

 ...
function CreateChildDialogv() as IHandle ptr
  dim as IHandle ptr r1 = IupHBox(IupLabel(NULL)          ,IupLabel("x"),IupLabel("y"),IupLabel("z"),NULL)
  dim as IHandle ptr r2 = IupHBox(IupLabel("position:")   ,IupText(NULL),IupText(NULL),IupText(NULL),NULL)
  dim as IHandle ptr r3 = IupHBox(IupLabel("orientation:"),IupText(NULL),IupText(NULL),IupText(NULL),NULL)
  dim as IHandle ptr r4 = IupHBox(IupLabel("dimension:")  ,IupText(NULL),IupText(NULL),IupText(NULL),NULL)
  dim as IHandle ptr vb = IupVBox(r1,r2,r3,r4,NULL)

  dim as IHandle ptr hChild = IupSetAttributes(IupDialog(vb),"PARENTDIALOG=main_dialog,TOOLBOX=YES,TITLE=child,RESIZE=NO")
  IupSetHandle("child_dialogv",hChild)
  IupShow(hChild)
  return  hChild
end function

function CreateChildDialogh() as IHandle ptr
  dim as IHandle ptr v1 = IupVBox(IupLabel(NULL), _
                                  IupLabel("position:"), _
                                  IupLabel("orientation:"), _
                                  IupLabel("dimension:"), NULL)
  dim as IHandle ptr v2 = IupVBox(IupLabel("x"), _
                                  IupText(NULL), _
                                  IupText(NULL), _
                                  IupText(NULL), NULL)
  dim as IHandle ptr v3 = IupVBox(IupLabel("y"), _
                                  IupText(NULL), _
                                  IupText(NULL), _
                                  IupText(NULL), NULL)
  dim as IHandle ptr v4 = IupVBox(IupLabel("z"), _
                                  IupText(NULL), _
                                  IupText(NULL), _
                                  IupText(NULL), NULL)

  dim as IHandle ptr hb = IupHBox(v1,v2,v3,v4,NULL)

  dim as IHandle ptr hChild = IupSetAttributes(IupDialog(hb),"PARENTDIALOG=main_dialog,TOOLBOX=YES,TITLE=child,RESIZE=NO")
  IupSetHandle("child_dialogh",hChild)
  IupShow(hChild)
  return  hChild
end function
...
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: IUP 3.5 Windows / Linux (BSD too) GUI Headers Available

Post by D.J.Peters »

By the way what looks better buttons with or without shadows ?
(i must create ~100 of them and in different sizes 24x16 for menue, 32x24 or 48x36 for toolbar)

Joshy

48x48 buttons with and without shadow and ground (created with "fbRaytracer.bi")
Image
Last edited by D.J.Peters on Oct 03, 2017 5:06, edited 1 time in total.
VANYA
Posts: 1834
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: IUP 3.5 Windows / Linux (BSD too) GUI Headers Available

Post by VANYA »

D.J.Peters wrote:By the way what looks better buttons with or without shadows ?
Better both on the user's choice.
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: IUP 3.5 Windows / Linux (BSD too) GUI Headers Available

Post by TJF »

Buttons (pictograms) should be reduced to the essentials. If there's no information in the shadow don't include it (it's just confusing in that case).
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: IUP 3.5 Windows / Linux (BSD too) GUI Headers Available

Post by D.J.Peters »

VANYA wrote:Better both on the user's choice.
100 x 3 sizes x 2 usersets = 600 images :-(
TJF wrote:... If there's no information in the shadow don't include it (it's just confusing in that case).
That is a good point.

Joshy
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: IUP 3.5 Windows / Linux (BSD too) GUI Headers Available

Post by D.J.Peters »

Image
The x,y,z labels are not really centered do you know what i'm doing wrong ?

Joshy

Code: Select all

' file ChildDialog.bas
#include once "inc/iup.bi"

sub _init_ constructor
  IupOpen(0,0)
end sub

sub _exit_ destructor
  IupClose()
end sub

#define TOPLABEL(txt) IupSetAttributes(IupLabel(txt),"ALIGNMENT=ACENTER,MINSIZE=64x0")
#define LEFTLABEL(txt) IupSetAttributes(IupLabel(txt),"ALIGNMENT=ARIGHT,MINSIZE=96x0")
#define TEXT(txt) IupSetAttributes(IupText(NULL),!"VALUE=\"" & txt & !"\",MINSIZE=64x0")

function CreateChildDialog as IHandle ptr
  dim as IHandle ptr hRow1 = IupSetAttributes(IupHBox(LeftLabel(""),            TopLabel(" x "),TopLabel(" y "),TopLabel(" z "),NULL),"GAP=5")
  dim as IHandle ptr hRow2 = IupSetAttributes(IupHBox(LeftLabel("Position:")   ,Text("0.0")    ,Text("0.0")    ,Text("0.0"),NULL),"GAP=5")
  dim as IHandle ptr hRow3 = IupSetAttributes(IupHBox(LeftLabel("Orientation:"),Text("0.0")    ,Text("0.0")    ,Text("0.0"),NULL),"GAP=5")
  dim as IHandle ptr hRow4 = IupSetAttributes(IupHBox(LeftLabel("Dimension:")  ,Text("0.0")    ,Text("0.0")    ,Text("0.0"),NULL),"GAP=5")
  dim as IHandle ptr hChildDialog = IupDialog(IupSetAttributes(IupVBox(hRow1,hRow2,hRow3,hRow4,NULL),"GAP=5"))
  IupSetAttribute(hChildDialog,"PARENTDIALOG","parent_dialog")
  IupSetAttributes(hChildDialog,!"TITLE=\"Tooldialog with a grid layout\",TOOLBOX=YES,RESIZE=NO")
  IupShowXY(hChildDialog,IUP_CENTERPARENT,IUP_CENTERPARENT)
  return hChildDialog
end function

function dialog_map_cb cdecl (hDialog as IHandle ptr) as integer
  IupSetHandle("parent_dialog",hDialog)
  IupSetHandle("child_dialog",CreateChildDialog())
  return IUP_DEFAULT
end function

function dialog_close_cb cdecl (hDialog as IHandle ptr) as integer
  dim as IHandle ptr hChildDialog = IupGetHandle("child_dialog")
  if hChildDialog then
    IupUnMap(hChildDialog)
    IupDestroy(hChildDialog)
    IupSetHandle("child_dialog",NULL)
  end if
  return IUP_CLOSE
end function


'
' main
'
dim as IHandle ptr hDialog = IupSetAttributes(IupDialog(IupCanvas(NULL)),"SIZE=FULLxFULL")

IupSetAttribute(hDialog,"TITLE","dialog with a child dialog")

IupSetCallback(hDialog,"MAP_CB"  ,@dialog_map_cb)
IupSetCallback(hDialog,"CLOSE_CB",@dialog_close_cb)

IupShow(hDialog)
IupMainLoop()
Last edited by D.J.Peters on Oct 03, 2017 5:03, edited 1 time in total.
AGS
Posts: 1284
Joined: Sep 25, 2007 0:26
Location: the Netherlands

Re: IUP 3.5 Windows / Linux (BSD too) GUI Headers Available

Post by AGS »

D.J.Peters wrote:Image
The x,y,z labels are not really centred do you know what i'm doing wrong ?

Joshy
I am guessing, Joshy, the problem is with the first label. It has no content (only a minimal
size). The people developing iup use IupFill() to fill empty space. The IupFill() takes as much
space as it can.

In the picture there seems to be an assumption as to where the arrows start
(or, if you like, where the labels start). I do not think the absolute positions are known.
You seem to be hoping the first label starts at the start of the text boxes
but there is no reason to believe this to be true.
If the first label starts at a different position then all of the labels could very well be
starting at a different position.

As a fix for the lay - out problem I'd use the same kind of text for the row 1, col1 as
used in the row 2, col 2 ("position:"). And then set the attribute for row 1, column 1 to
"VISIBLE=NO". That should at the very least put row 1, col 2 at the same position as
row 2, col 2 (assuming column numbering is one based).

And I am thinking: the combination of non - fixed position layout with fixed gap size (5)
must be a source of problems. How can lay out be non - fixed if the gap size is fixed?
At some resolution this kind of lay out must look much different from the intended lay out?

Apart from all of the above your program makes smart use of the iup lay out algorithm.
Which to me means you are using iup features unknown to fb users using iup.
Few (if any) fb programmer will be able to help out with issues you run into when using
somewhat 'advanced' iup features.

I for one am wondering what the reason for the call to iupcanvas can be. The canvas
never gets used anywhere in the program (I think?) so why create it?

Last but not least: perhaps you ran into an iup related bug. In which case only the
iup devs can fix the problem.
Post Reply