DLineDlg1.cpp 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. // DLineDlg1.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "EastDraw.h"
  5. #include "DLineDlg1.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CDLineDlg1 property page
  13. IMPLEMENT_DYNCREATE(CDLineDlg1, CPropertyPage)
  14. CDLineDlg1::CDLineDlg1() : CPropertyPage(CDLineDlg1::IDD)
  15. {
  16. //{{AFX_DATA_INIT(CDLineDlg1)
  17. m_Edit_LineWidth = 1;
  18. m_radio_BrushHatch = 0;
  19. m_radio_BrushStyle = 0;
  20. //}}AFX_DATA_INIT
  21. m_PenStyle=PS_SOLID;
  22. m_BrushStyle=BS_HOLLOW;
  23. m_BKMode=OPAQUE;
  24. }
  25. CDLineDlg1::~CDLineDlg1()
  26. {
  27. }
  28. void CDLineDlg1::DoDataExchange(CDataExchange* pDX)
  29. {
  30. CPropertyPage::DoDataExchange(pDX);
  31. //{{AFX_DATA_MAP(CDLineDlg1)
  32. DDX_Control(pDX, IDC_COMBO_BackgroundMode, m_Combo_BackgroundMode);
  33. DDX_Control(pDX, IDC_RADIO6_bs_hollow, m_radio_bs_Hollow);
  34. DDX_Control(pDX, IDC_RADIO_Ps_Solid, m_radio_ps_Solid);
  35. DDX_Control(pDX, IDC_RADIO_HS_VERTICAL, m_radio_vertical);
  36. DDX_Control(pDX, IDC_RADIO14_HS_HORIZONTAL, m_radio_horizontal);
  37. DDX_Control(pDX, IDC_RADIO13_HS_FDIAGONAL, m_radio_fdiagonal);
  38. DDX_Control(pDX, IDC_RADIO11_HS_DIAGCROSS, m_radio_diagcross);
  39. DDX_Control(pDX, IDC_RADIO9_HS_BDIAGONAL, m_radio_bdiagonal);
  40. DDX_Control(pDX, IDC_RADIO10_HS_CROSS, m_radio_corss);
  41. DDX_Control(pDX, IDC_STATIC_ShowBrushResult, m_Static_ShowBrushResult);
  42. DDX_Control(pDX, IDC_STATIC_ShowPenStyle, m_Static_ShowPenStyle);
  43. DDX_Control(pDX, IDC_SPIN_DDLineWidth, m_Spin_DLine_Width);
  44. DDX_Text(pDX, IDC_EDIT_LineWidth, m_Edit_LineWidth);
  45. DDV_MinMaxUInt(pDX, m_Edit_LineWidth, 1, 10000);
  46. DDX_Radio(pDX, IDC_RADIO9_HS_BDIAGONAL, m_radio_BrushHatch);
  47. DDX_Radio(pDX, IDC_RADIO6_bs_hollow, m_radio_BrushStyle);
  48. //}}AFX_DATA_MAP
  49. m_Combo_BackgroundMode.SetCurSel(m_BKMode==OPAQUE?0:1);
  50. }
  51. BEGIN_MESSAGE_MAP(CDLineDlg1, CPropertyPage)
  52. //{{AFX_MSG_MAP(CDLineDlg1)
  53. ON_BN_CLICKED(IDC_RADIO_Ps_Solid, OnRADIOPsSolid)
  54. ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
  55. ON_BN_CLICKED(IDC_RADIO3, OnRadio3)
  56. ON_BN_CLICKED(IDC_RADIO4, OnRadio4)
  57. ON_BN_CLICKED(IDC_RADIO5, OnRadio5)
  58. ON_BN_CLICKED(IDC_RADIO15, OnRadio15)
  59. ON_BN_CLICKED(IDC_RADIO16, OnRadio16)
  60. ON_WM_PAINT()
  61. ON_BN_CLICKED(IDC_RADIO6_bs_hollow, OnRADIO6bshollow)
  62. ON_BN_CLICKED(IDC_RADIO7_bs_solid, OnRADIO7bssolid)
  63. ON_BN_CLICKED(IDC_RADIO8_hatched, OnRADIO8hatched)
  64. ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_DDLineWidth, OnDeltaposSPINDDLineWidth)
  65. ON_EN_CHANGE(IDC_EDIT_LineWidth, OnChangeEDITLineWidth)
  66. ON_BN_CLICKED(IDC_RADIO9_HS_BDIAGONAL, OnRadioHs)
  67. ON_WM_CTLCOLOR()
  68. ON_BN_CLICKED(IDC_RADIO11_HS_DIAGCROSS, OnRadioHs)
  69. ON_BN_CLICKED(IDC_RADIO13_HS_FDIAGONAL, OnRadioHs)
  70. ON_BN_CLICKED(IDC_RADIO10_HS_CROSS, OnRadioHs)
  71. ON_BN_CLICKED(IDC_RADIO14_HS_HORIZONTAL, OnRadioHs)
  72. ON_BN_CLICKED(IDC_RADIO_HS_VERTICAL, OnRadioHs)
  73. ON_CBN_SELCHANGE(IDC_COMBO_BackgroundMode, OnSelchangeCOMBOBackgroundMode)
  74. //}}AFX_MSG_MAP
  75. END_MESSAGE_MAP()
  76. /////////////////////////////////////////////////////////////////////////////
  77. // CDLineDlg1 message handlers
  78. #include "DLineProperty.h"
  79. BOOL CDLineDlg1::OnInitDialog()
  80. {
  81. CPropertyPage::OnInitDialog();
  82. // TODO: Add extra initialization here
  83. m_Spin_DLine_Width.SetBase(1);
  84. m_Spin_DLine_Width.SetPos(1);
  85. m_Spin_DLine_Width.SetRange(1,1000);
  86. m_radio_bdiagonal.SetCheck(2);
  87. m_radio_ps_Solid.SetCheck(2);
  88. m_radio_bs_Hollow.SetCheck(2);
  89. m_BrushHatch=HS_BDIAGONAL;
  90. m_Combo_BackgroundMode.SetCurSel(0);
  91. return TRUE; // return TRUE unless you set the focus to a control
  92. // EXCEPTION: OCX Property Pages should return FALSE
  93. }
  94. void CDLineDlg1::OnRADIOPsSolid()
  95. {
  96. // TODO: Add your control notification handler code here
  97. m_PenStyle=PS_SOLID;
  98. OnChangePenStyle();
  99. }
  100. void CDLineDlg1::OnRadio2()
  101. {
  102. // TODO: Add your control notification handler code here
  103. m_PenStyle=PS_DASH;
  104. OnChangePenStyle();
  105. }
  106. void CDLineDlg1::OnRadio3()
  107. {
  108. // TODO: Add your control notification handler code here
  109. m_PenStyle=PS_DOT;
  110. OnChangePenStyle();
  111. }
  112. void CDLineDlg1::OnRadio4()
  113. {
  114. // TODO: Add your control notification handler code here
  115. m_PenStyle=PS_DASHDOT;
  116. OnChangePenStyle();
  117. }
  118. void CDLineDlg1::OnRadio5()
  119. {
  120. // TODO: Add your control notification handler code here
  121. m_PenStyle=PS_DASHDOTDOT;
  122. OnChangePenStyle();
  123. }
  124. void CDLineDlg1::OnRadio15()
  125. {
  126. // TODO: Add your control notification handler code here
  127. m_PenStyle=PS_NULL;
  128. OnChangePenStyle();
  129. }
  130. void CDLineDlg1::OnRadio16()
  131. {
  132. // TODO: Add your control notification handler code here
  133. m_PenStyle=PS_INSIDEFRAME;
  134. OnChangePenStyle();
  135. }
  136. void CDLineDlg1::OnPaint()
  137. {
  138. CPaintDC dc(this); // device context for painting
  139. // TODO: Add your message handler code here
  140. OnChangePenStyle();
  141. OnChangeBrushStyle(m_BrushStyle==BS_HATCHED);
  142. // Do not call CPropertyPage::OnPaint() for painting messages
  143. }
  144. void CDLineDlg1::OnChangePenStyle()
  145. {
  146. UpdateData();
  147. CDC * pDC;
  148. CRect rect;
  149. CPen pen;
  150. CBrush brush;
  151. CDLineProperty*parent=(CDLineProperty*)this->GetParent();
  152. this->m_PenColor=parent->m_DLineDlg2->m_PenColor;
  153. brush.CreateSolidBrush(RGB(255,255,255));
  154. pDC=m_Static_ShowPenStyle.GetDC();
  155. pen.CreatePen(m_PenStyle,m_Edit_LineWidth>10?10:m_Edit_LineWidth,m_PenColor);
  156. CPen*oldpen=pDC->SelectObject(&pen);
  157. m_Static_ShowPenStyle.GetClientRect(&rect);
  158. pDC->FillRect(&rect,&brush);
  159. brush.DeleteObject();
  160. LOGBRUSH brushlog;
  161. brushlog.lbColor=m_BrushColor;
  162. brushlog.lbHatch=m_BrushHatch;
  163. brushlog.lbStyle=m_BrushStyle;
  164. brush.CreateBrushIndirect(&brushlog);
  165. CBrush*OldBrush=pDC->SelectObject(&brush);
  166. int oldBKMode=pDC->SetBkMode(m_BKMode);
  167. int oldBkColor=pDC->SetBkColor(parent->m_DLineDlg2->m_BackgroundColor);
  168. pDC->MoveTo(rect.left+5,rect.Height()/2);
  169. pDC->LineTo(rect.right-5,rect.Height()/2);
  170. pDC->SelectObject(oldpen);
  171. pDC->SetBkMode(oldBKMode);
  172. pDC->SelectObject(OldBrush);
  173. m_Static_ShowPenStyle.ReleaseDC(pDC);
  174. }
  175. void CDLineDlg1::OnChangeBrushStyle(BOOL isHatched)
  176. {
  177. m_radio_vertical.EnableWindow(isHatched);
  178. m_radio_horizontal.EnableWindow(isHatched);
  179. m_radio_fdiagonal.EnableWindow(isHatched);
  180. m_radio_diagcross.EnableWindow(isHatched);
  181. m_radio_bdiagonal.EnableWindow(isHatched);
  182. m_radio_corss.EnableWindow(isHatched);
  183. UpdateData();
  184. CDC * pDC;
  185. CRect rect;
  186. CBrush brush;
  187. pDC=m_Static_ShowBrushResult.GetDC();
  188. m_Static_ShowBrushResult.GetClientRect(&rect);
  189. CDLineProperty*parent=(CDLineProperty*)this->GetParent();
  190. this->m_BrushColor=parent->m_DLineDlg2->m_BrushColor;
  191. brush.CreateSolidBrush(RGB(255,255,255));
  192. pDC->FillRect(&rect,&brush);
  193. brush.DeleteObject();
  194. LOGBRUSH brushlog;
  195. brushlog.lbColor=m_BrushColor;
  196. brushlog.lbHatch=m_BrushHatch;
  197. brushlog.lbStyle=m_BrushStyle;
  198. brush.CreateBrushIndirect(&brushlog);
  199. int oldBKMode=pDC->SetBkMode(m_BKMode);
  200. COLORREF oldBkColor=pDC->SetBkColor(parent->m_DLineDlg2->m_BackgroundColor);
  201. pDC->SelectObject(&brush);
  202. pDC->Rectangle(rect);
  203. m_Static_ShowBrushResult.ReleaseDC(pDC);
  204. }
  205. void CDLineDlg1::OnRADIO6bshollow()
  206. {
  207. // TODO: Add your control notification handler code here
  208. m_BrushStyle=BS_HOLLOW;
  209. OnChangeBrushStyle(false);
  210. }
  211. void CDLineDlg1::OnRADIO7bssolid()
  212. {
  213. // TODO: Add your control notification handler code here
  214. m_BrushStyle=BS_SOLID;
  215. OnChangeBrushStyle(false);
  216. }
  217. void CDLineDlg1::OnRADIO8hatched()
  218. {
  219. // TODO: Add your control notification handler code here
  220. //m_radio_BDIAGONAL.EnableTypeLib();
  221. m_BrushStyle=BS_HATCHED;
  222. OnChangeBrushStyle(true);
  223. }
  224. void CDLineDlg1::OnDeltaposSPINDDLineWidth(NMHDR* pNMHDR, LRESULT* pResult)
  225. {
  226. NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
  227. // TODO: Add your control notification handler code here
  228. OnChangePenStyle();
  229. *pResult = 0;
  230. }
  231. void CDLineDlg1::OnChangeEDITLineWidth()
  232. {
  233. // TODO: If this is a RICHEDIT control, the control will not
  234. // send this notification unless you override the CPropertyPage::OnInitDialog()
  235. // function and call CRichEditCtrl().SetEventMask()
  236. // with the ENM_CHANGE flag ORed into the mask.
  237. // TODO: Add your control notification handler code here
  238. if(this->IsWindowVisible())
  239. {
  240. UpdateData();
  241. OnChangePenStyle();
  242. }
  243. }
  244. void CDLineDlg1::OnRadioHs()
  245. {
  246. // TODO: Add your control notification handler code here
  247. UpdateData();
  248. switch(m_radio_BrushHatch)
  249. {
  250. case 0:m_BrushHatch=HS_BDIAGONAL; break;
  251. case 1:m_BrushHatch=HS_DIAGCROSS; break;
  252. case 2:m_BrushHatch=HS_FDIAGONAL; break;
  253. case 3:m_BrushHatch=HS_CROSS; break;
  254. case 4:m_BrushHatch=HS_HORIZONTAL; break;
  255. case 5:m_BrushHatch=HS_VERTICAL; break;
  256. }
  257. OnChangeBrushStyle(true);
  258. }
  259. HBRUSH CDLineDlg1::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
  260. {
  261. HBRUSH hbr = CPropertyPage::OnCtlColor(pDC, pWnd, nCtlColor);
  262. // TODO: Change any attributes of the DC here
  263. // TODO: Return a different brush if the default is not desired
  264. // brush.CreateSolidBrush(RGB(230,254,255));
  265. pDC->SetTextColor(RGB(0,100,255));
  266. pDC->SetBkColor(RGB(118,143,255));
  267. pDC->SelectObject(&brush);
  268. pDC->SetBkMode(TRANSPARENT);
  269. // hbr=(HBRUSH)brush.m_hObject;
  270. return hbr;
  271. }
  272. void CDLineDlg1::OnSelchangeCOMBOBackgroundMode()
  273. {
  274. // TODO: Add your control notification handler code here
  275. m_BKMode=m_Combo_BackgroundMode.GetCurSel()==0?OPAQUE:TRANSPARENT;
  276. this->OnChangePenStyle();
  277. this->OnChangeBrushStyle(true);
  278. }