From c188e5e00c246f73b30bfa9a806c072117ac7352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Wed, 30 Dec 2009 20:59:27 +0000 Subject: [PATCH] [GB.GTK] * BUG: Fix splitter arrangement again. * OPT: gFont::height() has been cached. git-svn-id: svn://localhost/gambas/trunk@2567 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- gb.gtk/src/cpaint_impl.cpp | 16 ---------------- gb.gtk/src/gfont.cpp | 11 ++++++++--- gb.gtk/src/gfont.h | 1 + gb.gtk/src/gsplitter.cpp | 17 +---------------- 4 files changed, 10 insertions(+), 35 deletions(-) diff --git a/gb.gtk/src/cpaint_impl.cpp b/gb.gtk/src/cpaint_impl.cpp index 6ce871248..4ca2a06c3 100644 --- a/gb.gtk/src/cpaint_impl.cpp +++ b/gb.gtk/src/cpaint_impl.cpp @@ -131,22 +131,6 @@ static int Begin(GB_PAINT *d) } else if (GB.Is(device, CLASS_Image)) { - /*gPicture *picture = CIMAGE_get(((CIMAGE *)device)); - GdkPixbuf *pixbuf; - - if (picture->isVoid()) - { - GB.Error("Bad picture"); - return TRUE; - } - - pixbuf = picture->getPixbuf(); - w = picture->width(); - h = picture->height(); - - target = - cairo_image_surface_create_for_data(picture->data(), CAIRO_FORMAT_ARGB32, w, h, - cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, w));*/ target = check_image(device); cairo_surface_reference(target); w = ((GB_IMG *)device)->width; diff --git a/gb.gtk/src/gfont.cpp b/gb.gtk/src/gfont.cpp index 7b744e5b8..1fb4f0dda 100644 --- a/gb.gtk/src/gfont.cpp +++ b/gb.gtk/src/gfont.cpp @@ -206,6 +206,7 @@ void gFont::reset() void gFont::realize() { ct = NULL; + _height = 0; reset(); @@ -371,6 +372,7 @@ void gFont::setName(char *nm) pango_font_description_set_family (desc,nm); _name_set = true; + _height = 0; } double gFont::size() @@ -396,6 +398,7 @@ void gFont::setSize(double sz) pango_font_description_set_size (desc,(int)(sz*PANGO_SCALE)); _size_set = true; + _height = 0; } void gFont::setGrade(int grade) @@ -474,18 +477,20 @@ int gFont::height(const char *text, int len) int h; if (len == 0 || !text || !*text) text = " "; - + ly=pango_layout_new(ct); pango_layout_set_text(ly,text,len); pango_layout_get_size(ly,NULL,&h); g_object_unref(G_OBJECT(ly)); - + return gt_pango_to_pixel(h); } int gFont::height() { - return height(" ", 1); + if (!_height) + _height = height(" ", 1); + return _height; } bool gFont::scalable() diff --git a/gb.gtk/src/gfont.h b/gb.gtk/src/gfont.h index 0784adcb3..16eb705fd 100644 --- a/gb.gtk/src/gfont.h +++ b/gb.gtk/src/gfont.h @@ -92,6 +92,7 @@ private: bool uline; bool strike; void realize(); + int _height; }; #endif diff --git a/gb.gtk/src/gsplitter.cpp b/gb.gtk/src/gsplitter.cpp index 3b183f1dd..8be2500a6 100644 --- a/gb.gtk/src/gsplitter.cpp +++ b/gb.gtk/src/gsplitter.cpp @@ -25,29 +25,14 @@ #include "gapplication.h" #include "gsplitter.h" -// static gboolean notify_later(gSplitter *data) -// { -// data->performArrange(); -// data->emit(SIGNAL(data->onResize)); -// data->_notify = false; -// return false; -// } - static void cb_notify(GtkPaned *paned, GParamSpec *arg1, gSplitter *data) { - if (!strcmp(arg1->name, "position")) // && !data->_notify) - { - //data->performArrange(); + if (!strcmp(arg1->name, "position")) data->emit(SIGNAL(data->onResize)); - //data->_notify = true; - //g_timeout_add(0, (GSourceFunc)notify_later, data); - } } static void cb_size_allocate(GtkPaned *widget, GtkAllocation *allocation, gSplitter *data) { - //g_debug("gSplitter: cb_size_allocate: %s", data->name()); - //data->performArrange(); data->updateChild(gtk_paned_get_child1(widget)); }