clicklabel.h

00001 /***************************************************************************
00002  *   Copyright (C) 2005-2008 by the FIFE team                              *
00003  *   http://www.fifengine.de                                               *
00004  *   This file is part of FIFE.                                            *
00005  *                                                                         *
00006  *   FIFE is free software; you can redistribute it and/or                 *
00007  *   modify it under the terms of the GNU Lesser General Public            *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2.1 of the License, or (at your option) any later version.    *
00010  *                                                                         *
00011  *   This library is distributed in the hope that it will be useful,       *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00014  *   Lesser General Public License for more details.                       *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Lesser General Public      *
00017  *   License along with this library; if not, write to the                 *
00018  *   Free Software Foundation, Inc.,                                       *
00019  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
00020  ***************************************************************************/
00021 
00022 #ifndef FIFE_GUI_WIDGETS_CLICKLABEL_H
00023 #define FIFE_GUI_WIDGETS_CLICKLABEL_H
00024 
00025 // Standard C++ library includes
00026 #include <string>
00027 
00028 // 3rd party library includes
00029 #include <guichan.hpp>
00030 
00031 // FIFE includes
00032 // These includes are split up in two parts, separated by one empty line
00033 // First block: files included from the FIFE root src directory
00034 // Second block: files included from the same folder
00035 
00036 namespace FIFE {
00037     class GuiFont;
00038 }
00039 
00040 namespace gcn {
00041     
00042     class ClickLabel : public Widget, public MouseListener, public KeyListener, public FocusListener {
00043     public:
00044         ClickLabel();
00045         ClickLabel(const std::string& caption);
00046         virtual ~ClickLabel();
00047 
00048         virtual void setWidth(int width);
00049         virtual void setCaption(const std::string& caption);
00050         virtual const std::string& getCaption() const;
00051 
00052         virtual void draw(Graphics* graphics);
00053 
00054         virtual void adjustSize();
00055 
00056         void setTextWrapping(bool);
00057         bool isTextWrapping() const;
00058 
00059         // Inherited from FocusListener
00060     
00061         virtual void focusLost(const Event& event);
00062     
00063     
00064         // Inherited from MouseListener
00065     
00066         virtual void mousePressed(MouseEvent& mouseEvent);
00067     
00068         virtual void mouseReleased(MouseEvent& mouseEvent);
00069     
00070         virtual void mouseEntered(MouseEvent& mouseEvent);
00071     
00072         virtual void mouseExited(MouseEvent& mouseEvent);
00073     
00074         virtual void mouseDragged(MouseEvent& mouseEvent);
00075     
00076     
00077         // Inherited from KeyListener
00078     
00079         virtual void keyPressed(KeyEvent& keyEvent);
00080     
00081         virtual void keyReleased(KeyEvent& keyEvent);
00082 
00083     protected:
00084         void wrapText();
00085 
00086         FIFE::GuiFont* mGuiFont;
00087         bool mTextWrapping;
00088         std::string mCaption;
00089         std::string mWrappedText;
00090 
00091         bool mHasMouse;
00092         bool mKeyPressed;
00093         bool mMousePressed;
00094     };
00095 }
00096 
00097 #endif
00098 /* vim: set noexpandtab: set shiftwidth=2: set tabstop=2: */
Generated on Wed Nov 23 13:04:43 2011 for FIFE by  doxygen 1.6.3