diff --git a/app/src/gambas3/.src/Project/ProjectItem.class b/app/src/gambas3/.src/Project/ProjectItem.class index 0f956ce17..573800aa5 100644 --- a/app/src/gambas3/.src/Project/ProjectItem.class +++ b/app/src/gambas3/.src/Project/ProjectItem.class @@ -112,10 +112,10 @@ End Public Sub DrawingArea_Enter() If $bCanHighlight Then - If Me.Background = Color.Default Then + 'If not $bHighlight Then $hDrawingArea.Background = Color.LightBackground $bHighlight = True - Endif + 'Endif Endif End diff --git a/examples/examples/Games/GameOfLife/.settings b/examples/examples/Games/GameOfLife/.settings index 1fa0ce353..38a7ed195 100644 --- a/examples/examples/Games/GameOfLife/.settings +++ b/examples/examples/Games/GameOfLife/.settings @@ -21,7 +21,7 @@ SearchString=True File[1]=".src/FMain.form" File[2]=".src/FMain.class:21.8" Active=3 -File[3]=".src/CGameField.class:17.26" +File[3]=".src/CGameField.class:26.12" Count=3 [Watches] diff --git a/examples/examples/Games/GameOfLife/.src/CGameField.class b/examples/examples/Games/GameOfLife/.src/CGameField.class index 0fde1cf95..2292b0628 100644 --- a/examples/examples/Games/GameOfLife/.src/CGameField.class +++ b/examples/examples/Games/GameOfLife/.src/CGameField.class @@ -24,7 +24,7 @@ Public Function Init(bSmall As Boolean, iLife As Integer, bSymetryH As Boolean, If bSmall Then - size = 7 + size = 9 For i = MaxX \ 2 - size To MaxX \ 2 + size For j = MaxY \ 2 - size To MaxY \ 2 + size diff --git a/gb.gtk/src/gcontrol.cpp b/gb.gtk/src/gcontrol.cpp index cd9d94c22..e140fc3e4 100644 --- a/gb.gtk/src/gcontrol.cpp +++ b/gb.gtk/src/gcontrol.cpp @@ -1459,7 +1459,7 @@ gColor gControl::realBackground() else if (pr) return pr->realBackground(); else - return COLOR_DEFAULT; + return gDesktop::bgColor(); } gColor gControl::background() @@ -1507,7 +1507,7 @@ gColor gControl::realForeground() else if (pr) return pr->realForeground(); else - return COLOR_DEFAULT; + return gDesktop::fgColor(); } gColor gControl::foreground() diff --git a/gb.gtk/src/gdraw.cpp b/gb.gtk/src/gdraw.cpp index 5fe5b3a90..8e9ae5873 100644 --- a/gb.gtk/src/gdraw.cpp +++ b/gb.gtk/src/gdraw.cpp @@ -516,9 +516,7 @@ void gDraw::setForeground(gColor vl) if (vl == COLOR_DEFAULT) vl = _default_fg; - //if ( foreground()==vl) return; - - cmap=gdk_drawable_get_colormap(dr); + cmap = gdk_drawable_get_colormap(dr); fill_gdk_color(&gcol, vl, cmap); gdk_gc_set_foreground(gc, &gcol); @@ -538,9 +536,7 @@ void gDraw::setBackground(gColor vl) if (vl == COLOR_DEFAULT) vl = _default_bg; - //if ( background()==vl) return; - - cmap=gdk_drawable_get_colormap(dr); + cmap = gdk_drawable_get_colormap(dr); fill_gdk_color(&gcol, vl, cmap); gdk_gc_set_background(gc, &gcol); diff --git a/gb.gtk/src/gdrawingarea.cpp b/gb.gtk/src/gdrawingarea.cpp index 5ca6591a0..b08730714 100644 --- a/gb.gtk/src/gdrawingarea.cpp +++ b/gb.gtk/src/gdrawingarea.cpp @@ -183,6 +183,8 @@ void gDrawingArea::resizeCache() GdkPixmap *buf; GdkGC *gc2; GdkWindow *win; + GdkColormap *cmap; + GdkColor gcol; win = GTK_WIDGET(widget)->window; if (!win) @@ -201,7 +203,10 @@ void gDrawingArea::resizeCache() { buf = gdk_pixmap_new(win, w, h, -1); gc2 = gdk_gc_new(buf); - gdk_gc_set_foreground(gc2, &widget->style->bg[GTK_STATE_NORMAL]); + + cmap = gdk_drawable_get_colormap(buf); + fill_gdk_color(&gcol, realBackground(), cmap); + gdk_gc_set_foreground(gc2, &gcol); if (w > bw || h > bh || !buffer) gdk_draw_rectangle(buf, gc2, true, 0, 0, w, h); @@ -217,6 +222,9 @@ void gDrawingArea::resizeCache() buffer = buf; g_object_unref(gc2); } + + drawBorder(buffer); + refreshCache(); } void gDrawingArea::setCache() @@ -262,13 +270,9 @@ void gDrawingArea::clear() if (_cached && buffer) { - gc2=gdk_gc_new(buffer); - gdk_gc_set_foreground(gc2,&widget->style->bg[GTK_STATE_NORMAL]); - gdk_draw_rectangle(buffer,gc2,true,0,0,width(),height()); - g_object_unref(G_OBJECT(gc2)); - drawBorder(buffer); - refreshCache(); - return; + g_object_unref(buffer); + buffer = NULL; + resizeCache(); } } @@ -294,3 +298,8 @@ void gDrawingArea::setNoBackground(bool vl) setBackground(background()); } +void gDrawingArea::setRealBackground(gColor color) +{ + gControl::setRealBackground(color); + clear(); +} diff --git a/gb.gtk/src/gdrawingarea.h b/gb.gtk/src/gdrawingarea.h index 8a5aebaf3..0ef759994 100644 --- a/gb.gtk/src/gdrawingarea.h +++ b/gb.gtk/src/gdrawingarea.h @@ -45,6 +45,7 @@ public: void clear(); virtual void resize(int w, int h); virtual void setEnabled(bool vl); + virtual void setRealBackground(gColor color); //"Events" void (*onExpose)(gDrawingArea *sender,int x,int y,int w,int h); diff --git a/gb.qt4/src/CDrawingArea.cpp b/gb.qt4/src/CDrawingArea.cpp index 2563bd359..2161f9919 100644 --- a/gb.qt4/src/CDrawingArea.cpp +++ b/gb.qt4/src/CDrawingArea.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include "CDraw.h" #include "cpaint_impl.h" @@ -193,14 +194,24 @@ void MyDrawingArea::createBackground(int w, int h) QX11Info xinfo = x11Info(); QPixmap p; Qt::HANDLE old = _background; + GC gc; _background = (Qt::HANDLE)XCreatePixmap(QX11Info::display(), RootWindow(QX11Info::display(), xinfo.screen()), w, h, xinfo.depth()); _background_w = w; _background_h = h; - //qDebug("createBackground: %d x %d : %d -> %08X", w, h, xinfo.depth(), (int)_background); - p = QPixmap::fromX11Pixmap(_background, QPixmap::ExplicitlyShared); - p.fill(palette().color(backgroundRole())); + + //qDebug("createBackground: %d x %d : %d -> %08X / winId = %08X", w, h, xinfo.depth(), (int)_background, (int)winId()); + //p = QPixmap::fromX11Pixmap(_background, QPixmap::ExplicitlyShared); + //qDebug("color = %06X -> %06X", palette().color(backgroundRole()).rgb(), QColormap::instance().pixel((unsigned long)palette().color(backgroundRole()).rgb())); + + gc = XCreateGC(QX11Info::display(), _background, 0, 0); + XSetForeground(QX11Info::display(), gc, QColormap::instance().pixel((unsigned long)palette().color(backgroundRole()).rgb())); + XFillRectangle(QX11Info::display(), _background, gc, 0, 0, w, h); + XFreeGC(QX11Info::display(), gc); + XSetWindowBackgroundPixmap(QX11Info::display(), winId(), _background); + XClearArea(QX11Info::display(), winId(), 0, 0, 0, 0, True); + _cached = true; if (old) @@ -311,7 +322,8 @@ void MyDrawingArea::clearBackground() { if (_cached) createBackground(width(), height()); - XClearArea(QX11Info::display(), winId(), 0, 0, 0, 0, True); + else + XClearArea(QX11Info::display(), winId(), 0, 0, 0, 0, True); } void MyDrawingArea::resizeEvent(QResizeEvent *e) @@ -403,6 +415,8 @@ void MyDrawingArea::setCached(bool c) void MyDrawingArea::setPalette(const QPalette &pal) { + if (_cached) + return; MyContainer::setPalette(pal); repaint(); } @@ -451,7 +465,14 @@ BEGIN_PROPERTY(CDRAWINGAREA_cached) if (READ_PROPERTY) GB.ReturnBoolean(WIDGET->isCached()); else + { + if (THIS->widget.bg == COLOR_DEFAULT) + { + CWIDGET_set_color((CWIDGET *)THIS, THIS->widget.fg, WIDGET->palette().color(WIDGET->backgroundRole()).rgb() & 0xFFFFFF); + WIDGET->clearBackground(); + } WIDGET->setCached(VPROP(GB_BOOLEAN)); + } END_PROPERTY diff --git a/gb.qt4/src/main.cpp b/gb.qt4/src/main.cpp index ffa7f5634..c12900f44 100644 --- a/gb.qt4/src/main.cpp +++ b/gb.qt4/src/main.cpp @@ -700,7 +700,7 @@ static void hook_lang(char *lang, int rtl) //locale = QTextCodec::locale(); } -#if 1 +#if 0 static int (*_old_handler)(Display *d, XErrorEvent *e) = NULL; static int X11_error_handler(Display *d, XErrorEvent *e) @@ -723,7 +723,7 @@ static void hook_main(int *argc, char **argv) QT_Init(); init_lang(GB.System.Language(), GB.System.IsRightToLeft()); - _old_handler = XSetErrorHandler(X11_error_handler); + //_old_handler = XSetErrorHandler(X11_error_handler); }