3 // (C) 1997-2007 Christopher J. Madsen
4 // (C) 2019 James Hammons
6 // GUEmap is licensed under either version 2 of the GPL, or (at your option)
7 // any later version. See LICENSE file for details.
9 // mapview.h: Interface of the MapView class
22 gmoNone, gmoAddEdge, gmoChangeEdge, gmoSelectBox, gmoDeleting, gmoAddCorner,
23 gmoControlDown, gmoShiftDown,
24 gmoShiftDragUp, gmoShiftDragDown, gmoShiftDragLeft, gmoShiftDragRight,
26 gmoDrag = gmoShiftDragUp // Drag operations must come last
31 epuRoomInfo, epuAddRoom, epuAddRoomEdge, epuMapInfo
35 class MapView: public QWidget
40 QMenu * roomContextMenu;
41 QMenu * mapContextMenu;
43 QAction * deleteRoomAct;
44 QAction * roomPropertiesAct;
45 QAction * mapPropertiesAct;
46 QAction * selectConnectedAct;
47 QAction * addCornerAct;
50 QAction * addUnexploredAct;
51 QAction * addLoopBackAct;
52 QAction * addNoExitAct;
57 QAction * addOneWayAct;
58 QAction * clearOneWayAct;
59 QAction * addRestrictedAct;
60 QAction * clearRestrictedAct;
74 RoomCorner cornerClicked;
77 QPoint scrollDragStart;
78 QPoint offsetScrollDragStart;
79 unsigned int scrollDragTimer;
97 bool shiftDown, ctrlDown, altDown;
104 MapView(QWidget * parent = NULL);
108 void DrawArrowhead(QPainter *, QPointF, QPointF);
109 void DrawNoExit(QPainter *, QPointF, QPointF);
110 void clearSelection(bool update = true);
111 void deleteSelection(bool removeCorner = true);
112 void deselectPage(int n, bool update = true);
113 void deselectPages(bool update = true);
114 void deselectRoom(RoomNum n, bool update = true);
116 void selectPage(int n, bool update = true);
117 void selectRoom(RoomNum n, bool update = true);
118 void selectOnlyRoom(RoomNum n);
119 void makeRoomVisible(RoomNum n);
120 void navigate(RoomCorner corner, bool toggleStubs = false);
121 void setRoomNote(const char * comment);
122 int FindHoveredEdge(void);
125 void paintEvent(QPaintEvent *);
126 void keyPressEvent(QKeyEvent *);
127 void keyReleaseEvent(QKeyEvent *);
128 void mouseDoubleClickEvent(QMouseEvent *);
129 void mousePressEvent(QMouseEvent *);
130 void mouseMoveEvent(QMouseEvent *);
131 void mouseReleaseEvent(QMouseEvent *);
133 // ClassWizard generated virtual function overrides
134 //{{AFX_VIRTUAL(CMapView)
135 virtual void OnInitialUpdate();
136 virtual void OnPrepareDC(QPainter * pDC, CPrintInfo * pInfo = NULL);
138 virtual bool OnPreparePrinting(CPrintInfo * pInfo);
139 virtual bool PreCreateWindow(CREATESTRUCT & cs);
140 virtual void OnActivateView(bool bActivate, CView * pActivateView, CView * pDeactiveView);
141 virtual void OnBeginPrinting(QPainter * pDC, CPrintInfo * pInfo);
142 virtual void OnEndPrinting(QPainter * pDC, CPrintInfo * pInfo);
143 virtual void OnUpdate(CView * pSender, LPARAM lHint, CObject * pHint);
148 void HandleAddCorner(void);
149 void HandleAddUnexplored(void);
150 void HandleAddLoopBack(void);
151 void HandleAddNoExit(void);
152 void SetEdgeDirection(EdgeType);
153 void HandleAddUp(void);
154 void HandleAddDown(void);
155 void HandleAddIn(void);
156 void HandleAddOut(void);
157 void HandleAddRoom(void);
158 void SetEdges(int, int, EdgeType);
159 void ClearEdges(int, int, EdgeType);
160 void HandleAddOneWay(void);
161 void HandleClearOneWay(void);
162 void HandleAddRestricted(void);
163 void HandleClearRestricted(void);
164 void HandleRoomProperties(void);
165 void HandleMapProperties(void);
166 void HandleDelete(void);
169 void RoomClicked(MapDoc *, int);
172 void addRoom(QPoint & point);
173 void adjustOffset(QPoint & p) const;
174 void computeSelectedRect(QRect & r) const;
176 // void drawBackground(QPainter * dc);
177 // void drawSelected(QPainter * dc);
179 void editProperties(EditPropUndo undoType, bool wasModified = false, EdgeVec * edges = NULL);
181 bool pasteClipboard(const string & text);
183 void getNavText(char & initial, RoomCorner & dir1, char & separator, RoomCorner & dir2, bool mustBeMove = false);
184 void setEdgeType(MapEdge & e);
185 void setNavText(char c);
187 void setScrollBars();
188 void zoomTo(short newZoom);
191 // Generated message map functions
193 //{{AFX_MSG(CMapView)
194 void OnEditProperties(unsigned int cmd);
195 bool OnMouseWheel(unsigned int nFlags, short zDelta, CPoint pt);
196 void OnChar(unsigned int nChar, unsigned int nRepCnt, unsigned int nFlags);
197 // void OnEditAddCorner();
198 void OnEditAddPage();
199 // void OnEditAddRoom();
200 // void OnEditClear();
203 void OnEditPaginate();
205 // void OnEditSelectAll();
206 void OnEditSelectConnected();
207 void OnKeyDown(unsigned int nChar, unsigned int nRepCnt, unsigned int nFlags);
208 // void OnLButtonDblClk(unsigned int nFlags, CPoint point);
209 // void OnLButtonDown(unsigned int nFlags, CPoint point);
210 // void OnLButtonUp(unsigned int nFlags, CPoint point);
211 // void OnMouseMove(unsigned int nFlags, CPoint point);
212 // void OnRButtonDown(unsigned int nFlags, CPoint point);
213 // void OnRButtonUp(unsigned int nFlags, CPoint point);
214 void OnSize(unsigned int nType, int cx, int cy);
215 void OnTimer(unsigned int nIDEvent);
216 void OnUpdateEditAddCorner(CCmdUI * pCmdUI);
217 void OnUpdateEditPaste(CCmdUI * pCmdUI);
218 void OnUpdateSelectedUnlocked(CCmdUI * pCmdUI);
219 void OnUpdateUnlocked(CCmdUI * pCmdUI);
220 void OnUpdateViewGrid(CCmdUI * pCmdUI);
222 void OnWindowRefresh();
223 int OnMouseActivate(CWnd *, unsigned int, unsigned int);
225 void OnNavGoDir(unsigned int cmd);
226 void OnUpdateViewZoom(CCmdUI * pCmdUI);
227 void OnViewZoom(unsigned int cmd);
232 #endif // __MAPVIEW_H__