2015-09-25 21:37:19 +02:00
|
|
|
// File: fmenuitem.h
|
|
|
|
// Provides: class FMenuItem
|
|
|
|
//
|
|
|
|
// Inheritance diagram
|
|
|
|
// ═══════════════════
|
|
|
|
//
|
|
|
|
// ▕▔▔▔▔▔▔▔▔▔▏ ▕▔▔▔▔▔▔▔▔▔▏
|
|
|
|
// ▕ FObject ▏ ▕ FTerm ▏
|
|
|
|
// ▕▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▁▁▏
|
|
|
|
// ▲ ▲
|
|
|
|
// │ │
|
|
|
|
// └─────┬─────┘
|
|
|
|
// │
|
|
|
|
// ▕▔▔▔▔▔▔▔▔▔▏
|
|
|
|
// ▕ FWidget ▏
|
|
|
|
// ▕▁▁▁▁▁▁▁▁▁▏
|
|
|
|
// ▲
|
|
|
|
// │
|
2015-10-07 02:36:38 +02:00
|
|
|
// ▕▔▔▔▔▔▔▔▔▔▔▔▏1 *▕▔▔▔▔▔▔▔▏
|
2015-09-25 21:37:19 +02:00
|
|
|
// ▕ FMenuItem ▏-┬- - - -▕ FMenu ▏
|
|
|
|
// ▕▁▁▁▁▁▁▁▁▁▁▁▏ : ▕▁▁▁▁▁▁▁▏
|
|
|
|
// :
|
|
|
|
// : *▕▔▔▔▔▔▔▔▔▔▔▔▏
|
|
|
|
// └- - - -▕ FMenuList ▏
|
|
|
|
// ▕▁▁▁▁▁▁▁▁▁▁▁▏
|
2015-08-09 23:47:08 +02:00
|
|
|
|
|
|
|
#ifndef _FMENUITEM_H
|
|
|
|
#define _FMENUITEM_H
|
|
|
|
|
|
|
|
#include "fwidget.h"
|
|
|
|
|
2015-09-25 21:37:19 +02:00
|
|
|
|
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 selected;
|
|
|
|
bool separator;
|
|
|
|
bool checked;
|
2015-09-27 16:00:13 +02:00
|
|
|
uInt text_length;
|
2015-09-15 23:07:24 +02:00
|
|
|
int hotkey;
|
|
|
|
//int accel_key;
|
|
|
|
FMenu* menu;
|
2015-10-10 03:14:14 +02:00
|
|
|
FWidget* super_menu;
|
2015-08-09 23:47:08 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
FMenuItem (const FMenuItem&);
|
|
|
|
FMenuItem& operator = (const FMenuItem&);
|
|
|
|
void init (FWidget*);
|
2015-11-01 22:45:23 +01:00
|
|
|
uChar hotKey();
|
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-10-10 03:14:14 +02:00
|
|
|
FWidget* getSuperMenu() const;
|
|
|
|
void setSuperMenu (FWidget*);
|
2015-08-16 20:05:39 +02:00
|
|
|
void processActivate();
|
2015-09-30 22:39:02 +02:00
|
|
|
void processDeactivate();
|
2015-08-22 18:53:52 +02:00
|
|
|
void processClicked();
|
2015-08-09 23:47:08 +02:00
|
|
|
|
|
|
|
public:
|
2015-09-27 16:45:28 +02:00
|
|
|
explicit FMenuItem (FWidget* = 0);
|
|
|
|
FMenuItem (FString&, FWidget* = 0);
|
|
|
|
FMenuItem (const std::string&, FWidget* = 0);
|
|
|
|
FMenuItem (const char*, FWidget* = 0);
|
2015-08-09 23:47:08 +02:00
|
|
|
virtual ~FMenuItem();
|
|
|
|
|
2015-10-29 21:10:50 +01:00
|
|
|
void onKeyPress (FKeyEvent*);
|
2015-09-28 04:31:29 +02:00
|
|
|
void onMouseDown (FMouseEvent*);
|
|
|
|
void onMouseUp (FMouseEvent*);
|
|
|
|
void onMouseMove (FMouseEvent*);
|
2015-10-29 21:10:50 +01:00
|
|
|
void onAccel (FAccelEvent*);
|
|
|
|
void onFocusIn (FFocusEvent*);
|
|
|
|
void onFocusOut (FFocusEvent*);
|
2015-09-15 23:07:24 +02:00
|
|
|
FString getText() const;
|
2015-10-29 21:10:50 +01:00
|
|
|
// make every setEnable from FWidget available
|
|
|
|
using FWidget::setEnable;
|
|
|
|
bool setEnable(bool);
|
|
|
|
bool setFocus(bool);
|
|
|
|
bool setFocus();
|
|
|
|
bool unsetFocus();
|
2015-09-15 23:07:24 +02:00
|
|
|
void setSelected();
|
|
|
|
void unsetSelected();
|
|
|
|
bool isSelected() const;
|
|
|
|
void setSeparator();
|
|
|
|
void unsetSeparator();
|
|
|
|
bool isSeparator() const;
|
|
|
|
void setChecked();
|
|
|
|
void unsetChecked();
|
|
|
|
bool isChecked() const;
|
2015-11-01 22:45:23 +01:00
|
|
|
int getHotkey() const;
|
2015-09-15 23:07:24 +02:00
|
|
|
bool hasHotkey() const;
|
2015-09-28 04:31:29 +02:00
|
|
|
FMenu* getMenu() const;
|
2015-09-15 23:07:24 +02:00
|
|
|
void setMenu(FMenu*);
|
|
|
|
bool hasMenu() const;
|
2015-11-05 23:25:21 +01:00
|
|
|
void openMenu();
|
2015-09-28 04:31:29 +02:00
|
|
|
uInt getTextLength() const;
|
2015-09-15 23:07:24 +02:00
|
|
|
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-09-30 22:39:02 +02:00
|
|
|
friend class FMenu;
|
2015-08-09 23:47:08 +02:00
|
|
|
};
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
|
|
|
|
// FMenuItem inline functions
|
2015-10-19 00:07:07 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline FWidget* FMenuItem::getSuperMenu() const
|
|
|
|
{ return super_menu; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FMenuItem::setSuperMenu (FWidget* smenu)
|
|
|
|
{ super_menu = smenu; }
|
|
|
|
|
2015-08-09 23:47:08 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline FString FMenuItem::getText() const
|
2015-09-22 04:18:20 +02:00
|
|
|
{ return text; }
|
2015-08-09 23:47:08 +02:00
|
|
|
|
2015-08-16 20:05:39 +02:00
|
|
|
//----------------------------------------------------------------------
|
2015-10-29 21:10:50 +01:00
|
|
|
inline bool FMenuItem::setFocus()
|
|
|
|
{ return setFocus(true); }
|
2015-08-09 23:47:08 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2015-10-29 21:10:50 +01:00
|
|
|
inline bool FMenuItem::unsetFocus()
|
|
|
|
{ return setFocus(false); }
|
2015-08-09 23:47:08 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FMenuItem::isSelected() const
|
|
|
|
{ return selected; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FMenuItem::setSeparator()
|
2015-09-22 04:18:20 +02:00
|
|
|
{ separator = true; }
|
2015-08-09 23:47:08 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FMenuItem::unsetSeparator()
|
2015-09-22 04:18:20 +02:00
|
|
|
{ separator = false; }
|
2015-08-09 23:47:08 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FMenuItem::isSeparator() const
|
|
|
|
{ return separator; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FMenuItem::setChecked()
|
2015-09-22 04:18:20 +02:00
|
|
|
{ checked = true; }
|
2015-08-09 23:47:08 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FMenuItem::unsetChecked()
|
2015-09-22 04:18:20 +02:00
|
|
|
{ checked = false; }
|
2015-08-09 23:47:08 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FMenuItem::isChecked() const
|
|
|
|
{ return checked; }
|
|
|
|
|
2015-11-01 22:45:23 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline int FMenuItem::getHotkey() const
|
|
|
|
{ return hotkey; }
|
|
|
|
|
2015-08-09 23:47:08 +02:00
|
|
|
//----------------------------------------------------------------------
|
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-09-28 04:31:29 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline FMenu* FMenuItem::getMenu() const
|
|
|
|
{ return menu; }
|
|
|
|
|
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
|
|
|
|
2015-09-28 04:31:29 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline uInt FMenuItem::getTextLength() const
|
|
|
|
{ return text_length; }
|
2015-08-09 23:47:08 +02:00
|
|
|
|
|
|
|
#endif // _FMENUITEM_H
|