added Widgets::Colors class and changed numerical color codes to color names

This commit is contained in:
fgerlits 2005-04-07 16:08:16 +00:00
parent 16bd74eaf8
commit fb2261a0a9
20 changed files with 336 additions and 78 deletions

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.7 $
Version : $Revision: 1.8 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/BlueBin.cxx,v $
------------------------------------------------------------------------------*/
@ -54,7 +54,7 @@ using namespace LiveSupport::Widgets;
/*------------------------------------------------------------------------------
* Constructor.
*----------------------------------------------------------------------------*/
BlueBin :: BlueBin(unsigned int backgroundColor,
BlueBin :: BlueBin(Colors::ColorName backgroundColor,
Ptr<CornerImages>::Ref cornerImages)
throw ()
{
@ -64,13 +64,7 @@ BlueBin :: BlueBin(unsigned int backgroundColor,
child = 0;
bgColor = Gdk::Color();
unsigned int red = (backgroundColor & 0xff0000) >> 8;
unsigned int green = (backgroundColor & 0x00ff00);
unsigned int blue = (backgroundColor & 0x0000ff) << 8;
bgColor.set_rgb(red, green, blue);
Glib::RefPtr<Gdk::Colormap> colormap = get_default_colormap();
colormap->alloc_color(bgColor);
bgColor = Colors::getColor(backgroundColor);
}

View file

@ -0,0 +1,131 @@
/*------------------------------------------------------------------------------
Copyright (c) 2004 Media Development Loan Fund
This file is part of the LiveSupport project.
http://livesupport.campware.org/
To report bugs, send an e-mail to bugs@campware.org
LiveSupport 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 of the License, or
(at your option) any later version.
LiveSupport 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 LiveSupport; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/Colors.cxx,v $
------------------------------------------------------------------------------*/
/* ============================================================ include files */
#ifdef HAVE_CONFIG_H
#include "configure.h"
#endif
#include <iostream.h>
#include "gtkmm/widget.h"
#include "LiveSupport/Widgets/Colors.h"
using namespace LiveSupport::Widgets;
/* =================================================== local data structures */
/* ================================================ local constants & macros */
/**
* The vector holding the colors.
*/
std::map<Colors::ColorName, Gdk::Color> Colors :: colors;
/**
* Clear the "initialized" flag.
*/
bool Colors :: initialized = false;
/* =============================================== local function prototypes */
/* ============================================================= module code */
/*------------------------------------------------------------------------------
* Load the colors.
*----------------------------------------------------------------------------*/
void
Colors :: initialize(void) throw ()
{
Gdk::Color whiteColor ("#ffffff");
Gdk::Color blackColor ("#000000");
Gdk::Color lightBlueColor ("#cfdee7");
Gdk::Color brightBlueColor ("#6fb0ff");
Gdk::Color blueColor ("#9ebadb");
Gdk::Color darkBlueColor ("#688597");
Gdk::Color grayColor ("#eaeaea");
Gdk::Color slateGrayColor ("#c7cdd3");
Gdk::Color mediumBlueGrayColor ("#97bacf");
Gdk::Color darkGrayColor ("#5a5a5a");
Gdk::Color orangeColor ("#ff4b00");
Gdk::Color masterPanelCenterBlueColor ("#99cdff");
Gdk::Color liveModeRowBlueColor ("#cde0f1");
Glib::RefPtr<Gdk::Colormap> colormap = Gtk::Widget::get_default_colormap();
colormap->alloc_color(whiteColor);
colormap->alloc_color(blackColor);
colormap->alloc_color(lightBlueColor);
colormap->alloc_color(brightBlueColor);
colormap->alloc_color(blueColor);
colormap->alloc_color(darkBlueColor);
colormap->alloc_color(grayColor);
colormap->alloc_color(slateGrayColor);
colormap->alloc_color(mediumBlueGrayColor);
colormap->alloc_color(darkGrayColor);
colormap->alloc_color(orangeColor);
colormap->alloc_color(masterPanelCenterBlueColor);
colormap->alloc_color(liveModeRowBlueColor);
colors[White] = whiteColor;
colors[Black] = blackColor;
colors[LightBlue] = lightBlueColor;
colors[BrightBlue] = brightBlueColor;
colors[Blue] = blueColor;
colors[DarkBlue] = darkBlueColor;
colors[Gray] = grayColor;
colors[SlateGray] = slateGrayColor;
colors[MediumBlueGray] = mediumBlueGrayColor;
colors[DarkGray] = darkGrayColor;
colors[Orange] = orangeColor;
colors[MasterPanelCenterBlue] = masterPanelCenterBlueColor;
colors[LiveModeRowBlue] = liveModeRowBlueColor;
initialized = true;
}
/*------------------------------------------------------------------------------
* Get a color by its name.
*----------------------------------------------------------------------------*/
const Gdk::Color&
Colors :: getColor(const ColorName& name) throw ()
{
if (!initialized) {
initialize();
}
return colors[name];
}

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $
Version : $Revision: 1.3 $
Author : $Author: fgerlits $
Version : $Revision: 1.4 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/ComboBoxText.cxx,v $
------------------------------------------------------------------------------*/
@ -33,6 +33,7 @@
#include "configure.h"
#endif
#include "LiveSupport/Widgets/Colors.h"
#include "LiveSupport/Widgets/ComboBoxText.h"
@ -68,10 +69,7 @@ ComboBoxText :: ComboBoxText(Glib::RefPtr<Gdk::Pixbuf> leftImage,
label->set_parent(*this);
// specify a white background
Gdk::Color bgColor = Gdk::Color();
bgColor.set_rgb(0xffff, 0xffff, 0xffff);
Glib::RefPtr<Gdk::Colormap> colormap = get_default_colormap();
colormap->alloc_color(bgColor);
Gdk::Color bgColor = Colors::getColor(Colors::White);
menu.reset(new Gtk::Menu());
menu->modify_bg(Gtk::STATE_NORMAL, bgColor);

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $
Version : $Revision: 1.2 $
Author : $Author: fgerlits $
Version : $Revision: 1.3 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/EntryBin.cxx,v $
------------------------------------------------------------------------------*/
@ -54,7 +54,7 @@ using namespace LiveSupport::Widgets;
/*------------------------------------------------------------------------------
* Constructor.
*----------------------------------------------------------------------------*/
EntryBin :: EntryBin(unsigned int backgroundColor,
EntryBin :: EntryBin(Colors::ColorName backgroundColor,
Ptr<CornerImages>::Ref cornerImages)
throw ()
: BlueBin(backgroundColor, cornerImages)

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $
Version : $Revision: 1.4 $
Author : $Author: fgerlits $
Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/ImageButton.cxx,v $
------------------------------------------------------------------------------*/
@ -33,6 +33,7 @@
#include "configure.h"
#endif
#include "LiveSupport/Widgets/Colors.h"
#include "LiveSupport/Widgets/ImageButton.h"
@ -220,10 +221,7 @@ ImageButton :: on_realize() throw ()
unset_flags(Gtk::NO_WINDOW);
set_window(gdkWindow);
Gdk::Color bgColor;
bgColor.set_rgb(0xffff, 0xffff, 0xffff);
Glib::RefPtr<Gdk::Colormap> colormap = get_default_colormap();
colormap->alloc_color(bgColor);
Gdk::Color bgColor = Colors::getColor(Colors::White);
modify_bg(Gtk::STATE_NORMAL, bgColor);
// make the widget receive expose events

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $
Version : $Revision: 1.12 $
Author : $Author: fgerlits $
Version : $Revision: 1.13 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/TestWindow.cxx,v $
------------------------------------------------------------------------------*/
@ -36,6 +36,7 @@
#include <iostream>
#include "LiveSupport/Widgets/WidgetFactory.h"
#include "LiveSupport/Widgets/Colors.h"
#include "TestWindow.h"
@ -58,7 +59,7 @@ using namespace LiveSupport::Widgets;
TestWindow :: TestWindow (void)
throw ()
: WhiteWindow("test window",
0xffffff,
Colors::White,
WidgetFactory::getInstance()->getWhiteWindowCorners())
{
Ptr<WidgetFactory>::Ref widgetFactory = WidgetFactory::getInstance();
@ -88,7 +89,7 @@ TestWindow :: TestWindow (void)
notebook->appendPage(*entryBin, "third page");
// create a blue container
blueBin = Gtk::manage(widgetFactory->createDarkBlueBin());
blueBin = Gtk::manage(widgetFactory->createBlueBin());
// create and set up the layout
layout = Gtk::manage(new Gtk::Table());

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.8 $
Version : $Revision: 1.9 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/WhiteWindow.cxx,v $
------------------------------------------------------------------------------*/
@ -57,7 +57,7 @@ using namespace LiveSupport::Widgets;
* Constructor.
*----------------------------------------------------------------------------*/
WhiteWindow :: WhiteWindow(Glib::ustring title,
unsigned int backgroundColor,
Colors::ColorName backgroundColor,
Ptr<CornerImages>::Ref cornerImages,
bool resizable)
throw ()
@ -72,13 +72,7 @@ WhiteWindow :: WhiteWindow(Glib::ustring title,
layout = Gtk::manage(new Gtk::Table());
// create the background color, as it is needed by the event box
Gdk::Color bgColor = Gdk::Color();
unsigned int red = (backgroundColor & 0xff0000) >> 8;
unsigned int green = (backgroundColor & 0x00ff00);
unsigned int blue = (backgroundColor & 0x0000ff) << 8;
bgColor.set_rgb(red, green, blue);
Glib::RefPtr<Gdk::Colormap> colormap = get_default_colormap();
colormap->alloc_color(bgColor);
Gdk::Color bgColor = Colors::getColor(backgroundColor);
// set the window title
this->title = Gtk::manage(new Gtk::Label(title));

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.11 $
Version : $Revision: 1.12 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/WidgetFactory.cxx,v $
------------------------------------------------------------------------------*/
@ -35,8 +35,9 @@
#include <gtkmm/entry.h>
#include "LiveSupport/Widgets/WidgetFactory.h"
#include "LiveSupport/Widgets/Colors.h"
#include "LiveSupport/Widgets/WidgetFactory.h"
using namespace LiveSupport::Core;
using namespace LiveSupport::Widgets;
@ -275,7 +276,7 @@ WidgetFactory :: createComboBoxText(void) throw ()
BlueBin *
WidgetFactory :: createBlueBin(void) throw ()
{
return new BlueBin(0xcfdee7, blueBinImages);
return new BlueBin(Colors::LightBlue, blueBinImages);
}
@ -285,7 +286,7 @@ WidgetFactory :: createBlueBin(void) throw ()
BlueBin *
WidgetFactory :: createDarkBlueBin(void) throw ()
{
return new BlueBin(0x99cdff, darkBlueBinImages);
return new BlueBin(Colors::MasterPanelCenterBlue, darkBlueBinImages);
}
@ -295,7 +296,7 @@ WidgetFactory :: createDarkBlueBin(void) throw ()
EntryBin *
WidgetFactory :: createEntryBin(void) throw ()
{
return new EntryBin(0xcfdfe7, entryBinImages);
return new EntryBin(Colors::LightBlue, entryBinImages);
}

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/ZebraTreeView.cxx,v $
------------------------------------------------------------------------------*/
@ -66,7 +66,22 @@ ZebraTreeView :: ZebraTreeView(Glib::RefPtr<Gtk::TreeModel> treeModel)
/*------------------------------------------------------------------------------
* Destructor.
*----------------------------------------------------------------------------*/
ZebraTreeView :: ~ZebraTreeView(void) throw ()
ZebraTreeView :: ~ZebraTreeView(void) throw ()
{
}
/*------------------------------------------------------------------------------
* Color the table blue.
*----------------------------------------------------------------------------*/
void
ZebraTreeView :: colorBlue(void) throw ()
{
Gdk::Color bgColor = Colors::getColor(Colors::LightBlue);
for (int i = 0; i < get_columns().size(); i++) {
Gtk::CellRenderer* renderer = get_column_cell_renderer(i);
renderer->property_cell_background_gdk() = bgColor;
// renderer->property_cell_background_set() = false;
}
}