2007-12-30 16:41:49 +00:00
|
|
|
/***************************************************************************
|
|
|
|
|
|
|
|
CScreen.cpp
|
|
|
|
|
|
|
|
(c) 2004-2006 - Daniel Campos Fernández <dcamposf@gmail.com>
|
2009-08-17 10:41:51 +00:00
|
|
|
|
2007-12-30 16:41:49 +00: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
|
2009-08-17 10:41:51 +00:00
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
2007-12-30 16:41:49 +00:00
|
|
|
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 __CSCREEN_CPP
|
|
|
|
|
|
|
|
#include "CWindow.h"
|
|
|
|
#include "CPicture.h"
|
|
|
|
#include "CFont.h"
|
|
|
|
#include "CScreen.h"
|
|
|
|
|
|
|
|
#include "gapplication.h"
|
|
|
|
#include "gmainwindow.h"
|
|
|
|
|
2008-03-31 19:04:28 +00:00
|
|
|
extern int CWINDOW_Embedder;
|
2007-12-30 16:41:49 +00:00
|
|
|
extern bool CWINDOW_Embedded;
|
|
|
|
|
|
|
|
extern int MAIN_scale;
|
|
|
|
|
|
|
|
char *CAPPLICATION_Theme = 0;
|
|
|
|
|
|
|
|
static int _busy = 0;
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(CSCREEN_width)
|
|
|
|
|
|
|
|
GB.ReturnInteger(gDesktop::width());
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(CSCREEN_height)
|
|
|
|
|
|
|
|
GB.ReturnInteger(gDesktop::height());
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(CSCREEN_resolution)
|
|
|
|
|
|
|
|
GB.ReturnInteger(gDesktop::resolution());
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(CSCREEN_charset)
|
|
|
|
|
|
|
|
GB.ReturnConstZeroString("UTF-8");
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
|
2009-09-06 15:57:54 +00:00
|
|
|
BEGIN_METHOD(CSCREEN_grab, GB_INTEGER x; GB_INTEGER y; GB_INTEGER width; GB_INTEGER height)
|
2007-12-30 16:41:49 +00:00
|
|
|
|
2009-09-06 15:57:54 +00:00
|
|
|
CPICTURE *pic;
|
|
|
|
gPicture *buf = gDesktop::screenshot(VARGOPT(x,0), VARGOPT(y, 0), VARGOPT(width, 0), VARGOPT(height, 0));
|
2007-12-30 16:41:49 +00:00
|
|
|
|
2008-01-17 21:39:26 +00:00
|
|
|
GB.New(POINTER(&pic), GB.FindClass("Picture"), 0, 0);
|
2007-12-30 16:41:49 +00:00
|
|
|
if (pic->picture) pic->picture->unref();
|
2009-09-06 15:57:54 +00:00
|
|
|
pic->picture = buf;
|
2007-12-30 16:41:49 +00:00
|
|
|
GB.ReturnObject(pic);
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
|
|
|
|
static void set_font(gFont *font, void *object = 0)
|
|
|
|
{
|
|
|
|
gDesktop::setFont(font);
|
|
|
|
MAIN_scale = gDesktop::scale();
|
|
|
|
}
|
|
|
|
|
2008-03-13 21:38:43 +00:00
|
|
|
static void set_tooltip_font(gFont *font, void *object = 0)
|
|
|
|
{
|
|
|
|
gApplication::setToolTipsFont(font);
|
|
|
|
}
|
|
|
|
|
2007-12-30 16:41:49 +00:00
|
|
|
BEGIN_PROPERTY(CAPP_font)
|
|
|
|
|
|
|
|
if (READ_PROPERTY)
|
2009-06-22 11:16:34 +00:00
|
|
|
GB.ReturnObject(CFONT_create(gDesktop::font()->copy(), set_font));
|
2007-12-30 16:41:49 +00:00
|
|
|
else if (VPROP(GB_OBJECT))
|
|
|
|
set_font(((CFONT*)VPROP(GB_OBJECT))->font);
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2008-03-13 21:38:43 +00:00
|
|
|
|
|
|
|
BEGIN_PROPERTY(CAPP_tooltip_font)
|
|
|
|
|
|
|
|
if (READ_PROPERTY)
|
2009-06-22 11:16:34 +00:00
|
|
|
GB.ReturnObject(CFONT_create(gApplication::toolTipsFont()->copy(), set_tooltip_font));
|
2008-03-13 21:38:43 +00:00
|
|
|
else if (VPROP(GB_OBJECT))
|
|
|
|
set_tooltip_font(((CFONT*)VPROP(GB_OBJECT))->font);
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
|
2007-12-30 16:41:49 +00:00
|
|
|
#if 0
|
|
|
|
BEGIN_PROPERTY(CSCREEN_font)
|
|
|
|
|
|
|
|
CFONT *Font;
|
|
|
|
|
|
|
|
|
|
|
|
if (READ_PROPERTY)
|
|
|
|
{
|
|
|
|
GB.New((void **)&Font, GB.FindClass("Font"), 0, 0);
|
|
|
|
Font->font->unref();
|
|
|
|
Font->font=gDesktop::font();
|
|
|
|
Font->font->ref();
|
|
|
|
GB.ReturnObject(Font);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Font=(CFONT*)VPROP(GB_OBJECT);
|
|
|
|
if (!Font) return;
|
|
|
|
if (!Font->font) return;
|
|
|
|
gDesktop::setFont(Font->font);
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
#endif
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(CSCREEN_active_window)
|
|
|
|
|
|
|
|
GB.ReturnObject(CWINDOW_Active);
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(CSCREEN_active_control)
|
|
|
|
|
|
|
|
gControl *win=gDesktop::activeControl();
|
|
|
|
|
|
|
|
if (!win) { GB.ReturnNull(); return; }
|
|
|
|
GB.ReturnObject(GetObject(win));
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(CSCREEN_busy)
|
|
|
|
|
|
|
|
int busy;
|
|
|
|
|
|
|
|
if (READ_PROPERTY)
|
|
|
|
GB.ReturnInteger(_busy);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
busy = VPROP(GB_INTEGER);
|
|
|
|
|
|
|
|
if (_busy == 0 && busy != 0)
|
|
|
|
gApplication::setBusy(true);
|
|
|
|
else if (_busy > 0 && busy == 0)
|
|
|
|
gApplication::setBusy(false);
|
|
|
|
|
|
|
|
_busy = busy;
|
|
|
|
}
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(CSCREEN_scale)
|
|
|
|
|
|
|
|
GB.ReturnInteger(MAIN_scale);
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(CAPP_tooltip_enabled)
|
|
|
|
|
|
|
|
if (READ_PROPERTY) { GB.ReturnBoolean(gApplication::toolTips()); return; }
|
|
|
|
gApplication::enableTooltips(VPROP(GB_BOOLEAN));
|
|
|
|
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2009-06-01 22:27:50 +00:00
|
|
|
BEGIN_PROPERTY(CAPP_tooltip_delay)
|
|
|
|
|
|
|
|
if (READ_PROPERTY)
|
|
|
|
GB.ReturnInteger(gApplication::toolTipsDelay());
|
|
|
|
else
|
|
|
|
gApplication::setToolTipsDelay(VPROP(GB_INTEGER));
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2007-12-30 16:41:49 +00:00
|
|
|
|
|
|
|
BEGIN_PROPERTY(CAPP_main_window)
|
|
|
|
|
|
|
|
GB.ReturnObject(WINDOW_get_main());
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
BEGIN_METHOD_VOID(CAPP_exit)
|
|
|
|
|
|
|
|
GB.FreeString(&CAPPLICATION_Theme);
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(CAPP_theme)
|
|
|
|
|
|
|
|
if (READ_PROPERTY) { GB.ReturnString(CAPPLICATION_Theme); return; }
|
|
|
|
GB.StoreString(PROP(GB_STRING), &CAPPLICATION_Theme);
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GB_DESC CDesktopDesc[] =
|
|
|
|
{
|
|
|
|
GB_DECLARE("Desktop", 0), GB_VIRTUAL_CLASS(),
|
|
|
|
|
|
|
|
GB_STATIC_PROPERTY_READ("W", "i", CSCREEN_width),
|
|
|
|
GB_STATIC_PROPERTY_READ("H", "i", CSCREEN_height),
|
|
|
|
GB_STATIC_PROPERTY_READ("Width", "i", CSCREEN_width),
|
|
|
|
GB_STATIC_PROPERTY_READ("Height", "i", CSCREEN_height),
|
|
|
|
GB_STATIC_PROPERTY_READ("Charset", "s", CSCREEN_charset),
|
|
|
|
GB_STATIC_PROPERTY_READ("Resolution", "i", CSCREEN_resolution),
|
|
|
|
GB_STATIC_PROPERTY_READ("Scale","i",CSCREEN_scale),
|
|
|
|
|
2009-09-06 15:57:54 +00:00
|
|
|
GB_STATIC_METHOD("Screenshot", "Picture", CSCREEN_grab, "[(X)i(Y)i(Width)i(Height)i]"),
|
2007-12-30 16:41:49 +00:00
|
|
|
|
|
|
|
GB_END_DECLARE
|
|
|
|
};
|
|
|
|
|
|
|
|
GB_DESC CApplicationTooltipDesc[] =
|
|
|
|
{
|
|
|
|
GB_DECLARE(".ApplicationTooltip", 0), GB_VIRTUAL_CLASS(),
|
|
|
|
|
|
|
|
GB_STATIC_PROPERTY("Enabled", "b", CAPP_tooltip_enabled),
|
|
|
|
GB_STATIC_PROPERTY("Font", "Font", CAPP_tooltip_font),
|
2009-06-07 22:10:14 +00:00
|
|
|
//GB_STATIC_PROPERTY("Delay", "i", CAPP_tooltip_delay),
|
2007-12-30 16:41:49 +00:00
|
|
|
|
|
|
|
GB_END_DECLARE
|
|
|
|
};
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(CAPP_embedder)
|
|
|
|
|
|
|
|
if (READ_PROPERTY)
|
2008-03-31 19:04:28 +00:00
|
|
|
GB.ReturnInteger(CWINDOW_Embedder);
|
2007-12-30 16:41:49 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (CWINDOW_Embedded)
|
|
|
|
{
|
|
|
|
GB.Error("Application is already embedded");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-03-31 19:04:28 +00:00
|
|
|
CWINDOW_Embedder = VPROP(GB_INTEGER);
|
2007-12-30 16:41:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
GB_DESC CApplicationDesc[] =
|
|
|
|
{
|
|
|
|
GB_DECLARE("Application", 0), GB_VIRTUAL_CLASS(),
|
|
|
|
|
2008-01-17 21:39:26 +00:00
|
|
|
GB_STATIC_METHOD("_exit", NULL, CAPP_exit, 0),
|
2007-12-30 16:41:49 +00:00
|
|
|
|
|
|
|
GB_STATIC_PROPERTY("Font", "Font", CAPP_font),
|
|
|
|
GB_STATIC_PROPERTY_READ("ActiveControl","Control",CSCREEN_active_control),
|
|
|
|
GB_STATIC_PROPERTY_READ("ActiveWindow", "Window", CSCREEN_active_window),
|
|
|
|
GB_STATIC_PROPERTY_READ("MainWindow", "Window", CAPP_main_window),
|
|
|
|
GB_STATIC_PROPERTY("Busy", "i", CSCREEN_busy),
|
|
|
|
GB_STATIC_PROPERTY_SELF("ToolTip", ".ApplicationTooltip"),
|
|
|
|
|
2008-03-31 19:04:28 +00:00
|
|
|
GB_STATIC_PROPERTY("Embedder", "i", CAPP_embedder),
|
2007-12-30 16:41:49 +00:00
|
|
|
GB_STATIC_PROPERTY("Theme", "s", CAPP_theme),
|
|
|
|
|
|
|
|
GB_END_DECLARE
|
|
|
|
};
|
|
|
|
|
|
|
|
|