[gtkada] Addressing widgets in a Gtk.Table

Dmitry A. Kazakov mailbox at dmitry-kazakov.de
Mon Jun 29 15:10:22 CEST 2009


On Mon, 29 Jun 2009 20:13:30 +0800, you wrote:

> I am looking for a way to have a cluster of Gtk.Button in some sort of array
> (a keyboard, if you like) where I can address them individually.  I am
> looking at Gtk.Table but I cannot find any procedures which allow me to
> address individual cells of the table.
> 
> Is Table the right container?

Yes it is.

> How do I address individual cells?
> All assistance appreciated

You can enumerate table elements using forall, foreach.

But it is better to index cells in an independent way. E.g. you can extend
Gtk_Table_Record putting an index accelerator in there:

type Button_List is
   array (Positive range <>, Positive range <>)
      of Gtk_Button;
type Gtk_Keyboard_Record (Rows, Columns : Positive) is
   new Gtk_Table_Record is with
record
   Buttons (1..Rows, 1..Columns);
end record;
type Gtk_Keyboard is access all Gtk_Keyboard_Record'Class;

procedure Gtk_New
   (  Widget : in out Gtk_Keyboard;
      Rows, Columns : Positive
   )  is
begin
   Widget := new Gtk_Keyboard_Record (Row, Columns);
   Initialize (Widget.all, Rows, Columns);
end Gtk_New;

procedure Initialize
   (  Widget : access Gtk_Keyboard_Record'Class
      Rows, Columns : Positive
   )  is
begin
   Gtk.Table.Initialize (Widget.all, GInt (Rows), GInt (Columns));
   -- ... Creating buttons and placing them into the table and the index
end;

etc

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



More information about the gtkada mailing list