PropertyList.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  1. // PropertyList.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "shellapi.h"
  5. #include "CMakeSetup.h"
  6. #include "CMakeSetupDialog.h"
  7. #include "PathDialog.h"
  8. #include "../cmCacheManager.h"
  9. #include "../cmSystemTools.h"
  10. #include "../cmake.h"
  11. #define IDC_PROPCMBBOX 712
  12. #define IDC_PROPEDITBOX 713
  13. #define IDC_PROPBTNCTRL 714
  14. #define IDC_PROPCHECKBOXCTRL 715
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CPropertyList
  17. CPropertyList::CPropertyList()
  18. {
  19. m_Dirty = false;
  20. m_curSel = -1;
  21. }
  22. CPropertyList::~CPropertyList()
  23. {
  24. for(std::set<CPropertyItem*>::iterator i = m_PropertyItems.begin();
  25. i != m_PropertyItems.end(); ++i)
  26. {
  27. delete *i;
  28. }
  29. }
  30. BEGIN_MESSAGE_MAP(CPropertyList, CListBox)
  31. //{{AFX_MSG_MAP(CPropertyList)
  32. ON_WM_CREATE()
  33. ON_WM_VSCROLL()
  34. ON_CONTROL_REFLECT(LBN_SELCHANGE, OnSelchange)
  35. ON_WM_LBUTTONUP()
  36. ON_WM_KILLFOCUS()
  37. ON_WM_LBUTTONDOWN()
  38. ON_WM_RBUTTONUP()
  39. ON_WM_MOUSEMOVE()
  40. //}}AFX_MSG_MAP
  41. ON_CBN_KILLFOCUS(IDC_PROPCMBBOX, OnKillfocusCmbBox)
  42. ON_CBN_SELCHANGE(IDC_PROPCMBBOX, OnSelchangeCmbBox)
  43. ON_EN_KILLFOCUS(IDC_PROPEDITBOX, OnKillfocusEditBox)
  44. ON_EN_CHANGE(IDC_PROPEDITBOX, OnChangeEditBox)
  45. ON_BN_CLICKED(IDC_PROPBTNCTRL, OnButton)
  46. ON_BN_CLICKED(IDC_PROPCHECKBOXCTRL, OnCheckBox)
  47. ON_COMMAND(42, OnDelete)
  48. ON_COMMAND(43, OnHelp)
  49. ON_COMMAND(44, OnIgnore)
  50. END_MESSAGE_MAP()
  51. /////////////////////////////////////////////////////////////////////////////
  52. // CPropertyList message handlers
  53. BOOL CPropertyList::PreCreateWindow(CREATESTRUCT& cs)
  54. {
  55. if (!CListBox::PreCreateWindow(cs))
  56. return FALSE;
  57. cs.style &= ~(LBS_OWNERDRAWVARIABLE | LBS_SORT);
  58. cs.style |= LBS_OWNERDRAWFIXED;
  59. m_bTracking = FALSE;
  60. m_nDivider = 0;
  61. m_bDivIsSet = FALSE;
  62. return TRUE;
  63. }
  64. void CPropertyList::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
  65. {
  66. lpMeasureItemStruct->itemHeight = 20; //pixels
  67. }
  68. void CPropertyList::DrawItem(LPDRAWITEMSTRUCT lpDIS)
  69. {
  70. CDC dc;
  71. dc.Attach(lpDIS->hDC);
  72. CRect rectFull = lpDIS->rcItem;
  73. CRect rect = rectFull;
  74. if (m_nDivider==0)
  75. m_nDivider = rect.Width() / 2;
  76. rect.left = m_nDivider;
  77. CRect rect2 = rectFull;
  78. rect2.right = rect.left - 1;
  79. UINT nIndex = lpDIS->itemID;
  80. if (nIndex != (UINT) -1)
  81. {
  82. //get the CPropertyItem for the current row
  83. CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(nIndex);
  84. //draw two rectangles, one for each row column
  85. if(pItem->m_NewValue)
  86. {
  87. dc.FillSolidRect(rect2,RGB(255,100, 100));
  88. }
  89. else
  90. {
  91. dc.FillSolidRect(rect2,RGB(192,192,192));
  92. }
  93. dc.DrawEdge(rect2,EDGE_SUNKEN,BF_BOTTOMRIGHT);
  94. dc.DrawEdge(rect,EDGE_SUNKEN,BF_BOTTOM);
  95. //write the property name in the first rectangle
  96. dc.SetBkMode(TRANSPARENT);
  97. dc.DrawText(pItem->m_propName,CRect(rect2.left+3,rect2.top+3,
  98. rect2.right-3,rect2.bottom+3),
  99. DT_LEFT | DT_SINGLELINE);
  100. //write the initial property value in the second rectangle
  101. dc.DrawText(pItem->m_curValue,CRect(rect.left+3,rect.top+3,
  102. rect.right+3,rect.bottom+3),
  103. DT_LEFT | DT_SINGLELINE);
  104. }
  105. dc.Detach();
  106. }
  107. int CPropertyList::AddItem(CString txt)
  108. {
  109. int nIndex = AddString(txt);
  110. return nIndex;
  111. }
  112. int CPropertyList::AddPropItem(CPropertyItem* pItem, bool reverseOrder)
  113. {
  114. this->HideControls();
  115. int nIndex;
  116. if(reverseOrder)
  117. {
  118. nIndex = InsertString(0, _T(""));
  119. }
  120. else
  121. {
  122. nIndex = AddString(_T(""));
  123. }
  124. SetItemDataPtr(nIndex,pItem);
  125. m_PropertyItems.insert(pItem);
  126. return nIndex;
  127. }
  128. int CPropertyList::AddProperty(const char* name,
  129. const char* value,
  130. const char* helpString,
  131. int type,
  132. const char* comboItems, bool reverseOrder)
  133. {
  134. CPropertyItem* pItem = 0;
  135. for(int i =0; i < this->GetCount(); ++i)
  136. {
  137. CPropertyItem* item = this->GetItem(i);
  138. if(item->m_propName == name)
  139. {
  140. pItem = item;
  141. if(pItem->m_curValue != value)
  142. {
  143. pItem->m_curValue = value;
  144. pItem->m_HelpString = helpString;
  145. InvalidateList();
  146. }
  147. return i;
  148. }
  149. }
  150. // if it is not found, then create a new one
  151. if(!pItem)
  152. {
  153. pItem = new CPropertyItem(name, value, helpString, type, comboItems);
  154. pItem->m_NewValue = true;
  155. }
  156. return this->AddPropItem(pItem, reverseOrder);
  157. }
  158. int CPropertyList::OnCreate(LPCREATESTRUCT lpCreateStruct)
  159. {
  160. if (CListBox::OnCreate(lpCreateStruct) == -1)
  161. return -1;
  162. m_bDivIsSet = FALSE;
  163. m_nDivider = 0;
  164. m_bTracking = FALSE;
  165. m_hCursorSize = AfxGetApp()->LoadStandardCursor(IDC_SIZEWE);
  166. m_hCursorArrow = AfxGetApp()->LoadStandardCursor(IDC_ARROW);
  167. m_SSerif8Font.CreatePointFont(80,_T("MS Sans Serif"));
  168. return 0;
  169. }
  170. void CPropertyList::OnSelchange()
  171. {
  172. CRect rect;
  173. CString lBoxSelText;
  174. GetItemRect(m_curSel,rect);
  175. rect.left = m_nDivider;
  176. CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(m_curSel);
  177. if (m_btnCtrl)
  178. m_btnCtrl.ShowWindow(SW_HIDE);
  179. if (m_CheckBoxControl)
  180. m_CheckBoxControl.ShowWindow(SW_HIDE);
  181. if (pItem->m_nItemType==CPropertyList::COMBO)
  182. {
  183. //display the combo box. If the combo box has already been
  184. //created then simply move it to the new location, else create it
  185. m_nLastBox = 0;
  186. if (m_cmbBox)
  187. m_cmbBox.MoveWindow(rect);
  188. else
  189. {
  190. rect.bottom += 100;
  191. m_cmbBox.Create(CBS_DROPDOWNLIST
  192. | CBS_NOINTEGRALHEIGHT | WS_VISIBLE
  193. | WS_CHILD | WS_BORDER,
  194. rect,this,IDC_PROPCMBBOX);
  195. m_cmbBox.SetFont(&m_SSerif8Font);
  196. }
  197. //add the choices for this particular property
  198. CString cmbItems = pItem->m_cmbItems;
  199. lBoxSelText = pItem->m_curValue;
  200. m_cmbBox.ResetContent();
  201. int i,i2;
  202. i=0;
  203. while ((i2=cmbItems.Find('|',i)) != -1)
  204. {
  205. m_cmbBox.AddString(cmbItems.Mid(i,i2-i));
  206. i=i2+1;
  207. }
  208. if(i != 0)
  209. m_cmbBox.AddString(cmbItems.Mid(i));
  210. m_cmbBox.ShowWindow(SW_SHOW);
  211. m_cmbBox.SetFocus();
  212. //jump to the property's current value in the combo box
  213. int j = m_cmbBox.FindStringExact(0,lBoxSelText);
  214. if (j != CB_ERR)
  215. m_cmbBox.SetCurSel(j);
  216. else
  217. m_cmbBox.SetCurSel(0);
  218. }
  219. else if (pItem->m_nItemType==CPropertyList::EDIT)
  220. {
  221. //display edit box
  222. m_nLastBox = 1;
  223. m_prevSel = m_curSel;
  224. rect.bottom -= 3;
  225. if (m_editBox)
  226. m_editBox.MoveWindow(rect);
  227. else
  228. {
  229. m_editBox.Create(ES_LEFT | ES_AUTOHSCROLL | WS_VISIBLE
  230. | WS_CHILD | WS_BORDER,
  231. rect,this,IDC_PROPEDITBOX);
  232. m_editBox.SetFont(&m_SSerif8Font);
  233. }
  234. lBoxSelText = pItem->m_curValue;
  235. m_editBox.ShowWindow(SW_SHOW);
  236. m_editBox.SetFocus();
  237. //set the text in the edit box to the property's current value
  238. m_editBox.SetWindowText(lBoxSelText);
  239. }
  240. else if (pItem->m_nItemType == CPropertyList::CHECKBOX)
  241. {
  242. rect.bottom -= 3;
  243. if (m_CheckBoxControl)
  244. m_CheckBoxControl.MoveWindow(rect);
  245. else
  246. {
  247. m_CheckBoxControl.Create("check",BS_CHECKBOX
  248. | BM_SETCHECK |BS_LEFTTEXT
  249. | WS_VISIBLE | WS_CHILD,
  250. rect,this,IDC_PROPCHECKBOXCTRL);
  251. m_CheckBoxControl.SetFont(&m_SSerif8Font);
  252. }
  253. lBoxSelText = pItem->m_curValue;
  254. m_CheckBoxControl.ShowWindow(SW_SHOW);
  255. m_CheckBoxControl.SetFocus();
  256. //set the text in the edit box to the property's current value
  257. if(lBoxSelText == "ON")
  258. {
  259. m_CheckBoxControl.SetCheck(1);
  260. }
  261. else
  262. {
  263. m_CheckBoxControl.SetCheck(0);
  264. }
  265. }
  266. else
  267. DisplayButton(rect);
  268. }
  269. void CPropertyList::DisplayButton(CRect region)
  270. {
  271. //displays a button if the property is a file/color/font chooser
  272. m_nLastBox = 2;
  273. m_prevSel = m_curSel;
  274. if (region.Width() > 25)
  275. region.left = region.right - 25;
  276. region.bottom -= 3;
  277. if (m_btnCtrl)
  278. m_btnCtrl.MoveWindow(region);
  279. else
  280. {
  281. m_btnCtrl.Create("...",BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD,
  282. region,this,IDC_PROPBTNCTRL);
  283. m_btnCtrl.SetFont(&m_SSerif8Font);
  284. }
  285. m_btnCtrl.ShowWindow(SW_SHOW);
  286. m_btnCtrl.SetFocus();
  287. }
  288. void CPropertyList::OnKillFocus(CWnd* pNewWnd)
  289. {
  290. //m_btnCtrl.ShowWindow(SW_HIDE);
  291. CListBox::OnKillFocus(pNewWnd);
  292. }
  293. void CPropertyList::OnKillfocusCmbBox()
  294. {
  295. m_cmbBox.ShowWindow(SW_HIDE);
  296. Invalidate();
  297. }
  298. void CPropertyList::OnKillfocusEditBox()
  299. {
  300. CString newStr;
  301. m_editBox.ShowWindow(SW_HIDE);
  302. Invalidate();
  303. }
  304. void CPropertyList::OnSelchangeCmbBox()
  305. {
  306. CString selStr;
  307. if (m_cmbBox)
  308. {
  309. m_cmbBox.GetLBText(m_cmbBox.GetCurSel(),selStr);
  310. CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(m_curSel);
  311. pItem->m_curValue = selStr;
  312. m_Dirty = true;
  313. }
  314. }
  315. void CPropertyList::OnChangeEditBox()
  316. {
  317. CString newStr;
  318. m_editBox.GetWindowText(newStr);
  319. CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(m_curSel);
  320. if(pItem->m_curValue != newStr)
  321. {
  322. pItem->m_curValue = newStr;
  323. m_Dirty = true;
  324. }
  325. }
  326. void CPropertyList::HideControls()
  327. {
  328. if(m_editBox)
  329. {
  330. m_editBox.ShowWindow(SW_HIDE);
  331. }
  332. if(m_cmbBox)
  333. {
  334. m_cmbBox.ShowWindow(SW_HIDE);
  335. }
  336. if(m_CheckBoxControl)
  337. {
  338. m_CheckBoxControl.ShowWindow(SW_HIDE);
  339. }
  340. if(m_btnCtrl)
  341. {
  342. m_btnCtrl.ShowWindow(SW_HIDE);
  343. }
  344. }
  345. void CPropertyList::OnVScroll( UINT nSBCode, UINT nPos, CScrollBar* pScrollBar )
  346. {
  347. this->HideControls();
  348. CListBox::OnVScroll(nSBCode, nPos, pScrollBar);
  349. }
  350. void CPropertyList::OnCheckBox()
  351. {
  352. CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(m_curSel);
  353. if(m_CheckBoxControl.GetCheck())
  354. {
  355. pItem->m_curValue = "ON";
  356. }
  357. else
  358. {
  359. pItem->m_curValue = "OFF";
  360. }
  361. m_Dirty = true;
  362. }
  363. void CPropertyList::OnButton()
  364. {
  365. CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(m_curSel);
  366. //display the appropriate common dialog depending on what type
  367. //of chooser is associated with the property
  368. if (pItem->m_nItemType == CPropertyList::FILE)
  369. {
  370. CString SelectedFile;
  371. CString Filter("All Files (*.*)||");
  372. CFileDialog FileDlg(TRUE, NULL, NULL, NULL,
  373. Filter);
  374. CString initialDir;
  375. CString currPath = pItem->m_curValue;
  376. if (currPath.Right(9) == "-NOTFOUND" || currPath == "NOTFOUND")
  377. {
  378. currPath = "";
  379. }
  380. if (currPath.GetLength() > 0)
  381. {
  382. int endSlash = currPath.ReverseFind('\\');
  383. if(endSlash == -1)
  384. {
  385. endSlash = currPath.ReverseFind('/');
  386. }
  387. initialDir = currPath.Left(endSlash);
  388. }
  389. initialDir.Replace("/", "\\");
  390. FileDlg.m_ofn.lpstrTitle = "Select file";
  391. if (currPath.GetLength() > 0)
  392. FileDlg.m_ofn.lpstrInitialDir = initialDir;
  393. if(IDOK == FileDlg.DoModal())
  394. {
  395. SelectedFile = FileDlg.GetPathName();
  396. m_btnCtrl.ShowWindow(SW_HIDE);
  397. std::string path = SelectedFile;
  398. cmSystemTools::ConvertToUnixSlashes(path);
  399. pItem->m_curValue = path.c_str();
  400. m_Dirty = true;
  401. InvalidateList();
  402. }
  403. }
  404. else if (pItem->m_nItemType == CPropertyList::PATH)
  405. {
  406. CString initialDir = pItem->m_curValue;
  407. // convert back to windos style path
  408. initialDir.Replace("/", "\\");
  409. CString title = "Setting Cache Value: ";
  410. title += pItem->m_propName;
  411. CPathDialog dlg("Select Path", title, initialDir);
  412. if(dlg.DoModal()==IDOK)
  413. {
  414. CString SelectedFile = dlg.GetPathName();
  415. m_btnCtrl.ShowWindow(SW_HIDE);
  416. std::string path = SelectedFile;
  417. cmSystemTools::ConvertToUnixSlashes(path);
  418. pItem->m_curValue = path.c_str();
  419. m_Dirty = true;
  420. InvalidateList();
  421. }
  422. }
  423. }
  424. void CPropertyList::OnLButtonUp(UINT nFlags, CPoint point)
  425. {
  426. if (m_bTracking)
  427. {
  428. //if columns were being resized then this indicates
  429. //that mouse is up so resizing is done. Need to redraw
  430. //columns to reflect their new widths.
  431. m_bTracking = FALSE;
  432. //if mouse was captured then release it
  433. if (GetCapture()==this)
  434. ::ReleaseCapture();
  435. ::ClipCursor(NULL);
  436. CClientDC dc(this);
  437. InvertLine(&dc,CPoint(point.x,m_nDivTop),CPoint(point.x,m_nDivBtm));
  438. //set the divider position to the new value
  439. m_nDivider = point.x;
  440. //redraw
  441. Invalidate();
  442. }
  443. else
  444. {
  445. BOOL loc;
  446. int i = ItemFromPoint(point,loc);
  447. m_curSel = i;
  448. CListBox::OnLButtonUp(nFlags, point);
  449. }
  450. }
  451. void CPropertyList::OnLButtonDown(UINT nFlags, CPoint point)
  452. {
  453. if ((point.x>=m_nDivider-5) && (point.x<=m_nDivider+5))
  454. {
  455. //if mouse clicked on divider line, then start resizing
  456. ::SetCursor(m_hCursorSize);
  457. CRect windowRect;
  458. GetWindowRect(windowRect);
  459. windowRect.left += 10; windowRect.right -= 10;
  460. //do not let mouse leave the list box boundary
  461. ::ClipCursor(windowRect);
  462. if (m_cmbBox)
  463. m_cmbBox.ShowWindow(SW_HIDE);
  464. if (m_editBox)
  465. m_editBox.ShowWindow(SW_HIDE);
  466. CRect clientRect;
  467. GetClientRect(clientRect);
  468. m_bTracking = TRUE;
  469. m_nDivTop = clientRect.top;
  470. m_nDivBtm = clientRect.bottom;
  471. m_nOldDivX = point.x;
  472. CClientDC dc(this);
  473. InvertLine(&dc,CPoint(m_nOldDivX,m_nDivTop),CPoint(m_nOldDivX,m_nDivBtm));
  474. //capture the mouse
  475. SetCapture();
  476. }
  477. else
  478. {
  479. m_bTracking = FALSE;
  480. CListBox::OnLButtonDown(nFlags, point);
  481. }
  482. }
  483. void CPropertyList::OnMouseMove(UINT nFlags, CPoint point)
  484. {
  485. if (m_bTracking)
  486. {
  487. //move divider line to the mouse pos. if columns are
  488. //currently being resized
  489. CClientDC dc(this);
  490. //remove old divider line
  491. InvertLine(&dc,CPoint(m_nOldDivX,m_nDivTop),CPoint(m_nOldDivX,m_nDivBtm));
  492. //draw new divider line
  493. InvertLine(&dc,CPoint(point.x,m_nDivTop),CPoint(point.x,m_nDivBtm));
  494. m_nOldDivX = point.x;
  495. }
  496. else if ((point.x >= m_nDivider-5) && (point.x <= m_nDivider+5))
  497. //set the cursor to a sizing cursor if the cursor is over the row divider
  498. ::SetCursor(m_hCursorSize);
  499. else
  500. {
  501. BOOL loc;
  502. int curSel = ItemFromPoint(point,loc);
  503. if(!loc && curSel < 65535)
  504. {
  505. CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(curSel);
  506. m_CMakeSetupDialog->SetDlgItemText(IDC_PROGRESS, pItem->m_HelpString);
  507. }
  508. CListBox::OnMouseMove(nFlags, point);
  509. }
  510. }
  511. void CPropertyList::InvertLine(CDC* pDC,CPoint ptFrom,CPoint ptTo)
  512. {
  513. int nOldMode = pDC->SetROP2(R2_NOT);
  514. pDC->MoveTo(ptFrom);
  515. pDC->LineTo(ptTo);
  516. pDC->SetROP2(nOldMode);
  517. }
  518. void CPropertyList::PreSubclassWindow()
  519. {
  520. m_bDivIsSet = FALSE;
  521. m_nDivider = 0;
  522. m_bTracking = FALSE;
  523. m_curSel = 1;
  524. m_hCursorSize = AfxGetApp()->LoadStandardCursor(IDC_SIZEWE);
  525. m_hCursorArrow = AfxGetApp()->LoadStandardCursor(IDC_ARROW);
  526. m_SSerif8Font.CreatePointFont(80,_T("MS Sans Serif"));
  527. }
  528. CPropertyItem* CPropertyList::GetItem(int index)
  529. {
  530. return (CPropertyItem*)GetItemDataPtr(index);
  531. }
  532. void CPropertyList::OnRButtonUp( UINT nFlags, CPoint point )
  533. {
  534. CMenu menu;
  535. CRect rect;
  536. this->GetWindowRect(&rect);
  537. BOOL loc;
  538. m_curSel = ItemFromPoint(point,loc);
  539. menu.CreatePopupMenu();
  540. menu.AppendMenu(MF_STRING | MF_ENABLED, 44, "Ignore Cache Entry");
  541. menu.AppendMenu(MF_STRING | MF_ENABLED, 42, "Delete Cache Entry");
  542. menu.AppendMenu(MF_STRING | MF_ENABLED, 43, "Help For Cache Entry");
  543. menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,
  544. rect.TopLeft().x + point.x,
  545. rect.TopLeft().y + point.y, this, NULL);
  546. }
  547. void CPropertyList::RemoveProperty(const char* name)
  548. {
  549. for(int i =0; i < this->GetCount(); ++i)
  550. {
  551. CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(i);
  552. if(pItem->m_propName == name)
  553. {
  554. m_PropertyItems.erase(pItem);
  555. delete pItem;
  556. this->DeleteString(i);
  557. return;
  558. }
  559. }
  560. }
  561. void CPropertyList::OnIgnore()
  562. {
  563. if(m_curSel == -1 || this->GetCount() <= 0)
  564. {
  565. return;
  566. }
  567. CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(m_curSel);
  568. pItem->m_curValue = "IGNORE";
  569. InvalidateList();
  570. }
  571. void CPropertyList::OnDelete()
  572. {
  573. if(m_curSel == -1 || this->GetCount() <= 0)
  574. {
  575. return;
  576. }
  577. CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(m_curSel);
  578. m_CMakeSetupDialog->GetCMakeInstance()->GetCacheManager()->RemoveCacheEntry(pItem->m_propName);
  579. m_PropertyItems.erase(pItem);
  580. delete pItem;
  581. this->DeleteString(m_curSel);
  582. this->HideControls();
  583. this->SetTopIndex(0);
  584. InvalidateList();
  585. }
  586. void CPropertyList::OnHelp()
  587. {
  588. if(m_curSel == -1 || this->GetCount() <= 0)
  589. {
  590. return;
  591. }
  592. CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(m_curSel);
  593. MessageBox(pItem->m_HelpString, pItem->m_propName, MB_OK|MB_ICONINFORMATION);
  594. }
  595. void CPropertyList::RemoveAll()
  596. {
  597. int c = this->GetCount();
  598. for(int i =0; i < c; ++i)
  599. {
  600. CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(0);
  601. m_CMakeSetupDialog->GetCMakeInstance()->GetCacheManager()
  602. ->RemoveCacheEntry(pItem->m_propName);
  603. m_PropertyItems.erase(pItem);
  604. delete pItem;
  605. this->DeleteString(0);
  606. }
  607. m_Dirty = false;
  608. this->HideControls();
  609. InvalidateList();
  610. }
  611. void CPropertyList::InvalidateList()
  612. {
  613. Invalidate();
  614. m_Dirty = true;
  615. }