gambas-source-code/gb.qt4/src/CColor.cpp
Benoît Minisini 53f66734b5 [DEVELOPMENT ENVIRONMENT]
* NEW: Support for choosing LinkForeground and VisitedForeground system 
  colors.
* NEW: An option to toggle the display of current file name in the IDE 
  window title.

[GB.GTK]
* NEW: Color.LinkForeground and Color.VisitedForeground are two new 
  properties that return the system color associated with links and visited 
  links. If not applicable, some default colors are returned.

[GB.GTK3]
* NEW: Color.LinkForeground and Color.VisitedForeground are two new 
  properties that return the system color associated with links and visited 
  links. If not applicable, some default colors are returned.
* BUG: Get rid of some warnings.

[GB.QT4]
* NEW: Color.LinkForeground and Color.VisitedForeground are two new 
  properties that return the system color associated with links and visited 
  links.


git-svn-id: svn://localhost/gambas/trunk@6331 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2014-06-20 13:44:08 +00:00

168 lines
4 KiB
C++

/***************************************************************************
CColor.cpp
(c) 2000-2013 Benoît Minisini <gambas@users.sourceforge.net>
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., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
***************************************************************************/
#define __CCOLOR_CPP
#include <qapplication.h>
#include <qcolor.h>
#include <qpalette.h>
#include "gambas.h"
#include "CWidget.h"
#include "CColor.h"
static uint get_light_foreground()
{
return IMAGE.MergeColor(qApp->palette().color(QPalette::Window).rgb() & 0xFFFFFF, qApp->palette().color(QPalette::WindowText).rgb() & 0xFFFFFF, 0.3);
}
QColor CCOLOR_light_foreground()
{
return QColor((QRgb)get_light_foreground());
}
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);
}
static void return_color(QPalette::ColorRole role)
{
GB.ReturnInteger(QApplication::palette().color(role).rgb() & 0xFFFFFF);
}
BEGIN_PROPERTY(Color_Background)
return_color(QPalette::Window);
END_PROPERTY
BEGIN_PROPERTY(Color_Foreground)
return_color(QPalette::WindowText);
END_PROPERTY
BEGIN_PROPERTY(Color_TextBackground)
return_color(QPalette::Base);
END_PROPERTY
BEGIN_PROPERTY(Color_TextForeground)
return_color(QPalette::Text);
END_PROPERTY
BEGIN_PROPERTY(Color_SelectedBackground)
return_color(QPalette::Highlight);
END_PROPERTY
BEGIN_PROPERTY(Color_SelectedForeground)
return_color(QPalette::HighlightedText);
END_PROPERTY
BEGIN_PROPERTY(Color_ButtonBackground)
return_color(QPalette::Button);
END_PROPERTY
BEGIN_PROPERTY(Color_ButtonForeground)
return_color(QPalette::ButtonText);
END_PROPERTY
BEGIN_PROPERTY(Color_LightBackground)
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)
GB.ReturnInteger(get_light_foreground());
END_PROPERTY
BEGIN_PROPERTY(Color_TooltipBackground)
return_color(QPalette::ToolTipBase);
END_PROPERTY
BEGIN_PROPERTY(Color_TooltipForeground)
return_color(QPalette::ToolTipText);
END_PROPERTY
BEGIN_PROPERTY(Color_LinkForeground)
return_color(QPalette::Link);
END_PROPERTY
BEGIN_PROPERTY(Color_VisitedForeground)
return_color(QPalette::LinkVisited);
END_PROPERTY
GB_DESC CColorDesc[] =
{
GB_DECLARE("Color", 0), GB_VIRTUAL_CLASS(),
GB_STATIC_PROPERTY("Background", "i", Color_Background),
GB_STATIC_PROPERTY("SelectedBackground", "i", Color_SelectedBackground),
GB_STATIC_PROPERTY("LightBackground", "i", Color_LightBackground),
GB_STATIC_PROPERTY("TextBackground", "i", Color_TextBackground),
GB_STATIC_PROPERTY("ButtonBackground", "i", Color_ButtonBackground),
GB_STATIC_PROPERTY("TooltipBackground", "i", Color_TooltipBackground),
GB_STATIC_PROPERTY("Foreground", "i", Color_Foreground),
GB_STATIC_PROPERTY("LightForeground", "i", Color_LightForeground),
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),
GB_STATIC_PROPERTY("LinkForeground", "i", Color_LinkForeground),
GB_STATIC_PROPERTY("VisitedForeground", "i", Color_VisitedForeground),
GB_END_DECLARE
};