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

CEGUITabButton.cpp

Go to the documentation of this file.
00001 /************************************************************************
00002         filename:       CEGUITabButton.cpp
00003         created:        8/8/2004
00004         author:         Steve Streeting
00005         
00006         purpose:        Implementation of TabButton widget 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 "elements/CEGUITabButton.h"
00027 
00028 // Start of CEGUI namespace section
00029 namespace CEGUI
00030 {
00031 const String TabButton::EventNamespace("TabButton");
00032 
00033 /*************************************************************************
00034         Event name constants
00035 *************************************************************************/
00036 const String TabButton::EventClicked( (utf8*)"Clicked" );
00037 
00038 
00039 /*************************************************************************
00040         Constructor
00041 *************************************************************************/
00042 TabButton::TabButton(const String& type, const String& name) :
00043         ButtonBase(type, name),
00044     d_selected(false), 
00045     d_rightOfSelected(true)
00046 {
00047         // add the additional events generated by this derived class
00048         addTabButtonEvents();
00049 }
00050 
00051 
00052 /*************************************************************************
00053         Destructor
00054 *************************************************************************/
00055 TabButton::~TabButton(void)
00056 {
00057 }
00058 
00059 
00060 /*************************************************************************
00061         Add button specific events      
00062 *************************************************************************/
00063 void TabButton::addTabButtonEvents(void)
00064 {
00065         addEvent(EventClicked);
00066 }
00067 
00068 
00069 /*************************************************************************
00070         handler invoked internally when the button is clicked.  
00071 *************************************************************************/
00072 void TabButton::onClicked(WindowEventArgs& e)
00073 {
00074         fireEvent(EventClicked, e, EventNamespace);
00075 }
00076 
00077 
00078 /*************************************************************************
00079         Handler for mouse button release events
00080 *************************************************************************/
00081 void TabButton::onMouseButtonUp(MouseEventArgs& e)
00082 {
00083         if ((e.button == LeftButton) && isPushed())
00084         {
00085                 Window* sheet = System::getSingleton().getGUISheet();
00086 
00087                 if (sheet != NULL)
00088                 {
00089                         // if mouse was released over this widget
00090                         if (this == sheet->getChildAtPosition(e.position))
00091                         {
00092                                 // fire event
00093                                 WindowEventArgs args(this);
00094                                 onClicked(args);
00095                         }
00096 
00097                 }
00098 
00099                 e.handled = true;
00100         }
00101 
00102         // default handling
00103         ButtonBase::onMouseButtonUp(e);
00104 }
00105 /*************************************************************************
00106 Draw method
00107 *************************************************************************/
00108 void TabButton::drawSelf(float z)
00109 {
00110         if (isDisabled())
00111         {
00112                 drawDisabled(z);
00113         }
00114         else if (isHovering())
00115         {
00116                 drawHover(z);
00117         }
00118     else if (d_selected)
00119     {
00120         drawPushed(z);
00121     }
00122     else
00123     {
00124         drawNormal(z);
00125     }
00126 }
00127 /*************************************************************************
00128 Set target window
00129 *************************************************************************/
00130 void TabButton::setTargetWindow(Window* wnd)
00131 {
00132     d_targetWindow = wnd;
00133     // Copy initial text
00134     setText(wnd->getText());
00135     // Parent control will keep text up to date, since changes affect layout
00136 }
00137 
00138 } // End of  CEGUI namespace section

Generated on Wed Sep 7 09:56:34 2005 for Crazy Eddies GUI System by  doxygen 1.4.3