| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- // FLTKPropertyList.cxx : implementation file
- //
- #include "FLTKPropertyList.h"
- #include "../cmCacheManager.h"
- #include "FLTKPropertyItemRow.h"
- #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"
- #include <cstdio>
- #include "CMakeSetupGUIImplementation.h"
- namespace fltk {
- /////////////////////////////////////////////////////////////////////////////
- // PropertyList
- PropertyList::PropertyList( CMakeSetupGUIImplementation * cmakeSetup )
- {
- m_CMakeSetup = cmakeSetup;
- PropertyItemRow::SetCMakeSetupGUI( cmakeSetup );
- }
- PropertyList::~PropertyList()
- {
- for(std::set<PropertyItem*>::iterator i = m_PropertyItems.begin();
- i != m_PropertyItems.end(); ++i)
- {
- delete *i;
- }
- }
- int PropertyList::AddItem( std::string txt)
- {
- int nIndex =0;// = AddString(txt);
- return nIndex;
- }
- int PropertyList::AddPropItem(PropertyItem* pItem)
- {
- int nIndex =0; //= AddString(_T(""));
- // SetItemDataPtr(nIndex,pItem);
- new PropertyItemRow( pItem ); // GUI of the property row
- m_PropertyItems.insert(pItem);
- return nIndex;
- }
- int PropertyList::AddProperty(const char* name,
- const char* value,
- const char* helpString,
- int type,
- const char* comboItems)
- {
- 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);
- }
- return this->AddPropItem(pItem);
- }
- 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;
- // this->DeleteString(0);
- }
- 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;
- }
- } // end fltk namespace
|