Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

CEGUIListboxItem.cpp

Go to the documentation of this file.
00001 /************************************************************************
00002         filename:       CEGUIListboxItem.cpp
00003         created:        12/6/2004
00004         author:         Paul D Turner
00005         
00006         purpose:        Implementation of base class for list items
00007 *************************************************************************/
00008 /*************************************************************************
00009     Crazy Eddie's GUI System (http://www.cegui.org.uk)
00010     Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
00011 
00012     This library is free software; you can redistribute it and/or
00013     modify it under the terms of the GNU Lesser General Public
00014     License as published by the Free Software Foundation; either
00015     version 2.1 of the License, or (at your option) any later version.
00016 
00017     This library is distributed in the hope that it will be useful,
00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020     Lesser General Public License for more details.
00021 
00022     You should have received a copy of the GNU Lesser General Public
00023     License along with this library; if not, write to the Free Software
00024     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 *************************************************************************/
00026 #include "elements/CEGUIListboxItem.h"
00027 #include "CEGUISystem.h"
00028 #include "CEGUIImagesetManager.h"
00029 #include "CEGUIImageset.h"
00030 
00031 
00032 // Start of CEGUI namespace section
00033 namespace CEGUI
00034 {
00035 /*************************************************************************
00036         Constants
00037 *************************************************************************/
00038 const colour    ListboxItem::DefaultSelectionColour     = 0xFF4444AA;
00039 
00040 /*************************************************************************
00041         Base class constructor
00042 *************************************************************************/
00043 ListboxItem::ListboxItem(const String& text, uint item_id, void* item_data, bool disabled, bool auto_delete) :
00044         d_itemText(text),
00045         d_itemID(item_id),
00046         d_itemData(item_data),
00047         d_disabled(disabled),
00048         d_autoDelete(auto_delete),
00049         d_selected(false),
00050         d_owner(NULL),
00051         d_selectBrush(NULL),
00052         d_selectCols(DefaultSelectionColour, DefaultSelectionColour, DefaultSelectionColour, DefaultSelectionColour)
00053 {
00054 }
00055 
00056 
00057 /*************************************************************************
00058         Set the selection highlighting brush image.
00059 *************************************************************************/
00060 void ListboxItem::setSelectionBrushImage(const String& imageset, const String& image)
00061 {
00062         setSelectionBrushImage(&ImagesetManager::getSingleton().getImageset(imageset)->getImage(image));
00063 }
00064 
00065 
00066 /*************************************************************************
00067         Return a ColourRect object describing the colours in 'cols' after
00068         having their alpha component modulated by the value 'alpha'.
00069 *************************************************************************/
00070 ColourRect ListboxItem::getModulateAlphaColourRect(const ColourRect& cols, float alpha) const
00071 {
00072         return ColourRect
00073                 (
00074                         calculateModulatedAlphaColour(cols.d_top_left, alpha),
00075                         calculateModulatedAlphaColour(cols.d_top_right, alpha),
00076                         calculateModulatedAlphaColour(cols.d_bottom_left, alpha),
00077                         calculateModulatedAlphaColour(cols.d_bottom_right, alpha)
00078                 );
00079 }
00080 
00081 
00082 /*************************************************************************
00083         Return a colour value describing the colour specified by 'col' after
00084         having its alpha component modulated by the value 'alpha'.
00085 *************************************************************************/
00086 colour ListboxItem::calculateModulatedAlphaColour(colour col, float alpha) const
00087 {
00088         colour temp(col);
00089         temp.setAlpha(temp.getAlpha() * alpha);
00090         return temp;
00091 }
00092 
00093 
00094 /*************************************************************************
00095         Set the colours used for selection highlighting.        
00096 *************************************************************************/
00097 void ListboxItem::setSelectionColours(colour top_left_colour, colour top_right_colour, colour bottom_left_colour, colour bottom_right_colour)
00098 {
00099         d_selectCols.d_top_left         = top_left_colour;
00100         d_selectCols.d_top_right        = top_right_colour;
00101         d_selectCols.d_bottom_left      = bottom_left_colour;
00102         d_selectCols.d_bottom_right     = bottom_right_colour;
00103 }
00104 
00105 } // End of  CEGUI namespace section

Generated on Wed Feb 16 12:41:06 2005 for Crazy Eddies GUI System by  doxygen 1.3.9.1