1 #ifndef _SCREEN_FLOW_EDIT_DLG_
2 #define _SCREEN_FLOW_EDIT_DLG_
3 
4 #define SCREEN_FLOW_MIN_SCALE 25
5 #define SCREEN_FLOW_MAX_SCALE 500
6 
7 // screen_flow_edit_dlg dialog
8 
9 struct trigger_connection{
10     CString source_screen;
11     CString target_screen;
12     CPoint line_start;
13     CPoint line_end;
14 };
15 
16 class screen_flow_button_frame : public CWnd
17 {
18 public:
19     screen_flow_button_frame(screen_flow *flow, CWnd *pParent = NULL);
20     ~screen_flow_button_frame();
21 
22 protected:
23     afx_msg BOOL OnEraseBkgnd(CDC* pDC);
24     afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
25     afx_msg void OnSize(UINT nType, int cx, int cy);
26     afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
27     virtual BOOL PreTranslateMessage(MSG* pMsg);
28     DECLARE_MESSAGE_MAP()
29 
30     void OnFitContent();
31     void OnZoomOut();
32     void OnZoomIn();
33     void OnRunProject();
34     void UpdateZoomValue();
35 
36 private:
37     screen_flow *mpScreenFlow;
38     custom_bitmap_button mZoomInButton;
39     custom_bitmap_button mZoomOutButton;
40     custom_bitmap_button mFitContent;
41     CStatic mZoomValueLable;
42     CButton mRunButton;
43 
44     CFont mFont;
45 };
46 
47 class screen_flow_diagram_win : public CWnd
48 {
49 public:
50     screen_flow_diagram_win(int display, screen_flow *flow, CWnd* pParent = NULL);   // standard constructor
51     ~screen_flow_diagram_win();
52 
53     afx_msg BOOL OnEraseBkgnd(CDC* pDC);
54     afx_msg void OnPaint();
55     afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
56     afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
57     afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
58     afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
59     afx_msg void OnMouseMove(UINT nFlags, CPoint point);
60     afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
61     afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
62     afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
63     afx_msg void OnSetFocus(CWnd* pOldWnd);
64     afx_msg void OnKillFocus(CWnd* pNewWnd);
65     afx_msg void OnSize(UINT nType, int cx, int cy);
66     virtual BOOL PreTranslateMessage(MSG* pMsg);
67     void SelectFlowItem(flow_item* item);
68     void HideFlowItem(flow_item *item);
69     DECLARE_MESSAGE_MAP()
70 
71 public:
72     void InitConnectionList();
73     void RemoveConnection(flow_item *source);
74     void RemoveConnection(flow_item *source, flow_item *target);
75     void CheckAddConnection(flow_item *source);
76     void CheckAddConnection(flow_item *source, flow_item *target);
77     void CalculateConnectionPos(trigger_connection *connection, flow_item *source, flow_item *target);
78     void UpdateConnectionPos(flow_item *source);
79     int CheckResizeCursor(CPoint point);
80     void UpdateDisplaySize();
81     void SelectedVisible();
82     BOOL HandleKeydown(UINT message);
83     VOID Zoom(int type);
84     CRect GetScaledRect(CRect rect);
85     CPoint GetScaledPoint(CPoint point);
86     void ShiftLeft(CRect scaled_rect, CRect client, INT scaled_shift_x, INT shift_x);
87     void ShiftTop(CRect scaled_rect, CRect client, INT scaled_shift_y, INT shift_y);
88     void ShiftRight(CRect scaled_rect, CRect client, INT scaled_shift_x, INT shift_x);
89     void ShiftBottom(CRect scaled_rect, CRect client, INT scaled_shift_y, INT shift_y);
90     flow_item *FindFirstVisibleItem();
91     BOOL EditFlowItem(flow_item* item);
GetScale()92     int GetScale() { return mScale; }
93 
94 private:
95     screen_flow *mpScreenFlow;
96     CArray<trigger_connection *> mConnectionList;
97     flow_item *mpDragItem;
98     CPoint mDragStart;
99     int    mDragMode;
100     int    mActiveDisplay;
101     CScrollHelper *m_scroll_helper;
102     int mDisplayWidth;
103     int mDisplayHeight;
104     int mDiagramScale;
105     int mSystemDpi;
106     int mScale;
107 };
108 
109 class screen_flow_edit_dlg : public express_dialog
110 {
111     DECLARE_DYNAMIC(screen_flow_edit_dlg)
112 
113 public:
114     screen_flow_edit_dlg(int display, CWnd* pParent = NULL);   // standard constructor
115     virtual ~screen_flow_edit_dlg();
116 
117 // Dialog Data
118     enum { IDD = IDD_SCREEN_FLOW_EDIT_DLG };
119 
120 protected:
121     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
122     virtual void OnCancel();
123     virtual BOOL OnInitDialog();
124     afx_msg void OnSize(UINT nType, int cx, int cy);
125     afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI);
126     afx_msg LRESULT  OnShowHideScreenItem(WPARAM wParam, LPARAM lParam);
127     afx_msg LRESULT  OnNodeSelect(WPARAM wParam, LPARAM lParam);
128     BOOL PreTranslateMessage(MSG* pMsg);
129     afx_msg LRESULT OnTestMessage(WPARAM wParam, LPARAM lParam);
130     DECLARE_MESSAGE_MAP()
131 
132 public:
133     void PositionChildren();
134     void InitScreenFlow(int diagram_width, int diagram_height);
135     void PopulateScreenItems();
GetOldFlow()136     screen_flow *GetOldFlow(){ return mpOldScreenFlow; };
GetFlow()137     screen_flow *GetFlow(){ return mpScreenFlow; };
Zoom(int type)138     void Zoom(int type){ mpScreenFlowDiagram->Zoom(type); };
139 
140 private:
141     int mActiveDisplay;
142     screen_flow *mpScreenFlow;
143     screen_flow *mpOldScreenFlow;
144     screen_flow_diagram_win *mpScreenFlowDiagram;
145     screen_flow_button_frame *mpButtonFrame;
146     CustomTreeCtrl mScreenItemView;
147 };
148 
149 #endif