#include "roomdialog.h"
#include "undo.h"
-
const int
penEdgeWidth = 9,
penPageWidth = 20,
static const char a2z[] = "abcdefghijklmnopqrstuvwxyz";
-
//
// Parse a direction word:
//
return rcNone;
}
-
#if 0
/////////////////////////////////////////////////////////////////////////////
// CRepaginateDlg dialog
};
#endif
-
-
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CMapView
mapContextMenu->addAction(deleteRoomAct);
}
-
MapView::~MapView()
{
delete doc;
// gueApp()->closingView(this); // Remove any comment for this view
}
-
void MapView::DrawArrowhead(QPainter * painter, QPointF head, QPointF tail)
{
QPolygonF arrow;
painter->drawPolygon(arrow);
}
-
void MapView::DrawNoExit(QPainter * painter, QPointF head, QPointF tail)
{
const double angle = Angle(tail - head);
painter->drawLine(p2, p3);
}
-
//
// MapView drawing
//
{ roomWidth / 4 - 48, roomHeight + 52 }
};
+ // Offsets used when the label collides with the line...
+ const QPoint edgLblOffsetEx[] = {
+ // N, S, E, W
+ { -48, 0 }, { 48, 0 }, { 0, -76 }, { 0, 76 },
+ // NE, NW, SE, SW
+ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
+ // NNE, NNW, SSE, SSW
+ { -48, 0 }, { -48, 0 }, { 48, 0 }, { 48, 0 }
+ };
+
const int
cantGoSide = 19,
cantGoAngleX = gridY / 6,
if (edge->type1 & etDirection)
{
+ QPoint ex = QPoint(0, 0);
+ double angle = Angle(end - start);
+
+ // Adjust text position if it runs into an edge
+ if (((edge->end1 == rcNNW || edge->end1 == rcN || edge->end1 == rcNNE) && (angle > THREE_QTR_TAU && angle < TAU))
+ || ((edge->end1 == rcSSW || edge->end1 == rcS || edge->end1 == rcSSE) && (angle > QTR_TAU && angle < HALF_TAU))
+ || ((edge->end1 == rcE) && (angle > 0 && angle < QTR_TAU))
+ || ((edge->end1 == rcW) && (angle > HALF_TAU && angle < THREE_QTR_TAU)))
+ {
+ ex = edgLblOffsetEx[edge->end1];
+ }
+
const QPoint & p = room[edge->room1]->pos;
-// dc->TextOut(p.x + edgLblXOffset[edge->end1], p.y + edgLblYOffset[edge->end1], &edgeLabel[(edge->type1 & etDirection) - 1], 1);
elBuf[0] = edgeLabel[(edge->type1 & etDirection) - 1];
- dc->drawText(p + edgLblOffset[edge->end1], elBuf);
+ dc->drawText(p + edgLblOffset[edge->end1] + ex, elBuf);
}
- if (edge->type2 & etDirection)
+ // Make sure there's an actual room #2 for this edge...
+ if (!(edge->type1 & etNoRoom2) && (edge->type2 & etDirection))
{
+ QPoint ex = QPoint(0, 0);
+ double angle = Angle(start - end);
+
+ // Adjust text position if it runs into an edge
+ if (((edge->end2 == rcNNW || edge->end2 == rcN || edge->end2 == rcNNE) && (angle > THREE_QTR_TAU && angle < TAU))
+ || ((edge->end2 == rcSSW || edge->end2 == rcS || edge->end2 == rcSSE) && (angle > QTR_TAU && angle < HALF_TAU))
+ || ((edge->end2 == rcE) && (angle > 0 && angle < QTR_TAU))
+ || ((edge->end2 == rcW) && (angle > HALF_TAU && angle < THREE_QTR_TAU)))
+ {
+ ex = edgLblOffsetEx[edge->end2];
+ }
+
const QPoint & p = room[edge->room2]->pos;
-// dc->TextOut(p.x + edgLblXOffset[edge->end2], p.y + edgLblYOffset[edge->end2], &edgeLabel[(edge->type2 & etDirection) - 1], 1);
elBuf[0] = edgeLabel[(edge->type2 & etDirection) - 1];
- dc->drawText(p + edgLblOffset[edge->end2], elBuf);
+ dc->drawText(p + edgLblOffset[edge->end2] + ex, elBuf);
}
edge--;
}
}
-
void MapView::keyPressEvent(QKeyEvent * event)
{
bool oldShift = shiftDown;
#endif
}
-
void MapView::keyReleaseEvent(QKeyEvent * event)
{
bool oldShift = shiftDown;
}
}
-
#if 0
/////////////////////////////////////////////////////////////////////////////
// CMapView printing
printingPage = 0;
}
-
bool MapView::OnPreparePrinting(CPrintInfo * pInfo)
{
// Require registration before printing map with more than 10 rooms:
return DoPreparePrinting(pInfo);
}
-
void MapView::OnBeginPrinting(QPainter * /*pDC*/, CPrintInfo * /*pInfo*/)
{
// Don't show selection or corners while printing:
showCorners = false;
}
-
void MapView::OnEndPrinting(QPainter* /*pDC*/, CPrintInfo* /*pInfo*/)
{
if (GetDocument()->locked)
}
#endif
-
//
// CMapView miscellaneous
//
return;
}
- point.rx() -= roomWidth / 2 - gridX / 2;
point.rx() -= point.x() % gridX;
- point.ry() -= roomHeight / 2 - gridY / 2;
point.ry() -= point.y() % gridY;
if (point.x() < 0)
editProperties(epuAddRoom, wasModified);
}
-
//
// Make sure we aren't dragging a room off the edge:
//
p.ry() = size.height() - rTmp.bottom();
}
-
//
// Deselect all rooms:
//
deselectPages(update);
}
-
//
// Compute a rectangle enclosing all selected rooms:
//
}
}
-
//
// Deselect a page:
//
}
}
-
//
// Deselect all pages:
//
selectedOne = -1;
}
-
//
// Deselect a room:
//
}
}
-
//
// Update the room comments dialog after the selection changes:
//
// static_cast<CMapApp *>(AfxGetApp())->setComment(this, (selectedOne >= 0 ? &(GetDocument()->getRoom(selectedOne)) : NULL));
}
-
//
// Select a page:
//
}
}
-
//
// Select a room:
//
}
}
-
void MapView::selectOnlyRoom(RoomNum n)
{
if (selectedOne != n)
}
}
-
//
// Make sure that a room is visible:
//
#endif
}
-
//
// Paste a string to the clipboard:
//
return true;
}
-
//
// Update the selected room's comment from the floating dialog:
//
}
}
-
int MapView::FindHoveredEdge(void)
{
for(int i=0; i<doc->edge.size(); i++)
return -1;
}
-
//
// Set the step size of the scroll bars:
//
#endif
}
-
//
// Zoom the display:
//
}
}
-
//
// Navigation:
//---------------------------------------------------------------------------
}
}
-
//
// Fill in the edge type from the navigation box:
//
}
}
-
//
// Start typing in the navigation bar:
//
#endif
}
-
#if 0
void MapView::OnChar(unsigned int c, unsigned int nRepCnt, unsigned int nFlags)
{
}
#endif
-
//
// Parse the text in the navigation bar:
//
#endif
}
-
#if 0
//
// Handle the Go button in the navigation bar:
}
}
-
//
// Handle the direction keys on the numeric keypad:
//
MessageBeep(MB_ICONASTERISK);
}
-
//
// CMapView message handlers
//---------------------------------------------------------------------------
}
#endif
-
// N.B.: If you click on a corner with no edge coming out of it, it will crash here... !!! FIX !!! [MOSTLY DONE--there's still a way to make it crash with "Add Corner", but I can't remember the specifics...]
//void MapView::OnEditAddCorner()
void MapView::HandleAddCorner(void)
update();
}
-
void MapView::HandleAddUnexplored(void)
{
EdgeVec deletedEdges;
update();
}
-
void MapView::HandleAddLoopBack(void)
{
EdgeVec deletedEdges;
update();
}
-
void MapView::HandleAddNoExit(void)
{
EdgeVec deletedEdges;
update();
}
-
void MapView::SetEdgeDirection(EdgeType et)
{
MapEdge e;
update();
}
-
void MapView::HandleAddUp(void)
{
SetEdgeDirection(etUp);
}
-
void MapView::HandleAddDown(void)
{
SetEdgeDirection(etDown);
}
-
void MapView::HandleAddIn(void)
{
SetEdgeDirection(etIn);
}
-
void MapView::HandleAddOut(void)
{
SetEdgeDirection(etOut);
}
-
void MapView::SetEdges(int room, int edgeNum, EdgeType eType)
{
/*
}
}
-
void MapView::ClearEdges(int room, int edgeNum, EdgeType eType)
{
// Go thru from current room to all connected "corner" rooms
}
}
-
void MapView::HandleAddOneWay(void)
{
MapEdge e;
update();
}
-
void MapView::HandleClearOneWay(void)
{
MapEdge e;
update();
}
-
void MapView::HandleAddRestricted(void)
{
MapEdge e;
update();
}
-
void MapView::HandleClearRestricted(void)
{
MapEdge e;
update();
}
-
//void MapView::OnEditAddRoom()
void MapView::HandleAddRoom(void)
{
- addRoom(scrollDragStart);
-}
+#if 0
+ MapDoc * const doc = GetDocument();
+ ASSERT_VALID(doc);
+ const int p = doc->page.size();
+
+ if (p < maxPages)
+ {
+ MapPage page;
+ page.pos = scrollDragStart;
+ page.pos.x -= page.pos.x % gridX;
+ page.pos.y -= page.pos.y % gridY;
+ doc->setUndoData(new UndoAdd(doc->isDirty, p));
+ showPages = true;
+ doc->addPage(p, page);
+ clearSelection();
+ selectPage(p);
+ }
+#else
+ QPoint roomPt(scrollDragStart - offset);
+ addRoom(roomPt);
+#endif
+}
void MapView::HandleMapProperties(void)
{
update();
}
-
//void MapView::OnEditClear()
void MapView::HandleDelete(void)
{
update();
}
-
#if 0
//--------------------------------------------------------------------
void MapView::OnEditAddPage()
}
#endif
-
//
// Input:
// removeCorner: (default true)
}
}
-
#if 0
//--------------------------------------------------------------------
// Cut, Copy & Paste:
}
}
-
void MapView::OnEditCut()
{
OnEditCopy();
deleteSelection();
}
-
void MapView::OnEditPaste()
{
const RoomScrap * scrap = static_cast<CMapApp *>(AfxGetApp())->getClipboard();
}
}
-
void MapView::OnEditPaginate()
{
showPages = true;
}
#endif
-
//
// Handle Edit Properties:
//
editProperties(epuRoomInfo);
}
-
//
// Bring up the Properties dialog:
//
delete undoRoom;
}
-
#if 0
//
// Select all rooms:
selectDone();
}
-
//---------------------------------------------------------------------------
// Select connected rooms:
selectDone();
}
-
void MapView::OnInitialUpdate()
{
const MapDoc * doc = GetDocument();
setScrollBars(); // Now fix the scroll bars
}
-
void MapView::OnKeyDown(unsigned int c, unsigned int nRepCnt, unsigned int nFlags)
{
bool ctrl = (GetKeyState(VK_CONTROL) < 0);
}
#endif
-
void MapView::mouseDoubleClickEvent(QMouseEvent * event)
//void MapView::OnLButtonDblClk(unsigned int nFlags, QPoint point)
{
addRoom(point);
}
-
/* N.B.: Handles RButton & MButton too */
void MapView::mousePressEvent(QMouseEvent * event)
//void MapView::OnLButtonDown(unsigned int nFlags, QPoint point)
{
edgeTmp.room1 = room;
edgeTmp.end1 = corner;
- setEdgeType(edgeTmp);
+// This is setting edge types when it shouldn't... So we're commenting this out for now.
+// setEdgeType(edgeTmp);
}
edgeTmp.room2 = 0;
update();
}
-
//void MapView::OnLButtonUp(unsigned int nFlags, QPoint point)
void MapView::mouseReleaseEvent(QMouseEvent * event)
{
update();
}
-
#if 0
int MapView::OnMouseActivate(CWnd * wnd, unsigned int hitTest, unsigned int message)
{
return result;
}
-
bool MapView::OnMouseWheel(unsigned int nFlags, short zDelta, QPoint pt)
{
if (nFlags == MK_CONTROL)
return CScrollZoomView::OnMouseWheel(nFlags, zDelta, pt);
}
-
void MapView::OnSize(unsigned int nType, int cx, int cy)
{
CScrollZoomView::OnSize(nType, cx, cy);
setScrollBars();
}
-
void MapView::OnTimer(unsigned int idEvent)
{
if (idEvent == menuTimer)
CScrollZoomView::OnTimer(idEvent);
}
-
//
// Update the view after the document changes:
//
Invalidate();
}
-
void MapView::OnUpdateEditAddCorner(CCmdUI* pCmdUI)
{
pCmdUI->Enable(opInProgress == gmoAddCorner);
}
-
void MapView::OnUpdateEditPaste(CCmdUI* pCmdUI)
{
pCmdUI->Enable((static_cast<CMapApp*>(AfxGetApp())->getClipboard() != NULL)
&& !GetDocument()->locked);
}
-
//
// Commands which require selected rooms and unlocked document:
//
pCmdUI->Enable(selected && !doc->locked);
}
-
//
// Commands which require the document to be unlocked:
//
pCmdUI->Enable(!GetDocument()->locked);
}
-
//
// Toggle the grid on and off:
//
InvalidateRect(NULL);
}
-
void MapView::OnUpdateViewGrid(CCmdUI * pCmdUI)
{
pCmdUI->SetCheck(showGrid);
}
-
void MapView::OnViewZoom(unsigned int cmd)
{
ASSERT((cmd == ID_VIEW_ZOOM_IN) || (cmd == ID_VIEW_ZOOM_OUT));
zoomTo(zoom + 10 - zoom % 10);
}
-
void MapView::OnUpdateViewZoom(CCmdUI * pCmdUI)
{
pCmdUI->Enable((pCmdUI->m_nID == ID_VIEW_ZOOM_IN)
? (zoom < maxZoom) : (zoom > minZoom));
}
-
//
// Redraw the window:
//
InvalidateRect(NULL);
}
-
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CRepaginateDlg dialog
/////////////////////////////////////////////////////////////////////////////
// CRepaginateDlg message handlers
-
bool CRepaginateDlg::OnInitDialog()
{
CDialog::OnInitDialog();
return true; // return TRUE unless you set the focus to a control
}
-
void CRepaginateDlg::OnYes()
{
EndDialog(IDYES);
}
#endif
-