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

Graph program

Development Platform:

Visual C++

  1. /* ==========================================================================
  2. Class : CReportLineProperties
  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 "CReportEntityLine" 
  7. object
  8. Description : This is a Wizard-created dialogbox class.
  9. Usage : See "CDiagramPropertyDlg".
  10.    ========================================================================*/
  11. #include "stdafx.h"
  12. #include "ReportLineProperties.h"
  13. #include "ReportEntityLine.h"
  14. #include "ReportEntitySettings.h"
  15. #include "..//Drawer.h"
  16. #ifdef _DEBUG
  17. #define new DEBUG_NEW
  18. #undef THIS_FILE
  19. static char THIS_FILE[] = __FILE__;
  20. #endif
  21. /////////////////////////////////////////////////////////////////////////////
  22. // CReportLineProperties dialog
  23. CReportLineProperties::CReportLineProperties(IThumbnailerStorage* pParent /*=NULL*/)
  24. : CDiagramPropertyDlg(CReportLineProperties::IDD, pParent)
  25. /* ============================================================
  26. Function : CReportLineProperties::CReportLineProperties
  27. Description : Constructor
  28. Access : Public
  29. Return : void
  30. Parameters : CWnd* pParent - Window parent
  31. Usage :
  32.    ============================================================*/
  33. {
  34. //{{AFX_DATA_INIT(CReportLineProperties)
  35. m_thickness = 0;
  36. //}}AFX_DATA_INIT
  37. m_otiColorCombo = NULL;
  38. m_otiThicknessCombo = NULL;
  39. }
  40. void CReportLineProperties::DoDataExchange(CDataExchange* pDX)
  41. /* ============================================================
  42. Function : CReportLineProperties::DoDataExchange
  43. Description : MFC data exchange handler.
  44. Access : Protected
  45. Return : void
  46. Parameters : CDataExchange* pDX - Exchange object
  47. Usage : Called from MFC.
  48.    ============================================================*/
  49. {
  50. CDialog::DoDataExchange(pDX);
  51. //{{AFX_DATA_MAP(CReportLineProperties)
  52. //}}AFX_DATA_MAP
  53. }
  54. BEGIN_MESSAGE_MAP(CReportLineProperties, CDialog)
  55. //{{AFX_MSG_MAP(CReportLineProperties)
  56. //}}AFX_MSG_MAP
  57. END_MESSAGE_MAP()
  58. /////////////////////////////////////////////////////////////////////////////
  59. // CReportLineProperties message handlers
  60. void CReportLineProperties::OnOK() 
  61. /* ============================================================
  62. Function : CReportLineProperties::OnOK
  63. Description : Handler for the dialog OK-button.
  64. Access : Protected
  65. Return : void
  66. Parameters : none
  67. Usage : Called from MFC.
  68.    ============================================================*/
  69. {
  70. CReportEntityLine* obj = static_cast< CReportEntityLine* >( GetEntity() );
  71. if (m_otiColorCombo->IsSelected())
  72. {
  73. m_otiColorCombo->CommitChanges();
  74. m_otiColorCombo->LostFocus();
  75. }
  76. if (m_otiThicknessCombo->IsSelected())
  77. {
  78. m_otiThicknessCombo->CommitChanges();
  79. m_otiThicknessCombo->LostFocus();
  80. }
  81. m_color = m_otiColorCombo->GetCurColor();
  82. m_thickness = m_otiThicknessCombo->GetLineThickness();
  83. obj->SetBorderColor( m_color );
  84. obj->SetBorderThickness( m_thickness );
  85. CReportEntitySettings::GetRESInstance()->SetLineColor( m_color );
  86. CReportEntitySettings::GetRESInstance()->SetLineThickness( m_thickness );
  87. ShowWindow( SW_HIDE );
  88. Redraw();
  89. }
  90. void CReportLineProperties::OnCancel() 
  91. /* ============================================================
  92. Function : CReportLineProperties::OnCancel
  93. Description : Handler for the dialog Cancel-button.
  94. Access : Protected
  95. Return : void
  96. Parameters : none
  97. Usage : Called from MFC.
  98.    ============================================================*/
  99. {
  100. if (m_otiColorCombo->IsSelected())
  101. {
  102. m_otiColorCombo->Select(FALSE);
  103. m_otiColorCombo->LostFocus();
  104. }
  105. if (m_otiThicknessCombo->IsSelected())
  106. {
  107. m_otiThicknessCombo->Select(FALSE);
  108. m_otiThicknessCombo->LostFocus();
  109. }
  110. ShowWindow( SW_HIDE );
  111. }
  112. BOOL CReportLineProperties::OnInitDialog() 
  113. /* ============================================================
  114. Function : CReportLineProperties::OnInitDialog
  115. Description : Handler for the "WM_INITDIALOG" messag
  116. Access : Protected
  117. Return : BOOL - Always "TRUE"
  118. Parameters : none
  119. Usage : Called from MFC
  120.    ============================================================*/
  121. {
  122. CDialog::OnInitDialog();
  123. COptionTreeItem *otiRoot = NULL;
  124. COptionTreeItem *otiItem = NULL;
  125. CRect rcClient;
  126. DWORD dwStyle, dwOptions;
  127. LOGFONT lfFont, lfDefaultFont;
  128. // Get log fonts
  129. GetFont()->GetLogFont(&lfFont);
  130. GetFont()->GetLogFont(&lfDefaultFont);
  131. strcpy(lfDefaultFont.lfFaceName, _T("Arial"));
  132. // Get the clients rectangle
  133. GetClientRect(rcClient);
  134. // Setup the window style
  135. dwStyle = WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
  136. // Setup the tree options 
  137. // OT_OPTIONS_SHOWINFOWINDOW
  138. dwOptions = OT_OPTIONS_SHADEEXPANDCOLUMN | OT_OPTIONS_SHADEROOTITEMS | OT_OPTIONS_SHOWINFOWINDOW;
  139. int  trBot=rcClient.bottom;
  140. if (GetDlgItem(IDOK))
  141. {
  142. CRect rrrr;
  143. GetDlgItem(IDOK)->GetWindowRect(rrrr);
  144. ScreenToClient(rrrr);
  145. trBot = rrrr.top -4;
  146. }
  147. // Create tree options
  148. CRect trR = rcClient;
  149. trR.bottom = trBot;
  150. if (m_otTree.Create(dwStyle, trR, this, dwOptions, 1004) == FALSE)
  151. {
  152. TRACE0("Failed to create options control.rn");
  153. return FALSE;
  154. }
  155. // Want to be notified
  156. m_otTree.SetNotify(TRUE, this);
  157. // -- Edit Items
  158. CString resStr;
  159. otiRoot = m_otTree.InsertItem(new COptionTreeItem());
  160. resStr.LoadString(IDS_REP_COMMON_PROPS);
  161. otiRoot->SetLabelText(resStr);
  162. resStr.LoadString(IDS_REP_FULL_COMMON_PROPS);
  163. otiRoot->SetInfoText(resStr);
  164. m_otiColorCombo = (COptionTreeItemColorComboBox*)m_otTree.InsertItem(new COptionTreeItemColorComboBox(), otiRoot);
  165. resStr.LoadString(IDS_OB_PR_DL_COLOR);
  166. m_otiColorCombo->SetLabelText(resStr);
  167. resStr.LoadString(IDS_REP_LINE_FULL_COL);
  168. m_otiColorCombo->SetInfoText(resStr);
  169. if (m_otiColorCombo->CreateComboItem(NULL) == TRUE)
  170. {
  171. m_otiColorCombo->SetCurColor(m_color);
  172. }
  173. m_otiThicknessCombo = (COptionTreeItemLineThikComboBox*)m_otTree.InsertItem(new COptionTreeItemLineThikComboBox(), otiRoot);
  174. resStr.LoadString(IDS_OB_PR_DL_LIN_TH);
  175. m_otiThicknessCombo->SetLabelText(resStr);
  176. resStr.LoadString(IDS_REP_LINE_FULL_TH);
  177. m_otiThicknessCombo->SetInfoText(resStr);
  178. if (m_otiThicknessCombo->CreateComboItem(NULL) == TRUE)
  179. {
  180. m_otiThicknessCombo->SetLineThickness(m_thickness);
  181. }
  182. otiRoot->Expand();
  183. return TRUE;
  184. }
  185. void CReportLineProperties::SetValues()
  186. /* ============================================================
  187. Function : CReportLineProperties::SetValues
  188. Description : Sets the values of the property dialog
  189. Access : Public
  190. Return : void
  191. Parameters : none
  192. Usage : Call to set the property dialog values.
  193.    ============================================================*/
  194. {
  195. CReportEntityLine* obj = static_cast< CReportEntityLine* >( GetEntity() );
  196. m_color = obj->GetBorderColor();
  197. m_thickness = obj->GetBorderThickness();
  198. if (m_otiColorCombo)
  199. m_otiColorCombo->SetCurColor(m_color);
  200. if (m_otiThicknessCombo)
  201. m_otiThicknessCombo->SetLineThickness(m_thickness);
  202. }