GooCanvas: header for advanced GTK drawing widget

External libraries (GTK, GSL, SDL, Allegro, OpenGL, etc) questions.
TJF
Posts: 3503
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Postby TJF » Sep 23, 2011 18:11

vladimir777 wrote:There is a confusion (at least for me as beginer in GTK) with versions.

I start with version 2, then I switched to 3, and now because of goocanvas I am back to version 2.

I am not using GTK in any real project now, just learning
and I will use both for now.

The most recept version is 3.1.??? and GTK-3 is out since March 2011. But it's not full usable jet. Still some bugs on windows. Did you try GtkToolButtonBar with GtkStockItems on windows? And, most important, no windows installer yet.

That's why I carefully migrate my projects to GTK-3 and replace all deprecated features, but still ship them with GTK 2.22 (ie GladeToBac is compiled against GTK-2.16 to reduce trouble for users with old GTK installations).

For me the main advantage of GTK-3 is the full Cairo integration. But with GooCanvas you'll have similar features and even more. So no reason for GTK-3 ATM (until you need double pointer support).

vladimir777 wrote:... and by the way TJF why I can not flip axes so zero is in lower left corner

You can flip axes: scale them by -1.0 .
vladimir777
Posts: 94
Joined: Aug 19, 2011 18:28

Postby vladimir777 » Sep 23, 2011 19:29

GtkToolButtonBar works fine with gtk3:

Code: Select all

#LIBPATH "C:\opt\GTK-3.0.9\lib"
#include once "c:\opt\gtk3inc\tjf\gtk.bi"

sub undo_redo cdecl(byval widget as GtkWidget ptr,  byval item as gpointer)

  static count as integer = 2
  dim name1 as string
  name1 = *gtk_widget_get_name(widget)

  print name1

  if (name1 = "undo")  Then
    count=count+1
   else
    count=count-1
  end if
 
  if (count < 0) then
     gtk_widget_set_sensitive(widget, FALSE)
     gtk_widget_set_sensitive(item, TRUE)
  end if

  if (count > 5) then
     gtk_widget_set_sensitive(widget, FALSE)
     gtk_widget_set_sensitive(item, TRUE)
  end if
 
end sub


dim as GtkWidget ptr win
dim as GtkWidget ptr vbox
dim as GtkWidget ptr toolbar
dim as GtkToolItem  ptr undo1
dim as GtkToolItem  ptr redo1
dim as GtkToolItem  ptr sep
dim as GtkToolItem  ptr exit1
 
gtk_init(@__FB_ARGC__, @__FB_ARGV__)

  win = gtk_window_new(GTK_WINDOW_TOPLEVEL)
  gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_CENTER)
  gtk_window_set_default_size(GTK_WINDOW(win), 250, 200)
  gtk_window_set_title(GTK_WINDOW(win), "undoredo")

  vbox = gtk_vbox_new(FALSE, 0)
  gtk_container_add(GTK_CONTAINER(win), vbox)


  toolbar = gtk_toolbar_new()
  gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS)

  gtk_container_set_border_width(GTK_CONTAINER(toolbar), 2)

  undo1 = gtk_tool_button_new_from_stock(GTK_STOCK_UNDO)
  gtk_widget_set_name(GTK_WIDGET(undo1), "undo1")
  gtk_toolbar_insert(GTK_TOOLBAR(toolbar), undo1, -1)

  redo1 = gtk_tool_button_new_from_stock(GTK_STOCK_REDO)
  gtk_toolbar_insert(GTK_TOOLBAR(toolbar), redo1, -1)

  sep = gtk_separator_tool_item_new()
  gtk_toolbar_insert(GTK_TOOLBAR(toolbar), sep, -1)

  exit1 = gtk_tool_button_new_from_stock(GTK_STOCK_QUIT)
  gtk_toolbar_insert(GTK_TOOLBAR(toolbar), exit1, -1)

  gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 5)
  g_signal_connect(G_OBJECT(undo1), "clicked", G_CALLBACK(@undo_redo), redo1)
  g_signal_connect(G_OBJECT(redo1), "clicked", G_CALLBACK(@undo_redo), undo1)
  g_signal_connect(G_OBJECT(exit1), "clicked", G_CALLBACK(@gtk_main_quit), NULL)
  g_signal_connect_swapped(G_OBJECT(win), "destroy",  G_CALLBACK(@gtk_main_quit), NULL)
  gtk_widget_show_all(win)

  gtk_main()
end 0




But I can not scale axis that way. Here is line I try:

goo_canvas_set_scale (GOO_CANVAS (canvas), 1/5)
and it zoom out 5x



goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 0, 1000, 1000)
goo_canvas_set_bounds (GOO_CANVAS (canvas), left, top, right, bottom)



goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 1000, 1000, 0)
THIS DOESNOT WORK for me
TJF
Posts: 3503
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Postby TJF » Sep 24, 2011 8:21

vladimir777 wrote:THIS DOESNOT WORK for me

Obviously we cannot swap the Y-axes by swapping top and bottom 8 (

And goo_canvas_set_scale doesn't work (and it shouldn't). But you can scale only the Y-axes. Try

Code: Select all

VAR canvas = goo_canvas_new ()

VAR root = goo_canvas_get_root_item (GOO_CANVAS (canvas))
goo_canvas_set_bounds (GOO_CANVAS (canvas), left_, bottom, right_, top)
goo_canvas_item_scale(root, 1.0, -1.0)
goo_canvas_item_translate(root, 0.0, -top - bottom)

Return to “Libraries”

Who is online

Users browsing this forum: No registered users and 1 guest