PropDlg.cpp
上传用户:wujian85
上传日期:2010-04-08
资源大小:227k
文件大小:8k
源码类别:

对话框与窗口

开发平台:

Visual C++

  1. // PropDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "printformeditor.h"
  5. #include "PropDlg.h"
  6. #include "Doc.h"
  7. #include "View.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CPropDlg dialog
  15. void SelectById(CComboBox * pBox, long lId)
  16. {
  17. for (int t = 0; t < pBox->GetCount(); t++)
  18. {
  19. long l = pBox->GetItemData(t);
  20. if (lId != 0 && lId&l) 
  21. {
  22. pBox->SetCurSel(t);
  23. return;
  24. }
  25. }
  26. }
  27. CPropDlg::CPropDlg(CWnd* pParent /*=NULL*/)
  28. : CDialog(CPropDlg::IDD, pParent)
  29. {
  30. //{{AFX_DATA_INIT(CPropDlg)
  31. // NOTE: the ClassWizard will add member initialization here
  32. //}}AFX_DATA_INIT
  33. pView = NULL;
  34. pDoc  = NULL;
  35. }
  36. void CPropDlg::DoDataExchange(CDataExchange* pDX)
  37. {
  38. CDialog::DoDataExchange(pDX);
  39. //{{AFX_DATA_MAP(CPropDlg)
  40. DDX_Control(pDX, IDC_TAB1, wndTab);
  41. //}}AFX_DATA_MAP
  42. }
  43. BEGIN_MESSAGE_MAP(CPropDlg, CDialog)
  44. //{{AFX_MSG_MAP(CPropDlg)
  45. ON_NOTIFY(TCN_SELCHANGE, IDC_TAB1, OnSelchangeTab1)
  46. ON_BN_CLICKED(IDC_BT_APPLY, OnBtApply)
  47. //}}AFX_MSG_MAP
  48. END_MESSAGE_MAP()
  49. /////////////////////////////////////////////////////////////////////////////
  50. // CPropDlg message handlers
  51. BOOL CPropDlg::OnInitDialog() 
  52. {
  53. CDialog::OnInitDialog();
  54. CRect drc;
  55. wndTab.GetClientRect(drc);
  56. dlgSheet1.Create(CPropPage1::IDD, &wndTab);
  57. dlgSheet1.SetWindowPos(0,4,27,drc.Width() - 8,drc.Height()-30,SWP_NOZORDER);
  58. dlgSheet2.Create(CPropPage2::IDD, &wndTab);
  59. dlgSheet2.SetWindowPos(0,4,27,drc.Width() - 8,drc.Height()-30,SWP_NOZORDER);
  60. dlgSheet3.Create(CPropPage3::IDD, &wndTab);
  61. dlgSheet3.SetWindowPos(0,4,27,drc.Width() - 8,drc.Height()-30,SWP_NOZORDER);
  62. GfxAddTabItem(wndTab, 0, "General");
  63. GfxAddTabItem(wndTab, 1, "Id's");
  64. GfxAddTabItem(wndTab, 2, "Other");
  65. dlgSheet1.ShowWindow(SW_SHOW);
  66. GfxSetTabDialog(0, &dlgSheet1);
  67. GfxSetTabDialog(1, &dlgSheet2);
  68. GfxSetTabDialog(2, &dlgSheet3);
  69. return TRUE;  // return TRUE unless you set the focus to a control
  70.               // EXCEPTION: OCX Property Pages should return FALSE
  71. }
  72. void CPropDlg::OnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult) 
  73. {
  74. int idx = wndTab.GetCurSel();
  75. GfxSwitchTabDialog(idx, iNumDialog);
  76. *pResult = 0;
  77. }
  78. void CPropDlg::OnBtApply() 
  79. {
  80. if (pView && pDoc && pDoc->GetSelectedCount() > 0)
  81. {
  82. bool bMulti = pDoc->GetSelectedCount() > 1;
  83. CString cs;
  84. for (int t = 0; t < pDoc->iFormObj; t++)
  85. {
  86. if (pDoc->ppObjs[t]->bSelected)
  87. {
  88. if (!bMulti)
  89. {
  90. dlgSheet1.wndEditX.GetWindowText(cs);
  91. pDoc->ppObjs[t]->rc.left = atoi(cs);
  92. dlgSheet1.wndEditWidth.GetWindowText(cs);
  93. pDoc->ppObjs[t]->rc.right = pDoc->ppObjs[t]->rc.left + atoi(cs);
  94. dlgSheet1.wndEditY.GetWindowText(cs);
  95. pDoc->ppObjs[t]->rc.top = atoi(cs);
  96. dlgSheet1.wndEditHeight.GetWindowText(cs);
  97. pDoc->ppObjs[t]->rc.bottom = pDoc->ppObjs[t]->rc.top + atoi(cs);
  98. }
  99. dlgSheet1.UpdateData();
  100. dlgSheet2.UpdateData();
  101. dlgSheet3.UpdateData();
  102. pDoc->ppObjs[t]->bBold = dlgSheet1.bBold ? true : false;
  103. pDoc->ppObjs[t]->bItalic = dlgSheet1.bItalic ? true : false;
  104. pDoc->ppObjs[t]->bUnderline = dlgSheet1.bUnderline ? true : false;
  105. lstrcpy(pDoc->ppObjs[t]->cId, dlgSheet2.csId);
  106. lstrcpy(pDoc->ppObjs[t]->cId2, dlgSheet2.csId2);
  107. lstrcpy(pDoc->ppObjs[t]->cCond, dlgSheet2.csCond);
  108. lstrcpy(pDoc->ppObjs[t]->cFont, dlgSheet1.csFontName);
  109. pDoc->ppObjs[t]->iSize = atoi(dlgSheet1.csFontSize);
  110. pDoc->ppObjs[t]->uiTextFormat &= ~(DT_RIGHT|DT_CENTER|DT_VCENTER|DT_BOTTOM|DT_SINGLELINE);
  111. int idx = dlgSheet2.wndCbVAlign.GetCurSel();
  112. long l = dlgSheet2.wndCbVAlign.GetItemData(idx);
  113. pDoc->ppObjs[t]->uiTextFormat |= l;
  114. if (l == DT_VCENTER) pDoc->ppObjs[t]->uiTextFormat |= DT_SINGLELINE;
  115. idx = dlgSheet2.wndCbHAlign.GetCurSel();
  116. l = dlgSheet2.wndCbHAlign.GetItemData(idx);
  117. pDoc->ppObjs[t]->uiTextFormat |= l;
  118. pDoc->ppObjs[t]->crBack = dlgSheet3.crBack;
  119. pDoc->ppObjs[t]->crFront = dlgSheet3.crText;
  120. pDoc->ppObjs[t]->crBdr = dlgSheet3.crBdr;
  121. idx = dlgSheet3.wndBckType.GetCurSel();
  122. pDoc->ppObjs[t]->iBack = (idx == 0 ? -1 : 0);
  123. idx = dlgSheet3.wndBorderSize.GetCurSel();
  124. if (idx < 1) idx = 1;
  125. pDoc->ppObjs[t]->iBorderSize = idx;
  126. }
  127. }
  128. pView->Invalidate();
  129. }
  130. }
  131. void CPropDlg::SetObject(Doc * pd, View * pv)
  132. {
  133. pDoc  = pd;
  134. pView = pv;
  135. if (pDoc && pDoc->GetSelectedCount() > 0)
  136. {
  137. bool bMulti = pDoc->GetSelectedCount() > 1;
  138. if (bMulti)
  139. {
  140. dlgSheet1.wndEditX.EnableWindow(false);
  141. dlgSheet1.wndEditHeight.EnableWindow(false);
  142. dlgSheet1.wndEditY.EnableWindow(false);
  143. dlgSheet1.wndEditWidth.EnableWindow(false);
  144. dlgSheet1.wndEditX.SetWindowText("");
  145. dlgSheet1.wndEditHeight.SetWindowText("");
  146. dlgSheet1.wndEditY.SetWindowText("");
  147. dlgSheet1.wndEditWidth.SetWindowText("");
  148. }
  149. else
  150. {
  151. dlgSheet1.wndEditX.EnableWindow(true);
  152. dlgSheet1.wndEditHeight.EnableWindow(true);
  153. dlgSheet1.wndEditY.EnableWindow(true);
  154. dlgSheet1.wndEditWidth.EnableWindow(true);
  155. }
  156. CString cs;
  157. for (int t = 0; t < pDoc->iFormObj; t++)
  158. {
  159. if (pDoc->ppObjs[t]->bSelected)
  160. {
  161. if (!bMulti)
  162. {
  163. cs.Format("%d", pDoc->ppObjs[t]->rc.left);
  164. dlgSheet1.wndEditX.SetWindowText(cs);
  165. cs.Format("%d", pDoc->ppObjs[t]->rc.Height());
  166. dlgSheet1.wndEditHeight.SetWindowText(cs);
  167. cs.Format("%d", pDoc->ppObjs[t]->rc.top);
  168. dlgSheet1.wndEditY.SetWindowText(cs);
  169. cs.Format("%d", pDoc->ppObjs[t]->rc.Width());
  170. dlgSheet1.wndEditWidth.SetWindowText(cs);
  171. }
  172. dlgSheet1.bBold = pDoc->ppObjs[t]->bBold;
  173. dlgSheet1.bItalic = pDoc->ppObjs[t]->bItalic;
  174. dlgSheet1.bUnderline = pDoc->ppObjs[t]->bUnderline;
  175. dlgSheet1.csFontName = pDoc->ppObjs[t]->cFont;
  176. dlgSheet1.csFontSize.Format("%d", pDoc->ppObjs[t]->iSize);
  177. // SelectById(&(dlgSheet2.wndCbHAlign), pDoc->ppObjs[t]->uiTextFormat);
  178. // SelectById(&(dlgSheet2.wndCbVAlign), pDoc->ppObjs[t]->uiTextFormat);
  179. if (pDoc->ppObjs[t]->uiTextFormat&DT_CENTER) dlgSheet2.wndCbHAlign.SetCurSel(1);
  180. else if (pDoc->ppObjs[t]->uiTextFormat&DT_RIGHT) dlgSheet2.wndCbHAlign.SetCurSel(2);
  181. else dlgSheet2.wndCbHAlign.SetCurSel(0);
  182. if (pDoc->ppObjs[t]->uiTextFormat&DT_VCENTER) dlgSheet2.wndCbVAlign.SetCurSel(1);
  183. else if (pDoc->ppObjs[t]->uiTextFormat&DT_BOTTOM) dlgSheet2.wndCbVAlign.SetCurSel(2);
  184. else dlgSheet2.wndCbVAlign.SetCurSel(0);
  185. dlgSheet2.csId = pDoc->ppObjs[t]->cId;
  186. dlgSheet2.csId2 = pDoc->ppObjs[t]->cId2;
  187. dlgSheet2.csCond = pDoc->ppObjs[t]->cCond;
  188. dlgSheet3.crBack = pDoc->ppObjs[t]->crBack;
  189. dlgSheet3.crText = pDoc->ppObjs[t]->crFront;
  190. dlgSheet3.crBdr  = pDoc->ppObjs[t]->crBdr;
  191. if (pDoc->ppObjs[t]->iBack == 0) dlgSheet3.wndBckType.SetCurSel(1);
  192. else dlgSheet3.wndBckType.SetCurSel(0);
  193. if (pDoc->ppObjs[t]->iBorder == 1) dlgSheet3.wndBorder.SetCurSel(1);
  194. else if (pDoc->ppObjs[t]->iBorder == 2) dlgSheet3.wndBorder.SetCurSel(2);
  195. else dlgSheet3.wndBorder.SetCurSel(0);
  196. dlgSheet3.wndBorderSize.SetCurSel(pDoc->ppObjs[t]->iBorderSize);
  197. //enum { pfoStatic = 0, pfoEdit, pfoLine, pfoRect, pfoFrame, pfoImage, pfoRadio, pfoCheck, pfoVLine, pfoHLine, pfoSubForm };
  198. // if (iType == pfoLine || iType == pfoLine || iType == pfoLine || iType == pfoLine)
  199. {
  200. dlgSheet3.wndLineType.EnableWindow(true);
  201. if (pDoc->ppObjs[t]->exInfo == 1) dlgSheet3.wndLineType.SetCurSel(1);
  202. else dlgSheet3.wndLineType.SetCurSel(0);
  203. }
  204. /* if (iType == pfoLine || iType == pfoRect || iType == pfoHLine || iType == pfoVLine)
  205. {
  206. dlgSheet3.iLineWidth = pDoc->ppObjs[t]->exInfo;
  207. }
  208. else dlgSheet3.wndLineType.EnableWindow(false);*/
  209. }
  210. }
  211. dlgSheet1.UpdateData(false);
  212. dlgSheet2.UpdateData(false);
  213. dlgSheet3.UpdateData(false);
  214. }
  215. }