[gtkada] Canvas Item Record

Clark, G L g.l.clark at lmco.com
Mon Feb 25 21:48:10 CET 2002


This is an addition the original message below:

  I figured out that the Set_Screen_Size(height_width) marks out the
rectangle used for grabbing a canvas item.
  This is the problem:
   
   Item3 := new Display_Alphanumeric_Record;  -->Canvas_Item_Record
   Item3.Text := "THISISATEST!";
   Item3.Font := Test_Font;                   -->Get_GdkFont("Courier", 12);
   Item3.Num  := 3;
   Set_Screen_Size(Item3, Text_Width(Item3.Font, Item3.Text), 
                          Text_Height(Item3.Font, Item3.Text));

   Put(Item3, Window1.Canvas1);

  Because the X,Y coord of the text is the left edge and the base line this
allows me to grab an area the same size as the text only just below the text
on the canvas:

  THISISATEST  <-Text on Canvas
  |_________| <-Grab area

   
    So, in the draw procedure if we add the text height to the Y coordinate
that everything will work fine.   
   

   procedure Draw (Item : access Display_Alphanumeric_Record;
                   Canvas : access Interactive_Canvas_Record'Class;
                   Dest : Gdk.Pixmap.Gdk_Pixmap;
                   Xdest, Ydest : Gint)
   is
      T : constant String := Item.Text;
      F : constant Gdk_Font := Item.Font;
   begin
      Draw_Text
      (Drawable   => Dest,
       Font       => F,
       Gc         => Window1.Green_GC,
       X          => Xdest,
       Y          => (Ydest + Text_Height(F, T)),   <-Magic happens here
       Text       => T);

    I guess this would be a good example of how talking through a problem by
yourself can lead to a solution.  Thanks anyway!

    -George


  The answer the original question is that I was missing the grab area with
the mouse and therefore couldn't drag the pixmap.
   

-----Original Message-----
From: Clark, G L [mailto:g.l.clark at lmco.com]
Sent: Monday, February 25, 2002 1:45 PM
To: 'gtkada at lists.act-europe.fr'
Subject: [gtkada] Canvas Item Record


Hello All,

    I'm wondering if the functionality I'm getting with the canvas widget is
the expected functionality:

    I have several types of canvas_item_records,  an arc, a rectangle, and
an alphanumeric.  They each are derived from canvas_iterm_record and each
have an overloaded Draw function.  In each draw function I use methods from
Gtk_Drawable to create the appropriate pixmaps.  'Draw_Rectangle,  Draw_Arc,
Draw_Text.
    I then create an item of each type and 'Put' them onto the Canvas.  As
expected a can drag around the rectangle pixmap and the Arc pixmap.
However, I can't drag around the Text on the Canvas.  Is this expected
behavior or am I doing something wrong?

   I think this post is appropriate for this group because of differences
between the Gnome Canvas widget and the one provided with GtkAda.

    Thanks,
       George Clark


_______________________________________________
gtkada mailing list
gtkada at lists.act-europe.fr
http://lists.act-europe.fr/mailman/listinfo/gtkada




More information about the gtkada mailing list