Re: get size of widget



On 2001.03.17 21:17:15 +0100 Martin Hejna wrote:
> 
> Hi
> 
> is here posibility for getting the size of widget (or at least of the
> whole
> window).
> 
> In fact my problem is that I have 12 buttons (3x4 table) and I am
> changing
> labels. When is label too large buttons resize and some of them don`t fit
> into
> window. I want label gets truncated (it is called clipped I hope). And I
> don`t
> want constant size of buttons (I want buttons get larger when I resize my
> application). I was trying viewport here (with or without scrolledwindow)
> but when I start resizing my window all butons get as large, that labels
> fit
> into buttons and buttons don`t fit into window.
> So size of buttons in % of table/box/window would be also nice (or any
> other
> solution).
> 
> Feel free to send answer to all question. Even if % are nicer solution I
> like
> learning about new things (getting size of widget for example).
> 

During the gtk initialization of the application, each widget will get a
size allocated via a GtkAllocation. This size can be retrieved via:

GtkWidget *widget;
int width = widget->allocation->width;
int height = widget->allocation->height;

Ronald

-- 
---------------------------------------------------.
--   .-.    | Ronald Bultje                        |
--   /V\    | Running: Linux 2.4.2 and OpenBSD 2.8 |
--  // \\   | E-mail : rbultje ronald bitfreak net |
-- /(   )\  | WWW    : http://ronald.bitfreak.net/ |
--  ^^-^^   |    *** Warning: Unix Addicted ***    |
---------------------------------------------------'





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