1 
2 #ifndef _TARGET_SCREEN_
3 #define _TARGET_SCREEN_
4 
5 #include <afxcview.h>
6 
7 ///////////////////////////////////////////////////////////////////////////////
8 #define ID_ADD_TEMPLATE_BASE  20000
9 #define MAX_TEMPLATES           100
10 
11 typedef struct {
12     widget_info *info;
13     void (*draw_func)(GX_WIDGET *);
14 } WIDGET_SELECT_ENTRY;
15 
16 class target_screen : public CWnd
17 {
18     public:
19         target_screen();
20         virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
21 
22         void UpdateWindowPos();
23 
24         void SwitchTopWidget(widget_info *info);
25         BOOL ConfigureDisplay(int display_index, BOOL bForce = FALSE);
26         void OnCloseProject(void);
27         void MakeTopWindowVisible(widget_info *info);
28 
29         void OnAddWidget(int type);
30         void OnAddTemplate(widget_info *base);
31 
32         BOOL SelectWidget(widget_info *select, BOOL echo_to_proj_view, BOOL multiple);
33         BOOL SelectWidget(GX_POINT &point, BOOL multiple = FALSE);
34         void WidgetWasMoved(widget_info *info);
35         void CopySelectedWidgets();
36         void ShiftSelectedWidgets(int x, int y);
37         widget_info *GetSingleSelect(void);
38         static BOOL SelectedWidgetsCanBeMoved();
39 
40         static USHORT GetWidgetParentType(widget_info *info);
41         static BOOL IsWidgetResizable(USHORT parent_type, widget_info *info, GX_RECTANGLE &new_size);
42 
43         void RepositionListChildren(widget_info *info);
44 
45         void TestDropItem(resource_item *item, CPoint spot, BOOL shifted);
46         void DeSelect();
47 
48         void OnAlignLeft();
49         void OnAlignTop();
50         void OnAlignRight();
51         void OnAlignBottom();
52         void OnHSpaceEqually();
53         void OnVSpaceEqually();
54         void OnMakeEqualWidth();
55         void OnMakeEqualHeight();
56         void OnAutosize();
57         void ZoomIn(int scale);
GetZoomScale()58         int GetZoomScale(){ return mZoomScale; };
SetZoomScale(int scale)59         void SetZoomScale(int scale){ mZoomScale = scale; };
60         BOOL OnAltKeyDown();
61 
62     private:
63         void InvalidateCrosshairArea();
64         void InvalidateSnapLineArea();
65         void UpdateSnapLines(int delta_x, int delta_y);
66         int  GetSnapLineVal(GX_RECTANGLE &size, int snap_line_type);
67         BOOL IsVerticalSnapLineType(int snap_line_type);
68         void TestAddSnapLine(SNAPLINE_INFO &snapline);
69         void ClearSnapLine(int snapline_direction);
70         BOOL Snap2Widget(GX_RECTANGLE &src_size, GX_RECTANGLE &target_size, int src_snap_line_type, int direction, int &snap_dist);
71         int  CalSnap2GridDelta(int value, int &delta);
72         BOOL CalSnap2WidgetDelta(GX_WIDGET *selected, int &delta, int direction, int snap_dist, int src_snap_line_type = -1);
73         void CalSnapDelta(int &delta_x, int &delta_y, int snap_dist);
74         int ConvertRadialProgressDragMode(int drag_mode, GX_RECTANGLE rect, GX_POINT point);
75         void UpdateRadialProgressSize(GX_RECTANGLE *size, int mDragMode, int delta_x, int delta_y);
76         void UpdateWidgetSize(GX_RECTANGLE *size, int mDrawMode, int delta_x, int delta_y);
77 
78     // Generated message map functions
79     protected:
80 
81 	    afx_msg void OnPaint();
82         afx_msg BOOL OnEraseBkgnd(CDC *pDC);
83         afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
84         afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
85         afx_msg void OnRButtonDown(UINT nFlags, CPoint pos);
86 
87         afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
88         afx_msg void OnMouseMove(UINT nFlags, CPoint point);
89 
90         afx_msg LRESULT OnGuixReady(WPARAM wp, LPARAM lp);
91         afx_msg LRESULT OnGuixDirty(WPARAM wp, LPARAM lp);
92         afx_msg LRESULT OnTestMessage(WPARAM wParam, LPARAM lParam);
93 
94 	    DECLARE_MESSAGE_MAP()
95 
96         BOOL IsWidgetSelected(GX_WIDGET *widget);
97         GX_WIDGET *FindSelectedWidget(GX_POINT point);
98 
99         int CheckResizeCursor(CPoint point);
100         int FindNearestSelected(int start_index, BOOL vertical);
101 
102         void PositionPopupList(widget_info *info, GX_DROP_LIST *list);
103 
104         void crc32_init(void);
105         unsigned int calc_crc(unsigned char *data, int len);
106         void canvas_to_bitmap(CString filename, GX_CANVAS *canvas);
107         void target_screen_to_bitmap(CString filename, GX_CANVAS *canvas);
108 
109         GX_WIDGET *mpSelectedParent;
110         int       mDragMode;
111         int       m_display_index;
112         BOOL      mFoldUndo;
113         GX_POINT  mDragStart;
114         GX_WIDGET *mpDragSelected;
115         unsigned int crc_table[256];
116         int       mZoomScale;
117         GRID_SNAP_INFO mGridSnapInfo;
118 
119 };
120 
121 #endif
122