2015-09-25 21:37:19 +02:00
|
|
|
// File: fmenuitem.h
|
|
|
|
// Provides: class FMenuItem
|
|
|
|
//
|
|
|
|
// Inheritance diagram
|
|
|
|
// ═══════════════════
|
|
|
|
//
|
|
|
|
// ▕▔▔▔▔▔▔▔▔▔▏ ▕▔▔▔▔▔▔▔▔▔▏
|
|
|
|
// ▕ FObject ▏ ▕ FTerm ▏
|
|
|
|
// ▕▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▁▁▏
|
|
|
|
// ▲ ▲
|
|
|
|
// │ │
|
|
|
|
// └─────┬─────┘
|
|
|
|
// │
|
2016-10-11 04:57:36 +02:00
|
|
|
// ▕▔▔▔▔▔▔▔▔▏
|
|
|
|
// ▕ FVTerm ▏
|
|
|
|
// ▕▁▁▁▁▁▁▁▁▏
|
|
|
|
// ▲
|
|
|
|
// │
|
2015-09-25 21:37:19 +02:00
|
|
|
// ▕▔▔▔▔▔▔▔▔▔▏
|
|
|
|
// ▕ FWidget ▏
|
|
|
|
// ▕▁▁▁▁▁▁▁▁▁▏
|
|
|
|
// ▲
|
|
|
|
// │
|
2015-11-15 19:46:33 +01:00
|
|
|
// ▕▔▔▔▔▔▔▔▔▔▔▔▏* 1▕▔▔▔▔▔▔▔▏
|
2015-09-25 21:37:19 +02:00
|
|
|
// ▕ FMenuItem ▏-┬- - - -▕ FMenu ▏
|
|
|
|
// ▕▁▁▁▁▁▁▁▁▁▁▁▏ : ▕▁▁▁▁▁▁▁▏
|
|
|
|
// :
|
2015-11-15 19:46:33 +01:00
|
|
|
// : 1▕▔▔▔▔▔▔▔▔▔▔▔▏
|
2015-09-25 21:37:19 +02:00
|
|
|
// └- - - -▕ FMenuList ▏
|
|
|
|
// ▕▁▁▁▁▁▁▁▁▁▁▁▏
|
2015-08-09 23:47:08 +02:00
|
|
|
|
2017-04-09 20:08:53 +02:00
|
|
|
#ifndef FMENUITEM_H
|
|
|
|
#define FMENUITEM_H
|
2015-08-09 23:47:08 +02:00
|
|
|
|
|
|
|
#include "fwidget.h"
|
|
|
|
|
2016-10-01 23:18:49 +02:00
|
|
|
// class forward declaration
|
2016-07-30 23:00:37 +02:00
|
|
|
class FDialog;
|
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
|
|
|
|
{
|
|
|
|
public:
|
2016-11-02 00:37:58 +01:00
|
|
|
// Using-declarations
|
|
|
|
using FWidget::addAccelerator;
|
|
|
|
using FWidget::delAccelerator;
|
|
|
|
using FWidget::setEnable;
|
|
|
|
|
2016-09-30 04:55:28 +02:00
|
|
|
// Constructor
|
2015-09-27 16:45:28 +02:00
|
|
|
explicit FMenuItem (FWidget* = 0);
|
2017-03-17 22:59:06 +01:00
|
|
|
FMenuItem (const FString&, FWidget* = 0);
|
|
|
|
FMenuItem (int, const FString&, FWidget* = 0);
|
2016-11-02 00:37:58 +01:00
|
|
|
|
2016-09-30 04:55:28 +02:00
|
|
|
// Destructor
|
2015-08-09 23:47:08 +02:00
|
|
|
virtual ~FMenuItem();
|
2016-09-30 04:55:28 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
// Accessors
|
2015-11-15 19:46:33 +01:00
|
|
|
const char* getClassName() const;
|
2016-11-02 00:37:58 +01:00
|
|
|
int getHotkey() const;
|
|
|
|
FMenu* getMenu() const;
|
|
|
|
uInt getTextLength() const;
|
|
|
|
FString getText() const;
|
|
|
|
|
|
|
|
// Mutators
|
|
|
|
bool setEnable (bool);
|
|
|
|
bool setFocus (bool);
|
|
|
|
bool setFocus();
|
|
|
|
bool unsetFocus();
|
|
|
|
void setSelected();
|
|
|
|
void unsetSelected();
|
|
|
|
void setSeparator();
|
|
|
|
void unsetSeparator();
|
|
|
|
void setChecked();
|
|
|
|
void unsetChecked();
|
|
|
|
void setMenu (FMenu*);
|
2017-03-17 22:59:06 +01:00
|
|
|
void setText (const FString&);
|
2016-11-02 00:37:58 +01:00
|
|
|
|
|
|
|
// Inquiries
|
|
|
|
bool isSelected() const;
|
|
|
|
bool isSeparator() const;
|
|
|
|
bool isChecked() const;
|
|
|
|
bool hasHotkey() const;
|
|
|
|
bool hasMenu() const;
|
|
|
|
|
|
|
|
// Methods
|
|
|
|
void addAccelerator (int, FWidget*);
|
|
|
|
void delAccelerator (FWidget*);
|
|
|
|
void openMenu();
|
2016-09-30 04:55:28 +02:00
|
|
|
|
|
|
|
// Event handlers
|
2016-11-02 00:37:58 +01:00
|
|
|
void onKeyPress (FKeyEvent*);
|
|
|
|
void onMouseDoubleClick (FMouseEvent*);
|
|
|
|
void onMouseDown (FMouseEvent*);
|
|
|
|
void onMouseUp (FMouseEvent*);
|
|
|
|
void onMouseMove (FMouseEvent*);
|
|
|
|
void onAccel (FAccelEvent*);
|
|
|
|
void onFocusIn (FFocusEvent*);
|
|
|
|
void onFocusOut (FFocusEvent*);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// Accessor
|
|
|
|
FWidget* getSuperMenu() const;
|
|
|
|
|
|
|
|
// Mutator
|
|
|
|
void setSuperMenu (FWidget*);
|
|
|
|
|
|
|
|
// Inquiries
|
|
|
|
bool isWindowsMenu (FWidget*) const;
|
|
|
|
bool isMenuBar (FWidget*) const;
|
|
|
|
bool isMenu (FWidget*) const;
|
|
|
|
|
|
|
|
// Data Members
|
|
|
|
FString text;
|
|
|
|
bool selected;
|
|
|
|
bool separator;
|
|
|
|
bool checkable;
|
|
|
|
bool checked;
|
|
|
|
bool radio_button;
|
|
|
|
bool dialog_index;
|
|
|
|
uInt text_length;
|
|
|
|
int hotkey;
|
|
|
|
int accel_key;
|
|
|
|
FMenu* menu;
|
|
|
|
FWidget* super_menu;
|
|
|
|
FDialog* associated_window;
|
2015-08-09 23:47:08 +02:00
|
|
|
|
|
|
|
private:
|
2016-11-02 00:37:58 +01:00
|
|
|
// Disable copy constructor
|
|
|
|
FMenuItem (const FMenuItem&);
|
|
|
|
|
|
|
|
// Disable assignment operator (=)
|
|
|
|
FMenuItem& operator = (const FMenuItem&);
|
|
|
|
|
|
|
|
// Methods
|
|
|
|
void init (FWidget*);
|
|
|
|
uChar hotKey();
|
|
|
|
void processActivate();
|
|
|
|
void processDeactivate();
|
|
|
|
void createDialogList (FMenu*);
|
|
|
|
|
|
|
|
// Callback methods
|
2017-02-24 00:30:07 +01:00
|
|
|
void cb_switchToDialog (FWidget*, data_ptr);
|
|
|
|
void cb_destroyDialog (FWidget*, data_ptr);
|
2016-11-02 00:37:58 +01:00
|
|
|
|
|
|
|
virtual void processClicked();
|
|
|
|
|
|
|
|
// Friend classes
|
2016-07-03 20:08:39 +02:00
|
|
|
friend class FDialogListMenu;
|
2015-08-09 23:47:08 +02:00
|
|
|
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-11-15 19:46:33 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline const char* FMenuItem::getClassName() const
|
|
|
|
{ return "FMenuItem"; }
|
|
|
|
|
2015-10-19 00:07:07 +02:00
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
inline int FMenuItem::getHotkey() const
|
|
|
|
{ return hotkey; }
|
2015-10-19 00:07:07 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
inline FMenu* FMenuItem::getMenu() const
|
|
|
|
{ return menu; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline uInt FMenuItem::getTextLength() const
|
|
|
|
{ return text_length; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline FString FMenuItem::getText() const
|
|
|
|
{ return text; }
|
2015-10-19 00:07:07 +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 void FMenuItem::setSeparator()
|
2015-11-07 23:16:09 +01:00
|
|
|
{
|
|
|
|
separator = true;
|
|
|
|
unsetFocusable();
|
|
|
|
}
|
2015-08-09 23:47:08 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FMenuItem::unsetSeparator()
|
2015-11-07 23:16:09 +01:00
|
|
|
{
|
|
|
|
separator = false;
|
|
|
|
setFocusable();
|
|
|
|
}
|
2015-08-09 23:47:08 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
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
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
inline void FMenuItem::setMenu(FMenu* m)
|
|
|
|
{ menu = m; }
|
2015-08-09 23:47:08 +02:00
|
|
|
|
2015-11-01 22:45:23 +01:00
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
inline bool FMenuItem::isSelected() const
|
|
|
|
{ return selected; }
|
2015-11-01 22:45:23 +01:00
|
|
|
|
2015-08-09 23:47:08 +02:00
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
inline bool FMenuItem::isSeparator() const
|
|
|
|
{ return separator; }
|
2015-08-09 23:47:08 +02:00
|
|
|
|
2015-09-28 04:31:29 +02:00
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
inline bool FMenuItem::isChecked() const
|
|
|
|
{ return checked; }
|
2015-09-28 04:31:29 +02:00
|
|
|
|
2015-08-09 23:47:08 +02:00
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01: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 bool FMenuItem::hasMenu() const
|
|
|
|
{ return bool(menu != 0); }
|
2015-08-09 23:47:08 +02:00
|
|
|
|
2015-09-28 04:31:29 +02:00
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
inline FWidget* FMenuItem::getSuperMenu() const
|
|
|
|
{ return super_menu; }
|
2015-08-09 23:47:08 +02:00
|
|
|
|
2015-11-24 23:40:41 +01:00
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
inline void FMenuItem::setSuperMenu (FWidget* smenu)
|
|
|
|
{ super_menu = smenu; }
|
2015-11-24 23:40:41 +01:00
|
|
|
|
2017-04-09 20:08:53 +02:00
|
|
|
#endif // FMENUITEM_H
|