Re: GtkDrawingArea size
- From: Guenther Wutz <guenther wutz stud hs-regensburg de>
- To: <gtk-app-devel-list gnome org>
- Subject: Re: GtkDrawingArea size
- Date: Fri, 09 Mar 2012 19:52:49 -0000
Hey
if you use Gtk+-3.0 you can use
GtkWindow* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_resizable(window, FALSE);
This should prevent the resizing and disables the grip.
--
Günther Wutz
Student der University of Applied Science
Allgemeine Informatik
Am Donnerstag, den 08.03.2012, 17:25 -0900 schrieb Christopher Howard:
On 03/08/2012 01:54 AM, Tadej Borovšak wrote:
Hello.
2012/3/7 Christopher Howard <christopher howard frigidcode com>:
Hello again. So, I recently started a project to create a certain board
game (in C) using gtk+, and I just started learning gtk+. I was planning
to draw the board graphics, pieces, etc. all into one GtkDrawingArea.
So, how do I fix the size of the drawing area so it doesn't get larger
or smaller than my graphics?
I would add a wrapper GtkAlignment around my drawing area, set it's
xalign and yalign propertes to 0.5, it's xscale and yscale to 0, pack
GtkDrawingArea inside it and fix it's size using
gtk_window_set_size_request().
Have a look at this simple app:
#include <gtk/gtk.h>
#define WIDTH 300
#define HEIGHT 400
static gboolean
cb_draw (GtkWidget *w,
GdkEventExpose *e)
{
cairo_t *cr = gdk_cairo_create (e->window);
cairo_set_source_rgb (cr, 1.0, 1.0, 0.0);
cairo_paint (cr);
cairo_destroy (cr);
return TRUE;
}
int
main (int argc,
char **argv)
{
GtkWidget *window,
*align,
*area;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "destroy", gtk_main_quit, NULL);
align = gtk_alignment_new (0.5, 0.5, 0, 0);
gtk_container_add (GTK_CONTAINER (window), align);
area = gtk_drawing_area_new ();
gtk_widget_set_size_request (area, WIDTH, HEIGHT);
g_signal_connect (area, "expose-event", G_CALLBACK (cb_draw), NULL);
gtk_container_add (GTK_CONTAINER (align), area);
gtk_widget_show_all (window);
gtk_main ();
return 0;
}
Cheers,
Tadej
Thanks for the help. Is there a way to turn off the small resizing
graphic that appears at the bottom right of the window? (It looks like
three small diagonal lines.) Even if this did not actually prevent
resizing it would make sense in my case not to have it showing.
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]