Re: How to find width of a menubar?



>>I have a menubar in a toolbar item, with buttons on either side. I have no
>> idea how wide this menu will be, and I find if it gets too wide,  first
>> the buttons go into an overflow menu, and then the menubar dissapears
>> altogether.
>>
>> If I knew the width of the menubar, I could modify its contents so
>> everything stays visable.
>>
>> How could I do that? How could I check the width it will be rendered at?
>>
>> -Sud.
>
>you can get the size of a widget by getting the size of its onderlying 
>Gdk::Window.
>
>  int width,height;
>  MyMenubar.get_window()->get_size(width,height);

this is not quite correct as a general solution, because many widgets
render into their parent's window. 

the more general solution is to connect to the allocate signal for the
widget, which is emitted every time GTK recomputes the size that the
widget will be rendered at.

--p



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