GTK3 reared it's ugly head on win7.
when executing a gtk3 example (gtk_applicatione110.bas). I am not 100% sure but most gtk3 programs should work on windows. The part that does not work is the part the demo uses
And I'm wondering why there are no parameter names in the header files (good job on the byval though).
The demos work though. And nice demos they are. That goo canvas thingy is fun. My brix program (tcl port) is almost done. Drag-n-drop is a bit hard to get right in goo canvas. Perhaps that´ll change in the future (or perhaps I'm doing something wrong?).
Code: Select all
#define SCALE_STEP 0.1
#INCLUDE ONCE "gtk/GTK-2.22.0_TJF.bi"
#INCLUDE ONCE "gtk/goocanvas-2.0.0.bi"
#ifndef NIL
#define NIL 0
#endif
type context__ as context_
type item_function as function (byval opt as integer, byval context as context__ ptr) as GooCanvasItem ptr
type context_
dim canvas as GtkWidget ptr
dim root as GooCanvasItem ptr
dim mould as GooCanvasItem ptr
dim drawing as GooCanvasItem ptr
dim drawn as GooCanvasItem ptr
dim background as GooCanvasItem ptr
dim funs as item_function ptr ''array of functions responsible for drawing items in mould
dim num_items as integer ''number of items in mould
dim drag_item as GooCanvasItem ptr ''the item that is being dragged
dim drag_x as double ''x value of item getting dragged at start of drag
dim drag_y as double ''y value of item getting dragged at start of drag
dim item_x as double ''x value of item getting dragged at end of drag
dim item_y as double ''y value of item getting dragged at end of drag
dim item_width as double ''the width of the dragged item
dim item_height as double ''the height of the dragged item
dim dragging as integer ''flag (dragging?)
end type
#define Xmax 1000
#define Ymax 1000
''Brix
''
''This example is a port of a tcl/tk program implementing a simple drawing program.
''On the left you see objects that can be placed on the canvas by drag-and-drop.
''These objects on the left are referred to collectively as 'the mould'. Items that are in
''the mould form a group.
''You can click on items in the mould and drop them on the right hand side of
''the window. You cannot drop an item inside the mould.
''Drag-and-drop has been implemented by putting an item on top of
''each item in the mould. When clicking on an item in the mould the top
''item is the item that gets selected and dragged/dropped. As soon as a drag ends
''the dragged item is moved to another group. The items in the mould get
''renewed (items are drawn on top of the mould items).
''The items that are on top of the items in the mould are member of the group drawing.
''A drop operation will not lead to the creation of items in the drawing group when
''an item is dropped on top of the mold. Dropping an item on the mold (or, for that matter,
''on the background) will remove the dropped item from the canvas.
''Pushing button C will remove all the items from the group drawn (it clears the canvas but
''not the mould).
''Pushing + will scale all the items up by SCALE_STEP.
''Pushing - will scale all the items down by SCALE_STEP.
''Brix has been implemented using goocanvas (not part of official GTK+ but implemented on
''top of/using GTK+)
''To compile you need GTK+ version 0.22 (both dynamic libraries and import libraries).
''You also need the necessary header files. The header files and the source code
''are part of the package you can download here. The GTK+ binaries you can download
''here.
function on_button_drawn_press_event_cb cdecl (_
byval item as GooCanvasItem ptr,_
byval target_item as GooCanvasItem ptr,_
byval event as GdkEventButton ptr,_
byval context as context_ ptr ) As gboolean
context->drag_item = target_item
context->drag_x = event->x
context->drag_y = event->y
g_object_get (G_OBJECT (target_item),_
"x", @context->item_x,_
"y", @context->item_y,_
"width", @context->item_width,_
"height", @context->item_height,_
NIL)
goo_canvas_pointer_grab (GOO_CANVAS(context->canvas), target_item, _
GDK_POINTER_MOTION_MASK or GDK_POINTER_MOTION_HINT_MASK or _
GDK_BUTTON_RELEASE_MASK, NIL, event->time)
return TRUE
end function
function on_button_drawing_press_event_cb cdecl (_
byval item as GooCanvasItem ptr,_
byval target_item as GooCanvasItem ptr,_
byval event as GdkEventButton ptr,_
byval context as context_ ptr ) As gboolean
var list = goo_canvas_get_items_at(GOO_CANVAS(context->canvas),event->x,event->y,FALSE)
if (list <> NIL) then
var item1 = g_list_first(list)
''only deal with items that are part of the drawing group
while (item1 <> NIL)
var parent = goo_canvas_item_get_parent(item1->data)
if (parent = context->drawing) then
context->drag_item = item1->data
context->drag_x = event->x
context->drag_y = event->y
g_object_get (G_OBJECT (item1->data),_
"x", @context->item_x,_
"y", @context->item_y,_
"width", @context->item_width,_
"height", @context->item_height,_
NIL)
goo_canvas_pointer_grab (GOO_CANVAS(context->canvas), item1->data, GDK_POINTER_MOTION_MASK or GDK_POINTER_MOTION_HINT_MASK or _
GDK_BUTTON_RELEASE_MASK, NIL, event->time)
return TRUE
end if
item1 = g_list_next(item1)
wend
g_list_free(list)
end if
return TRUE
end function
function on_button_drawn_release_event_cb cdecl (byval item as GooCanvasItem ptr,_
byval target_item as GooCanvasItem ptr,_
byval event as GdkEventButton ptr,_
byval context as context_ ptr) as gboolean
if (context->drag_item = target_item andalso context->drag_item <> NIL) then
var list = goo_canvas_get_items_at(GOO_CANVAS(context->canvas),event->x,event->y,FALSE)
var ll = g_list_length(list)
if (ll) then
var cur_item = g_list_first(list)
while (cur_item <> NIL)
''do not allow dropping items onto the mould
if (cur_item = context->background) then
goo_canvas_pointer_ungrab (GOO_CANVAS(context->canvas), context->drag_item, event->time)
goo_canvas_item_remove(target_item)
context->drag_item = NIL
g_list_free(list)
return TRUE
end if
cur_item = g_list_next(list)
wend
end if
goo_canvas_pointer_ungrab (GOO_CANVAS(context->canvas), context->drag_item, event->time)
context->drag_item = NIL
return TRUE
end if
return FALSE
end function
function on_button_drawing_release_event_cb cdecl (byval item as GooCanvasItem ptr,_
byval target_item as GooCanvasItem ptr,_
byval event as GdkEventButton ptr,_
byval context as context_ ptr) as gboolean
dim bounding_box1 as goocanvasbounds
dim bounding_box2 as goocanvasbounds
if (context->drag_item = target_item andalso context->drag_item <> NIL) then
var list = goo_canvas_get_items_at(GOO_CANVAS(context->canvas),event->x,event->y,FALSE)
var num_items = g_list_length(list)
if (num_items) then
var cur_item = g_list_first(list)
while (cur_item <> NIL)
''do not allow dropping items onto the mould
if (cur_item->data = context->background) then
goo_canvas_pointer_ungrab (GOO_CANVAS(context->canvas), context->drag_item, event->time)
goo_canvas_item_remove(target_item)
context->drag_item = NIL
g_list_free(list)
return TRUE
end if
cur_item = g_list_next(cur_item)
wend
g_list_free(list)
end if
goo_canvas_pointer_ungrab (GOO_CANVAS(context->canvas), context->drag_item, event->time)
var parent = goo_canvas_item_get_parent(target_item)
''put item in the drawn group so it can be cleared
if (parent <> context->drawn) then
g_object_set(G_OBJECT(target_item),"parent",context->drawn)
end if
context->drag_item = NIL
''redraw items on top of mould
for i as integer = 1 to context->num_items
var drawn_item = context->funs[i](1,context)
next i
''remove items in group drawing that have been drawn on top of an item
''in group drawing. It would be more efficient to just redraw one item (the one
''that changed group).
''get all the items that are member of the group drawing
dim background_area as GooCanvasBounds
goo_canvas_item_get_bounds(context->background,@background_area)
var item_list = goo_canvas_get_items_in_area(GOO_CANVAS(context->canvas),@background_area,TRUE,TRUE,FALSE)
var len_ = g_list_length(item_list)
var next_ = g_list_first(item_list)
redim drawing_list(0 to len_ - 1) as GooCanvasItem ptr
dim ct as integer = 0
while (next_ <> NIL)
var data_ = next_->data
var parent = goo_canvas_item_get_parent(data_)
if (parent = context->drawing) then
drawing_list(ct) = data_
ct += 1
end if
next_ = g_list_next(next_)
wend
redim preserve drawing_list(0 to ct)
''remove item if item was painted on top of an item from the drawing group
dim lb as integer = lbound(drawing_list)
dim ub as integer = ubound(drawing_list)
for ct = lb to ub
goo_canvas_item_get_bounds(drawing_list(ct),@bounding_box1)
for idx as integer = lb to ub
if (idx <> ct) then
goo_canvas_item_get_bounds(drawing_list(idx),@bounding_box2)
if (bounding_box2. x1 = bounding_box1.x1 andalso _
bounding_box2. x2 = bounding_box1.x2 andalso _
bounding_box2. y1 = bounding_box1.y1 andalso _
bounding_box2. y2 = bounding_box1.y2 ) then
''two items in group drawing on top of each other -> drop item
goo_canvas_item_remove(drawing_list(idx))
end if
end if
next idx
next ct
g_list_free(item_list)
return TRUE
end if
return FALSE
end function
function on_motion_drawn_notify_event_cb cdecl (byval item as GooCanvasItem ptr,_
byval target_item as GooCanvasItem ptr,_
byval event as GdkEventMotion ptr,_
byval context as context_ ptr) as gboolean
if (context->drag_item = target_item andalso context->drag_item <> NIL) then
dim rel_x as gdouble = event->x - context->drag_x
dim rel_y as gdouble = event->y - context->drag_y
g_object_set (G_OBJECT (target_item), "x", context->item_x + rel_x, "y", context->item_y + rel_y, NIL)
return TRUE
end if
return FALSE
end function
function on_motion_drawing_notify_event_cb cdecl (byval item as GooCanvasItem ptr,_
byval target_item as GooCanvasItem ptr,_
byval event as GdkEventMotion ptr,_
byval context as context_ ptr) as gboolean
if (context->drag_item = target_item andalso context->drag_item <> NIL) then
dim rel_x as gdouble = event->x - context->drag_x
dim rel_y as gdouble = event->y - context->drag_y
g_object_set (G_OBJECT (target_item), "x", context->item_x + rel_x, "y", context->item_y + rel_y, NIL)
return TRUE
end if
return FALSE
end function
''GTKWidget callbacks (buttons clear, + and -)
function clear_cb cdecl alias "clear_cb"(byval widget as gtkwidget ptr,byval context as context_ ptr) as integer
''remove all the items that are in the drawing
dim x as double
dim y as double
dim scale as double
dim rotation as double
dim item as GooCanvasItem ptr
''remove entire group
goo_canvas_item_get_simple_transform(context->drawn,@x,@y,@scale,@rotation)
var idx = goo_canvas_item_find_child(context->root,context->drawn)
goo_canvas_item_remove_child(context->root,idx)
context->drawn = goo_canvas_group_new(context->root,"x",0.0,"y",0.0,"width",1000.0,"height",1000.0,"line-width",0.5,NIL)
goo_canvas_item_set_simple_transform(context->drawn,x,y,scale,rotation)
return 1
end function
function plus_cb cdecl alias "plus_cb" (byval widget as gtkwidget ptr,byval context as context_ ptr) as integer
dim scale as double
scale = goo_canvas_get_scale(GOO_CANVAS(context->canvas))
goo_canvas_set_scale(GOO_CANVAS(context->canvas),scale+SCALE_STEP)
return 1
end function
function min_cb cdecl alias "min_cb" (byval widget as gtkwidget ptr,byval context as context_ ptr) as integer
''when the scale gets too small the mould gets smaller than the scrolled window
dim scale as double
scale = goo_canvas_get_scale(GOO_CANVAS(context->canvas))
goo_canvas_set_scale(GOO_CANVAS(context->canvas),scale-SCALE_STEP)
return 1
end function
function create_mould(byval context as context_ ptr) as integer
dim item as GooCanvasItem ptr
for i as integer = 0 to context->num_items
var item = context->funs[i](0,context)
next i
for i as integer = 1 to context->num_items
item = context->funs[i](1,context)
next i
return 1
end function
function create_background(byval opt as integer, byval context as context_ ptr) as GooCanvasItem ptr
dim item as GooCanvasItem ptr
dim scale as gdouble
dim x as gdouble
dim y as gdouble
''draw mould background(no callbacks needed)
if (opt = 0) then
item = goo_canvas_rect_new(context->background,0,0,200,1000,"fill-color","lightgray",NIL)
return item
end if
return NIL
end function
function create_lrect(byval opt as integer, byval context as context_ ptr) as GooCanvasItem ptr
dim item as GooCanvasItem ptr
''draw mould item (no callbacks needed)
if (opt = 0) then
item = goo_canvas_rect_new(context->mould,50,30,80,15,"fill-color-rgba",&h9999,NIL)
return item
end if
item = goo_canvas_rect_new(context->drawn,50,30,80,15,"fill-color-rgba",&h9999,NIL)
return item
end function
function create_cube(byval opt as integer, byval context as context_ ptr) as GooCanvasItem ptr
dim item as GooCanvasItem ptr
if (opt = 0) then
item = goo_canvas_rect_new(context->mould,70,50,40,40,"fill-color","yellow",NIL)
return item
end if
item = goo_canvas_rect_new(context->drawing,70,50,40,40,"fill-color","yellow",NIL)
goo_canvas_item_raise(item,NIL)
return item
end function
function create_window(byval opt as integer, byval context as context_ ptr) as GooCanvasItem ptr
dim item as GooCanvasItem ptr
if (opt = 0) then
item = goo_canvas_rect_new(context->mould,90.0,95.0,12,15,"fill-color","lightblue",NIL)
return item
end if
item = goo_canvas_rect_new(context->drawing,90.0,95.0,12,15,"fill-color","lightblue",NIL)
goo_canvas_item_raise(item,NIL)
return item
end function
function create_door(byval opt as integer, byval context as context_ ptr) as GooCanvasItem ptr
dim item as GooCanvasItem ptr
if (opt = 0) then
item = goo_canvas_rect_new(context->mould,125,55,12,30,"fill-color","brown",NIL)
return item
end if
item = goo_canvas_rect_new(context->drawing,125,55,12,30,"fill-color","brown",NIL)
''setup_dnd_handlers(canvas,item)
goo_canvas_item_raise(item,NIL)
return item
end function
function create_roof(byval opt as integer, byval context as context_ ptr) as GooCanvasItem ptr
dim item as GooCanvasItem ptr
if (opt = 0) then
item = goo_canvas_polyline_new(context->mould,TRUE,4,40.0,125.0,60.0,100.0,80.0,125.0,40.0,125.0,"fill-color","red",NIL)
return item
end if
item = goo_canvas_polyline_new(context->drawing,TRUE,4,40.0,125.0,60.0,100.0,80.0,125.0,40.0,125.0,"fill-color","red",NIL)
goo_canvas_item_raise(item,NIL)
return item
end function
function create_flag(byval opt as integer, byval context as context_ ptr) as GooCanvasItem ptr
dim item as GooCanvasItem ptr
if (opt = 0) then
item = goo_canvas_polyline_new(context->mould,TRUE,7,50.0,50.0,65.0,52.0,65.0,64.0,52.0,62.0,52.0,90.0,50.0,90.0,50.0,50.0,"fill-color","blue",NIL)
''g_object_set (G_OBJECT (item), "x", 15, "y", 40, NIL)
return item
end if
item = goo_canvas_polyline_new(context->drawing,TRUE,7,50.0,50.0,65.0,52.0,65.0,64.0,52.0,62.0,52.0,90.0,50.0,90.0,50.0,50.0,"fill-color","blue",NIL)
goo_canvas_item_raise(item,NIL)
return item
end function
function create_slope(byval opt as integer, byval context as context_ ptr) as GooCanvasItem ptr
dim item as GooCanvasItem ptr
if (opt = 0) then
item = goo_canvas_polyline_new(context->mould,TRUE,4,50.0,145.0,120.0,110.0,120.0,145.0,50.0,145.0,"fill-color","green",NIL)
return item
end if
item = goo_canvas_polyline_new(context->drawing,TRUE,4,50.0,145.0,120.0,110.0,120.0,145.0,50.0,145.0,"fill-color","green",NIL)
goo_canvas_item_raise(item,NIL)
return item
end function
function create_arch(byval opt as integer, byval context as context_ ptr) as GooCanvasItem ptr
dim item as GooCanvasItem ptr
if (opt = 0) then
item = goo_canvas_polyline_new(context->mould,TRUE,10,_
70.0,155.0,_
100.0,155.0,_
100.0,185.0,_
95.0,185.0,_
95.0,165.0,_
85.0,160.0,_
75.0,165.0,_
75.0,185.0,_
70.0,185.0,_
70.0,155.0,"fill-color","orange",NIL)
''g_object_set (G_OBJECT (item), "x", 50, "y", 135, NIL)
return item
end if
item = goo_canvas_polyline_new(context->drawing,TRUE,10,_
70.0,155.0,_
100.0,155.0,_
100.0,185.0,_
95.0,185.0,_
95.0,165.0,_
85.0,160.0,_
75.0,165.0,_
75.0,185.0,_
70.0,185.0,_
70.0,155.0,"fill-color","orange",NIL)
goo_canvas_item_raise(item,NIL)
return item
end function
function create_man(byval opt as integer, byval context as context_ ptr) as GooCanvasItem ptr
dim item as GooCanvasItem ptr
if (opt = 0) then
item = goo_canvas_polyline_new(context->mould,TRUE,22,_
/' 1 '/ 109.0, 172.0,_
/' 2 '/ 116.4, 167.0,_
/' 3 '/ 118.6, 167.0,_
/' 4 '/ 117.6, 163.6,_
/' 5 '/ 119.6, 160.6,_
/' 6 '/ 122.8, 160.4,_
/' 7 '/ 124.4, 163.8,_
/' 8 '/ 123.4, 167.2,_
/' 9 '/ 125.4, 167.4,_
/' 10 '/ 130.4, 174.0,_
/' 11 '/ 128.6, 175.0,_
/' 12 '/ 123.6, 169.4,_
/' 13 '/ 123.6, 174.4,_
/' 14 '/ 125.2, 182.0,_
/' 15 '/ 122.0, 182.0,_
/' 16 '/ 120.0, 174.4,_
/' 17 '/ 117.6, 182.0,_
/' 18 '/ 114.4, 182.0,_
/' 19 '/ 116.4, 174.4,_
/' 20 '/ 116.6, 169.8,_
/' 21 '/ 110.4, 174.0,_
/' 22 '/ 109.0, 172.0,"fill-color","bisque",NIL)
''g_object_set (G_OBJECT (item), "x", 85, "y", 135, NIL)
return item
end if
item = goo_canvas_polyline_new(context->drawing,TRUE,22,_
/' 1 '/ 109.0, 172.0,_
/' 2 '/ 116.4, 167.0,_
/' 3 '/ 118.6, 167.0,_
/' 4 '/ 117.6, 163.6,_
/' 5 '/ 119.6, 160.6,_
/' 6 '/ 122.8, 160.4,_
/' 7 '/ 124.4, 163.8,_
/' 8 '/ 123.4, 167.2,_
/' 9 '/ 125.4, 167.4,_
/' 10 '/ 130.4, 174.0,_
/' 11 '/ 128.6, 175.0,_
/' 12 '/ 123.6, 169.4,_
/' 13 '/ 123.6, 174.4,_
/' 14 '/ 125.2, 182.0,_
/' 15 '/ 122.0, 182.0,_
/' 16 '/ 120.0, 174.4,_
/' 17 '/ 117.6, 182.0,_
/' 18 '/ 114.4, 182.0,_
/' 19 '/ 116.4, 174.4,_
/' 20 '/ 116.6, 169.8,_
/' 21 '/ 110.4, 174.0,_
/' 22 '/ 109.0, 172.0,"fill-color","bisque",NIL)
goo_canvas_item_raise(item,NIL)
return item
end function
function create_woman(byval opt as integer, byval context as context_ ptr) as GooCanvasItem ptr
dim item as GooCanvasItem ptr
if (opt = 0) then
item = goo_canvas_polyline_new(context->mould,TRUE,22,_
/' 1 '/ 39.0,172.0,_
/' 2 '/ 46.4,167.0,_
/' 3 '/ 48.6,167.0,_
/' 4 '/ 47.6,163.6,_
/' 5 '/ 49.6,160.6,_
/' 6 '/ 52.8,160.4,_
/' 7 '/ 54.4,163.8,_
/' 8 '/ 53.4,167.2,_
/' 9 '/ 55.4,167.4,_
/' 10 '/ 60.4,174.0,_
/' 11 '/ 58.6,175.0,_
/' 12 '/ 53.6,169.4,_
/' 13 '/ 53.6,174.4,_
/' 14 '/ 55.2,182.0,_
/' 15 '/ 52.0,182.0,_
/' 16 '/ 49.0,182.0,_
/' 17 '/ 47.6,182.0,_
/' 18 '/ 44.4,182.0,_
/' 19 '/ 46.4,174.4,_
/' 20 '/ 46.6,169.8,_
/' 21 '/ 40.4,174.0,_
/' 22 '/ 39.0,172.0,"fill-color","purple",NIL)
return item
end if
item = goo_canvas_polyline_new(context->drawing,TRUE,22,_
/' 1 '/ 39.0,172.0,_
/' 2 '/ 46.4,167.0,_
/' 3 '/ 48.6,167.0,_
/' 4 '/ 47.6,163.6,_
/' 5 '/ 49.6,160.6,_
/' 6 '/ 52.8,160.4,_
/' 7 '/ 54.4,163.8,_
/' 8 '/ 53.4,167.2,_
/' 9 '/ 55.4,167.4,_
/' 10 '/ 60.4,174.0,_
/' 11 '/ 58.6,175.0,_
/' 12 '/ 53.6,169.4,_
/' 13 '/ 53.6,174.4,_
/' 14 '/ 55.2,182.0,_
/' 15 '/ 52.0,182.0,_
/' 16 '/ 49.0,182.0,_
/' 17 '/ 47.6,182.0,_
/' 18 '/ 44.4,182.0,_
/' 19 '/ 46.4,174.4,_
/' 20 '/ 46.6,169.8,_
/' 21 '/ 40.4,174.0,_
/' 22 '/ 39.0,172.0,"fill-color","purple",NIL)
goo_canvas_item_raise(item,NIL)
return item
end function
function create_wheel(byval opt as integer, byval context as context_ ptr) as GooCanvasItem ptr
dim item as GooCanvasItem ptr
if (opt = 0) then
item = goo_canvas_ellipse_new(context->mould,52,210,8,8,"fill-color","black",NIL)
return item
end if
item = goo_canvas_ellipse_new(context->drawing,52,210,8,8,"fill-color","black",NIL)
goo_canvas_item_raise(item,NIL)
return item
end function
function create_bush(byval opt as integer, byval context as context_ ptr) as GooCanvasItem ptr
dim item as GooCanvasItem ptr
if (opt = 0) then
item = goo_canvas_ellipse_new(context->mould,88,210,15,15,"fill-color","darkgreen","line-width",1,"stroke-color-rgba",0,NIL)
return item
end if
item = goo_canvas_ellipse_new(context->drawing,88,210,15,15,"fill-color","darkgreen","line-width",1,"stroke-color-rgba",0,NIL)
goo_canvas_item_raise(item,NIL)
return item
end function
sub my_main(byval argc as integer,byval argv as zstring ptr ptr)
gtk_init (@argc,@argv)
dim context as context_ ptr = callocate(1,sizeof(context_))
dim funs(0 to ...) as item_function => _
{_
@create_background,@create_lrect,@create_cube,@create_door,_
@create_roof,@create_slope,@create_flag,_
@create_arch,@create_man,@create_woman,_
@create_wheel,@create_bush,@create_window _
}
' Create the window and widgets.
var win = gtk_window_new (GTK_WINDOW_TOPLEVEL)
gtk_window_set_default_size (GTK_WINDOW (win), 640, 600)
gtk_widget_show (win)
g_signal_connect (win, "delete_event", G_CALLBACK(@gtk_main_quit), NIL)
var scrolled_win = gtk_scrolled_window_new (NIL, NIL)
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win), _
GTK_SHADOW_IN)
gtk_widget_show (scrolled_win)
var clear_button = gtk_button_new_with_label("C")
gtk_widget_show(clear_button)
var min_button = gtk_button_new_with_label("-")
gtk_widget_show(min_button)
var plus_button = gtk_button_new_with_label("+")
gtk_widget_show(plus_button)
var horizontal_box = gtk_hbox_new(TRUE,1)
gtk_widget_show(horizontal_box)
/' Connect the "clicked" signal of the buttons to callbacks '/
g_signal_connect (clear_button, "clicked",G_CALLBACK (@clear_cb), context)
g_signal_connect (min_button, "clicked",G_CALLBACK (@min_cb), context)
g_signal_connect (plus_button, "clicked",G_CALLBACK (@plus_cb), context)
gtk_container_add(GTK_CONTAINER(horizontal_box),clear_button)
gtk_container_add(GTK_CONTAINER(horizontal_box),min_button)
gtk_container_add(GTK_CONTAINER(horizontal_box),plus_button)
var vertical_box = gtk_vpaned_new()
gtk_widget_show(vertical_box)
gtk_paned_add1(GTK_PANED(vertical_box),horizontal_box)
gtk_paned_add2(GTK_PANED(vertical_box),scrolled_win)
gtk_container_add (GTK_CONTAINER (win), vertical_box)
dim canvas as GtkWidget ptr = goo_canvas_new ()
g_object_set (G_OBJECT (canvas), "integer-layout", TRUE, NULL)
goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 0, Xmax, ymax)
goo_canvas_set_scale(GOO_CANVAS(canvas),1.5)
gtk_widget_show (canvas)
gtk_container_add (GTK_CONTAINER (scrolled_win), canvas)
context->canvas = canvas
dim root as GooCanvasItem ptr = goo_canvas_get_root_item (GOO_CANVAS (canvas))
context->root = root
context->background = goo_canvas_group_new(root,"x",0.0,"y",0.0,"width",1000.0,"height",1000.0,"line-width",0.5,NIL)
context->mould = goo_canvas_group_new(root,"x",0.0,"y",0.0,"width",1000.0,"height",1000.0,"line-width",0.5,NIL)
context->drawing = goo_canvas_group_new(root,"x",0.0,"y",0.0,"width",1000.0,"height",1000.0,"line-width",0.5,NIL)
context->drawn = goo_canvas_group_new(root,"x",0.0,"y",0.0,"width",1000.0,"height",1000.0,"line-width",0.5,NIL)
context->drag_item = NIL
context->funs = @funs(0)
context->num_items = ubound(funs)
g_signal_connect(context->drawn,"button-press-event",G_CALLBACK(@on_button_drawn_press_event_cb),context)
g_signal_connect(context->drawing,"button-press-event",G_CALLBACK(@on_button_drawing_press_event_cb),context)
g_signal_connect(context->drawn,"button-release-event",G_CALLBACK(@on_button_drawn_release_event_cb),context)
g_signal_connect(context->drawing,"button-release-event",G_CALLBACK(@on_button_drawing_release_event_cb),context)
g_signal_connect(context->drawn, "motion-notify-event", G_CALLBACK (@on_motion_drawn_notify_event_cb), context)
g_signal_connect(context->drawing, "motion-notify-event", G_CALLBACK (@on_motion_drawing_notify_event_cb), context)
create_mould(context)
gtk_main()
end sub
my_main(__FB_ARGC__,__FB_ARGV__)