finalcut/src/fmenulist.cpp

105 lines
2.1 KiB
C++
Raw Normal View History

// fmenulist.cpp
// class FMenuList
#include "fmenulist.h"
//----------------------------------------------------------------------
// class FMenuList
//----------------------------------------------------------------------
// constructor and destructor
//----------------------------------------------------------------------
FMenuList::FMenuList()
2015-09-22 04:18:20 +02:00
: itemlist()
{ }
//----------------------------------------------------------------------
FMenuList::~FMenuList() // destructor
{
// delete all items
if ( ! itemlist.empty() )
{
std::vector<FMenuItem*>::iterator iter;
iter = itemlist.begin();
while ( iter != itemlist.end() )
{
(*iter)->setSuperMenu(0);
//delAccelerator (*iter);
iter = itemlist.erase(iter);
}
}
}
// private methods of FMenuList
//----------------------------------------------------------------------
// public methods of FMenuList
//----------------------------------------------------------------------
bool FMenuList::hasSelectedItem()
{
if ( ! itemlist.empty() )
{
std::vector<FMenuItem*>::const_iterator iter, end;
iter = itemlist.begin();
end = itemlist.end();
while ( iter != end )
{
if ( (*iter)->isSelected() )
return true;
++iter;
}
}
return false;
}
//----------------------------------------------------------------------
2015-09-20 05:44:50 +02:00
void FMenuList::insert (FMenuItem* i)
{
2015-09-20 05:44:50 +02:00
itemlist.push_back(i);
}
//----------------------------------------------------------------------
2015-09-20 05:44:50 +02:00
void FMenuList::remove (FMenuItem* i)
{
std::vector<FMenuItem*>::iterator iter;
2015-09-20 05:44:50 +02:00
//delAccelerator (i);
if ( itemlist.empty() )
return;
iter = itemlist.begin();
while ( iter != itemlist.end() )
{
2015-09-20 05:44:50 +02:00
if ( (*iter) == i )
{
iter = itemlist.erase(iter);
2015-09-20 05:44:50 +02:00
i->setSuperMenu(0);
break;
}
else
++iter;
}
}
//----------------------------------------------------------------------
void FMenuList::remove (int pos)
{
if ( int(count()) < pos )
return;
itemlist.erase (itemlist.begin()+pos-1);
}
//----------------------------------------------------------------------
void FMenuList::clear()
{
itemlist.clear();
}
2015-08-16 20:05:39 +02:00