IDEView.h 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. #pragma once
  2. //#include "IDE.h"
  3. #include "drawobj.h"
  4. #include "graph.h"
  5. #include "IDEDoc.h"
  6. #define VIEW_USE_THREAD 0
  7. //////////////////////////////////////////////////////////////////////////
  8. // 鼠标单击 = 鼠标按下 + 鼠标移动或鼠标松开;
  9. // 因为图元有一定的区域范围,所有如果是 【鼠标按下+鼠标松开】,在后面其实还有【鼠标移动】;
  10. // 所以,鼠标单击,完全可以用【鼠标按下+鼠标松开】来表示;
  11. class CIDEView : public CScrollView
  12. {
  13. protected: // create from serialization only
  14. CIDEView();
  15. DECLARE_DYNCREATE(CIDEView)
  16. // Attributes
  17. public:
  18. CIDEDoc* GetDocument();
  19. UINT m_nID;
  20. CPoint m_pointMouse;
  21. CPoint m_startPoint,m_endPoint; // 起始点;
  22. CPoint m_lastPoint; // 上一个点;
  23. BOOL m_bMove; // 能移动否;
  24. BOOL m_bMoveElements; // 是否有可移动的东西;
  25. BOOL m_mouseState; // 左键状态:TRUE=DOWN; FALSE=UP;
  26. BOOL m_bHandle; // 是否显示手势;
  27. BOOL m_bModified;
  28. CGraph* m_pGraph;
  29. CDrawObjList m_selection; // 选中的图元(可以是多个);
  30. CDrawObjList m_freezed; // 冻结的图元;
  31. CDrawObjList m_copied; // 要复制的图元;
  32. CDrawObjList m_deleted; // 要删除的图元;
  33. CDrawObj * m_tempObj; // 临时图元,生成图元的图元对象;
  34. CDrawObj * m_pCurActionObj; // 用来响应动作的当前图元;
  35. int m_nCurActionType; // 当前响应的动作类型,为了清除某些动作效果;
  36. int m_nDragHandle; // 图元句柄,标识鼠标位置;
  37. int m_nBDragHandle; // 保持;
  38. BOOL m_bDrag; // 是否拖动(点在图元中,鼠标按住 + 鼠标移动 = 拖动);
  39. BOOL m_bFreezed; // 冻结状态;
  40. BOOL m_bRectSelect; // 是否区选(区域的起点和终点都不在图元内容, 鼠标按住 + 鼠标移动 = 区选);
  41. CRect m_mouseRect;
  42. // 字体;
  43. int m_nRudoPosition; // 撤销位置;
  44. int m_nCanUndoTimes; // 可以撤销的次数;
  45. int m_nCanRedoTimes; // 可以重做的次数;
  46. bool m_bPolygon;
  47. CTime m_tblTime;
  48. #if VIEW_USE_THREAD
  49. HANDLE m_hIDEViewRunObject;
  50. HANDLE m_hFreshGraphThread;
  51. CRITICAL_SECTION m_csFreshGraph;
  52. HANDLE m_hFreshGraphObject;
  53. static DWORD WINAPI CIDEView::FreshGraphThread( void *pData );
  54. #endif
  55. // Operations
  56. public:
  57. // Overrides
  58. // ClassWizard generated virtual function overrides
  59. //{{AFX_VIRTUAL(CIDEView)
  60. public:
  61. virtual void OnDraw(CDC* pDC); // overridden to draw this view
  62. virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
  63. virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
  64. protected:
  65. virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
  66. virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
  67. virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
  68. virtual void OnPrint(CDC* pDC, CPrintInfo* pInfo);
  69. virtual void OnEndPrintPreview(CDC* pDC, CPrintInfo* pInfo, POINT point, CPreviewView* pView);
  70. //}}AFX_VIRTUAL
  71. // Implementation
  72. public:
  73. void SetHisTime(CTime time);
  74. void ChangeView();
  75. CDrawObj * CreateDrawObjbyNo(int objNo);
  76. virtual ~CIDEView();
  77. #ifdef _DEBUG
  78. virtual void AssertValid() const;
  79. virtual void Dump(CDumpContext& dc) const;
  80. #endif
  81. void KeyMove(int x1,int y1,int x2,int y2);
  82. BOOL IsSelected(CDrawObj* pDrawObj);
  83. void Select(CDrawObj* pObj, BOOL bAdd);
  84. void Remove(CDrawObj* pObj);
  85. CDrawObj* ObjectAt(CPoint point);
  86. void RefreshScrollSizes(void);
  87. CRect GetAlignRect(void);
  88. void ObjectIn(); //区域选
  89. void ExchangeSave(); //有改动记录
  90. void FileProcess(); //undo redo后,处理临时文件的改名
  91. protected:
  92. private:
  93. CString RegSearch(HKEY hKey, TCHAR rootKey[], CString path,CString sContent);
  94. void ShowOCX( CRect rect,CString sOcxPath,int iIndex,CString sPageName );
  95. CWnd m_OcxWnd;
  96. bool m_bOcxCreate;
  97. CString GetClsidbyName( CString sName );
  98. public:
  99. bool m_bIsHaveOCX;
  100. // Generated message map functions
  101. protected:
  102. //{{AFX_MSG(CIDEView)
  103. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  104. afx_msg void OnDestroy();
  105. afx_msg void OnEditUnfreeze();
  106. afx_msg void OnEditPaste();
  107. afx_msg void OnEditMovetofront();
  108. afx_msg void OnEditMovetoback();
  109. afx_msg void OnEditHinvert();
  110. afx_msg void OnEditFreeze();
  111. afx_msg void OnEditCut();
  112. afx_msg void OnEditCopy();
  113. afx_msg void OnEditDelete();
  114. afx_msg void OnDeskGrid();
  115. afx_msg void OnAlignTop();
  116. afx_msg void OnAlignVcenter();
  117. afx_msg void OnAlignRight();
  118. afx_msg void OnAlignLeft();
  119. afx_msg void OnAlignHcenter();
  120. afx_msg void OnAlignBottom();
  121. afx_msg void OnEditVinvert();
  122. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  123. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  124. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  125. afx_msg void OnPointer();
  126. afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  127. afx_msg void OnFileNew();
  128. afx_msg void OnFileOpen();
  129. afx_msg void OnFileSave();
  130. afx_msg void OnFileSaveAs();
  131. afx_msg void OnAppExit();
  132. afx_msg void OnUpdateDeskGrid(CCmdUI* pCmdUI);
  133. afx_msg void OnUpdateEditFreeze(CCmdUI* pCmdUI);
  134. afx_msg void OnRedo();
  135. afx_msg void OnUndo();
  136. afx_msg void OnUpdateUndo(CCmdUI* pCmdUI);
  137. afx_msg void OnUpdateRedo(CCmdUI* pCmdUI);
  138. afx_msg void OnPicsize();
  139. afx_msg void OnUpdateAlignBottom(CCmdUI* pCmdUI);
  140. afx_msg void OnUpdateAlignHcenter(CCmdUI* pCmdUI);
  141. afx_msg void OnUpdateAlignLeft(CCmdUI* pCmdUI);
  142. afx_msg void OnUpdateAlignRight(CCmdUI* pCmdUI);
  143. afx_msg void OnUpdateAlignTop(CCmdUI* pCmdUI);
  144. afx_msg void OnUpdateAlignVcenter(CCmdUI* pCmdUI);
  145. afx_msg void OnUpdateEditHinvert(CCmdUI* pCmdUI);
  146. afx_msg void OnUpdateEditMovetoback(CCmdUI* pCmdUI);
  147. afx_msg void OnUpdateEditMovetofront(CCmdUI* pCmdUI);
  148. afx_msg void OnUpdateEditVinvert(CCmdUI* pCmdUI);
  149. afx_msg void OnUpdateEditCopy(CCmdUI* pCmdUI);
  150. afx_msg void OnUpdateEditCut(CCmdUI* pCmdUI);
  151. afx_msg void OnUpdateEditClear(CCmdUI* pCmdUI);
  152. afx_msg void OnUpdateEditPaste(CCmdUI* pCmdUI);
  153. afx_msg void OnDrawTline();
  154. afx_msg void OnDrawText();
  155. afx_msg void OnDrawRect();
  156. afx_msg void OnDrawData();
  157. afx_msg void OnDraw3drect();
  158. afx_msg void OnDraw3circle();
  159. afx_msg void OnUpdatePointer(CCmdUI* pCmdUI);
  160. afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
  161. afx_msg void OnTimer(UINT nIDEvent);
  162. afx_msg void OnUpdateDraw3circle(CCmdUI* pCmdUI);
  163. afx_msg void OnUpdateDraw3drect(CCmdUI* pCmdUI);
  164. afx_msg void OnUpdateDrawData(CCmdUI* pCmdUI);
  165. afx_msg void OnUpdateDrawText(CCmdUI* pCmdUI);
  166. afx_msg void OnUpdateDrawTline(CCmdUI* pCmdUI);
  167. afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
  168. afx_msg void OnEditSave();
  169. afx_msg void OnUpdateEditSave(CCmdUI* pCmdUI);
  170. afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  171. afx_msg void OnUpdateDrawRect(CCmdUI* pCmdUI);
  172. afx_msg void OnUpdatePicsize(CCmdUI* pCmdUI);
  173. afx_msg void OnDrawBitmap();
  174. afx_msg void OnUpdateDrawBitmap(CCmdUI* pCmdUI);
  175. afx_msg void OnDrawCurve();
  176. afx_msg void OnUpdateDrawCurve(CCmdUI* pCmdUI);
  177. afx_msg void OnDrawWatch();
  178. afx_msg void OnUpdateDrawWatch(CCmdUI* pCmdUI);
  179. afx_msg void OnDrawBar();
  180. afx_msg void OnUpdateDrawBar(CCmdUI* pCmdUI);
  181. afx_msg void OnVerspace();
  182. afx_msg void OnUpdateVerspace(CCmdUI* pCmdUI);
  183. afx_msg void OnSamewidth();
  184. afx_msg void OnUpdateSamewidth(CCmdUI* pCmdUI);
  185. afx_msg void OnSameheight();
  186. afx_msg void OnUpdateSameheight(CCmdUI* pCmdUI);
  187. afx_msg void OnHorspace();
  188. afx_msg void OnUpdateHorspace(CCmdUI* pCmdUI);
  189. afx_msg void OnAllsame();
  190. afx_msg void OnUpdateAllsame(CCmdUI* pCmdUI);
  191. afx_msg void OnOpenpic();
  192. afx_msg void OnDrawArc();
  193. afx_msg void OnDrawBreaker();
  194. afx_msg void OnDrawFan();
  195. afx_msg void OnDrawGrid();
  196. afx_msg void OnDrawHiscurve();
  197. afx_msg void OnDrawLine();
  198. afx_msg void OnDrawPie();
  199. afx_msg void OnDrawPipe();
  200. afx_msg void OnDrawPolygon();
  201. afx_msg void OnDrawReport();
  202. afx_msg void OnDrawSinglebar();
  203. afx_msg void OnDrawTransfer();
  204. afx_msg void OnDrawYpipe();
  205. afx_msg void OnDrawZheline();
  206. afx_msg void OnDrawZhepipe();
  207. afx_msg void OnDrawArrow();
  208. afx_msg void OnDrawEllipse();
  209. afx_msg void OnDrawSwitch();
  210. afx_msg void OnCombine();
  211. afx_msg void OnDiscombine();
  212. afx_msg void OnDrawRoundrect();
  213. afx_msg void OnDrawOCX();
  214. afx_msg void OnDrawGIF();
  215. afx_msg void OnDrawFlash();
  216. afx_msg void OnDrawBtnRadio();
  217. afx_msg void OnDrawBtnCheck();
  218. afx_msg void OnUpdateDrawSwitch(CCmdUI* pCmdUI);
  219. afx_msg void OnUpdateDrawArc(CCmdUI* pCmdUI);
  220. afx_msg void OnUpdateDrawArrow(CCmdUI* pCmdUI);
  221. afx_msg void OnUpdateDrawBreaker(CCmdUI* pCmdUI);
  222. afx_msg void OnUpdateDrawEllipse(CCmdUI* pCmdUI);
  223. afx_msg void OnUpdateDrawFan(CCmdUI* pCmdUI);
  224. afx_msg void OnUpdateDrawGrid(CCmdUI* pCmdUI);
  225. afx_msg void OnUpdateDrawHiscurve(CCmdUI* pCmdUI);
  226. afx_msg void OnUpdateDrawPie(CCmdUI* pCmdUI);
  227. afx_msg void OnUpdateDrawPipe(CCmdUI* pCmdUI);
  228. afx_msg void OnUpdateDrawPolygon(CCmdUI* pCmdUI);
  229. afx_msg void OnUpdateDrawReport(CCmdUI* pCmdUI);
  230. afx_msg void OnUpdateDrawSinglebar(CCmdUI* pCmdUI);
  231. afx_msg void OnUpdateDrawTransfer(CCmdUI* pCmdUI);
  232. afx_msg void OnUpdateDrawYpipe(CCmdUI* pCmdUI);
  233. afx_msg void OnUpdateDrawZheline(CCmdUI* pCmdUI);
  234. afx_msg void OnUpdateDrawZhepipe(CCmdUI* pCmdUI);
  235. afx_msg void OnUpdateDrawLine(CCmdUI* pCmdUI);
  236. afx_msg void OnUpdateDrawRoundrect(CCmdUI* pCmdUI);
  237. afx_msg void OnUpdateDiscombine(CCmdUI* pCmdUI);
  238. afx_msg void OnUpdateCombine(CCmdUI* pCmdUI);
  239. afx_msg void OnUpdateDrawOCX(CCmdUI* pCmdUI);
  240. afx_msg void OnUpdateDrawGIF(CCmdUI* pCmdUI);
  241. afx_msg void OnUpdateDrawFlash(CCmdUI* pCmdUI);
  242. //}}AFX_MSG
  243. afx_msg long OnOutbarNotify(WPARAM wParam, LPARAM lParam);
  244. DECLARE_MESSAGE_MAP()
  245. public:
  246. afx_msg void OnProperty();
  247. afx_msg void OnUpdateProperty(CCmdUI *pCmdUI);
  248. afx_msg void OnEditVar();
  249. afx_msg void OnUpdateEditVar(CCmdUI *pCmdUI);
  250. afx_msg void OnRealTimeCurve();
  251. afx_msg void OnUpdateRealTimeCurve(CCmdUI *pCmdUI);
  252. afx_msg void OnClose();
  253. afx_msg void OnKillFocus(CWnd* pNewWnd);
  254. afx_msg void OnSetFocus(CWnd* pOldWnd);
  255. void FileSave();
  256. protected:
  257. virtual void OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView);
  258. BOOL IsValidChar(char chr);
  259. CString GetVarNameFromGS( CString sGS );
  260. public:
  261. afx_msg void OnRButtonDblClk(UINT nFlags, CPoint point);
  262. CString m_sVarName;
  263. };
  264. #ifndef _DEBUG // debug version in VectorView.cpp
  265. inline CIDEDoc* CIDEView::GetDocument()
  266. { return (CIDEDoc*)m_pDocument; }
  267. #endif