2015-09-25 21:37:19 +02:00
|
|
|
// File: flabel.h
|
|
|
|
// Provides: class FLabel
|
|
|
|
//
|
|
|
|
// Inheritance diagram
|
|
|
|
// ═══════════════════
|
|
|
|
//
|
|
|
|
// ▕▔▔▔▔▔▔▔▔▔▏ ▕▔▔▔▔▔▔▔▔▔▏
|
|
|
|
// ▕ FObject ▏ ▕ FTerm ▏
|
|
|
|
// ▕▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▁▁▏
|
|
|
|
// ▲ ▲
|
|
|
|
// │ │
|
|
|
|
// └─────┬─────┘
|
|
|
|
// │
|
2016-10-11 04:57:36 +02:00
|
|
|
// ▕▔▔▔▔▔▔▔▔▏
|
|
|
|
// ▕ FVTerm ▏
|
|
|
|
// ▕▁▁▁▁▁▁▁▁▏
|
|
|
|
// ▲
|
|
|
|
// │
|
2015-09-25 21:37:19 +02:00
|
|
|
// ▕▔▔▔▔▔▔▔▔▔▏
|
|
|
|
// ▕ FWidget ▏
|
|
|
|
// ▕▁▁▁▁▁▁▁▁▁▏
|
|
|
|
// ▲
|
|
|
|
// │
|
|
|
|
// ▕▔▔▔▔▔▔▔▔▏
|
|
|
|
// ▕ FLabel ▏
|
|
|
|
// ▕▁▁▁▁▁▁▁▁▏
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-04-09 20:08:53 +02:00
|
|
|
#ifndef FLABEL_H
|
|
|
|
#define FLABEL_H
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
#include <vector>
|
2017-09-17 21:32:46 +02:00
|
|
|
|
|
|
|
#include "final/fwidget.h"
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2015-09-25 21:37:19 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FLabel
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
#pragma pack(push)
|
|
|
|
#pragma pack(1)
|
|
|
|
|
|
|
|
class FLabel : public FWidget
|
|
|
|
{
|
2017-09-11 03:06:02 +02:00
|
|
|
public:
|
|
|
|
// Using-declaration
|
|
|
|
using FWidget::setEnable;
|
|
|
|
|
|
|
|
// Constructor
|
|
|
|
explicit FLabel (FWidget* = 0);
|
|
|
|
FLabel (const FString&, FWidget* = 0);
|
|
|
|
|
|
|
|
// Destructor
|
|
|
|
virtual ~FLabel();
|
|
|
|
|
2017-09-20 05:44:41 +02:00
|
|
|
// Overloaded operators
|
|
|
|
FLabel& operator = (const FString&);
|
|
|
|
FLabel& operator << (const FString&);
|
|
|
|
FLabel& operator << (const wchar_t);
|
|
|
|
FLabel& operator << (const uInt);
|
|
|
|
FLabel& operator << (const int);
|
|
|
|
FLabel& operator << (const uLong);
|
|
|
|
FLabel& operator << (const long);
|
|
|
|
FLabel& operator << (const float);
|
|
|
|
FLabel& operator << (const double);
|
|
|
|
FLabel& operator << (const lDouble);
|
|
|
|
const FLabel& operator >> (FString&);
|
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
// Accessors
|
|
|
|
const char* getClassName() const;
|
|
|
|
FTerm* getAccelWidget();
|
|
|
|
fc::text_alignment getAlignment();
|
|
|
|
FString& getText();
|
|
|
|
|
|
|
|
// Mutators
|
|
|
|
void setAccelWidget (FWidget* = 0);
|
|
|
|
void setAlignment(fc::text_alignment);
|
|
|
|
bool setEmphasis(bool);
|
|
|
|
bool setEmphasis();
|
|
|
|
bool unsetEmphasis();
|
|
|
|
bool setReverseMode(bool);
|
|
|
|
bool setReverseMode();
|
|
|
|
bool unsetReverseMode();
|
|
|
|
bool setEnable (bool);
|
2017-09-20 05:44:41 +02:00
|
|
|
void setNumber (uLong);
|
|
|
|
void setNumber (long);
|
|
|
|
void setNumber (float, int = FLT_DIG);
|
|
|
|
void setNumber (double, int = DBL_DIG);
|
|
|
|
void setNumber (lDouble, int = LDBL_DIG);
|
2017-09-11 03:06:02 +02:00
|
|
|
void setText (const FString&);
|
|
|
|
|
|
|
|
// Inquiries
|
|
|
|
bool hasEmphasis();
|
|
|
|
bool hasReverseMode();
|
|
|
|
|
|
|
|
// Methods
|
|
|
|
void hide();
|
2017-09-20 05:44:41 +02:00
|
|
|
void clear();
|
2017-09-11 03:06:02 +02:00
|
|
|
|
|
|
|
// Event handlers
|
|
|
|
void onMouseDown (FMouseEvent*);
|
|
|
|
void onAccel (FAccelEvent*);
|
|
|
|
|
|
|
|
// Callback method
|
|
|
|
void cb_accel_widget_destroyed (FWidget*, data_ptr);
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Disable copy constructor
|
|
|
|
FLabel (const FLabel&);
|
|
|
|
|
|
|
|
// Disable assignment operator (=)
|
|
|
|
FLabel& operator = (const FLabel&);
|
|
|
|
|
|
|
|
// Methods
|
|
|
|
void init();
|
|
|
|
uChar getHotkey();
|
|
|
|
int getHotkeyPos (wchar_t*&, wchar_t*&, uInt);
|
|
|
|
void setHotkeyAccelerator();
|
|
|
|
int getAlignOffset (int);
|
|
|
|
void printLine (wchar_t*&, uInt, int, int = 0);
|
|
|
|
void draw();
|
|
|
|
|
|
|
|
// Data Members
|
2017-09-20 16:56:20 +02:00
|
|
|
FStringList multiline_text;
|
2017-09-11 03:06:02 +02:00
|
|
|
bool multiline;
|
|
|
|
FString text;
|
|
|
|
fc::text_alignment alignment;
|
|
|
|
short emphasis_color;
|
|
|
|
short ellipsis_color;
|
|
|
|
bool emphasis;
|
|
|
|
bool reverse_mode;
|
|
|
|
FWidget* accel_widget;
|
2015-05-23 13:35:12 +02:00
|
|
|
};
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
|
|
|
|
// FLabel inline functions
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline const char* FLabel::getClassName() const
|
|
|
|
{ return "FLabel"; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline FTerm* FLabel::getAccelWidget ()
|
|
|
|
{ return accel_widget; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2017-07-23 01:19:59 +02:00
|
|
|
inline fc::text_alignment FLabel::getAlignment()
|
2015-05-23 13:35:12 +02:00
|
|
|
{ return alignment; }
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline FString& FLabel::getText()
|
|
|
|
{ return text; }
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FLabel::setEmphasis()
|
|
|
|
{ return setEmphasis(true); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FLabel::unsetEmphasis()
|
|
|
|
{ return setEmphasis(false); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FLabel::setReverseMode()
|
|
|
|
{ return setReverseMode(true); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FLabel::unsetReverseMode()
|
|
|
|
{ return setReverseMode(false); }
|
|
|
|
|
2017-09-20 05:44:41 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FLabel::setNumber (uLong num)
|
|
|
|
{ setText(FString().setNumber(num)); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FLabel::setNumber (long num)
|
|
|
|
{ setText(FString().setNumber(num)); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FLabel::setNumber (float num, int precision)
|
|
|
|
{ setText(FString().setNumber(num, precision)); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FLabel::setNumber (double num, int precision)
|
|
|
|
{ setText(FString().setNumber(num, precision)); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FLabel::setNumber (lDouble num, int precision)
|
|
|
|
{ setText(FString().setNumber(num, precision)); }
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
inline bool FLabel::hasEmphasis()
|
|
|
|
{ return emphasis; }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
inline bool FLabel::hasReverseMode()
|
|
|
|
{ return reverse_mode; }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-09-20 05:44:41 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FLabel::clear()
|
|
|
|
{ text.clear(); }
|
|
|
|
|
2017-04-09 20:08:53 +02:00
|
|
|
#endif // FLABEL_H
|