void TreeTest::MouseMove(Point pos, dword flags) { // always show cursor position ShowCoords(pos); // Layer* pLayer; if(m_bPan) { Pointf pt = LPtoMP(pos) - m_ptPan; m_rcBnds -= pt; ViewDraw w(this); w.DrawRect(GetSize(),SWhite); w.DrawImage(pos.x-m_ptPanLP.x,pos.y-m_ptPanLP.y,m_view); // if(m_optionGrid.GetData()) // { DrawGrid(w); // } } }
void ButtonReleaseAction(Graph *graph, XButtonReleasedEvent *buttonevent) { int button; int sx2, sy2; int sx1, sy1; float x1, y1, x2, y2; button = buttonevent->button; sx2 = buttonevent->x; sy2 = buttonevent->y; switch (ButtonMode()) { case DATAMODE: switch (button) { case 1: /* zoom box */ /* * mark the end of the drag and zoom */ graph->dragx2 = sx2; graph->dragy2 = sy2; WorldTransform(graph, graph->dragx1, graph->dragy1, &x1, &y1); WorldTransform(graph, graph->dragx2, graph->dragy2, &x2, &y2); /* * Don't perform a zero scale action. */ if (x2 == x1 || y2 == y1) return; if (x2 > x1) { graph->wxmin = x1; graph->wxmax = x2; } else { graph->wxmin = x2; graph->wxmax = x1; } if (y2 > y1) { graph->wymin = y1; graph->wymax = y2; } else { graph->wymin = y2; graph->wymax = y1; } ScaleAndRefreshGraph(graph); /* * set the drag coords back to the invalid state */ graph->dragx1 = -1; graph->dragx2 = -1; break; case 2: /* ruler line */ /* * get the world coordinates of the starting point */ x1 = graph->dragwx1; y1 = graph->dragwy1; if (sx2 != graph->dragx1 || sy2 != graph->dragy1) { if (snapmode) { /* * display the final coords */ Snap(graph, sx2, sy2, &x2, &y2); /* * compute the screen coordinate of the data point */ ScreenTransform(graph, x2, y2, &sx1, &sy1); ShowCoords((BasicWindow *)graph, sx1, sy1, x2, y2); } else { /* * display the final coords */ WorldTransform(graph, sx2, sy2, &x2, &y2); ShowCoords((BasicWindow *)graph, sx2, sy2, x2, y2); } ClearWindow((BasicWindow *)graph->frame->text); ShowSlope((BasicWindow *)graph->frame->text, 0, graph->fontheight, x1, y1, x2, y2); AddLabelLine((BasicWindow *)graph, 0, 0, 0, 0, x1, y1, x2, y2, WORLD_LBL, TEMPORARY_LBL); } /* * set the drag coords back to the invalid state */ graph->dragx1 = -1; graph->dragx2 = -1; break; case 3: /* drag line */ /* * erase the old line */ EraseSuperLine((BasicWindow *)graph, graph->dragx2, graph->dragy1, graph->dragx2, graph->dragy2); /* * get the coords */ Snap(graph, sx2, sy2, &x2, &y2); ShowCoords((BasicWindow *)graph, graph->dragx2, graph->dragy2, x2, y2); graph->dragx1 = -1; graph->dragx2 = -1; break; } break; case DRAWMODE: switch (button) { case 1: /* draw line */ /* * mark the end of the drag and zoom */ graph->dragx2 = sx2; graph->dragy2 = sy2; WorldTransform(graph, graph->dragx1, graph->dragy1, &x1, &y1); WorldTransform(graph, graph->dragx2, graph->dragy2, &x2, &y2); /* * draw a line between the points */ AddLabelLine((BasicWindow *)graph, 0, 0, 0, 0, x1, y1, x2, y2, WORLD_LBL, TEMPORARY_LBL); /* * set the drag coords back to the invalid state */ graph->dragx1 = -1; graph->dragx2 = -1; break; } break; } }
void ButtonPressAction(Graph *graph, XButtonPressedEvent *buttonevent) { float x, y; int sx1, sy1; int sx2, sy2; int button; sx1 = buttonevent->x; sy1 = buttonevent->y; button = buttonevent->button; switch (ButtonMode()) { case DATAMODE: switch (button) { case 1: /* * mark the start of the drag location */ graph->dragx1 = sx1; graph->dragy1 = sy1; break; case 2: ClearWindow((BasicWindow *)graph->frame->text); if (snapmode) { /* * world coord xy readout of data */ Snap(graph, sx1, sy1, &x, &y); /* * get the screen coords of the data point */ ScreenTransform(graph, x, y, &sx2, &sy2); ShowCoords((BasicWindow *)graph, sx2, sy2, x, y); /* * mark the start of the drag location */ graph->dragx1 = sx2; graph->dragy1 = sy2; } else { /* * world coord xy readout of cursor location */ WorldTransform(graph, sx1, sy1, &x, &y); ShowCoords((BasicWindow *)graph, sx1, sy1, x, y); /* * mark the start of the drag location */ graph->dragx1 = sx1; graph->dragy1 = sy1; } graph->dragwx1 = x; graph->dragwy1 = y; break; case 3: /* * world coord xy readout closest above point */ Snap(graph, sx1, sy1, &x, &y); /* * draw a line to the point on the plot (sx2, sy2) */ ScreenTransform(graph, x, y, &sx2, &sy2); /* avoid writing on the last pixel */ if (sy2 > sy1) { sy2 -= 1; } else { sy2 += 1; } graph->dragx1 = sx1; graph->dragy1 = sy1; graph->dragx2 = sx2; graph->dragy2 = sy2; DrawSuperLine((BasicWindow *)graph, sx2, sy1, sx2, sy2); ClearWindow((BasicWindow *)graph->frame->text); NBShowCoords((BasicWindow *)graph->frame->text, 0, graph->fontheight, x, y); } break; case DRAWMODE: switch (button) { case 1: /* * mark the start of the line */ graph->dragx1 = sx1; graph->dragy1 = sy1; WorldTransform(graph, sx1, sy1, &x, &y); graph->dragwx1 = x; graph->dragwy1 = y; break; } break; case ZAPMODE: switch (button) { case 1: /* * delete the label */ ZapLabel(graph, (XKeyEvent *)buttonevent); break; } break; case PINCHMODE: switch (button) { case 1: /* * offset the plots */ OffsetPlotGraphically(graph, buttonevent->x, buttonevent->y, 0); break; } break; } }