2015-09-25 21:37:19 +02:00
|
|
|
// File: fstatusbar.h
|
|
|
|
// Provides: class FStatusKey
|
|
|
|
// class FStatusBar
|
|
|
|
//
|
|
|
|
// Inheritance diagram
|
|
|
|
// ═══════════════════
|
|
|
|
//
|
|
|
|
// ▕▔▔▔▔▔▔▔▔▔▏ ▕▔▔▔▔▔▔▔▔▔▏
|
|
|
|
// ▕ FObject ▏ ▕ FTerm ▏
|
|
|
|
// ▕▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▁▁▏
|
|
|
|
// ▲ ▲
|
|
|
|
// │ │
|
|
|
|
// └─────┬─────┘
|
|
|
|
// │
|
2016-10-11 04:57:36 +02:00
|
|
|
// ▕▔▔▔▔▔▔▔▔▏
|
|
|
|
// ▕ FVTerm ▏
|
|
|
|
// ▕▁▁▁▁▁▁▁▁▏
|
|
|
|
// ▲
|
|
|
|
// │
|
2015-09-25 21:37:19 +02:00
|
|
|
// ▕▔▔▔▔▔▔▔▔▔▏
|
|
|
|
// ▕ FWidget ▏
|
|
|
|
// ▕▁▁▁▁▁▁▁▁▁▏
|
|
|
|
// ▲
|
|
|
|
// │
|
|
|
|
// ├────────────────────┐
|
|
|
|
// │ │
|
|
|
|
// ▕▔▔▔▔▔▔▔▔▔▏ │
|
|
|
|
// ▕ FWindow ▏ │
|
|
|
|
// ▕▁▁▁▁▁▁▁▁▁▏ │
|
|
|
|
// ▲ │
|
|
|
|
// │ │
|
|
|
|
// ▕▔▔▔▔▔▔▔▔▔▔▔▔▏1 *▕▔▔▔▔▔▔▔▔▔▔▔▔▏
|
|
|
|
// ▕ FStatusBar ▏- - - -▕ FStatusKey ▏
|
|
|
|
// ▕▁▁▁▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▁▁▁▁▁▏
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-04-09 20:08:53 +02:00
|
|
|
#ifndef FSTATUSBAR_H
|
|
|
|
#define FSTATUSBAR_H
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
#include <vector>
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
#include "fwindow.h"
|
|
|
|
|
2015-09-25 21:37:19 +02:00
|
|
|
|
2016-10-01 23:18:49 +02:00
|
|
|
// class forward declaration
|
2015-05-23 13:35:12 +02:00
|
|
|
class FStatusBar;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FStatusKey
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
#pragma pack(push)
|
|
|
|
#pragma pack(1)
|
|
|
|
|
|
|
|
class FStatusKey : public FWidget
|
|
|
|
{
|
2017-09-11 03:06:02 +02:00
|
|
|
public:
|
|
|
|
// Constructors
|
|
|
|
explicit FStatusKey (FWidget* = 0);
|
|
|
|
FStatusKey (int, const FString&, FWidget* = 0);
|
|
|
|
|
|
|
|
// Destructor
|
|
|
|
virtual ~FStatusKey();
|
|
|
|
|
|
|
|
// Accessors
|
|
|
|
virtual const char* getClassName() const;
|
|
|
|
virtual int getKey() const;
|
|
|
|
virtual FString getText() const;
|
|
|
|
|
|
|
|
// Mutators
|
|
|
|
void setActive();
|
|
|
|
void unsetActive();
|
|
|
|
bool setMouseFocus(bool);
|
|
|
|
bool setMouseFocus();
|
|
|
|
bool unsetMouseFocus();
|
|
|
|
|
|
|
|
// Inquiry
|
|
|
|
bool isActivated() const;
|
|
|
|
bool hasMouseFocus() const;
|
|
|
|
|
|
|
|
// Event handler
|
|
|
|
void onAccel (FAccelEvent*);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// Mutators
|
|
|
|
void setKey (int);
|
|
|
|
void setText (const FString&);
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Disable copy constructor
|
|
|
|
FStatusKey (const FStatusKey&);
|
|
|
|
|
|
|
|
// Disable assignment operator (=)
|
|
|
|
FStatusKey& operator = (const FStatusKey&);
|
|
|
|
|
|
|
|
// Methods
|
|
|
|
void init (FWidget*);
|
|
|
|
void processActivate();
|
|
|
|
FStatusBar* getConnectedStatusbar() const;
|
|
|
|
void setConnectedStatusbar (FStatusBar*);
|
|
|
|
|
|
|
|
// Friend class
|
|
|
|
friend class FStatusBar;
|
|
|
|
|
|
|
|
// Data Members
|
|
|
|
int key;
|
|
|
|
FString text;
|
|
|
|
bool active;
|
|
|
|
bool mouse_focus;
|
|
|
|
FStatusBar* bar;
|
2015-05-23 13:35:12 +02:00
|
|
|
};
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
|
|
|
|
// FStatusKey inline functions
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
inline const char* FStatusKey::getClassName() const
|
|
|
|
{ return "FStatusKey"; }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
inline int FStatusKey::getKey() const
|
|
|
|
{ return key; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline FString FStatusKey::getText() const
|
|
|
|
{ return text; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FStatusKey::unsetActive()
|
|
|
|
{ active = false; }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FStatusKey::setMouseFocus()
|
|
|
|
{ return setMouseFocus(true); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FStatusKey::unsetMouseFocus()
|
|
|
|
{ return setMouseFocus(false); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
inline bool FStatusKey::isActivated() const
|
|
|
|
{ return active; }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
inline bool FStatusKey::hasMouseFocus() const
|
|
|
|
{ return mouse_focus; }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FStatusKey::setKey (int k)
|
2015-09-22 04:18:20 +02:00
|
|
|
{ key = k; }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2017-03-17 22:59:06 +01:00
|
|
|
inline void FStatusKey::setText (const FString& txt)
|
2015-09-22 04:18:20 +02:00
|
|
|
{ text = txt; }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline FStatusBar* FStatusKey::getConnectedStatusbar() const
|
|
|
|
{ return bar; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FStatusKey::setConnectedStatusbar (FStatusBar* sb)
|
|
|
|
{ bar = sb; }
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FStatusBar
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
#pragma pack(push)
|
|
|
|
#pragma pack(1)
|
|
|
|
|
|
|
|
class FStatusBar : public FWindow
|
|
|
|
{
|
2017-09-11 03:06:02 +02:00
|
|
|
public:
|
|
|
|
// Constructor
|
|
|
|
explicit FStatusBar (FWidget* = 0);
|
|
|
|
|
|
|
|
// Destructor
|
|
|
|
virtual ~FStatusBar();
|
|
|
|
|
|
|
|
// Accessors
|
|
|
|
virtual const char* getClassName() const;
|
|
|
|
FStatusKey* getStatusKey (int) const;
|
|
|
|
FString getMessage() const;
|
|
|
|
uInt getCount() const;
|
|
|
|
|
|
|
|
// Mutators
|
|
|
|
void activateKey (int);
|
|
|
|
void deactivateKey (int);
|
|
|
|
void setMessage (const FString&);
|
|
|
|
|
|
|
|
// Inquiries
|
|
|
|
bool isActivated (int) const;
|
|
|
|
bool hasActivatedKey();
|
|
|
|
|
|
|
|
// Methods
|
|
|
|
void hide();
|
|
|
|
void drawMessage();
|
|
|
|
void clearMessage();
|
|
|
|
void insert (FStatusKey*);
|
|
|
|
void remove (FStatusKey*);
|
|
|
|
void remove (int);
|
|
|
|
void clear();
|
|
|
|
void adjustSize();
|
|
|
|
|
|
|
|
// Event handlers
|
|
|
|
void onMouseDown (FMouseEvent*);
|
|
|
|
void onMouseUp (FMouseEvent*);
|
|
|
|
void onMouseMove (FMouseEvent*);
|
|
|
|
|
|
|
|
// Callback method
|
|
|
|
void cb_statuskey_activated (FWidget*, data_ptr);
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Typedef
|
|
|
|
typedef std::vector<FStatusKey*> keyList;
|
|
|
|
|
|
|
|
// Disable copy constructor
|
|
|
|
FStatusBar (const FStatusBar&);
|
|
|
|
|
|
|
|
// Disable assignment operator (=)
|
|
|
|
FStatusBar& operator = (const FStatusBar&);
|
|
|
|
|
|
|
|
// Methods
|
|
|
|
void init();
|
|
|
|
void draw();
|
|
|
|
void drawKeys();
|
|
|
|
|
|
|
|
// Data Members
|
|
|
|
keyList key_list;
|
|
|
|
FString text;
|
|
|
|
bool mouse_down;
|
|
|
|
int x;
|
|
|
|
int x_msg;
|
2015-05-23 13:35:12 +02:00
|
|
|
};
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
|
|
|
|
// FStatusBar inline functions
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline const char* FStatusBar::getClassName() const
|
|
|
|
{ return "FStatusBar"; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
inline FStatusKey* FStatusBar::getStatusKey (int index) const
|
|
|
|
{ return key_list[uInt(index-1)]; }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
inline uInt FStatusBar::getCount() const
|
|
|
|
{ return uInt(key_list.size()); }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FStatusBar::activateKey (int index)
|
2016-11-02 00:37:58 +01:00
|
|
|
{ key_list[uInt(index-1)]->setActive(); }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FStatusBar::deactivateKey (int index)
|
2016-11-02 00:37:58 +01:00
|
|
|
{ key_list[uInt(index-1)]->unsetActive(); }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FStatusBar::isActivated(int index) const
|
2016-11-02 00:37:58 +01:00
|
|
|
{ return key_list[uInt(index-1)]->isActivated(); }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline FString FStatusBar::getMessage() const
|
|
|
|
{ return text; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FStatusBar::clearMessage()
|
|
|
|
{ text.clear(); }
|
|
|
|
|
2017-04-09 20:08:53 +02:00
|
|
|
#endif // FSTATUSBAR_H
|