- Your Widget Set For OpenGL
Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | Related Pages

ubutton.hpp

00001 /*************************************************************************** 00002 LibUFO - UI For OpenGL 00003 copyright : (C) 2001-2005 by Johannes Schmidt 00004 email : schmidtjf at users.sourceforge.net 00005 ------------------- 00006 00007 file : include/ufo/widgets/ubutton.hpp 00008 begin : Mon May 28 2001 00009 $Id: ubutton.hpp,v 1.17 2005/06/21 09:27:23 schmidtjf Exp $ 00010 ***************************************************************************/ 00011 00012 /*************************************************************************** 00013 * This library is free software; you can redistribute it and/or * 00014 * modify it under the terms of the GNU Lesser General Public * 00015 * License as published by the Free Software Foundation; either * 00016 * version 2.1 of the License, or (at your option) any later version. * 00017 * * 00018 * This library is distributed in the hope that it will be useful, * 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00021 * Lesser General Public License for more details. * 00022 * * 00023 * You should have received a copy of the GNU Lesser General Public * 00024 * License along with this library; if not, write to the Free Software * 00025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 00026 ***************************************************************************/ 00027 00028 #ifndef UBUTTON_HPP 00029 #define UBUTTON_HPP 00030 00031 #include "ucompound.hpp" 00032 #include "../events/ukeysym.hpp" 00033 #include "../ukeystroke.hpp" 00034 00035 namespace ufo { 00036 class UButtonGroup; 00037 00046 class UFO_EXPORT UButton : public UCompound { 00047 UFO_DECLARE_DYNAMIC_CLASS(UButton) 00048 UFO_UI_CLASS(UButtonUI) 00049 UFO_STYLE_TYPE(UStyle::CE_Button) 00050 public: 00051 UButton(); 00052 UButton(UIcon * icon); 00053 UButton(const std::string & text, UIcon * icon = NULL); 00054 00055 public: // Public methods 00059 virtual void doClick(); 00060 00066 virtual void doClick(int millis); 00067 00076 virtual bool isSelected() const ; 00077 00081 virtual void setSelected(bool b); 00082 00087 bool isPressed() const; 00088 00093 void setPressed(bool b); 00094 00098 bool isRolloverEnabled() const ; 00099 00103 void setRolloverEnabled(bool b); 00104 00109 bool isRollover() const; 00110 00114 bool isToggable() const ; 00115 00119 void setToggable(bool b); 00120 00125 virtual std::string getActionCommand() const; 00126 00133 virtual void setActionCommand(const std::string & actionCommand); 00134 00135 // 00136 // icons 00137 // 00140 void setPressedIcon(UIcon * icon); 00143 UIcon * getPressedIcon() const; 00146 void setRolloverIcon(UIcon * icon); 00149 UIcon * getRolloverIcon() const; 00150 00155 void setAccelerator(const UKeyStroke & stroke); 00156 UKeyStroke getAccelerator() const; 00157 00160 int getAcceleratorIndex() const; 00161 00165 void setButtonGroup(UButtonGroup * buttonGroup); 00166 UButtonGroup * getButtonGroup() const; 00167 00169 virtual void activate(); 00170 00171 public: // Overrides UWidget 00172 virtual bool isActive() const; 00173 00174 public: // Overrides UCompound 00175 virtual UIcon * getIcon() const; 00176 virtual void setText(const std::string & text); 00177 00178 00179 protected: // Protected slots 00180 void fireActionEvent(); 00182 void buttonUp(); 00183 00184 protected: // Overrides UWidget 00185 virtual UDimension getContentsSize(const UDimension & maxSize) const; 00186 virtual void processKeyEvent(UKeyEvent * e); 00187 virtual void processMouseEvent(UMouseEvent * e); 00188 virtual void processShortcutEvent(UShortcutEvent * e); 00189 00190 private: // Private attributes 00192 UIcon * m_pressedIcon; 00194 UIcon * m_rolloverIcon; 00195 00199 std::string m_actionCommand; 00200 00201 UButtonGroup * m_buttonGroup; 00202 00204 UKeyStroke m_accelerator; 00205 int m_acceleratorIndex; 00206 00207 public: // Public signal methods 00210 USignal1<UActionEvent*> & sigActivated() { return m_sigActivated; } 00211 00215 USignal1<UActionEvent*> & sigHighlighted() { return m_sigHighlighted; } 00216 00217 private: // Private signals 00218 USignal1<UActionEvent*> m_sigActivated; 00219 USignal1<UActionEvent*> m_sigHighlighted; 00220 }; 00221 00222 00223 // 00224 // inline implementation 00225 // 00226 00227 inline UIcon * 00228 UButton::getPressedIcon() const { 00229 return m_pressedIcon; 00230 } 00231 00232 inline UIcon * 00233 UButton::getRolloverIcon() const { 00234 return m_rolloverIcon; 00235 } 00236 00237 } // namespace ufo 00238 00239 #endif // UBUTTON_HPP

The libUFO Project - written by Johannes Schmidt