00001 /************************************************************************ 00002 filename: CEGUIRenderableElement.cpp 00003 created: 14/4/2004 00004 author: Paul D Turner 00005 00006 purpose: Implements RenderableElement base class 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 "CEGUIRenderableElement.h" 00027 00028 // Start of CEGUI namespace section 00029 namespace CEGUI 00030 { 00031 00032 /************************************************************************* 00033 Constructor 00034 *************************************************************************/ 00035 RenderableElement::RenderableElement(void) : 00036 d_next(NULL), 00037 d_colours(colour(1, 1, 1, 1)), 00038 d_area(0, 0, 0, 0), 00039 d_useColoursPerImage(false) 00040 { 00041 } 00042 00043 00044 /************************************************************************* 00045 Destructor 00046 *************************************************************************/ 00047 RenderableElement::~RenderableElement(void) 00048 { 00049 } 00050 00051 00052 /************************************************************************* 00053 Sets the colours to be applied when rendering the element. 00054 *************************************************************************/ 00055 void RenderableElement::setColours(const colour& top_left_colour, const colour& top_right_colour, const colour& bottom_left_colour, const colour& bottom_right_colour) 00056 { 00057 d_colours.d_top_left = top_left_colour; 00058 d_colours.d_top_right = top_right_colour; 00059 d_colours.d_bottom_left = bottom_left_colour; 00060 d_colours.d_bottom_right = bottom_right_colour; 00061 } 00062 00063 00064 /************************************************************************* 00065 Draw the element chain starting with this element. 00066 *************************************************************************/ 00067 void RenderableElement::draw(const Vector3& position, const Rect& clip_rect) 00068 { 00069 Vector3 final_pos(position); 00070 final_pos.d_x += d_area.d_left; 00071 final_pos.d_y += d_area.d_top; 00072 00073 // call implementation function to perform actual rendering 00074 draw_impl(final_pos, clip_rect); 00075 00076 // render next element in the chain if any. 00077 if (d_next != NULL) 00078 { 00079 d_next->draw(position, clip_rect); 00080 } 00081 00082 } 00083 00084 void RenderableElement::draw(RenderCache& renderCache) const 00085 { 00086 draw_impl(renderCache); 00087 00088 // also draw next element in the chain 00089 if (d_next) 00090 { 00091 d_next->draw(renderCache); 00092 } 00093 } 00094 00095 } // End of CEGUI namespace section