2008-04-24 14:49:12 +02:00
|
|
|
/***************************************************************************
|
|
|
|
|
|
|
|
CColor.cpp
|
|
|
|
|
2013-08-03 17:38:01 +02:00
|
|
|
(c) 2000-2013 Benoît Minisini <gambas@users.sourceforge.net>
|
2008-04-24 14:49:12 +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
|
2009-08-17 12:41:51 +02:00
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
2008-04-24 14:49:12 +02: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
|
2011-06-03 02:51:09 +02:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
2011-12-31 03:39:20 +01:00
|
|
|
MA 02110-1301, USA.
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#define __CCOLOR_CPP
|
|
|
|
|
|
|
|
#include <qapplication.h>
|
|
|
|
#include <qcolor.h>
|
|
|
|
#include <qpalette.h>
|
|
|
|
|
|
|
|
#include "gambas.h"
|
|
|
|
|
|
|
|
#include "CWidget.h"
|
|
|
|
#include "CColor.h"
|
|
|
|
|
2011-12-26 23:52:25 +01:00
|
|
|
static uint get_light_foreground()
|
2010-09-15 03:49:26 +02:00
|
|
|
{
|
2011-12-26 23:52:25 +01:00
|
|
|
return IMAGE.MergeColor(qApp->palette().color(QPalette::Window).rgb() & 0xFFFFFF, qApp->palette().color(QPalette::WindowText).rgb() & 0xFFFFFF, 0.3);
|
2010-09-15 03:49:26 +02:00
|
|
|
}
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2010-09-15 03:49:26 +02:00
|
|
|
QColor CCOLOR_light_foreground()
|
2009-08-09 00:34:19 +02:00
|
|
|
{
|
2011-12-26 23:52:25 +01:00
|
|
|
return QColor((QRgb)get_light_foreground());
|
2009-08-09 00:34:19 +02:00
|
|
|
}
|
|
|
|
|
2009-12-28 02:19:27 +01:00
|
|
|
QColor CCOLOR_make(GB_COLOR color)
|
|
|
|
{
|
|
|
|
int b = color & 0xFF;
|
|
|
|
int g = (color >> 8) & 0xFF;
|
|
|
|
int r = (color >> 16) & 0xFF;
|
|
|
|
int a = (color >> 24) ^ 0xFF;
|
|
|
|
|
|
|
|
return QColor(r, g, b, a);
|
|
|
|
}
|
|
|
|
|
2008-04-29 15:40:55 +02:00
|
|
|
static void return_color(QPalette::ColorRole role)
|
2008-04-24 14:49:12 +02:00
|
|
|
{
|
2008-04-29 15:40:55 +02:00
|
|
|
GB.ReturnInteger(QApplication::palette().color(role).rgb() & 0xFFFFFF);
|
2008-04-24 14:49:12 +02:00
|
|
|
}
|
|
|
|
|
2011-10-09 22:27:10 +02:00
|
|
|
BEGIN_PROPERTY(Color_Background)
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2008-04-29 15:40:55 +02:00
|
|
|
return_color(QPalette::Window);
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2011-10-09 22:27:10 +02:00
|
|
|
BEGIN_PROPERTY(Color_Foreground)
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2008-04-29 15:40:55 +02:00
|
|
|
return_color(QPalette::WindowText);
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2011-10-09 22:27:10 +02:00
|
|
|
BEGIN_PROPERTY(Color_TextBackground)
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2008-04-29 15:40:55 +02:00
|
|
|
return_color(QPalette::Base);
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2011-10-09 22:27:10 +02:00
|
|
|
BEGIN_PROPERTY(Color_TextForeground)
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2008-04-29 15:40:55 +02:00
|
|
|
return_color(QPalette::Text);
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2011-10-09 22:27:10 +02:00
|
|
|
BEGIN_PROPERTY(Color_SelectedBackground)
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2008-04-29 15:40:55 +02:00
|
|
|
return_color(QPalette::Highlight);
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2011-10-09 22:27:10 +02:00
|
|
|
BEGIN_PROPERTY(Color_SelectedForeground)
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2008-04-29 15:40:55 +02:00
|
|
|
return_color(QPalette::HighlightedText);
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2011-10-09 22:27:10 +02:00
|
|
|
BEGIN_PROPERTY(Color_ButtonBackground)
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2008-04-29 15:40:55 +02:00
|
|
|
return_color(QPalette::Button);
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2011-10-09 22:27:10 +02:00
|
|
|
BEGIN_PROPERTY(Color_ButtonForeground)
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2008-04-29 15:40:55 +02:00
|
|
|
return_color(QPalette::ButtonText);
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2010-09-15 03:49:26 +02:00
|
|
|
BEGIN_PROPERTY(Color_LightBackground)
|
2009-09-01 03:14:13 +02:00
|
|
|
|
2010-09-15 03:49:26 +02:00
|
|
|
uint col = IMAGE.MergeColor(qApp->palette().color(QPalette::Base).rgb() & 0xFFFFFF, qApp->palette().color(QPalette::Highlight).rgb() & 0xFFFFFF, 0.5);
|
|
|
|
GB.ReturnInteger(col);
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(Color_LightForeground)
|
2009-09-01 11:29:40 +02:00
|
|
|
|
2011-12-26 23:52:25 +01:00
|
|
|
GB.ReturnInteger(get_light_foreground());
|
2009-09-01 03:14:13 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2011-10-09 22:27:10 +02:00
|
|
|
BEGIN_PROPERTY(Color_TooltipBackground)
|
|
|
|
|
|
|
|
return_color(QPalette::ToolTipBase);
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(Color_TooltipForeground)
|
|
|
|
|
|
|
|
return_color(QPalette::ToolTipText);
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2014-06-20 15:44:08 +02:00
|
|
|
BEGIN_PROPERTY(Color_LinkForeground)
|
|
|
|
|
|
|
|
return_color(QPalette::Link);
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(Color_VisitedForeground)
|
|
|
|
|
|
|
|
return_color(QPalette::LinkVisited);
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2008-04-24 14:49:12 +02:00
|
|
|
GB_DESC CColorDesc[] =
|
|
|
|
{
|
|
|
|
GB_DECLARE("Color", 0), GB_VIRTUAL_CLASS(),
|
|
|
|
|
2011-10-09 22:27:10 +02:00
|
|
|
GB_STATIC_PROPERTY("Background", "i", Color_Background),
|
|
|
|
GB_STATIC_PROPERTY("SelectedBackground", "i", Color_SelectedBackground),
|
2010-09-15 03:49:26 +02:00
|
|
|
GB_STATIC_PROPERTY("LightBackground", "i", Color_LightBackground),
|
2011-10-09 22:27:10 +02:00
|
|
|
GB_STATIC_PROPERTY("TextBackground", "i", Color_TextBackground),
|
|
|
|
GB_STATIC_PROPERTY("ButtonBackground", "i", Color_ButtonBackground),
|
|
|
|
GB_STATIC_PROPERTY("TooltipBackground", "i", Color_TooltipBackground),
|
2008-04-24 14:49:12 +02:00
|
|
|
|
2011-10-09 22:27:10 +02:00
|
|
|
GB_STATIC_PROPERTY("Foreground", "i", Color_Foreground),
|
2010-09-15 03:49:26 +02:00
|
|
|
GB_STATIC_PROPERTY("LightForeground", "i", Color_LightForeground),
|
2011-10-09 22:27:10 +02:00
|
|
|
GB_STATIC_PROPERTY("SelectedForeground", "i", Color_SelectedForeground),
|
|
|
|
GB_STATIC_PROPERTY("TextForeground", "i", Color_TextForeground),
|
|
|
|
GB_STATIC_PROPERTY("ButtonForeground", "i", Color_ButtonForeground),
|
|
|
|
GB_STATIC_PROPERTY("TooltipForeground", "i", Color_TooltipForeground),
|
2014-06-20 15:44:08 +02:00
|
|
|
GB_STATIC_PROPERTY("LinkForeground", "i", Color_LinkForeground),
|
|
|
|
GB_STATIC_PROPERTY("VisitedForeground", "i", Color_VisitedForeground),
|
2008-04-24 14:49:12 +02:00
|
|
|
|
|
|
|
GB_END_DECLARE
|
|
|
|
};
|
|
|
|
|
|
|
|
|