A bug or a screw up?
- From: Chris Moller <moller mollerware com>
- To: gtk-list gnome org
- Subject: A bug or a screw up?
- Date: Wed, 07 May 2014 09:22:48 -0400
I just did a good-size upgrade I'd been putting off for too long that
took me from GTK 3.2 to GTK 3.10.8, and some stuff that used to work
doesn't any more:
Basically, I have a window that contains
a vbox that contans
a label
another label
a drawing area
a third label
The problem is that the top of drawing area is lined up with the top of
the enclosing vbox, or maybe at the top of the window, rather than at
the bottom of the second label.
Is there something new I'm missing? It didn't used to work that way.
Thanks,
Chris Moller
Fedora release 20 (Heisenbug) (Linux qcore.mollernet.net
3.13.10-200.fc20.x86_64 #1 SMP)
GTK+ Version: 3.10.8
A screenshot: http://mollerware.com/example.png
The code showing it:
---------------------------------------------------------------------
#include <gtk/gtk.h>
#define DA_WIDTH 320
#define DA_HEIGHT 240
gboolean
da_draw_cb (GtkWidget *widget, cairo_t *cr, gpointer data)
{
cairo_identity_matrix (cr);
/***
Fill the entire da with a black a rectangle, then overlay the
black rectangle
with a smaller red one.
Notice that that top edge of the da, the top bit of the black
rectangle,
is cut off.
***/
GdkRGBA black = {0.0, 0.0, 0.0, 1.0};
gdk_cairo_set_source_rgba (cr, &black);
cairo_rectangle (cr, 0.0, 0.0, DA_WIDTH, DA_HEIGHT);
cairo_fill (cr);
GdkRGBA red = {1.0, 0.0, 0.0, 1.0};
gdk_cairo_set_source_rgba (cr, &red);
cairo_rectangle (cr, 10.0, 10.0, DA_WIDTH - 20.0, DA_HEIGHT - 20.0);
cairo_fill (cr);
/***
Stroke a green line from the top left corner of the da, [0, 0],
to a central
point [100, 100].
Notice that the top left extent of the line is cut off.
Following what's visible of the line, it appears that the top
left corner of the
da corresponds to the top left corner either of the enclosing
vbox or the
enclosing window rather than to where you'd expect it under label
2. Also
note that label 3 is placed properly ender where the bottom edge
of the
da ought to be.
***/
GdkRGBA green = {0.0, 1.0, 0.0, 1.0};
gdk_cairo_set_source_rgba (cr, &green);
cairo_move_to (cr, 0.0, 0.0);
cairo_line_to (cr, 100.0, 100.0);
cairo_stroke (cr);
return TRUE;
}
int
main (int argc,
char *argv[])
{
GtkWidget *window;
GtkWidget *vbox;
GtkWidget *label;
GtkWidget *da;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_main_quit), NULL);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
gtk_container_add (GTK_CONTAINER (window), vbox);
label = gtk_label_new ("label 1");
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 2);
label = gtk_label_new ("label 2");
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 2);
da = gtk_drawing_area_new ();
gtk_widget_set_size_request (da, DA_WIDTH, DA_HEIGHT);
gtk_box_pack_start (GTK_BOX (vbox), da, TRUE, TRUE, 2);
g_signal_connect (da,"draw", G_CALLBACK (da_draw_cb), NULL);
label = gtk_label_new ("label 3");
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 2);
gtk_widget_show_all (window);
gtk_main ();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]