XTPReportRecordItem.cpp
上传用户:szled88
上传日期:2015-04-09
资源大小:43957k
文件大小:36k
源码类别:

对话框与窗口

开发平台:

Visual C++

  1. // XTPReportRecordItem.cpp : implementation of the CXTPReportRecordItem class.
  2. //
  3. // This file is a part of the XTREME REPORTCONTROL MFC class library.
  4. // (c)1998-2008 Codejock Software, All Rights Reserved.
  5. //
  6. // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE
  7. // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN
  8. // CONSENT OF CODEJOCK SOFTWARE.
  9. //
  10. // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED
  11. // IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO
  12. // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A
  13. // SINGLE COMPUTER.
  14. //
  15. // CONTACT INFORMATION:
  16. // support@codejock.com
  17. // http://www.codejock.com
  18. //
  19. /////////////////////////////////////////////////////////////////////////////
  20. #include "stdafx.h"
  21. #include "Common/XTPDrawHelpers.h"
  22. #include "Common/XTPMarkupRender.h"
  23. #include "XTPReportRow.h"
  24. #include "XTPReportRecords.h"
  25. #include "XTPReportColumns.h"
  26. #include "XTPReportColumn.h"
  27. #include "XTPReportControl.h"
  28. #include "XTPReportPaintManager.h"
  29. #include "XTPReportHyperlink.h"
  30. #include "XTPReportRecord.h"
  31. #include "XTPReportRecordItem.h"
  32. #include "XTPReportInplaceControls.h"
  33. #include "XTPReportRecordItemControls.h"
  34. #include "Common/XTPPropExchange.h"
  35. #ifdef _DEBUG
  36. #define new DEBUG_NEW
  37. #undef THIS_FILE
  38. static char THIS_FILE[] = __FILE__;
  39. #endif
  40. #ifndef IDC_HAND
  41. #define IDC_HAND MAKEINTRESOURCE(32649)
  42. #endif
  43. //////////////////////////////////////////////////////////////////////////
  44. // XTP_REPORTRECORDITEM_ARGS
  45. XTP_REPORTRECORDITEM_ARGS::XTP_REPORTRECORDITEM_ARGS()
  46. {
  47. pControl = NULL;
  48. pRow = NULL;
  49. pColumn = NULL;
  50. pItem = NULL;
  51. rcItem.SetRectEmpty();
  52. }
  53. XTP_REPORTRECORDITEM_ARGS::XTP_REPORTRECORDITEM_ARGS(CXTPReportControl* pControl, CXTPReportRow* pRow, CXTPReportColumn* pColumn)
  54. {
  55. ASSERT(pControl && pRow && pColumn);
  56. this->pControl = pControl;
  57. this->pRow = pRow;
  58. this->pColumn = pColumn;
  59. this->pItem = pRow->GetRecord()->GetItem(pColumn);
  60. this->rcItem = pRow->GetItemRect(pItem);
  61. }
  62. XTP_REPORTRECORDITEM_ARGS::~XTP_REPORTRECORDITEM_ARGS()
  63. {
  64. }
  65. void XTP_REPORTRECORDITEM_ARGS::AddRef()
  66. {
  67. CMDTARGET_ADDREF(pRow);
  68. CMDTARGET_ADDREF(pColumn);
  69. CMDTARGET_ADDREF(pItem);
  70. }
  71. void XTP_REPORTRECORDITEM_ARGS::Release()
  72. {
  73. if (pRow)
  74. pRow->InternalRelease();
  75. if (pColumn)
  76. pColumn->InternalRelease();
  77. if (pItem)
  78. pItem->InternalRelease();
  79. }
  80. const XTP_REPORTRECORDITEM_ARGS& XTP_REPORTRECORDITEM_ARGS::operator=(const XTP_REPORTRECORDITEM_ARGS& src)
  81. {
  82. pControl = src.pControl;
  83. pRow     = src.pRow;
  84. pColumn  = src.pColumn;
  85. pItem    = src.pItem;
  86. rcItem   = src.rcItem;
  87. return *this;
  88. }
  89. CXTPReportInplaceButtons::CXTPReportInplaceButtons()
  90. {
  91. }
  92. //////////////////////////////////////////////////////////////////////////
  93. // CXTPReportRecordItemConstraint
  94. CXTPReportRecordItemConstraint::CXTPReportRecordItemConstraint()
  95. {
  96. m_dwData = 0;
  97. m_nIndex = 0;
  98. }
  99. int CXTPReportRecordItemConstraint::GetIndex() const
  100. {
  101. return m_nIndex;
  102. }
  103. //////////////////////////////////////////////////////////////////////////
  104. // CXTPReportRecordItemConstraints
  105. CXTPReportRecordItemConstraints::CXTPReportRecordItemConstraints()
  106. {
  107. }
  108. CXTPReportRecordItemConstraints::~CXTPReportRecordItemConstraints()
  109. {
  110. RemoveAll();
  111. }
  112. int CXTPReportRecordItemConstraints::GetCount() const
  113. {
  114. return (int)m_arrConstraints.GetSize();
  115. }
  116. CXTPReportRecordItemConstraint* CXTPReportRecordItemConstraints::GetAt(int nIndex) const
  117. {
  118. return m_arrConstraints.GetAt(nIndex);
  119. }
  120. void CXTPReportRecordItemConstraints::RemoveAll()
  121. {
  122. for (int i = 0; i < GetCount(); i++)
  123. m_arrConstraints[i]->InternalRelease();
  124. m_arrConstraints.RemoveAll();
  125. }
  126. //////////////////////////////////////////////////////////////////////////
  127. // CXTPReportRecordItemEditOptions
  128. CXTPReportRecordItemEditOptions::CXTPReportRecordItemEditOptions()
  129. {
  130. m_bAllowEdit = TRUE;
  131. m_bConstraintEdit = FALSE;
  132. m_pConstraints = new CXTPReportRecordItemConstraints();
  133. m_bSelectTextOnEdit = FALSE;
  134. m_dwEditStyle = ES_AUTOHSCROLL;
  135. m_nMaxLength = 0;
  136. }
  137. CXTPReportRecordItemEditOptions::~CXTPReportRecordItemEditOptions()
  138. {
  139. RemoveButtons();
  140. CMDTARGET_RELEASE(m_pConstraints);
  141. }
  142. void CXTPReportRecordItemEditOptions::RemoveButtons()
  143. {
  144. for (int j = 0; j < arrInplaceButtons.GetSize(); j++)
  145. arrInplaceButtons[j]->InternalRelease();
  146. arrInplaceButtons.RemoveAll();
  147. }
  148. void CXTPReportRecordItemEditOptions::AddComboButton()
  149. {
  150. arrInplaceButtons.Add(new CXTPReportInplaceButton(XTP_ID_REPORT_COMBOBUTTON));
  151. }
  152. void CXTPReportRecordItemEditOptions::AddExpandButton()
  153. {
  154. arrInplaceButtons.Add(new CXTPReportInplaceButton(XTP_ID_REPORT_EXPANDBUTTON));
  155. }
  156. void CXTPReportRecordItemEditOptions::AddSpinButton()
  157. {
  158. arrInplaceButtons.Add(new CXTPReportInplaceButton(XTP_ID_REPORT_SPINBUTTON));
  159. }
  160. CXTPReportInplaceButton* CXTPReportRecordItemEditOptions::GetButton(int nIndex)
  161. {
  162. if(nIndex >= arrInplaceButtons.GetSize())
  163. return NULL;
  164. return arrInplaceButtons.GetAt(nIndex);
  165. }
  166. CXTPReportRecordItemConstraint* CXTPReportRecordItemEditOptions::FindConstraint(DWORD_PTR dwData)
  167. {
  168. for (int i = 0; i < m_pConstraints->GetCount(); i++)
  169. {
  170. CXTPReportRecordItemConstraint* pConstaint = m_pConstraints->GetAt(i);
  171. if (pConstaint->m_dwData == dwData)
  172. return pConstaint;
  173. }
  174. return NULL;
  175. }
  176. CXTPReportRecordItemConstraint* CXTPReportRecordItemEditOptions::FindConstraint(LPCTSTR lpszConstraint)
  177. {
  178. for (int i = 0; i < m_pConstraints->GetCount(); i++)
  179. {
  180. CXTPReportRecordItemConstraint* pConstaint = m_pConstraints->GetAt(i);
  181. if (pConstaint->m_strConstraint == lpszConstraint)
  182. return pConstaint;
  183. }
  184. return NULL;
  185. }
  186. CXTPReportRecordItemConstraint* CXTPReportRecordItemEditOptions::AddConstraint(LPCTSTR lpszConstraint, DWORD_PTR dwData /*= 0*/)
  187. {
  188. CXTPReportRecordItemConstraint* pConstaint = new CXTPReportRecordItemConstraint();
  189. pConstaint->m_strConstraint = lpszConstraint;
  190. pConstaint->m_dwData = dwData;
  191. pConstaint->m_nIndex = (int)m_pConstraints->m_arrConstraints.Add(pConstaint);
  192. return pConstaint;
  193. }
  194. //////////////////////////////////////////////////////////////////////////
  195. // CXTPReportRecordItem
  196. IMPLEMENT_SERIAL(CXTPReportRecordItem, CCmdTarget, VERSIONABLE_SCHEMA | _XTP_SCHEMA_CURRENT)
  197. CXTPReportRecordItem::CXTPReportRecordItem()
  198. {
  199. static const CString g_strFormatStringDef = _T("%s");
  200. m_strFormatString = g_strFormatStringDef;
  201. m_bEditable = TRUE;
  202. m_pFontCaption = NULL;
  203. m_bBoldText = FALSE;
  204. m_clrText = XTP_REPORT_COLOR_DEFAULT;
  205. m_clrBackground = XTP_REPORT_COLOR_DEFAULT;
  206. m_nIconIndex = XTP_REPORT_NOICON;
  207. m_pRecord = 0;
  208. m_dwData = 0;
  209. m_nSortPriority = -1;
  210. m_nGroupPriority = -1;
  211. m_Alignment = (XTPReportColumnIconAlignment)(-1);
  212. m_bChecked = FALSE;
  213. m_bHasCheckbox = FALSE;
  214. m_pEditOptions = NULL;
  215. m_pItemControls = NULL;
  216. m_pFocusedItemControl = NULL;
  217. m_bItemControlUnderMouse = FALSE;
  218. m_pItemControlHookWnd = NULL;
  219. m_bFocusable = TRUE;
  220. m_pHyperlinks = NULL;
  221. m_pMarkupUIElement = NULL;
  222. m_pControl = NULL;
  223. }
  224. CXTPReportRecordItem::~CXTPReportRecordItem()
  225. {
  226. CMDTARGET_RELEASE(m_pEditOptions);
  227. CMDTARGET_RELEASE(m_pItemControls);
  228. CMDTARGET_RELEASE(m_pHyperlinks);
  229. XTPMarkupReleaseElement(m_pMarkupUIElement);
  230. }
  231. void CXTPReportRecordItem::SetCaption(LPCTSTR strCaption)
  232. {
  233. m_strCaption = strCaption;
  234. XTPMarkupReleaseElement(m_pMarkupUIElement);
  235. if (m_pRecord && m_pRecord->m_pRecords && m_pRecord->m_pRecords->GetMarkupContext())
  236. {
  237. m_pMarkupUIElement = XTPMarkupParseText(m_pRecord->m_pRecords->GetMarkupContext(), strCaption);
  238. }
  239. }
  240. void CXTPReportRecordItem::DoMouseButtonClick()
  241. {
  242. mouse_event(GetSystemMetrics(SM_SWAPBUTTON) ? MOUSEEVENTF_RIGHTDOWN : MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
  243. mouse_event(GetSystemMetrics(SM_SWAPBUTTON) ? MOUSEEVENTF_RIGHTUP : MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
  244. }
  245. void CXTPReportRecordItem::GetCaptionRect(XTP_REPORTRECORDITEM_ARGS* pDrawArgs, CRect& rcItem)
  246. {
  247. ASSERT(pDrawArgs->pControl);
  248. if (!pDrawArgs->pControl)
  249. return;
  250. else
  251. m_pControl = pDrawArgs->pControl;
  252. if (GetIconIndex() != XTP_REPORT_NOICON)
  253. rcItem.left += pDrawArgs->pControl->GetPaintManager()->DrawBitmap(NULL, pDrawArgs->pControl, rcItem, GetIconIndex());
  254. if (m_bHasCheckbox)
  255. rcItem.left += 15;
  256. if(m_pItemControls && m_pItemControls->GetSize())
  257. {
  258. for(int i = 0; i < m_pItemControls->GetSize() && rcItem.Width() > 0; i++)
  259. {
  260. int nWidth = m_pItemControls->GetAt(i)->GetSize().cx;
  261. nWidth = nWidth < 0 ? rcItem.Width() : nWidth;
  262. if(m_pItemControls->GetAt(i)->GetAlignment() == xtpItemControlRight)
  263. rcItem.right -= nWidth;
  264. else
  265. rcItem.left += nWidth;
  266. }
  267. }
  268. }
  269. void CXTPReportRecordItem::DrawCheckBox(XTP_REPORTRECORDITEM_DRAWARGS* pDrawArgs, CRect& rcItem)
  270. {
  271. BOOL bEditable = IsEditable() && (pDrawArgs->pColumn == NULL || pDrawArgs->pColumn->IsEditable());
  272. CDC* pDC = pDrawArgs->pDC;
  273. int eState = (bEditable ? 0: 2) + (IsChecked() ? 1 : 0);
  274. CXTPReportPaintManager* pPaintManager = pDrawArgs->pControl->GetPaintManager();
  275. int nIconAlign = pDrawArgs->nTextAlign & xtpColumnIconMask;
  276. m_rcGlyph = rcItem;
  277. CSize sizeGlyph = pPaintManager->DrawGlyph(NULL, m_rcGlyph, eState + 2);
  278. CRect rcGlyph(m_rcGlyph);
  279. // horizontal alignment
  280. switch(nIconAlign)
  281. {
  282. case xtpColumnIconRight:
  283. rcGlyph.left = rcItem.right - sizeGlyph.cx - 2;
  284. // shift text box to the left
  285. rcItem.right -= (2 + sizeGlyph.cx);
  286. break;
  287. case xtpColumnIconCenter:
  288. rcGlyph.left = rcItem.CenterPoint().x - sizeGlyph.cx / 2 - 1;
  289. rcGlyph.right = rcGlyph.left + sizeGlyph.cx;
  290. break; // left text box as is - draw on image...
  291. case xtpColumnIconLeft:
  292. default:
  293. rcGlyph.left += 2;
  294. // shift text box to the right
  295. rcItem.left += 2 + sizeGlyph.cx;
  296. rcGlyph.right = rcItem.left - 1;
  297. break;
  298. }
  299. // vertical alignment
  300. switch(nIconAlign)
  301. {
  302. case xtpColumnIconTop:
  303. rcGlyph.bottom = rcItem.top + sizeGlyph.cy + 2;
  304. break;
  305. case xtpColumnIconBottom:
  306. rcGlyph.top = rcItem.bottom - sizeGlyph.cy - 2;
  307. break;
  308. }
  309. // draw the glyph
  310. pPaintManager->DrawGlyph(pDC, rcGlyph, eState + 2);
  311. }
  312. void CXTPReportRecordItem::OnDrawCaption(XTP_REPORTRECORDITEM_DRAWARGS* pDrawArgs, XTP_REPORTRECORDITEM_METRICS* pMetrics)
  313. {
  314. ASSERT(pDrawArgs->pItem == this);
  315. if (m_pMarkupUIElement)
  316. {
  317. CRect rcItem = pDrawArgs->rcItem;
  318. rcItem.DeflateRect(2, 1, 2, 0);
  319. XTPMarkupMeasureElement(m_pMarkupUIElement, rcItem.Width(), INT_MAX);
  320. XTPMarkupSetDefaultFont(m_pRecord->GetRecords()->GetMarkupContext(), (HFONT)pMetrics->pFont->GetSafeHandle(), pMetrics->clrForeground);
  321. XTPMarkupRenderElement(m_pMarkupUIElement, pDrawArgs->pDC->GetSafeHdc(), &rcItem);
  322. }
  323. else
  324. {
  325. pDrawArgs->pControl->GetPaintManager()->DrawItemCaption(pDrawArgs, pMetrics);
  326. }
  327. }
  328. void CXTPReportRecordItem::OnDrawControls(XTP_REPORTRECORDITEM_DRAWARGS* pDrawArgs, CRect& rcItem)
  329. {
  330. ASSERT(pDrawArgs->pItem == this);
  331. if(!m_pItemControls)
  332. return;
  333. for (int i = 0; i < m_pItemControls->GetSize() && rcItem.Width(); i++)
  334. {
  335. pDrawArgs->pControl->GetPaintManager()->DrawItemControl(pDrawArgs, m_pItemControls->GetAt(i), rcItem);
  336. }
  337. }
  338. int CXTPReportRecordItem::Draw(XTP_REPORTRECORDITEM_DRAWARGS* pDrawArgs)
  339. {
  340. ASSERT(pDrawArgs->pControl);
  341. if (!pDrawArgs->pControl)
  342. return 0;
  343. else
  344. m_pControl = pDrawArgs->pControl;
  345. CDC* pDC = pDrawArgs->pDC;
  346. CRect& rcItem = pDrawArgs->rcItem;
  347. CXTPReportPaintManager* pPaintManager = pDrawArgs->pControl->GetPaintManager();
  348. CRgn rgn;
  349. rgn.CreateRectRgn(rcItem.left, rcItem.top - 1, rcItem.right, rcItem.bottom);
  350. if (!pDC->IsPrinting())
  351. pDC->SelectClipRgn(&rgn);
  352. XTP_REPORTRECORDITEM_METRICS* pMetrics = new XTP_REPORTRECORDITEM_METRICS();
  353. pMetrics->strText = GetCaption(pDrawArgs->pColumn);
  354. pDrawArgs->pRow->GetItemMetrics(pDrawArgs, pMetrics);
  355. ASSERT(pMetrics->pFont);
  356. ASSERT(pMetrics->clrForeground != XTP_REPORT_COLOR_DEFAULT);
  357. if (pMetrics->clrBackground != XTP_REPORT_COLOR_DEFAULT)
  358. pDC->FillSolidRect(rcItem, pMetrics->clrBackground);
  359. int nItemGlyphs = rcItem.left;
  360. // draw tree inside item rect (see also HitTest function)
  361. if (pDrawArgs->pColumn && pDrawArgs->pColumn->IsTreeColumn())
  362. {
  363. if(pDrawArgs->pControl->IsVirtualMode())
  364. {
  365. pDrawArgs->pRow->m_nRowLevel = pMetrics->nVirtRowLevel ? 1 : 0; // only 1 level of children is supported at the moment
  366. if(pDrawArgs->pRow->m_nRowLevel)
  367. pDrawArgs->pRow->m_rcCollapse = CRect(0);
  368. }
  369. int nTreeDepth = pDrawArgs->pRow->GetTreeDepth() - pDrawArgs->pRow->GetGroupLevel();
  370. if (nTreeDepth > 0)
  371. nTreeDepth++;
  372. rcItem.left += pDrawArgs->pControl->GetIndent(nTreeDepth);
  373. BOOL bHasChildren = pDrawArgs->pControl->IsVirtualMode() ?
  374. pDrawArgs->pRow->m_nRowLevel == 0 && (pMetrics->nVirtRowFlags & xtpVirtRowHasChildren) :
  375. pDrawArgs->pRow->HasChildren();
  376. CRect rcBitmap(rcItem);
  377. CSize sizeBitmap = pPaintManager->DrawCollapsedBitmap(NULL, pDrawArgs->pRow, rcBitmap);
  378. pPaintManager->DrawTreeStructure(pDrawArgs, pMetrics, rcItem, sizeBitmap);
  379. int nIconAlign = pDrawArgs->nTextAlign & xtpColumnIconMask;
  380. // horizontal alignment
  381. switch(nIconAlign)
  382. {
  383. case xtpColumnIconRight:
  384. rcBitmap.left = rcBitmap.right - sizeBitmap.cx - 2;
  385. break;
  386. case xtpColumnIconLeft:
  387. rcBitmap.right = rcBitmap.left + sizeBitmap.cx + 2;
  388. break;
  389. }
  390. // vertical alignment
  391. switch(nIconAlign)
  392. {
  393. case xtpColumnIconTop:
  394. rcBitmap.bottom = rcBitmap.top + sizeBitmap.cy + 2;
  395. break;
  396. case xtpColumnIconBottom:
  397. rcBitmap.top = rcBitmap.bottom - sizeBitmap.cy - 2;
  398. break;
  399. }
  400. sizeBitmap = pPaintManager->DrawCollapsedBitmap(bHasChildren ? pDC : NULL, pDrawArgs->pRow, rcBitmap);
  401. if (!pDC->IsPrinting() && bHasChildren)
  402. pDrawArgs->pRow->SetCollapseRect(rcBitmap);
  403. rcItem.left += sizeBitmap.cx + 2;
  404. }
  405. pDC->SetTextColor(pMetrics->clrForeground);
  406. CFont* pOldFont = (CFont*)pDC->SelectObject(pMetrics->pFont);
  407. if (pMetrics->clrBackground != XTP_REPORT_COLOR_DEFAULT)
  408. pDC->SetBkColor(pMetrics->clrBackground);
  409. else
  410. pDC->SetBkColor(pPaintManager->m_clrControlBack);
  411. if (m_bHasCheckbox)
  412. DrawCheckBox(pDrawArgs, rcItem);
  413. // Do the draw bitmap pDC, rcItem, GetIconIndex()
  414. if (pMetrics->nItemIcon != XTP_REPORT_NOICON || GetIconIndex() != XTP_REPORT_NOICON)
  415. {
  416. pPaintManager->DrawItemBitmap(pDrawArgs, rcItem, pMetrics->nItemIcon != XTP_REPORT_NOICON ? pMetrics->nItemIcon : GetIconIndex());
  417. }
  418. nItemGlyphs = (rcItem.left - nItemGlyphs);
  419. OnDrawControls(pDrawArgs, rcItem);
  420. if(rcItem.Width())
  421. OnDrawCaption(pDrawArgs, pMetrics);
  422. int nItemTextWidth = nItemGlyphs + pDC->GetTextExtent(pMetrics->strText).cx + 4;
  423. pDC->SelectObject(pOldFont);
  424. pMetrics->InternalRelease();
  425. if (!pDC->IsPrinting())
  426. pDC->SelectClipRgn(NULL);
  427. return nItemTextWidth;
  428. }
  429. CXTPReportRecordItemControl* CXTPReportRecordItem::HitTest(CPoint ptPoint)
  430. {
  431. if(!(m_pItemControls && m_pItemControls->GetSize()))
  432. return NULL;
  433. for(int i = 0; i < m_pItemControls->GetSize(); i++)
  434. {
  435. CRect rcControl = m_pItemControls->GetAt(i)->GetRect();
  436. if(rcControl.PtInRect(ptPoint))
  437. return m_pItemControls->GetAt(i);
  438. }
  439. return NULL;
  440. }
  441. BOOL CXTPReportRecordItem::OnLButtonDown(XTP_REPORTRECORDITEM_CLICKARGS* pClickArgs)
  442. {
  443. CXTPReportRecordItemControl* pItemControl = HitTest(pClickArgs->ptClient);
  444. if(!pItemControl)
  445. return FALSE;
  446. pItemControl->OnLButtonDown(pClickArgs);
  447. // create item control window
  448. m_pItemControlHookWnd = new CXTPReportRecordItemControlHookWnd(pClickArgs);
  449. m_pItemControlHookWnd->Create(AfxRegisterWndClass(0), _T(""), WS_CHILD, pItemControl->GetRect(), pClickArgs->pControl, 0);
  450. m_pItemControlHookWnd->SetCapture();
  451. // redraw control
  452. pClickArgs->pControl->RedrawControl();
  453. return TRUE;
  454. }
  455. BOOL CXTPReportRecordItem::OnLButtonUp(XTP_REPORTRECORDITEM_CLICKARGS* pClickArgs)
  456. {
  457. if(m_pItemControlHookWnd && m_pFocusedItemControl)
  458. {
  459. pClickArgs->pControl->ScreenToClient(&pClickArgs->ptClient);
  460. m_pFocusedItemControl->OnLButtonUp(pClickArgs);
  461. pClickArgs->pControl->RedrawControl();
  462. // destroy item control window
  463. ReleaseCapture();
  464. m_pItemControlHookWnd->DestroyWindow();
  465. delete m_pItemControlHookWnd;
  466. m_pItemControlHookWnd = NULL;
  467. return TRUE;
  468. }
  469. CXTPReportRecordItemControl* pItemControl = HitTest(pClickArgs->ptClient);
  470. if(!pItemControl)
  471. return FALSE;
  472. pItemControl->OnLButtonUp(pClickArgs);
  473. pClickArgs->pControl->RedrawControl();
  474. return TRUE;
  475. }
  476. void CXTPReportRecordItem::OnClick(XTP_REPORTRECORDITEM_CLICKARGS* pClickArgs)
  477. {
  478. if (!pClickArgs || !pClickArgs->pControl)
  479. return;
  480. if(OnLButtonUp(pClickArgs))
  481. return;
  482. InternalAddRef();
  483. CMDTARGET_ADDREF(pClickArgs->pColumn);
  484. CMDTARGET_ADDREF(pClickArgs->pControl);
  485. CXTPReportRow* pRow = pClickArgs->pRow;
  486. CMDTARGET_ADDREF(pRow);
  487. BOOL bCheckBoxClicked = FALSE;
  488. CXTPReportControl* pControl = pClickArgs->pControl;
  489. if (IsEditable() && m_bHasCheckbox && (pClickArgs->pColumn == NULL || pClickArgs->pColumn->IsEditable())
  490. && OnRequestEdit(pClickArgs))
  491. {
  492. // adjust vertical coordinates if virtual mode
  493. if (pControl->IsVirtualMode())
  494. {
  495. m_rcGlyph.top = pClickArgs->rcItem.top;
  496. m_rcGlyph.bottom = pClickArgs->rcItem.bottom;
  497. }
  498. // check whether we're clicking glyph area
  499. if (m_rcGlyph.PtInRect(pClickArgs->ptClient))
  500. {
  501. if (pControl->IsAutoCheckItems()) SetChecked(!IsChecked());
  502. pControl->RedrawControl();
  503. pControl->SendMessageToParent(pClickArgs->pRow, this, pClickArgs->pColumn, XTP_NM_REPORT_CHECKED, &pClickArgs->ptClient);
  504. bCheckBoxClicked = TRUE;
  505. }
  506. }
  507. if (!bCheckBoxClicked && IsAllowEdit(pClickArgs) && pControl->IsEditOnClick())
  508. {
  509. pControl->EditItem(pClickArgs);
  510. CPoint pt(pClickArgs->ptClient);
  511. pControl->ClientToScreen(&pt);
  512. CXTPReportInplaceEdit* pEdit = DYNAMIC_DOWNCAST(CXTPReportInplaceEdit, CWnd::FromHandle(WindowFromPoint(pt)));
  513. if (pEdit && pEdit->GetItem() == this)
  514. {
  515. CXTPReportRecordItemEditOptions* pEditOptions = GetEditOptions(pClickArgs->pColumn);
  516. if (pEditOptions->m_bSelectTextOnEdit)
  517. {
  518. pEdit->SetSel(0, -1);
  519. }
  520. else
  521. {
  522. DoMouseButtonClick();
  523. }
  524. }
  525. }
  526. pClickArgs->pControl->SendMessageToParent(pClickArgs->pRow, this, pClickArgs->pColumn, NM_CLICK, &pClickArgs->ptClient);
  527. // Determine Hyperlink Click
  528. int nHyperlink = HitTestHyperlink(pClickArgs->ptClient);
  529. if (nHyperlink >= 0)
  530. {
  531. pClickArgs->pControl->SendMessageToParent(pClickArgs->pRow, this, pClickArgs->pColumn, XTP_NM_REPORT_HYPERLINK, &pClickArgs->ptClient, nHyperlink);
  532. }
  533. CMDTARGET_RELEASE(pRow);
  534. CMDTARGET_RELEASE(pClickArgs->pColumn);
  535. CMDTARGET_RELEASE(pClickArgs->pControl);
  536. InternalRelease();
  537. }
  538. int CXTPReportRecordItem::HitTestHyperlink(CPoint ptClick)
  539. {
  540. int nHyperlinks = GetHyperlinksCount();
  541. CXTPReportHyperlink* pHyperlink;
  542. for (int nHyperlink = 0; nHyperlink < nHyperlinks; nHyperlink++)
  543. {
  544. pHyperlink = GetHyperlinkAt(nHyperlink);
  545. ASSERT(pHyperlink);
  546. if (pHyperlink && pHyperlink->m_rcHyperSpot.PtInRect(ptClick))
  547. return nHyperlink;
  548. }
  549. return -1;
  550. }
  551. void CXTPReportRecordItem::OnDblClick(XTP_REPORTRECORDITEM_CLICKARGS* pClickArgs)
  552. {
  553. if(OnLButtonDown(pClickArgs))
  554. return;
  555. CXTPReportControl* pControl = pClickArgs->pControl;
  556. if (IsAllowEdit(pClickArgs) && !pControl->IsEditOnClick() && pControl->GetInplaceEdit()->GetItem() != this)
  557. {
  558. pControl->EditItem(pClickArgs);
  559. CPoint pt(pClickArgs->ptClient);
  560. pControl->ClientToScreen(&pt);
  561. CXTPReportInplaceEdit* pEdit = DYNAMIC_DOWNCAST(CXTPReportInplaceEdit, CWnd::FromHandle(WindowFromPoint(pt)));
  562. if (pEdit && pEdit->GetItem() == this)
  563. {
  564. CXTPReportRecordItemEditOptions* pEditOptions = GetEditOptions(pClickArgs->pColumn);
  565. if (pEditOptions->m_bSelectTextOnEdit)
  566. {
  567. pEdit->SetSel(0, -1);
  568. }
  569. else
  570. {
  571. DoMouseButtonClick();
  572. }
  573. }
  574. }
  575. pControl->SendMessageToParent(pClickArgs->pRow, this, pClickArgs->pColumn, NM_DBLCLK, &pClickArgs->ptClient, -1);
  576. }
  577. void CXTPReportRecordItem::OnMouseMove(UINT nFlags, CPoint point, CXTPReportControl* pControl)
  578. {
  579. int nHyperlink = HitTestHyperlink(point);
  580. if (nHyperlink >= 0)
  581. {
  582. SetCursor(AfxGetApp()->LoadStandardCursor(IDC_HAND));
  583. return;
  584. }
  585. CXTPReportRecordItemControl* pItemControl = HitTest(point);
  586. if(m_pItemControlHookWnd && m_pFocusedItemControl && (nFlags & MK_LBUTTON))
  587. {
  588. pControl->ScreenToClient(&point);
  589. if(m_bItemControlUnderMouse && !m_pFocusedItemControl->GetRect().PtInRect(point))
  590. {
  591. m_pFocusedItemControl->OnMouseLeave(nFlags, point);
  592. m_bItemControlUnderMouse = FALSE;
  593. }
  594. else if(!m_bItemControlUnderMouse && m_pFocusedItemControl->GetRect().PtInRect(point))
  595. {
  596. m_pFocusedItemControl->OnMouseEnter(nFlags, point);
  597. m_bItemControlUnderMouse = TRUE;
  598. }
  599. else
  600. m_pFocusedItemControl->OnMouseMove(nFlags, point);
  601. pControl->RedrawControl();
  602. return;
  603. }
  604. if(pItemControl)
  605. {
  606. if(pItemControl != m_pFocusedItemControl)
  607. {
  608. if(m_pFocusedItemControl)
  609. {
  610. m_pFocusedItemControl->OnMouseLeave(nFlags, point);
  611. m_bItemControlUnderMouse = FALSE;
  612. }
  613. pItemControl->OnMouseEnter(nFlags, point);
  614. m_bItemControlUnderMouse = TRUE;
  615. }
  616. pItemControl->OnMouseMove(nFlags, point);
  617. if(pControl)
  618. pControl->RedrawControl();
  619. }
  620. else
  621. {
  622. if(m_pFocusedItemControl)
  623. {
  624. m_pFocusedItemControl->OnMouseLeave(nFlags, point);
  625. m_bItemControlUnderMouse = FALSE;
  626. if(pControl)
  627. pControl->RedrawControl();
  628. }
  629. }
  630. m_pFocusedItemControl = pItemControl;
  631. }
  632. void CXTPReportRecordItem::SetFont(CFont* pFont)
  633. {
  634. m_pFontCaption = pFont;
  635. }
  636. void CXTPReportRecordItem::SetBold(BOOL bBold)
  637. {
  638. m_bBoldText = bBold;
  639. }
  640. void CXTPReportRecordItem::SetTextColor(COLORREF clrText)
  641. {
  642. m_clrText = clrText;
  643. }
  644. void CXTPReportRecordItem::SetBackgroundColor(COLORREF clrBackground)
  645. {
  646. m_clrBackground = clrBackground;
  647. }
  648. int CXTPReportRecordItem::Compare(CXTPReportColumn* pColumn, CXTPReportRecordItem* pItem)
  649. {
  650. if (!pItem)
  651. return 0;
  652. if (m_nSortPriority != -1 || pItem->m_nSortPriority != -1)
  653. return m_nSortPriority - pItem->m_nSortPriority;
  654. return m_pRecord->GetRecords()->Compare(GetCaption(pColumn), pItem->GetCaption(pColumn));
  655. }
  656. CFont* CXTPReportRecordItem::GetFont()
  657. {
  658. return m_pFontCaption;
  659. }
  660. CString CXTPReportRecordItem::GetGroupCaption(CXTPReportColumn* pColumn)
  661. {
  662. if (!m_strGroupCaption.IsEmpty())
  663. return m_strGroupCaption;
  664. int nID = GetGroupCaptionID(pColumn);
  665. if (nID > 0)
  666. {
  667. CString str;
  668. if (str.LoadString(nID))
  669. {
  670. return str;
  671. }
  672. }
  673. return pColumn->GetCaption() + _T(": ") + GetCaption(pColumn);
  674. }
  675. int CXTPReportRecordItem::CompareGroupCaption(CXTPReportColumn* pColumn, CXTPReportRecordItem* pItem)
  676. {
  677. if (m_nGroupPriority != -1)
  678. return m_nGroupPriority - pItem->m_nGroupPriority;
  679. if (!m_strGroupCaption.IsEmpty())
  680. return m_pRecord->GetRecords()->Compare(m_strGroupCaption, pItem->m_strGroupCaption);
  681. int nID = GetGroupCaptionID(pColumn);
  682. if (nID > 0)
  683. return nID - pItem->GetGroupCaptionID(pColumn);
  684. return Compare(pColumn, pItem);
  685. }
  686. int CXTPReportRecordItem::GetGroupCaptionID(CXTPReportColumn* /*pColumn*/)
  687. {
  688. return m_nGroupPriority;
  689. }
  690. void CXTPReportRecordItem::GetItemMetrics(XTP_REPORTRECORDITEM_DRAWARGS* pDrawArgs, XTP_REPORTRECORDITEM_METRICS* pItemMetrics)
  691. {
  692. if (m_clrBackground != XTP_REPORT_COLOR_DEFAULT)
  693. pItemMetrics->clrBackground = m_clrBackground;
  694. if (m_clrText != XTP_REPORT_COLOR_DEFAULT)
  695. pItemMetrics->clrForeground = m_clrText;
  696. if (m_pFontCaption != NULL)
  697. pItemMetrics->pFont = m_pFontCaption;
  698. else if (m_bBoldText)
  699. pItemMetrics->pFont = &pDrawArgs->pControl->GetPaintManager()->m_fontBoldText;
  700. if(m_Alignment != (XTPReportColumnIconAlignment)(-1))
  701. pItemMetrics->nColumnAlignment = m_Alignment;
  702. }
  703. int CXTPReportRecordItem::GetIndex() const
  704. {
  705. return m_pRecord ? m_pRecord->IndexOf(this) : -1;
  706. }
  707. CXTPReportColumn* CXTPReportRecordItem::GetColumn()
  708. {
  709. if (m_pControl)
  710. {
  711. int nItemIndex = GetIndex();
  712. CXTPReportColumns* pCols = m_pControl->GetColumns();
  713. if (pCols)
  714. {
  715. return pCols->GetAt(nItemIndex);
  716. }
  717. }
  718. return NULL;
  719. }
  720. BOOL CXTPReportRecordItem::IsEditable() const
  721. {
  722. if (this == NULL)
  723. return FALSE;
  724. ASSERT(m_pRecord);
  725. return m_pRecord ? m_pRecord->m_bEditable && m_bEditable && IsFocusable() : FALSE;
  726. }
  727. BOOL CXTPReportRecordItem::IsFocusable() const
  728. {
  729. if (this == NULL)
  730. return FALSE;
  731. return m_bFocusable;
  732. }
  733. void CXTPReportRecordItem::OnBeginEdit(XTP_REPORTRECORDITEM_ARGS* pItemArgs)
  734. {
  735. ASSERT(pItemArgs);
  736. if (!pItemArgs)
  737. return;
  738. CXTPReportControl* pControl = pItemArgs->pControl;
  739. CXTPReportInplaceEdit* pEdit = pControl->GetInplaceEdit();
  740. CRect rcCaption(pItemArgs->rcItem);
  741. GetCaptionRect(pItemArgs, rcCaption);
  742. if (IsEditable() && OnRequestEdit(pItemArgs))
  743. {
  744. CXTPReportRecordItemEditOptions* pEditOptions = GetEditOptions(pItemArgs->pColumn);
  745. ASSERT(pEditOptions);
  746. CXTPReportInplaceButtons* pInpaceButtons = &pEditOptions->arrInplaceButtons;
  747. CRect rcButtons(pItemArgs->rcItem);
  748. CXTPClientRect rcControl(pItemArgs->pControl);
  749. int i;
  750. // calculate right-aligned item controls width
  751. int nControlsWidthRight = 0;
  752. for(i = 0; m_pItemControls && i < m_pItemControls->GetSize(); i++)
  753. {
  754. if(m_pItemControls->GetAt(i)->GetAlignment() == xtpItemControlRight)
  755. nControlsWidthRight += m_pItemControls->GetAt(i)->GetRect().Width();
  756. }
  757. // calculate inplace buttons widths
  758. int nButtonsWidthIn = 0, nButtonsWidthOut = 0;
  759. for (i = 0; i < pInpaceButtons->GetSize(); i++)
  760. {
  761. CXTPReportInplaceButton* pButton = pInpaceButtons->GetAt(i);
  762. if (pButton->IsInsideCellButton())
  763. nButtonsWidthIn += pButton->GetWidth();
  764. else
  765. nButtonsWidthOut += pButton->GetWidth();
  766. }
  767. // adjust buttons rect
  768. if (rcButtons.right + nButtonsWidthOut > rcControl.right)
  769. rcButtons.right = rcControl.right - nButtonsWidthOut;
  770. rcButtons.left = min(rcButtons.right, pItemArgs->rcItem.right - nControlsWidthRight);
  771. // create buttons
  772. for (i = 0; i < pInpaceButtons->GetSize(); i++)
  773. {
  774. CXTPReportInplaceButton* pButton = pInpaceButtons->GetAt(i);
  775. pButton->Create(pItemArgs, rcButtons);
  776. pControl->GetInplaceButtons()->Add(pButton);
  777. }
  778. // adjust item rect
  779. pItemArgs->rcItem.right = rcButtons.left + 1 + nControlsWidthRight;
  780. if (pEditOptions->m_bAllowEdit)
  781. {
  782. pEdit->Create(pItemArgs);
  783. }
  784. else if (pInpaceButtons->GetSize() > 0)
  785. {
  786. OnInplaceButtonDown(pInpaceButtons->GetAt(0));
  787. }
  788. //----------------------------------------------------
  789. XTP_NM_REPORTRECORDITEM nm;
  790. ::ZeroMemory(&nm, sizeof(nm));
  791. nm.pItem = this;
  792. nm.pRow = pItemArgs->pRow;
  793. nm.pColumn = pItemArgs->pColumn;
  794. pControl->SendNotifyMessage(XTP_NM_REPORT_BEGINEDIT, (NMHDR*)&nm);
  795. }
  796. }
  797. void CXTPReportRecordItem::OnCancelEdit(CXTPReportControl* pControl, BOOL bApply)
  798. {
  799. CXTPReportInplaceButtons* pInpaceButtons = pControl->GetInplaceButtons();
  800. for (int i = 0; i < pInpaceButtons->GetSize(); i++)
  801. {
  802. CXTPReportInplaceButton* pButton = pInpaceButtons->GetAt(i);
  803. pButton->DestroyWindow();
  804. pButton->SetItemArgs(0);
  805. }
  806. pInpaceButtons->RemoveAll();
  807. CXTPReportInplaceList* pInpaceList = pControl->GetInplaceList();
  808. if (pInpaceList->GetSafeHwnd())
  809. {
  810. pInpaceList->DestroyWindow();
  811. }
  812. CXTPReportInplaceEdit* pEdit = pControl->GetInplaceEdit();
  813. if (bApply && pEdit->GetSafeHwnd() && pEdit->GetItem() == this)
  814. {
  815. OnValidateEdit((XTP_REPORTRECORDITEM_ARGS*)pEdit);
  816. }
  817. pEdit->HideWindow();
  818. pEdit->SetItemArgs(0);
  819. pEdit->DestroyWindow(); // pControl->SetFocus();
  820. }
  821. void CXTPReportRecordItem::OnConstraintChanged(XTP_REPORTRECORDITEM_ARGS* pItemArgs, CXTPReportRecordItemConstraint* pConstraint)
  822. {
  823. OnEditChanged(pItemArgs, pConstraint->m_strConstraint);
  824. }
  825. void CXTPReportRecordItem::OnValidateEdit(XTP_REPORTRECORDITEM_ARGS* pItemArgs)
  826. {
  827. ASSERT(pItemArgs);
  828. if (!pItemArgs)
  829. return;
  830. CXTPReportControl* pControl = pItemArgs->pControl;
  831. CXTPReportInplaceEdit* pEdit = pControl->GetInplaceEdit();
  832. XTP_REPORTRECORDITEM_ARGS args = *pItemArgs;
  833. if (pEdit->GetSafeHwnd() && pEdit->GetItem() == this)
  834. {
  835. args.AddRef();
  836. BOOL bRedraw = FALSE;
  837. CMDTARGET_RELEASE(pEdit->pItem); //pEdit->pItem = NULL;
  838. if (GetEditOptions(args.pColumn)->m_bConstraintEdit)
  839. {
  840. if (pEdit->m_pSelectedConstraint)
  841. {
  842. OnConstraintChanged(&args, pEdit->m_pSelectedConstraint);
  843. bRedraw = TRUE;
  844. }
  845. }
  846. else
  847. {
  848. CString strValue;
  849. pEdit->GetWindowText(strValue);
  850. if (GetCaption(args.pColumn) != strValue)
  851. {
  852. OnEditChanged(&args, strValue);
  853. bRedraw = TRUE;
  854. }
  855. }
  856. if (bRedraw)
  857. {
  858. pControl->RedrawControl();
  859. pControl->SendMessageToParent(args.pRow, this, args.pColumn, XTP_NM_REPORT_VALUECHANGED, 0);
  860. }
  861. else
  862. {
  863. OnEditCanceled(pItemArgs);
  864. pControl->SendMessageToParent(args.pRow, this, args.pColumn, XTP_NM_REPORT_EDIT_CANCELED, 0);
  865. }
  866. pEdit->SetItemArgs(0);
  867. args.Release();
  868. }
  869. }
  870. BOOL CXTPReportRecordItem::IsAllowEdit(XTP_REPORTRECORDITEM_ARGS* pItemArgs)
  871. {
  872. BOOL bIsAllowEdit = pItemArgs->pControl->IsAllowEdit();
  873. if (m_pRecord)
  874. {
  875. // is header record
  876. if (m_pRecord->m_pRecords == pItemArgs->pControl->GetHeaderRecords())
  877. {
  878. bIsAllowEdit = pItemArgs->pControl->IsHeaderRowsAllowEdit();
  879. }
  880. else
  881. // is footer record
  882. if (m_pRecord->m_pRecords == pItemArgs->pControl->GetFooterRecords())
  883. {
  884. bIsAllowEdit = pItemArgs->pControl->IsFooterRowsAllowEdit();
  885. }
  886. }
  887. return bIsAllowEdit && IsEditable() &&
  888. ((pItemArgs->pColumn && pItemArgs->pColumn->IsEditable()) || (!pItemArgs->pColumn && m_pEditOptions &&
  889. m_pEditOptions->m_bAllowEdit));
  890. /*  return pItemArgs->pControl->IsAllowEdit() && IsEditable() &&
  891. ((pItemArgs->pColumn && pItemArgs->pColumn->IsEditable()) || (!pItemArgs->pColumn && m_pEditOptions &&
  892. m_pEditOptions->m_bAllowEdit));*/
  893. }
  894. BOOL CXTPReportRecordItem::OnRequestEdit(XTP_REPORTRECORDITEM_ARGS* pItemArgs)
  895. {
  896. CXTPReportControl* pControl = pItemArgs->pControl;
  897. XTP_NM_REPORTREQUESTEDIT nm;
  898. ::ZeroMemory(&nm, sizeof(nm));
  899. nm.bCancel = FALSE;
  900. nm.pItem = this;
  901. nm.pRow = pItemArgs->pRow;
  902. nm.pColumn = pItemArgs->pColumn;
  903. pControl->SendNotifyMessage(XTP_NM_REPORT_REQUESTEDIT, (NMHDR*)&nm);
  904. return !nm.bCancel;
  905. }
  906. BOOL CXTPReportRecordItem::OnChar(XTP_REPORTRECORDITEM_ARGS* pItemArgs, UINT nChar)
  907. {
  908. CXTPReportControl* pControl = pItemArgs->pControl;
  909. if ((nChar == VK_SPACE) && IsEditable() && m_bHasCheckbox && (pItemArgs->pColumn == NULL || pItemArgs->pColumn->IsEditable())
  910. && OnRequestEdit(pItemArgs))
  911. {
  912. if (pControl->IsAutoCheckItems()) SetChecked(!IsChecked());
  913. pControl->RedrawControl();
  914. pControl->SendMessageToParent(pItemArgs->pRow, this, pItemArgs->pColumn, XTP_NM_REPORT_CHECKED, NULL);
  915. return TRUE;
  916. }
  917. if (IsAllowEdit(pItemArgs))
  918. {
  919. pControl->EditItem(pItemArgs);
  920. CXTPReportInplaceEdit* pEdit = pControl->GetInplaceEdit();
  921. if (pEdit->GetSafeHwnd() && pEdit->GetItem() == this)
  922. {
  923. pEdit->SetFocus();
  924. pEdit->SetSel(0, -1);
  925. if (nChar != VK_TAB) pEdit->SendMessage(WM_CHAR, nChar);
  926. }
  927. return TRUE;
  928. }
  929. return FALSE;
  930. }
  931. CXTPReportRecordItemEditOptions* CXTPReportRecordItem::GetEditOptions(CXTPReportColumn* pColumn)
  932. {
  933. if (m_pEditOptions)
  934. return m_pEditOptions;
  935. if (pColumn)
  936. return pColumn->GetEditOptions();
  937. return m_pEditOptions = new CXTPReportRecordItemEditOptions();
  938. }
  939. CXTPReportRecordItemControls* CXTPReportRecordItem::GetItemControls()
  940. {
  941. if (!m_pItemControls)
  942. m_pItemControls = new CXTPReportRecordItemControls(this);
  943. return m_pItemControls;
  944. }
  945. void CXTPReportRecordItem::OnInplaceButtonDown(CXTPReportInplaceButton* pButton)
  946. {
  947. CXTPReportControl* pControl = pButton->pControl;
  948. XTP_NM_REPORTINPLACEBUTTON nm;
  949. ::ZeroMemory(&nm, sizeof(nm));
  950. nm.pButton = pButton;
  951. nm.pItem = this;
  952. if (pControl->SendNotifyMessage(XTP_NM_REPORT_INPLACEBUTTONDOWN, (NMHDR*)&nm) == TRUE)
  953. return;
  954. if (pButton->GetID() == XTP_ID_REPORT_COMBOBUTTON)
  955. {
  956. CXTPReportInplaceList* pList = pControl->GetInplaceList();
  957. XTP_REPORTRECORDITEM_ARGS itemArgs = *pButton;
  958. if (!itemArgs.pColumn && !itemArgs.pControl && !itemArgs.pItem && !itemArgs.pRow)
  959. {
  960. return;
  961. }
  962. ASSERT(itemArgs.pItem == this);
  963. CXTPWindowRect rcButton(pButton);
  964. pControl->ScreenToClient(&rcButton);
  965. itemArgs.rcItem.right = rcButton.right;
  966. itemArgs.rcItem.bottom  = rcButton.bottom;
  967. CXTPReportRecordItemEditOptions* pEditOptions = GetEditOptions(itemArgs.pColumn);
  968. if (pEditOptions->GetConstraints()->GetCount() > 0)
  969. {
  970. pList->Create(&itemArgs, pEditOptions->GetConstraints());
  971. }
  972. }
  973. else if (pButton->GetID() == XTP_ID_REPORT_SPINBUTTON)
  974. {
  975. XTP_REPORTRECORDITEM_ARGS itemArgs = *pButton;
  976. ASSERT(itemArgs.pItem == this);
  977. CXTPReportInplaceEdit* pEdit = pControl->GetInplaceEdit();
  978. if (itemArgs.pRow && itemArgs.pColumn && pEdit->GetSafeHwnd() && pEdit->GetItem() == this)
  979. {
  980. CString strValue;
  981. pEdit->GetWindowText(strValue);
  982. int nValue = _ttoi(strValue);
  983. nValue += pButton->m_nSpinIncrement;
  984. strValue.Format(_T("%d"), nValue);
  985. pEdit->SetWindowText(strValue);
  986. pControl->RedrawControl();
  987. pControl->SendMessageToParent(itemArgs.pRow, this, itemArgs.pColumn, XTP_NM_REPORT_VALUECHANGED, 0);
  988. }
  989. }
  990. }
  991. CXTPReportHyperlinks* CXTPReportRecordItem::GetHyperlinks()
  992. {
  993. if (!m_pHyperlinks)
  994. m_pHyperlinks = new CXTPReportHyperlinks();
  995. return m_pHyperlinks;
  996. }
  997. void CXTPReportRecordItem::DoPropExchange(CXTPPropExchange* pPX)
  998. {
  999. PX_DWord(pPX, _T("TextColor"), (DWORD&)m_clrText, XTP_REPORT_COLOR_DEFAULT);
  1000. PX_DWord(pPX, _T("BackgroundColor"), (DWORD&)m_clrBackground, XTP_REPORT_COLOR_DEFAULT);
  1001. PX_Bool(pPX, _T("BoldText"), m_bBoldText, FALSE);
  1002. PX_String(pPX, _T("Format"), m_strFormatString, _T("%s"));
  1003. PX_Bool(pPX, _T("Editable"), m_bEditable, TRUE);
  1004. PX_Int(pPX, _T("IconIndex"), m_nIconIndex, XTP_REPORT_NOICON);
  1005. PX_Int(pPX, _T("SortPriority"), m_nSortPriority, -1);
  1006. PX_Int(pPX, _T("GroupPriority"), m_nGroupPriority, -1);
  1007. PX_String(pPX, _T("GroupCaption"), m_strGroupCaption, _T(""));
  1008. PX_Bool(pPX, _T("Focusable"), m_bFocusable, TRUE);
  1009. PX_Bool(pPX, _T("Checked"), m_bChecked, FALSE);
  1010. PX_Bool(pPX, _T("HasCheckbox"), m_bHasCheckbox, FALSE);
  1011. ULONGLONG ullData = m_dwData;
  1012. PX_UI8(pPX, _T("Data"), ullData, 0);
  1013. m_dwData = (DWORD_PTR)ullData;
  1014. PX_String(pPX, _T("Tooltip"), m_strTooltip, _T(""));
  1015. if (pPX->GetSchema() > _XTP_SCHEMA_98)
  1016. {
  1017. PX_String(pPX, _T("Caption"), m_strCaption, _T(""));
  1018. }
  1019. // Hyperlinks
  1020. CXTPPropExchangeSection secHyperlinks(pPX->GetSection(_T("Hyperlinks")));
  1021. CXTPReportHyperlinks arHyperlinks;
  1022. if (pPX->IsStoring() && m_pHyperlinks)
  1023. {
  1024. arHyperlinks.CopyFrom(m_pHyperlinks);
  1025. }
  1026. arHyperlinks.DoPropExchange(&secHyperlinks);
  1027. if (pPX->IsLoading())
  1028. {
  1029. if (arHyperlinks.GetSize())
  1030. {
  1031. if (GetHyperlinks())
  1032. GetHyperlinks()->CopyFrom(&arHyperlinks);
  1033. }
  1034. else if (m_pHyperlinks)
  1035. {
  1036. m_pHyperlinks->RemoveAll();
  1037. }
  1038. }
  1039. // Item controls
  1040. CXTPReportRecordItemControls arItemControls;
  1041. if (pPX->IsStoring() && m_pItemControls)
  1042. arItemControls.CopyFrom(m_pItemControls);
  1043. if (pPX->GetSchema() >= _XTP_SCHEMA_1200)
  1044. {
  1045. CXTPPropExchangeSection secItemControls(pPX->GetSection(_T("ItemControls")));
  1046. arItemControls.DoPropExchange(&secItemControls);
  1047. }
  1048. if (pPX->IsLoading())
  1049. {
  1050. if (arItemControls.GetSize())
  1051. {
  1052. if (GetItemControls())
  1053. GetItemControls()->CopyFrom(&arItemControls);
  1054. }
  1055. else if (m_pItemControls)
  1056. {
  1057. m_pItemControls->RemoveAll();
  1058. }
  1059. }
  1060. // Update Markup data
  1061. if (pPX->IsLoading())
  1062. {
  1063. XTPMarkupReleaseElement(m_pMarkupUIElement);
  1064. if (m_pRecord && m_pRecord->GetRecords() && m_pRecord->GetRecords()->GetMarkupContext())
  1065. {
  1066. m_pMarkupUIElement = XTPMarkupParseText(m_pRecord->GetRecords()->GetMarkupContext(), m_strCaption);
  1067. }
  1068. }
  1069. }