Main Page   Class Hierarchy   Compound List   File List   Compound Members  

button.h

00001 /*--License:
00002         Kyra Sprite Engine
00003         Copyright Lee Thomason (Grinning Lizard Software) 2001-2002
00004         www.grinninglizard.com/kyra
00005         www.sourceforge.net/projects/kyra
00006 
00007         Kyra is provided under 2 licenses:
00008 
00009         - The GPL, with no additional restrictions.
00010         - The LGPL, provided you display the Kyra splash screen, described below.
00011 
00012 
00013 --- GPL License --
00014         This program is free software; you can redistribute it and/or
00015         modify it under the terms of the GNU General Public License
00016         as published by the Free Software Foundation; either version 2
00017         of the License, or (at your option) any later version.
00018 
00019         This program is distributed in the hope that it will be useful,
00020         but WITHOUT ANY WARRANTY; without even the implied warranty of
00021         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022         GNU General Public License for more details.
00023 
00024         You should have received a copy of the GNU General Public License
00025         along with this program; if not, write to the Free Software
00026         Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00027 
00028         The full text of the license can be found in license.txt
00029 
00030 
00031 --- LGPL License --
00032   **Provided you kindly display the Kyra splash screen (details below), 
00033         you     may use the LGPL license:**
00034 
00035     This library is free software; you can redistribute it and/or
00036     modify it under the terms of the GNU Lesser General Public
00037     License as published by the Free Software Foundation; either
00038     version 2.1 of the License, or (at your option) any later version.
00039 
00040     This library is distributed in the hope that it will be useful,
00041     but WITHOUT ANY WARRANTY; without even the implied warranty of
00042     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00043     Lesser General Public License for more details.
00044 
00045     You should have received a copy of the GNU Lesser General Public
00046     License along with this library; if not, write to the Free Software
00047     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00048 
00049         The full text of the license can be found in lgpl.txt
00050 
00051 
00052 --- Kyra Splash Screen.
00053 
00054         It would be appreciate if you display the Kyra splash screen when using
00055         either license, however it is only required for the LGPL. All the
00056         resources for the splash are compiled into the library, and it can be
00057         accessed through the following API:
00058 
00059                 KrEngine::StartSplash
00060                 KrEngine::UpdateSplash
00061                 KrEngine::EndSplash
00062 
00063         Full documentation is provided with the KrEngine class. The splash screen
00064         should be displayed for 2 seconds.
00065 
00066         Thank you.
00067 */
00068 
00069 #ifndef KYRA_BUTTONWIDGET_INCLUDED
00070 #define KYRA_BUTTONWIDGET_INCLUDED
00071 
00072 #include "../gui/widget.h"
00073 
00077 class KrButton : public KrWidget
00078 {
00079   public:
00080         virtual ~KrButton();
00081 
00083         void SetTextChar( const std::string& text );
00084 
00096         void SetIcon( KrSprite* giveSprite );
00097 
00098         // Used to initialize the widget.
00099         virtual void AddedtoTree();
00100 
00101   protected:
00102         KrButton(       int width, 
00103                                 int height,
00104                                 const KrScheme& scheme );
00105         KrButton(       KrSprite* graphic,
00106                                 const KrScheme& scheme );
00107 
00108 
00109         enum
00110         {
00111                 OVER = 0x01,
00112                 DOWN = 0x02,
00113 
00114                 ICON_DEPTH = 1,
00115                 TEXT_DEPTH = 2,
00116         };
00117         void SetMode( int mode );
00118         void PlaceText();
00119         void PlaceIcon();
00120 
00121         int width, height, mode;
00122                 
00123   private:
00124         KrImNode          *holder;
00125         KrBoxResource *plateRes;
00126         KrBox             *plate;
00127         KrBevelElement bevel;
00128         KrSprite          *icon;
00129         bool                    userDrawn;
00130         int                        iconX, iconY;
00131 
00132         KrTextBox*                textBox;
00133         std::string               text;
00134 };
00135 
00136 
00154 class KrPushButton : public KrButton
00155 {
00156   public:
00158         KrPushButton(   int width, 
00159                                         int height,
00160                                         const KrScheme& scheme ) : KrButton( width, height, scheme )    {}
00161 
00166         KrPushButton(   KrSprite* graphic,
00167                                         const KrScheme& scheme ) : KrButton( graphic, scheme ) {}
00168 
00169         ~KrPushButton() {}
00170 
00171         virtual int  IsMouseListener()                                          { return LEFT_MOUSE; }
00172         virtual void MouseIn( bool down, bool in );
00173         virtual void MouseMove( bool down, int x, int y );
00174         virtual void MouseClick( int down, int x, int y );
00175 
00176         // Not a key listener.
00177         // Not groupable or selectable.
00178 
00179 //      virtual bool CanAccelerate()                                            { return true; }
00180         virtual void Accelerate( bool down );
00181 };
00182 
00183 
00201 class KrToggleButton : public KrButton
00202 {
00203   public:
00205         KrToggleButton( int width, 
00206                                         int height,
00207                                         const KrScheme& scheme ) : KrButton( width, height, scheme )    {}
00208 
00213         KrToggleButton( KrSprite* graphic,
00214                                         const KrScheme& scheme ) : KrButton( graphic, scheme ) {}
00215 
00216         ~KrToggleButton()       {}
00217 
00218         virtual int IsMouseListener()                                           { return LEFT_MOUSE; }
00219         virtual void MouseIn( bool down, bool in );
00220         virtual void MouseMove( bool down, int x, int y );
00221         virtual void MouseClick( int down, int x, int y );
00222 
00223         // Not a key listener.
00224 
00225         virtual bool IsSelectable()                                                     { return true; }
00226         virtual void Selected( bool selected );
00227         virtual void Accelerate( bool down );
00228 };
00229 
00230 
00231 #endif
00232 

Generated on Mon Sep 15 12:01:10 2003 for Kyra by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001