2008-04-24 14:49:12 +02:00
|
|
|
/***************************************************************************
|
|
|
|
|
2009-08-17 12:41:51 +02:00
|
|
|
CDrawingArea.cpp
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2009-08-17 12:41:51 +02:00
|
|
|
(c) 2000-2009 Benoît Minisini <gambas@users.sourceforge.net>
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2009-08-17 12:41:51 +02:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
any later version.
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2009-08-17 12:41:51 +02:00
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2009-08-17 12:41:51 +02:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#define __CDRAWINGAREA_CPP
|
|
|
|
|
2008-05-01 01:08:02 +02:00
|
|
|
#include <QApplication>
|
2008-04-24 14:49:12 +02:00
|
|
|
#include <QPaintEvent>
|
|
|
|
#include <QPixmap>
|
2008-05-01 01:08:02 +02:00
|
|
|
#include <QPainter>
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2009-07-12 23:49:13 +02:00
|
|
|
#include "CDraw.h"
|
2009-12-28 02:19:27 +01:00
|
|
|
#include "cpaint_impl.h"
|
2009-07-12 23:49:13 +02:00
|
|
|
#include "CDrawingArea.h"
|
|
|
|
|
2008-04-24 14:49:12 +02:00
|
|
|
#ifndef NO_X_WINDOW
|
2008-04-29 15:40:55 +02:00
|
|
|
#include <QX11Info>
|
2008-04-24 14:49:12 +02:00
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
DECLARE_EVENT(EVENT_draw);
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
|
2009-01-03 23:24:02 +01:00
|
|
|
class MyDrawingArea
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
2009-09-01 03:14:13 +02:00
|
|
|
MyDrawingArea::MyDrawingArea(QWidget *parent) : MyContainer(parent)
|
2008-04-24 14:49:12 +02:00
|
|
|
{
|
|
|
|
drawn = 0;
|
2010-02-25 13:04:34 +01:00
|
|
|
cache = 0;
|
2009-01-03 23:24:02 +01:00
|
|
|
_background = 0;
|
|
|
|
_frozen = false;
|
|
|
|
_event_mask = 0;
|
2009-12-28 02:19:27 +01:00
|
|
|
_use_paint = false;
|
2010-02-04 17:00:01 +01:00
|
|
|
_set_background = false;
|
2010-02-25 04:27:10 +01:00
|
|
|
_cached = false;
|
|
|
|
|
2009-01-03 23:24:02 +01:00
|
|
|
setMerge(false);
|
|
|
|
setCached(false);
|
|
|
|
setAllowFocus(false);
|
|
|
|
|
2008-04-29 15:40:55 +02:00
|
|
|
setAttribute(Qt::WA_KeyCompression, false);
|
2009-09-24 01:21:08 +02:00
|
|
|
setAttribute(Qt::WA_NativeWindow, true);
|
|
|
|
setAttribute(Qt::WA_DontCreateNativeAncestors, true);
|
2010-02-25 04:27:10 +01:00
|
|
|
|
2008-05-01 01:08:02 +02:00
|
|
|
//setAttribute(Qt::WA_NoSystemBackground, true);
|
2008-04-24 14:49:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MyDrawingArea::~MyDrawingArea()
|
|
|
|
{
|
2009-01-03 23:24:02 +01:00
|
|
|
if (_background)
|
2009-09-01 03:14:13 +02:00
|
|
|
{
|
2009-01-03 23:24:02 +01:00
|
|
|
delete _background;
|
2009-09-01 03:14:13 +02:00
|
|
|
_background = 0;
|
|
|
|
}
|
2008-04-24 14:49:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void MyDrawingArea::setAllowFocus(bool f)
|
|
|
|
{
|
|
|
|
if (f)
|
|
|
|
{
|
2009-01-03 23:24:02 +01:00
|
|
|
setFocusPolicy(Qt::WheelFocus);
|
|
|
|
setAttribute(Qt::WA_InputMethodEnabled, true);
|
2008-04-24 14:49:12 +02:00
|
|
|
}
|
|
|
|
else
|
2008-05-01 01:08:02 +02:00
|
|
|
{
|
2008-04-24 14:49:12 +02:00
|
|
|
setFocusPolicy(Qt::NoFocus);
|
2008-05-01 01:08:02 +02:00
|
|
|
}
|
2008-04-24 14:49:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MyDrawingArea::setMerge(bool m)
|
|
|
|
{
|
2009-01-03 23:24:02 +01:00
|
|
|
_merge = m;
|
|
|
|
/*if (_merge)
|
|
|
|
clearWFlags(Qt::WPaintClever);
|
|
|
|
else
|
|
|
|
setWFlags(Qt::WPaintClever);*/
|
2008-04-24 14:49:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void MyDrawingArea::setFrozen(bool f)
|
|
|
|
{
|
2009-01-03 23:24:02 +01:00
|
|
|
if (f == _frozen)
|
|
|
|
return;
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
#ifndef NO_X_WINDOW
|
2010-01-21 17:46:21 +01:00
|
|
|
XWindowAttributes attr;
|
|
|
|
|
2009-01-03 23:24:02 +01:00
|
|
|
if (f)
|
|
|
|
{
|
|
|
|
//setBackgroundMode(Qt::NoBackground);
|
|
|
|
XGetWindowAttributes(QX11Info::display(), winId(), &attr);
|
|
|
|
_event_mask = attr.your_event_mask;
|
|
|
|
XSelectInput(QX11Info::display(), winId(), ExposureMask);
|
|
|
|
//clearWFlags(Qt::WPaintClever);
|
|
|
|
//qDebug("frozen");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//setBackgroundMode(Qt::PaletteBackground);
|
|
|
|
XSelectInput(QX11Info::display(), winId(), _event_mask);
|
|
|
|
setMerge(_merge);
|
|
|
|
//qDebug("unfrozen");
|
|
|
|
}
|
2008-04-24 14:49:12 +02:00
|
|
|
#endif
|
|
|
|
|
2009-01-03 23:24:02 +01:00
|
|
|
_frozen = f;
|
2008-04-24 14:49:12 +02:00
|
|
|
}
|
|
|
|
|
2010-03-08 03:37:53 +01:00
|
|
|
void MyDrawingArea::redraw(QRect &r, bool frame)
|
|
|
|
{
|
|
|
|
QPainter *p;
|
|
|
|
void *_object = CWidget::getReal(this);
|
|
|
|
|
|
|
|
if (!_object)
|
|
|
|
return;
|
|
|
|
|
|
|
|
//qDebug("paint: %d %d %d %d", event->rect().x(), event->rect().y(), event->rect().width(), event->rect().height());
|
|
|
|
|
|
|
|
if (_use_paint)
|
|
|
|
{
|
|
|
|
PAINT_begin(THIS);
|
|
|
|
p = PAINT_get_current();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DRAW_begin(THIS);
|
|
|
|
p = DRAW_get_current();
|
|
|
|
}
|
|
|
|
|
2010-04-27 23:05:15 +02:00
|
|
|
/*if (!isTransparent())
|
2010-03-08 03:37:53 +01:00
|
|
|
{
|
|
|
|
p->translate(-r.x(), -r.y());
|
2010-04-27 23:05:15 +02:00
|
|
|
}*/
|
2010-03-08 03:37:53 +01:00
|
|
|
|
|
|
|
if (!_use_paint)
|
|
|
|
{
|
|
|
|
//p->setBrushOrigin(-r.x(), -r.y());
|
|
|
|
DRAW_clip(r.x(), r.y(), r.width(), r.height());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
PAINT_clip(r.x(), r.y(), r.width(), r.height());
|
|
|
|
|
|
|
|
//p->setClipRegion(event->region().intersect(contentsRect()));
|
|
|
|
//p->setBrushOrigin(-r.x(), -r.y());
|
|
|
|
|
|
|
|
p->save();
|
|
|
|
|
|
|
|
GB.Raise(THIS, EVENT_draw, 0);
|
|
|
|
|
|
|
|
p->restore();
|
|
|
|
|
|
|
|
if (frame)
|
|
|
|
{
|
|
|
|
p->setRenderHint(QPainter::Antialiasing, false);
|
|
|
|
drawFrame(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_use_paint)
|
|
|
|
PAINT_end();
|
|
|
|
else
|
|
|
|
DRAW_end();
|
|
|
|
}
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
void MyDrawingArea::paintEvent(QPaintEvent *event)
|
|
|
|
{
|
2009-01-03 23:24:02 +01:00
|
|
|
if (_background)
|
|
|
|
{
|
2010-02-04 17:00:01 +01:00
|
|
|
if (_set_background)
|
|
|
|
{
|
|
|
|
XSetWindowBackgroundPixmap(QX11Info::display(), winId(), _background->handle());
|
|
|
|
_set_background = false;
|
|
|
|
}
|
2009-09-24 01:21:08 +02:00
|
|
|
QPainter paint( this );
|
|
|
|
drawFrame(&paint);
|
|
|
|
//MyContainer::paintEvent(event);
|
2009-01-03 23:24:02 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-04-29 14:54:45 +02:00
|
|
|
//QPainter paint( this );
|
2009-01-03 23:24:02 +01:00
|
|
|
QRect r;
|
|
|
|
|
2009-09-01 03:14:13 +02:00
|
|
|
r = event->rect().intersect(rect());
|
2009-01-03 23:24:02 +01:00
|
|
|
if (r.isValid())
|
|
|
|
{
|
2010-04-27 23:05:15 +02:00
|
|
|
/*if (!isTransparent())
|
2010-02-25 13:04:34 +01:00
|
|
|
{
|
|
|
|
cache = new QPixmap(r.width(), r.height());
|
|
|
|
cache->fill(this, r.x(), r.y());
|
2010-04-27 23:05:15 +02:00
|
|
|
}*/
|
2009-07-18 04:30:07 +02:00
|
|
|
|
2010-03-08 03:37:53 +01:00
|
|
|
redraw(r, true);
|
|
|
|
|
2010-04-27 23:05:15 +02:00
|
|
|
/*if (!isTransparent())
|
2010-02-25 13:04:34 +01:00
|
|
|
{
|
|
|
|
paint.drawPixmap(r.x(), r.y(), *cache);
|
|
|
|
delete cache;
|
|
|
|
cache = 0;
|
2010-04-27 23:05:15 +02:00
|
|
|
}*/
|
2009-01-03 23:24:02 +01:00
|
|
|
}
|
|
|
|
}
|
2008-04-24 14:49:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void MyDrawingArea::setBackground()
|
|
|
|
{
|
2009-01-03 23:24:02 +01:00
|
|
|
if (_background)
|
|
|
|
{
|
|
|
|
_background->detach();
|
|
|
|
|
|
|
|
#ifdef NO_X_WINDOW
|
|
|
|
setErasePixmap(*_background);
|
|
|
|
#else
|
2010-02-04 17:00:01 +01:00
|
|
|
//if (isVisible())
|
|
|
|
// XSetWindowBackgroundPixmap(QX11Info::display(), winId(), _background->handle());
|
|
|
|
//else
|
|
|
|
_set_background = true;
|
|
|
|
refreshBackground();
|
2009-01-03 23:24:02 +01:00
|
|
|
#endif
|
|
|
|
}
|
2010-02-04 17:00:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void MyDrawingArea::refreshBackground()
|
|
|
|
{
|
|
|
|
if (_background)
|
2009-01-03 23:24:02 +01:00
|
|
|
{
|
|
|
|
#ifdef NO_X_WINDOW
|
2010-02-04 17:00:01 +01:00
|
|
|
update();
|
2009-01-03 23:24:02 +01:00
|
|
|
#else
|
2010-02-04 17:00:01 +01:00
|
|
|
int fw = frameWidth();
|
|
|
|
if (fw == 0)
|
|
|
|
XClearWindow(QX11Info::display(), winId());
|
|
|
|
else
|
|
|
|
{
|
|
|
|
XClearArea(QX11Info::display(), winId(), fw, fw, 0, 0, False);
|
|
|
|
repaint();
|
|
|
|
}
|
2009-01-03 23:24:02 +01:00
|
|
|
#endif
|
|
|
|
}
|
2008-04-24 14:49:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MyDrawingArea::clearBackground()
|
|
|
|
{
|
2009-01-03 23:24:02 +01:00
|
|
|
if (_background)
|
|
|
|
{
|
|
|
|
QPainter p(_background);
|
2009-09-24 01:21:08 +02:00
|
|
|
p.fillRect(0, 0, _background->width(), _background->height(), palette().color(backgroundRole()));
|
2009-01-03 23:24:02 +01:00
|
|
|
p.end();
|
|
|
|
setBackground();
|
|
|
|
}
|
|
|
|
}
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
void MyDrawingArea::resizeEvent(QResizeEvent *e)
|
|
|
|
{
|
|
|
|
MyContainer::resizeEvent(e);
|
|
|
|
updateBackground();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyDrawingArea::updateBackground()
|
2009-01-03 23:24:02 +01:00
|
|
|
{
|
|
|
|
int wb, hb, w, h;
|
|
|
|
|
|
|
|
if (drawn)
|
|
|
|
{
|
|
|
|
GB.Error("DrawingArea is being drawn");
|
2010-01-11 00:00:31 +01:00
|
|
|
return;
|
2009-01-03 23:24:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (_background)
|
|
|
|
{
|
|
|
|
w = QMAX(width(), 1);
|
|
|
|
h = QMAX(height(), 1);
|
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
if (w != _background->width() && h != _background->height())
|
|
|
|
{
|
|
|
|
QPixmap *p = new QPixmap(w, h);
|
|
|
|
p->fill(palette().color(backgroundRole()));
|
2009-01-03 23:24:02 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
wb = QMIN(w, _background->width());
|
|
|
|
hb = QMIN(h, _background->height());
|
2009-01-03 23:24:02 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
QPainter pt(p);
|
|
|
|
pt.drawPixmap(0, 0, *_background, 0, 0, wb, hb);
|
|
|
|
pt.end();
|
2009-01-03 23:24:02 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
delete _background;
|
|
|
|
_background = p;
|
2010-02-04 17:00:01 +01:00
|
|
|
|
2010-01-11 00:00:31 +01:00
|
|
|
setBackground();
|
|
|
|
}
|
2009-01-03 23:24:02 +01:00
|
|
|
}
|
|
|
|
}
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2010-03-08 03:37:53 +01:00
|
|
|
void MyDrawingArea::setStaticContents(bool on)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-25 04:27:10 +01:00
|
|
|
void MyDrawingArea::updateCache()
|
2009-01-03 23:24:02 +01:00
|
|
|
{
|
|
|
|
if (_background)
|
|
|
|
delete _background;
|
|
|
|
|
2010-04-27 23:05:15 +02:00
|
|
|
if (_cached) // && !_transparent)
|
2009-01-03 23:24:02 +01:00
|
|
|
{
|
|
|
|
_background = new QPixmap(width(), height());
|
2010-02-04 17:00:01 +01:00
|
|
|
clearBackground();
|
|
|
|
|
2009-09-24 01:21:08 +02:00
|
|
|
setAttribute(Qt::WA_PaintOnScreen, true);
|
2010-03-07 02:38:15 +01:00
|
|
|
setAttribute(Qt::WA_OpaquePaintEvent, true);
|
2010-02-04 17:00:01 +01:00
|
|
|
setAttribute(Qt::WA_StaticContents, true);
|
2009-01-03 23:24:02 +01:00
|
|
|
}
|
2010-02-25 04:27:10 +01:00
|
|
|
else //if (_background)
|
2009-01-03 23:24:02 +01:00
|
|
|
{
|
|
|
|
_background = 0;
|
2009-09-24 01:21:08 +02:00
|
|
|
setAttribute(Qt::WA_PaintOnScreen, false);
|
2010-03-07 02:38:15 +01:00
|
|
|
setAttribute(Qt::WA_OpaquePaintEvent, false);
|
2009-09-24 01:21:08 +02:00
|
|
|
setAttribute(Qt::WA_StaticContents, false);
|
2010-02-04 17:00:01 +01:00
|
|
|
#ifdef NO_X_WINDOW
|
|
|
|
setBackgroundMode(Qt::NoBackground);
|
|
|
|
#else
|
|
|
|
XSetWindowBackgroundPixmap(QX11Info::display(), winId(), None);
|
|
|
|
XClearArea(QX11Info::display(), winId(), 0, 0, 0, 0, True);
|
|
|
|
#endif
|
2009-01-03 23:24:02 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-25 04:27:10 +01:00
|
|
|
void MyDrawingArea::setCached(bool c)
|
|
|
|
{
|
|
|
|
_cached = c;
|
|
|
|
updateCache();
|
|
|
|
}
|
|
|
|
|
2009-01-03 23:24:02 +01:00
|
|
|
void MyDrawingArea::setPalette(const QPalette &pal)
|
|
|
|
{
|
2009-09-01 03:14:13 +02:00
|
|
|
MyContainer::setPalette(pal);
|
2009-01-03 23:24:02 +01:00
|
|
|
repaint();
|
|
|
|
}
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2010-04-27 23:05:15 +02:00
|
|
|
/*void MyDrawingArea::setTransparent(bool on)
|
2010-02-25 04:27:10 +01:00
|
|
|
{
|
|
|
|
_transparent = on;
|
|
|
|
updateCache();
|
2010-04-27 23:05:15 +02:00
|
|
|
}*/
|
2010-02-25 04:27:10 +01:00
|
|
|
|
2010-03-08 03:37:53 +01:00
|
|
|
void MyDrawingArea::hideEvent(QHideEvent *e)
|
|
|
|
{
|
|
|
|
if (_background)
|
|
|
|
_set_background = true;
|
|
|
|
MyContainer::hideEvent(e);
|
|
|
|
}
|
2010-02-25 04:27:10 +01:00
|
|
|
|
2008-04-24 14:49:12 +02:00
|
|
|
/***************************************************************************
|
|
|
|
|
2009-01-03 23:24:02 +01:00
|
|
|
DrawingArea
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
BEGIN_METHOD(CDRAWINGAREA_new, GB_OBJECT parent)
|
|
|
|
|
2009-01-03 23:24:02 +01:00
|
|
|
MyDrawingArea *wid = new MyDrawingArea(QCONTAINER(VARG(parent)));
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2009-01-03 23:24:02 +01:00
|
|
|
//THIS->widget.background = QColorGroup::Base;
|
|
|
|
THIS->container = wid;
|
2010-02-25 13:04:34 +01:00
|
|
|
THIS->widget.flag.fillBackground = false;
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2009-01-03 23:24:02 +01:00
|
|
|
CWIDGET_new(wid, (void *)_object);
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(CDRAWINGAREA_cached)
|
|
|
|
|
2009-01-03 23:24:02 +01:00
|
|
|
if (READ_PROPERTY)
|
|
|
|
GB.ReturnBoolean(WIDGET->isCached());
|
|
|
|
else
|
|
|
|
WIDGET->setCached(VPROP(GB_BOOLEAN));
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
|
|
|
|
DECLARE_METHOD(CCONTROL_background);
|
|
|
|
|
|
|
|
|
|
|
|
BEGIN_METHOD_VOID(CDRAWINGAREA_clear)
|
|
|
|
|
2009-01-03 23:24:02 +01:00
|
|
|
WIDGET->clearBackground();
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(CDRAWINGAREA_background)
|
|
|
|
|
2009-01-03 23:24:02 +01:00
|
|
|
CCONTROL_background(_object, _param);
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2009-01-03 23:24:02 +01:00
|
|
|
if (!READ_PROPERTY)
|
|
|
|
WIDGET->clearBackground();
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(CDRAWINGAREA_border)
|
|
|
|
|
2009-09-01 03:14:13 +02:00
|
|
|
CCONTAINER_border(_object, _param);
|
2009-01-03 23:24:02 +01:00
|
|
|
|
|
|
|
if (!READ_PROPERTY)
|
|
|
|
WIDGET->clearBackground();
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(CDRAWINGAREA_enabled)
|
|
|
|
|
2009-01-03 23:24:02 +01:00
|
|
|
CCONTROL_enabled(_object, _param);
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2009-01-03 23:24:02 +01:00
|
|
|
if (!READ_PROPERTY)
|
|
|
|
WIDGET->setFrozen(!VPROP(GB_BOOLEAN));
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(CDRAWINGAREA_merge)
|
|
|
|
|
2009-01-03 23:24:02 +01:00
|
|
|
if (READ_PROPERTY)
|
|
|
|
GB.ReturnBoolean(WIDGET->isMerge());
|
|
|
|
else
|
|
|
|
WIDGET->setMerge(VPROP(GB_BOOLEAN));
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(CDRAWINGAREA_focus)
|
|
|
|
|
2009-01-03 23:24:02 +01:00
|
|
|
if (READ_PROPERTY)
|
|
|
|
GB.ReturnBoolean(WIDGET->isAllowFocus());
|
|
|
|
else
|
|
|
|
WIDGET->setAllowFocus(VPROP(GB_BOOLEAN));
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2009-12-29 02:21:39 +01:00
|
|
|
BEGIN_PROPERTY(CDRAWINGAREA_painted)
|
2009-12-28 02:19:27 +01:00
|
|
|
|
|
|
|
if (READ_PROPERTY)
|
|
|
|
GB.ReturnBoolean(WIDGET->isPaint());
|
|
|
|
else
|
|
|
|
WIDGET->setPaint(VPROP(GB_BOOLEAN));
|
|
|
|
|
|
|
|
END_PROPERTY
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2010-04-27 23:05:15 +02:00
|
|
|
#if 0
|
2010-02-25 04:27:10 +01:00
|
|
|
BEGIN_PROPERTY(CDRAWINGAREA_transparent)
|
|
|
|
|
|
|
|
if (READ_PROPERTY)
|
|
|
|
GB.ReturnBoolean(WIDGET->isTransparent());
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WIDGET->setTransparent(VPROP(GB_BOOLEAN));
|
2010-02-25 13:04:34 +01:00
|
|
|
//THIS->widget.flag.fillBackground = !WIDGET->isTransparent();
|
|
|
|
//CWIDGET_reset_color((CWIDGET *)THIS);
|
2010-02-25 04:27:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
END_PROPERTY
|
2010-04-27 23:05:15 +02:00
|
|
|
#endif
|
2010-02-25 04:27:10 +01:00
|
|
|
|
2010-03-08 03:37:53 +01:00
|
|
|
BEGIN_METHOD(DrawingArea_Refresh, GB_INTEGER x; GB_INTEGER y; GB_INTEGER w; GB_INTEGER h)
|
|
|
|
|
|
|
|
if (WIDGET->isCached())
|
|
|
|
{
|
|
|
|
QRect r;
|
|
|
|
|
|
|
|
if (!MISSING(x) && !MISSING(y))
|
|
|
|
r.setRect(VARG(x), VARG(y), VARGOPT(w, WIDGET->width()), VARGOPT(h, WIDGET->height()));
|
|
|
|
else
|
|
|
|
r.setRect(0, 0, WIDGET->width(), WIDGET->height());
|
|
|
|
|
|
|
|
WIDGET->redraw(r, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
CCONTROL_refresh(_object, _param);
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2008-04-24 14:49:12 +02:00
|
|
|
GB_DESC CDrawingAreaDesc[] =
|
|
|
|
{
|
2009-01-03 23:24:02 +01:00
|
|
|
GB_DECLARE("DrawingArea", sizeof(CDRAWINGAREA)), GB_INHERITS("Container"),
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2009-01-03 23:24:02 +01:00
|
|
|
GB_METHOD("_new", NULL, CDRAWINGAREA_new, "(Parent)Container;"),
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2009-01-03 23:24:02 +01:00
|
|
|
GB_PROPERTY("Cached", "b", CDRAWINGAREA_cached),
|
|
|
|
GB_PROPERTY("Merge", "b", CDRAWINGAREA_merge),
|
|
|
|
|
|
|
|
GB_PROPERTY("Border", "i", CDRAWINGAREA_border),
|
|
|
|
GB_PROPERTY("Background", "i", CDRAWINGAREA_background),
|
|
|
|
|
|
|
|
GB_PROPERTY("Focus", "b", CDRAWINGAREA_focus),
|
|
|
|
GB_PROPERTY("Enabled", "b", CDRAWINGAREA_enabled),
|
2009-12-29 02:21:39 +01:00
|
|
|
GB_PROPERTY("Painted", "b", CDRAWINGAREA_painted),
|
2010-04-27 23:05:15 +02:00
|
|
|
//GB_PROPERTY("Transparent", "b", CDRAWINGAREA_transparent),
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2009-01-03 23:24:02 +01:00
|
|
|
GB_METHOD("Clear", NULL, CDRAWINGAREA_clear, NULL),
|
2010-03-08 03:37:53 +01:00
|
|
|
GB_METHOD("Refresh", NULL, DrawingArea_Refresh, "[(X)i(Y)i(Width)i(Height)i]"),
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2009-01-03 23:24:02 +01:00
|
|
|
GB_EVENT("Draw", NULL, NULL, &EVENT_draw),
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
GB_INTERFACE("Draw", &DRAW_Interface),
|
2009-12-28 02:19:27 +01:00
|
|
|
GB_INTERFACE("Paint", &PAINT_Interface),
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
DRAWINGAREA_DESCRIPTION,
|
|
|
|
|
2009-01-03 23:24:02 +01:00
|
|
|
GB_END_DECLARE
|
2008-04-24 14:49:12 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|