1
0

PropertyList.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812
  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. // The dialogs might change the working directory. Save it.
  395. std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
  396. //display the appropriate common dialog depending on what type
  397. //of chooser is associated with the property
  398. if (pItem->m_nItemType == CPropertyList::FILE)
  399. {
  400. CString SelectedFile;
  401. CString Filter("All Files (*.*)||");
  402. CFileDialog FileDlg(TRUE, NULL, NULL, NULL,
  403. Filter);
  404. CString initialDir;
  405. CString currPath = pItem->m_curValue;
  406. if (currPath.Right(9) == "-NOTFOUND" || currPath == "NOTFOUND")
  407. {
  408. currPath = "";
  409. }
  410. if (currPath.GetLength() > 0)
  411. {
  412. int endSlash = currPath.ReverseFind('\\');
  413. if(endSlash == -1)
  414. {
  415. endSlash = currPath.ReverseFind('/');
  416. }
  417. initialDir = currPath.Left(endSlash);
  418. }
  419. initialDir.Replace("/", "\\");
  420. FileDlg.m_ofn.lpstrTitle = "Select file";
  421. if (currPath.GetLength() > 0)
  422. FileDlg.m_ofn.lpstrInitialDir = initialDir;
  423. if(IDOK == FileDlg.DoModal())
  424. {
  425. SelectedFile = FileDlg.GetPathName();
  426. m_btnCtrl.ShowWindow(SW_HIDE);
  427. std::string path = SelectedFile;
  428. cmSystemTools::ConvertToUnixSlashes(path);
  429. pItem->m_curValue = path.c_str();
  430. m_Dirty = true;
  431. InvalidateList();
  432. }
  433. }
  434. else if (pItem->m_nItemType == CPropertyList::PATH)
  435. {
  436. CString initialDir = pItem->m_curValue;
  437. // convert back to windos style path
  438. initialDir.Replace("/", "\\");
  439. CString title = "Setting Cache Value: ";
  440. title += pItem->m_propName;
  441. CPathDialog dlg("Select Path", title, initialDir);
  442. if(dlg.DoModal()==IDOK)
  443. {
  444. CString SelectedFile = dlg.GetPathName();
  445. m_btnCtrl.ShowWindow(SW_HIDE);
  446. std::string path = SelectedFile;
  447. cmSystemTools::ConvertToUnixSlashes(path);
  448. pItem->m_curValue = path.c_str();
  449. m_Dirty = true;
  450. InvalidateList();
  451. }
  452. }
  453. cmSystemTools::ChangeDirectory(cwd.c_str());
  454. }
  455. void CPropertyList::OnLButtonUp(UINT nFlags, CPoint point)
  456. {
  457. if (m_bTracking)
  458. {
  459. //if columns were being resized then this indicates
  460. //that mouse is up so resizing is done. Need to redraw
  461. //columns to reflect their new widths.
  462. m_bTracking = FALSE;
  463. //if mouse was captured then release it
  464. if (GetCapture()==this)
  465. ::ReleaseCapture();
  466. ::ClipCursor(NULL);
  467. CClientDC dc(this);
  468. InvertLine(&dc,CPoint(point.x,m_nDivTop),CPoint(point.x,m_nDivBtm));
  469. //set the divider position to the new value
  470. m_nDivider = point.x;
  471. //redraw
  472. Invalidate();
  473. }
  474. else
  475. {
  476. BOOL loc;
  477. int i = ItemFromPoint(point,loc);
  478. m_curSel = i;
  479. CListBox::OnLButtonUp(nFlags, point);
  480. }
  481. }
  482. void CPropertyList::OnLButtonDown(UINT nFlags, CPoint point)
  483. {
  484. if ((point.x>=m_nDivider-5) && (point.x<=m_nDivider+5))
  485. {
  486. //if mouse clicked on divider line, then start resizing
  487. ::SetCursor(m_hCursorSize);
  488. CRect windowRect;
  489. GetWindowRect(windowRect);
  490. windowRect.left += 10; windowRect.right -= 10;
  491. //do not let mouse leave the list box boundary
  492. ::ClipCursor(windowRect);
  493. if (m_cmbBox)
  494. m_cmbBox.ShowWindow(SW_HIDE);
  495. if (m_editBox)
  496. m_editBox.ShowWindow(SW_HIDE);
  497. CRect clientRect;
  498. GetClientRect(clientRect);
  499. m_bTracking = TRUE;
  500. m_nDivTop = clientRect.top;
  501. m_nDivBtm = clientRect.bottom;
  502. m_nOldDivX = point.x;
  503. CClientDC dc(this);
  504. InvertLine(&dc,CPoint(m_nOldDivX,m_nDivTop),CPoint(m_nOldDivX,m_nDivBtm));
  505. //capture the mouse
  506. SetCapture();
  507. }
  508. else
  509. {
  510. m_bTracking = FALSE;
  511. CListBox::OnLButtonDown(nFlags, point);
  512. }
  513. }
  514. void CPropertyList::OnMouseMove(UINT nFlags, CPoint point)
  515. {
  516. if (m_bTracking)
  517. {
  518. //move divider line to the mouse pos. if columns are
  519. //currently being resized
  520. CClientDC dc(this);
  521. //remove old divider line
  522. InvertLine(&dc,CPoint(m_nOldDivX,m_nDivTop),CPoint(m_nOldDivX,m_nDivBtm));
  523. //draw new divider line
  524. InvertLine(&dc,CPoint(point.x,m_nDivTop),CPoint(point.x,m_nDivBtm));
  525. m_nOldDivX = point.x;
  526. }
  527. else if ((point.x >= m_nDivider-5) && (point.x <= m_nDivider+5))
  528. //set the cursor to a sizing cursor if the cursor is over the row divider
  529. ::SetCursor(m_hCursorSize);
  530. else
  531. {
  532. BOOL loc;
  533. int curSel = ItemFromPoint(point,loc);
  534. if(!loc && curSel < 65535)
  535. {
  536. CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(curSel);
  537. m_CMakeSetupDialog->SetDlgItemText(IDC_PROGRESS, pItem->m_HelpString);
  538. }
  539. CListBox::OnMouseMove(nFlags, point);
  540. }
  541. }
  542. void CPropertyList::InvertLine(CDC* pDC,CPoint ptFrom,CPoint ptTo)
  543. {
  544. int nOldMode = pDC->SetROP2(R2_NOT);
  545. pDC->MoveTo(ptFrom);
  546. pDC->LineTo(ptTo);
  547. pDC->SetROP2(nOldMode);
  548. }
  549. void CPropertyList::PreSubclassWindow()
  550. {
  551. m_bDivIsSet = FALSE;
  552. m_nDivider = 0;
  553. m_bTracking = FALSE;
  554. m_curSel = 1;
  555. m_hCursorSize = AfxGetApp()->LoadStandardCursor(IDC_SIZEWE);
  556. m_hCursorArrow = AfxGetApp()->LoadStandardCursor(IDC_ARROW);
  557. m_SSerif8Font.CreatePointFont(80,_T("MS Sans Serif"));
  558. }
  559. CPropertyItem* CPropertyList::GetItem(int index)
  560. {
  561. return (CPropertyItem*)GetItemDataPtr(index);
  562. }
  563. void CPropertyList::OnRButtonUp( UINT nFlags, CPoint point )
  564. {
  565. CMenu menu;
  566. CRect rect;
  567. this->GetWindowRect(&rect);
  568. BOOL loc;
  569. m_curSel = ItemFromPoint(point,loc);
  570. menu.CreatePopupMenu();
  571. menu.AppendMenu(MF_STRING | MF_ENABLED, 44, "Ignore Cache Entry");
  572. menu.AppendMenu(MF_STRING | MF_ENABLED, 42, "Delete Cache Entry");
  573. menu.AppendMenu(MF_STRING | MF_ENABLED, 43, "Help For Cache Entry");
  574. menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,
  575. rect.TopLeft().x + point.x,
  576. rect.TopLeft().y + point.y, this, NULL);
  577. }
  578. void CPropertyList::RemoveProperty(const char* name)
  579. {
  580. for(int i =0; i < this->GetCount(); ++i)
  581. {
  582. CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(i);
  583. if(pItem->m_propName == name)
  584. {
  585. m_PropertyItems.erase(pItem);
  586. delete pItem;
  587. this->DeleteString(i);
  588. return;
  589. }
  590. }
  591. }
  592. void CPropertyList::OnIgnore()
  593. {
  594. if(m_curSel == -1 || this->GetCount() <= 0)
  595. {
  596. return;
  597. }
  598. CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(m_curSel);
  599. pItem->m_curValue = "IGNORE";
  600. InvalidateList();
  601. }
  602. void CPropertyList::OnDelete()
  603. {
  604. if(m_curSel == -1 || this->GetCount() <= 0)
  605. {
  606. return;
  607. }
  608. CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(m_curSel);
  609. m_CMakeSetupDialog->GetCMakeInstance()->GetCacheManager()->RemoveCacheEntry(pItem->m_propName);
  610. m_PropertyItems.erase(pItem);
  611. delete pItem;
  612. this->DeleteString(m_curSel);
  613. this->HideControls();
  614. this->SetTopIndex(0);
  615. InvalidateList();
  616. }
  617. void CPropertyList::OnHelp()
  618. {
  619. if(m_curSel == -1 || this->GetCount() <= 0)
  620. {
  621. return;
  622. }
  623. CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(m_curSel);
  624. MessageBox(pItem->m_HelpString, pItem->m_propName, MB_OK|MB_ICONINFORMATION);
  625. }
  626. void CPropertyList::RemoveAll()
  627. {
  628. int c = this->GetCount();
  629. for(int i =0; i < c; ++i)
  630. {
  631. CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(0);
  632. this->DeleteString(0);
  633. }
  634. for(std::set<CPropertyItem*>::iterator ii = m_PropertyItems.begin();
  635. ii != m_PropertyItems.end(); ++ii)
  636. {
  637. delete *ii;
  638. }
  639. m_PropertyItems.clear();
  640. m_Dirty = false;
  641. this->HideControls();
  642. InvalidateList();
  643. }
  644. void CPropertyList::InvalidateList()
  645. {
  646. Invalidate();
  647. m_Dirty = true;
  648. }
  649. void CPropertyList::ShowAdvanced()
  650. {
  651. this->SetRedraw(FALSE);
  652. this->ResetContent();
  653. m_ShowAdvanced = true;
  654. std::map<std::string, CPropertyItem*> sortProps;
  655. for(std::set<CPropertyItem*>::iterator i = m_PropertyItems.begin();
  656. i != m_PropertyItems.end(); ++i)
  657. {
  658. sortProps[(const char*)(*i)->m_propName] = *i;
  659. }
  660. for(std::map<std::string, CPropertyItem*>::iterator i = sortProps.begin();
  661. i != sortProps.end(); ++i)
  662. {
  663. CPropertyItem* item = i->second;
  664. if(item->m_NewValue)
  665. {
  666. this->AddPropItem(item, 2);
  667. }
  668. }
  669. for(std::map<std::string, CPropertyItem*>::iterator i = sortProps.begin();
  670. i != sortProps.end(); ++i)
  671. {
  672. CPropertyItem* item = i->second;
  673. if(!item->m_NewValue)
  674. {
  675. this->AddPropItem(item, 2);
  676. }
  677. }
  678. this->SetRedraw(TRUE);
  679. this->InvalidateList();
  680. }
  681. void CPropertyList::HideAdvanced()
  682. {
  683. this->SetRedraw(FALSE);
  684. this->ResetContent();
  685. m_ShowAdvanced = false;
  686. std::map<std::string, CPropertyItem*> sortProps;
  687. for(std::set<CPropertyItem*>::iterator i = m_PropertyItems.begin();
  688. i != m_PropertyItems.end(); ++i)
  689. {
  690. sortProps[(const char*)(*i)->m_propName] = *i;
  691. }
  692. for(std::map<std::string, CPropertyItem*>::iterator i = sortProps.begin();
  693. i != sortProps.end(); ++i)
  694. {
  695. CPropertyItem* item = i->second;
  696. if(item->m_NewValue && !item->m_Advanced)
  697. {
  698. this->AddPropItem(item, 2);
  699. }
  700. }
  701. for(std::map<std::string, CPropertyItem*>::iterator i = sortProps.begin();
  702. i != sortProps.end(); ++i)
  703. {
  704. CPropertyItem* item = i->second;
  705. if(!item->m_Advanced && !item->m_NewValue)
  706. {
  707. this->AddPropItem(item, 2);
  708. }
  709. }
  710. this->SetRedraw(TRUE);
  711. this->InvalidateList();
  712. }