Re: help on array of widgets



Hi Mj,

On Thu, 28 Jul 2011 10:37:26 +0800 (SGT) you wrote:
> 
> What I had in mind is like GIMP's Layer Dock where, a layer can be added, 
> removed and rearranged. To keep my learning simple, I experimented with Buttons 
> first. What I opted to do is a vector of Buttons, which failed obviously. So 
> with Yann's suggestion, I'm currently using vector of Button pointers instead.
> 
> Do you have any better design in mind?

I'd guess what Chris meant was that you are not really dealing with an
arbitrary vector and cannot make that std::vector instance the
controlling object. If you have a "stack" of buttons on the screen then
you already have to place them in the widget hierarchy, probably as
children of a Gtk::VBox or a Gtk::TreeView or similar. That container
widget is already implementing the storage and marshalling of the
buttons, so any attempt on your part to store and marshal them
independently is a mistake. Instead you should use the container
widget's child access methods to perform any iteration or access you
need. This is particularly true if you are intending to allow
re-ordering, because having multiple lists is just asking for trouble
with getting them out of step.

Cheers,
Rob


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]