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
vladimir777
Posts: 94
Joined: Aug 19, 2011 18:28

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

Post by vladimir777 »

works great! Good job, Joshi!
=========================
1. downloaded fbIUPWindows.zip
2. buildall.bat compiled all samples properly
================================================
but when I try some ploting samples got error msg:

File not found, "inc/iup_draw.bi" in '#include once "inc/iup_draw.bi"'

I am probably using some old fbIUPWindows or what?
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 »

There isn't a fbIUPWindows.zip file on my server anymore
or do you mean fbIUP3.5Windows.z7 ?

Joshy
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 »

vladimir777 wrote:http://freebasic.ucoz.com/files/fbIUPWindows.zip

I got it from here
You can download from here: http://www.freebasic.net/forum/viewtopi ... 19#p163119

Or the one that you provided, I updated the archive.
Drago
Posts: 116
Joined: Aug 10, 2005 13:15

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

Post by Drago »

Hoi Joshy,

did you change your Center Text Child code ?

Image

For me the text is shown fine.

But the startup Position never was centerParent.

I'll had to change the code to explicit call of the ChildWindow to show up correct.

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("1.0")    ,Text("1.1")    ,Text("1.2"),NULL),"GAP=5")
      dim as IHandle ptr hRow3 = IupSetAttributes(IupHBox(LeftLabel("Orientation:"),Text("2.0")    ,Text("2.1")    ,Text("2.2"),NULL),"GAP=5")
      dim as IHandle ptr hRow4 = IupSetAttributes(IupHBox(LeftLabel("Dimension:")  ,Text("3.0")    ,Text("3.3")    ,Text("3.2"),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")
      return hChildDialog
    end function

    function dialog_map_cb cdecl (hDialog as IHandle ptr) as integer
      IupSetHandle("child_dialog",CreateChildDialog())
      IupShowXY(IupGetHandle("child_dialog"),IUP_CENTERPARENT,IUP_CENTERPARENT)      
      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_DEFAULT
    end function

function btn_1 cdecl ( self as Ihandle ptr) as integer
	dialog_map_cb (IupGetHandle("parent_dialog"))
	return IUP_DEFAULT
end function

function btn_2 cdecl ( self as Ihandle ptr) as integer
	dialog_close_cb (IupGetHandle("parent_dialog"))
	return IUP_DEFAULT
end function

function btn_3 cdecl ( self as Ihandle ptr) as integer
  return IUP_CLOSE
end function

    '
    ' main
    '
 	var btn_go = IupButton( "Go", "btn_go")
    IupSetCallback( btn_go  , "ACTION", cast(Icallback,@btn_1 ))
	var btn_done = IupButton( "Done", "btn_done")
    IupSetCallback( btn_Done  , "ACTION", cast(Icallback,@btn_2 ))	
	var btn_exit = IupButton( "Exit", "btn_exit")
    IupSetCallback( btn_exit  , "ACTION", cast(Icallback,@btn_3 ))
	var hbox =IupHbox( btn_go, btn_done, btn_exit, NULL )
	IupSetAttribute(hbox, "GAP", "5")
	IupSetAttribute(hbox, "EXPANDCHILDREN", "YES")
	var frm1 = iupframe(hbox)		
 
    dim as IHandle ptr hDialog = IupSetAttributes(IupDialog(hbox),"SIZE=400x200")
    IupSetHandle("parent_dialog",hDialog)	
    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()
vladimir777
Posts: 94
Joined: Aug 19, 2011 18:28

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

Post by vladimir777 »

It is ok now.

I run all demo programs, and found just one problem with PPlot_demo

If I uncheck X - autoscale, and try to scale by mouse program crashes (windowsXP)
Y axis works fine ...

I guess it must be linked dinamically?
==============================
Anyway, I like it VERY much!
vladimir777
Posts: 94
Joined: Aug 19, 2011 18:28

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

Post by vladimir777 »

what's wrong here

Code: Select all

#include once "inc/iup.bi"
#include once "inc/cdiup.bi"

dim shared as IHandle ptr bt1, bt2, bt3, bt4, cbox, label1, kanvas1
dim shared as cdCanvas ptr cdcanvas = NULL

sub _init_ constructor
  IupOpen(0,0)
end sub

sub _exit_ destructor
  IupClose()
end sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function bt_cb1 cdecl (self as IHandle ptr) as integer
return IUP_DEFAULT
end function

function bt_cb2 cdecl (self as IHandle ptr) as integer
return IUP_DEFAULT
end function

function bt_cb3 cdecl (self as IHandle ptr) as integer
return IUP_DEFAULT
end function

function bt_cb4 cdecl (self as IHandle ptr) as integer
cdCanvasClear(cdcanvas)
cdCanvasBox(cdcanvas, 0, 10, 0, 44) 
cdCanvasLine(kanvas1, 33, 45, 70, 20)
return IUP_DEFAULT
end function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function button_cb cdecl (self as Ihandle ptr, but as integer, press as integer, x as integer, y as integer) as integer 
  return IUP_DEFAULT
end function

function motion_cb cdecl (self as Ihandle ptr, x as integer, y as integer) as integer
  return IUP_DEFAULT
end function

function redraw_cb cdecl (self as Ihandle ptr, x as single, y as single) as integer
  cdCanvasActivate(cdcanvas)
  cdCanvasClear(cdcanvas)
  cdCanvasForeground(cdcanvas, CD_BLUE)
  cdCanvasBox(cdcanvas, 0, 100, 0, 100)
  cdCanvasBox(cdcanvas, 0, 10, 0, 44)
  
  cdCanvasLine(cdcanvas, 33, 45, 70, 20)
  print "REDRAW"
  return IUP_DEFAULT
end function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
bt1 = IupButton("Draw Circle", NULL)
IupSetCallback(bt1, "ACTION", cptr(ICallback,@bt_cb1))
IupSetAttribute(bt1,"SIZE","80x20"): IupSetAttribute(bt1,"CX","10"): IupSetAttribute(bt1,"CY","10")

bt2 = IupButton("Clear", NULL)
IupSetCallback(bt2, "ACTION", cptr(ICallback,@bt_cb2))
IupSetAttribute(bt2,"SIZE","80x20"): IupSetAttribute(bt2,"CX","10"): IupSetAttribute(bt2,"CY","50")

bt3 = IupButton("Draw Line", NULL)
IupSetCallback(bt3, "ACTION", cptr(ICallback,@bt_cb3))
IupSetAttribute(bt3,"SIZE","80x20"): IupSetAttribute(bt3,"CX","10"): IupSetAttribute(bt3,"CY","90")

bt4 = IupButton("Draw Box", NULL)
IupSetCallback(bt4, "ACTION", cptr(ICallback,@bt_cb4))
IupSetAttribute(bt4,"SIZE","80x20"): IupSetAttribute(bt4,"CX","10"): IupSetAttribute(bt4,"CY","130")

label1 = IupLabel("Label1")
IupSetAttribute(label1 ,"SIZE","180x20")
IupSetAttribute(label1 ,"CX","100")
IupSetAttribute(label1 ,"CY","10"):
IupSetAttribute(label1,"BGCOLOR","255 0 0")
IupSetAttribute(label1,"FGCOLOR","0 255 0"): IupSetAttribute(label1,"FONT", "Times, Bold 12")
IupSetAttribute(label1,"ALIGNMENT", "ACENTER:ACENTER")

kanvas1 = IupCanvas( NULL )
IupSetAttribute(kanvas1, "SIZE", "500x300")
IupSetAttribute(kanvas1,"CX","10"): IupSetAttribute(kanvas1,"CY","200")
IupSetCallback(kanvas1, "ACTION"   , cast(Icallback,@redraw_cb))
IupSetCallback(kanvas1, "BUTTON_CB", cast(Icallback,@button_cb))
IupSetCallback(kanvas1, "MOTION_CB", cast(Icallback,@motion_cb))

cdcanvas = cdCreateCanvas(CD_IUP, kanvas1)
cdCanvasForeground(cdcanvas, CD_BLUE)

cbox = IupCbox(bt1, bt2, bt3, bt4, label1, kanvas1, NULL)
IupSetAttribute(cbox,"SIZE","700x500")

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
IupShow(IupSetAttributes(IupDialog(CBox), !"TITLE=\"MY FIRST IUP\""))
IupMainLoop()
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 »

Take a look inside Canvas1.bas
you can see the dialog is mapped berfore you create the cdCanvas !

Joshy

Code: Select all

#include once "inc/cdiup.bi"

sub _init_ constructor
  IupOpen(0,0)
end sub

sub _exit_ destructor
  IupClose()
end sub

function button_cb cdecl (self as IHandle ptr) as integer
  dim as IHandle ptr dlg = IupGetHandle("mydialog")
  if dlg then
    dim as integer w,h
    IupGetIntInt(dlg,"RASTERSIZE",@w,@h)
    dim as IHandle ptr canv = IupGetHandle("mycanvas")
    if canv then
      cdCanvasActivate(canv)
      cdCanvasClear(canv)
      for i as integer=1 to 100
        cdCanvasForeground(canv, rgb(rnd*255,rnd*255,rnd*255))
        cdCanvasLine(canv, rnd*w,rnd*h ,rnd*w,rnd*h)
      next
    end if  
  end if
  return IUP_DEFAULT
end function
'
' main
'
dim as IHandle ptr button = IupButton("Draw Lines", NULL)
IupSetCallback(button, "ACTION", @button_cb)
dim as IHandle ptr iupcanv = IupCanvas( NULL )
dim as IHandle ptr vbox = IupVBox(button,iupcanv, NULL)
dim as IHandle ptr dialog = IupSetAttributes(IupDialog(vbox),"RASTERSIZE=640x480")
IupSetHandle("mydialog",dialog)
IupMap(dialog)
dim as IHandle ptr cdcanv = cdCreateCanvas(CD_IUP, iupcanv)
IupSetHandle("mycanvas",cdcanv)
IupShow(dialog)
IupMainLoop()
vladimir777
Posts: 94
Joined: Aug 19, 2011 18:28

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

Post by vladimir777 »

Thx
vladimir777
Posts: 94
Joined: Aug 19, 2011 18:28

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

Post by vladimir777 »

Playing with this example:
http://www.tecgraf.puc-rio.br/cd/en/scr ... src_c.html
cdCanvasGetSize(cdcanvas, &w, &h, NULL, NULL) doesnot work

Code: Select all

' http://www.tecgraf.puc-rio.br/cd/en/screenshots_src_c.html
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#include once "inc/iup.bi"
#include once "inc/cdiup.bi"

dim shared as IHandle ptr bt1, bt2, bt3, bt4, cbox, label1, kanvas1, dialog1
dim shared as cdCanvas ptr cdcanvas = NULL

sub _init_ constructor
  IupOpen(0,0)
end sub

sub _exit_ destructor
  IupClose()
end sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' BUTTON1
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function bt_cb1 cdecl (self as IHandle ptr) as integer
cdCanvasActivate(cdcanvas)
cdCanvasClear(cdcanvas)

cdCanvasForeground(cdcanvas, CD_RED)
cdCanvasBox(cdcanvas, 10, 70, 110, 400)

cdCanvasLine(cdcanvas, 133, 145, 70, 20)
cdCanvasRect(cdcanvas, 100, 400, 100, 300)
cdcanvasflush(cdcanvas)

return IUP_DEFAULT
end function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' BUTTON2
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function bt_cb2 cdecl (self as IHandle ptr) as integer
Dim As Integer w, h
Dim as Integer ptr dashes

' Get size in pixels to be used for computing coordinates. 
'cdCanvasGetSize(cdcanvas, &w, &h, NULL, NULL)
w=500: h = 300

cdCanvasActivate(cdcanvas)
cdCanvasClear(cdcanvas)

cdCanvasLineWidth(cdcanvas, 3)
cdCanvasLineStyle(cdcanvas, CD_CONTINUOUS)
cdCanvasForeground(cdcanvas, cdEncodeAlpha(CD_DARK_MAGENTA, 128))
cdCanvasRect(cdcanvas, 100, 200, 100, 200)
cdCanvasBegin(cdcanvas, CD_OPEN_LINES)
cdCanvasVertex(cdcanvas, 300, 250)
cdCanvasVertex(cdcanvas, 320, 270)
cdCanvasVertex(cdcanvas, 350, 260)
cdCanvasVertex(cdcanvas, 340, 200)
cdCanvasVertex(cdcanvas, 310, 210)
cdCanvasEnd(cdcanvas)

' Draw the blue diagonal line with a pre-defined line style.   Notice that the pre-defined line style is dependent on the driver. 
cdCanvasForeground(cdcanvas, CD_BLUE)
cdCanvasLineWidth(cdcanvas, 10)
cdCanvasLineStyle(cdcanvas, CD_DOTTED)
cdCanvasLine(cdcanvas, 0, h-1, w-1, 0)


' Reset line style and width 
cdCanvasLineStyle(cdcanvas, CD_CONTINUOUS)
cdCanvasLineWidth(cdcanvas, 1)
' Draw an arc at bottom-left, and a sector at bottom-right.   Notice that counter-clockwise orientation of both. 
cdCanvasInteriorStyle(cdcanvas, CD_SOLID)
cdCanvasForeground(cdcanvas, CD_MAGENTA)
cdCanvasSector(cdcanvas, w-100, 100, 100, 100, 50, 180)
cdCanvasForeground(cdcanvas, CD_RED)
cdCanvasArc(cdcanvas, 100, 100, 100, 100, 50, 180)

cdcanvasflush(cdcanvas)

return IUP_DEFAULT
end function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' BUTTON3
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function bt_cb3 cdecl (self as IHandle ptr) as integer
Dim As Integer w, h
w=500: h= 300
cdCanvasActivate(cdcanvas)
cdCanvasClear(cdcanvas)
' Draw a solid filled rectangle at center. 
cdCanvasForeground(cdcanvas, CD_YELLOW)
cdCanvasBox(cdcanvas, w/2 - 100, w/2 + 100, h/2 - 100, h/2 + 100)
 
' Prepare font for text. 
cdCanvasTextAlignment(cdcanvas, CD_CENTER)
'cdCanvasTextOrientation(cdcanvas, 70)  PROBLEM
cdCanvasFont(cdcanvas, "Times", CD_BOLD, 24)

' Draw text at center, with orientation,   and draw its bounding box.
'   Notice that in some drivers the bounding box is not precise. 
'cdCanvasGetTextBounds(cdcanvas, w/2, h/2, "kklkjkljkljk", irect)  PROBLEM
cdCanvasForeground(cdcanvas, CD_RED)
cdCanvasBegin(cdcanvas, CD_CLOSED_LINES)
cdCanvasVertex(cdcanvas, 22, 22)
cdCanvasVertex(cdcanvas, 33, 44)
cdCanvasVertex(cdcanvas, 55, 66)
cdCanvasVertex(cdcanvas, 77, 77)
cdCanvasEnd(cdcanvas)
cdCanvasForeground(cdcanvas, CD_BLUE)
cdCanvasText(cdcanvas, w/2, h/2, "Montenegro")

cdcanvasflush(cdcanvas)

return IUP_DEFAULT
end function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' BUTTON4
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function bt_cb4 cdecl (self as IHandle ptr) as integer
Dim As Integer w, h
w=200: h= 200
cdCanvasActivate(cdcanvas)
cdCanvasClear(cdcanvas)


return IUP_DEFAULT
end function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function button_cb cdecl (self as Ihandle ptr, but as integer, press as integer, x as integer, y as integer) as integer 
  return IUP_DEFAULT
end function

function motion_cb cdecl (self as Ihandle ptr, x as integer, y as integer) as integer
  return IUP_DEFAULT
end function

function redraw_cb cdecl (self as Ihandle ptr, x as single, y as single) as integer
  cdCanvasActivate(cdcanvas)
  cdCanvasClear(cdcanvas)

  cdCanvasForeground(cdcanvas, CD_BLUE)
  cdCanvasBox(cdcanvas, 10, 30, 10, 400)

  cdCanvasLine(cdcanvas, 33, 45, 570, 320)

  cdcanvasflush(cdcanvas)
  print "REDRAW"
  return IUP_DEFAULT
end function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
bt1 = IupButton("Primitives", NULL)
IupSetCallback(bt1, "ACTION", cptr(ICallback,@bt_cb1))
IupSetAttribute(bt1,"SIZE","80x20"): IupSetAttribute(bt1,"CX","10"): IupSetAttribute(bt1,"CY","10")

bt2 = IupButton("More Drawing", NULL)
IupSetCallback(bt2, "ACTION", cptr(ICallback,@bt_cb2))
IupSetAttribute(bt2,"SIZE","80x20"): IupSetAttribute(bt2,"CX","10"): IupSetAttribute(bt2,"CY","50")

bt3 = IupButton("Vertex and Text", NULL)
IupSetCallback(bt3, "ACTION", cptr(ICallback,@bt_cb3))
IupSetAttribute(bt3,"SIZE","80x20"): IupSetAttribute(bt3,"CX","10"): IupSetAttribute(bt3,"CY","90")

bt4 = IupButton("World Coordinates", NULL)
IupSetCallback(bt4, "ACTION", cptr(ICallback,@bt_cb4))
IupSetAttribute(bt4,"SIZE","80x20"): IupSetAttribute(bt4,"CX","10"): IupSetAttribute(bt4,"CY","130")

label1 = IupLabel("Label1")
IupSetAttribute(label1 ,"SIZE","180x20")
IupSetAttribute(label1 ,"CX","100")
IupSetAttribute(label1 ,"CY","10"):
IupSetAttribute(label1,"BGCOLOR","255 0 0")
IupSetAttribute(label1,"FGCOLOR","0 255 0"): IupSetAttribute(label1,"FONT", "Times, Bold 12")
IupSetAttribute(label1,"ALIGNMENT", "ACENTER:ACENTER")

kanvas1 = IupCanvas( NULL )
IupSetAttribute(kanvas1, "SIZE", "500x300")
IupSetAttribute(kanvas1,"CX","10"): IupSetAttribute(kanvas1,"CY","200")
IupSetCallback(kanvas1, "ACTION"   , cast(Icallback,@redraw_cb))
IupSetCallback(kanvas1, "BUTTON_CB", cast(Icallback,@button_cb))
IupSetCallback(kanvas1, "MOTION_CB", cast(Icallback,@motion_cb))


cbox = IupCbox(bt1, bt2, bt3, bt4, label1, kanvas1, NULL)
IupSetAttribute(cbox,"SIZE","700x500")

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
dialog1=iupdialog(cbox)
IupMap(dialog1)
cdcanvas = cdCreateCanvas(CD_IUP, kanvas1)


IupShow(dialog1)
IupMainLoop()
Having problem with WORLD COORDINATES

Code: Select all

/* Prepare World Coordinates */
wdCanvasViewport(canvas, 0,w-1,0,h-1);
if (w>h)
    wdCanvasWindow(canvas, 0,(double)w/(double)h,0,1);
else
    wdCanvasWindow(canvas, 0,1,0,(double)h/(double)w);
 
/* Draw a filled blue rectangle in WC */
wdCanvasBox(canvas, 0.20, 0.30, 0.40, 0.50);
cdCanvasForeground(canvas, CD_RED);
 
/* Draw the diagonal of that rectangle in WC */
wdCanvasLine(canvas, 0.20, 0.40, 0.30, 0.50);
 
/* Prepare Vector Text in WC. */
wdCanvasVectorCharSize(canvas, 0.07);
 
/* Draw vector text, and draw its bounding box.
   We also use this text to show when we are using a contextplus driver. */
cdCanvasForeground(canvas, CD_RED);
if (contextplus)
    wdCanvasGetVectorTextBounds(canvas, "WDj-Plus", 0.25, 0.35, drect);
else
    wdCanvasGetVectorTextBounds(canvas, "WDj", 0.25, 0.35, drect);
cdCanvasBegin(canvas, CD_CLOSED_LINES);
wdCanvasVertex(canvas, drect[0], drect[1]);
wdCanvasVertex(canvas, drect[2], drect[3]);
wdCanvasVertex(canvas, drect[4], drect[5]);
wdCanvasVertex(canvas, drect[6], drect[7]);
cdCanvasEnd(canvas);
cdCanvasLineWidth(canvas, 2);
cdCanvasLineStyle(canvas, CD_CONTINUOUS);
if (contextplus)
    wdCanvasVectorText(canvas, 0.25, 0.35, "WDj-Plus");
else
    wdCanvasVectorText(canvas, 0.25, 0.35, "WDj");
 
/* Reset line width */
cdCanvasLineWidth(canvas, 1);
 
/* Draw a filled path at center-right (looks like a weird fish).
   Notice that in PDF the arc is necessarily a circle arc, and not an ellipse. */
cdCanvasForeground(canvas, CD_GREEN);
cdCanvasBegin(canvas, CD_PATH);
cdCanvasPathSet(canvas, CD_PATH_MOVETO);
cdCanvasVertex(canvas, w/2 + 200, h/2);
cdCanvasPathSet(canvas, CD_PATH_LINETO);
cdCanvasVertex(canvas, w/2 + 230, h/2 + 50);
cdCanvasPathSet(canvas, CD_PATH_LINETO);
cdCanvasVertex(canvas, w/2 + 250, h/2 + 50);
cdCanvasPathSet(canvas, CD_PATH_CURVETO);
cdCanvasVertex(canvas, w/2+150+150, h/2+200-50); /* control point for start */
cdCanvasVertex(canvas, w/2+150+180, h/2+250-50); /* control point for end */
cdCanvasVertex(canvas, w/2+150+180, h/2+200-50); /* end point */
cdCanvasPathSet(canvas, CD_PATH_CURVETO);
cdCanvasVertex(canvas, w/2+150+180, h/2+150-50);
cdCanvasVertex(canvas, w/2+150+150, h/2+100-50);
cdCanvasVertex(canvas, w/2+150+300, h/2+100-50);
cdCanvasPathSet(canvas, CD_PATH_LINETO);
cdCanvasVertex(canvas, w/2+150+300, h/2-50);
cdCanvasPathSet(canvas, CD_PATH_ARC);
cdCanvasVertex(canvas, w/2+300, h/2); /* center */
cdCanvasVertex(canvas, 200, 100); /* width, height */
cdCanvasVertex(canvas, -30*1000, -170*1000); /* start angle, end angle (degrees / 1000) */
cdCanvasPathSet(canvas, CD_PATH_FILL);
cdCanvasEnd(canvas);
 
/* Draw 3 pixels at center left. */
cdCanvasPixel(canvas, 10, h/2+0, CD_RED);
cdCanvasPixel(canvas, 11, h/2+1, CD_GREEN);
cdCanvasPixel(canvas, 12, h/2+2, CD_BLUE);
 
/* Draw 4 mark types, distributed near each corner. */
cdCanvasForeground(canvas, CD_RED);
cdCanvasMarkSize(canvas, 30);
cdCanvasMarkType(canvas, CD_PLUS);
cdCanvasMark(canvas, 200, 200);
cdCanvasMarkType(canvas, CD_CIRCLE);
cdCanvasMark(canvas, w - 200, 200);
cdCanvasMarkType(canvas, CD_HOLLOW_CIRCLE);
cdCanvasMark(canvas, 200, h - 200);
cdCanvasMarkType(canvas, CD_DIAMOND);
cdCanvasMark(canvas, w - 200, h - 200);
 
/* Draw all the line style possibilities at bottom.
   Notice that they have some small differences between drivers. */
cdCanvasLineWidth(canvas, 1);
cdCanvasLineStyle(canvas, CD_CONTINUOUS);
cdCanvasLine(canvas, 0, 10, w, 10);
cdCanvasLineStyle(canvas, CD_DASHED);
cdCanvasLine(canvas, 0, 20, w, 20);
cdCanvasLineStyle(canvas, CD_DOTTED);
cdCanvasLine(canvas, 0, 30, w, 30);
cdCanvasLineStyle(canvas, CD_DASH_DOT);
cdCanvasLine(canvas, 0, 40, w, 40);
cdCanvasLineStyle(canvas, CD_DASH_DOT_DOT);
cdCanvasLine(canvas, 0, 50, w, 50);
 
/* Draw all the hatch style possibilities in the top-left corner.
   Notice that they have some small differences between drivers. */
cdCanvasHatch(canvas, CD_VERTICAL);
cdCanvasBox(canvas, 0, 50, h - 60, h);
cdCanvasHatch(canvas, CD_FDIAGONAL);
cdCanvasBox(canvas, 50, 100, h - 60, h);
cdCanvasHatch(canvas, CD_BDIAGONAL);
cdCanvasBox(canvas, 100, 150, h - 60, h);
cdCanvasHatch(canvas, CD_CROSS);
cdCanvasBox(canvas, 150, 200, h - 60, h);
cdCanvasHatch(canvas, CD_HORIZONTAL);
cdCanvasBox(canvas, 200, 250, h - 60, h);
cdCanvasHatch(canvas, CD_DIAGCROSS);
cdCanvasBox(canvas, 250, 300, h - 60, h);
 
/* Draw 4 regions, in diamond shape,
   at top, bottom, left, right,
   using different interior styles. */
 
/* At top, not filled polygon, notice that the last line style is used. */
cdCanvasBegin(canvas, CD_CLOSED_LINES);
cdCanvasVertex(canvas, w/2, h - 100);
cdCanvasVertex(canvas, w/2 + 50, h - 150);
cdCanvasVertex(canvas, w/2, h - 200);
cdCanvasVertex(canvas, w/2 - 50, h - 150);
cdCanvasEnd(canvas);
 
/* At left, hatch filled polygon */
cdCanvasHatch(canvas, CD_DIAGCROSS);
cdCanvasBegin(canvas, CD_FILL);
cdCanvasVertex(canvas, 100, h/2);
cdCanvasVertex(canvas, 150, h/2 + 50);
cdCanvasVertex(canvas, 200, h/2);
cdCanvasVertex(canvas, 150, h/2 - 50);
cdCanvasEnd(canvas);
 
/* At right, pattern filled polygon */
cdCanvasPattern(canvas, STYLE_SIZE, STYLE_SIZE, pattern);
cdCanvasBegin(canvas, CD_FILL);
cdCanvasVertex(canvas, w - 100, h/2);
cdCanvasVertex(canvas, w - 150, h/2 + 50);
cdCanvasVertex(canvas, w - 200, h/2);
cdCanvasVertex(canvas, w - 150, h/2 - 50);
cdCanvasEnd(canvas);
/* At bottom, stipple filled polygon */
cdCanvasStipple(canvas, STYLE_SIZE, STYLE_SIZE, stipple);
cdCanvasBegin(canvas, CD_FILL);
cdCanvasVertex(canvas, w/2, 100);
cdCanvasVertex(canvas, w/2 + 50, 150);
cdCanvasVertex(canvas, w/2, 200);
cdCanvasVertex(canvas, w/2 - 50, 150);
cdCanvasEnd(canvas);
 
/* Draw two beziers at bottom-left */
cdCanvasBegin(canvas, CD_BEZIER);
cdCanvasVertex(canvas, 100, 100);
cdCanvasVertex(canvas, 150, 200);
cdCanvasVertex(canvas, 180, 250);
cdCanvasVertex(canvas, 180, 200);
cdCanvasVertex(canvas, 180, 150);
cdCanvasVertex(canvas, 150, 100);
cdCanvasVertex(canvas, 300, 100);
cdCanvasEnd(canvas);
 
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 »

Code: Select all

' Get size in pixels to be used for computing coordinates.
cdCanvasGetSize(cdcanvas, @w, @h, NULL, NULL)

Code: Select all

#include once "inc/cdiup.bi"

sub _init_ constructor
  IupOpen(0,0)
end sub

sub _exit_ destructor
  IupClose()
end sub

function button_cb cdecl (self as IHandle ptr) as integer
  dim as IHandle ptr dlg = IupGetHandle("mydialog")
  if dlg then
    dim as integer w,h
    dim as IHandle ptr canv = IupGetHandle("mycanvas")
    if canv then
      cdCanvasActivate(canv)
      cdCanvasGetSize(canv, @w, @h, NULL, NULL)
      cdCanvasClear(canv)
      for i as integer=1 to 100
        cdCanvasForeGround(canv, rgb(rnd*255,rnd*255,rnd*255))
        cdCanvasLine(canv, rnd*w,rnd*h ,rnd*w,rnd*h)
      next
    end if  
  end if
  return IUP_DEFAULT
end function
'
' main
'
dim as IHandle ptr button = IupButton("Draw Lines", NULL)
IupSetCallback(button, "ACTION", @button_cb)
dim as IHandle ptr iupcanv = IupCanvas( NULL )
dim as IHandle ptr vbox = IupVBox(button,iupcanv, NULL)
dim as IHandle ptr dialog = IupSetAttributes(IupDialog(vbox),"RASTERSIZE=120x120")
IupSetHandle("mydialog",dialog)
IupMap(dialog)
dim as IHandle ptr cdcanv = cdCreateCanvas(CD_IUP, iupcanv)
IupSetHandle("mycanvas",cdcanv)
IupShow(dialog)
IupMainLoop()
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 »

If you need world coords you must include "inc/wd.bi"
I never tested wd.bi or wd_old.bi before and found few wrong declares.
The files are included in fbIUP3.5Windows.7z
Linux users can use wd.bi and wd_old.bi from windows package also.

Joshy

short test in button4 callback

Code: Select all

#include once "inc/iup.bi"
#include once "inc/cdiup.bi"
#include once "inc/wd.bi"

dim shared as IHandle ptr bt1, bt2, bt3, bt4, cbox, label1, kanvas1, dialog1
dim shared as cdCanvas ptr cdcanvas = NULL

sub _init_ constructor
  IupOpen(0,0)
end sub

sub _exit_ destructor
  IupClose()
end sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' BUTTON1
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function bt_cb1 cdecl (self as IHandle ptr) as integer
  cdCanvasActivate(cdcanvas)
  dim as integer w,h
  cdCanvasGetSize(cdcanvas, @w, @h, NULL, NULL)
  
  cdCanvasClear(cdcanvas)

  cdCanvasForeground(cdcanvas, RGB(255,0,0))
  cdCanvasBox(cdcanvas, 10, 70, 110, 400)
  cdCanvasForeground(cdcanvas, RGB(0,255,0))
  cdCanvasLine(cdcanvas, 133, 145, 70, 20)
  cdCanvasForeground(cdcanvas, RGB(0,0,255))
  cdCanvasRect(cdcanvas, 100, 400, 100, 300)
  
  cdcanvasflush(cdcanvas)
  return IUP_DEFAULT
end function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' BUTTON2
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function bt_cb2 cdecl (self as IHandle ptr) as integer
  Dim As Integer w, h
  Dim as Integer ptr dashes
  cdCanvasActivate(cdcanvas)
  cdCanvasClear(cdcanvas)
  ' Get size in pixels to be used for computing coordinates.
  cdCanvasGetSize(cdcanvas, @w, @h, NULL, NULL)

  cdCanvasLineWidth(cdcanvas, 3)
  cdCanvasLineStyle(cdcanvas, CD_CONTINUOUS)
  cdCanvasForeground(cdcanvas, cdEncodeAlpha(CD_DARK_MAGENTA, 128))
  cdCanvasRect(cdcanvas, 100, 200, 100, 200)
  cdCanvasBegin(cdcanvas, CD_OPEN_LINES)
    cdCanvasVertex(cdcanvas, 300, 250)
    cdCanvasVertex(cdcanvas, 320, 270)
    cdCanvasVertex(cdcanvas, 350, 260)
    cdCanvasVertex(cdcanvas, 340, 200)
    cdCanvasVertex(cdcanvas, 310, 210)
  cdCanvasEnd(cdcanvas)

  ' Draw the blue diagonal line with a pre-defined line style.   Notice that the pre-defined line style is dependent on the driver.
  cdCanvasForeground(cdcanvas, CD_BLUE)
  cdCanvasLineWidth(cdcanvas, 10)
  cdCanvasLineStyle(cdcanvas, CD_DOTTED)
  cdCanvasLine(cdcanvas, 0, h-1, w-1, 0)

  ' Reset line style and width
  cdCanvasLineStyle(cdcanvas, CD_CONTINUOUS)
  cdCanvasLineWidth(cdcanvas, 1)
  
  ' Draw an arc at bottom-left, and a sector at bottom-right.   Notice that counter-clockwise orientation of both.
  cdCanvasInteriorStyle(cdcanvas, CD_SOLID)
  cdCanvasForeground(cdcanvas, CD_MAGENTA)
  cdCanvasSector(cdcanvas, w-100, 100, 100, 100, 50, 180)
  
  cdCanvasForeground(cdcanvas, CD_RED)
  cdCanvasArc(cdcanvas, 100, 100, 100, 100, 50, 180)

  cdCanvasFlush(cdcanvas)

  return IUP_DEFAULT
end function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' BUTTON3
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function bt_cb3 cdecl (self as IHandle ptr) as integer
  Dim As Integer w, h
  cdCanvasActivate(cdcanvas)
  cdCanvasClear(cdcanvas)
  ' Get size in pixels to be used for computing coordinates.
  cdCanvasGetSize(cdcanvas, @w, @h, NULL, NULL)
  ' Draw a solid filled rectangle at center.
  cdCanvasForeground(cdcanvas,rgb(255,255,0))
  cdCanvasBox(cdcanvas, w/2 - 100, w/2 + 100, h/2 - 100, h/2 + 100)

  ' Prepare font for text.
  cdCanvasTextAlignment(cdcanvas, CD_CENTER)
  'cdCanvasTextOrientation(cdcanvas, 70)  PROBLEM
  cdCanvasFont(cdcanvas, "Times", CD_BOLD, 24)

  ' Draw text at center, with orientation,   and draw its bounding box.
  '   Notice that in some drivers the bounding box is not precise.
  'cdCanvasGetTextBounds(cdcanvas, w/2, h/2, "kklkjkljkljk", irect)  PROBLEM
  cdCanvasForeground(cdcanvas, CD_RED)
  cdCanvasBegin(cdcanvas, CD_CLOSED_LINES)
    cdCanvasVertex(cdcanvas, 22, 22)
    cdCanvasVertex(cdcanvas, 33, 44)
    cdCanvasVertex(cdcanvas, 55, 66)
    cdCanvasVertex(cdcanvas, 77, 77)
  cdCanvasEnd(cdcanvas)

  cdCanvasForeground(cdcanvas, CD_BLUE)
  cdCanvasText(cdcanvas, w/2, h/2, "Montenegro")

  cdcanvasflush(cdcanvas)
  return IUP_DEFAULT
end function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' BUTTON4
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function bt_cb4 cdecl (self as IHandle ptr) as integer
  Dim As Integer w, h
  cdCanvasActivate(cdcanvas)
  cdCanvasClear(cdcanvas)
  ' Get size in pixels to be used for computing coordinates.
  cdCanvasGetSize(cdcanvas, @w, @h, NULL, NULL)

  ' Prepare World Coordinates
   wdCanvasViewport(cdcanvas, 0,w-1,0,h-1)
  if (w>h) then
    wdCanvasWindow(cdcanvas, 0,w/h,0,1)
  else
    wdCanvasWindow(cdcanvas, 0,1,0,h/w)
  end if
  
  ' Draw a filled blue rectangle in WC
  wdCanvasBox(cdcanvas, 0.20, 0.30, 0.40, 0.50)
  cdCanvasForeground(cdcanvas, CD_RED)

  ' Draw the diagonal of that rectangle in WC
  wdCanvasLine(cdcanvas, 0.20, 0.40, 0.30, 0.50)

  return IUP_DEFAULT
end function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function button_cb cdecl (self as Ihandle ptr, but as integer, press as integer, x as integer, y as integer) as integer
  return IUP_DEFAULT
end function

function motion_cb cdecl (self as Ihandle ptr, x as integer, y as integer) as integer
  return IUP_DEFAULT
end function

function redraw_cb cdecl (self as Ihandle ptr, x as single, y as single) as integer
  cdCanvasActivate(cdcanvas)
  cdCanvasClear(cdcanvas)

  cdCanvasForeground(cdcanvas,rgb(0,0,255))
  cdCanvasBox(cdcanvas, 10, 30, 10, 400)

  cdCanvasLine(cdcanvas, 33, 45, 570, 320)

  cdcanvasflush(cdcanvas)
  return IUP_DEFAULT
end function

'
' main
'
bt1 = IupButton("Primitives", NULL)
IupSetCallback(bt1, "ACTION", cast(ICallback,@bt_cb1))
bt2 = IupButton("More Drawing", NULL)
IupSetCallback(bt2, "ACTION", cast(ICallback,@bt_cb2))
bt3 = IupButton("Vertex and Text", NULL)
IupSetCallback(bt3, "ACTION", cast(ICallback,@bt_cb3))
bt4 = IupButton("World Coordinates", NULL)
IupSetCallback(bt4, "ACTION", cast(ICallback,@bt_cb4))

dim as IHandle ptr hBox = IupHBox(bt1, bt2, bt3, bt4,NULL)

kanvas1 = IupCanvas( NULL )
IupSetAttribute(kanvas1, "RASTERSIZE","500x500")
IupSetCallback(kanvas1, "ACTION"   , cast(Icallback,@redraw_cb))
IupSetCallback(kanvas1, "BUTTON_CB", cast(Icallback,@button_cb))
IupSetCallback(kanvas1, "MOTION_CB", cast(Icallback,@motion_cb))

dim as IHandle ptr vBox = IupVBox(hBox,Kanvas1,NULL)

dialog1=iupdialog(vBox)
IupMap(dialog1)
cdcanvas = cdCreateCanvas(CD_IUP, kanvas1)
IupShow(dialog1)
IupMainLoop()
vladimir777
Posts: 94
Joined: Aug 19, 2011 18:28

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

Post by vladimir777 »

KEYDATA.txt
edit.bas
edit2.bas
edit3.bas

CODE COMPLETION USING MULTILINE box

to test type this:
STR and then press ` (key left from number 1) and see statusbar
then continue tu type like STRCPY and press blank It will finish that line

Also try to type
DIM a As
and press blank


KEYDATA.txt

Code: Select all

memchr
(byval as any ptr, byval as integer, byval as size_t) as any ptr

memcmp 
(byval as any ptr, byval as any ptr, byval as size_t) as integer

memcpy 
(byval as any ptr, byval as any ptr, byval as size_t) as any ptr

memmove 
(byval as any ptr, byval as any ptr, byval as size_t) as any ptr

memset
(byval as any ptr, byval as integer, byval as size_t) as any ptr

strcat
(byval as zstring ptr, byval as zstring ptr) as zstring ptr

strchr
(byval as zstring ptr, byval as integer) as zstring ptr

strcmp
(byval as zstring ptr, byval as zstring ptr) as integer

strcoll
(byval as zstring ptr, byval as zstring ptr) as integer

strcpy
(byval as zstring ptr, byval as zstring ptr) as zstring ptr

strcspn
(byval as zstring ptr, byval as zstring ptr) as size_t

strerror
(byval as integer) as zstring ptr

strlen
(byval as zstring ptr) as size_t

strncat
(byval as zstring ptr, byval as zstring ptr, byval as size_t) as zstring ptr

strncmp
(byval as zstring ptr, byval as zstring ptr, byval as size_t) as integer

strncpy
(byval as zstring ptr, byval as zstring ptr, byval as size_t) as zstring ptr

strpbrk
(byval as zstring ptr, byval as zstring ptr) as zstring ptr

strrchr
(byval as zstring ptr, byval as integer) as zstring ptr

strspn
(byval as zstring ptr, byval as zstring ptr) as size_t

strstr
(byval as zstring ptr, byval as zstring ptr) as zstring ptr

strtok
(byval as zstring ptr, byval as zstring ptr) as zstring ptr

strxfrm
(byval as zstring ptr, byval as zstring ptr, byval as size_t) as size_t

wcscat
(byval as wchar_t ptr, byval as wchar_t ptr) as wchar_t ptr

wcschr
(byval as wchar_t ptr, byval as wchar_t) as wchar_t ptr

wcscmp
(byval as wchar_t ptr, byval as wchar_t ptr) as integer

wcscoll
(byval as wchar_t ptr, byval as wchar_t ptr) as integer

wcscpy
(byval as wchar_t ptr, byval as wchar_t ptr) as wchar_t ptr

wcscspn
(byval as wchar_t ptr, byval as wchar_t ptr) as size_t

wcslen
(byval as wchar_t ptr) as size_t

wcsncat
(byval as wchar_t ptr, byval as wchar_t ptr, byval as size_t) as wchar_t ptr

wcsncmp
(byval as wchar_t ptr, byval as wchar_t ptr, byval as size_t) as integer

wcsncpy
(byval as wchar_t ptr, byval as wchar_t ptr, byval as size_t) as wchar_t ptr

wcspbrk
(byval as wchar_t ptr, byval as wchar_t ptr) as wchar_t ptr

wcsrchr
(byval as wchar_t ptr, byval as wchar_t) as wchar_t ptr

wcsspn
(byval as wchar_t ptr, byval as wchar_t ptr) as size_t

wcsstr
(byval as wchar_t ptr, byval as wchar_t ptr) as wchar_t ptr

wcstok
(byval as wchar_t ptr, byval as wchar_t ptr) as wchar_t ptr

wcsxfrm
(byval as wchar_t ptr, byval as wchar_t ptr, byval as size_t) as size_t


edit.bas

Code: Select all

#include once "crt.bi"
#include "inc/iup.bi"
#include once "inc/iupimglib.bi"

#include "inc/iupkey.bi"

dim shared intelisense_on_off as string

dim shared helpdata1(1 to 10000) as string
dim shared helpdata2(1 to 10000) as string
dim shared helpdata3(1 to 10000) as string
dim shared helpdatacnt as integer

dim shared lines_data(1 to 100000) as string
dim shared linesCNT as integer

dim shared intelisense as string
dim shared intelisenseSRCH as string

enum jump_action
	none
	findfunction
	findcontrol
end enum

dim shared as Ihandle ptr dlg, ml, hbox1, label1, label2, vbox1, hbox7, btnjmp, btnjmp7

sub _init_ constructor
  IupOpen(0,0)
  IupImageLibOpen()
end sub
sub _exit_ destructor
  IupClose()
end sub

#include "edit2.bas"
#include "edit3.bas"


function PF2 cdecl (self as Ihandle ptr) as integer
if intelisense_on_off = "ON" then
	intelisense_on_off = "OFF"
else
	intelisense_on_off = "ON"
endif
IupSetAttribute(label1, "TITLE", " F2-" + intelisense_on_off + " | F3-LineInfo | F4-Insert ")
print("F2")
end function  

function PF3 cdecl (self as Ihandle ptr) as integer
    print("F3")
   
end function  

function napuni() as integer
dim lc as integer
lc = valint(*IupGetAttribute(ml, "LINECOUNT"))
linesCNT = lc
'redim lines_data(1 to lc) as string
'lines_data(1)="sss"
dim i as integer
i = 1
Dim As String tstr, delim
dim tmpstr as zstring ptr
Dim zret As Zstring Ptr
	delim = chr(10)
	tstr = !"Hello-W\norld, \n From , Freebasic!\n"
	tstr = *IupGetAttribute(ml, "VALUE")
	'tmpstr = @tstr
	tmpstr = IupGetAttribute(ml, "VALUE")
	
	zret = strtok(tmpstr, delim)
	
	
	If zret <> NULL Then
		lines_data(i) = zret[0]	

		i = i + 1
		Do 
			zret = strtok(NULL, delim)
			If zret <> NULL Then
				lines_data(i) = zret[0]
			End If
			i=i+1
		Loop Until zret = NULL
	End If
	
return 0
end function

function PF4 cdecl (self as Ihandle ptr) as integer
  print("F4")
  IupSetAttribute(self, "INSERT", "RIMILEZ")
  'IupShow(dialog1)
  IupPopUp(dialog1, IUP_CENTERPARENT, IUP_CENTERPARENT)
  return IUP_DEFAULT
end function  

function PF5 cdecl (self as Ihandle ptr) as integer
print("F5")
dim ii as integer = napuni()
IupPopUp(dialog1, IUP_CENTERPARENT, IUP_CENTERPARENT)
return IUP_DEFAULT
end function  






function findhelp(what as string) as string
dim txt1 as string
dim txt2 as string
dim i as integer
dim ret as string
dim ln as integer
ln = len(what)
ret=""
for i = 1 to helpdatacnt

	txt1 = trim(helpdata1(i))

	
	if ucase(what) = mid(ucase(txt1),1,ln) then
		ret = ret + txt1 + "|"
	end if
next i
return ret
end function










function findreplace(what as string) as string
dim as string txt1, txt2, ret
dim i as integer
ret=""
for i = 1 to helpdatacnt

	txt1 = trim(helpdata1(i))
	txt2 = trim(helpdata2(i))

	
	if ucase(what) = ucase(txt1) then
		ret = txt2
	end if

next i
return ret
end function

sub filllist()
dim i as integer
dim txt as string
IupSetAttribute(list5, "REMOVEITEM", "ALL")
for i = 1 to linesCNT
	txt = trim(lines_data(i))
	if mid(ucase(txt), 1, 4) = "TYPE" then
	IupSetAttribute(list5, "APPENDITEM", txt)
	end if
next i
end sub

function ml_action cdecl (self as Ihandle ptr, c as integer, after as zstring ptr) as integer
dim fff as string
dim as integer rrr, kp, i, ll, pp, ret, mmm
ret = IUP_DEFAULT 
  
  if (c = 32 or c = 40 or c = 96 ) then
	kp = *IupGetAttribute(self, "CARETPOS") 
	fff = *IupGetAttribute(self, "LINEVALUE")
	ll = len(fff) :	pp = 1
	for i = 1 to ll
		if mid(fff,i,1) = " " then
		pp=i
		endif
	next i
	
	intelisense =  trim(mid(fff, pp, ll - pp + 11))
		
		if c = 96 then
			IupSetAttribute(label2, "TITLE", findhelp(intelisense))
			ret = IUP_IGNORE
		else		
			if intelisense_on_off = "ON" then
				if ucase(intelisense) = "AS" then
					mmm = napuni()
					FILLLIST
					IupPopUp(dialog8, IUP_CENTERPARENT, IUP_CENTERPARENT)
				else
					IupSetAttribute(ml, "INSERT", findreplace(intelisense))
				end if
			else
				if intelisense = "as" then
					'IupPopUp(dialog8, IUP_CENTERPARENT, IUP_CENTERPARENT)
				else
					IupSetAttribute(label2, "TITLE", findreplace(intelisense))
				end if
			endif
		end if
  endif

return ret
end function



function ml_button_cb cdecl (self as Ihandle ptr, lin1 as integer, col1 as integer, pos1 as integer) as integer
return IUP_DEFAULT
end function

function ml_caret_cb cdecl (self as Ihandle ptr, lin1 as integer, col1 as integer, pos1 as integer) as integer
return IUP_DEFAULT
end function
'''''''''''''''''''''''
function readhelpdata() as integer
dim txt as string
dim i as integer
open "KEYDATA.txt" for input as #1
  i = 1
  do while not eof(1)
  line input #1, txt
  helpdata1(i) = txt
  line input #1, txt
  helpdata2(i) = txt
  line input #1, txt
  helpdata3(i) = txt  
  i = i + 1
  loop
  close #1
  helpdatacnt = i - 1
  return 0
end function

'
' main
'
intelisense_on_off = "ON"
dim rret as integer
rret = readhelpdata()

label1 = IupLabel(" F2-" + intelisense_on_off + " | F3-LineInfo | F4-Insert ")
IupSetAttribute(label1,"FONT", "Courier, 10")
IupSetAttribute(label1,"SIZE","680x15")
IupSetAttribute(label1, "BGCOLOR", "255 0 0")
IupSetAttribute(label1, "FGCOLOR", "0 0 255")

label2 = IupLabel("")
IupSetAttribute(label2,"FONT", "Courier, 10")
IupSetAttribute(label2,"SIZE","680x15")
IupSetAttribute(label2, "BGCOLOR", "255 0 0")
IupSetAttribute(label2, "FGCOLOR", "255 0 0")

ml = IupMultiLine(NULL)
IupSetAttribute(ml,"FONT", "Courier, 10")
IupSetAttribute(ml,"TABSIZE", "4")
IupSetCallback(ml, "ACTION", cast(Icallback,@ml_action))
IupSetCallback(ml, "BUTTON_CB", cast(Icallback,@ml_button_cb))
IupSetCallback(ml, "CARET_CB", cast(Icallback,@ml_caret_cb))
IupSetCallback(ml, "K_F2", cast(Icallback,@PF2))
IupSetCallback(ml, "K_F3", cast(Icallback,@PF3))
IupSetCallback(ml, "K_F4", cast(Icallback,@PF4))
IupSetCallback(ml, "K_F5", cast(Icallback,@PF5))

IupSetAttribute(ml, "EXPAND", "YES")
IupSetAttribute(ml, "BORDER", "YES")

hbox7 = IupHBox(label2, NULL)
IupSetAttribute(hbox7, "NCMARGIN", "2")

vbox1=IUPVBox(label1, ml, hbox7, NULL)

'IupSetAttribute(vbox1, "NCMARGIN", "2")
dlg = IupDialog(vbox1)
IupSetAttribute(dlg, "TITLE", "FreeBasic Pad")
IupSetAttribute(dlg, "SIZE",  "640x280")
IupSetAttribute(dlg, "ICON",  ImgNames(1))

IupMap(dialog8)
IupMap(dialog1)

IupShow(dlg)
IupMainLoop()
edit2.bas

Code: Select all

dim shared as IHandle ptr f2bt1, f2bt2, dialog1, cbox

''''' 


''''' METHODS

function f2bt1_clicked cdecl (self as IHandle ptr) as integer
  IupSetAttribute(ml, "VALUE", !"dim shared as IHandle ptr f2bt1, f2bt2, dialog1, cbox\n\n'''''\n\n")
  'return IUP_DEFAULT
  return IUP_CLOSE
end function

function f2bt2_clicked cdecl (self as IHandle ptr) as integer
  IupSetAttribute(ml, "VALUE", lines_data(2))
  return IUP_DEFAULT
end function

''''' CONTROLS 

f2bt1 = IupButton("OK", NULL)
IupSetAttribute(f2bt1, "SIZE", "80x15")
IupSetCallback(f2bt1, "ACTION", cptr(ICallback,@f2bt1_clicked))
IupSetAttribute(f2bt1, "CX", "10")
IupSetAttribute(f2bt1, "CY", "10")

f2bt2 = IupButton("Cancel", NULL)
IupSetAttribute(f2bt2, "SIZE", "80x15")
IupSetCallback(f2bt2, "ACTION", cptr(ICallback,@f2bt2_clicked))
IupSetAttribute(f2bt2, "CX", "10")
IupSetAttribute(f2bt2, "CY", "50")

cbox = IupCbox(f2bt1, f2bt2, NULL)
IupSetAttribute(cbox, "SIZE", "480x200")

dialog1 = IupDialog(CBox)
IupSetAttribute(dialog1, "TITLE", "As")
IupSetAttribute(dialog1, "RESIZE", "NO")
IupSetAttribute(dialog1, "MINBOX", "NO")

edit3.bas

Code: Select all

dim shared as IHandle ptr f2bt9, f2bt8, dialog8, cbox8, list4, list5
''''' 

''''' METHODS

function list_cb cdecl (self as IHandle ptr, t as zstring ptr, i as integer, v as integer) as integer
  'print *t, i
  IupSetAttribute(f2bt9, "TITLE", *t)
  return IUP_DEFAULT
end function


function f2bt9_clicked cdecl (self as IHandle ptr) as integer
  dim txt as string
  txt = *IupGetAttribute(f2bt9, "TITLE")
  txt = " " + trim(txt)
  IupSetAttribute(ml, "INSERT", txt)
  
  
  
  
  
  
  
  return IUP_CLOSE
end function


''''' CONTROLS 

f2bt9 = IupButton("OK", NULL)
IupSetAttribute(f2bt9, "SIZE", "80x15")
IupSetCallback(f2bt9, "ACTION", cptr(ICallback,@f2bt9_clicked))
IupSetAttribute(f2bt9, "CX", "2")
IupSetAttribute(f2bt9, "CY", "300")




list4 = IupList(NULL)
IupSetAttributes(list4, !"1=\"Byte\", 2=\"Short\", 3=\"Integer\", 4=\"Longint\", 5=\"Ubyte\", 6=\"Ushort\", 7=\"Uinteger\", 8=\"Ulongint\", 9=\"Single\", 10=\"Double\", 11=\"String\", 12=\"Zstring\", EXPAND=YES")
IupSetCallback(list4, "ACTION", cptr(ICallback,@list_cb))

IupSetAttribute(list4,"SIZE","80x120")
IupSetAttribute(list4,"CX","2")
IupSetAttribute(list4,"CY","2")
IupSetAttribute(list4,"MULTIPLE","NO")

list5 = IupList(NULL)
IupSetAttribute(list5,"SIZE","80x120")
IupSetAttribute(list5,"CX","170")
IupSetAttribute(list5,"CY","2")
IupSetAttribute(list5,"MULTIPLE","NO")

cbox8 = IupCbox(f2bt9, list4, list5, NULL)
IupSetAttribute(cbox8,"FONT", "Courier, 10")
IupSetAttribute(cbox8, "SIZE", "380x200")

dialog8 = IupDialog(CBox8)
IupSetAttribute(dialog8, "TITLE", "As")
IupSetAttribute(dialog8, "RESIZE", "NO")
IupSetAttribute(dialog8, "MINBOX", "NO")

Drago
Posts: 116
Joined: Aug 10, 2005 13:15

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

Post by Drago »

Hoi Joshy,

did you plan to update to IUP 3.8 ?

expecially I'm interested in the new IUP Grid :-)


Auf jedenFall : 3 Wochen Urlaub ab jetzt.
Erstmal ein Rasberry bestellen *g*

Grüße
Rainer
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:did you plan to update to IUP 3.8 ?
No but feel free and add the hand full of new features to "iup.bi" and download the latest mingw IUP libs.
Drago wrote:... Erstmal ein Rasberry bestellen *g*
Do you order the PI from pollin.de ?

Joshy
Post Reply