void CChildView::UpdateCursor() { if (!m_EditorMode) { BOOL CtrlPressed; BOOL ShiftPressed; CtrlPressed = (GetAsyncKeyState(VK_CONTROL) & 0x8000); ShiftPressed = (GetAsyncKeyState(VK_SHIFT) & 0x8000); if (CtrlPressed && !ShiftPressed) { SetViewCursor(::LoadCursor(NULL, IDC_ARROW)); return; } else if (!m_EditorMode) { if (!CtrlPressed && ShiftPressed) { SetViewCursor(m_MagnifyCur); return; } else if (CtrlPressed && ShiftPressed) { SetViewCursor(m_MagnifyCur2); return; } } } SetViewCursor(m_DefCur); }
void BTitleView::MouseMoved(BPoint where, uint32 code, const BMessage *message) { if (fTrackingState != NULL) { int32 buttons = 0; if (Looper() != NULL && Looper()->CurrentMessage() != NULL) Looper()->CurrentMessage()->FindInt32("buttons", &buttons); fTrackingState->MouseMoved(where, buttons); return; } switch (code) { default: if (InColumnResizeArea(where) && Window()->IsActive()) SetViewCursor(&fHorizontalResizeCursor); else SetViewCursor(B_CURSOR_SYSTEM_DEFAULT); break; case B_EXITED_VIEW: SetViewCursor(B_CURSOR_SYSTEM_DEFAULT); break; } _inherited::MouseMoved(where, code, message); }
void ObjectView::MouseUp(BPoint point) { if (fTrackingInfo.isTracking) { //spin the teapot on release, TODO: use a marching sum and divide by time if (fTrackingInfo.buttons == B_PRIMARY_MOUSE_BUTTON && fTrackingInfo.pickedObject != NULL && (fabs(fTrackingInfo.lastDx) > 1.0f || fabs(fTrackingInfo.lastDy) > 1.0f) ) { fTrackingInfo.pickedObject->Spin(0.5f * fTrackingInfo.lastDy, 0.5f * fTrackingInfo.lastDx); setEvent(drawEvent); } //stop tracking fTrackingInfo.isTracking = false; fTrackingInfo.buttons = 0; fTrackingInfo.pickedObject = NULL; fTrackingInfo.lastX = 0.0f; fTrackingInfo.lastY = 0.0f; fTrackingInfo.lastDx = 0.0f; fTrackingInfo.lastDy = 0.0f; BCursor grabCursor(B_CURSOR_ID_GRAB); SetViewCursor(&grabCursor); } }
void Splitter::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage) { if (transit == B_ENTERED_VIEW) { BCursor cursor(kSplitterCursor); SetViewCursor(&cursor); } if (!fTracking || fIgnoreMouseMoved) { fIgnoreMouseMoved = false; return; } // stupid R5 app_server sends us bogus mouse // coordinates when we have moved meanwhile // (by relayouting) uint32 buttons; GetMouse(&where, &buttons, false); ConvertToParent(&where); float offset; if (fOrientation == B_VERTICAL) offset = where.x - fMousePos.x; else offset = where.y - fMousePos.y; if (offset != 0.0) Move(offset); }
// SetDropTargetRect void DragSortableListView::SetDropTargetRect(const BMessage* message, BPoint where) { if (AcceptDragMessage(message)) { bool copy = modifiers() & B_SHIFT_KEY; bool replaceAll = !message->HasPointer("list") && !copy; BRect r = Bounds(); if (replaceAll) { r.bottom--; // compensate for scrollbar offset _SetDropAnticipationRect(r); fDropIndex = -1; } else { // offset where by half of item height r = ItemFrame(0); where.y += r.Height() / 2.0; int32 index = IndexOf(where); if (index < 0) index = CountItems(); _SetDropIndex(index); const uchar* cursorData = copy ? kCopyCursor : B_HAND_CURSOR; BCursor cursor(cursorData); SetViewCursor(&cursor, true); } } }
void ObjectView::MouseDown(BPoint point) { GLObject* object = NULL; BMessage *msg = Window()->CurrentMessage(); uint32 buttons = msg->FindInt32("buttons"); object = reinterpret_cast<GLObject*>(fObjects.ItemAt(ObjectAtPoint(point))); if (object != NULL){ if (buttons == B_PRIMARY_MOUSE_BUTTON || buttons == B_SECONDARY_MOUSE_BUTTON) { fTrackingInfo.pickedObject = object; fTrackingInfo.buttons = buttons; fTrackingInfo.isTracking = true; fTrackingInfo.lastX = point.x; fTrackingInfo.lastY = point.y; fTrackingInfo.lastDx = 0.0f; fTrackingInfo.lastDy = 0.0f; fTrackingInfo.pickedObject->Spin(0.0f, 0.0f); SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS | B_NO_POINTER_HISTORY); BCursor grabbingCursor(B_CURSOR_ID_GRABBING); SetViewCursor(&grabbingCursor); } else { ConvertToScreen(&point); object->MenuInvoked(point); } } }
void CChildView::OnInsertMark() { if (theApp.m_map.Content.MarkCategories.GetSize() == 0) { AfxMessageBox("Before using marks you must define atleast one mark category.", MB_ICONERROR); return; } m_DefCur = ::LoadCursor(0, IDC_CROSS); SetViewCursor(m_DefCur); m_NewObjectType = otMark; }
void TextDocumentView::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage) { if (!fSelectionEnabled) return; BCursor iBeamCursor(B_CURSOR_ID_I_BEAM); SetViewCursor(&iBeamCursor); if (fMouseDown) SetCaret(where, true); }
// MouseUp void DragSortableListView::MouseUp(BPoint where) { // remove drop mark _SetDropAnticipationRect(BRect(0.0, 0.0, -1.0, -1.0)); SetAutoScrolling(false); // be sure to forget drag message _SetDragMessage(NULL); BListView::MouseUp(where); BCursor cursor(B_HAND_CURSOR); SetViewCursor(&cursor, true); }
void ResizeView::MouseMoved(BPoint, uint32, const BMessage*) { SetViewCursor(&cursor); if (mousePressed) { BWindow* window(Window()); BMessage* windowmsg(window->CurrentMessage()); BPoint windowCoord; windowmsg->FindPoint("where", &windowCoord); BMessage msg(M_RESIZE_VIEW); if (windowCoord.x <= 0.0 || windowCoord.x >= window->Bounds().right) return; msg.AddPoint("loc", windowCoord); msg.AddPointer("view", attachedView); window->PostMessage(&msg); } }
void ObjectView::MouseMoved(BPoint point, uint32 transit, const BMessage *msg) { if (fTrackingInfo.isTracking && fTrackingInfo.pickedObject != NULL) { float dx = point.x - fTrackingInfo.lastX; float dy = point.y - fTrackingInfo.lastY; fTrackingInfo.lastX = point.x; fTrackingInfo.lastY = point.y; if (fTrackingInfo.buttons == B_PRIMARY_MOUSE_BUTTON) { fTrackingInfo.pickedObject->Spin(0.0f, 0.0f); fTrackingInfo.pickedObject->RotateWorldSpace(dx,dy); fTrackingInfo.lastDx = dx; fTrackingInfo.lastDy = dy; setEvent(drawEvent); } else if (fTrackingInfo.buttons == B_SECONDARY_MOUSE_BUTTON) { float xinc = (dx * 2 * displayScale / Bounds().Width()); float yinc = (-dy * 2 * displayScale / Bounds().Height()); float zinc = 0; if (fPersp) { zinc = yinc * (fTrackingInfo.pickedObject->z / displayScale); xinc *= -(fTrackingInfo.pickedObject->z * 4 / zRatio); yinc *= -(fTrackingInfo.pickedObject->z * 4 / zRatio); } fTrackingInfo.pickedObject->x += xinc; if (modifiers() & B_SHIFT_KEY) fTrackingInfo.pickedObject->z += zinc; else fTrackingInfo.pickedObject->y += yinc; fForceRedraw = true; setEvent(drawEvent); } } else { void* object = fObjects.ItemAt(ObjectAtPoint(point)); BCursor cursor(object != NULL ? B_CURSOR_ID_GRAB : B_CURSOR_ID_SYSTEM_DEFAULT); SetViewCursor(&cursor); } }
void CChildView::SetEditorMode() { m_CurHideUnexplored = theApp.m_map.HideUnexplored; theApp.m_map.HideUnexplored = FALSE; m_EditorMode = TRUE; m_DefCur = ::LoadCursor(NULL, IDC_ARROW); SetViewCursor(m_DefCur); ActivateDefStyle(); g_pMainFrame->ShowControlBar(&g_pMainFrame->m_EditorTB, TRUE, FALSE); theApp.m_map.Content.DrawOptions |= cdoSimplify; HideMarkDescriptions(); CMenu *menu = g_pMainFrame->GetMenu()->GetSubMenu(1); menu->EnableMenuItem(1, MF_BYPOSITION | MF_ENABLED); menu->EnableMenuItem(2, MF_BYPOSITION | MF_ENABLED); Invalidate(FALSE); }
void CChildView::SetViewerMode() { theApp.m_map.HideUnexplored = m_CurHideUnexplored; m_EditorMode = FALSE; m_NewObjectType = 0; if (theApp.m_map.IsEmpty()) m_DefCur = ::LoadCursor(NULL, IDC_ARROW); else m_DefCur = theApp.LoadCursor(IDC_CURDRAGHAND); SetViewCursor(m_DefCur); g_pMainFrame->ShowControlBar(&g_pMainFrame->m_EditorTB, FALSE, FALSE); SelectAll(FALSE); theApp.m_map.Content.DrawOptions = cdoHideLarge | cdoHideSmall; CMenu *menu = g_pMainFrame->GetMenu()->GetSubMenu(1); menu->EnableMenuItem(1, MF_BYPOSITION | MF_GRAYED); menu->EnableMenuItem(2, MF_BYPOSITION | MF_GRAYED); Invalidate(FALSE); }
// MouseMoved void DragSortableListView::MouseMoved(BPoint where, uint32 transit, const BMessage *msg) { if (msg && AcceptDragMessage(msg)) { switch (transit) { case B_ENTERED_VIEW: case B_INSIDE_VIEW: { // remember drag message // this is needed to react on modifier changes _SetDragMessage(msg); // set drop target through virtual function SetDropTargetRect(msg, where); // go into autoscrolling mode BRect r = Bounds(); r.InsetBy(0.0, r.Height() * SCROLL_AREA); SetAutoScrolling(!r.Contains(where)); break; } case B_EXITED_VIEW: // forget drag message _SetDragMessage(NULL); SetAutoScrolling(false); // fall through case B_OUTSIDE_VIEW: _RemoveDropAnticipationRect(); break; } } else { _RemoveDropAnticipationRect(); BListView::MouseMoved(where, transit, msg); _SetDragMessage(NULL); SetAutoScrolling(false); BCursor cursor(B_HAND_CURSOR); SetViewCursor(&cursor, true); } fLastMousePos = where; }
void CChildView::OnLButtonUp(UINT nFlags, CPoint point) { if (m_ptClick.x != -1) { if (!m_Moving) HideMarkDescriptions(); m_ptClick.x = -1; ReleaseCapture(); SetViewCursor(m_DefCur); if (!m_Selection.IsRectNull()) { CDC *dc; dc = GetDC(); DrawSelectionRect(*dc); ReleaseDC(dc); CContentObjects& objs = theApp.m_map.Content.Objects; CContentObj* o; CRect r; m_Selection.NormalizeRect(); ScreenToMapRect(&m_Selection); for (int i = 0; i < objs.GetSize(); i++) { o = objs[i]; if (!o->Selected && o->Plane == theApp.m_map.m_iLevel && r.IntersectRect(o->BoundsRect, m_Selection) && o->IsVisible() == ovVisible) if (theApp.m_map.Content.IsVisibleUser(o, o->BoundsRect)) { o->Selected = TRUE; InvalidateObj(o); m_ObjSelCount++; } } m_Selection.SetRectEmpty(); UpdateCurrentStyle(); } } CWnd ::OnLButtonUp(nFlags, point); }
void BSplitView::MouseMoved(BPoint where, uint32 transit, const BMessage* message) { BCursor cursor(B_CURSOR_ID_SYSTEM_DEFAULT); int32 splitterIndex = fSplitLayout->DraggedSplitter(); if (splitterIndex >= 0 || fSplitLayout->IsAboveSplitter(where)) { if (Orientation() == B_VERTICAL) cursor = BCursor(B_CURSOR_ID_RESIZE_NORTH_SOUTH); else cursor = BCursor(B_CURSOR_ID_RESIZE_EAST_WEST); } if (splitterIndex >= 0) { BRect oldFrame = fSplitLayout->SplitterItemFrame(splitterIndex); if (fSplitLayout->DragSplitter(where)) { Invalidate(oldFrame); Invalidate(fSplitLayout->SplitterItemFrame(splitterIndex)); } } SetViewCursor(&cursor, true); }
void CChildView::OnKillFocus(CWnd* pNewWnd) { CWnd ::OnKillFocus(pNewWnd); SetViewCursor(m_DefCur); }
void CChildView::SetArrowCursor() { m_DefCur = ::LoadCursor(0, IDC_ARROW); SetViewCursor(m_DefCur); }
void SeqSplitterView::MouseMoved( BPoint where, uint32 code, const BMessage* message) { if (code == B_ENTERED_VIEW) { if (mDirection == B_VERTICAL && gVrtCursor) SetViewCursor(gVrtCursor); if (mDirection == B_HORIZONTAL && gHrzCursor) SetViewCursor(gHrzCursor); } if( !mMouseDown || !Window() || !Window()->CurrentMessage() ) return; BView* prev = PreviousSibling(); BView* next = NextSibling(); if( !prev || !next ) return; // The mouse moved message's "where" field is in window // coordinates. We need to use that instead of view // coordinates because the changes in this view's frame // are asynchronous with the mouse events we receive. BPoint screenWhere; Window()->CurrentMessage()->FindPoint("where", &screenWhere); Window()->ConvertToScreen(&screenWhere); BPoint delta = screenWhere - mPointDown; bool locked = false; //printf("recived mouse of %f\n", where.x); if( Window() && Window()->Lock() ) { locked = true; Window()->BeginViewTransaction(); } if( mDirection == B_VERTICAL ) { /* Move me */ float prevLeft = prev->Frame().left; float nextRight = next->Frame().right; float x = mFrameDown.left + delta.x; float y = mFrameDown.top; if( x < prevLeft ) x = prevLeft; if( x + Bounds().Width() > nextRight ) x = nextRight - Bounds().Width(); MoveTo( x, y ); /* Move prev */ float height = prev->Bounds().Height(); float prevRight = Frame().left - 1; prev->ResizeTo( prevRight - prevLeft, height ); /* Move next */ height = next->Bounds().Height(); float nextTop = next->Frame().top; float nextLeft = Frame().right + 1; //printf("\tsending out move to %f\n", nextLeft); BRect f = next->Frame(); if( f.left != nextLeft ) next->MoveTo( nextLeft, nextTop ); if( f.Width() != nextRight - nextLeft ) next->ResizeTo( nextRight - nextLeft, height ); #if 0 next->MoveTo( nextLeft, nextTop ); next->ResizeTo( nextRight - nextLeft, height ); #endif } else { /* Move me */ float prevTop = prev->Frame().top; float nextBottom = next->Frame().bottom; float x = mFrameDown.left; float y = mFrameDown.top + delta.y; if( y < prevTop ) y = prevTop; if( y + Bounds().Height() > nextBottom ) y = nextBottom - Bounds().Height(); MoveTo( x, y ); /* Move prev */ float width = prev->Bounds().Width(); float prevBottom = Frame().top - 1; prev->ResizeTo( width, prevBottom - prevTop ); /* Move next */ width = next->Bounds().Width(); float nextLeft = next->Frame().left; float nextTop = Frame().bottom + 1; next->MoveTo( nextLeft, nextTop ); next->ResizeTo( width, nextBottom - nextTop ); } if( locked ) { Window()->EndViewTransaction(); Window()->Unlock(); } }
// MouseMoved void ObjectView::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage) { // BRect dirty(where, where); // dirty.InsetBy(-10, -10); // Invalidate(dirty); if (dragMessage) { //printf("ObjectView::MouseMoved(BPoint(%.1f, %.1f)) - DRAG MESSAGE\n", where.x, where.y); //Window()->CurrentMessage()->PrintToStream(); } else { //printf("ObjectView::MouseMoved(BPoint(%.1f, %.1f))\n", where.x, where.y); } if (fScrolling) { BCursor cursor(kGrabCursor); SetViewCursor(&cursor); BPoint offset = fLastMousePos - where; ScrollBy(offset.x, offset.y); fLastMousePos = where + offset; } else if (fInitiatingDrag) { BPoint offset = fLastMousePos - where; if (sqrtf(offset.x * offset.x + offset.y * offset.y) > 5.0) { BMessage newDragMessage('drag'); BBitmap* dragBitmap = new BBitmap(BRect(0, 0, 40, 40), B_RGBA32, true); if (dragBitmap->Lock()) { BView* helper = new BView(dragBitmap->Bounds(), "offscreen view", B_FOLLOW_ALL, B_WILL_DRAW); dragBitmap->AddChild(helper); helper->SetDrawingMode(B_OP_ALPHA); helper->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE); BRect r(helper->Bounds()); helper->SetHighColor(0, 0, 0, 128); helper->StrokeRect(r); helper->SetHighColor(200, 200, 200, 100); r.InsetBy(1, 1); helper->FillRect(r); helper->SetHighColor(0, 0, 0, 255); const char* text = B_TRANSLATE("Test"); float pos = (r.Width() - helper->StringWidth(text)) / 2; helper->DrawString(text, BPoint(pos, 25)); helper->Sync(); } DragMessage(&newDragMessage, dragBitmap, B_OP_ALPHA, B_ORIGIN, this); fInitiatingDrag = false; } } else { BCursor cursor(kMoveCursor); SetViewCursor(&cursor); if (fState && fState->IsTracking()) { BRect before = fState->Bounds(); fState->MouseMoved(where); BRect after = fState->Bounds(); BRect invalid(before | after); Invalidate(invalid); } } // SetViewCursor(); }
void CChildView::OnInsertText() { m_DefCur = ::LoadCursor(0, IDC_CROSS); SetViewCursor(m_DefCur); m_NewObjectType = otTextLabel; }
void CChildView::OnLButtonDown(UINT nFlags, CPoint point) { int i; CPoint pt; CContentObjects& objs = theApp.m_map.Content.Objects; CContentObj *o2; BOOL ShiftPressed = nFlags & MK_SHIFT; if (theApp.m_map.IsEmpty() || m_InPopup) goto mend; SetFocus(); i = m_NewObjectType; m_NewObjectType = 0; if (i) SelectAll(FALSE); switch (i) { case otTextLabel: SetArrowCursor(); CTextProps *tp; tp = new CTextProps(this); if (tp->DoModal() == IDOK) { CContentText *ct = new CContentText(theApp.m_map.Content); ct->StyleIdx = m_DefStyleIdx; ct->SetText(tp->m_EditText); pt = ScreenToMap(point); // ct->SetPosition(pt.x, pt.y); ct->SetPosition(pt.x - ct->BoundsRect.Width()/2, pt.y - ct->BoundsRect.Height()/2); ct->Plane = theApp.m_map.m_iLevel; ct->Selected = TRUE; m_ObjSelCount++; theApp.m_map.Content.Objects.Add(ct); InvalidateObj(ct); theApp.m_map.Content.Modified = TRUE; } return; case otMark: SetArrowCursor(); CNewMarkDlg dlg(this); if (dlg.DoModal() == IDOK) { CContentMark *cm = new CContentMark(theApp.m_map.Content); cm->Category = dlg.m_CategoryIdx; cm->ShortText = dlg.m_ShortText; cm->LongText = dlg.m_LongText; pt = ScreenToMap(point); cm->SetPosition(pt.x - cm->BoundsRect.Width()/2, pt.y - cm->BoundsRect.Height()/2); cm->Plane = theApp.m_map.m_iLevel; cm->Selected = TRUE; m_ObjSelCount++; theApp.m_map.Content.Objects.Add(cm); InvalidateObj(cm); theApp.m_map.Content.Modified = TRUE; } return; } pt = ScreenToMap(point); o2 = theApp.m_map.Content.GetObjectAt(pt, theApp.m_map.m_iLevel); if (!m_EditorMode) { if (ShiftPressed) { i = g_pMainFrame->m_cbZoom.GetCurSel(); if (nFlags & MK_CONTROL) { m_LastZoomIdx = i; i = 1; keybd_event('~', 0, 0, 0); // Disables kbd layout switching by Ctrl+Shift } else m_LastZoomIdx = -1; if (i > 0) { ChangeZoom(point, i - 1); } } else { if (o2 && o2->GetType() == otMark && !(theApp.m_map.Content.DrawOptions & cdoHideAll)) { BYTE dm = ((CContentMark*)o2)->DisplayMode; HideMarkDescriptions(); if (dm != dmExpanded) { ((CContentMark*)o2)->DisplayMode = dmExpanded; o2->Selected = FALSE; InvalidateObj(o2); } } else { m_Moving = FALSE; m_ptClick = point; SetViewCursor(m_DragHand2Cur); SetCapture(); } } } else { SelClick(point); m_ptClick = point; SetCapture(); m_Moving = FALSE; if (!o2) { m_Selection.left = m_Selection.right = point.x; m_Selection.top = m_Selection.bottom = point.y; } else m_Selection.SetRectEmpty(); } mend: CWnd ::OnLButtonDown(nFlags, point); }
void RemoteView::AttachedToWindow() { SetViewColor(B_TRANSPARENT_COLOR); SetViewCursor(&fViewCursor); }