PropertyList.cpp 17 KB

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