Unsolved clipping problem
- From: Tintin72 <lucas sanner free fr>
- To: gtk-app-devel-list gnome org
- Subject: Unsolved clipping problem
- Date: Wed, 30 Aug 2006 00:47:57 -0700 (PDT)
Hi,
I'm programming GTK under Windows Xp and I have a clipping problem I just
can't solve.
My application consist in a window with a drawing area wrapped by a
scrolled_window.
So when I move the slider a little fast I get clipping effect on the edges
(up or down) of the drawing area.
Maybe it's the way I handle the drawing area or the way I handle the
scrolled window (or both) that cause this clipping effect ?
To illustrated the pb, I build a simple example where text lines are drawed
in the drawing area.
#include <gtk/gtk.h>
#define WIDTH 500
#define HEIGHT 300
typedef struct APPLICATION
{
GtkWidget *pWin;
GtkWidget *pDrawArea;
GtkWidget *pVBox;
GtkWidget *pScrollBar;
}APPLICATION;
GdkPixmap *pPixmap = NULL;
static gboolean configure_event(GtkWidget *widget, GdkEventConfigure *event)
{
if(pPixmap) g_object_unref(pPixmap);
pPixmap = gdk_pixmap_new(widget->window, widget->allocation.width,
widget->allocation.height, -1);
gdk_draw_rectangle (pPixmap, widget->style->white_gc, TRUE, 0, 0,
widget->allocation.width,
widget->allocation.height);
return TRUE;
}
static gboolean draw_cb(GtkWidget *drawArea, GdkEventExpose *event, gpointer
userData)
{
gdk_draw_drawable(drawArea->window,
drawArea->style->fg_gc[GTK_WIDGET_STATE (drawArea)],
pPixmap, event->area.x,
event->area.y,
event->area.x, event->area.y,
event->area.width,
event->area.height);
PangoContext *pContext = gtk_widget_get_pango_context(drawArea);
PangoLayout *pLayout = pango_layout_new(pContext);
int i;
for(i = 0; i < 30; i++)
{
pango_layout_set_text (pLayout, "Test clipping", 14);
gdk_draw_layout (drawArea->window,
drawArea->style->fg_gc[GTK_WIDGET_STATE(drawArea)],
0,i
* 15, pLayout);
}
g_object_unref(pLayout);
return FALSE;
}
int main (int argc, char *argv[])
{
APPLICATION myApp;
gtk_init(&argc, &argv);
myApp.pWin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size(GTK_WINDOW(myApp.pWin), WIDTH, HEIGHT);
g_signal_connect(G_OBJECT(myApp.pWin), "destroy",
G_CALLBACK(gtk_main_quit), NULL);
myApp.pVBox = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(myApp.pWin), myApp.pVBox);
myApp.pScrollBar = gtk_scrolled_window_new(NULL,NULL);
gtk_box_pack_start(GTK_BOX(myApp.pVBox), myApp.pScrollBar, TRUE, TRUE, 0);
myApp.pDrawArea = gtk_drawing_area_new ();
gtk_box_pack_start(GTK_BOX(myApp.pScrollBar), myApp.pDrawArea, TRUE, TRUE,
0);
gtk_widget_set_size_request (myApp.pDrawArea,
myApp.pWin->allocation.width, 500);
g_signal_connect(G_OBJECT(myApp.pDrawArea),"expose_event",G_CALLBACK(draw_cb),
&myApp);
g_signal_connect(G_OBJECT(myApp.pDrawArea),"configure_event", G_CALLBACK
(configure_event), NULL);
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(myApp.pScrollBar),
myApp.pDrawArea);
gtk_window_set_title(GTK_WINDOW(myApp.pWin), "GTK-Win");
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(myApp.pScrollBar),
GTK_POLICY_NEVER,GTK_POLICY_AUTOMATIC);
gtk_widget_show_all (myApp.pWin);
gtk_main ();
return 0;
}
A guy on a forum compiled my code on his system (Linux probably) and
everything seems ok (no clipping at all).
So I really don't understand.
I builded many applications with different GUIs, and I've never had this
kind of problem.
Is there any incompatibilities between GTK and Windows ?
Can somebody help me ?
Thanks for advance
--
View this message in context: http://www.nabble.com/Unsolved-clipping-problem-tf2188276.html#a6054038
Sent from the Gtk+ - Apps Dev forum at Nabble.com.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]