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

239 lines
5.1 KiB
C++
Raw Normal View History

/***************************************************************************
CPictureBox.cpp
(c) 2004-2006 - Daniel Campos Fernández <dcamposf@gmail.com>
GTK+ component
Realizado para la Junta de Extremadura.
Consejería de Educación Ciencia y Tecnología.
Proyecto gnuLinEx
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 1, 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 __CPICTUREBOX_CPP
#include "main.h"
#include "gambas.h"
#include "widgets.h"
#include "CPictureBox.h"
#include "CPicture.h"
#include "CContainer.h"
#include <string.h>
/**********************************************************************************
PictureBox
***********************************************************************************/
GB_CLASS CPICTURE_Class;
BEGIN_METHOD_VOID (CPICTUREBOX_init)
CPICTURE_Class=GB.FindClass("Picture");
END_METHOD
BEGIN_METHOD(CPICTUREBOX_new, GB_OBJECT parent)
CCONTAINER *Parent=(CCONTAINER*)VPROP(GB_OBJECT);
Parent=(CCONTAINER*)GetContainer ((CWIDGET*)Parent);
THIS->widget=new gPictureBox(Parent->widget);
InitControl(THIS->widget,(CWIDGET*)THIS);
END_METHOD
BEGIN_METHOD_VOID(CPICTUREBOX_free)
if (THIS->picture) { GB.Unref((void**)&THIS->picture); THIS->picture=NULL; }
END_METHOD
BEGIN_PROPERTY(CPICTUREBOX_picture)
CPICTURE *pic=NULL;
gPicture *buf;
if (READ_PROPERTY)
{
GB.ReturnObject(THIS->picture);
return;
}
pic=(CPICTURE*)VPROP(GB_OBJECT);
if (pic) GB.Ref((void*)pic);
if (THIS->picture) GB.Unref((void**)&THIS->picture);
THIS->picture=pic;
if (!pic) PBOX->setPicture(NULL);
else PBOX->setPicture(pic->picture);
END_PROPERTY
BEGIN_PROPERTY(CPICTUREBOX_stretch)
if (READ_PROPERTY) { GB.ReturnBoolean(PBOX->stretch()); return; }
PBOX->setStretch(VPROP(GB_INTEGER));
END_PROPERTY
BEGIN_PROPERTY(CPICTUREBOX_alignment)
if (READ_PROPERTY) { GB.ReturnInteger(PBOX->alignment()); return; }
PBOX->setAlignment(VPROP(GB_INTEGER));
END_PROPERTY
BEGIN_PROPERTY(CPICTUREBOX_border)
if (READ_PROPERTY) { GB.ReturnInteger(PBOX->getBorder()); return; }
PBOX->setBorder(VPROP(GB_INTEGER));
END_PROPERTY
/**********************************************************************************
MovieBox
***********************************************************************************/
BEGIN_METHOD(CMOVIEBOX_new, GB_OBJECT parent)
CCONTAINER *Parent=(CCONTAINER*)VPROP(GB_OBJECT);
Parent=(CCONTAINER*)GetContainer ((CWIDGET*)Parent);
MTHIS->widget=new gMovieBox(Parent->widget);
InitControl(MTHIS->widget,(CWIDGET*)MTHIS);
END_METHOD
BEGIN_METHOD_VOID(CMOVIEBOX_free)
******** 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
if (MTHIS->path) GB.Free(POINTER(&MTHIS->path));
END_METHOD
BEGIN_PROPERTY(CMOVIEBOX_border)
if (READ_PROPERTY) { GB.ReturnInteger(MBOX->getBorder()); return; }
MBOX->setBorder(VPROP(GB_INTEGER));
END_PROPERTY
BEGIN_PROPERTY(CMOVIEBOX_path)
char *addr;
char *name;
int len;
if (READ_PROPERTY)
{
GB.ReturnNewString(MTHIS->path,0);
return;
}
name=GB.ToZeroString(PROP(GB_STRING));
if (GB.LoadFile (name,strlen(name),&addr,&len))
{
GB.Error("File or directory does not exist");
return;
}
******** 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
if (MTHIS->path) { GB.Free(POINTER(&MTHIS->path)); MTHIS->path=NULL; }
GB.Alloc(POINTER(&MTHIS->path),strlen(name)+1);
strcpy(MTHIS->path,name);
MBOX->loadMovie(addr,len);
GB.ReleaseFile (&addr,len);
END_PROPERTY
BEGIN_PROPERTY(CMOVIEBOX_playing)
if (READ_PROPERTY) { GB.ReturnBoolean(MBOX->playing()); return; }
MBOX->setPlaying(VPROP(GB_BOOLEAN));
END_PROPERTY
BEGIN_METHOD_VOID(CMOVIEBOX_rewind)
if (MBOX->playing())
{
MBOX->setPlaying(false);
MBOX->setPlaying(true);
}
END_METHOD
GB_DESC CPictureBoxDesc[] =
{
GB_DECLARE("PictureBox", sizeof(CPICTUREBOX)), GB_INHERITS("Control"),
******** 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_STATIC_METHOD("_init",0,CPICTUREBOX_init,0),
GB_METHOD("_new", 0, CPICTUREBOX_new, "(Parent)Container;"),
GB_METHOD("_free", 0, CPICTUREBOX_free,0),
GB_PROPERTY("Picture", "Picture", CPICTUREBOX_picture),
GB_PROPERTY("Stretch", "b", CPICTUREBOX_stretch),
GB_PROPERTY("Border", "i", CPICTUREBOX_border),
GB_PROPERTY("Alignment", "i", CPICTUREBOX_alignment),
PICTUREBOX_DESCRIPTION,
GB_END_DECLARE
};
GB_DESC CMovieBoxDesc[] =
{
GB_DECLARE("MovieBox", sizeof(CMOVIEBOX)), GB_INHERITS("Control"),
******** 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, CMOVIEBOX_new, "(Parent)Container;"),
GB_METHOD("_free", 0, CMOVIEBOX_free,0),
GB_METHOD("Rewind", 0, CMOVIEBOX_rewind, 0),
GB_PROPERTY("Path", "s", CMOVIEBOX_path),
GB_PROPERTY("Playing", "b", CMOVIEBOX_playing),
GB_PROPERTY("Border", "i", CMOVIEBOX_border),
MOVIEBOX_DESCRIPTION,
GB_END_DECLARE
};