Re: DrawingArea - allocating needed space
- From: "Olexiy Avramchenko" <aolexiy gmail com>
- To: "Piotr Zurek" <p zurek gmail com>
- Cc: gtk-sharp-list lists ximian com, gtk-list gnome org
- Subject: Re: DrawingArea - allocating needed space
- Date: Fri, 10 Nov 2006 10:36:31 +0200
On 11/10/06, Piotr Zurek <p zurek gmail com> wrote:
Hi there,
First of all, sorry for crossposting, but slowly losing hope for getting
any answer from gtk-sharp-list. Maybe someone will prove me wrong...
Anyway, I need a word of advice on using DrawingArea.
In my application the user is supposed to draw all elements in all
directions around one central element. Let's say that I start with an
empty drawing and I draw the first element in the center of the area
allocated for the my drawing. The application automatically places all
elements so that they do not overlap. Sooner or later the user hits a
point where the allocated area is not enough. I have to allocate some
more space. It's not a problem if it grows to the right or down - I can
use SetSizeRequest to grow it. But what if it has to grow to the left or
up? Do I have to move the the central element from the initial position
evey time I need to make some more space for elements above or on the
left? I think I could probably do it that way but maybe somehow I can
use the SizeAllocate (or something else) and use negative values for my
drawing coordiantes?
I hope I described it clear enough but if not, please let me know.
Hello, Piotr
You may use gtk_window_set_gravity() for the top window to control the
way it resizes on size changes (see attached sample). But I'm not sure
whether it is the right way for the portable application.
Have you looked over GtkLayout container for such purposes? I think it
will be better suitable for your task.
Olexiy
#include <gtk/gtk.h>
static gboolean
resizer(GtkWidget *area)
{
gtk_widget_set_size_request(area, 300,400);
return FALSE;
}
int
main(int argc, char **argv)
{
GtkWidget *window, *area;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(window, "delete-event", G_CALLBACK(gtk_main_quit), NULL);
area = gtk_drawing_area_new();
gtk_container_add(GTK_CONTAINER(window), area);
gtk_widget_show_all(window);
gtk_window_set_gravity(GTK_WINDOW(window), GDK_GRAVITY_SOUTH_EAST);
gtk_window_move(GTK_WINDOW(window), 300,400);
g_timeout_add(1000, (GSourceFunc)resizer, area);
gtk_main();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]