finalcut/src/fmenu.h

242 lines
8.3 KiB
C
Raw Normal View History

// File: fmenubar.h
// Provides: class FMenu
//
// Inheritance diagram
// ═══════════════════
//
// ▕▔▔▔▔▔▔▔▔▔▏ ▕▔▔▔▔▔▔▔▔▔▏
// ▕ FObject ▏ ▕ FTerm ▏
// ▕▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▁▁▏
// ▲ ▲
// │ │ *▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏
// └─────┬─────┘ ┌ - -▕ FRadioMenuItem ▏
// │ : ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏
// ▕▔▔▔▔▔▔▔▔▔▏ :
// ▕ FWidget ▏ : *▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏
// ▕▁▁▁▁▁▁▁▁▁▏ ├ - -▕ FCheckMenuItem ▏
// ▲ : ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏
// │ 1 :
// ▕▔▔▔▔▔▔▔▔▔▏ ▕▔▔▔▔▔▔▔▔▔▔▔▏- ┘ ▕▔▔▔▔▔▔▔▔▔▔▔▏
// ▕ FWindow ▏ ▕ FMenuList ▏- - - -▕ FMenuItem ▏
// ▕▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▁▁▁▁▏1 *▕▁▁▁▁▁▁▁▁▁▁▁▏
// ▲ ▲ 1:
// │ │ :
// └─────┬─────┘ :
// │ 1 :
// ▕▔▔▔▔▔▔▔▏- - - ┘ ▕▔▔▔▔▔▔▔▔▔▔▔▏
// ▕ FMenu ▏- - - - - - - -▕ FMenuItem ▏
// ▕▁▁▁▁▁▁▁▏1 1▕▁▁▁▁▁▁▁▁▁▁▁▏
2015-08-16 20:05:39 +02:00
#ifndef _FMENU_H
#define _FMENU_H
#include "fwindow.h"
#include "fmenubar.h"
2015-08-16 20:05:39 +02:00
#include "fmenulist.h"
#include "fmenuitem.h"
//----------------------------------------------------------------------
// class FMenu
//----------------------------------------------------------------------
#pragma pack(push)
#pragma pack(1)
class FMenu : public FWindow, public FMenuList
{
private:
FMenuItem* item;
FWidget* super_menu;
FMenu* open_sub_menu;
uInt max_item_width;
bool mouse_down;
bool has_checkable_items;
2015-08-16 20:05:39 +02:00
private:
// Disable copy constructor
2015-08-16 20:05:39 +02:00
FMenu (const FMenu&);
// Disable assignment operator (=)
2015-08-16 20:05:39 +02:00
FMenu& operator = (const FMenu&);
void init(FWidget*);
void calculateDimensions();
void adjustItems();
int adjustX(int);
bool isWindowsMenu (FWidget*) const;
bool isMenuBar (FWidget*) const;
bool isMenu (FWidget*) const;
bool isRadioMenuItem (FWidget*) const;
FWidget* getSuperMenu() const;
void setSuperMenu (FWidget*);
bool isSubMenu() const;
void openSubMenu (FMenu*);
void hideSubMenus();
void hideSuperMenus();
bool containsMenuStructure (const FPoint&);
bool containsMenuStructure (int, int);
FMenu* superMenuAt (const FPoint&);
FMenu* superMenuAt (int, int);
bool selectNextItem();
bool selectPrevItem();
void keypressMenuBar (FKeyEvent*&);
bool hotkeyMenu (FKeyEvent*&);
int getHotkeyPos (wchar_t*&, wchar_t*&, uInt);
void draw();
void drawItems();
void drawSeparator(int);
void processActivate();
2015-08-16 20:05:39 +02:00
public:
// Constructor
explicit FMenu (FWidget* = 0);
2015-09-27 16:45:28 +02:00
FMenu (FString&, FWidget* = 0);
FMenu (const std::string&, FWidget* = 0);
FMenu (const char*, FWidget* = 0);
// Destructor
virtual ~FMenu();
2015-08-16 20:05:39 +02:00
virtual const char* getClassName() const;
// Event handlers
2015-10-29 21:10:50 +01:00
void onKeyPress (FKeyEvent*);
2015-08-16 20:05:39 +02:00
void onMouseDown (FMouseEvent*);
void onMouseUp (FMouseEvent*);
void onMouseMove (FMouseEvent*);
2015-10-29 21:10:50 +01:00
void onAccel (FAccelEvent*);
2015-09-30 22:39:02 +02:00
void show();
2015-08-16 20:05:39 +02:00
void hide();
void setStatusbarMessage (FString);
2015-08-16 20:05:39 +02:00
FMenuItem* getItem() const;
FString getText() const;
2015-10-29 21:10:50 +01:00
bool setEnable(bool);
bool setEnable();
bool unsetEnable();
bool setDisable();
bool isEnabled() const;
2015-08-16 20:05:39 +02:00
void setSelected();
void unsetSelected();
bool isSelected() const;
bool setMenuWidget (bool);
bool setMenuWidget();
bool unsetMenuWidget();
2015-08-16 20:05:39 +02:00
bool hasHotkey() const;
void setMenu (FMenu*);
bool hasMenu() const;
void setText (FString&);
void setText (const std::string&);
void setText (const char*);
// Callback method
void cb_menuitem_toggled (FWidget*, void*);
2015-09-30 22:39:02 +02:00
private:
friend class FApplication;
friend class FCheckMenuItem;
2016-06-12 23:06:58 +02:00
friend class FDialog;
2015-11-07 23:16:09 +01:00
friend class FMenuBar;
2015-09-30 22:39:02 +02:00
friend class FMenuItem;
friend class FRadioMenuItem;
2015-08-16 20:05:39 +02:00
};
#pragma pack(pop)
// FMenu inline functions
2015-10-19 00:07:07 +02:00
//----------------------------------------------------------------------
inline FWidget* FMenu::getSuperMenu() const
{ return super_menu; }
//----------------------------------------------------------------------
inline void FMenu::setSuperMenu (FWidget* smenu)
{ super_menu = smenu; }
//----------------------------------------------------------------------
inline bool FMenu::containsMenuStructure (const FPoint& p)
{ return containsMenuStructure (p.getX(), p.getY()); }
//----------------------------------------------------------------------
inline FMenu* FMenu::superMenuAt (const FPoint& p)
{ return superMenuAt (p.getX(), p.getY()); }
2015-08-16 20:05:39 +02:00
//----------------------------------------------------------------------
inline const char* FMenu::getClassName() const
{ return "FMenu"; }
//----------------------------------------------------------------------
2015-09-20 05:44:50 +02:00
inline void FMenu::onAccel (FAccelEvent* ev)
{ item->onAccel(ev); }
2015-08-16 20:05:39 +02:00
//----------------------------------------------------------------------
inline FMenuItem* FMenu::getItem() const
{ return item; }
//----------------------------------------------------------------------
inline FString FMenu::getText() const
{ return item->getText(); }
//----------------------------------------------------------------------
2015-10-29 21:10:50 +01:00
inline bool FMenu::setEnable(bool on)
{ return item->setEnable(on); }
//----------------------------------------------------------------------
inline bool FMenu::setEnable()
{ return item->setEnable(); }
//----------------------------------------------------------------------
inline bool FMenu::unsetEnable()
{ return item->unsetEnable(); }
2015-08-16 20:05:39 +02:00
//----------------------------------------------------------------------
2015-10-29 21:10:50 +01:00
inline bool FMenu::setDisable()
{ return item->setDisable(); }
2015-08-16 20:05:39 +02:00
//----------------------------------------------------------------------
2015-10-29 21:10:50 +01:00
inline bool FMenu::isEnabled() const
{ return item->isEnabled(); }
2015-08-16 20:05:39 +02:00
//----------------------------------------------------------------------
inline void FMenu::setSelected()
{ item->setSelected(); }
//----------------------------------------------------------------------
inline void FMenu::unsetSelected()
{ item->unsetSelected(); }
//----------------------------------------------------------------------
inline bool FMenu::isSelected() const
{ return item->isSelected(); }
//----------------------------------------------------------------------
inline bool FMenu::setMenuWidget()
{ return setMenuWidget(true); }
//----------------------------------------------------------------------
inline bool FMenu::unsetMenuWidget()
{ return setMenuWidget(false); }
2015-08-16 20:05:39 +02:00
//----------------------------------------------------------------------
inline bool FMenu::hasHotkey() const
{ return item->hasHotkey(); }
//----------------------------------------------------------------------
inline void FMenu::setMenu (FMenu* m)
{ item->setMenu(m); }
//----------------------------------------------------------------------
inline bool FMenu::hasMenu() const
{ return item->hasMenu(); }
//----------------------------------------------------------------------
inline void FMenu::setText (FString& txt)
{ item->setText(txt); }
//----------------------------------------------------------------------
inline void FMenu::setText (const std::string& txt)
{ item->setText(txt); }
//----------------------------------------------------------------------
inline void FMenu::setText (const char* txt)
{ item->setText(txt); }
#endif // _FMENU_H