Exemplo n.º 1
0
// _Select
void
PathManipulator::_Select(BRect r)
{
	BPoint p;
	BPoint pIn;
	BPoint pOut;
	int32 count = fPath->CountPoints();
	Selection temp;
	for (int32 i = 0; i < count && fPath->GetPointsAt(i, p, pIn, pOut); i++) {
		if (r.Contains(p) || r.Contains(pIn) || r.Contains(pOut)) {
			temp.Add(i);
		}
	}
	// merge old and new selection
	count = fOldSelection->CountItems();
	for (int32 i = 0; i < count; i++) {
		int32 index = fOldSelection->IndexAt(i);
		if (temp.Contains(index))
			temp.Remove(index);
		else
			temp.Add(index);
	}
	if (temp != *fSelection) {
		*fSelection = temp;
		_UpdateSelection();
	}
}
Exemplo n.º 2
0
bool
PatchView::GetToolTipAt(BPoint point, BToolTip** tip)
{
	bool found = false;
	int32 index = 0;
	endpoint_itor begin, end;
	int32 size = fConsumers.size();
	for (int32 i = 0; !found && i < size; i++) {
		BRect r = ColumnIconFrameAt(i);
		if (r.Contains(point)) {
			begin = fConsumers.begin();
			end = fConsumers.end();
			found = true;
			index = i;
		}
	}
	size = fProducers.size();
	for (int32 i = 0; !found && i < size; i++) {
		BRect r = RowIconFrameAt(i);
		if (r.Contains(point)) {
			begin = fProducers.begin();
			end = fProducers.end();
			found = true;
			index = i;
		}
	}
	
	if (!found)
		return false;

	endpoint_itor itor;
	for (itor = begin; itor != end; itor++, index--)
		if (index <= 0)
			break;
	
	if (itor == end)
		return false;

	BMidiRoster* roster = BMidiRoster::MidiRoster();
	if (roster == NULL)
		return false;
	BMidiEndpoint* obj = roster->FindEndpoint(itor->ID());
	if (obj == NULL)
		return false;

	BString str;
	str << "<" << obj->ID() << ">: " << obj->Name();
	obj->Release();

	SetToolTip(str.String());

	*tip = ToolTip();

	return true;
}
Exemplo n.º 3
0
/*****************************************************************************
 * PlaylistView::MouseDown
 *****************************************************************************/
void
PlaylistView::MouseDown( BPoint where )
{
    int32 clicks = 1;
    Window()->CurrentMessage()->FindInt32( "clicks", &clicks );
    bool handled = false;
    for ( int32 i = 0; PlaylistItem* item = (PlaylistItem*)ItemAt( i ); i++ )
    {
        BRect r = ItemFrame( i );
        if ( r.Contains( where ) )
        {
            if ( clicks == 2 )
            {
                // only do something if user clicked the same item twice
                if ( fLastClickedItem == item )
                {
                    playlist_t * p_playlist;
                    p_playlist = (playlist_t *) vlc_object_find( p_intf,
                        VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
                    if( p_playlist )
                    {
                        playlist_Goto( p_playlist, i );
                        vlc_object_release( p_playlist );
                    }
                    handled = true;
                }
            }
            else
            {
                // remember last clicked item
                fLastClickedItem = item;
                if ( i == fCurrentIndex )
                {
                    r.right = r.left + TEXT_OFFSET;
                    if ( r.Contains ( where ) )
                    {
                        fMainWindow->PostMessage( PAUSE_PLAYBACK );
                        InvalidateItem( i );
                        handled = true;
                    }
                }
            }
            break;
        }
    }
    if ( !handled )
        DragSortableListView::MouseDown(where);
}
Exemplo n.º 4
0
bool
BPose::PointInPose(BPoint loc, const BPoseView* poseView, BPoint where,
	BTextWidget** hitWidget) const
{
	if (hitWidget)
		*hitWidget = NULL;

	// check intersection with icon
	BRect rect;
	rect.left = loc.x + kListOffset;
	rect.right = rect.left + B_MINI_ICON;
	rect.bottom = loc.y + poseView->ListElemHeight();
	rect.top = rect.bottom - B_MINI_ICON;
	if (rect.Contains(where))
		return true;

	for (int32 index = 0; ; index++) {
		BColumn* column = poseView->ColumnAt(index);
		if (column == NULL)
			break;
		BTextWidget* widget = WidgetFor(column->AttrHash());
		if (widget
			&& widget->CalcClickRect(loc, column, poseView).Contains(where)) {
			if (hitWidget)
				*hitWidget = widget;
			return true;
		}
	}

	return false;
}
Exemplo n.º 5
0
void
BRadioButton::MouseDown(BPoint where)
{
	if (!IsEnabled() || !QueryCurrentMouse(true, B_PRIMARY_MOUSE_BUTTON)) return;

#if 0
	font_height fontHeight;
	GetFontHeight(&fontHeight);
	float sHeight = fontHeight.ascent + fontHeight.descent;

	BRect rect = Frame().OffsetToSelf(B_ORIGIN);
	rect.InsetBy(5, (rect.Height() - sHeight) / 2);
	if (rect.IsValid() == false) return;
	rect.right = rect.left + rect.Height();
	if (rect.Contains(where) == false) return;
#endif

	if ((Flags() &B_NAVIGABLE) && !IsFocus()) MakeFocus();

//	SetValue((Value() == B_CONTROL_ON) ?B_CONTROL_OFF :B_CONTROL_ON);

	if (Value() == B_CONTROL_ON) return;
	SetValue(B_CONTROL_ON);

	Invoke();
}
Exemplo n.º 6
0
BView *
DTipWatcherView::ViewForPoint(BPoint pt)
{
	int32 winIndex = 0;
	
	BView *view = NULL;
	BWindow *win = be_app->WindowAt(winIndex++);
	while (win)
	{
		// Took a hint from Marco Nelissen's BubbleHelper -- the app may have a window that isn't running
		// lying around
		if (!win->IsHidden() && win->LockWithTimeout(1000000) == B_OK)
		{
			BRect r = win->Frame();
			if (r.Contains(pt))
			{
				BPoint winpt(pt.x - r.left, pt.y - r.top);
				view = win->FindView(winpt);
			}
			win->Unlock();
		}
		
		if (view)
			break;
		win = be_app->WindowAt(winIndex++);
	}
	
	return view;
}
Exemplo n.º 7
0
void
TBarView::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage)
{
	if (fDragRegion->IsDragging()) {
		fDragRegion->MouseMoved(where, transit, dragMessage);
		return;
	}

	if (transit == B_ENTERED_VIEW && EventMask() == 0)
		SetEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY);

	desk_settings* settings = ((TBarApp*)be_app)->Settings();
	bool alwaysOnTop = settings->alwaysOnTop;
	bool autoRaise = settings->autoRaise;
	bool autoHide = settings->autoHide;

	if (!autoRaise && !autoHide) {
		if (transit == B_EXITED_VIEW || transit == B_OUTSIDE_VIEW)
			SetEventMask(0);
		return;
	}

	bool isTopMost = Window()->Feel() == B_FLOATING_ALL_WINDOW_FEEL;

	// Auto-Raise
	where = ConvertToScreen(where);
	BRect screenFrame = (BScreen(Window())).Frame();
	if ((where.x == screenFrame.left || where.x == screenFrame.right
			|| where.y == screenFrame.top || where.y == screenFrame.bottom)
		&& Window()->Frame().Contains(where)) {
		// cursor is on a screen edge within the window frame

		if (!alwaysOnTop && autoRaise && !isTopMost)
			RaiseDeskbar(true);

		if (autoHide && IsHidden())
			HideDeskbar(false);

	} else {
		TBarWindow* window = (TBarWindow*)Window();
		if (window->IsShowingMenu())
			return;

		// cursor is not on screen edge
		BRect preventHideArea = Window()->Frame().InsetByCopy(
			-kMaxPreventHidingDist, -kMaxPreventHidingDist);

		if (preventHideArea.Contains(where))
			return;

		// cursor to bar distance above threshold
		if (!alwaysOnTop && autoRaise && isTopMost) {
			RaiseDeskbar(false);
			SetEventMask(0);
		}

		if (autoHide && !IsHidden())
			HideDeskbar(true);
	}
}
Exemplo n.º 8
0
void
WorkspacesView::MouseMoved(BPoint where, uint32 transit,
	const BMessage* dragMessage)
{
	WorkspacesWindow* window = dynamic_cast<WorkspacesWindow*>(Window());
	if (window == NULL || !window->IsAutoRaising())
		return;

	// Auto-Raise

	where = ConvertToScreen(where);
	BScreen screen(window);
	BRect screenFrame = screen.Frame();
	BRect windowFrame = window->Frame();
	float tabHeight = window->GetTabHeight();
	float borderWidth = window->GetBorderWidth();

	if (where.x == screenFrame.left || where.x == screenFrame.right
			|| where.y == screenFrame.top || where.y == screenFrame.bottom) {
		// cursor is on screen edge

		// Stretch frame to also accept mouse moves over the window borders
		windowFrame.InsetBy(-borderWidth, -(tabHeight + borderWidth));

		if (windowFrame.Contains(where))
			window->Activate();
	}
}
Exemplo n.º 9
0
status_t
BDragger::_DetermineRelationship()
{
	if (fTarget) {
		if (fTarget == Parent())
			fRelation = TARGET_IS_PARENT;
		else if (fTarget == ChildAt(0))
			fRelation = TARGET_IS_CHILD;
		else
			fRelation = TARGET_IS_SIBLING;
	} else {
		if (fRelation == TARGET_IS_PARENT)
			fTarget = Parent();
		else if (fRelation == TARGET_IS_CHILD)
			fTarget = ChildAt(0);
		else
			return B_ERROR;
	}

	if (fRelation == TARGET_IS_PARENT) {
		BRect bounds (Frame());
		BRect parentBounds (Parent()->Bounds());
		if (!parentBounds.Contains(bounds))
			MoveTo(parentBounds.right - bounds.Width(),
				parentBounds.bottom - bounds.Height());
	}

	return B_OK;
}
Exemplo n.º 10
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();
	}
}
Exemplo n.º 11
0
void
CaptureView::MouseMoved(BPoint point, uint32 transit,
	const BMessage* dragMessage)
{
	ConvertToScreen(&point);

	if (fMovedOutWhat != 0 && !fMovedOutFrame.Contains(point))
		_SendMovedOutNotification();

	uint32 modifiers = ::modifiers();
	if ((modifiers & fModifierMask) == 0) {
		_UpdateLast(point);
		return;
	}

	// TODO: we will need to iterate over all existing screens to find the
	// right one!
	BScreen screen;
	BRect screenFrame = screen.Frame();

	uint32 location = kNowhere;
	if (point.x <= screenFrame.left && fLastPoint.x > screenFrame.left)
		location = kLeftEdge;
	else if (point.x >= screenFrame.right && fLastPoint.x < screenFrame.right)
		location = kRightEdge;
	else if (point.y <= screenFrame.top && fLastPoint.y > screenFrame.top)
		location = kTopEdge;
	else if (point.y >= screenFrame.bottom && fLastPoint.y < screenFrame.bottom)
		location = kBottomEdge;

	if (location != kNowhere)
		_Notify(location, fLastTeam);

	_UpdateLast(point);
}
Exemplo n.º 12
0
int RegionTestcase::GetPointsInRect(BRect theRect, BPoint **pointArrayPtr)
{
	*pointArrayPtr = pointArray;
	if (!theRect.IsValid()) {
		return(0);
	}
	
	float xIncrement = (theRect.Width() + 1.0) / (numPointsPerSide - 1);
	float yIncrement = (theRect.Height() + 1.0) / (numPointsPerSide - 1);
	
	int numPoints = 0;
	
	for(int i = 0; i < numPointsPerSide; i++) {
		float xCoord = theRect.left + (i * xIncrement);
		if (i == numPointsPerSide - 1) {
			xCoord = theRect.right;
		}
		for(int j = 0; j < numPointsPerSide; j++) {
			float yCoord = theRect.top + (j * yIncrement);
			if (j == numPointsPerSide - 1) {
				yCoord = theRect.bottom;
			}
			pointArray[numPoints].Set(floor(xCoord), floor(yCoord));
			assert(theRect.Contains(pointArray[numPoints]));
			numPoints++;
		}
	}
	return(numPoints); 
}
Exemplo n.º 13
0
bool
make_sure_frame_is_on_screen(BRect& frame, BWindow* window)
{
	BScreen* screen = window != NULL ? new BScreen(window)
		: new BScreen(B_MAIN_SCREEN_ID);

	bool success = false;
	if (frame.IsValid() && screen->IsValid()) {
		BRect screenFrame = screen->Frame();
		if (!screenFrame.Contains(frame)) {
			// make sure frame fits in the screen
			if (frame.Width() > screenFrame.Width())
				frame.right -= frame.Width() - screenFrame.Width() + 10.0;
			if (frame.Height() > screenFrame.Height())
				frame.bottom -= frame.Height() - screenFrame.Height() + 30.0;
			// frame is now at the most the size of the screen
			if (frame.right > screenFrame.right)
				frame.OffsetBy(-(frame.right - screenFrame.right), 0.0);
			if (frame.bottom > screenFrame.bottom)
				frame.OffsetBy(0.0, -(frame.bottom - screenFrame.bottom));
			if (frame.left < screenFrame.left)
				frame.OffsetBy((screenFrame.left - frame.left), 0.0);
			if (frame.top < screenFrame.top)
				frame.OffsetBy(0.0, (screenFrame.top - frame.top));
		}
		success = true;
	}
	delete screen;
	return success;
}
Exemplo n.º 14
0
void DormantNodeView::MouseMoved(
	BPoint point,
	uint32 transit,
	const BMessage *message) {
	D_HOOK(("DormantNodeView::MouseMoved()\n"));

	int32 index;
	if (!message && ((index = IndexOf(point)) >= 0)) {
		DormantNodeListItem *item = dynamic_cast<DormantNodeListItem *>(ItemAt(index));
		DormantNodeListItem *last = dynamic_cast<DormantNodeListItem *>(m_lastItemUnder);
		BRect r = item->getRealFrame(be_plain_font);
		if (item && r.Contains(point)) {
			if (item != last) {
				if (last)
					last->MouseOver(this, point, B_EXITED_VIEW);
				item->MouseOver(this, point, B_ENTERED_VIEW);
				m_lastItemUnder = item;
			}
			else {
				item->MouseOver(this, point, B_INSIDE_VIEW);
			}
		}
		else if (last) {
			last->MouseOver(this, point, B_EXITED_VIEW);
		}
	}
	
	_inherited::MouseMoved(point, transit, message);
}
Exemplo n.º 15
0
void
Utility::_MakeTabSpaceTransparent(BBitmap* screenshot, BRect frame) const
{
	if (!frame.IsValid() || screenshot->ColorSpace() != B_RGBA32)
		return;

	if (!frame.Contains(tabFrame))
		return;

	float tabHeight = tabFrame.bottom - tabFrame.top;

	BRegion tabSpace(frame);
	frame.OffsetBy(0, tabHeight);
	tabSpace.Exclude(frame);
	tabSpace.Exclude(tabFrame);
	frame.OffsetBy(0, -tabHeight);
	tabSpace.OffsetBy(-frame.left, -frame.top);
	BScreen screen;
	BRect screenFrame = screen.Frame();
	tabSpace.OffsetBy(-screenFrame.left, -screenFrame.top);

	BView view(screenshot->Bounds(), "bitmap", B_FOLLOW_ALL_SIDES, 0);
	screenshot->AddChild(&view);
	if (view.Looper() && view.Looper()->Lock()) {
		view.SetDrawingMode(B_OP_COPY);
		view.SetHighColor(B_TRANSPARENT_32_BIT);

		for (int i = 0; i < tabSpace.CountRects(); i++)
			view.FillRect(tabSpace.RectAt(i));

		view.Sync();
		view.Looper()->Unlock();
	}
	screenshot->RemoveChild(&view);
}
Exemplo n.º 16
0
BView* BubbleHelper::FindView(BPoint where)
{
	BView* winview = NULL;
	BWindow* win;
	long windex = 0;
	while ((winview == NULL) && ((win = be_app->WindowAt(windex++)) != NULL)) {
		if (win != textwin) {
			// lock with timeout, in case somebody has a non-running window around
			// in their app.
			if (win->LockWithTimeout(1E6) == B_OK) {
				BRect frame = win->Frame();
				if (frame.Contains(where)) {
					BPoint winpoint;
					winpoint = where - frame.LeftTop();
					winview = win->FindView(winpoint);
					if (winview) {
						BRegion region;
						BPoint newpoint = where;
						winview->ConvertFromScreen(&newpoint);
						winview->GetClippingRegion(&region);
						if (!region.Contains(newpoint)) winview = 0;
					}
				}
				win->Unlock();
			}
		}
	}
	return winview;
}
Exemplo n.º 17
0
void BitmapView::MouseUp( BPoint cPosition )
{
	BMessage pcData((uint32)0);

	m_bCanDrag = false;

	BFont* pcFont = GetFont();
	if ( m_bSelRectActive )
	{
		SetDrawingMode( B_OP_INVERT );
		DrawFrame( m_cSelRect, FRAME_TRANSPARENT | FRAME_THIN );
		m_bSelRectActive = false;

		if ( m_cSelRect.left > m_cSelRect.right )
		{
			float nTmp = m_cSelRect.left;
			m_cSelRect.left = m_cSelRect.right;
			m_cSelRect.right = nTmp;
		}

		if ( m_cSelRect.top > m_cSelRect.bottom )
		{
			float nTmp = m_cSelRect.top;
			m_cSelRect.top = m_cSelRect.bottom;
			m_cSelRect.bottom = nTmp;
		}

		for ( uint i = 0 ; i < m_cIcons.size() ; ++i )
		{
			m_cIcons[i]->Select( this, m_cSelRect.Contains( m_cIcons[i]->GetFrame( pcFont ) ) );
		}
		Flush();
	}
	else if ( Window()->CurrentMessage()->FindMessage( "_drag_message", &pcData ) == B_OK )
	{
		if (pcData.ReturnAddress() == BMessenger( this ))
		{
			BPoint cHotSpot;
			pcData.FindPoint( "_hot_spot", &cHotSpot );

			for ( uint i = 0 ; i < m_cIcons.size() ; ++i )
			{
				BRect cFrame = m_cIcons[i]->GetFrame( pcFont );
				Erase( cFrame );
			}
			Flush();
			for ( uint i = 0 ; i < m_cIcons.size() ; ++i )
			{
				if ( m_cIcons[i]->m_bSelected )
				{
					m_cIcons[i]->m_cPosition += cPosition - m_cDragStartPos;
				}
				m_cIcons[i]->Draw( this, BPoint(0,0), true, true );
			}
			Flush();
		}
	}
}
Exemplo n.º 18
0
BRect
FitRectToScreen(BRect source)
{
	// This function returns the source moved and resized so that it fits onto
	// current screen.
	BRect result = source;
	BRect screenFrame = BScreen().Frame();

	if (!screenFrame.Contains(result.RightBottom()))
		result.OffsetTo(BPoint(15.0, 15.0));

	if (!screenFrame.Contains(result.RightBottom())) {
		result.bottom = min_c(screenFrame.bottom, result.bottom);
		result.right = min_c(screenFrame.right, result.right);
	}

	return result;
}
Exemplo n.º 19
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();
	}
}
Exemplo n.º 20
0
// CenterWindowOnScreen -- Centers the BWindow to the Current Screen
static void CenterWindowOnScreen(BWindow* w)
{
	BRect	screenFrame = (BScreen(B_MAIN_SCREEN_ID).Frame());	BPoint	pt;
	pt.x = screenFrame.Width()/2 - w->Bounds().Width()/2;
	pt.y = screenFrame.Height()/2 - w->Bounds().Height()/2;

	if (screenFrame.Contains(pt))
		w->MoveTo(pt);
}
Exemplo n.º 21
0
void
PlaylistListView::MouseDown(BPoint where)
{
    if (!IsFocus())
        MakeFocus(true);

    int32 clicks;
    if (Window()->CurrentMessage()->FindInt32("clicks", &clicks) < B_OK)
        clicks = 1;

    bool handled = false;

    float playbackMarkSize = playback_mark_size(fFontHeight);
    float textOffset = text_offset(fFontHeight);

    for (int32 i = 0;
            Item* item = dynamic_cast<Item*>(ItemAt(i)); i++) {
        BRect r = ItemFrame(i);
        if (r.Contains(where)) {
            if (clicks == 2) {
                // only do something if user clicked the same item twice
                if (fLastClickedItem == item) {
                    BAutolock _(fPlaylist);
                    fPlaylist->SetCurrentItemIndex(i);
                    handled = true;
                }
            } else {
                // remember last clicked item
                fLastClickedItem = item;
                if (i == fCurrentPlaylistIndex) {
                    r.right = r.left + playbackMarkSize + textOffset;
                    if (r.Contains (where)) {
                        fController->TogglePlaying();
                        handled = true;
                    }
                }
            }
            break;
        }
    }

    if (!handled)
        SimpleListView::MouseDown(where);
}
Exemplo n.º 22
0
void RegionTestcase::CheckFrame(BRegion *theRegion)
{
	BRect theFrame = theRegion->Frame();
	if (theFrame.IsValid()) {
		assert(!RegionIsEmpty(theRegion));

		BRect testFrame = theRegion->RectAt(0);
		assert(theFrame.Contains(testFrame));
		
		for(int i = 1; i < theRegion->CountRects(); i++) {
			BRect tempRect = theRegion->RectAt(i);
			assert(theFrame.Contains(tempRect));
			testFrame = testFrame | tempRect;
		}
		assert(testFrame == theFrame);	
	} else {
		assert(RegionIsEmpty(theRegion));
	}
}
void
CheckBoxItem::MouseDown(BPoint where)
{
	if (!fBoxRect.Contains(where))
		return;

	fMouseDown = true;

	fListView->InvalidateItem(fListView->IndexOf(this));
}
Exemplo n.º 24
0
void TElementsView::MouseDown(BPoint where)
{
	// Check and see if we are in our DragRect
	BRect dragRect;
	GetDragRect(&dragRect);

	if ( dragRect.Contains(where) ) {
		StartMouseWatcher(this);
	}

}
Exemplo n.º 25
0
void
BTextWidget::MouseUp(BRect bounds, BPoseView *view, BPose *pose, BPoint)
{
	// Start editing without delay if the pose was selected recently and this
	// click is not the second click of a doubleclick.
	// If the pose has been selected a long time ago, check again
	// for a double click (inducing a delay).

	// TODO: re-enable modifiers, one should be enough

	if (IsEditable() && pose->IsSelected()) {
		bigtime_t delta = system_time() - pose->SelectionTime();
		bigtime_t doubleClickSpeed;
		get_click_speed(&doubleClickSpeed);
		bigtime_t oldClickSpeed = 2 * doubleClickSpeed;

		// freshly selected and not a double click
		if (delta > doubleClickSpeed && delta < oldClickSpeed) {
			StartEdit(bounds, view, pose);
			return;
		}

		// TODO: reimplement asynchronous
		// selected a longer time ago, redo a double click detection
		if (delta > oldClickSpeed) {
			// check for double click
			bigtime_t doubleClickTime = system_time() + doubleClickSpeed;
			while (system_time() < doubleClickTime) {
				// loop for double-click time and watch the mouse and keyboard

				BPoint point;
				uint32 buttons;
				view->GetMouse(&point, &buttons, false);

				// double click
				if (buttons)
					return;

				// mouse moved too far
				if (!bounds.Contains(point))
					return;

				//if (modifiers() & (B_SHIFT_KEY | B_COMMAND_KEY
				//	| B_CONTROL_KEY | B_MENU_KEY))
				//	// watch the keyboard (ignoring standard locking keys)
				//	break;

				snooze(10000);
			}
			StartEdit(bounds, view, pose);
		}
	}
}
Exemplo n.º 26
0
MouseWindow::MouseWindow(BRect _rect)
	: 
		BWindow(_rect, TR("Mouse"), B_TITLED_WINDOW, 
			B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS |
				B_AUTO_UPDATE_SIZE_LIMITS)
{
	// Add the main settings view
	fSettingsView = new SettingsView(fSettings);
	fSettingsBox = new BBox("main box");
	fSettingsBox->AddChild(fSettingsView);

	// Add the "Default" button
	fDefaultsButton = new BButton(TR("Defaults"), new BMessage(kMsgDefaults));
	fDefaultsButton->SetEnabled(fSettings.IsDefaultable());

	// Add the "Revert" button
	fRevertButton = new BButton(TR("Revert"), new BMessage(kMsgRevert));
	fRevertButton->SetEnabled(false);

	SetPulseRate(100000);
		// we are using the pulse rate to scan pressed mouse
		// buttons and draw the selected imagery

	// Build the layout
	SetLayout(new BGroupLayout(B_VERTICAL));

	AddChild(BGroupLayoutBuilder(B_VERTICAL, 10)
		.Add(fSettingsBox)
		.AddGroup(B_HORIZONTAL, 5)
			.Add(fDefaultsButton)
			.Add(fRevertButton)
			.AddGlue()
		.End()
		.SetInsets(10, 10, 10, 10)
	);

	// check if the window is on screen
	BRect rect = BScreen().Frame();
	rect.InsetBySelf(20, 20);

	BPoint position = fSettings.WindowPosition();
	BRect windowFrame = Frame().OffsetToSelf(position);
	if (!rect.Contains(windowFrame)) {
		// center window on screen as it doesn't fit on the saved position
		position.x = (rect.Width() - windowFrame.Width()) / 2;
		position.y = (rect.Height() - windowFrame.Height()) / 2;
		if (position.x < 0)
			position.x = 0;
		if (position.y < 0)
			position.y = 15;
	}
	MoveTo(position);
}
Exemplo n.º 27
0
void ArpIntControl::MouseMoved(	BPoint pt,
								uint32 code,
								const BMessage* msg)
{
	BRect	cb = ControlBounds();
	if (!(cb.Contains(pt))) {
		StopEdit();
		StopTimer();
	}

	if (IsEnabled() == false) return;
	if (mMotion) mMotion->MouseMoved(pt, code, msg);
}
Exemplo n.º 28
0
// TopOfScreen -- Places the BWindow starting from the top of the Current Screen
static void TopOfScreen(BWindow* w)
{
	BRect	screenFrame = (BScreen(B_MAIN_SCREEN_ID).Frame());
	BPoint 	pt;
	pt.x = 5;
	pt.y = 110;

	if (screenFrame.Contains(pt))
		w->MoveTo(pt);
	
	int BottomToolbox = (int) screenFrame.Height() - 314;
	w->ResizeTo(w->Bounds().Width(),BottomToolbox);
}
Exemplo n.º 29
0
void
PadView::MouseDown(BPoint where)
{
	BWindow* window = Window();
	if (window == NULL)
		return;

	BRegion region;
	GetClippingRegion(&region);
	if (!region.Contains(where))
		return;

	bool handle = true;
	for (int32 i = 0; BView* child = ChildAt(i); i++) {
		if (child->Frame().Contains(where)) {
			handle = false;
			break;
		}
	}
	if (!handle)
		return;

	BMessage* message = window->CurrentMessage();
	if (message == NULL)
		return;

	uint32 buttons;
	message->FindInt32("buttons", (int32*)&buttons);
	if (buttons & B_SECONDARY_MOUSE_BUTTON) {
		BRect r = Bounds();
		r.InsetBy(2.0, 2.0);
		r.top += 6.0;
		if (r.Contains(where)) {
			DisplayMenu(where);
		} else {
			// sends the window to the back
			window->Activate(false);
		}
	} else {
		if (system_time() - fClickTime < sActivationDelay) {
			window->Minimize(true);
			fClickTime = 0;
		} else {
			window->Activate();
			fDragOffset = ConvertToScreen(where) - window->Frame().LeftTop();
			fDragging = true;
			SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
			fClickTime = system_time();
		}
	}
}
Exemplo n.º 30
0
BRect SeqToolBarView::DraggingRectFor(BPoint pt, int32* lIndex, int32* rIndex)
{
	if (mCachedData.size() < 1) {
		if (lIndex) *lIndex = -1;
		if (rIndex) *rIndex = 0;
		return Bounds();
	}
	BRect			bounds(Bounds() );
	float			x  = 0;
	float			IN_BETWEEN = 0.20;

	for (uint32 k = 0; k < mCachedData.size(); k++) {
		BRect		b = mCachedData[k].Bounds();
		float		inBetween = b.Width() * IN_BETWEEN;
		float		pad = 0;
		b.OffsetBy(BPoint(x, 0) );
		/* Special case:  If we're on the last tool, the drag bounds
		 * extend to the end of the view.
		 */
		if (k >= mCachedData.size() - 1) {
			b.right = bounds.right;
			pad = LAST_BUTTON_PAD;
		}

		if (b.Contains(pt)) {
			if (lIndex && rIndex) *lIndex = *rIndex = (int32)k;
			BRect		ans(b);
			if (pt.x <= b.left + inBetween) {
				if (lIndex) *lIndex = *lIndex -1;
				ans.right = ans.left + inBetween;
				if (k > 0) {
					float	f = (mCachedData[k-1].Bounds().Width()) * IN_BETWEEN;
					ans.left -= (mSpace + f);
				}
			} else if (pt.x >= b.right - inBetween - pad) {
				if (rIndex) *rIndex = *rIndex + 1;
				ans.left = ans.right - inBetween - pad;
				if (k != mCachedData.size() - 1) {
					float	f = (mCachedData[k+1].Bounds().Width()) * IN_BETWEEN;
					ans.right += mSpace + f;
				}
			}
			return ans;
		}
		x = b.right + 1;
		x += mSpace;
		if (x > pt.x) return BRect(-1, -1, -1, -1);
	}
	return BRect(-1, -1, -1, -1);
}