summaryrefslogtreecommitdiffstats
path: root/Source/MFCDialog
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2004-01-02 22:24:19 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2004-01-02 22:24:19 (GMT)
commit0c4bec756312a21c9afaf4fd7f648c242b2da5dd (patch)
tree330547c4d9c9602c15dca50137fc9b68ae9f6d68 /Source/MFCDialog
parent02d253c59ed0cbcb15f0714148cbe0fbc01a254f (diff)
downloadCMake-0c4bec756312a21c9afaf4fd7f648c242b2da5dd.zip
CMake-0c4bec756312a21c9afaf4fd7f648c242b2da5dd.tar.gz
CMake-0c4bec756312a21c9afaf4fd7f648c242b2da5dd.tar.bz2
ENH: fix bug with advanced items loosing edit and do a better job sorting
Diffstat (limited to 'Source/MFCDialog')
-rw-r--r--Source/MFCDialog/CMakeSetup.rc4
-rw-r--r--Source/MFCDialog/CMakeSetupDialog.cpp130
-rw-r--r--Source/MFCDialog/PropertyList.cpp119
-rw-r--r--Source/MFCDialog/PropertyList.h16
4 files changed, 154 insertions, 115 deletions
diff --git a/Source/MFCDialog/CMakeSetup.rc b/Source/MFCDialog/CMakeSetup.rc
index 3546656..c5fb36d 100644
--- a/Source/MFCDialog/CMakeSetup.rc
+++ b/Source/MFCDialog/CMakeSetup.rc
@@ -76,7 +76,7 @@ IDR_MAINFRAME ICON DISCARDABLE "res\\CMakeSetupDialog.ico"
IDD_ABOUTBOX DIALOGEX 0, 0, 235, 55
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "About CMakeSetup"
-FONT 8, "MS Sans Serif"
+FONT 8, "MS Sans Serif", 0, 0, 0x1
BEGIN
ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20
LTEXT "CMakeSetup\nwww.cmake.org",IDC_STATIC,40,18,119,16
@@ -108,7 +108,7 @@ BEGIN
PUSHBUTTON "OK",IDC_OK,166,219,51,15
PUSHBUTTON "Cancel",IDCANCEL,222,219,51,15
PUSHBUTTON "Help",IDC_HELP_BUTTON,278,219,51,15
- LISTBOX IDC_LIST2,15,53,419,126,LBS_OWNERDRAWVARIABLE |
+ LISTBOX IDC_LIST2,15,53,419,126,LBS_SORT | LBS_OWNERDRAWVARIABLE |
LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL |
WS_HSCROLL
GROUPBOX "Cache Values",IDC_FRAME,10,44,432,140
diff --git a/Source/MFCDialog/CMakeSetupDialog.cpp b/Source/MFCDialog/CMakeSetupDialog.cpp
index 77fb76e..9b6c145 100644
--- a/Source/MFCDialog/CMakeSetupDialog.cpp
+++ b/Source/MFCDialog/CMakeSetupDialog.cpp
@@ -768,14 +768,9 @@ void CMakeSetupDialog::FillCacheGUIFromCacheManager()
{
cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
size_t size = m_CacheEntriesList.GetItems().size();
- bool reverseOrder = false;
// if there are already entries in the cache, then
// put the new ones in the top, so they show up first
- if(size)
- {
- reverseOrder = true;
- }
-
+ bool reverseOrder = false;
// all the current values are not new any more
std::set<CPropertyItem*> items = m_CacheEntriesList.GetItems();
for(std::set<CPropertyItem*>::iterator i = items.begin();
@@ -798,15 +793,7 @@ void CMakeSetupDialog::FillCacheGUIFromCacheManager()
{
value = '\'' + value + '\'';
}
-
- if(!m_AdvancedValues)
- {
- if(i.GetPropertyAsBool("ADVANCED"))
- {
- m_CacheEntriesList.RemoveProperty(key);
- continue;
- }
- }
+ bool advanced = i.GetPropertyAsBool("ADVANCED");
switch(i.GetType() )
{
case cmCacheManager::BOOL:
@@ -816,7 +803,8 @@ void CMakeSetupDialog::FillCacheGUIFromCacheManager()
"ON",
i.GetProperty("HELPSTRING"),
CPropertyList::COMBO,"ON|OFF",
- reverseOrder
+ reverseOrder,
+ advanced
);
}
else
@@ -825,7 +813,7 @@ void CMakeSetupDialog::FillCacheGUIFromCacheManager()
"OFF",
i.GetProperty("HELPSTRING"),
CPropertyList::COMBO,"ON|OFF",
- reverseOrder
+ reverseOrder, advanced
);
}
break;
@@ -834,7 +822,7 @@ void CMakeSetupDialog::FillCacheGUIFromCacheManager()
value.c_str(),
i.GetProperty("HELPSTRING"),
CPropertyList::PATH,"",
- reverseOrder
+ reverseOrder, advanced
);
break;
case cmCacheManager::FILEPATH:
@@ -842,7 +830,7 @@ void CMakeSetupDialog::FillCacheGUIFromCacheManager()
value.c_str(),
i.GetProperty("HELPSTRING"),
CPropertyList::FILE,"",
- reverseOrder
+ reverseOrder, advanced
);
break;
case cmCacheManager::STRING:
@@ -850,7 +838,7 @@ void CMakeSetupDialog::FillCacheGUIFromCacheManager()
value.c_str(),
i.GetProperty("HELPSTRING"),
CPropertyList::EDIT,"",
- reverseOrder
+ reverseOrder, advanced
);
break;
case cmCacheManager::INTERNAL:
@@ -858,6 +846,15 @@ void CMakeSetupDialog::FillCacheGUIFromCacheManager()
break;
}
}
+ if(m_CacheEntriesList.GetShowAdvanced())
+ {
+ m_CacheEntriesList.ShowAdvanced();
+ }
+ else
+ {
+ m_CacheEntriesList.HideAdvanced();
+ }
+
m_OKButton.EnableWindow(false);
if(cachem->GetSize() > 0 && !cmSystemTools::GetErrorOccuredFlag())
{
@@ -867,11 +864,22 @@ void CMakeSetupDialog::FillCacheGUIFromCacheManager()
i != items.end(); ++i)
{
CPropertyItem* item = *i;
- if(item->m_NewValue)
+ if(item->m_Advanced )
{
- // if one new value then disable to OK button
- enable = false;
- break;
+ if(item->m_NewValue && m_CacheEntriesList.GetShowAdvanced())
+ {
+ enable = false;
+ break;
+ }
+ }
+ else
+ {
+ if(item->m_NewValue)
+ {
+ // if one new value then disable to OK button
+ enable = false;
+ break;
+ }
}
}
if(enable)
@@ -1274,83 +1282,15 @@ void CMakeSetupDialog::OnHelpButton()
void CMakeSetupDialog::ShowAdvancedValues()
{
- cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
- for(cmCacheManager::CacheIterator i = cachem->NewIterator();
- !i.IsAtEnd(); i.Next())
- {
- const char* key = i.GetName();
- if(!i.GetPropertyAsBool("ADVANCED"))
- {
- continue;
- }
- switch(i.GetType() )
- {
- case cmCacheManager::BOOL:
- if(cmSystemTools::IsOn(i.GetValue()))
- {
- m_CacheEntriesList.AddProperty(key,
- "ON",
- i.GetProperty("HELPSTRING"),
- CPropertyList::COMBO,"ON|OFF",
- true
- );
- }
- else
- {
- m_CacheEntriesList.AddProperty(key,
- "OFF",
- i.GetProperty("HELPSTRING"),
- CPropertyList::COMBO,"ON|OFF",
- true
- );
- }
- break;
- case cmCacheManager::PATH:
- m_CacheEntriesList.AddProperty(key,
- i.GetValue(),
- i.GetProperty("HELPSTRING"),
- CPropertyList::PATH,"",
- true
- );
- break;
- case cmCacheManager::FILEPATH:
- m_CacheEntriesList.AddProperty(key,
- i.GetValue(),
- i.GetProperty("HELPSTRING"),
- CPropertyList::FILE,"",
- true
- );
- break;
- case cmCacheManager::STRING:
- m_CacheEntriesList.AddProperty(key,
- i.GetValue(),
- i.GetProperty("HELPSTRING"),
- CPropertyList::EDIT,"",
- true
- );
- break;
- case cmCacheManager::INTERNAL:
- m_CacheEntriesList.RemoveProperty(key);
- break;
- }
- }
+ m_CacheEntriesList.ShowAdvanced();
}
void CMakeSetupDialog::RemoveAdvancedValues()
{
- cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
-
- for(cmCacheManager::CacheIterator i = cachem->NewIterator();
- !i.IsAtEnd(); i.Next())
- {
- const char* key = i.GetName();
- if(i.GetPropertyAsBool("ADVANCED"))
- {
- m_CacheEntriesList.RemoveProperty(key);
- }
- }
+ m_CacheEntriesList.HideAdvanced();
}
+
void CMakeSetupDialog::OnAdvancedValues()
{
this->UpdateData();
diff --git a/Source/MFCDialog/PropertyList.cpp b/Source/MFCDialog/PropertyList.cpp
index bc1c8bc..a0e2755 100644
--- a/Source/MFCDialog/PropertyList.cpp
+++ b/Source/MFCDialog/PropertyList.cpp
@@ -20,6 +20,7 @@
CPropertyList::CPropertyList()
{
m_Dirty = false;
+ m_ShowAdvanced = false;
m_curSel = -1;
}
@@ -129,34 +130,52 @@ int CPropertyList::AddItem(CString txt)
int nIndex = AddString(txt);
return nIndex;
}
-
-int CPropertyList::AddPropItem(CPropertyItem* pItem, bool reverseOrder)
+// order = 0 sorted
+// order = 1 add to top
+// order = 2 add to bottom
+int CPropertyList::AddPropItem(CPropertyItem* pItem, int order)
{
+ if(pItem->m_Advanced && ! m_ShowAdvanced)
+ {
+ m_PropertyItems.insert(pItem);
+ return 0;
+ }
this->HideControls();
int nIndex;
- if(reverseOrder)
+ if(order)
{
- nIndex = InsertString(0, _T(""));
+ if(order == 1)
+ {
+ order = 0;
+ }
+ if(order == 2)
+ {
+ order = -1;
+ }
+ nIndex = InsertString(order, _T(""));
}
else
{
- nIndex = AddString(_T(""));
+ nIndex = AddString(pItem->m_propName);
}
SetItemDataPtr(nIndex,pItem);
m_PropertyItems.insert(pItem);
return nIndex;
}
-int CPropertyList::AddProperty(const char* name,
- const char* value,
- const char* helpString,
- int type,
- const char* comboItems, bool reverseOrder)
+void CPropertyList::AddProperty(const char* name,
+ const char* value,
+ const char* helpString,
+ int type,
+ const char* comboItems,
+ bool reverseOrder,
+ bool advanced)
{
- CPropertyItem* pItem = 0;
- for(int i =0; i < this->GetCount(); ++i)
+ CPropertyItem* pItem = 0;
+ for(std::set<CPropertyItem*>::iterator i = m_PropertyItems.begin();
+ i != m_PropertyItems.end(); ++i)
{
- CPropertyItem* item = this->GetItem(i);
+ CPropertyItem* item = *i;
if(item->m_propName == name)
{
pItem = item;
@@ -166,7 +185,7 @@ int CPropertyList::AddProperty(const char* name,
pItem->m_HelpString = helpString;
InvalidateList();
}
- return i;
+ return;
}
}
// if it is not found, then create a new one
@@ -175,7 +194,14 @@ int CPropertyList::AddProperty(const char* name,
pItem = new CPropertyItem(name, value, helpString, type, comboItems);
pItem->m_NewValue = true;
}
- return this->AddPropItem(pItem, reverseOrder);
+ pItem->m_Advanced = advanced;
+ int order = 0;
+ if(reverseOrder)
+ {
+ order = 1;
+ }
+ this->AddPropItem(pItem, order);
+ return;
}
int CPropertyList::OnCreate(LPCREATESTRUCT lpCreateStruct)
@@ -707,3 +733,66 @@ void CPropertyList::InvalidateList()
m_Dirty = true;
}
+void CPropertyList::ShowAdvanced()
+{
+ this->ResetContent();
+ m_ShowAdvanced = true;
+ std::map<std::string, CPropertyItem*> sortProps;
+ for(std::set<CPropertyItem*>::iterator i = m_PropertyItems.begin();
+ i != m_PropertyItems.end(); ++i)
+ {
+ sortProps[(const char*)(*i)->m_propName] = *i;
+ }
+ for(std::map<std::string, CPropertyItem*>::iterator i = sortProps.begin();
+ i != sortProps.end(); ++i)
+ {
+ CPropertyItem* item = i->second;
+ if(item->m_NewValue)
+ {
+ this->AddPropItem(item, 2);
+ }
+ }
+ for(std::map<std::string, CPropertyItem*>::iterator i = sortProps.begin();
+ i != sortProps.end(); ++i)
+ {
+ CPropertyItem* item = i->second;
+ if(!item->m_NewValue)
+ {
+ this->AddPropItem(item, 2);
+ }
+ }
+ this->InvalidateList();
+}
+
+
+void CPropertyList::HideAdvanced()
+{
+ this->ResetContent();
+ m_ShowAdvanced = false;
+ std::map<std::string, CPropertyItem*> sortProps;
+ for(std::set<CPropertyItem*>::iterator i = m_PropertyItems.begin();
+ i != m_PropertyItems.end(); ++i)
+ {
+ sortProps[(const char*)(*i)->m_propName] = *i;
+ }
+ for(std::map<std::string, CPropertyItem*>::iterator i = sortProps.begin();
+ i != sortProps.end(); ++i)
+ {
+ CPropertyItem* item = i->second;
+ if(item->m_NewValue && !item->m_Advanced)
+ {
+ this->AddPropItem(item, 2);
+ }
+ }
+ for(std::map<std::string, CPropertyItem*>::iterator i = sortProps.begin();
+ i != sortProps.end(); ++i)
+ {
+ CPropertyItem* item = i->second;
+ if(!item->m_Advanced && !item->m_NewValue)
+ {
+ this->AddPropItem(item, 2);
+ }
+ }
+ this->InvalidateList();
+}
+
diff --git a/Source/MFCDialog/PropertyList.h b/Source/MFCDialog/PropertyList.h
index 696cc9e..d3992a1 100644
--- a/Source/MFCDialog/PropertyList.h
+++ b/Source/MFCDialog/PropertyList.h
@@ -35,6 +35,7 @@ public:
CString m_cmbItems;
bool m_NewValue;
bool m_Removed;
+ bool m_Advanced;
public:
CPropertyItem(CString propName, CString curValue,
@@ -48,6 +49,7 @@ public:
m_curValue = curValue;
m_nItemType = nItemType;
m_cmbItems = cmbItems;
+ m_Advanced = false;
}
};
@@ -76,18 +78,22 @@ public:
// Operations
public:
+ bool GetShowAdvanced() {return m_ShowAdvanced;}
bool IsDirty() { return m_Dirty; }
void ClearDirty() { m_Dirty = false; }
int AddItem(CString txt);
- int AddProperty(const char* name,
+ void AddProperty(const char* name,
const char* value,
const char* helpString,
int type,
const char* comboItems,
- bool reverseOrder);
+ bool reverseOrder,
+ bool advanced);
void RemoveProperty(const char* name);
void HideControls();
+ void ShowAdvanced();
+ void HideAdvanced();
std::set<CPropertyItem*> GetItems()
{
return m_PropertyItems;
@@ -136,7 +142,10 @@ protected:
void InvertLine(CDC* pDC,CPoint ptFrom,CPoint ptTo);
void DisplayButton(CRect region);
- int AddPropItem(CPropertyItem* pItem, bool top);
+// order = 0 sorted
+// order = 1 add to top
+// order = 2 add to bottom
+ int AddPropItem(CPropertyItem* pItem, int order);
void InvalidateList();
CComboBox m_cmbBox;
@@ -158,6 +167,7 @@ protected:
BOOL m_bDivIsSet;
HCURSOR m_hCursorArrow;
HCURSOR m_hCursorSize;
+ bool m_ShowAdvanced;
std::set<CPropertyItem*> m_PropertyItems;
};