PropertyList.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698
  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 == "NOTFOUND")
  374. {
  375. currPath = "";
  376. }
  377. if (currPath.GetLength() > 0)
  378. {
  379. int endSlash = currPath.ReverseFind('\\');
  380. if(endSlash == -1)
  381. {
  382. endSlash = currPath.ReverseFind('/');
  383. }
  384. initialDir = currPath.Left(endSlash);
  385. }
  386. initialDir.Replace("/", "\\");
  387. FileDlg.m_ofn.lpstrTitle = "Select file";
  388. if (currPath.GetLength() > 0)
  389. FileDlg.m_ofn.lpstrInitialDir = initialDir;
  390. if(IDOK == FileDlg.DoModal())
  391. {
  392. SelectedFile = FileDlg.GetPathName();
  393. m_btnCtrl.ShowWindow(SW_HIDE);
  394. std::string path = SelectedFile;
  395. cmSystemTools::ConvertToUnixSlashes(path);
  396. pItem->m_curValue = path.c_str();
  397. m_Dirty = true;
  398. InvalidateList();
  399. }
  400. }
  401. else if (pItem->m_nItemType == CPropertyList::PATH)
  402. {
  403. CString initialDir = pItem->m_curValue;
  404. // convert back to windos style path
  405. initialDir.Replace("/", "\\");
  406. CString title = "Setting Cache Value: ";
  407. title += pItem->m_propName;
  408. CPathDialog dlg("Select Path", title, initialDir);
  409. if(dlg.DoModal()==IDOK)
  410. {
  411. CString SelectedFile = dlg.GetPathName();
  412. m_btnCtrl.ShowWindow(SW_HIDE);
  413. std::string path = SelectedFile;
  414. cmSystemTools::ConvertToUnixSlashes(path);
  415. pItem->m_curValue = path.c_str();
  416. m_Dirty = true;
  417. InvalidateList();
  418. }
  419. }
  420. }
  421. void CPropertyList::OnLButtonUp(UINT nFlags, CPoint point)
  422. {
  423. if (m_bTracking)
  424. {
  425. //if columns were being resized then this indicates
  426. //that mouse is up so resizing is done. Need to redraw
  427. //columns to reflect their new widths.
  428. m_bTracking = FALSE;
  429. //if mouse was captured then release it
  430. if (GetCapture()==this)
  431. ::ReleaseCapture();
  432. ::ClipCursor(NULL);
  433. CClientDC dc(this);
  434. InvertLine(&dc,CPoint(point.x,m_nDivTop),CPoint(point.x,m_nDivBtm));
  435. //set the divider position to the new value
  436. m_nDivider = point.x;
  437. //redraw
  438. Invalidate();
  439. }
  440. else
  441. {
  442. BOOL loc;
  443. int i = ItemFromPoint(point,loc);
  444. m_curSel = i;
  445. CListBox::OnLButtonUp(nFlags, point);
  446. }
  447. }
  448. void CPropertyList::OnLButtonDown(UINT nFlags, CPoint point)
  449. {
  450. if ((point.x>=m_nDivider-5) && (point.x<=m_nDivider+5))
  451. {
  452. //if mouse clicked on divider line, then start resizing
  453. ::SetCursor(m_hCursorSize);
  454. CRect windowRect;
  455. GetWindowRect(windowRect);
  456. windowRect.left += 10; windowRect.right -= 10;
  457. //do not let mouse leave the list box boundary
  458. ::ClipCursor(windowRect);
  459. if (m_cmbBox)
  460. m_cmbBox.ShowWindow(SW_HIDE);
  461. if (m_editBox)
  462. m_editBox.ShowWindow(SW_HIDE);
  463. CRect clientRect;
  464. GetClientRect(clientRect);
  465. m_bTracking = TRUE;
  466. m_nDivTop = clientRect.top;
  467. m_nDivBtm = clientRect.bottom;
  468. m_nOldDivX = point.x;
  469. CClientDC dc(this);
  470. InvertLine(&dc,CPoint(m_nOldDivX,m_nDivTop),CPoint(m_nOldDivX,m_nDivBtm));
  471. //capture the mouse
  472. SetCapture();
  473. }
  474. else
  475. {
  476. m_bTracking = FALSE;
  477. CListBox::OnLButtonDown(nFlags, point);
  478. }
  479. }
  480. void CPropertyList::OnMouseMove(UINT nFlags, CPoint point)
  481. {
  482. if (m_bTracking)
  483. {
  484. //move divider line to the mouse pos. if columns are
  485. //currently being resized
  486. CClientDC dc(this);
  487. //remove old divider line
  488. InvertLine(&dc,CPoint(m_nOldDivX,m_nDivTop),CPoint(m_nOldDivX,m_nDivBtm));
  489. //draw new divider line
  490. InvertLine(&dc,CPoint(point.x,m_nDivTop),CPoint(point.x,m_nDivBtm));
  491. m_nOldDivX = point.x;
  492. }
  493. else if ((point.x >= m_nDivider-5) && (point.x <= m_nDivider+5))
  494. //set the cursor to a sizing cursor if the cursor is over the row divider
  495. ::SetCursor(m_hCursorSize);
  496. else
  497. CListBox::OnMouseMove(nFlags, point);
  498. }
  499. void CPropertyList::InvertLine(CDC* pDC,CPoint ptFrom,CPoint ptTo)
  500. {
  501. int nOldMode = pDC->SetROP2(R2_NOT);
  502. pDC->MoveTo(ptFrom);
  503. pDC->LineTo(ptTo);
  504. pDC->SetROP2(nOldMode);
  505. }
  506. void CPropertyList::PreSubclassWindow()
  507. {
  508. m_bDivIsSet = FALSE;
  509. m_nDivider = 0;
  510. m_bTracking = FALSE;
  511. m_curSel = 1;
  512. m_hCursorSize = AfxGetApp()->LoadStandardCursor(IDC_SIZEWE);
  513. m_hCursorArrow = AfxGetApp()->LoadStandardCursor(IDC_ARROW);
  514. m_SSerif8Font.CreatePointFont(80,_T("MS Sans Serif"));
  515. }
  516. CPropertyItem* CPropertyList::GetItem(int index)
  517. {
  518. return (CPropertyItem*)GetItemDataPtr(index);
  519. }
  520. void CPropertyList::OnRButtonUp( UINT nFlags, CPoint point )
  521. {
  522. CMenu menu;
  523. CRect rect;
  524. this->GetWindowRect(&rect);
  525. BOOL loc;
  526. m_curSel = ItemFromPoint(point,loc);
  527. menu.CreatePopupMenu();
  528. menu.AppendMenu(MF_STRING | MF_ENABLED, 44, "Ignore Cache Entry");
  529. menu.AppendMenu(MF_STRING | MF_ENABLED, 42, "Delete Cache Entry");
  530. menu.AppendMenu(MF_STRING | MF_ENABLED, 43, "Help For Cache Entry");
  531. menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,
  532. rect.TopLeft().x + point.x,
  533. rect.TopLeft().y + point.y, this, NULL);
  534. }
  535. void CPropertyList::RemoveProperty(const char* name)
  536. {
  537. for(int i =0; i < this->GetCount(); ++i)
  538. {
  539. CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(i);
  540. if(pItem->m_propName == name)
  541. {
  542. m_PropertyItems.erase(pItem);
  543. delete pItem;
  544. this->DeleteString(i);
  545. return;
  546. }
  547. }
  548. }
  549. void CPropertyList::OnIgnore()
  550. {
  551. if(m_curSel == -1 || this->GetCount() <= 0)
  552. {
  553. return;
  554. }
  555. CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(m_curSel);
  556. pItem->m_curValue = "IGNORE";
  557. InvalidateList();
  558. }
  559. void CPropertyList::OnDelete()
  560. {
  561. if(m_curSel == -1 || this->GetCount() <= 0)
  562. {
  563. return;
  564. }
  565. CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(m_curSel);
  566. cmCacheManager::GetInstance()->RemoveCacheEntry(pItem->m_propName);
  567. m_PropertyItems.erase(pItem);
  568. delete pItem;
  569. this->DeleteString(m_curSel);
  570. this->HideControls();
  571. this->SetTopIndex(0);
  572. InvalidateList();
  573. }
  574. void CPropertyList::OnHelp()
  575. {
  576. if(m_curSel == -1 || this->GetCount() <= 0)
  577. {
  578. return;
  579. }
  580. CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(m_curSel);
  581. MessageBox(pItem->m_HelpString, pItem->m_propName, MB_OK|MB_ICONINFORMATION);
  582. }
  583. void CPropertyList::RemoveAll()
  584. {
  585. int c = this->GetCount();
  586. for(int i =0; i < c; ++i)
  587. {
  588. CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(0);
  589. cmCacheManager::GetInstance()->RemoveCacheEntry(pItem->m_propName);
  590. m_PropertyItems.erase(pItem);
  591. delete pItem;
  592. this->DeleteString(0);
  593. }
  594. m_Dirty = false;
  595. this->HideControls();
  596. InvalidateList();
  597. }
  598. void CPropertyList::InvalidateList()
  599. {
  600. Invalidate();
  601. m_Dirty = true;
  602. }