2015-05-23 13:35:12 +02:00
|
|
|
// fstatusbar.h
|
|
|
|
// class FStatusKey
|
|
|
|
// class FStatusBar
|
|
|
|
|
|
|
|
#ifndef _FSTATUSBAR_H
|
|
|
|
#define _FSTATUSBAR_H
|
|
|
|
|
|
|
|
#include "fwindow.h"
|
|
|
|
|
|
|
|
class FStatusBar;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FStatusKey
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
#pragma pack(push)
|
|
|
|
#pragma pack(1)
|
|
|
|
|
|
|
|
class FStatusKey : public FWidget
|
|
|
|
{
|
|
|
|
private:
|
2015-09-22 04:18:20 +02:00
|
|
|
int key;
|
|
|
|
FString text;
|
|
|
|
bool active;
|
|
|
|
bool mouse_focus;
|
2015-05-23 13:35:12 +02:00
|
|
|
FStatusBar* bar;
|
|
|
|
|
|
|
|
private:
|
|
|
|
FStatusKey (const FStatusKey&);
|
|
|
|
FStatusKey& operator = (const FStatusKey&);
|
2015-07-26 18:24:10 +02:00
|
|
|
void init (FWidget*);
|
2015-05-23 13:35:12 +02:00
|
|
|
void processActivate();
|
|
|
|
FStatusBar* statusbar() const;
|
|
|
|
void setStatusbar (FStatusBar*);
|
|
|
|
|
|
|
|
public:
|
2015-05-27 02:25:13 +02:00
|
|
|
explicit FStatusKey (FWidget* parent=0);
|
2015-05-23 13:35:12 +02:00
|
|
|
FStatusKey (int, FString&, FWidget* parent=0);
|
|
|
|
FStatusKey (int, const std::string&, FWidget* parent=0);
|
|
|
|
FStatusKey (int, const char*, FWidget* parent=0);
|
|
|
|
virtual ~FStatusKey();
|
|
|
|
|
|
|
|
void onAccel (FAccelEvent*);
|
|
|
|
void setActive();
|
|
|
|
void unsetActive();
|
|
|
|
bool isActivated() const;
|
|
|
|
bool setMouseFocus(bool);
|
|
|
|
bool setMouseFocus();
|
|
|
|
bool unsetMouseFocus();
|
|
|
|
bool hasMouseFocus() const;
|
|
|
|
virtual int getKey() const;
|
|
|
|
virtual FString getText() const;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void setKey (int);
|
|
|
|
void setText (FString&);
|
|
|
|
void setText (const std::string&);
|
|
|
|
void setText (const char*);
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend class FStatusBar;
|
|
|
|
};
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
|
|
|
|
// FStatusKey inline functions
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FStatusKey::unsetActive()
|
2015-09-22 04:18:20 +02:00
|
|
|
{ active = false; }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FStatusKey::isActivated() const
|
|
|
|
{ return active; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FStatusKey::setMouseFocus()
|
|
|
|
{ return setMouseFocus(true); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FStatusKey::unsetMouseFocus()
|
|
|
|
{ return setMouseFocus(false); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FStatusKey::hasMouseFocus() const
|
|
|
|
{ return mouse_focus; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline int FStatusKey::getKey() const
|
2015-09-22 04:18:20 +02:00
|
|
|
{ return key; }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline FString FStatusKey::getText() const
|
2015-09-22 04:18:20 +02:00
|
|
|
{ return text; }
|
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
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FStatusKey::setText (FString& txt)
|
2015-09-22 04:18:20 +02:00
|
|
|
{ text = txt; }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FStatusKey::setText (const std::string& txt)
|
2015-09-22 04:18:20 +02:00
|
|
|
{ text = txt; }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FStatusKey::setText (const char* txt)
|
2015-09-22 04:18:20 +02:00
|
|
|
{ text = txt; }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FStatusBar
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
#pragma pack(push)
|
|
|
|
#pragma pack(1)
|
|
|
|
|
|
|
|
class FStatusBar : public FWindow
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
std::vector<FStatusKey*> keylist;
|
|
|
|
FString text;
|
2015-09-22 04:18:20 +02:00
|
|
|
bool mouse_down;
|
|
|
|
int x;
|
|
|
|
int x_msg;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
FStatusBar (const FStatusBar&);
|
|
|
|
FStatusBar& operator = (const FStatusBar&);
|
|
|
|
void init();
|
|
|
|
void draw();
|
|
|
|
void drawKeys();
|
|
|
|
void adjustSize();
|
|
|
|
|
|
|
|
public:
|
2015-05-27 02:25:13 +02:00
|
|
|
explicit FStatusBar (FWidget* parent=0); // constructor
|
2015-05-23 13:35:12 +02:00
|
|
|
virtual ~FStatusBar(); // destructor
|
|
|
|
virtual const char* getClassName() const;
|
|
|
|
|
|
|
|
void onMouseDown (FMouseEvent*);
|
|
|
|
void onMouseUp (FMouseEvent*);
|
|
|
|
void onMouseMove (FMouseEvent*);
|
|
|
|
void hide();
|
2015-09-22 04:18:20 +02:00
|
|
|
// make every setGeometry from FWidget available
|
|
|
|
using FWidget::setGeometry;
|
2015-05-23 13:35:12 +02:00
|
|
|
void setGeometry (int, int, int, int, bool adjust=true);
|
|
|
|
|
|
|
|
uInt count() const;
|
|
|
|
FStatusKey* key (int) const;
|
|
|
|
void activateKey (int);
|
|
|
|
void deactivateKey (int);
|
|
|
|
bool isActivated (int) const;
|
|
|
|
bool hasActivatedKey();
|
|
|
|
|
|
|
|
void drawMessage();
|
|
|
|
void setMessage (const FString);
|
|
|
|
FString getMessage() const;
|
|
|
|
void clearMessage();
|
|
|
|
|
|
|
|
void insert (FStatusKey*);
|
|
|
|
void remove (FStatusKey*);
|
|
|
|
void remove (int);
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
void cb_statuskey_activated (FWidget*, void*);
|
|
|
|
};
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
|
|
|
|
// FStatusBar inline functions
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline const char* FStatusBar::getClassName() const
|
|
|
|
{ return "FStatusBar"; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline uInt FStatusBar::count() const
|
|
|
|
{ return uInt(keylist.size()); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline FStatusKey* FStatusBar::key(int index) const
|
|
|
|
{ return keylist[uInt(index-1)]; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FStatusBar::activateKey (int index)
|
|
|
|
{ keylist[uInt(index-1)]->setActive(); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FStatusBar::deactivateKey (int index)
|
|
|
|
{ keylist[uInt(index-1)]->unsetActive(); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FStatusBar::isActivated(int index) const
|
|
|
|
{ return keylist[uInt(index-1)]->isActivated(); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FStatusBar::setMessage (FString mgs)
|
|
|
|
{ text = mgs; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline FString FStatusBar::getMessage() const
|
|
|
|
{ return text; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FStatusBar::clearMessage()
|
|
|
|
{ text.clear(); }
|
|
|
|
|
|
|
|
#endif // _FSTATUSBAR_H
|