[GB.QT4]
* BUG: Cached DrawingArea Background color now works correctly. [GB.GTK] * BUG: Cached DrawingArea Background color now works correctly. git-svn-id: svn://localhost/gambas/trunk@4339 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
5e93a00359
commit
4a54ecbc8e
9 changed files with 53 additions and 26 deletions
|
@ -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
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <QPixmap>
|
||||
#include <QPainter>
|
||||
#include <QX11Info>
|
||||
#include <QColormap>
|
||||
|
||||
#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
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue