2001-06-11 02:21:55 +04:00
|
|
|
// FLTKPropertyList.cxx : implementation file
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "FLTKPropertyList.h"
|
|
|
|
#include "../cmCacheManager.h"
|
|
|
|
#include "FLTKPropertyItemRow.h"
|
2001-06-14 22:32:20 +04:00
|
|
|
#include "FL/filename.H"
|
|
|
|
#include "FL/fl_file_chooser.H"
|
|
|
|
#include "FL/Fl_Color_Chooser.H"
|
|
|
|
#include "FL/fl_ask.H"
|
|
|
|
#include "FL/Fl_Button.H"
|
2001-06-21 16:41:14 +04:00
|
|
|
#include "CMakeSetupGUIImplementation.h"
|
|
|
|
|
2001-06-11 02:21:55 +04:00
|
|
|
|
|
|
|
namespace fltk {
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// PropertyList
|
|
|
|
|
2001-06-21 16:41:14 +04:00
|
|
|
PropertyList::PropertyList( CMakeSetupGUIImplementation * cmakeSetup )
|
2001-06-11 02:21:55 +04:00
|
|
|
{
|
2001-06-21 16:41:14 +04:00
|
|
|
m_CMakeSetup = cmakeSetup;
|
|
|
|
PropertyItemRow::SetCMakeSetupGUI( cmakeSetup );
|
2001-10-28 06:47:23 +03:00
|
|
|
m_Dirty = false;
|
2001-06-11 02:21:55 +04:00
|
|
|
}
|
|
|
|
|
2001-06-13 08:16:35 +04:00
|
|
|
|
|
|
|
|
2001-06-11 02:21:55 +04:00
|
|
|
PropertyList::~PropertyList()
|
|
|
|
{
|
|
|
|
for(std::set<PropertyItem*>::iterator i = m_PropertyItems.begin();
|
|
|
|
i != m_PropertyItems.end(); ++i)
|
|
|
|
{
|
|
|
|
delete *i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-06-13 08:16:35 +04:00
|
|
|
int PropertyList::AddItem( std::string txt)
|
2001-06-11 02:21:55 +04:00
|
|
|
{
|
2001-10-28 06:47:23 +03:00
|
|
|
int nIndex =0;
|
2001-06-11 02:21:55 +04:00
|
|
|
return nIndex;
|
|
|
|
}
|
|
|
|
|
2001-10-28 06:47:23 +03:00
|
|
|
|
|
|
|
|
|
|
|
int PropertyList::AddPropItem(PropertyItem* pItem, bool reverseOrder)
|
2001-06-11 02:21:55 +04:00
|
|
|
{
|
|
|
|
|
2001-10-28 06:47:23 +03:00
|
|
|
int nIndex =0;
|
|
|
|
if(reverseOrder)
|
|
|
|
{
|
|
|
|
nIndex = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nIndex = m_PropertyItems.size();
|
|
|
|
}
|
2001-06-11 02:21:55 +04:00
|
|
|
|
2001-10-28 06:47:23 +03:00
|
|
|
new PropertyItemRow( pItem ); // GUI of the new property row
|
2001-06-11 02:21:55 +04:00
|
|
|
|
|
|
|
m_PropertyItems.insert(pItem);
|
|
|
|
|
|
|
|
return nIndex;
|
|
|
|
}
|
|
|
|
|
2001-10-28 06:47:23 +03:00
|
|
|
|
|
|
|
|
2001-06-11 02:21:55 +04:00
|
|
|
int PropertyList::AddProperty(const char* name,
|
|
|
|
const char* value,
|
|
|
|
const char* helpString,
|
|
|
|
int type,
|
2001-10-28 06:47:23 +03:00
|
|
|
const char* comboItems,
|
|
|
|
bool reverseOrder)
|
2001-06-11 02:21:55 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
PropertyItem* pItem = 0;
|
|
|
|
for(int i =0; i < this->GetCount(); ++i)
|
|
|
|
{
|
|
|
|
PropertyItem* item = this->GetItem(i);
|
|
|
|
if(item->m_propName == name)
|
|
|
|
{
|
|
|
|
pItem = item;
|
|
|
|
if(pItem->m_curValue != value)
|
|
|
|
{
|
|
|
|
pItem->m_curValue = value;
|
|
|
|
pItem->m_HelpString = helpString;
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// if it is not found, then create a new one
|
|
|
|
if(!pItem)
|
|
|
|
{
|
|
|
|
pItem = new PropertyItem(name, value, helpString, type, comboItems);
|
|
|
|
}
|
2001-10-28 06:47:23 +03:00
|
|
|
return this->AddPropItem(pItem,reverseOrder);
|
2001-06-11 02:21:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-10-28 06:47:23 +03:00
|
|
|
void PropertyList::RemoveProperty(const char* name)
|
|
|
|
{
|
|
|
|
for(int i =0; i < this->GetCount(); ++i)
|
|
|
|
{
|
|
|
|
PropertyItem* pItem = (PropertyItem*) GetItemDataPtr(i);
|
|
|
|
if(pItem->m_propName == name)
|
|
|
|
{
|
|
|
|
m_PropertyItems.erase(pItem);
|
|
|
|
delete pItem;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-11 02:21:55 +04:00
|
|
|
|
|
|
|
|
|
|
|
void PropertyList::RemoveAll()
|
|
|
|
{
|
|
|
|
int c = this->GetCount();
|
|
|
|
for(int i =0; i < c; ++i)
|
|
|
|
{
|
|
|
|
PropertyItem* pItem = (PropertyItem*) GetItemDataPtr(0);
|
|
|
|
cmCacheManager::GetInstance()->RemoveCacheEntry(pItem->m_propName.c_str());
|
|
|
|
m_PropertyItems.erase(pItem);
|
|
|
|
delete pItem;
|
|
|
|
}
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PropertyItem * PropertyList::GetItemDataPtr(int index)
|
|
|
|
{
|
|
|
|
std::set<PropertyItem*>::iterator it = m_PropertyItems.begin();
|
|
|
|
for(int i=0; it != m_PropertyItems.end() && i<index; i++)
|
|
|
|
{
|
|
|
|
++it;
|
|
|
|
}
|
|
|
|
return *it;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PropertyItem * PropertyList::GetItem(int index)
|
|
|
|
{
|
|
|
|
std::set<PropertyItem*>::iterator it = m_PropertyItems.begin();
|
|
|
|
for(int i=0; it != m_PropertyItems.end() && i<index; i++)
|
|
|
|
{
|
|
|
|
++it;
|
|
|
|
}
|
|
|
|
return *it;
|
|
|
|
}
|
|
|
|
|
2001-10-28 06:47:23 +03:00
|
|
|
void
|
|
|
|
PropertyList
|
|
|
|
::InvalidateList(void)
|
|
|
|
{
|
|
|
|
Invalidate();
|
|
|
|
m_Dirty = true;
|
|
|
|
}
|
2001-06-11 02:21:55 +04:00
|
|
|
|
|
|
|
|
|
|
|
} // end fltk namespace
|
|
|
|
|
|
|
|
|
|
|
|
|