2015-08-09 23:47:08 +02:00
|
|
|
// fmenuitem.h
|
|
|
|
// class FMenuItem
|
|
|
|
|
|
|
|
#ifndef _FMENUITEM_H
|
|
|
|
#define _FMENUITEM_H
|
|
|
|
|
|
|
|
#include "fwidget.h"
|
|
|
|
|
2015-08-16 20:05:39 +02:00
|
|
|
class FMenu;
|
2015-08-09 23:47:08 +02:00
|
|
|
class FMenuList;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FMenuItem
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
#pragma pack(push)
|
|
|
|
#pragma pack(1)
|
|
|
|
|
|
|
|
class FMenuItem : public FWidget
|
|
|
|
{
|
|
|
|
private:
|
2015-09-15 23:07:24 +02:00
|
|
|
FString text;
|
|
|
|
bool active;
|
|
|
|
bool selected;
|
|
|
|
bool separator;
|
|
|
|
bool checked;
|
|
|
|
int hotkey;
|
|
|
|
//int accel_key;
|
|
|
|
FMenu* menu;
|
|
|
|
FMenuList* super_menu;
|
2015-08-09 23:47:08 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
FMenuItem (const FMenuItem&);
|
|
|
|
FMenuItem& operator = (const FMenuItem&);
|
|
|
|
void init (FWidget*);
|
2015-08-16 20:05:39 +02:00
|
|
|
uChar getHotkey();
|
2015-08-09 23:47:08 +02:00
|
|
|
bool isMenuBar (FWidget*) const;
|
2015-09-15 23:07:24 +02:00
|
|
|
bool isMenu (FWidget*) const;
|
2015-08-09 23:47:08 +02:00
|
|
|
FMenuList* superMenu() const;
|
|
|
|
void setSuperMenu (FMenuList*);
|
2015-08-16 20:05:39 +02:00
|
|
|
void processActivate();
|
2015-08-22 18:53:52 +02:00
|
|
|
void processClicked();
|
2015-08-09 23:47:08 +02:00
|
|
|
|
|
|
|
public:
|
2015-08-16 20:05:39 +02:00
|
|
|
explicit FMenuItem (FWidget* parent=0);
|
2015-08-09 23:47:08 +02:00
|
|
|
FMenuItem (FString&, FWidget* parent=0);
|
|
|
|
FMenuItem (const std::string&, FWidget* parent=0);
|
|
|
|
FMenuItem (const char*, FWidget* parent=0);
|
|
|
|
virtual ~FMenuItem();
|
|
|
|
|
2015-09-15 23:07:24 +02:00
|
|
|
void onAccel (FAccelEvent*);
|
|
|
|
FString getText() const;
|
|
|
|
void setActive();
|
|
|
|
void unsetActive();
|
|
|
|
bool isActivated() const;
|
|
|
|
void setSelected();
|
|
|
|
void unsetSelected();
|
|
|
|
bool isSelected() const;
|
|
|
|
void setSeparator();
|
|
|
|
void unsetSeparator();
|
|
|
|
bool isSeparator() const;
|
|
|
|
void setChecked();
|
|
|
|
void unsetChecked();
|
|
|
|
bool isChecked() const;
|
|
|
|
bool hasHotkey() const;
|
|
|
|
void setMenu(FMenu*);
|
|
|
|
bool hasMenu() const;
|
|
|
|
void setText (FString&);
|
|
|
|
void setText (const std::string&);
|
|
|
|
void setText (const char*);
|
2015-08-09 23:47:08 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class FMenuList;
|
2015-08-22 18:53:52 +02:00
|
|
|
friend class FMenuBar;
|
2015-08-09 23:47:08 +02:00
|
|
|
};
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
|
|
|
|
// FMenuItem inline functions
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline FString FMenuItem::getText() const
|
|
|
|
{ return this->text; }
|
|
|
|
|
2015-08-16 20:05:39 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FMenuItem::setActive()
|
|
|
|
{ this->active = true; }
|
|
|
|
|
2015-08-09 23:47:08 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FMenuItem::unsetActive()
|
|
|
|
{ this->active = false; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FMenuItem::isActivated() const
|
|
|
|
{ return active; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FMenuItem::unsetSelected()
|
|
|
|
{ this->selected = false; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FMenuItem::isSelected() const
|
|
|
|
{ return selected; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FMenuItem::setSeparator()
|
|
|
|
{ this->separator = true; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FMenuItem::unsetSeparator()
|
|
|
|
{ this->separator = false; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FMenuItem::isSeparator() const
|
|
|
|
{ return separator; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FMenuItem::setChecked()
|
|
|
|
{ this->checked = true; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FMenuItem::unsetChecked()
|
|
|
|
{ this->checked = false; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FMenuItem::isChecked() const
|
|
|
|
{ return checked; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2015-08-16 20:05:39 +02:00
|
|
|
inline bool FMenuItem::hasHotkey() const
|
|
|
|
{ return bool(hotkey != 0); }
|
2015-08-09 23:47:08 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2015-08-16 20:05:39 +02:00
|
|
|
inline void FMenuItem::setMenu(FMenu* m)
|
|
|
|
{ menu = m; }
|
2015-08-09 23:47:08 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2015-08-16 20:05:39 +02:00
|
|
|
inline bool FMenuItem::hasMenu() const
|
|
|
|
{ return bool(menu != 0); }
|
2015-08-09 23:47:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
#endif // _FMENUITEM_H
|