2015-09-25 21:37:19 +02:00
|
|
|
// File: ftogglebutton.h
|
2016-10-01 23:18:49 +02:00
|
|
|
// Provides: class FToggleButton
|
2015-09-25 21:37:19 +02:00
|
|
|
//
|
|
|
|
// Inheritance diagram
|
|
|
|
// ═══════════════════
|
|
|
|
//
|
|
|
|
// ▕▔▔▔▔▔▔▔▔▔▏ ▕▔▔▔▔▔▔▔▔▔▏
|
|
|
|
// ▕ FObject ▏ ▕ FTerm ▏
|
|
|
|
// ▕▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▁▁▏
|
|
|
|
// ▲ ▲
|
|
|
|
// │ │
|
|
|
|
// └─────┬─────┘
|
|
|
|
// │
|
2016-10-11 04:57:36 +02:00
|
|
|
// ▕▔▔▔▔▔▔▔▔▏
|
|
|
|
// ▕ FVTerm ▏
|
|
|
|
// ▕▁▁▁▁▁▁▁▁▏
|
|
|
|
// ▲
|
|
|
|
// │
|
2015-09-25 21:37:19 +02:00
|
|
|
// ▕▔▔▔▔▔▔▔▔▔▏
|
|
|
|
// ▕ FWidget ▏
|
|
|
|
// ▕▁▁▁▁▁▁▁▁▁▏
|
|
|
|
// ▲
|
|
|
|
// │
|
|
|
|
// ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏
|
|
|
|
// ▕ FToggleButton ▏
|
|
|
|
// ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-04-09 20:08:53 +02:00
|
|
|
#ifndef FTOGGLEBUTTON_H
|
|
|
|
#define FTOGGLEBUTTON_H
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
#include "fwidget.h"
|
|
|
|
|
|
|
|
|
2016-10-01 23:18:49 +02:00
|
|
|
// class forward declaration
|
2015-05-23 13:35:12 +02:00
|
|
|
class FButtonGroup;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2015-09-22 04:18:20 +02:00
|
|
|
// class FToggleButton - abstract class for FRadioButton, FCheckBox, ...
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
#pragma pack(push)
|
|
|
|
#pragma pack(1)
|
|
|
|
|
|
|
|
class FToggleButton : public FWidget
|
|
|
|
{
|
2016-11-02 00:37:58 +01:00
|
|
|
public:
|
|
|
|
// Using-declaration
|
|
|
|
using FWidget::setGeometry;
|
|
|
|
|
|
|
|
// Constructors
|
|
|
|
explicit FToggleButton (FWidget* = 0);
|
|
|
|
FToggleButton (const FString&, FWidget* = 0);
|
|
|
|
|
|
|
|
// Destructor
|
|
|
|
virtual ~FToggleButton();
|
|
|
|
|
|
|
|
// Accessors
|
|
|
|
virtual const char* getClassName() const;
|
|
|
|
FString& getText();
|
|
|
|
|
|
|
|
// Mutators
|
|
|
|
void setGeometry (int, int, int, int, bool = true);
|
|
|
|
bool setNoUnderline (bool);
|
|
|
|
bool setNoUnderline();
|
|
|
|
bool unsetNoUnderline();
|
|
|
|
bool setEnable (bool);
|
|
|
|
bool setEnable();
|
|
|
|
bool unsetEnable();
|
|
|
|
bool setDisable();
|
|
|
|
bool setFocus (bool);
|
|
|
|
bool setFocus();
|
|
|
|
bool unsetFocus();
|
|
|
|
bool setChecked (bool);
|
|
|
|
bool setChecked();
|
|
|
|
bool unsetChecked();
|
2017-03-26 20:40:04 +02:00
|
|
|
virtual void setText (const FString&);
|
2016-11-02 00:37:58 +01:00
|
|
|
|
|
|
|
// Inquiries
|
|
|
|
bool isChecked();
|
|
|
|
|
|
|
|
// Methods
|
|
|
|
void hide();
|
|
|
|
|
|
|
|
// Event handlers
|
|
|
|
void onMouseDown (FMouseEvent*);
|
|
|
|
void onMouseUp (FMouseEvent*);
|
2017-03-12 00:29:56 +01:00
|
|
|
void onWheel (FWheelEvent*);
|
2016-11-02 00:37:58 +01:00
|
|
|
void onAccel (FAccelEvent*);
|
|
|
|
void onFocusIn (FFocusEvent*);
|
|
|
|
void onFocusOut (FFocusEvent*);
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
protected:
|
2016-11-02 00:37:58 +01:00
|
|
|
// Accessor
|
|
|
|
uChar getHotkey();
|
|
|
|
FButtonGroup* getGroup() const;
|
|
|
|
|
|
|
|
// Mutator
|
|
|
|
void setHotkeyAccelerator();
|
|
|
|
|
|
|
|
// Inquiries
|
|
|
|
bool isRadioButton() const;
|
|
|
|
bool isCheckboxButton() const;
|
2017-03-12 00:29:56 +01:00
|
|
|
bool hasGroup() const;
|
2016-11-02 00:37:58 +01:00
|
|
|
|
|
|
|
// Methods
|
|
|
|
virtual void draw();
|
|
|
|
void drawLabel();
|
|
|
|
void processClick();
|
|
|
|
void processToggle();
|
|
|
|
|
|
|
|
// Event handler
|
|
|
|
virtual void onKeyPress (FKeyEvent*);
|
|
|
|
|
|
|
|
// Data Members
|
2016-09-27 00:46:05 +02:00
|
|
|
bool checked;
|
|
|
|
int label_offset_pos;
|
|
|
|
int button_width; // plus margin spaces
|
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
|
|
|
FToggleButton (const FToggleButton&);
|
2016-11-02 00:37:58 +01:00
|
|
|
|
2016-09-30 04:55:28 +02:00
|
|
|
// Disable assignment operator (=)
|
2015-05-23 13:35:12 +02:00
|
|
|
FToggleButton& operator = (const FToggleButton&);
|
2016-09-30 04:55:28 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
// Mutator
|
|
|
|
void setGroup (FButtonGroup*);
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
// Methods
|
|
|
|
void init();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
// Friend classes
|
|
|
|
friend class FButtonGroup;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
// Data Members
|
|
|
|
FButtonGroup* button_group;
|
|
|
|
bool focus_inside_group;
|
|
|
|
FString text;
|
2015-05-23 13:35:12 +02:00
|
|
|
};
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
|
|
|
|
// FRadioButton inline functions
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline const char* FToggleButton::getClassName() const
|
|
|
|
{ return "FToggleButton"; }
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline FString& FToggleButton::getText()
|
|
|
|
{ return text; }
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FToggleButton::setNoUnderline()
|
|
|
|
{ return setNoUnderline(true); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FToggleButton::unsetNoUnderline()
|
|
|
|
{ return setNoUnderline(false); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FToggleButton::setEnable()
|
|
|
|
{ return setEnable(true); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FToggleButton::unsetEnable()
|
|
|
|
{ return setEnable(false); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FToggleButton::setDisable()
|
|
|
|
{ return setEnable(false); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FToggleButton::setFocus()
|
|
|
|
{ return setFocus(true); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FToggleButton::unsetFocus()
|
|
|
|
{ return setFocus(false); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FToggleButton::setChecked()
|
|
|
|
{ return setChecked(true); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FToggleButton::unsetChecked()
|
|
|
|
{ return setChecked(false); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FToggleButton::isChecked()
|
|
|
|
{ return checked; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
inline FButtonGroup* FToggleButton::getGroup() const
|
|
|
|
{ return button_group; }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-03-12 00:29:56 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FToggleButton::hasGroup() const
|
|
|
|
{ return button_group; }
|
|
|
|
|
2017-04-09 20:08:53 +02:00
|
|
|
#endif // FTOGGLEBUTTON_H
|