//! Track the mouse without blocking the window
void
CPUButton::MouseDown(BPoint point)
{
	BPoint mousePosition;
	uint32 mouseButtons;

	GetMouse(&mousePosition, &mouseButtons);

	if ((B_PRIMARY_MOUSE_BUTTON & mouseButtons) != 0) {
		SetValue(!Value());
		SetTracking(true);
		SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
	} else if ((B_SECONDARY_MOUSE_BUTTON & mouseButtons) != 0
		&& fReplicantInDeskbar) {
		BPopUpMenu *menu = new BPopUpMenu(B_TRANSLATE("Deskbar menu"));
		menu->AddItem(new BMenuItem(B_TRANSLATE("About Pulse" B_UTF8_ELLIPSIS),
			new BMessage(B_ABOUT_REQUESTED)));
		menu->AddSeparatorItem();
		menu->AddItem(new BMenuItem(B_TRANSLATE("Remove replicant"),
			new BMessage(kDeleteReplicant)));
		menu->SetTargetForItems(this);

		ConvertToScreen(&point);
		menu->Go(point, true, true, true);
	}
}
Example #2
0
void
SButton::MouseDown(BPoint where)
{
	if(!IsEnabled()) return;

	BWindow *window = Window();

	if(!(window->Flags() & B_AVOID_FOCUS)) window->Activate();

	if(tooltips)
	{
		BMessage msg(S_TOOLTIPS_CHANGED);
		msg.AddBool("state", false);
		BMessenger msgr(NULL, window);
		msgr.SendMessage(&msg);
	}

	if(!waitting_is_keyboard)
	{
		waitting = true;
		DrawDefault(Bounds(), true, window->IsActive());
		SetMouseEventMask(B_POINTER_EVENTS, B_SUSPEND_VIEW_FOCUS | B_LOCK_WINDOW_FOCUS);
		window->UpdateIfNeeded();
	}
}
Example #3
0
// MouseDown
void
TestView::MouseDown(BPoint where)
{
	fTracking = true;
	fLastMousePos = where;
	SetMouseEventMask(B_POINTER_EVENTS);
}
Example #4
0
void MyView::MouseDown(BPoint where)
{
	SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
	int32		buttons;
	Looper()->CurrentMessage()->FindInt32("buttons", &buttons);
	fLastPos = where;
	if (buttons == B_PRIMARY_MOUSE_BUTTON)
	{
		fTracking = true;
		fMovingLayer = FindLayer(topLayer, where);
		if (fMovingLayer == topLayer)
			fMovingLayer = NULL;
		if (fMovingLayer)
		{
			BRect	bounds(fMovingLayer->Bounds());
			fMovingLayer->ConvertToScreen2(&bounds);
			BRect	resizeRect(bounds.right-10, bounds.bottom-10, bounds.right, bounds.bottom);
			if (resizeRect.Contains(where))
				fIsResize = true;
			else
				fIsResize = false;
		}
	}
	else if (buttons == B_SECONDARY_MOUSE_BUTTON)
	{
		fIs2ndButton = true;
	}
	else if (buttons == B_TERTIARY_MOUSE_BUTTON)
	{
		DrawSubTree(topLayer);
	}
}
Example #5
0
void ArpDocumentButton::MouseDown(BPoint point)
{
	ArpD(cdb << ADH << "Mouse down received." << endl);
	
	BMessage* msg = Window()->CurrentMessage();
	if( !msg ) return;
	int32 button=0;
	msg->FindInt32("buttons",&button);
	
	SetMouseEventMask(B_POINTER_EVENTS | B_KEYBOARD_EVENTS);
	mAction = ButtonPressed;
	mPressed = IsPointIn(point);
	
#if 0		// popup menu not currently implemented
	if( button == B_PRIMARY_MOUSE_BUTTON ) {
		
	} else {
		mAction = MenuPopped;
		mMenued = true;

	}
#endif
	
	Invalidate();
}
Example #6
0
void ResizeView::MouseDown(BPoint)
{
	SetMouseEventMask(B_POINTER_EVENTS,
					  B_LOCK_WINDOW_FOCUS | B_SUSPEND_VIEW_FOCUS | B_NO_POINTER_HISTORY);
	mousePressed = true;
	vision_app->SetCursor(&cursor);
}
Example #7
0
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);
		}
	}
}
Example #8
0
//--------------------------------------------------------------------
void InterView::MouseDown(BPoint point)
{
	BMenuItem *selected;
	BPoint cursor;
	uint32 buttons;

	GetMouse(&cursor, &buttons, false);

	if (buttons & B_PRIMARY_MOUSE_BUTTON)
	{
		mouseDown = true;
		mouseCoord = point;
		SetMouseEventMask(B_POINTER_EVENTS,B_LOCK_WINDOW_FOCUS);
//		be_app->SetCursor(B_I_BEAM_CURSOR);
	}

	if (buttons & B_SECONDARY_MOUSE_BUTTON)
	{
		ConvertToScreen(&point);
		selected = menu->Go(point);
		if ( selected && (selected->Message() != NULL))
			if (selected->Message()->what == MSG_ZOOM_IN)
				ZoomIn();
			else if (selected->Message()->what == MSG_ZOOM_OUT)
				ZoomOut();
			else
				msgDest->PostMessage(selected->Message());
 	}

	if (buttons & B_TERTIARY_MOUSE_BUTTON)
	{
		((InterApp*)be_app)->theWin->SwapFullScreenNoMenu();
	}
}
Example #9
0
void
BButton::MouseDown(BPoint point)
{
	if (!IsEnabled())
		return;

	SetValue(B_CONTROL_ON);

	if (Window()->Flags() & B_ASYNCHRONOUS_CONTROLS) {
 		SetTracking(true);
 		SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
 	} else {
		BRect bounds = Bounds();
		uint32 buttons;

		do {
			Window()->UpdateIfNeeded();
			snooze(40000);

			GetMouse(&point, &buttons, true);

 			bool inside = bounds.Contains(point);

			if ((Value() == B_CONTROL_ON) != inside)
				SetValue(inside ? B_CONTROL_ON : B_CONTROL_OFF);
		} while (buttons != 0);

		if (Value() == B_CONTROL_ON)
			Invoke();
	}
}
Example #10
0
void
MemoryView::MouseDown(BPoint point)
{
	if (!IsFocus())
		MakeFocus(true);

	if (fTargetBlock == NULL)
		return;

	int32 buttons;
	if (Looper()->CurrentMessage()->FindInt32("buttons", &buttons) != B_OK)
		buttons = B_PRIMARY_MOUSE_BUTTON;

	if (buttons == B_SECONDARY_MOUSE_BUTTON) {
		_HandleContextMenu(point);
		return;
	}

	int32 offset = _GetOffsetAt(point);
	if (offset < fSelectionStart || offset > fSelectionEnd) {
		BRegion oldSelectionRegion;
		_GetSelectionRegion(oldSelectionRegion);
		fSelectionBase = offset;
		fSelectionStart = fSelectionBase;
		fSelectionEnd = fSelectionBase;
		Invalidate(oldSelectionRegion.Frame());
	}

	SetMouseEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY);
	fTrackingMouse = true;
}
Example #11
0
void CollapsableBox::MouseDown(BPoint where)
{
	if (!IsEnabled())
		return;

	Window()->Activate();

	uint32 buttons;
	
	GetMouse(&where, &buttons);
	if ((buttons & B_PRIMARY_MOUSE_BUTTON) == 0)
		return;
		
	if (! m_collapsed_rect.Contains(where))
		return;
	
	m_click = where;
	SetMouseEventMask(B_POINTER_EVENTS,
		B_SUSPEND_VIEW_FOCUS | B_LOCK_WINDOW_FOCUS | B_NO_POINTER_HISTORY);
	SetTracking(true);
		
	m_pressing = true;
	Draw(Bounds());
	Flush();
}
Example #12
0
void
CStatusBar::MouseDown(
	BPoint point)
{
	D_HOOK(("CStatusBar::MouseDown()\n"));

	if ((m_scrollBar == NULL) || !Window()->IsActive())
		return;

	int32 buttons;
	if (Window()->CurrentMessage()->FindInt32("buttons", &buttons) != B_OK)
		buttons = B_PRIMARY_MOUSE_BUTTON;

	if (buttons == B_PRIMARY_MOUSE_BUTTON)
	{
		// drag rect
		BRect dragRect(Bounds());
		dragRect.left = dragRect.right - 10.0;
		if (dragRect.Contains(point))
		{
			// resize
			m_dragging = true;
			SetMouseEventMask(B_POINTER_EVENTS,
							  B_LOCK_WINDOW_FOCUS | B_NO_POINTER_HISTORY);
		}
	}
}
Example #13
0
void BHSplitter::MouseDown(BPoint where)
{
	drag=1;
	SetMouseEventMask(B_POINTER_EVENTS,B_NO_POINTER_HISTORY);
	//be_app->SetCursor(c_h_resize_cursor_data);
	Invalidate();
}
Example #14
0
void
FieldView::MouseDown(BPoint pt)
{
	if (fPauseMode || gGameState == GAME_OVER)
		return;

	SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
	fTracking = true;

	GetMouse(&pt, &fButtons, true);
	if (gGameState == GAME_STOPPED)
	{
		Window()->PostMessage(M_START_TIMER);
		IntPoint tilePt;
		BRect r(gGameStyle->TileSize());
		tilePt.x = uint16(pt.x / (r.Width() + 1.0));
		tilePt.y = uint16(pt.y / (r.Height() + 1.0));

		if (fButtons == B_PRIMARY_MOUSE_BUTTON)
			fField->TeleportMine(tilePt);
		Invalidate();
	}
	if (gPlaySounds && gGameState != GAME_OVER)
		fClickPlayer->StartPlaying();

	SelectTile(pt);
	fMainWin->SetFace(FACE_WORRY);
}
Example #15
0
void DragonView::MouseDown( BPoint where )
{
	BMessage *current_msg = Window()->CurrentMessage();
	uint32 buttons = current_msg->FindInt32( "buttons" );
	uint32 mod_keys = current_msg->FindInt32( "modifiers" );

	// We're only going to allow a drag when the primary mouse button is
	// down, and no modifiers are down.  If a different button is being
	// used or any of the modifiers are pressed, we return without doing
	// anything.
	
	if( buttons != B_PRIMARY_MOUSE_BUTTON || mod_keys != 0 ) return;

	// Ok, the mouse is down, so we need to take note of the click location;
	// this will let us check for dragging movement in our MouseMoved().

	_button_down = true;
	_button_click = where;

	// Turn on the event mask for all pointer events, so we'll know when
	// the user lets go of the mouse button.

	if( SetMouseEventMask( B_POINTER_EVENTS, 0 ) != B_OK ) {
		// That's bad... but unlikely.
		return;
	}
}
Example #16
0
void SeqSplitterView::MouseDown(BPoint where)
{
	mMouseDown = true;
	mPointDown = ConvertToScreen( where );
	mFrameDown = Frame();
	SetMouseEventMask( B_POINTER_EVENTS,
					   B_LOCK_WINDOW_FOCUS|B_SUSPEND_VIEW_FOCUS|B_NO_POINTER_HISTORY );
}
Example #17
0
void
BitmapButton::MouseDown(BPoint where)
{
	if (fMouseInside) {
		_SetMouseDown(true);
		SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
	}
}
Example #18
0
void
CalcView::MouseDown(BPoint point)
{
	// ensure this view is the current focus
	if (!fExpressionTextView->IsFocus()) {
		// Call our version of MakeFocus(), since that will also apply the
		// num_lock setting.
		MakeFocus();
	}

	// read mouse buttons state
	int32 buttons = 0;
	Window()->CurrentMessage()->FindInt32("buttons", &buttons);

	if ((B_PRIMARY_MOUSE_BUTTON & buttons) == 0) {
		// display popup menu if not primary mouse button
		BMenuItem* selected;
		if ((selected = fPopUpMenu->Go(ConvertToScreen(point))) != NULL
			&& selected->Message() != NULL) {
			Window()->PostMessage(selected->Message(), this);
		}
		return;
	}

	if (fOptions->keypad_mode == KEYPAD_MODE_COMPACT) {
		if (fCalcIcon != NULL) {
			BRect bounds(Bounds());
			bounds.left = bounds.right - fCalcIcon->Bounds().Width();
			if (bounds.Contains(point)) {
				// user clicked on calculator icon
				fExpressionTextView->Clear();
			}
		}
		return;
	}

	// calculate grid sizes
	float sizeDisp = fHeight * kDisplayScaleY;
	float sizeCol = fWidth / (float)fColumns;
	float sizeRow = (fHeight - sizeDisp) / (float)fRows;

	// calculate location within grid
	int gridCol = (int)floorf(point.x / sizeCol);
	int gridRow = (int)floorf((point.y - sizeDisp) / sizeRow);

	// check limits
	if ((gridCol >= 0) && (gridCol < fColumns)
		&& (gridRow >= 0) && (gridRow < fRows)) {

		// process key press
		int key = gridRow * fColumns + gridCol;
		_FlashKey(key, FLAGS_MOUSE_DOWN);
		_PressKey(key);

		// make sure we receive the mouse up!
		SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
	}
}
Example #19
0
void
View::MouseDown(BPoint where)
{
	SetMouseEventMask(0, B_LOCK_WINDOW_FOCUS | B_SUSPEND_VIEW_FOCUS
		| B_NO_POINTER_HISTORY);

	::Window* window = new ::Window(100);
	window->Show();
}
Example #20
0
void
BButton::MouseDown(BPoint point)
{
	if (!IsEnabled())
		return;

	if (fBehavior == B_POP_UP_BEHAVIOR && _PopUpRect().Contains(point)) {
		InvokeNotify(fPopUpMessage, B_CONTROL_MODIFIED);
		return;
	}

	bool toggleBehavior = fBehavior == B_TOGGLE_BEHAVIOR;

	if (toggleBehavior) {
		bool wasPressed = Value() == B_CONTROL_ON;
		_SetFlag(FLAG_WAS_PRESSED, wasPressed);
		SetValue(wasPressed ? B_CONTROL_OFF : B_CONTROL_ON);
		Invalidate();
	} else
		SetValue(B_CONTROL_ON);

	if (Window()->Flags() & B_ASYNCHRONOUS_CONTROLS) {
 		SetTracking(true);
 		SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
 	} else {
		BRect bounds = Bounds();
		uint32 buttons;
		bool inside = false;

		do {
			Window()->UpdateIfNeeded();
			snooze(40000);

			GetMouse(&point, &buttons, true);

 			inside = bounds.Contains(point);

			if (toggleBehavior) {
				bool pressed = inside ^ _Flag(FLAG_WAS_PRESSED);
				SetValue(pressed ? B_CONTROL_ON : B_CONTROL_OFF);
			} else {
				if ((Value() == B_CONTROL_ON) != inside)
					SetValue(inside ? B_CONTROL_ON : B_CONTROL_OFF);
			}
		} while (buttons != 0);

		if (inside) {
			if (toggleBehavior) {
				SetValue(
					_Flag(FLAG_WAS_PRESSED) ? B_CONTROL_OFF : B_CONTROL_ON);
			}

			Invoke();
		} else if (_Flag(FLAG_FLAT))
			Invalidate();
	}
}
Example #21
0
// MouseDown
void
ObjectView::MouseDown(BPoint where)
{
	uint32 buttons;
	int32 clicks;
//
//	snooze(1000000);
//	BMessageQueue* queue = Window()->MessageQueue();
//	BMessage* msg;
//	int32 count = 0;
//	for (int32 i = 0; (msg = queue->FindMessage(i)); i++) {
//		if (msg->what == B_MOUSE_MOVED)
//			count++;
//	}
//	printf("B_MOUSE_MOVED count before GetMouse(): %ld\n", count);
//
//	GetMouse(&where, &buttons);
//
//	count = 0;
//	for (int32 i = 0; (msg = queue->FindMessage(i)); i++) {
//		if (msg->what == B_MOUSE_MOVED)
//			count++;
//	}
//	printf("B_MOUSE_MOVED count after 1st GetMouse(): %ld\n", count);
//
//	GetMouse(&where, &buttons);
//
//	count = 0;
//	for (int32 i = 0; (msg = queue->FindMessage(i)); i++) {
//		if (msg->what == B_MOUSE_MOVED)
//			count++;
//	}
//	printf("B_MOUSE_MOVED count after 2nd GetMouse(): %ld\n", count);
//	return;

//be_app->HideCursor();

	Window()->CurrentMessage()->FindInt32("buttons", (int32*)&buttons);
	Window()->CurrentMessage()->FindInt32("clicks", &clicks);
//printf("ObjectView::MouseDown() - clicks: %ld\n", clicks);
	fInitiatingDrag = buttons & B_SECONDARY_MOUSE_BUTTON;
	fScrolling = !fInitiatingDrag && (buttons & B_TERTIARY_MOUSE_BUTTON);

	SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);

	if (fScrolling  || fInitiatingDrag) {
		fLastMousePos = where;
	} else {
		if (!fState)
			AddObject(State::StateFor(fObjectType, fColor, fDrawingMode,
									  fFill, fPenSize));
	
		if (fState) {
			fState->MouseDown(where);
		}
	}
}
Example #22
0
// MouseDown
void
VolumeSlider::MouseDown(BPoint where)
{
	if (Bounds().Contains(where) && IsEnabled()) {
		fTracking = true;
		SetValue(_ValueFor(where.x));
		SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
	}
}
// MouseDown
void
ColorSlider::MouseDown(BPoint where)
{
	Window()->Activate();
	
	SetMouseEventMask(B_POINTER_EVENTS, B_SUSPEND_VIEW_FOCUS | B_LOCK_WINDOW_FOCUS);
	_TrackMouse(where);
	fMouseDown = true;
}
void
BSplitView::MouseDown(BPoint where)
{
	SetMouseEventMask(B_POINTER_EVENTS,
		B_LOCK_WINDOW_FOCUS | B_SUSPEND_VIEW_FOCUS);

	if (fSplitLayout->StartDraggingSplitter(where))
		Invalidate();
}
Example #25
0
// init mouse tracking
void
ValControlSegment::trackMouse(BPoint point, track_flags flags)
{
	fTrackFlags = flags;
	fPrevPoint = point;
	setTracking(true);
	SetMouseEventMask(B_POINTER_EVENTS,
		B_LOCK_WINDOW_FOCUS | B_NO_POINTER_HISTORY);
}
void PatternTrashButton::MouseDown(BPoint where) {
	
	if (!IsEnabled()) return;
	
	fMousePressed = true;
	Update();
	
	SetMouseEventMask(B_POINTER_EVENTS, B_SUSPEND_VIEW_FOCUS|B_LOCK_WINDOW_FOCUS );

};
void PatternNrButton::MouseDown(BPoint where) {
	
	if (!IsEnabled()) return;
	
	SetValue( FindButtonNr( where ) );
	fMousePressed = true;
	
	SetMouseEventMask(B_POINTER_EVENTS, B_SUSPEND_VIEW_FOCUS|B_LOCK_WINDOW_FOCUS );

};
Example #28
0
void KnobSwitch::MouseUp( BPoint where ) 
{ 
        fPressing = false; 
        SetMouseEventMask( 0, 0 ); 
        State state = StateForPosition(where); 
        if (!fMovedSinceClick || state != fStateWhenPressed) { 
                SetValue(!Value()); 
                Invoke(); 
        } 
} 
Example #29
0
void
VolumeSlider::MouseDown(BPoint point)
{
	if (!fSoundPlayer || !Bounds().InsetBySelf(2,2).Contains(point))
		return;

	_UpdateVolume(point);
	SetTracking(true);
	SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
}
Example #30
0
void
ColorField::MouseDown(BPoint where)
{
	Window()->Activate();

	fMouseDown = true;
	SetMouseEventMask(B_POINTER_EVENTS,
		B_SUSPEND_VIEW_FOCUS | B_LOCK_WINDOW_FOCUS);
	PositionMarkerAt(where);
	Invoke();
}