00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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:
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
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:
00172
virtual bool isActive()
const;
00173
00174
public:
00175
virtual UIcon * getIcon()
const;
00176
virtual void setText(
const std::string & text);
00177
00178
00179
protected:
00180
void fireActionEvent();
00182
void buttonUp();
00183
00184
protected:
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:
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:
00210 USignal1<UActionEvent*> & sigActivated() {
return m_sigActivated; }
00211
00215 USignal1<UActionEvent*> & sigHighlighted() {
return m_sigHighlighted; }
00216
00217
private:
00218 USignal1<UActionEvent*> m_sigActivated;
00219 USignal1<UActionEvent*> m_sigHighlighted;
00220 };
00221
00222
00223
00224
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 }
00238
00239
#endif // UBUTTON_HPP