gambas-source-code/gb.gtk/src/CDrawingArea.cpp

166 lines
3.9 KiB
C++
Raw Normal View History

/***************************************************************************
CDrawingArea.cpp
(c) 2004-2006 - Daniel Campos Fernández <dcamposf@gmail.com>
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.
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.
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.
***************************************************************************/
#define __CDRAWINGAREA_CPP
#include <stdio.h>
#include "main.h"
#include "gambas.h"
#include "widgets.h"
#include "CDraw.h"
#include "cpaint_impl.h"
#include "CDrawingArea.h"
#include "CWidget.h"
#include "CContainer.h"
DECLARE_EVENT(EVENT_draw);
/***************************************************************************
DrawingArea
***************************************************************************/
static void Darea_Expose(gDrawingArea *sender,int x,int y,int w,int h)
{
CWIDGET *_object = GetObject(sender);
//fprintf(stderr, "expose: %d %d %d %d\n", x, y, w, h);
if (GB.CanRaise(THIS, EVENT_draw))
{
if (THIS->painted)
{
PAINT_begin(THIS);
PAINT_clip(x, y, w, h);
GB.Raise(THIS, EVENT_draw, 0);
PAINT_end();
}
else
{
DRAW_begin(THIS);
DRAW_get_current()->setClip(x, y, w, h);
GB.Raise(THIS, EVENT_draw, 0);
DRAW_end();
}
}
}
BEGIN_METHOD(CDRAWINGAREA_new, GB_OBJECT parent)
InitControl(new gDrawingArea(CONTAINER(VARG(parent))), (CWIDGET*)THIS);
WIDGET->onExpose = Darea_Expose;
END_METHOD
BEGIN_PROPERTY(CDRAWINGAREA_border)
if (READ_PROPERTY) { GB.ReturnInteger(WIDGET->getBorder()); return; }
WIDGET->setBorder(VPROP(GB_INTEGER));
END_PROPERTY
/*********************************************************
GTK+ manages the event compression internally,
this function is placed here only for compatibility
with gb.qt
**********************************************************/
BEGIN_PROPERTY(CDRAWINGAREA_merge)
if (READ_PROPERTY) GB.ReturnBoolean(THIS->merge);
else THIS->merge=VPROP(GB_BOOLEAN);
END_PROPERTY
BEGIN_PROPERTY(CDRAWINGAREA_cached)
if (READ_PROPERTY) { GB.ReturnBoolean(WIDGET->cached()); return; }
WIDGET->setCached(VPROP(GB_BOOLEAN));
END_PROPERTY
BEGIN_PROPERTY(CDRAWINGAREA_focus)
if (READ_PROPERTY) { GB.ReturnBoolean(WIDGET->canFocus()); return; }
WIDGET->setCanFocus(VPROP(GB_BOOLEAN));
END_PROPERTY
BEGIN_METHOD_VOID(CDRAWINGAREA_clear)
WIDGET->clear();
END_METHOD
BEGIN_PROPERTY(CDRAWINGAREA_painted)
if (READ_PROPERTY)
GB.ReturnBoolean(THIS->painted);
else
THIS->painted = VPROP(GB_BOOLEAN);
END_PROPERTY
/*BEGIN_PROPERTY(CDRAWINGAREA_transparent)
if (READ_PROPERTY)
GB.ReturnBoolean(WIDGET->isTransparent());
else
WIDGET->setTransparent(VPROP(GB_BOOLEAN));
END_PROPERTY*/
GB_DESC CDrawingAreaDesc[] =
{
GB_DECLARE("DrawingArea", sizeof(CDRAWINGAREA)), GB_INHERITS("Container"),
******** Merged /branches/64bits r918:1003 into /trunk [CONFIGURATION] * NEW: 64 bits port. [EXAMPLES] * BUG: Fixed the AnalogWatch example. [WIKI CGI SCRIPT] * NEW: Some little cosmetic changes. [INTERPRETER] * NEW: The extern function implementation has been redesigned and is now based on libffi, so that it works on 64 bits system. Because of a flaw in the compiler design, projects that use the Pointer datatype must be recompiled to be used on a 64 bits system. This flaw will be fixed in Gambas 3. * OPT: Put some tables into read-only memory. About 1000 bytes are saved for each running interpreter, except the first one. * BUG: Does not crash anymore if a component cannot be loaded. * NEW: Spanish translation updated. * NEW: A new interpreter API for returning a pointer. [COMPILER] * BUG: Correctly compiles LONG constants inside code. [GB.DEBUG] * BUG: Compiles and links the gb.debug components with the thread libraries. [GB.DB.SQLITE3] * BUG: Getting the primary index of a table without primary index is safe now. [GB.GTK] * BUG: Modified the GLib priority of watched descriptors, as the main loop could enter in a loop in which user interface events were not managed. * BUG: Message boxes use application title without crashing now. [GB.OPENGL] * BUG: Disable dead code. [GB.QT.EXT] * BUG: TextEdit.TextWidth and TextEdit.TextHeight were not declared as read-only properties. [GB.XML.XSLT] * BUG: XSLT class is now declared as being not creatable. git-svn-id: svn://localhost/gambas/trunk@1006 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-01-17 21:39:26 +00:00
GB_METHOD("_new", 0, CDRAWINGAREA_new, "(Parent)Container;"),
GB_PROPERTY("Cached", "b", CDRAWINGAREA_cached),
GB_PROPERTY("Border", "i", CDRAWINGAREA_border),
GB_PROPERTY("Merge","b",CDRAWINGAREA_merge),
GB_PROPERTY("Focus","b",CDRAWINGAREA_focus),
GB_PROPERTY("Painted", "b", CDRAWINGAREA_painted),
//GB_PROPERTY("Transparent", "b", CDRAWINGAREA_transparent),
******** Merged /branches/64bits r918:1003 into /trunk [CONFIGURATION] * NEW: 64 bits port. [EXAMPLES] * BUG: Fixed the AnalogWatch example. [WIKI CGI SCRIPT] * NEW: Some little cosmetic changes. [INTERPRETER] * NEW: The extern function implementation has been redesigned and is now based on libffi, so that it works on 64 bits system. Because of a flaw in the compiler design, projects that use the Pointer datatype must be recompiled to be used on a 64 bits system. This flaw will be fixed in Gambas 3. * OPT: Put some tables into read-only memory. About 1000 bytes are saved for each running interpreter, except the first one. * BUG: Does not crash anymore if a component cannot be loaded. * NEW: Spanish translation updated. * NEW: A new interpreter API for returning a pointer. [COMPILER] * BUG: Correctly compiles LONG constants inside code. [GB.DEBUG] * BUG: Compiles and links the gb.debug components with the thread libraries. [GB.DB.SQLITE3] * BUG: Getting the primary index of a table without primary index is safe now. [GB.GTK] * BUG: Modified the GLib priority of watched descriptors, as the main loop could enter in a loop in which user interface events were not managed. * BUG: Message boxes use application title without crashing now. [GB.OPENGL] * BUG: Disable dead code. [GB.QT.EXT] * BUG: TextEdit.TextWidth and TextEdit.TextHeight were not declared as read-only properties. [GB.XML.XSLT] * BUG: XSLT class is now declared as being not creatable. git-svn-id: svn://localhost/gambas/trunk@1006 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-01-17 21:39:26 +00:00
GB_METHOD("Clear", 0, CDRAWINGAREA_clear, 0),
******** Merged /branches/64bits r918:1003 into /trunk [CONFIGURATION] * NEW: 64 bits port. [EXAMPLES] * BUG: Fixed the AnalogWatch example. [WIKI CGI SCRIPT] * NEW: Some little cosmetic changes. [INTERPRETER] * NEW: The extern function implementation has been redesigned and is now based on libffi, so that it works on 64 bits system. Because of a flaw in the compiler design, projects that use the Pointer datatype must be recompiled to be used on a 64 bits system. This flaw will be fixed in Gambas 3. * OPT: Put some tables into read-only memory. About 1000 bytes are saved for each running interpreter, except the first one. * BUG: Does not crash anymore if a component cannot be loaded. * NEW: Spanish translation updated. * NEW: A new interpreter API for returning a pointer. [COMPILER] * BUG: Correctly compiles LONG constants inside code. [GB.DEBUG] * BUG: Compiles and links the gb.debug components with the thread libraries. [GB.DB.SQLITE3] * BUG: Getting the primary index of a table without primary index is safe now. [GB.GTK] * BUG: Modified the GLib priority of watched descriptors, as the main loop could enter in a loop in which user interface events were not managed. * BUG: Message boxes use application title without crashing now. [GB.OPENGL] * BUG: Disable dead code. [GB.QT.EXT] * BUG: TextEdit.TextWidth and TextEdit.TextHeight were not declared as read-only properties. [GB.XML.XSLT] * BUG: XSLT class is now declared as being not creatable. git-svn-id: svn://localhost/gambas/trunk@1006 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-01-17 21:39:26 +00:00
GB_EVENT("Draw", 0, 0, &EVENT_draw),
GB_INTERFACE("Draw", &DRAW_Interface),
GB_INTERFACE("Paint", &PAINT_Interface),
DRAWINGAREA_DESCRIPTION,
GB_END_DECLARE
};