FLTKPropertyList.cxx 2.7 KB

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