Mode.cpp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. // Mode.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "eastdraw.h"
  5. #include "Mode.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CMode property page
  13. IMPLEMENT_DYNCREATE(CMode, CPropertyPage)
  14. CMode::CMode() : CPropertyPage(CMode::IDD)
  15. {
  16. //{{AFX_DATA_INIT(CMode)
  17. m_Edit_Detail = _T("");
  18. m_bMode = FALSE;
  19. //}}AFX_DATA_INIT
  20. m_DrawingMode=R2_BLACK;
  21. //m_StringtoIntmap=new CMap<CString,CString&,int,int&>(1000);
  22. m_StringtoString=new CMapStringToString(1000);
  23. m_BKMode=OPAQUE;
  24. m_bMode=false;
  25. }
  26. CMode::~CMode()
  27. {
  28. }
  29. void CMode::DoDataExchange(CDataExchange* pDX)
  30. {
  31. CPropertyPage::DoDataExchange(pDX);
  32. //{{AFX_DATA_MAP(CMode)
  33. DDX_Control(pDX, IDC_CHECK_ModeCheck, m_Check_mode);
  34. DDX_Control(pDX, IDC_COMBO_BackgroundMode, m_Combo_BackgroundMode);
  35. DDX_Control(pDX, IDC_TREE_DrawingMode, m_Tree_DrawingMode);
  36. DDX_Text(pDX, IDC_EDIT_Detail, m_Edit_Detail);
  37. DDX_Check(pDX, IDC_CHECK_ModeCheck, m_bMode);
  38. //}}AFX_DATA_MAP
  39. }
  40. BEGIN_MESSAGE_MAP(CMode, CPropertyPage)
  41. //{{AFX_MSG_MAP(CMode)
  42. ON_NOTIFY(TVN_SELCHANGED, IDC_TREE_DrawingMode, OnSelchangedTREEDrawingMode)
  43. ON_CBN_SELCHANGE(IDC_COMBO_BackgroundMode, OnSelchangeCOMBOBackgroundMode)
  44. ON_WM_CTLCOLOR()
  45. ON_BN_CLICKED(IDC_CHECK_ModeCheck, OnCHECKModeCheck)
  46. //}}AFX_MSG_MAP
  47. END_MESSAGE_MAP()
  48. /////////////////////////////////////////////////////////////////////////////
  49. // CMode message handlers
  50. BOOL CMode::OnInitDialog()
  51. {
  52. CPropertyPage::OnInitDialog();
  53. // TODO: Add extra initialization here
  54. CString str[16]=
  55. {
  56. "R2_BLACK","R2_WHITE","R2_NOP","R2_NOT",
  57. "R2_COPYPEN", "R2_NOTCOPYPEN","R2_MERGEPENNOT", "R2_MASKPENNOT",
  58. "R2_MERGENOTPEN" ,"R2_MASKNOTPEN" ,"R2_MERGEPEN", "R2_NOTMERGEPEN",
  59. "R2_MASKPEN","R2_NOTMASKPEN","R2_XORPEN","R2_NOTXORPEN"
  60. };
  61. int mode[16]=
  62. {
  63. R2_BLACK,R2_WHITE,R2_NOP,R2_NOT,
  64. R2_COPYPEN, R2_NOTCOPYPEN,R2_MERGEPENNOT, R2_MASKPENNOT,
  65. R2_MERGENOTPEN ,R2_MASKNOTPEN ,R2_MERGEPEN, R2_NOTMERGEPEN,
  66. R2_MASKPEN,R2_NOTMASKPEN,R2_XORPEN, R2_NOTXORPEN
  67. };
  68. CString strInfo[16]=
  69. {
  70. "Pixel is always black.",
  71. "Pixel is always white.",
  72. "Pixel remains unchanged.",
  73. "Pixel is the inverse of the screen color.",
  74. "Pixel is the pen color.",
  75. "Pixel is the inverse of the pen color.",
  76. "Pixel is a combination of the pen color and the inverse of the screen color (final pixel = (NOT screen pixel) OR pen).",
  77. "Pixel is a combination of the colors common to both the pen and the inverse of the screen (final pixel = (NOT screen pixel) AND pen).",
  78. "Pixel is a combination of the screen color and the inverse of the pen color (final pixel = (NOT pen) OR screen pixel).",
  79. "Pixel is a combination of the colors common to both the screen and the inverse of the pen (final pixel = (NOT pen) AND screen pixel).",
  80. "Pixel is a combination of the pen color and the screen color (final pixel = pen OR screen pixel).",
  81. "Pixel is the inverse of the R2_MERGEPEN color (final pixel = NOT(pen OR screen pixel)).",
  82. "Pixel is a combination of the colors common to both the pen and the screen (final pixel = pen AND screen pixel).",
  83. "Pixel is the inverse of the R2_MASKPEN color (final pixel = NOT(pen AND screen pixel)).",
  84. "Pixel is a combination of the colors that are in the pen or in the screen, but not in both (final pixel = pen XOR screen pixel).",
  85. "Pixel is the inverse of the R2_XORPEN color (final pixel = NOT(pen XOR screen pixel)). "
  86. };
  87. for(int i=0;i<16;i++)
  88. {
  89. //(*m_StringtoIntmap)[_T(str[i])]=mode[i];
  90. //(*m_StringtoString)[_T(str[i])]=_T(strInfo[i]);
  91. }
  92. HTREEITEM hItem;
  93. hItem=m_Tree_DrawingMode.InsertItem("DrawingMode");
  94. HTREEITEM hItemSon=m_Tree_DrawingMode.InsertItem(str[0]);
  95. for(i=1;i<16;i++)
  96. {
  97. m_Tree_DrawingMode.InsertItem(_T(str[i]));
  98. }
  99. m_Tree_DrawingMode.Expand(hItem,TVE_EXPAND);
  100. m_Tree_DrawingMode.Select(hItemSon,TVGN_CARET);
  101. m_Combo_BackgroundMode.SetCurSel(0);
  102. m_BKMode=OPAQUE;
  103. m_Edit_Detail="Pixel is always black.";
  104. this->UpdateData(false);
  105. return TRUE; // return TRUE unless you set the focus to a control
  106. // EXCEPTION: OCX Property Pages should return FALSE
  107. }
  108. void CMode::OnSelchangedTREEDrawingMode(NMHDR* pNMHDR, LRESULT* pResult)
  109. {
  110. NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
  111. // TODO: Add your control notification handler code here
  112. HTREEITEM hItem=m_Tree_DrawingMode.GetSelectedItem();
  113. CString str_Item=m_Tree_DrawingMode.GetItemText(hItem);
  114. // m_StringtoIntmap->Lookup(_T(str_Item),m_DrawingMode);
  115. //m_StringtoString->Lookup(_T(str_Item),m_Edit_Detail);
  116. this->UpdateData(false);
  117. *pResult = 0;
  118. }
  119. void CMode::OnSelchangeCOMBOBackgroundMode()
  120. {
  121. m_BKMode=m_Combo_BackgroundMode.GetCurSel()==0?OPAQUE:TRANSPARENT;
  122. // TODO: Add your control notification handler code here
  123. }
  124. HBRUSH CMode::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
  125. {
  126. HBRUSH hbr = CPropertyPage::OnCtlColor(pDC, pWnd, nCtlColor);
  127. // TODO: Change any attributes of the DC here
  128. // TODO: Return a different brush if the default is not desired
  129. pDC->SetTextColor(RGB(0,100,255));
  130. pDC->SetBkColor(RGB(100,200,200));
  131. pDC->SelectObject(&brush);
  132. pDC->SetBkMode(TRANSPARENT);
  133. return hbr;
  134. }
  135. void CMode::OnCHECKModeCheck()
  136. {
  137. // TODO: Add your control notification handler code here
  138. m_bMode=!m_bMode;
  139. m_Check_mode.SetCheck(m_bMode?1:0);
  140. }