2015-09-25 21:37:19 +02:00
|
|
|
// File: fbutton.h
|
|
|
|
// Provides: class FButton
|
|
|
|
//
|
|
|
|
// Inheritance diagram
|
|
|
|
// ═══════════════════
|
|
|
|
//
|
|
|
|
// ▕▔▔▔▔▔▔▔▔▔▏ ▕▔▔▔▔▔▔▔▔▔▏
|
|
|
|
// ▕ FObject ▏ ▕ FTerm ▏
|
|
|
|
// ▕▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▁▁▏
|
|
|
|
// ▲ ▲
|
|
|
|
// │ │
|
|
|
|
// └─────┬─────┘
|
|
|
|
// │
|
2016-10-11 04:57:36 +02:00
|
|
|
// ▕▔▔▔▔▔▔▔▔▏
|
|
|
|
// ▕ FVTerm ▏
|
|
|
|
// ▕▁▁▁▁▁▁▁▁▏
|
|
|
|
// ▲
|
|
|
|
// │
|
2015-09-25 21:37:19 +02:00
|
|
|
// ▕▔▔▔▔▔▔▔▔▔▏
|
|
|
|
// ▕ FWidget ▏
|
|
|
|
// ▕▁▁▁▁▁▁▁▁▁▏
|
|
|
|
// ▲
|
|
|
|
// │
|
|
|
|
// ▕▔▔▔▔▔▔▔▔▔▏
|
|
|
|
// ▕ FButton ▏
|
|
|
|
// ▕▁▁▁▁▁▁▁▁▁▏
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
#ifndef _FBUTTON_H
|
|
|
|
#define _FBUTTON_H
|
|
|
|
|
|
|
|
#include "fwidget.h"
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FButton
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
#pragma pack(push)
|
|
|
|
#pragma pack(1)
|
|
|
|
|
|
|
|
class FButton : public FWidget
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
FString text;
|
2016-09-27 00:46:05 +02:00
|
|
|
bool button_down;
|
|
|
|
bool click_animation;
|
|
|
|
int click_time;
|
|
|
|
short button_fg;
|
|
|
|
short button_bg;
|
|
|
|
short button_hotkey_fg;
|
|
|
|
short button_focus_fg;
|
|
|
|
short button_focus_bg;
|
|
|
|
short button_inactive_fg;
|
|
|
|
short button_inactive_bg;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
private:
|
2016-09-30 04:55:28 +02:00
|
|
|
// Disable copy constructor
|
2015-05-23 13:35:12 +02:00
|
|
|
FButton (const FButton&);
|
2016-09-30 04:55:28 +02:00
|
|
|
// Disable assignment operator (=)
|
2015-05-23 13:35:12 +02:00
|
|
|
FButton& operator = (const FButton&);
|
2016-09-30 04:55:28 +02:00
|
|
|
|
2015-06-19 19:53:30 +02:00
|
|
|
void init();
|
|
|
|
uChar getHotkey();
|
|
|
|
void setHotkeyAccelerator();
|
2015-09-22 04:18:20 +02:00
|
|
|
void detectHotkey();
|
2015-06-19 19:53:30 +02:00
|
|
|
void draw();
|
|
|
|
void updateButtonColor();
|
|
|
|
void processClick();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
public:
|
2016-09-30 04:55:28 +02:00
|
|
|
// Constructors
|
|
|
|
explicit FButton (FWidget* = 0);
|
|
|
|
FButton (const FString&, FWidget* = 0);
|
|
|
|
// Destructor
|
|
|
|
virtual ~FButton();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2015-06-19 19:53:30 +02:00
|
|
|
const char* getClassName() const;
|
2016-01-08 01:00:05 +01:00
|
|
|
void setForegroundColor (short);
|
|
|
|
void setBackgroundColor (short);
|
|
|
|
void setHotkeyForegroundColor (short);
|
|
|
|
void setFocusForegroundColor (short);
|
|
|
|
void setFocusBackgroundColor (short);
|
|
|
|
void setInactiveForegroundColor (short);
|
|
|
|
void setInactiveBackgroundColor (short);
|
2015-06-19 19:53:30 +02:00
|
|
|
void hide();
|
|
|
|
|
2016-09-30 04:55:28 +02:00
|
|
|
// Event handlers
|
2015-06-19 19:53:30 +02:00
|
|
|
void onKeyPress (FKeyEvent*);
|
|
|
|
void onMouseDown (FMouseEvent*);
|
|
|
|
void onMouseUp (FMouseEvent*);
|
|
|
|
void onMouseMove (FMouseEvent*);
|
2015-07-01 22:34:40 +02:00
|
|
|
void onTimer (FTimerEvent*);
|
2015-06-19 19:53:30 +02:00
|
|
|
void onAccel (FAccelEvent*);
|
|
|
|
void onFocusIn (FFocusEvent*);
|
|
|
|
void onFocusOut (FFocusEvent*);
|
|
|
|
|
|
|
|
bool setNoUnderline(bool);
|
|
|
|
bool setNoUnderline();
|
|
|
|
bool unsetNoUnderline();
|
|
|
|
bool setEnable(bool);
|
|
|
|
bool setEnable();
|
|
|
|
bool unsetEnable();
|
|
|
|
bool setDisable();
|
|
|
|
bool setFocus(bool);
|
|
|
|
bool setFocus();
|
|
|
|
bool unsetFocus();
|
|
|
|
bool setFlat(bool);
|
|
|
|
bool setFlat();
|
|
|
|
bool unsetFlat();
|
|
|
|
bool isFlat() const;
|
|
|
|
bool setShadow(bool);
|
|
|
|
bool setShadow();
|
|
|
|
bool unsetShadow();
|
|
|
|
bool hasShadow() const;
|
|
|
|
bool setDown(bool);
|
|
|
|
bool setDown();
|
|
|
|
bool setUp();
|
|
|
|
bool isDown() const;
|
|
|
|
bool setClickAnimation(bool);
|
|
|
|
bool setClickAnimation();
|
|
|
|
bool unsetClickAnimation();
|
|
|
|
bool hasClickAnimation();
|
|
|
|
|
|
|
|
void setText (const FString&);
|
|
|
|
FString& getText();
|
2015-05-23 13:35:12 +02:00
|
|
|
};
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
|
|
|
|
// FButton inline functions
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline const char* FButton::getClassName() const
|
|
|
|
{ return "FButton"; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FButton::setNoUnderline()
|
|
|
|
{ return setNoUnderline(true); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FButton::unsetNoUnderline()
|
|
|
|
{ return setNoUnderline(false); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FButton::setEnable()
|
|
|
|
{ return setEnable(true); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FButton::unsetEnable()
|
|
|
|
{ return setEnable(false); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FButton::setDisable()
|
|
|
|
{ return setEnable(false); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FButton::setFocus()
|
|
|
|
{ return setFocus(true); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FButton::unsetFocus()
|
|
|
|
{ return setFocus(false); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FButton::setFlat()
|
|
|
|
{ return setFlat(true); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FButton::unsetFlat()
|
|
|
|
{ return setFlat(false); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FButton::isFlat() const
|
2016-01-24 14:53:09 +01:00
|
|
|
{ return ((flags & fc::flat) != 0); }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FButton::setShadow()
|
|
|
|
{ return setShadow(true); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FButton::unsetShadow()
|
|
|
|
{ return setShadow(false); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FButton::hasShadow() const
|
2016-01-24 14:53:09 +01:00
|
|
|
{ return ((flags & fc::shadow) != 0); }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FButton::setDown()
|
|
|
|
{ return setDown(true); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FButton::setUp()
|
|
|
|
{ return setDown(false); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FButton::isDown() const
|
|
|
|
{ return button_down; }
|
|
|
|
|
2015-06-15 22:04:27 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FButton::setClickAnimation(bool on)
|
|
|
|
{ return click_animation = on; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FButton::setClickAnimation()
|
|
|
|
{ return setClickAnimation(true); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FButton::unsetClickAnimation()
|
|
|
|
{ return setClickAnimation(false); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FButton::hasClickAnimation()
|
|
|
|
{ return click_animation; }
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline FString& FButton::getText()
|
2015-09-22 04:18:20 +02:00
|
|
|
{ return text; }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
#endif // _FBUTTON_H
|