PropertyList.cpp 19 KB

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