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)
|
||||
: FWindow(parent)
|
||||
, item(0)
|
||||
, item()
|
||||
, super_menu(0)
|
||||
, opened_sub_menu(0)
|
||||
, shown_sub_menu(0)
|
||||
|
@ -53,7 +53,7 @@ FMenu::FMenu(FWidget* parent)
|
|||
//----------------------------------------------------------------------
|
||||
FMenu::FMenu (const FString& txt, FWidget* parent)
|
||||
: FWindow(parent)
|
||||
, item(0)
|
||||
, item(txt, parent)
|
||||
, super_menu(0)
|
||||
, opened_sub_menu(0)
|
||||
, shown_sub_menu(0)
|
||||
|
@ -62,16 +62,6 @@ FMenu::FMenu (const FString& txt, FWidget* parent)
|
|||
, mouse_down(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);
|
||||
}
|
||||
|
||||
|
@ -104,9 +94,7 @@ bool FMenu::setMenuWidget (bool on)
|
|||
void FMenu::setStatusbarMessage (const FString& msg)
|
||||
{
|
||||
FWidget::setStatusbarMessage(msg);
|
||||
|
||||
if ( item )
|
||||
item->setStatusbarMessage(msg);
|
||||
item.setStatusbarMessage(msg);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -474,9 +462,7 @@ void FMenu::init(FWidget* parent)
|
|||
|
||||
setForegroundColor (wc.menu_active_fg);
|
||||
setBackgroundColor (wc.menu_active_bg);
|
||||
|
||||
if ( item )
|
||||
item->setMenu(this);
|
||||
item.setMenu(this);
|
||||
|
||||
if ( parent )
|
||||
{
|
||||
|
@ -500,9 +486,7 @@ void FMenu::init(FWidget* parent)
|
|||
//----------------------------------------------------------------------
|
||||
void FMenu::calculateDimensions()
|
||||
{
|
||||
int item_X
|
||||
, item_Y
|
||||
, adjust_X;
|
||||
int item_X, item_Y, adjust_X;
|
||||
std::vector<FMenuItem*>::const_iterator iter, last;
|
||||
iter = item_list.begin();
|
||||
last = item_list.end();
|
||||
|
@ -1038,7 +1022,7 @@ bool FMenu::containsMenuStructure (int x, int y)
|
|||
return true;
|
||||
else if ( si && si->hasMenu() && opened_sub_menu )
|
||||
return si->getMenu()->containsMenuStructure(x, y);
|
||||
else if ( item && item->getTermGeometry().contains(x, y) )
|
||||
else if ( item.getTermGeometry().contains(x, y) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
|
|
@ -99,6 +99,14 @@ FMenuItem::FMenuItem (int k, const FString& txt, FWidget* parent)
|
|||
//----------------------------------------------------------------------
|
||||
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();
|
||||
|
||||
// remove dialog list item callback from the dialog
|
||||
|
|
|
@ -87,7 +87,7 @@ class FMenu : public FWindow, public FMenuList
|
|||
// Accessors
|
||||
virtual const char* getClassName() const;
|
||||
FString getText() const;
|
||||
FMenuItem* getItem() const;
|
||||
FMenuItem* getItem();
|
||||
|
||||
// Mutators
|
||||
virtual bool setEnable(bool);
|
||||
|
@ -228,7 +228,7 @@ class FMenu : public FWindow, public FMenuList
|
|||
friend class FRadioMenuItem;
|
||||
|
||||
// Data Members
|
||||
FMenuItem* item;
|
||||
FMenuItem item;
|
||||
FWidget* super_menu;
|
||||
FMenu* opened_sub_menu;
|
||||
FMenu* shown_sub_menu;
|
||||
|
@ -247,35 +247,35 @@ inline const char* FMenu::getClassName() const
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
inline FString FMenu::getText() const
|
||||
{ return item->getText(); }
|
||||
{ return item.getText(); }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FMenuItem* FMenu::getItem() const
|
||||
{ return item; }
|
||||
inline FMenuItem* FMenu::getItem()
|
||||
{ return &item; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FMenu::setEnable(bool on)
|
||||
{ return item->setEnable(on); }
|
||||
{ return item.setEnable(on); }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FMenu::setEnable()
|
||||
{ return item->setEnable(); }
|
||||
{ return item.setEnable(); }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FMenu::unsetEnable()
|
||||
{ return item->unsetEnable(); }
|
||||
{ return item.unsetEnable(); }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FMenu::setDisable()
|
||||
{ return item->setDisable(); }
|
||||
{ return item.setDisable(); }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FMenu::setSelected()
|
||||
{ item->setSelected(); }
|
||||
{ item.setSelected(); }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FMenu::unsetSelected()
|
||||
{ item->unsetSelected(); }
|
||||
{ item.unsetSelected(); }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FMenu::setMenuWidget()
|
||||
|
@ -287,27 +287,27 @@ inline bool FMenu::unsetMenuWidget()
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FMenu::setMenu (FMenu* m)
|
||||
{ item->setMenu(m); }
|
||||
{ item.setMenu(m); }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FMenu::setText (const FString& txt)
|
||||
{ item->setText(txt); }
|
||||
{ item.setText(txt); }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FMenu::isEnabled() const
|
||||
{ return item->isEnabled(); }
|
||||
{ return item.isEnabled(); }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FMenu::isSelected() const
|
||||
{ return item->isSelected(); }
|
||||
{ return item.isSelected(); }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FMenu::hasHotkey() const
|
||||
{ return item->hasHotkey(); }
|
||||
{ return item.hasHotkey(); }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FMenu::hasMenu() const
|
||||
{ return item->hasMenu(); }
|
||||
{ return item.hasMenu(); }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FWidget* FMenu::getSuperMenu() const
|
||||
|
@ -327,7 +327,7 @@ inline FMenu* FMenu::superMenuAt (const FPoint& p)
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FMenu::onAccel (FAccelEvent* ev)
|
||||
{ item->onAccel(ev); }
|
||||
{ item.onAccel(ev); }
|
||||
|
||||
} // namespace finalcut
|
||||
|
||||
|
|
Loading…
Reference in New Issue