Addressing widgets in a Gtk.Table

View: New views
2 Messages — Rating Filter:   Alert me  

Addressing widgets in a Gtk.Table

by Rick Duley-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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?
 
How do I address individual cells?
All assistance appreciated
--
Rick Duley
North Perth,
Western Australia
http://rickduley.webs.com
                                     .-_|\
                                    /     \
                              perth *_.-._/
                                         v
aussie : 0409 106 049
o'seas : +61 409 106 049
--------------------------------------------
"Wise men profit more from fools
     than fools from wise men;
for the wise shun the mistakes of fools
      but fools do not imitate
                the successes of the wise."
                   Marcus Cato (234-149 BC)

_______________________________________________
gtkada mailing list
gtkada@...
http://lists.adacore.com/mailman/listinfo/gtkada

Re: Addressing widgets in a Gtk.Table

by Dmitry A. Kazakov :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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
_______________________________________________
gtkada mailing list
gtkada@...
http://lists.adacore.com/mailman/listinfo/gtkada