ReportBoxProperties.cpp
Upload User: kairuinn
Upload Date: 2009-02-07
Package Size: 2922k
Code Size: 13k
Category:

Graph program

Development Platform:

Visual C++

  1. /* ==========================================================================
  2. Class : CReportBoxProperties
  3. Author : Johan Rosengren, Abstrakt Mekanik AB
  4. Date : 2004-07-25
  5. Purpose : "CReportBoxProperties" is a "CDiagramPropertyDlg"-derived 
  6. class for setting properties to a "CReportEntityBox" 
  7. object
  8. Description : This is a Wizard-created dialogbox class.
  9. Usage : See "CDiagramPropertyDlg".
  10.    ========================================================================*/
  11. #include "stdafx.h"
  12. #include "ReportBoxProperties.h"
  13. #include "ReportEntityBox.h"
  14. #include "ReportEntitySettings.h"
  15. #ifdef _DEBUG
  16. #define new DEBUG_NEW
  17. #undef THIS_FILE
  18. static char THIS_FILE[] = __FILE__;
  19. #endif
  20. /////////////////////////////////////////////////////////////////////////////
  21. // CReportBoxProperties dialog
  22. CReportBoxProperties::CReportBoxProperties(IThumbnailerStorage* pParent /*=NULL*/)
  23. : CDiagramPropertyDlg(CReportBoxProperties::IDD, pParent)
  24. /* ============================================================
  25. Function : CReportBoxProperties::CReportBoxProperties
  26. Description : Constructor
  27. Access : Public
  28. Return : void
  29. Parameters : CWnd* pParent - Parent window
  30. Usage :
  31.    ============================================================*/
  32. {
  33. //{{AFX_DATA_INIT(CReportBoxProperties)
  34. m_borderThickness = 0;
  35. m_fill = FALSE;
  36. //}}AFX_DATA_INIT
  37. m_borderStyle = 0;
  38. m_otiExistFill = NULL;
  39. m_otiFillColorCombo = NULL;
  40. m_otiExistLeft = NULL;
  41. m_otiExistRight = NULL;
  42. m_otiExistTop = NULL;
  43. m_otiExistBottom= NULL;
  44. m_otiFrameColorCombo =NULL;
  45. m_otiFrameThicknessCombo = NULL;
  46. }
  47. void CReportBoxProperties::DoDataExchange(CDataExchange* pDX)
  48. /* ============================================================
  49. Function : CReportBoxProperties::DoDataExchange
  50. Description : MFC data exchange handler.
  51. Access : Protected
  52. Return : void
  53. Parameters : CDataExchange* pDX - Exchange object
  54. Usage : Called from MFC.
  55.    ============================================================*/
  56. {
  57. CDialog::DoDataExchange(pDX);
  58. //{{AFX_DATA_MAP(CReportBoxProperties)
  59. //}}AFX_DATA_MAP
  60. }
  61. BEGIN_MESSAGE_MAP(CReportBoxProperties, CDialog)
  62. //{{AFX_MSG_MAP(CReportBoxProperties)
  63. //}}AFX_MSG_MAP
  64. END_MESSAGE_MAP()
  65. /////////////////////////////////////////////////////////////////////////////
  66. // CReportBoxProperties message handlers
  67. void CReportBoxProperties::OnOK() 
  68. /* ============================================================
  69. Function : CReportBoxProperties::OnOK
  70. Description : Handler for the dialog OK-button.
  71. Access : Protected
  72. Return : void
  73. Parameters : none
  74. Usage : Called from MFC.
  75.    ============================================================*/
  76. {
  77. CReportEntityBox* obj = static_cast< CReportEntityBox* >( GetEntity() );
  78. if (m_otiExistFill->IsSelected())
  79. {
  80. m_otiExistFill->CommitChanges();
  81. m_otiExistFill->LostFocus();
  82. }
  83. if (m_otiFillColorCombo->IsSelected())
  84. {
  85. m_otiFillColorCombo->CommitChanges();
  86. m_otiFillColorCombo->LostFocus();
  87. }
  88. if (m_otiExistLeft->IsSelected())
  89. {
  90. m_otiExistLeft->CommitChanges();
  91. m_otiExistLeft->LostFocus();
  92. }
  93. if (m_otiExistRight->IsSelected())
  94. {
  95. m_otiExistRight->CommitChanges();
  96. m_otiExistRight->LostFocus();
  97. }
  98. if (m_otiExistTop->IsSelected())
  99. {
  100. m_otiExistTop->CommitChanges();
  101. m_otiExistTop->LostFocus();
  102. }
  103. if (m_otiExistBottom->IsSelected())
  104. {
  105. m_otiExistBottom->CommitChanges();
  106. m_otiExistBottom->LostFocus();
  107. }
  108. if (m_otiFrameColorCombo->IsSelected())
  109. {
  110. m_otiFrameColorCombo->CommitChanges();
  111. m_otiFrameColorCombo->LostFocus();
  112. }
  113. if (m_otiFrameThicknessCombo->IsSelected())
  114. {
  115. m_otiFrameThicknessCombo->CommitChanges();
  116. m_otiFrameThicknessCombo->LostFocus();
  117. }
  118. m_fill = m_otiExistFill->GetCheck();
  119. m_fillColor = m_otiFillColorCombo->GetCurColor();
  120. m_borderStyle = 0;
  121. if (m_otiExistLeft->GetCheck())
  122. m_borderStyle |= DIAGRAM_FRAME_STYLE_LEFT;
  123. if (m_otiExistRight->GetCheck())
  124. m_borderStyle |= DIAGRAM_FRAME_STYLE_RIGHT;
  125. if (m_otiExistTop->GetCheck())
  126. m_borderStyle |= DIAGRAM_FRAME_STYLE_TOP;
  127. if (m_otiExistBottom->GetCheck())
  128. m_borderStyle |= DIAGRAM_FRAME_STYLE_BOTTOM;
  129. m_borderColor = m_otiFrameColorCombo->GetCurColor();
  130. m_borderThickness = m_otiFrameThicknessCombo->GetLineThickness();
  131. obj->SetBorderColor( m_borderColor );
  132. obj->SetBorderThickness( m_borderThickness );
  133. obj->SetFill( m_fill );
  134. obj->SetFillColor( m_fillColor );
  135.     obj->SetBorderStyle( m_borderStyle );
  136. CReportEntitySettings::GetRESInstance()->SetFill( m_fill );
  137. CReportEntitySettings::GetRESInstance()->SetFillColor( m_fillColor );
  138. CReportEntitySettings::GetRESInstance()->SetBorderColor( m_borderColor );
  139. CReportEntitySettings::GetRESInstance()->SetBorderThickness( m_borderThickness );
  140. CReportEntitySettings::GetRESInstance()->SetBorderStyle( m_borderStyle );
  141. ShowWindow( SW_HIDE );
  142. Redraw();
  143. }
  144. void CReportBoxProperties::OnCancel() 
  145. /* ============================================================
  146. Function : CReportBoxProperties::OnCancel
  147. Description : Handler for the dialog Cancel-button.
  148. Access : Protected
  149. Return : void
  150. Parameters : none
  151. Usage : Called from MFC.
  152.    ============================================================*/
  153. {
  154. if (m_otiExistFill->IsSelected())
  155. {
  156. m_otiExistFill->Select(FALSE);
  157. m_otiExistFill->LostFocus();
  158. }
  159. if (m_otiFillColorCombo->IsSelected())
  160. {
  161. m_otiFillColorCombo->Select(FALSE);
  162. m_otiFillColorCombo->LostFocus();
  163. }
  164. if (m_otiExistLeft->IsSelected())
  165. {
  166. m_otiExistLeft->Select(FALSE);
  167. m_otiExistLeft->LostFocus();
  168. }
  169. if (m_otiExistRight->IsSelected())
  170. {
  171. m_otiExistRight->Select(FALSE);
  172. m_otiExistRight->LostFocus();
  173. }
  174. if (m_otiExistTop->IsSelected())
  175. {
  176. m_otiExistTop->Select(FALSE);
  177. m_otiExistTop->LostFocus();
  178. }
  179. if (m_otiExistBottom->IsSelected())
  180. {
  181. m_otiExistBottom->Select(FALSE);
  182. m_otiExistBottom->LostFocus();
  183. }
  184. if (m_otiFrameColorCombo->IsSelected())
  185. {
  186. m_otiFrameColorCombo->Select(FALSE);
  187. m_otiFrameColorCombo->LostFocus();
  188. }
  189. if (m_otiFrameThicknessCombo->IsSelected())
  190. {
  191. m_otiFrameThicknessCombo->Select(FALSE);
  192. m_otiFrameThicknessCombo->LostFocus();
  193. }
  194. ShowWindow( SW_HIDE );
  195. }
  196. BOOL CReportBoxProperties::OnInitDialog() 
  197. /* ============================================================
  198. Function : CReportBoxProperties::OnInitDialog
  199. Description : Handler for the "WM_INITDIALOG" messag
  200. Access : Protected
  201. Return : BOOL - Always "TRUE"
  202. Parameters : none
  203. Usage : Called from MFC
  204.    ============================================================*/
  205. {
  206. CDialog::OnInitDialog();
  207. COptionTreeItem *otiRoot = NULL;
  208. COptionTreeItem *otiItem = NULL;
  209. CRect rcClient;
  210. DWORD dwStyle, dwOptions;
  211. LOGFONT lfFont, lfDefaultFont;
  212. // Get log fonts
  213. GetFont()->GetLogFont(&lfFont);
  214. GetFont()->GetLogFont(&lfDefaultFont);
  215. strcpy(lfDefaultFont.lfFaceName, _T("Arial"));
  216. // Get the clients rectangle
  217. GetClientRect(rcClient);
  218. // Setup the window style
  219. dwStyle = WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
  220. // Setup the tree options 
  221. // OT_OPTIONS_SHOWINFOWINDOW
  222. dwOptions = OT_OPTIONS_SHADEEXPANDCOLUMN | OT_OPTIONS_SHADEROOTITEMS | OT_OPTIONS_SHOWINFOWINDOW;
  223. int  trBot=rcClient.bottom;
  224. if (GetDlgItem(IDOK))
  225. {
  226. CRect rrrr;
  227. GetDlgItem(IDOK)->GetWindowRect(rrrr);
  228. ScreenToClient(rrrr);
  229. trBot = rrrr.top -4;
  230. }
  231. // Create tree options
  232. CRect trR = rcClient;
  233. trR.bottom = trBot;
  234. if (m_otTree.Create(dwStyle, trR, this, dwOptions, 1004) == FALSE)
  235. {
  236. TRACE0("Failed to create options control.rn");
  237. return FALSE;
  238. }
  239. // Want to be notified
  240. m_otTree.SetNotify(TRUE, this);
  241. CString resStr;
  242. CString yesS;
  243. yesS.LoadString(IDS_YES);
  244. CString noS;
  245. noS.LoadString(IDS_NO);
  246. // -- Edit Items
  247. otiRoot = m_otTree.InsertItem(new COptionTreeItem());
  248. resStr.LoadString(IDS_REP_BOX_FILL);
  249. otiRoot->SetLabelText(resStr);
  250. resStr.LoadString(IDS_REP_BOX_FULL_FILL);
  251. otiRoot->SetInfoText(resStr);
  252. m_otiExistFill = (COptionTreeItemCheckBox*)m_otTree.InsertItem(new COptionTreeItemCheckBox(), otiRoot);
  253. resStr.LoadString(IDS_REP_BOX_IS_FILL);
  254. m_otiExistFill->SetLabelText(resStr);
  255. resStr.LoadString(IDS_REP_BOX_FULL_IS_FILL);
  256. m_otiExistFill->SetInfoText(resStr);
  257. if (m_otiExistFill->CreateCheckBoxItem(m_fill, OT_CHECKBOX_SHOWCHECK) == TRUE)
  258. {
  259. m_otiExistFill->SetCheckText(yesS, noS);
  260. }
  261. m_otiFillColorCombo = (COptionTreeItemColorComboBox*)m_otTree.InsertItem(new COptionTreeItemColorComboBox(), otiRoot);
  262. resStr.LoadString(IDS_OB_PR_DL_COLOR);
  263. m_otiFillColorCombo->SetLabelText(resStr);
  264. resStr.LoadString(IDS_REP_BOX_FULL_COLOR);
  265. m_otiFillColorCombo->SetInfoText(resStr);
  266. if (m_otiFillColorCombo->CreateComboItem(NULL) == TRUE)
  267. {
  268. m_otiFillColorCombo->SetCurColor(m_fillColor);
  269. }
  270. otiRoot->Expand();
  271. otiRoot = m_otTree.InsertItem(new COptionTreeItem());
  272. resStr.LoadString(IDS_REP_PR_DL_FRAME);
  273. otiRoot->SetLabelText(resStr);
  274. resStr.LoadString(IDS_REP_PR_DL_FULL_FRAME);
  275. otiRoot->SetInfoText(resStr);
  276. m_otiExistLeft = (COptionTreeItemCheckBox*)m_otTree.InsertItem(new COptionTreeItemCheckBox(), otiRoot);
  277. resStr.LoadString(IDS_REP_PR_DL_LEFT);
  278. m_otiExistLeft->SetLabelText(resStr);
  279. resStr.LoadString(IDS_REP_PR_DL_FULL_LEFT);
  280. m_otiExistLeft->SetInfoText(resStr);
  281. if (m_otiExistLeft->CreateCheckBoxItem(m_borderStyle&DIAGRAM_FRAME_STYLE_LEFT, OT_CHECKBOX_SHOWCHECK) == TRUE)
  282. {
  283. m_otiExistLeft->SetCheckText(yesS, noS);
  284. }
  285. m_otiExistRight = (COptionTreeItemCheckBox*)m_otTree.InsertItem(new COptionTreeItemCheckBox(), otiRoot);
  286. resStr.LoadString(IDS_REP_PR_DL_RIGHT);
  287. m_otiExistRight->SetLabelText(resStr);
  288. resStr.LoadString(IDS_REP_PR_DL_FULL_RIGHT);
  289. m_otiExistRight->SetInfoText(resStr);
  290. if (m_otiExistRight->CreateCheckBoxItem(m_borderStyle&DIAGRAM_FRAME_STYLE_RIGHT, OT_CHECKBOX_SHOWCHECK) == TRUE)
  291. {
  292. m_otiExistRight->SetCheckText(yesS, noS);
  293. }
  294. m_otiExistTop = (COptionTreeItemCheckBox*)m_otTree.InsertItem(new COptionTreeItemCheckBox(), otiRoot);
  295. resStr.LoadString(IDS_REP_PR_DL_TOP);
  296. m_otiExistTop->SetLabelText(resStr);
  297. resStr.LoadString(IDS_REP_PR_DL_FULL_TOP);
  298. m_otiExistTop->SetInfoText(resStr);
  299. if (m_otiExistTop->CreateCheckBoxItem(m_borderStyle&DIAGRAM_FRAME_STYLE_TOP, OT_CHECKBOX_SHOWCHECK) == TRUE)
  300. {
  301. m_otiExistTop->SetCheckText(yesS, noS);
  302. }
  303. m_otiExistBottom = (COptionTreeItemCheckBox*)m_otTree.InsertItem(new COptionTreeItemCheckBox(), otiRoot);
  304. resStr.LoadString(IDS_REP_PR_DL_BOTTOM);
  305. m_otiExistBottom->SetLabelText(resStr);
  306. resStr.LoadString(IDS_REP_PR_DL_FULL_BOTTOM);
  307. m_otiExistBottom->SetInfoText(resStr);
  308. if (m_otiExistBottom->CreateCheckBoxItem(m_borderStyle&DIAGRAM_FRAME_STYLE_BOTTOM, OT_CHECKBOX_SHOWCHECK) == TRUE)
  309. {
  310. m_otiExistBottom->SetCheckText(yesS, noS);
  311. }
  312. m_otiFrameColorCombo = (COptionTreeItemColorComboBox*)m_otTree.InsertItem(new COptionTreeItemColorComboBox(), otiRoot);
  313. resStr.LoadString(IDS_PER_PR_DL_COL_FR);
  314. m_otiFrameColorCombo->SetLabelText(resStr);
  315. resStr.LoadString(IDS_PER_PR_DL_FULL_COL_FR);
  316. m_otiFrameColorCombo->SetInfoText(resStr);
  317. if (m_otiFrameColorCombo->CreateComboItem(NULL) == TRUE)
  318. {
  319. m_otiFrameColorCombo->SetCurColor(m_borderColor);
  320. }
  321. m_otiFrameThicknessCombo = (COptionTreeItemLineThikComboBox*)m_otTree.InsertItem(new COptionTreeItemLineThikComboBox(), otiRoot);
  322. resStr.LoadString(IDS_PER_PR_DL_TH_FR);
  323. m_otiFrameThicknessCombo->SetLabelText(resStr);
  324. resStr.LoadString(IDS_PER_PR_DL_FULL_TH_FR);
  325. m_otiFrameThicknessCombo->SetInfoText(resStr);
  326. if (m_otiFrameThicknessCombo->CreateComboItem(NULL) == TRUE)
  327. {
  328. m_otiFrameThicknessCombo->SetLineThickness(m_borderThickness);
  329. }
  330. otiRoot->Expand();
  331. return TRUE;
  332. }
  333. void CReportBoxProperties::SetValues()
  334. /* ============================================================
  335. Function : CReportBoxProperties::SetValues
  336. Description : Sets the data in the box from the attached 
  337. object.
  338. Access : Public
  339. Return : void
  340. Parameters : none
  341. Usage : Called from the object
  342.    ============================================================*/
  343. {
  344. CReportEntityBox* obj = static_cast< CReportEntityBox* >( GetEntity() );
  345. m_borderColor = obj->GetBorderColor();
  346. m_fillColor = obj->GetFillColor();
  347. m_borderThickness = obj->GetBorderThickness();
  348. if( m_otiFillColorCombo )
  349. m_otiFillColorCombo->SetCurColor( m_fillColor );
  350. if( m_otiFrameColorCombo )
  351. m_otiFrameColorCombo->SetCurColor( m_borderColor );
  352. if (m_otiFrameThicknessCombo)
  353. m_otiFrameThicknessCombo->SetLineThickness(m_borderThickness);
  354. m_fill = obj->GetFill();
  355. if (m_otiExistFill)
  356. m_otiExistFill->SetCheck(m_fill);
  357. m_borderStyle = obj->GetBorderStyle();
  358. if (m_otiExistLeft)
  359. m_otiExistLeft->SetCheck(m_borderStyle&DIAGRAM_FRAME_STYLE_LEFT);
  360. if (m_otiExistRight)
  361. m_otiExistRight->SetCheck((m_borderStyle&DIAGRAM_FRAME_STYLE_RIGHT)?TRUE:FALSE);
  362. if (m_otiExistTop)
  363. m_otiExistTop->SetCheck((m_borderStyle&DIAGRAM_FRAME_STYLE_TOP)?TRUE:FALSE);
  364. if (m_otiExistBottom)
  365. m_otiExistBottom->SetCheck((m_borderStyle&DIAGRAM_FRAME_STYLE_BOTTOM)?TRUE:FALSE);
  366. }