FMenuItem delete its entry from the parent object
This commit is contained in:
parent
f19b4811ae
commit
03bd7bd6da
|
@ -38,7 +38,7 @@ namespace finalcut
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FMenu::FMenu(FWidget* parent)
|
FMenu::FMenu(FWidget* parent)
|
||||||
: FWindow(parent)
|
: FWindow(parent)
|
||||||
, item(0)
|
, item()
|
||||||
, super_menu(0)
|
, super_menu(0)
|
||||||
, opened_sub_menu(0)
|
, opened_sub_menu(0)
|
||||||
, shown_sub_menu(0)
|
, shown_sub_menu(0)
|
||||||
|
@ -53,7 +53,7 @@ FMenu::FMenu(FWidget* parent)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FMenu::FMenu (const FString& txt, FWidget* parent)
|
FMenu::FMenu (const FString& txt, FWidget* parent)
|
||||||
: FWindow(parent)
|
: FWindow(parent)
|
||||||
, item(0)
|
, item(txt, parent)
|
||||||
, super_menu(0)
|
, super_menu(0)
|
||||||
, opened_sub_menu(0)
|
, opened_sub_menu(0)
|
||||||
, shown_sub_menu(0)
|
, shown_sub_menu(0)
|
||||||
|
@ -62,16 +62,6 @@ FMenu::FMenu (const FString& txt, FWidget* parent)
|
||||||
, mouse_down(false)
|
, mouse_down(false)
|
||||||
, has_checkable_items(false)
|
, has_checkable_items(false)
|
||||||
{
|
{
|
||||||
try
|
|
||||||
{
|
|
||||||
item = new FMenuItem(txt, parent);
|
|
||||||
}
|
|
||||||
catch (const std::bad_alloc& ex)
|
|
||||||
{
|
|
||||||
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
init(parent);
|
init(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,9 +94,7 @@ bool FMenu::setMenuWidget (bool on)
|
||||||
void FMenu::setStatusbarMessage (const FString& msg)
|
void FMenu::setStatusbarMessage (const FString& msg)
|
||||||
{
|
{
|
||||||
FWidget::setStatusbarMessage(msg);
|
FWidget::setStatusbarMessage(msg);
|
||||||
|
item.setStatusbarMessage(msg);
|
||||||
if ( item )
|
|
||||||
item->setStatusbarMessage(msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -474,9 +462,7 @@ void FMenu::init(FWidget* parent)
|
||||||
|
|
||||||
setForegroundColor (wc.menu_active_fg);
|
setForegroundColor (wc.menu_active_fg);
|
||||||
setBackgroundColor (wc.menu_active_bg);
|
setBackgroundColor (wc.menu_active_bg);
|
||||||
|
item.setMenu(this);
|
||||||
if ( item )
|
|
||||||
item->setMenu(this);
|
|
||||||
|
|
||||||
if ( parent )
|
if ( parent )
|
||||||
{
|
{
|
||||||
|
@ -500,9 +486,7 @@ void FMenu::init(FWidget* parent)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FMenu::calculateDimensions()
|
void FMenu::calculateDimensions()
|
||||||
{
|
{
|
||||||
int item_X
|
int item_X, item_Y, adjust_X;
|
||||||
, item_Y
|
|
||||||
, adjust_X;
|
|
||||||
std::vector<FMenuItem*>::const_iterator iter, last;
|
std::vector<FMenuItem*>::const_iterator iter, last;
|
||||||
iter = item_list.begin();
|
iter = item_list.begin();
|
||||||
last = item_list.end();
|
last = item_list.end();
|
||||||
|
@ -1038,7 +1022,7 @@ bool FMenu::containsMenuStructure (int x, int y)
|
||||||
return true;
|
return true;
|
||||||
else if ( si && si->hasMenu() && opened_sub_menu )
|
else if ( si && si->hasMenu() && opened_sub_menu )
|
||||||
return si->getMenu()->containsMenuStructure(x, y);
|
return si->getMenu()->containsMenuStructure(x, y);
|
||||||
else if ( item && item->getTermGeometry().contains(x, y) )
|
else if ( item.getTermGeometry().contains(x, y) )
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -99,6 +99,14 @@ FMenuItem::FMenuItem (int k, const FString& txt, FWidget* parent)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FMenuItem::~FMenuItem() // destructor
|
FMenuItem::~FMenuItem() // destructor
|
||||||
{
|
{
|
||||||
|
if ( super_menu && (isMenu(super_menu) || isMenuBar(super_menu)) )
|
||||||
|
{
|
||||||
|
FMenuList* menu_list = dynamic_cast<FMenuList*>(super_menu);
|
||||||
|
|
||||||
|
if ( menu_list )
|
||||||
|
menu_list->remove(this);
|
||||||
|
}
|
||||||
|
|
||||||
delAccelerator();
|
delAccelerator();
|
||||||
|
|
||||||
// remove dialog list item callback from the dialog
|
// remove dialog list item callback from the dialog
|
||||||
|
|
|
@ -87,7 +87,7 @@ class FMenu : public FWindow, public FMenuList
|
||||||
// Accessors
|
// Accessors
|
||||||
virtual const char* getClassName() const;
|
virtual const char* getClassName() const;
|
||||||
FString getText() const;
|
FString getText() const;
|
||||||
FMenuItem* getItem() const;
|
FMenuItem* getItem();
|
||||||
|
|
||||||
// Mutators
|
// Mutators
|
||||||
virtual bool setEnable(bool);
|
virtual bool setEnable(bool);
|
||||||
|
@ -228,7 +228,7 @@ class FMenu : public FWindow, public FMenuList
|
||||||
friend class FRadioMenuItem;
|
friend class FRadioMenuItem;
|
||||||
|
|
||||||
// Data Members
|
// Data Members
|
||||||
FMenuItem* item;
|
FMenuItem item;
|
||||||
FWidget* super_menu;
|
FWidget* super_menu;
|
||||||
FMenu* opened_sub_menu;
|
FMenu* opened_sub_menu;
|
||||||
FMenu* shown_sub_menu;
|
FMenu* shown_sub_menu;
|
||||||
|
@ -247,35 +247,35 @@ inline const char* FMenu::getClassName() const
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline FString FMenu::getText() const
|
inline FString FMenu::getText() const
|
||||||
{ return item->getText(); }
|
{ return item.getText(); }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline FMenuItem* FMenu::getItem() const
|
inline FMenuItem* FMenu::getItem()
|
||||||
{ return item; }
|
{ return &item; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FMenu::setEnable(bool on)
|
inline bool FMenu::setEnable(bool on)
|
||||||
{ return item->setEnable(on); }
|
{ return item.setEnable(on); }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FMenu::setEnable()
|
inline bool FMenu::setEnable()
|
||||||
{ return item->setEnable(); }
|
{ return item.setEnable(); }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FMenu::unsetEnable()
|
inline bool FMenu::unsetEnable()
|
||||||
{ return item->unsetEnable(); }
|
{ return item.unsetEnable(); }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FMenu::setDisable()
|
inline bool FMenu::setDisable()
|
||||||
{ return item->setDisable(); }
|
{ return item.setDisable(); }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline void FMenu::setSelected()
|
inline void FMenu::setSelected()
|
||||||
{ item->setSelected(); }
|
{ item.setSelected(); }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline void FMenu::unsetSelected()
|
inline void FMenu::unsetSelected()
|
||||||
{ item->unsetSelected(); }
|
{ item.unsetSelected(); }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FMenu::setMenuWidget()
|
inline bool FMenu::setMenuWidget()
|
||||||
|
@ -287,27 +287,27 @@ inline bool FMenu::unsetMenuWidget()
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline void FMenu::setMenu (FMenu* m)
|
inline void FMenu::setMenu (FMenu* m)
|
||||||
{ item->setMenu(m); }
|
{ item.setMenu(m); }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline void FMenu::setText (const FString& txt)
|
inline void FMenu::setText (const FString& txt)
|
||||||
{ item->setText(txt); }
|
{ item.setText(txt); }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FMenu::isEnabled() const
|
inline bool FMenu::isEnabled() const
|
||||||
{ return item->isEnabled(); }
|
{ return item.isEnabled(); }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FMenu::isSelected() const
|
inline bool FMenu::isSelected() const
|
||||||
{ return item->isSelected(); }
|
{ return item.isSelected(); }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FMenu::hasHotkey() const
|
inline bool FMenu::hasHotkey() const
|
||||||
{ return item->hasHotkey(); }
|
{ return item.hasHotkey(); }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FMenu::hasMenu() const
|
inline bool FMenu::hasMenu() const
|
||||||
{ return item->hasMenu(); }
|
{ return item.hasMenu(); }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline FWidget* FMenu::getSuperMenu() const
|
inline FWidget* FMenu::getSuperMenu() const
|
||||||
|
@ -327,7 +327,7 @@ inline FMenu* FMenu::superMenuAt (const FPoint& p)
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline void FMenu::onAccel (FAccelEvent* ev)
|
inline void FMenu::onAccel (FAccelEvent* ev)
|
||||||
{ item->onAccel(ev); }
|
{ item.onAccel(ev); }
|
||||||
|
|
||||||
} // namespace finalcut
|
} // namespace finalcut
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue