FLTKPropertyList.cxx 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. // FLTKPropertyList.cxx : implementation file
  2. //
  3. #include "FLTKPropertyList.h"
  4. #include "../cmCacheManager.h"
  5. #include "FLTKPropertyItemRow.h"
  6. #include "FL/filename.H"
  7. #include "FL/fl_file_chooser.H"
  8. #include "FL/Fl_Color_Chooser.H"
  9. #include "FL/fl_ask.H"
  10. #include "FL/Fl_Button.H"
  11. #include "CMakeSetupGUIImplementation.h"
  12. namespace fltk {
  13. /////////////////////////////////////////////////////////////////////////////
  14. // PropertyList
  15. PropertyList::PropertyList( CMakeSetupGUIImplementation * cmakeSetup )
  16. {
  17. m_CMakeSetup = cmakeSetup;
  18. PropertyItemRow::SetCMakeSetupGUI( cmakeSetup );
  19. }
  20. PropertyList::~PropertyList()
  21. {
  22. for(std::set<PropertyItem*>::iterator i = m_PropertyItems.begin();
  23. i != m_PropertyItems.end(); ++i)
  24. {
  25. delete *i;
  26. }
  27. }
  28. int PropertyList::AddItem( std::string txt)
  29. {
  30. int nIndex =0;// = AddString(txt);
  31. return nIndex;
  32. }
  33. int PropertyList::AddPropItem(PropertyItem* pItem)
  34. {
  35. int nIndex =0; //= AddString(_T(""));
  36. // SetItemDataPtr(nIndex,pItem);
  37. new PropertyItemRow( pItem ); // GUI of the property row
  38. m_PropertyItems.insert(pItem);
  39. return nIndex;
  40. }
  41. int PropertyList::AddProperty(const char* name,
  42. const char* value,
  43. const char* helpString,
  44. int type,
  45. const char* comboItems)
  46. {
  47. PropertyItem* pItem = 0;
  48. for(int i =0; i < this->GetCount(); ++i)
  49. {
  50. PropertyItem* item = this->GetItem(i);
  51. if(item->m_propName == name)
  52. {
  53. pItem = item;
  54. if(pItem->m_curValue != value)
  55. {
  56. pItem->m_curValue = value;
  57. pItem->m_HelpString = helpString;
  58. Invalidate();
  59. }
  60. return i;
  61. }
  62. }
  63. // if it is not found, then create a new one
  64. if(!pItem)
  65. {
  66. pItem = new PropertyItem(name, value, helpString, type, comboItems);
  67. }
  68. return this->AddPropItem(pItem);
  69. }
  70. void PropertyList::RemoveAll()
  71. {
  72. int c = this->GetCount();
  73. for(int i =0; i < c; ++i)
  74. {
  75. PropertyItem* pItem = (PropertyItem*) GetItemDataPtr(0);
  76. cmCacheManager::GetInstance()->RemoveCacheEntry(pItem->m_propName.c_str());
  77. m_PropertyItems.erase(pItem);
  78. delete pItem;
  79. // this->DeleteString(0);
  80. }
  81. Invalidate();
  82. }
  83. PropertyItem * PropertyList::GetItemDataPtr(int index)
  84. {
  85. std::set<PropertyItem*>::iterator it = m_PropertyItems.begin();
  86. for(int i=0; it != m_PropertyItems.end() && i<index; i++)
  87. {
  88. ++it;
  89. }
  90. return *it;
  91. }
  92. PropertyItem * PropertyList::GetItem(int index)
  93. {
  94. std::set<PropertyItem*>::iterator it = m_PropertyItems.begin();
  95. for(int i=0; it != m_PropertyItems.end() && i<index; i++)
  96. {
  97. ++it;
  98. }
  99. return *it;
  100. }
  101. } // end fltk namespace