FLTK 1.3.x C Wrapper (obsolete)

User contributed sources that have become inactive, deprecated, or generally unusable. But ... we don't really want to throw them away either.
Post Reply
WQ1980
Posts: 48
Joined: Sep 25, 2015 12:04
Location: Russia

Re: FLTK 1.3.3 C Wrapper Windows/Linux 32/64-bit.

Post by WQ1980 »

D.J.Peters wrote: Good find it was an typo byref/byval both in FreeBASIC and the C++ wrapper.

Is fixed now.

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

Re: FLTK 1.3.3 C Wrapper Windows/Linux 32/64-bit.

Post by D.J.Peters »

I uploaded file "fltk-c.zip" again .
(only some *.bas files are changed)

fixed: some integer vs. long stuff for 64 bit targets.

Joshy
WQ1980
Posts: 48
Joined: Sep 25, 2015 12:04
Location: Russia

Re: FLTK 1.3.3 C Wrapper Windows/Linux 32/64-bit.

Post by WQ1980 »

Hi!

Will support fl_xid and fl_find in Windows and Linux?

http://www.fltk.org/doc-1.3/osissues.ht ... 2_messages
and
http://www.fltk.org/doc-1.3/osissues.ht ... s_x_events

Fl_Window -> HWND
and
Fl_Window -> XID ?
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: FLTK 1.3.3 C Wrapper Windows/Linux 32/64-bit.

Post by D.J.Peters »

Get latest version.

added: FL_Find(), Fl_XID()

Joshy

Fl_XID.bas

Code: Select all

#include once "fltk-c.bi"

sub ShowCB cdecl (byval self as Fl_Widget ptr, box as any ptr)
  var win = Fl_WidgetWindow(self)
  Fl_WidgetCopyLabel(box,"0x" & hex(Fl_XID(win)))
  Fl_WidgetDeactivate self
end sub
'
' main
'
var win = Fl_WindowNew(320,52,"FL_XID()")
var btn = Fl_ButtonNew( 10,10,150,32,"show handle")
var box = Fl_BoxNew   (170,10,150,32)
Fl_WidgetSetLabelSize  box,20
Fl_WidgetSetLabelColor box,&H0000AA00
Fl_WidgetSetCallbackArg btn,@ShowCB,box
Fl_WindowShow win
Fl_Run
Windows: HWND (a pointer 32/64-bit)
Linux: XID a XLIB window id (ulong 32-bit)

Code: Select all

#ifdef __FB_WIN32__
declare function FL_Find(xid as any ptr) as Fl_Window ptr
declare function Fl_XID(win as const Fl_Window ptr) as any ptr
#else
declare function FL_Find(xid as ulong) as Fl_Window ptr
declare function Fl_XID(win as const Fl_Window ptr) as ulong
#endif
WQ1980
Posts: 48
Joined: Sep 25, 2015 12:04
Location: Russia

Re: FLTK 1.3.3 C Wrapper Windows/Linux 32/64-bit.

Post by WQ1980 »

D.J.Peters wrote:Get latest version.

added: FL_Find(), Fl_XID()

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

Re: FLTK 1.3.3 C Wrapper Windows/Linux 32/64-bit.

Post by D.J.Peters »

Added some new stuff.

Joshy

new test: Fl_Tree_of_Fl_Tables.bas
Image
file: Fl_Tree_of_Fl_Tables.bas

Code: Select all

#include once "fltk-c.bi"
#include once "string.bi"

#ifndef PI
#define PI 3.14159
#endif

function DrawCellCB cdecl (byval self as any ptr,byval context as Fl_TableContext, _
                           byval r as long,byval c as long, _
                           byval x as long,byval y as long,byval w as long,byval h as long) as long
  dim as string mode
  dim as const zstring ptr pMode = Fl_WidgetGetUserData(self)
  if pMode then mode = *pMode
  select case as const context
  case FL_CONTEXT_STARTPAGE ' before page is drawn..
    DrawSetFont(FL_HELVETICA, 10) ' set the font for our drawing operations
  case FL_CONTEXT_COL_HEADER,FL_CONTEXT_ROW_HEADER
    dim as long value,colour
    dim as string header
    if (context=FL_CONTEXT_COL_HEADER) then
      value = c
      colour = Fl_TableGetColHeaderColor(self)
    else
      value = r
      colour = Fl_TableGetRowHeaderColor(self)
    end if
    if mode="SinCos" then
      header = format(value/10.0*PI,"0.000")
    else 
      header = str(value)
    end if
    DrawPushClip(x,y,w,h)
      DrawBox(BoxType(FL_THIN_UP_BOX),x,y,w,h,colour)
      DrawSetColor(FL_BLACK)
      DrawStrBox(header,x,y,w,h,FL_ALIGN_CENTER)
    DrawPopClip()
  case FL_CONTEXT_CELL
    dim as string cell="???"
    if mode = "Addition" then
      cell=str(r+c)
    elseif mode = "Subtract" then
      cell=str(r-c)
    elseif mode = "Multiply" then
      cell=str(r*c)
    elseif mode = "Divide" then
      if (c<>0) then cell = Format(r/c,"0.000") else cell = "N/A"
    elseif mode = "Exponent" then
      cell = str(r^c)
    elseif mode = "SinCos" then
      cell = Format ( sin(r/10.0*PI) * cos(c/10.0*PI),"0.000" ) 
    end if
    dim as long colour = iif(Fl_TableIsSelected(self,r,c),FL_YELLOW,FL_WHITE)
    DrawPushClip(x,y,w,h)
      DrawRectFillColor(x,y,w,h,colour)
      DrawSetColor(FL_GRAY0) 
      DrawStrBox(cell,x,y,w,h,FL_ALIGN_CENTER)
      DrawRectColor(x,y,w,h,Fl_WidgetGetColor(self))
    DrawPopClip()
  case else 
    return 0 ' let FLTK do the job
  end select

  return 1 ' we have done our job
end function

function ResizeCB cdecl (byval self as any ptr,byval x as long,byval y as long,byval w as long,byval h as long) as long
  if (w>718) then 
   w = 718 ' don't exceed 700 in width
   Fl_TableResize(self,x,y,w,Fl_WidgetGetH(self)) ' disallow changes in height
   return 1 ' ' we have done our job
  end if
  return 0 ' let FLTK do the job 
end function

function HandleCB cdecl (byval self as any ptr,byval event as Fl_Event) as long
  return Fl_TableExHandleBase(self,event)
end function

#macro AddTable(path,mode)
  ' create Fl_TableEx
  table = Fl_TableExNew(0,0,500,156)
  Fl_TableBegin(table) ' <-- optional (is done by the base constructor)
    ' setup row 
    Fl_TableSetRows(table,11)
    Fl_TableRowHeightAll(table,20)
    Fl_TableSetRowHeader(table,1)

    ' setup col
    Fl_TableSetCols(table,11)
    Fl_TableColWidthAll(table,60)
    Fl_TableSetColHeader(table,1)
    ' enable column resizing
    Fl_TableSetRowResize(table,0)

  Fl_TableEnd(table) ' <- !!! important !!! we must close the child list

  ' save string mode as user data
  Fl_WidgetSetUserData table,mode
  ' set DrawCell, Resize and Handle callback
  Fl_TableExSetDrawCellCB table,@DrawCellCB
  Fl_TableExSetHandleCB table,@HandleCB
  Fl_TableExSetResizeCB table,@ResizeCB
  ' add new tree item
  item = Fl_TreeAdd(tree,path)
  ' set table as tree item
  Fl_Tree_ItemSetWidget(item,table)
#endmacro

'
' main
'
var win = Fl_Double_WindowNew(700, 400, "Tree of tables")
Fl_WindowBegin win
  ' Create tree
  var tree = Fl_TreeNew(10, 10, Fl_WidgetGetW(win)-20,Fl_WidgetGetH(win)-20)
  Fl_Tree_ItemSetLabel Fl_TreeRoot(tree),"Math Tables"
  Fl_TreeSetItemLabelFont tree,FL_COURIER ' font to use for items
  Fl_TreeSetLineSpacing tree,12 ' extra space between items
  Fl_TreeSetItemDrawMode(tree,Fl_TreeGetItemDrawMode(tree)   or _ 
                              FL_TREE_ITEM_DRAW_LABEL_AND_WIDGET or _ ' draw item with widget() next to it 
                              FL_TREE_ITEM_HEIGHT_FROM_WIDGET)        ' make item height follow table's height

  Fl_TreeSetSelectMode(tree,FL_TREE_SELECT_NONE) ' font to use for items
  Fl_TreeSetWidgetMarginLeft(tree,12)            ' space between item and table
  Fl_TreeSetConnectorStyle(tree,FL_TREE_CONNECTOR_DOTTED)
  ' Create tables, assign each a tree item
  Fl_TreeBegin(tree)
    dim as Fl_TableEx   ptr table
    dim as Fl_Tree_Item ptr item
    AddTable(@"Arithmetic/Addition",@"Addition")
    AddTable(@"Arithmetic/Subtract",@"Subtract")
    AddTable(@"Arithmetic/Multiply",@"Multiply")
    AddTable(@"Arithmetic/Divide  ",@"Divide")
    AddTable(@"Misc/Exponent"      ,@"Exponent")
    AddTable(@"Misc/Sin*Cos "      ,@"SinCos")
  Fl_TreeEnd(tree)
Fl_WindowEnd win
Fl_WindowShow win
Fl_Run
new class:

Code: Select all

' NEW:
'###########################################################
'# class Fl_Tree_Prefs is used by Fl_Tree_Item and Fl_Tree #
'###########################################################
type Fl_Tree_Prefs
  declare constructor
  as Fl_Font     _labelfont    ' label's font face
  as Fl_Fontsize _labelsize    ' label's font size
  as long        _margintop    ' -- 
  as long        _marginleft   '   |- tree's controllable margins
  as long        _marginbottom ' --
  as long        _openchild_marginbottom ' extra space below an open child tree
  as long        _usericonmarginleft     ' space to left of user icon (if any)
  as long        _labelmarginleft        ' space to left of label
  as long        _widgetmarginleft       ' space to left of widget
  as long        _connectorwidth         ' connector width (right of open/close icon)
  as long        _linespacing            ' vertical space between lines
  as Fl_Color    _labelfgcolor           ' label's foreground color
  as Fl_Color    _labelbgcolor           ' label's background color
  as Fl_Color    _connectorcolor         ' connector dotted line color
  as Fl_Tree_Connector _connectorstyle   ' connector line style
  as Fl_Image ptr _openimage             ' the 'open' icon [+]
  as Fl_Image ptr _closeimage            ' the 'close' icon [-]
  as Fl_Image ptr _userimage             ' user's own icon
  as ubyte        _showcollapse          ' 1=show collapse icons, 0=don't
  as ubyte        _showroot              ' show the root item as part of the tree
  as FL_TREE_SORT _sortorder             ' none, ascening, descending, etc.
  as ulong        _selectbox             ' selection box type
  as FL_TREE_SELECT _selectmode          ' selection mode
  as FL_TREE_ITEM_RESELECT_MODE _itemreselectmode ' controls item selection callback() behavior
  as FL_TREE_ITEM_DRAW_MODE     _itemdrawmode     ' controls how items draw label + widget()
  as Fl_Tree_Item_Draw_Callback ptr _itemdrawcallback ' callback to handle drawing items (0=none)
  as any ptr _itemdrawuserdata      ' data for drawing items (0=none)
end type
constructor Fl_Tree_Prefs
  _labelfont              = FL_HELVETICA
  _labelsize              = FL_NORMAL_SIZE
  _marginleft             = 6
  _margintop              = 3
  _marginbottom           = 20
  _openchild_marginbottom = 0
  _usericonmarginleft     = 3
  _labelmarginleft        = 3
  _widgetmarginleft       = 3
  _linespacing            = 0
  _labelfgcolor           = FL_BLACK
  _labelbgcolor           = &Hffffffff ' we use this as 'transparent'
  _connectorcolor         = 43
  _connectorstyle         = FL_TREE_CONNECTOR_DOTTED
  _openimage              = 0 ' !!! todo @L_openpixmap
  _closeimage             = 0 ' !!! todo @L_closepixmap
  _userimage              = 0
  _showcollapse           = 1
  _showroot               = 1
  _connectorwidth         = 17
  _sortorder              = FL_TREE_SORT_NONE
  _selectbox              = FL_FLAT_BOX
  _selectmode             = FL_TREE_SELECT_SINGLE
  _itemreselectmode       = FL_TREE_SELECTABLE_ONCE
  _itemdrawmode           = FL_TREE_ITEM_DRAW_DEFAULT
  _itemdrawcallback       = 0
  _itemdrawuserdata       = 0
  ' Let fltk's current 'scheme' affect defaults
  if ( Fl_GetScheme()<>0 ) then
    if ( *Fl_GetScheme()="gtk+") then
      _selectbox = BoxType(FL_GTK_THIN_UP_BOX)
    elseif ( *Fl_GetScheme()="plastic") then
      _selectbox = BoxType(FL_PLASTIC_THIN_UP_BOX)
    end if
  end if
end constructor
new const's:

Code: Select all

' NEW: Bit flags that control how item's labels and widget()s are drawn in the tree.
type FL_TREE_ITEM_DRAW_MODE as ulong
' If widget() defined, draw in place of label, and widget() tracks item height (default)
const as FL_TREE_ITEM_DRAW_MODE FL_TREE_ITEM_DRAW_DEFAULT          = 0
' If widget() defined, include label to the left of the widget
const as FL_TREE_ITEM_DRAW_MODE FL_TREE_ITEM_DRAW_LABEL_AND_WIDGET = 1 
' If widget() defined, widget()'s height controls item's height
const as FL_TREE_ITEM_DRAW_MODE FL_TREE_ITEM_HEIGHT_FROM_WIDGET    = 2
new methods:

Code: Select all

' NEW:
type Fl_Tree_Item_Draw_Callback as sub (byval item as Fl_Tree_Item ptr,byval userdata as any ptr)
'#########################################
'# class Fl_Tree_Item is used by Fl_Tree #
'#########################################
declare function Fl_Tree_ItemNew(byval tree as Fl_Tree ptr) as Fl_Tree_Item ptr
' The item's x position relative to the window
declare function Fl_Tree_ItemGetX(byval item as Fl_Tree_Item ptr) as long
' The item's y position relative to the window
declare function Fl_Tree_ItemGetY(byval item as Fl_Tree_Item ptr) as long
' The entire item's width to right edge of Fl_Tree's inner width within scrollbars.
declare function Fl_Tree_ItemGetW(byval item as Fl_Tree_Item ptr) as long
' The item's height
declare function Fl_Tree_ItemGetH(byval item as Fl_Tree_Item ptr) as long
' The item's label x position relative to the window
declare function Fl_Tree_ItemGetLabelX(byval item as Fl_Tree_Item ptr) as long
' The item's label y position relative to the window
declare function Fl_Tree_ItemGetlabelY(byval item as Fl_Tree_Item ptr) as long
' The item's maximum label width to right edge of Fl_Tree's inner width within scrollbars.
declare function Fl_Tree_ItemGetLabelW(byval item as Fl_Tree_Item ptr) as long
' The item's label height
declare function Fl_Tree_ItemGetLabelH(byval item as Fl_Tree_Item ptr) as long
declare function Fl_Tree_ItemDrawItemContent(byval item as Fl_Tree_Item ptr,byval render as long) as long
declare sub      Fl_Tree_ItemDraw(byval item as Fl_Tree_Item ptr, byval x as long,byref y as long,byval w as long,byval itemfocus as Fl_Tree_Item ptr,byref tree_item_xmax as long,byval lastchild as long=1,byval render as long=1)
declare sub      Fl_Tree_ItemShowSelf(byval item as Fl_Tree_Item ptr,byval indent as const zstring ptr=@"")
' Set/Get a user-data value for the item.
declare sub      Fl_Tree_ItemSetUserData(byval item as Fl_Tree_Item ptr,byval userdata as any ptr)
declare function Fl_Tree_ItemGetUserData() as any ptr
declare sub      Fl_Tree_ItemSetLabel(byval item as Fl_Tree_Item ptr,byval newlabel as const zstring ptr)
declare function Fl_Tree_ItemGetLabel(byval item as Fl_Tree_Item ptr) as const zstring ptr
' Set/Get item's label font face.
declare sub      Fl_Tree_ItemSetLabelfont(byval item as Fl_Tree_Item ptr,byval font as Fl_Font)
declare function Fl_Tree_ItemLabelfont(byval item as Fl_Tree_Item ptr) as Fl_Font
' Set/Get item's label font size.
declare sub      Fl_Tree_ItemSetLabelsize(byval item as Fl_Tree_Item ptr,byval size as Fl_Fontsize)
declare function Fl_Tree_ItemGetLabelsize(byval item as Fl_Tree_Item ptr) as Fl_Fontsize
' Set/Get item's label foreground text color.
declare sub      Fl_Tree_ItemSetLabelfgcolor(byval item as Fl_Tree_Item ptr,byval c as Fl_Color)
declare function Fl_Tree_ItemGetLabelfgcolor(byval item as Fl_Tree_Item ptr) as Fl_Color
' Set/Get item's label text color. Alias for labelfgcolor(Fl_Color)).
declare sub      Fl_Tree_ItemSetLabelcolor(byval item as Fl_Tree_Item ptr,byval c as Fl_Color)
declare function Fl_Tree_ItemGetLabelcolor(byval item as Fl_Tree_Item ptr) as Fl_Color
' Set/Get item's label background color.
' A special case is made for color &Hffffffff which uses the parent tree's bg color.
declare sub      Fl_Tree_ItemSetLabelbgcolor(byval item as Fl_Tree_Item ptr,byval c as Fl_Color)
declare function Fl_Tree_ItemGetLabelbgcolor(byval item as Fl_Tree_Item ptr) as Fl_Color
' Assign /return an FLTK widget to/from this item.
declare sub      Fl_Tree_ItemSetWidget(byval item as Fl_Tree_Item ptr,byval wgft as Fl_Widget ptr)
declare function Fl_Tree_ItemGetWidget(byval item as Fl_Tree_Item ptr) as const Fl_Widget ptr
' Return the number of children this item has.
declare function Fl_Tree_ItemGetChildren(byval item as Fl_Tree_Item ptr) as long
' Return the child item for the given 'index'.
declare function Fl_Tree_ItemGetChild(byval item as Fl_Tree_Item ptr,byval index as long) as Fl_Tree_Item ptr
' Return the const child item for the given 'index'.
declare function Fl_Tree_ItemGetConstChild(byval item as Fl_Tree_Item ptr,byval t as long) as const Fl_Tree_Item ptr
' See if this item has children.
declare function Fl_Tree_ItemHasChildren(byval item as Fl_Tree_Item ptr) as long
declare function Fl_Tree_ItemFindChildByName(byval item as Fl_Tree_Item ptr,byval nam as const zstring ptr) as long
declare function Fl_Tree_ItemFindChildByItem(byval item as Fl_Tree_Item ptr,byval item as Fl_Tree_Item ptr) as long
declare function Fl_Tree_ItemRemoveChild(byval item as Fl_Tree_Item ptr,byval item as Fl_Tree_Item ptr) as long
declare function Fl_Tree_ItemRemoveChildSetLabel(byval item as Fl_Tree_Item ptr,byval newlabel as const zstring ptr) as long
declare sub      Fl_Tree_ItemClearChildren(byval item as Fl_Tree_Item ptr)
declare sub      Fl_Tree_ItemSwapChildrenByIndex(byval item as Fl_Tree_Item ptr,byval ax as long,byval bx as long)
declare function Fl_Tree_ItemSwapChildren(byval item as Fl_Tree_Item ptr,byval a as Fl_Tree_Item ptr, byval b as Fl_Tree_Item ptr) as long
declare function Fl_Tree_ItemFindConstChildItemByName(byval item as Fl_Tree_Item ptr,byval nam as const zstring ptr) as const Fl_Tree_Item ptr
declare function Fl_Tree_ItemFindChildItemByName(byval item as Fl_Tree_Item ptr,byval nam as zstring ptr) as Fl_Tree_Item ptr
declare function Fl_Tree_ItemFindConstChildItem(byval item as Fl_Tree_Item ptr,byval arr as zstring ptr ptr) as const Fl_Tree_Item ptr
declare function Fl_Tree_ItemFindChildItem(byval item as Fl_Tree_Item ptr,byval arr as zstring ptr ptr) as Fl_Tree_Item ptr
declare function Fl_Tree_ItemFindConstItem(byval item as Fl_Tree_Item ptr,byval arr as zstring ptr ptr) as const Fl_Tree_Item ptr
declare function Fl_Tree_ItemFindItem(byval item as Fl_Tree_Item ptr,byval arr as zstring ptr ptr) as Fl_Tree_Item ptr

' Adding items
declare function Fl_Tree_ItemAdd(byval item as Fl_Tree_Item ptr,byref prefs as const Fl_Tree_Prefs,byval arr as zstring ptr ptr) as Fl_Tree_Item ptr
declare function Fl_Tree_ItemAdd2(byval item as Fl_Tree_Item ptr,byref prefs as const Fl_Tree_Prefs,byval new_label as const zstring ptr) as Fl_Tree_Item ptr
declare function Fl_Tree_ItemAddItem(byval item as Fl_Tree_Item ptr,byref prefs as const Fl_Tree_Prefs,byval new_label as const zstring ptr,byval newitem as Fl_Tree_Item ptr) as Fl_Tree_Item ptr
declare function Fl_Tree_ItemAddItem2(byval item as Fl_Tree_Item ptr,byref prefs as const Fl_Tree_Prefs,byval arr as zstring ptr ptr,byval newitem as Fl_Tree_Item ptr) as Fl_Tree_Item ptr

declare function Fl_Tree_ItemReplace(byval item as Fl_Tree_Item ptr,byval newitem as Fl_Tree_Item ptr) as Fl_Tree_Item ptr
declare function Fl_Tree_ItemReplaceChild(byval item as Fl_Tree_Item ptr,byval oldtem as Fl_Tree_Item ptr, byval newitem as Fl_Tree_Item ptr) as Fl_Tree_Item ptr
declare function Fl_Tree_ItemInsert(byval item as Fl_Tree_Item ptr,byref prefs as const Fl_Tree_Prefs,byval new_label as const zstring ptr,byval pos as long) as Fl_Tree_Item ptr
declare function Fl_Tree_ItemInsertAbove(byval item as Fl_Tree_Item ptr,byref prefs as const Fl_Tree_Prefs,byval new_label as const zstring ptr) as Fl_Tree_Item ptr
declare function Fl_Tree_ItemDeparent(byval item as Fl_Tree_Item ptr,byval index as long) as Fl_Tree_Item ptr

declare function Fl_Tree_ItemReparent(byval item as Fl_Tree_Item ptr,byval newchild as Fl_Tree_Item ptr,byval index as long) as long
declare function Fl_Tree_ItemMove(byval item as Fl_Tree_Item ptr,byval _to as long,byval from as long) as long
declare function Fl_Tree_ItemMoveItem(byval item as Fl_Tree_Item ptr,byval other as Fl_Tree_Item ptr,byval op as long,byval pos as long) as long
declare function Fl_Tree_ItemMoveAbove(byval item as Fl_Tree_Item ptr,byval other as Fl_Tree_Item ptr) as long
declare function Fl_Tree_ItemMoveBelow(byval item as Fl_Tree_Item ptr,byval other as Fl_Tree_Item ptr) as long
declare function Fl_Tree_ItemMoveInto(byval item as Fl_Tree_Item ptr,byval other as Fl_Tree_Item ptr,byval pos as long) as long
declare function Fl_Tree_ItemDepth(byval item as Fl_Tree_Item ptr) as long
declare function Fl_Tree_ItemPrev(byval item as Fl_Tree_Item ptr) as Fl_Tree_Item ptr
declare function Fl_Tree_ItemNext(byval item as Fl_Tree_Item ptr) as Fl_Tree_Item ptr
declare function Fl_Tree_ItemNextSibling(byval item as Fl_Tree_Item ptr) as Fl_Tree_Item ptr
declare function Fl_Tree_ItemPrevSibling(byval item as Fl_Tree_Item ptr) as Fl_Tree_Item ptr
declare sub      Fl_Tree_ItemUpdatePrevNext(byval item as Fl_Tree_Item ptr, byval index as long)
declare function Fl_Tree_ItemNextDisplayed(byval item as Fl_Tree_Item ptr,byref prefs as Fl_Tree_Prefs) as Fl_Tree_Item ptr
declare function Fl_Tree_ItemPrevDisplayed(byval item as Fl_Tree_Item ptr,byref prefs as Fl_Tree_Prefs) as Fl_Tree_Item ptr
' Return the parent for this item. Returns NULL if we are the root.
declare function Fl_Tree_ItemGetParent(byval item as Fl_Tree_Item ptr) as Fl_Tree_Item ptr
' Return the const parent for this item. Returns NULL if we are the root.
declare function Fl_Tree_ItemGetConstParent(byval item as Fl_Tree_Item ptr) as const Fl_Tree_Item ptr
' Set the parent for this item. Should only be used by Fl_Tree's internals.
declare sub      Fl_Tree_ItemSetParent(byval item as Fl_Tree_Item ptr,byval other as Fl_Tree_Item ptr)
declare function Fl_Tree_ItemGetPrefs(byval item as Fl_Tree_Item ptr) byref as const Fl_Tree_Prefs 
' Return the tree for this item.
declare function Fl_Tree_ItemGetTree(byval item as Fl_Tree_Item ptr) as const Fl_Tree

' State
declare sub      Fl_Tree_ItemOpen(byval item as Fl_Tree_Item ptr)
declare sub      Fl_Tree_ItemClose(byval item as Fl_Tree_Item ptr)
' See if the item is 'open'.
declare function Fl_Tree_ItemIsOpen(byval item as Fl_Tree_Item ptr) as long
' See if the item is 'closed'.
declare function Fl_Tree_ItemIsClose(byval item as Fl_Tree_Item ptr) as long
' Toggle the item's open/closed state.
declare sub      Fl_Tree_ItemOpenToggle(byval item as Fl_Tree_Item ptr)
' Change the item's selection state to the optionally specified 'val'.
' If 'v' is not specified, the item will be selected.
declare sub      Fl_Tree_ItemSelect(byval item as Fl_Tree_Item ptr,byval v as long=1)
' Toggle the item's selection state.
declare sub      Fl_Tree_ItemSelectToggle(byval item as Fl_Tree_Item ptr)
' Select item and all its children.
' Returns count of how many items were in the 'deselected' state, ie. how many items were "changed".
declare function Fl_Tree_ItemSelectAll(byval item as Fl_Tree_Item ptr) as long
' Disable the item's selection state.
declare sub      Fl_Tree_ItemDeselect(byval item as Fl_Tree_Item ptr)
' Deselect item and all its children.
' Returns count of how many items were in the 'selected' state, ie. how many items were "changed".
declare function Fl_Tree_ItemDeselectAll(byval item as Fl_Tree_Item ptr) as long
' See if the item is selected.
declare function Fl_Tree_ItemIsSelected(byval item as Fl_Tree_Item ptr) as ubyte
' Change the item's activation state to the optionally specified 'v'.
' When deactivated, the item will be 'grayed out'; the callback()
' won't be invoked if the user clicks on the label. If a widget()
' is associated with the item, its activation state will be changed as well.
' If 'v' is not specified, the item will be activated.
declare sub      Fl_Tree_ItemActivate(byval item as Fl_Tree_Item ptr,byval v as long=1)
' Deactivate the item; the callback() won't be invoked when clicked. Same as activate(0)
declare sub      Fl_Tree_ItemDeactivate(byval item as Fl_Tree_Item ptr)
' See if the item is activated.
declare function Fl_Tree_ItemIsActivated(byval item as Fl_Tree_Item ptr) as ubyte 
' See if the item is activated. Alias for is_activated().
declare function Fl_Tree_ItemIsActive(byval item as Fl_Tree_Item ptr) as ubyte
' See if the item is visible.
declare function Fl_Tree_ItemIsVisible(byval item as Fl_Tree_Item ptr) as long
declare function Fl_Tree_ItemVisibleR(byval item as Fl_Tree_Item ptr) as long

' Set/Get the item's user icon to an Fl_Image. '0' will disable.
declare sub      Fl_Tree_ItemSetUserIcon(byval item as Fl_Tree_Item ptr,byval img as Fl_Image ptr)
declare function Fl_Tree_ItemGetUserIcon(byval item as Fl_Tree_Item ptr) as Fl_Image ptr

' Events
declare function Fl_Tree_ItemFindConstClicked(byval item as Fl_Tree_Item ptr,byref prefs as const Fl_Tree_Prefs,byval yonly as long=0) as const Fl_Tree_Item ptr
declare function Fl_Tree_ItemFindClicked(byval item as Fl_Tree_Item ptr,byref prefs as const Fl_Tree_Prefs,byval yonly as long=0) as Fl_Tree_Item ptr

declare function Fl_Tree_ItemEventOnCollapseIcon(byval item as Fl_Tree_Item ptr,byref prefs as const Fl_Tree_Prefs) as long
declare function Fl_Tree_ItemEventOnLabel(byval item as Fl_Tree_Item ptr,byref prefs as const Fl_Tree_Prefs) as long
' Is this item the root of the tree?
declare function Fl_Tree_ItemIsRoot(byval item as Fl_Tree_Item ptr) as long
Last edited by D.J.Peters on Oct 03, 2017 4:03, edited 1 time in total.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: FLTK 1.3.3 C Wrapper Windows/Linux 32/64-bit.

Post by D.J.Peters »

Minor windows 32/64 udate :
I recompiled FLTK and the c-wrapper with the toolchain mingw64_5.2.0.
Before FLTK was compiled with mingw64_4.9.2 and the c-wrapper wth mingw64_5.2.0.

fixed:
added DrawPushClip/DrawPopClip to the drawing test codes.

added: (alternate form)
#define Fl_GroupSetResizeable Fl_GroupSetResizable
#define Fl_JPG_ImageNew Fl_JPEG_ImageNew
#define Fl_JPG_ImageDelete Fl_JPEG_ImageDelete
...

Joshy
WQ1980
Posts: 48
Joined: Sep 25, 2015 12:04
Location: Russia

Re: FLTK 1.3.3 C Wrapper Windows/Linux 32/64-bit.

Post by WQ1980 »

Only now I reached compiler FB...

Fl_XID.bas

In Windows 7-64 bit, FB 1.00 32-bit -> not compiled:
undefined reference to `Fl_XID'
and also Fl_Find

And also in Ubuntu 12.04 32-bit, FB 1.00 32-bit does not work:
Fl_XID: undefined symbol: Fl_XID


In Windows XP-32 bit and Windows 8-32 bit -> compiled
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: FLTK 1.3.3 C Wrapper Windows/Linux 32/64-bit.

Post by D.J.Peters »

I'm not at home ATM and can't test it.

First check the declare in the include file FL_Find FL_XID the letter "L" must be lowercase ---> "l" <---
and / or you have a old version laying around without Fl_Find and Fl_XID at all.

Ber sure you don't have a old version of FLTK-c-1.3.3-64.dll and libFLTK-c-1.3.3-64.a in any other folder like FreeBASIC/lib ...
same for ibFLTK-c-1.3.3-64.so ibFLTK-c-1.3.3-64-syslib.so in /usr/lib64 or /usr/lib.

Joshy
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: FLTK 1.3.3 C Wrapper Windows/Linux 32/64-bit.

Post by MrSwiss »

@WQ1980,

do yourself a favor and get FBC version 1.04.0 compiler(s) first ...
WQ1980
Posts: 48
Joined: Sep 25, 2015 12:04
Location: Russia

Re: FLTK 1.3.3 C Wrapper Windows/Linux 32/64-bit.

Post by WQ1980 »

MrSwiss wrote:@WQ1980,

do yourself a favor and get FBC version 1.04.0 compiler(s) first ...
Yes, FB 1.04 + Win 7-64 -> compiled
Thanks!
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: FLTK 1.3.3 C Wrapper Windows/Linux 32/64-bit.

Post by D.J.Peters »

@WQ1980 I fixed the problems with Fl_XID latest version is from Wed Oct 21, 2015 12:48 am.

If I rebuild the static libs from FLTK 1.3.3 C++ package
Fl_XID is a inline function named fl_xid and only for internal use
so if I build the FLTK C wrapper fl_xid is a #define to fl_xid_.

FLTK 1.3.3 C++ package with code::blocks workspace can be downloaded from first page also.

Joshy
badidea
Posts: 2586
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: FLTK 1.3.3 C Wrapper Windows/Linux 32/64-bit.

Post by badidea »

I have another FLTK question.

Can I access the pixel data of Fl_JPEG_ImageNew(fileName) or is this data is in the JPEG format?
I know there is a Fl_ImageData(...) function, but this does seem to point to the actual pixels in any convenient format, or I am doing something wrong.

What I actually want, is to load a jpeg-file and display only a section of the data (in a box). E.g. For a 800x600 pixel jpeg, display a pixel area (100,100)-(200,200). Some kind of 'crop' function. Any suggestions on how to do this?

And to show that I am actually making progress learning FLTK, this is how my program currently looks like:
http://nr100.home.xs4all.nl/badidea/sbs/sbs2.png
The 'Todo: Camp Image' is where I want to display a part of a larger image.
WQ1980
Posts: 48
Joined: Sep 25, 2015 12:04
Location: Russia

Re: FLTK 1.3.3 C Wrapper Windows/Linux 32/64-bit.

Post by WQ1980 »

badidea wrote:I have another FLTK question.

Can I access the pixel data of Fl_JPEG_ImageNew(fileName) or is this data is in the JPEG format?
I know there is a Fl_ImageData(...) function, but this does seem to point to the actual pixels in any convenient format, or I am doing something wrong.
My simple code Fl_Image -> FBImage:

Code: Select all

#Include Once "fltk-c.bi"

Var jpg = Fl_JPEG_ImageNew("media/renata.jpg")

Dim As Integer w, h, pitch, bypp
Dim As UByte Ptr pixels1
ScreenRes 320, 200, 32
w=128
h=128

Dim fbImage As Any Ptr
fbImage=ImageCreate(w,h, RGB(255, 255,255))
ImageInfo(fbImage,,, bypp, pitch, pixels1)

Open Cons For Output As #2
?#2, pitch, bypp

For y As Integer = 0 To h-1
	Dim row As UByte Ptr = Cast(UByte Ptr, *Fl_ImageData(jpg)) + y * (w*3)
	Dim row1 As UByte Ptr = pixels1 + y * pitch
	For x As Integer = 0 To w-1
		'?#2,row[x * 3] ,row[(x * 3) + 1], row[(x * 3) + 2], pitch
		row1[(x * 4)]=row[x * 3]
		row1[(x * 4) + 1]=row[(x * 3) + 1]
		row1[(x * 4) + 2]=row[(x * 3) + 2]
		Swap row1[(x * 4) + 2], row1[x * 4]
	Next
Next
Put (0,0), fbImage
Sleep
Some kind of 'crop' function. Any suggestions on how to do this?
Maybe -> Fl_ImageCopy2 function from fltk-c.bi?
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: FLTK 1.3.3 C Wrapper Windows/Linux 32/64-bit.

Post by D.J.Peters »

Yes Fl_JPG_Image extends Fl_RGB_Image extends Fl__Image and the Fl_Image has the function Fl_ImageData and method Fl_ImageCopy(width,height) Fl_ImageCopy2() in FreeBASIC.

Joshy
Post Reply