PropertyList.cpp 17 KB

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