5
#include "PropertyList.h"
6
#include "CMakeSetup.h"
7
#include "CMakeSetupDialog.h"
6
8
#include "PathDialog.h"
7
9
#include "../cmCacheManager.h"
8
10
#include "../cmSystemTools.h"
10
12
#define IDC_PROPCMBBOX 712
11
13
#define IDC_PROPEDITBOX 713
12
14
#define IDC_PROPBTNCTRL 714
126
130
int nIndex = AddString(txt);
130
int CPropertyList::AddPropItem(CPropertyItem* pItem, bool reverseOrder)
134
// order = 1 add to top
135
// order = 2 add to bottom
136
int CPropertyList::AddPropItem(CPropertyItem* pItem, int order)
138
if(pItem->m_Advanced && ! m_ShowAdvanced)
140
m_PropertyItems.insert(pItem);
132
143
this->HideControls();
136
nIndex = InsertString(0, _T(""));
155
nIndex = InsertString(order, _T(""));
140
nIndex = AddString(_T(""));
159
nIndex = AddString(pItem->m_propName);
142
161
SetItemDataPtr(nIndex,pItem);
143
162
m_PropertyItems.insert(pItem);
147
int CPropertyList::AddProperty(const char* name,
149
const char* helpString,
151
const char* comboItems, bool reverseOrder)
166
void CPropertyList::AddProperty(const char* name,
168
const char* helpString,
170
const char* comboItems,
153
CPropertyItem* pItem = 0;
154
for(int i =0; i < this->GetCount(); ++i)
174
CPropertyItem* pItem = 0;
175
for(std::set<CPropertyItem*>::iterator i = m_PropertyItems.begin();
176
i != m_PropertyItems.end(); ++i)
156
CPropertyItem* item = this->GetItem(i);
178
CPropertyItem* item = *i;
157
179
if(item->m_propName == name)
172
195
pItem = new CPropertyItem(name, value, helpString, type, comboItems);
173
196
pItem->m_NewValue = true;
175
return this->AddPropItem(pItem, reverseOrder);
198
pItem->m_Advanced = advanced;
204
this->AddPropItem(pItem, order);
178
208
int CPropertyList::OnCreate(LPCREATESTRUCT lpCreateStruct)
319
349
m_btnCtrl.MoveWindow(region);
322
352
m_btnCtrl.Create("...",BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD,
323
353
region,this,IDC_PROPBTNCTRL);
324
354
m_btnCtrl.SetFont(&m_SSerif8Font);
421
451
CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(m_curSel);
453
// The dialogs might change the working directory. Save it.
454
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
423
456
//display the appropriate common dialog depending on what type
424
457
//of chooser is associated with the property
428
461
CString SelectedFile;
429
462
CString Filter("All Files (*.*)||");
431
464
CFileDialog FileDlg(TRUE, NULL, NULL, NULL,
433
466
CString initialDir;
434
467
CString currPath = pItem->m_curValue;
468
if (currPath.Right(9) == "-NOTFOUND" || currPath == "NOTFOUND")
435
472
if (currPath.GetLength() > 0)
437
474
int endSlash = currPath.ReverseFind('\\');
440
477
endSlash = currPath.ReverseFind('/');
442
479
initialDir = currPath.Left(endSlash);
444
481
initialDir.Replace("/", "\\");
445
482
FileDlg.m_ofn.lpstrTitle = "Select file";
446
483
if (currPath.GetLength() > 0)
449
486
if(IDOK == FileDlg.DoModal())
451
488
SelectedFile = FileDlg.GetPathName();
453
490
m_btnCtrl.ShowWindow(SW_HIDE);
454
491
std::string path = SelectedFile;
455
492
cmSystemTools::ConvertToUnixSlashes(path);
568
607
//set the cursor to a sizing cursor if the cursor is over the row divider
569
608
::SetCursor(m_hCursorSize);
612
int curSel = ItemFromPoint(point,loc);
613
if(!loc && curSel < 65535)
615
CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(curSel);
616
m_CMakeSetupDialog->SetDlgItemText(IDC_PROGRESS, pItem->m_HelpString);
571
618
CListBox::OnMouseMove(nFlags, point);
574
623
void CPropertyList::InvertLine(CDC* pDC,CPoint ptFrom,CPoint ptTo)
576
625
int nOldMode = pDC->SetROP2(R2_NOT);
578
627
pDC->MoveTo(ptFrom);
579
628
pDC->LineTo(ptTo);
608
657
m_curSel = ItemFromPoint(point,loc);
609
658
menu.CreatePopupMenu();
659
menu.AppendMenu(MF_STRING | MF_ENABLED, 44, "Ignore Cache Entry");
610
660
menu.AppendMenu(MF_STRING | MF_ENABLED, 42, "Delete Cache Entry");
611
661
menu.AppendMenu(MF_STRING | MF_ENABLED, 43, "Help For Cache Entry");
612
662
menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,
682
void CPropertyList::OnIgnore()
684
if(m_curSel == -1 || this->GetCount() <= 0)
688
CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(m_curSel);
689
pItem->m_curValue = "IGNORE";
632
695
void CPropertyList::OnDelete()
634
697
if(m_curSel == -1 || this->GetCount() <= 0)
638
701
CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(m_curSel);
639
cmCacheManager::GetInstance()->RemoveCacheEntry(pItem->m_propName);
702
m_CMakeSetupDialog->GetCMakeInstance()->GetCacheManager()->RemoveCacheEntry(pItem->m_propName);
640
703
m_PropertyItems.erase(pItem);
642
705
this->DeleteString(m_curSel);
661
724
for(int i =0; i < c; ++i)
663
726
CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(0);
664
cmCacheManager::GetInstance()->RemoveCacheEntry(pItem->m_propName);
665
m_PropertyItems.erase(pItem);
667
727
this->DeleteString(0);
729
for(std::set<CPropertyItem*>::iterator ii = m_PropertyItems.begin();
730
ii != m_PropertyItems.end(); ++ii)
734
m_PropertyItems.clear();
670
736
this->HideControls();
671
737
InvalidateList();
746
void CPropertyList::ShowAdvanced()
748
this->SetRedraw(FALSE);
749
this->ResetContent();
750
m_ShowAdvanced = true;
751
std::map<std::string, CPropertyItem*> sortProps;
752
for(std::set<CPropertyItem*>::iterator i = m_PropertyItems.begin();
753
i != m_PropertyItems.end(); ++i)
755
sortProps[(const char*)(*i)->m_propName] = *i;
757
for(std::map<std::string, CPropertyItem*>::iterator i = sortProps.begin();
758
i != sortProps.end(); ++i)
760
CPropertyItem* item = i->second;
763
this->AddPropItem(item, 2);
766
for(std::map<std::string, CPropertyItem*>::iterator i = sortProps.begin();
767
i != sortProps.end(); ++i)
769
CPropertyItem* item = i->second;
770
if(!item->m_NewValue)
772
this->AddPropItem(item, 2);
775
this->SetRedraw(TRUE);
776
this->InvalidateList();
780
void CPropertyList::HideAdvanced()
782
this->SetRedraw(FALSE);
783
this->ResetContent();
784
m_ShowAdvanced = false;
785
std::map<std::string, CPropertyItem*> sortProps;
786
for(std::set<CPropertyItem*>::iterator i = m_PropertyItems.begin();
787
i != m_PropertyItems.end(); ++i)
789
sortProps[(const char*)(*i)->m_propName] = *i;
791
for(std::map<std::string, CPropertyItem*>::iterator i = sortProps.begin();
792
i != sortProps.end(); ++i)
794
CPropertyItem* item = i->second;
795
if(item->m_NewValue && !item->m_Advanced)
797
this->AddPropItem(item, 2);
800
for(std::map<std::string, CPropertyItem*>::iterator i = sortProps.begin();
801
i != sortProps.end(); ++i)
803
CPropertyItem* item = i->second;
804
if(!item->m_Advanced && !item->m_NewValue)
806
this->AddPropItem(item, 2);
809
this->SetRedraw(TRUE);
810
this->InvalidateList();