PropertyList.cpp 19 KB

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