void QuaSymbolBridge::MouseDown(BPoint where) { long channel, quant; BRect area = Bounds(); ulong mods = modifiers(); // Key mods??? ulong buts; BMessage *msg; BPoint pt; drawing_mode cur_mode = DrawingMode(); long clicks; GetMouse(&pt, &buts); msg = Window()->CurrentMessage(); if ((clicks=msg->FindInt32("clicks")) == 1) { if (buts & B_SECONDARY_MOUSE_BUTTON) { BPopUpMenu *qMenu = new BPopUpMenu("env sel", true, FALSE); BPoint orig = where; ConvertToScreen(&where); BMessage *msg = new BMessage(SET_DISPLAY_MODE); msg->AddInt32("display mode", OBJECT_DISPLAY_SMALL); BMenuItem *item = new BMenuItem("Small", msg); qMenu->AddItem(item); item->SetTarget(this); msg = new BMessage(SET_DISPLAY_MODE); msg->AddInt32("display mode", OBJECT_DISPLAY_BIG); item = new BMenuItem("Large", msg); qMenu->AddItem(item); item->SetTarget(this); qMenu->SetAsyncAutoDestruct(true); qMenu->Go(where, true, false, true); } else { msg = new BMessage(MOVE_OBJECT); msg->AddPointer("sym_object", this); if (mods & B_SHIFT_KEY) { ((ObjectViewContainer *)Parent())->AddSelection(this); } else { ((ObjectViewContainer *)Parent())->Select(this); } DragMessage(msg, area); } } else if (clicks > 1) { // edit object Edit(); } else { } }
// MouseWheelChanged bool DragSortableListView::MouseWheelChanged(float x, float y) { BPoint where; uint32 buttons; GetMouse(&where, &buttons, false); if (Bounds().Contains(where)) return true; else return false; }
void TextScrollerView::MouseDown(BPoint point) { tracking_mouse = true; uint32 buttons; GetMouse(&point,&buttons); previous_point = point; while (buttons) { float distance = (point.y - previous_point.y) / 10.0; if (distance > 0) distance = min_c(distance,5.0); else distance = max_c(distance,-5.0); LockLooper(); text_view->ScrollBy(0,-distance); GetMouse(&point,&buttons); UnlockLooper(); snooze(20 * 1000); } tracking_mouse = false; }
static void GenerateEditEvent( int flag) { XVirtualEvent event; Point where; Tk_Window tkwin; Window window; TkDisplay *dispPtr; window = TkMacOSXGetXWindow(FrontNonFloatingWindow()); dispPtr = TkGetDisplayList(); tkwin = Tk_IdToWindow(dispPtr->display, window); tkwin = (Tk_Window) ((TkWindow *) tkwin)->dispPtr->focusPtr; if (tkwin == NULL) { return; } event.type = VirtualEvent; event.serial = Tk_Display(tkwin)->request; event.send_event = false; event.display = Tk_Display(tkwin); event.event = Tk_WindowId(tkwin); event.root = XRootWindow(Tk_Display(tkwin), 0); event.subwindow = None; event.time = TkpGetMS(); GetMouse(&where); tkwin = Tk_TopCoordsToWindow(tkwin, where.h, where.v, &event.x, &event.y); LocalToGlobal(&where); event.x_root = where.h; event.y_root = where.v; event.state = TkMacOSXButtonKeyState(); event.same_screen = true; switch (flag) { case EDIT_CUT: event.name = Tk_GetUid("Cut"); break; case EDIT_COPY: event.name = Tk_GetUid("Copy"); break; case EDIT_PASTE: event.name = Tk_GetUid("Paste"); break; case EDIT_CLEAR: event.name = Tk_GetUid("Clear"); break; } Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL); }
INT DragGraphWindow (GRAPH_WINDOW *gw, EventRecord *theEvent, DOC_DRAG_EVENT *docDrag) { WindowPtr theWindow; int TopOld, BottomOld, LeftOld, RightOld, Left, Right, Top, Bottom, DelLeft, DelRight, DelTop, DelBottom; Rect currentRect; Rect theDragRect; Point MouseLoc; theWindow = MAC_WIN(gw); #warning do we need kWindowContentRgn instead of kWindowStructureRgn? GetWindowBounds(theWindow, kWindowStructureRgn, ¤tRect); /* store old corners of the window */ TopOld = currentRect.top; BottomOld = currentRect.bottom; LeftOld = currentRect.left; RightOld = currentRect.right; /* set drag rect */ GetMouse(&MouseLoc); LocalToGlobal(&MouseLoc); Left = DragRect()->left + MouseLoc.h - LeftOld; Right = DragRect()->right + MouseLoc.h - RightOld; Top = DragRect()->top + MouseLoc.v - TopOld; Bottom = DragRect()->bottom + MouseLoc.v - BottomOld; SetRect(&theDragRect,Left,Top,Right,Bottom); /* drag window */ DragWindow (theWindow,theEvent->where,&theDragRect); /* report new size */ #warning do we need kWindowContentRgn instead of kWindowStructureRgn? GetWindowBounds(theWindow, kWindowStructureRgn, ¤tRect); Left = currentRect.left; Right = currentRect.right; Top = currentRect.top; Bottom = currentRect.bottom; DelLeft = Left - LeftOld; DelRight = Right - RightOld; DelTop = Top - TopOld; DelBottom = Bottom- BottomOld; if (DelLeft==0 && DelRight==0 && DelTop==0 && DelBottom) return (NO_POS_CHANGE); docDrag->Global_LL[0] = gw->Global_LL[0] += DelLeft; docDrag->Global_LL[1] = gw->Global_LL[1] += DelBottom; docDrag->Global_UR[0] = gw->Global_UR[0] += DelRight; docDrag->Global_UR[1] = gw->Global_UR[1] += DelTop; return (POS_CHANGE); }
void Mover::MouseMoved(BPoint p,uint32 transit,const BMessage *bla) { if (moving) { uint32 dummy; GetMouse(&p,&dummy,false); p = ConvertToScreen(p); BMessage moved(MOVER_MESSAGE); moved.AddPointer(MM_VIEW,this); float coord; if (vertical) coord = p.x-clickPoint.x; else coord = p.y-clickPoint.y; moved.AddFloat(MM_COORD,coord); // est-on dans les limites? bool l_InLimits = true; if (!vertical) { if ( (coord < limits.top) || (coord > limits.bottom)) l_InLimits = false; } else { if ( (coord < limits.left) || (coord > limits.right)) l_InLimits = false; } if (l_InLimits) Window()->PostMessage(&moved); } else switch(transit) { case B_ENTERED_VIEW: if(vertical) be_app->SetCursor(verticalMouse); else be_app->SetCursor(horizontalMouse); break; case B_EXITED_VIEW: case B_OUTSIDE_VIEW: be_app->SetCursor(B_HAND_CURSOR); break; default: break; } }
void TMagnify::NudgeMouse(float x, float y) { BPoint loc; uint32 button; GetMouse(&loc, &button); ConvertToScreen(&loc); loc.x += x; loc.y += y; set_mouse_position((int32)loc.x, (int32)loc.y); }
void TipsterText::MouseDown(BPoint pt) { BPoint temp; uint32 buttons; GetMouse(&temp, &buttons); if (Bounds().Contains(temp)) { BMessage message(M_UPDATE_TIP); fMessenger->SendMessage(&message); } }
void PulseView::MouseDown(BPoint point) { BPoint cursor; uint32 buttons; MakeFocus(true); GetMouse(&cursor, &buttons, true); if (buttons & B_SECONDARY_MOUSE_BUTTON) { ConvertToScreen(&point); // Use the asynchronous version so we don't interfere with // the window responding to Pulse() events popupmenu->Go(point, true, false, true); } }
bool CObjectRotateCamera::Update() { CMouseManager* mouse = GetMouse(); bool down[2] = {mouse->IsPressed(0), mouse->IsPressed(1)}; int x = mouse->GetX(); int y = mouse->GetY(); int dx = x - m_lastx; int dy = y - m_lasty; bool needUpdate = false; if (!GetKeyboard()->IsPressed(VK_SHIFT) && m_lastDown[0] && down[0] && (abs(dx) + abs(dy) > 0)) { m_anglex += dx * 0.01f; // * elapsedTime; m_anglez += dy * 0.01f;// * elapsedTime; m_anglex = NormAngle(m_anglex); m_anglez = NormAngle(m_anglez); Point3 eye = Angle2Pos(m_anglex, m_anglez); SetEye(eye.x, eye.y, eye.z); needUpdate = true; } if (GetMouse()->GetWheel() != 0) { m_radius *= max(0.01f, 1 - GetMouse()->GetWheel() * 0.0003f); Point3 eye = Angle2Pos(m_anglex, m_anglez); SetEye(eye.x, eye.y, eye.z); needUpdate = true; } m_lastDown[0] = down[0]; m_lastDown[1] = down[1]; m_lastx = x; m_lasty = y; return needUpdate; }
void MCScreenDC::querymouse(int2 &x, int2 &y) { CGrafPtr oldport; GDHandle olddevice; GetGWorld(&oldport, &olddevice); MoveWindow(invisibleWin, 0, 0, False); // OS X moves this. SetGWorld(GetWindowPort(invisibleWin), GetMainDevice()); Point mloc; GetMouse(&mloc); //get local mouse position SetGWorld(oldport, olddevice); x = mloc.h; y = mloc.v; }
void PictureViewer::MouseDown(BPoint a) { mouseDown = true; oldMousePos = a; SetMouseEventMask(1); uint32 buttons; int32 action = 0; BPoint ad; GetMouse(&ad, &buttons ); if ( buttons == B_PRIMARY_MOUSE_BUTTON ) action = setup->LeftMouseAction(); if ( buttons == B_SECONDARY_MOUSE_BUTTON ) action = setup->RightMouseAction(); if ( buttons == B_TERTIARY_MOUSE_BUTTON ) action = setup->MiddleMouseAction(); if (action == P_OPENNEW) { if (thePic != NULL) { if (theRef != NULL) be_roster->Launch(theRef); mouseDown = false; return; } } if (action == P_CLIPPING) { if ( (setup->ViewingMode() == PEEK_IMAGE_SCALED_NICELY) || (setup->ViewingMode() == PEEK_IMAGE_SCALE_TO_WINDOW) || (setup->ViewingMode() == PEEK_IMAGE_SCALE_TO_WINDOW) ) return; if (thePic != NULL) { if (clipping) DrawClipping(); busyClipping = true; clipping = true; clippingRegion.Set( ad.x, ad.y, ad.x, ad.y ); } } if (action == P_FULLSCREEN) { ((WindowPeek*)Window())->SetFullScreen( ! setup->FullScreen() ); return; } if (action == P_HIDEFILES) { ((WindowPeek*)Window())->SetCompactMode( ! setup->CompactMode() ); return; } }
void TPanelWindowView::MouseDown( BPoint point ) { uint32 buttons; GetMouse( &point, &buttons ); if ( !fIsDraggingFromOutside ) { if ( modifiers() & B_SHIFT_KEY ) { int count = 5; while ( count ) { count --; BPoint pw; uint32 mods; GetMouse( &pw, &mods ); if ( !mods ) break; if ( !(modifiers() & B_SHIFT_KEY ) ) break; if ( pw != point ) { // TODO: fix this, we want this on separate thread so drawing doesnt block // thread_id tid = spawn_thread( _rearrange_tabs_thread_entry, "ReArrangeTabsThread", B_NORMAL_PRIORITY, this ); // resume_thread(tid); ReArrangeTabsThread(); return; } snooze( 500000 / 5 ); } } TInnerPanel *panel = PanelAt( point ); if ( panel ) panel->MouseDown(point, buttons); } }
static void mac_eventloop(void) { Boolean gotevent; EventRecord event; RgnHandle cursrgn; Point mousenow, mousethen; KeyState *ks; WindowPtr front; cursrgn = NewRgn(); GetMouse(&mousethen); for (;;) { mac_adjustcursor(cursrgn); gotevent = WaitNextEvent(everyEvent, &event, LONG_MAX, cursrgn); mac_adjustcursor(cursrgn); front = mac_frontwindow(); if (front != NULL) { ks = mac_windowkey(front); if (ks->collecting_entropy) { GetMouse(&mousenow); if (mousenow.h != mousethen.h || mousenow.v != mousethen.v) { ks->entropy[ks->entropy_got++] = *(unsigned *)&mousenow; ks->entropy[ks->entropy_got++] = TickCount(); if (ks->entropy_got >= ks->entropy_required) ks->collecting_entropy = 0; SetControlValue(ks->progress, ks->entropy_got); mousethen = mousenow; } SetEmptyRgn(cursrgn); } } if (gotevent) mac_event(&event); if (borednow) cleanup_exit(0); } DisposeRgn(cursrgn); }
void GetCursorPos(MOUSE_POINT& point) { #ifdef _MSC_VER POINT p; GetCursorPos (&p); point.x = p.x; point.y = p.y; #else Point p; GetMouse (&p); point.x = p.h; point.y = p.v; #endif }
// MouseDown void TestView::MouseDown(BPoint where) { // clear previous stroke int32 count = fMouseSamples.CountItems(); for (int32 i = 0; i < count; i++) delete (BPoint*)fMouseSamples.ItemAtFast(i); fMouseSamples.MakeEmpty(); FillRect(Bounds(), B_SOLID_LOW); // sample new stroke uint32 buttons; GetMouse(&where, &buttons); MovePenTo(where); while (buttons) { StrokeLine(where); fMouseSamples.AddItem(new BPoint(where)); snooze(20000); GetMouse(&where, &buttons); } }
void CGUISlider::AfterUpdate( float elapsedTime ) { m_bChanged = false; if (m_bPushed) { m_bPushed = GetMouse()->IsPressed(0); m_value = ComputeValue(); if (m_value != m_lastValue) { m_bChanged = true; m_lastValue = m_value; } } }
static PyObject *Evt_GetMouse(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Point mouseLoc; #ifndef GetMouse PyMac_PRECHECK(GetMouse); #endif if (!PyArg_ParseTuple(_args, "")) return NULL; GetMouse(&mouseLoc); _res = Py_BuildValue("O&", PyMac_BuildPoint, mouseLoc); return _res; }
void FontDrawView::MouseDown(BPoint where) { BPoint pt; uint32 buttons; GetMouse(&pt,&buttons); if(buttons == B_PRIMARY_MOUSE_BUTTON) oldpoint=where; if(buttons == B_SECONDARY_MOUSE_BUTTON) { fontlocation=where; Draw(Bounds()); } }
static void GetCursorPosition( const WindowInfo *window, int pos[2] ) { Point mouse_pos; float window_rect[4]; GetMouse( &mouse_pos ); CGSGetScreenRectForWindow( window->connection, window->drawable, window_rect ); pos[0] = mouse_pos.h - (int) window_rect[0]; pos[1] = (int) window_rect[3] - (mouse_pos.v - (int) window_rect[1]); /*crDebug( "%i %i", pos[0], pos[1] );*/ }
/////////////////// // Draw the scrollbar void CScrollbar::Draw(SDL_Surface * bmpDest) { int x=0; int length; // Top arrow if(bTopButton) x=15; DrawImageAdv(bmpDest, gfxGUI.bmpScrollbar, x,0, iX,iY, 15,14); // Bottom arrow x=0; if(bBotButton) x=15; DrawImageAdv(bmpDest, gfxGUI.bmpScrollbar, x,14, iX,iY+iHeight-14, 15,14); // Main bit DrawRectFill(bmpDest, iX,iY+14, iX+iWidth, iY+iHeight-14, tLX->clScrollbarBack); DrawVLine(bmpDest, iY+14, iY+iHeight-14, iX,tLX->clScrollbarBackLight); DrawVLine(bmpDest, iY+14, iY+iHeight-14, iX+iWidth,tLX->clScrollbarBackLight); // Slider if(iMax > iItemsperbox && iMax > 0) { length = (int)((float)iItemsperbox/(float)iMax * iHeight-30); length = MAX(length, 12); int pos = iScrollPos; if(pos+length > iHeight-30) pos=iHeight-30-length; if (pos < 0) pos = 0; DrawRectFill(bmpDest, iX+2, iY+15+pos, iX+iWidth-1, iY+15+pos+length, tLX->clScrollbarFront); // Shine DrawVLine(bmpDest, iY+15+pos, iY+15+pos+length, iX+1, tLX->clScrollbarHighlight); DrawHLine(bmpDest, iX+1, iX+iWidth-1, iY+15+pos, tLX->clScrollbarHighlight); // Dark DrawVLine(bmpDest, iY+15+pos, iY+15+pos+length, iX+iWidth-1, tLX->clScrollbarShadow); DrawHLine(bmpDest, iX+1, iX+iWidth-1, iY+15+pos+length, tLX->clScrollbarShadow); } // Slight hack if( !GetMouse()->Button ) { bTopButton=false; bBotButton=false; } }
// -------------------------------------------------------------------------------------- void DisplayHelpBalloons(WindowRef prefsWindow) { GrafPtr savedPort; Point mouseLocation; Rect hotRects[3]; short hotRectID; static int previousHotRectID = kNotInHotRect; GetPort(&savedPort); SetPortWindowPort(prefsWindow); GetMouse(&mouseLocation); GetWindowProperty(prefsWindow, kAppSignature, kHotRectsTag, 3 * sizeof(Rect), NULL, hotRects); for (hotRectID = kInList; hotRectID < kNotInHotRect; hotRectID++) { if (PtInRect(mouseLocation, &hotRects[hotRectID])) { if (hotRectID != previousHotRectID) { HMMessageRecord helpMessage; Point tips[3]; helpMessage.hmmHelpType = khmmStringRes; helpMessage.u.hmmStringRes.hmmResID = rHelpStrings; helpMessage.u.hmmStringRes.hmmIndex = hotRectID + 1; GetWindowProperty(prefsWindow, kAppSignature, kBalloonTipsTag, 3 * sizeof(Point), NULL, tips); LocalToGlobal(&tips[hotRectID]); LocalToGlobal(&topLeft(hotRects[hotRectID])); LocalToGlobal(&botRight(hotRects[hotRectID])); HMShowBalloon(&helpMessage, tips[hotRectID], &hotRects[hotRectID], NULL, kBalloonWDEFID, kTopLeftTipPointsLeftVariant, kHMRegularWindow); } break; } } previousHotRectID = hotRectID; SetPort(savedPort); }
/* * Make sure the right cursor's being displayed. */ static void mac_adjustcursor(RgnHandle cursrgn) { Point mouse; WindowPtr window, front; short part; #if TARGET_API_MAC_CARBON Cursor arrow; RgnHandle visrgn; #endif GetMouse(&mouse); LocalToGlobal(&mouse); part = FindWindow(mouse, &window); front = FrontWindow(); if (part != inContent || window == NULL || window != front) { /* Cursor isn't in the front window, so switch to arrow */ #if TARGET_API_MAC_CARBON GetQDGlobalsArrow(&arrow); SetCursor(&arrow); #else SetCursor(&qd.arrow); #endif SetRectRgn(cursrgn, SHRT_MIN, SHRT_MIN, SHRT_MAX, SHRT_MAX); if (front != NULL) { #if TARGET_API_MAC_CARBON visrgn = NewRgn(); GetPortVisibleRegion(GetWindowPort(front), visrgn); DiffRgn(cursrgn, visrgn, cursrgn); DisposeRgn(visrgn); #else DiffRgn(cursrgn, front->visRgn, cursrgn); #endif } } else { if (mac_wininfo(window)->adjustcursor != NULL) (*mac_wininfo(window)->adjustcursor)(window, mouse, cursrgn); else { #if TARGET_API_MAC_CARBON GetQDGlobalsArrow(&arrow); SetCursor(&arrow); GetPortVisibleRegion(GetWindowPort(window), cursrgn); #else SetCursor(&qd.arrow); CopyRgn(window->visRgn, cursrgn); #endif } } }
void TBarMenuBar::InitTrackingHook(bool (*hookFunction)(BMenu*, void*), void* state, bool both) { BPoint loc; uint32 buttons; GetMouse(&loc, &buttons); // set the hook functions for the two menus // will always have the deskbar menu // may have the app menu as well (mini mode) if (fDeskbarMenuItem->Frame().Contains(loc) || both) init_tracking_hook(fDeskbarMenuItem, hookFunction, state); if (fAppListMenuItem && (fAppListMenuItem->Frame().Contains(loc) || both)) init_tracking_hook(fAppListMenuItem, hookFunction, state); }
void DeskbarPulseView::MouseDown(BPoint point) { BPoint cursor; uint32 buttons; MakeFocus(true); GetMouse(&cursor, &buttons, true); if (buttons & B_PRIMARY_MOUSE_BUTTON) { BMessage *message = Window()->CurrentMessage(); int32 clicks = message->FindInt32("clicks"); if (clicks >= 2) { BMessenger messenger(this); BMessage *m = new BMessage(PV_NORMAL_MODE); messenger.SendMessage(m); } } else MiniPulseView::MouseDown(point); }
void MouseUp(BPoint where) { (void) where; BPoint mouseWhere; ulong buttons; GetMouse(&mouseWhere, &buttons); BMessage msg(GNASH_MOUSE_CLICKED); if (B_OK != msg.AddBool("pressed", false) || B_OK != msg.AddInt32("mask", _pressedbuttons & ~buttons)) QQ(1); else be_app_messenger.SendMessage(&msg); _pressedbuttons = buttons; }
void AmUndoableIntControl::MouseMoved( BPoint pt, uint32 code, const BMessage *msg) { /* Sometimes, views might not receive a mouse up for * whatever reason. If it looks like that's happened, * then behave as if I've had a mouse up. */ if (mUndo) { BPoint pointypointy; uint32 button; GetMouse(&pointypointy, &button, false); if( button == 0 ) CommitUndo(); } inherited::MouseMoved(pt, code, msg); }
/*================================= GetMouseRelativeToPort ==================================*/ void SUMiscUtils::GetMouseRelativeToPort( Point *outPt ) { GrafPtr currentPort; GetPort( ¤tPort ); ThrowIfNil_( currentPort ); // should never happen GetMouse( outPt ); Rect theRect; #if PP_Target_Carbon ::GetPortBounds(currentPort, &theRect); #else theRect = currentPort->portRect; #endif outPt->h -= theRect.left; // repair SetOrigin changes outPt->v -= theRect.top; }
void RDDBIcon::MouseDown(BPoint point) { uint32 buttons=0; BPoint cursor; GetMouse(&cursor,&buttons,true); ConvertToScreen(&cursor); cursor.y--; cursor.x--; /* In the future, we may want to contact the restart_daemon and build a list of applications that requested restarting and dynamically populate the pop-up menu with these items. In theory, we could allow the restart request to be removed for any given application with a simple menu selection by the user. For now, however, we will just show the restart_daemon specific menu items. */ pop_up_menu->Go(cursor,true,false,true); }
void MouseDown(BPoint where) { (void) where; MakeFocus(); BPoint mouseWhere; ulong buttons; GetMouse(&mouseWhere, &buttons); // XXX many buttons clicked simultaneously BMessage msg(GNASH_MOUSE_CLICKED); if (B_OK != msg.AddBool("pressed", true) || B_OK != msg.AddInt32("mask", buttons)) QQ(1); else be_app_messenger.SendMessage(&msg); _pressedbuttons = buttons; }