Initial commit.
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / FLTKDialog / FLTKPropertyList.cxx
blob332807eb3d713062693ec05c78def54ca640e62a
1 /*=========================================================================
3 Program: Insight Segmentation & Registration Toolkit
4 Module: $RCSfile: FLTKPropertyList.cxx,v $
5 Language: C++
6 Date: $Date: 2007/08/21 20:21:09 $
7 Version: $Revision: 1.10 $
9 Copyright (c) 2002 Insight Consortium. All rights reserved.
10 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 // FLTKPropertyList.cxx : implementation file
20 #include "FLTKPropertyList.h"
21 #include "../cmCacheManager.h"
22 #include "FLTKPropertyItemRow.h"
23 #include "FL/filename.H"
24 #include "FL/Fl_File_Chooser.H"
25 #include "FL/Fl_Color_Chooser.H"
26 #include "FL/fl_ask.H"
27 #include "FL/Fl_Button.H"
28 #include "CMakeSetupGUIImplementation.h"
31 namespace fltk {
33 /////////////////////////////////////////////////////////////////////////////
34 // PropertyList
36 PropertyList::PropertyList( CMakeSetupGUIImplementation * cmakeSetup )
38 m_CMakeSetup = cmakeSetup;
39 PropertyItemRow::SetCMakeSetupGUI( cmakeSetup );
40 m_Dirty = false;
45 PropertyList::~PropertyList()
47 for(std::set<PropertyItem*>::iterator i = m_PropertyItems.begin();
48 i != m_PropertyItems.end(); ++i)
50 delete *i;
57 int PropertyList::AddItem( std::string txt)
59 int nIndex =0;
60 return nIndex;
65 int PropertyList::AddPropItem(PropertyItem* pItem, bool reverseOrder)
68 int nIndex =0;
69 if(reverseOrder)
71 nIndex = 0;
73 else
75 nIndex = m_PropertyItems.size();
78 new PropertyItemRow( pItem ); // GUI of the new property row
80 m_PropertyItems.insert(pItem);
82 return nIndex;
87 int PropertyList::AddProperty(const char* name,
88 const char* value,
89 const char* helpString,
90 int type,
91 const char* comboItems,
92 bool reverseOrder)
95 PropertyItem* pItem = 0;
96 for(int i =0; i < this->GetCount(); ++i)
98 PropertyItem* item = this->GetItem(i);
99 if(item->m_propName == name)
101 pItem = item;
102 if(pItem->m_curValue != value)
104 pItem->m_curValue = value;
105 pItem->m_HelpString = helpString;
106 Invalidate();
108 return i;
111 // if it is not found, then create a new one
112 if(!pItem)
114 pItem = new PropertyItem(name, value, helpString, type, comboItems);
116 return this->AddPropItem(pItem,reverseOrder);
120 void PropertyList::RemoveProperty(const char* name)
122 for(int i =0; i < this->GetCount(); ++i)
124 PropertyItem* pItem = (PropertyItem*) GetItemDataPtr(i);
125 if(pItem->m_propName == name)
127 m_PropertyItems.erase(pItem);
128 delete pItem;
129 return;
136 void PropertyList::RemoveAll()
138 int c = this->GetCount();
139 for(int i =0; i < c; ++i)
141 PropertyItem* pItem = (PropertyItem*) GetItemDataPtr(0);
142 // cmCacheManager::GetInstance()->RemoveCacheEntry(pItem->m_propName.c_str());
143 m_PropertyItems.erase(pItem);
144 delete pItem;
146 Invalidate();
151 PropertyItem * PropertyList::GetItemDataPtr(int index)
153 std::set<PropertyItem*>::iterator it = m_PropertyItems.begin();
154 for(int i=0; it != m_PropertyItems.end() && i<index; i++)
156 ++it;
158 return *it;
162 PropertyItem * PropertyList::GetItem(int index)
164 std::set<PropertyItem*>::iterator it = m_PropertyItems.begin();
165 for(int i=0; it != m_PropertyItems.end() && i<index; i++)
167 ++it;
169 return *it;
172 void
173 PropertyList
174 ::InvalidateList(void)
176 Invalidate();
177 m_Dirty = true;
181 } // end fltk namespace