Ejemplo n.º 1
0
void
ObjectViewContainer::MessageReceived(BMessage *inMsg)
{
	BPoint delta(0, 0), where(0, 0);
	if (inMsg->WasDropped()) {
		where = inMsg->DropPoint(&delta);
		ConvertFromScreen(&where);
	}
	switch (inMsg->what) {
	
	case MOVE_OBJECT: {
		if (inMsg->HasPointer("qua_object")) {		
			QuaObject		*obj;
			inMsg->FindPointer("qua_object", (void **)&obj);
			where = where - delta - Bounds().LeftTop();
			obj->MoveTo(where);
		} else if (inMsg->HasPointer("sym_object")) {		
			SymObject		*obj;
			inMsg->FindPointer("sym_object", (void **)&obj);
			where = where - delta - Bounds().LeftTop();
			obj->MoveTo(where);
		}
		break;
	}
	
	default:
		BView::MessageReceived(inMsg);
		break;
		
	}
}
Ejemplo n.º 2
0
void
Window::MouseUp(IE::point point)
{
	ConvertFromScreen(point);

	if (Control* control = _GetControl(point)) {
		control->MouseUp(point);
	}
}
Ejemplo n.º 3
0
void MDE_Widget::GetMousePos(int *x, int *y)
{
	if (m_screen)
	{
		(*x) = m_screen->m_mouse_x;
		(*y) = m_screen->m_mouse_y;
	}
	else
		*x = *y = 0;
	ConvertFromScreen(*x, *y);
}
Ejemplo n.º 4
0
void BrowseView::ResizeList(float coord)
{
	if (horizontalMover == NULL)
		return;
		
	BPoint p = ConvertFromScreen(BPoint(0,coord));
	mainScroll->ResizeTo(mainScroll->Frame().Width(),p.y-mainScroll->Frame().top-2);
	linksScroll->ResizeTo(linksScroll->Frame().Width(),Frame().Height()-p.y-horizontalMover->Frame().Height()-bottomSpace);
	linksScroll->MoveTo(linksScroll->Frame().left,p.y+2+horizontalMover->Frame().Height());
	horizontalMover->MoveTo(horizontalMover->Frame().left,p.y);
}
Ejemplo n.º 5
0
void
PrefListView::MessageReceived(BMessage* msg)
{
	switch (msg->what) {
		case 'ITEM':
		{
			puts("We have a winner, supposably ;-)");
			BPoint dropzone;
			msg->FindPoint("_drop_point_", &dropzone);
			dropzone = ConvertFromScreen(dropzone);

			int32 i, nr;
			msg->FindInt32("Item", &i);
			msg->FindInt32("Item_nr", &nr);

			XmlNode* Item = (XmlNode*)i;
			XmlNode* toItem = dynamic_cast<XmlNode*>(ItemAt(IndexOf(dropzone)));

			// Only proceed if valid
			if (toItem && Item && toItem!=Item) {
				XmlNode* parent = Item->Parent();

				uint32 index = parent->IndexOf(Item);
				uint32 toIndex = toItem->Parent()->IndexOf(toItem);
				if (index<toIndex)
					toIndex++;

				parent->DetachChild(index);

				if (toItem->Attribute(OPML_URL)!=NULL) {
					toItem->Parent()->AddChild(Item, toIndex);
				}
				else {
					toItem->AddChild(Item,0);
				}

				MakeEmpty();
				BuildView(root);

				Invalidate();
			}
		}
		break;

		default:
			BOutlineListView::MessageReceived(msg);
	}
}
Ejemplo n.º 6
0
void
AudioListView::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case kDraggedItem:
		{
			BPoint dropPoint = message->DropPoint();
			int32 dropIndex = IndexOf(ConvertFromScreen(dropPoint));
			int32 count = CountItems();
			if (dropIndex < 0 || dropIndex > count)
				dropIndex = count;

			BList indices;
			GetSelectedItems(indices);
			MoveItems(indices, dropIndex);

			RenumberTracks();
			break;
		}
		case kDeleteItem:
		{
			if (!IsEmpty()) {
				RemoveSelected();

				if (!IsEmpty())
					RenumberTracks();
			}
			// fake to update button state and calculate SizeBar
			Looper()->PostMessage(B_REFS_RECEIVED);
			break;
		}
		case kPopupClosed:
		{
			fShowingPopUpMenu = false;
			break;
		}
		default:
		{
			BListView::MessageReceived(message);
			break;
		}
	}
}
Ejemplo n.º 7
0
void
Window::MouseMoved(IE::point point)
{
	ConvertFromScreen(point);

	Control* oldActiveControl = fActiveControl;
	Control* control = _GetControl(point);

	if (oldActiveControl != control) {
		if (oldActiveControl != NULL)
			oldActiveControl->MouseMoved(point, Control::MOUSE_EXIT);
		if (control != NULL)
			control->MouseMoved(point, Control::MOUSE_ENTER);
	} else {
		if (control != NULL)
			control->MouseMoved(point, Control::MOUSE_INSIDE);
	}
	fActiveControl = control;
}
Ejemplo n.º 8
0
void MainView::showPopUp(const BPoint& win_point)
{
	BMenuItem *item;
	BPoint point = ConvertFromScreen(win_point);
	if(menu != NULL) {
		delete menu;
	}
	menu = new BPopUpMenu("menu", false);

	BMessage *msg = new BMessage(MSG_ADD_GUIDE);
	msg->AddBool("orientation", true);
	msg->AddInt32("point", point.y);	
	item = new BMenuItem("Add Horizontal Guide", msg);
	item->SetTarget(this);
	menu->AddItem(item);
	
	msg = new BMessage(MSG_ADD_GUIDE);
	msg->AddBool("orientation", false);
	msg->AddInt32("point", point.x);
	item = new BMenuItem("Add Vertical Guide", msg);
	item->SetTarget(this);
	menu->AddItem(item);
	
	msg = new BMessage(MSG_MAIN_VIEW_SHOW_GUIDES);
	item = new BMenuItem("Show Guides", msg);
	item->SetTarget(this);
	menu->AddItem(item);
	
	msg = new BMessage(MSG_MAIN_VIEW_HIDE_GUIDES);
	item = new BMenuItem("Hide Guides", msg);
	item->SetTarget(this);
	menu->AddItem(item);
	
	item = new BMenuItem("Edit Guides", new BMessage(MSG_SHOW_GUIDES));
	item->SetTarget(Window());
	menu->AddItem(item);
	
	menu->Go(win_point, true);
}
Ejemplo n.º 9
0
void	ListView1::MessageDropped(BMessage *msg, BPoint point) {
printf("MessageDropped():");
	switch(msg->what) {
		case B_MOUSE_DOWN: printf("B_MOUSE_DOWN\n");break;
		case B_SIMPLE_DATA: be_app->PostMessage(msg); break;
		case B_MOUSE_MOVED: printf("B_MOUSE_MOVED\n");break;
		case LISTITEM_DROPPED: 	printf("LISTITEM_DROPPED\n");
				if ((CDMode!=AUDIOCD_INDEX) && (CDMode!=CDEXTRA_INDEX)) break;
				if (msg->WasDropped()) {
					BPoint where=msg->DropPoint();
					ConvertFromScreen(&where);
					where.PrintToStream();
					BRow *draggedRow=NULL;
					if ((CDMode==DATACD_INDEX) || (CDMode==BOOTABLECD_INDEX) || (CDMode==DVDVIDEO_INDEX)) {	// yes? then we are not in audio mode
						draggedRow=folderRow;
					} else
					if ((CDMode==AUDIOCD_INDEX) || (CDMode==CDEXTRA_INDEX)) {
						draggedRow=audioRow;
					}
					void	*row;
					msg->FindPointer("from", &row);
					if (RowAt(where)) {
						int32 index=IndexOf(RowAt(where));
						if (index>0) index--;
						AddRow(draggedRow, index);
					} else
						AddRow(draggedRow);
					RemoveRow(IndexOf((BRow *)row));
					Invalidate();
					ResetTrackNumbers();
					//Refresh();
					
					project_has_changed=true;
				}
				break;
		default:  BColumnListView::MessageDropped(msg, point);
	}
}
Ejemplo n.º 10
0
void
CalcView::Paste(BMessage* message)
{
	// handle color drops first
	// read incoming color
	const rgb_color* dropColor = NULL;
	ssize_t dataSize;
	if (message->FindData("RGBColor", B_RGB_COLOR_TYPE,
			(const void**)&dropColor, &dataSize) == B_OK
		&& dataSize == sizeof(rgb_color)) {

		// calculate view relative drop point
		BPoint dropPoint = ConvertFromScreen(message->DropPoint());

		// calculate current keypad area
		float sizeDisp = fHeight * kDisplayScaleY;
		BRect keypadRect(0.0, sizeDisp, fWidth, fHeight);

		// check location of color drop
		if (keypadRect.Contains(dropPoint) && dropColor) {
			fBaseColor = *dropColor;
			_Colorize();
			// redraw
			Invalidate();
		}

	} else {
		// look for text/plain MIME data
		const char* text;
		ssize_t numBytes;
		if (message->FindData("text/plain", B_MIME_TYPE,
				(const void**)&text, &numBytes) == B_OK) {
			BString temp;
			temp.Append(text, numBytes);
			fExpressionTextView->Insert(temp.String());
		}
	}
}
Ejemplo n.º 11
0
void
ObjectView::MessageReceived(BMessage *inMsg)
{
	BPoint delta(0, 0), where(0, 0);
	if (inMsg->WasDropped()) {
		where = inMsg->DropPoint(&delta);
		ConvertFromScreen(&where);
	}
	switch (inMsg->what) {
	
	case REDISPLAY_OBJECT: {
		BRect		r;
		BMessageQueue	*q = Window()->MessageQueue();
		BMessage	*m=nullptr;
		
		if (inMsg->HasRect("rect")) {
			r = inMsg->FindRect("rect");
		} else {
			r = Bounds();
		}
		for (int count=0; m=q->FindMessage(REDISPLAY_OBJECT, count); count++) {
			ObjectView	*ov=nullptr;
			m->FindPointer("object", (void**)&ov);
			if (ov == this) {
				BRect	s;
				if (m->HasRect("rect")) {
					s = m->FindRect("rect");
					s.left = Min(s.left,r.left);
					s.right = Max(s.right, r.right);
					m->ReplaceRect("rect", s);
				} else {
					s = r;
					m->AddRect("rect", s);
				}
				return;
			}
		}
		Draw(r);
		break;
	}
	
	case SET_COLOR: {
		rgb_color		*p;
		ssize_t			sz;
		
		inMsg->FindData("color", B_RAW_TYPE, (const void **)&p, &sz);
		color.red = p->red;
		color.green = p->green;
		color.blue = p->blue;
		ReDraw();
		break;
	}
	
	case SET_DISPLAY_MODE: {
		rgb_color		*p;
		int32			md = inMsg->FindInt32("display mode");
		SetDisplayMode(md);
		break;
	}
	
	default:
		BView::MessageReceived(inMsg);
		break;
		
	}
}
Ejemplo n.º 12
0
void TPanelWindowView::MessageReceived( BMessage *message )
{
	if ( fDebugLevel >= 20 )
		message->PrintToStream();

	if ( message->what == B_GET_PROPERTY
		 || message->what == B_SET_PROPERTY
		 || message->what == B_COUNT_PROPERTIES
		 || message->what == B_CREATE_PROPERTY
		 || message->what == B_DELETE_PROPERTY
		 || message->what == B_EXECUTE_PROPERTY )
	{
		int32 index, what;
		BMessage specifier;
		const char *property;
		if ( message->GetCurrentSpecifier( &index, &specifier, &what, &property ) == B_OK )
		{
			BMessage reply( B_REPLY );
			if ( message->what == B_GET_PROPERTY
				 || message->what == B_COUNT_PROPERTIES
				 || message->what == B_EXECUTE_PROPERTY )
			{
				if ( GetOptions( property, &reply ) )
					reply.AddInt32( "error", 0 );
				else
					reply.AddInt32( "error", -1 );
			}
			else if ( message->what == B_SET_PROPERTY )
			{
				if ( SetOptions( property, message ) )
					reply.AddInt32( "error", 0 );
				else
					reply.AddInt32( "error", -1 );
			}
			else if ( message->what == B_CREATE_PROPERTY )
			{
				if ( !strcasecmp( property, "tab" ) )
				{
					int32 index;
					if ( message->FindInt32( "index", &index ) != B_OK )
						index = -1;
					TShortcutPanel *panel = new TShortcutPanel( this );

					fPanels.Lock();
					if ( index >= 0 )
					{
						TInnerPanel *rightpanel = fPanels.ItemAt(index);
						AddPanel( panel, rightpanel );
					}
					else
					{
						AddPanel( panel );
					}
					fPanels.Unlock();

					ChangedSize(0);

					reply.AddInt32( "error", 0 );
				}
				else
					reply.AddInt32( "error", -1 );
			}
			else if ( message->what == B_DELETE_PROPERTY )
			{
				int32 index;
				if ( specifier.FindInt32( "index", &index ) != B_OK )
					reply.AddInt32( "error", -1 );
				else
				{
					fPanels.Lock();
					TInnerPanel *panel = fPanels.ItemAt(index);
					if ( !panel )
						reply.AddInt32( "error", -1 );
					else
					{
						if ( panel != fRunningAppPanel )
						{
							RemovePanel( panel );
							reply.AddInt32( "error", 0 );
						}
						else
							reply.AddInt32( "error", -1 );
					}
					fPanels.Unlock();
				}
			}
			message->SendReply( &reply );
		}
		return;
	}

	if ( message->WasDropped() )
	{
		BPoint point = message->DropPoint();
		ConvertFromScreen( &point );
		TInnerPanel *panel = PanelAt( point );
		if ( message->what == 'IDRG' )
		{
			TPanelIcon *item;
			if ( message->FindPointer( "source", (void**)&item ) == B_OK )
			{
				TRaisingIconPanel *previous_parent = item->fParent;
				TRaisingIconPanel *rpanel;
				if ( modifiers() & B_CONTROL_KEY )
				{
					rpanel = new TShortcutPanel(this);
					bool left = false;
					if ( point.x < (panel->Frame().left+(panel->Frame().Width()/2) ) )
					{
						left = true;
					}
						
					rpanel = new TShortcutPanel(this);
					AddPanel( rpanel, left ? panel : 0 );
				}
				else
					rpanel = dynamic_cast<TRaisingIconPanel*>(panel);
				if ( rpanel && rpanel != fRunningAppPanel )
				{
					TPanelIcon *icon = rpanel->IconAt( point, true );
					if ( previous_parent == fRunningAppPanel && dynamic_cast<TShortcutPanel*>(rpanel) )
					{
						int32 index = rpanel->IndexOf(icon);
						AddShortcut( dynamic_cast<TShortcutPanel*>(rpanel), dynamic_cast<TAppPanelIcon*>(item)->Ref(), index );
					}
					else if ( !dynamic_cast<TTrashIcon*>(icon) || (modifiers() & B_SHIFT_KEY) )
					{
						previous_parent->RemoveItem( item, false );
						int32 index = rpanel->IndexOf(icon);
						rpanel->AddItem( item, index );
					}
					else
					{
						if ( item->Removable() )
							RemoveShortcut(item);
					}
					if ( previous_parent->CountItems() == 0 && previous_parent != fRunningAppPanel )
						RemovePanel( previous_parent );
				}
			}
		}
		else
		{
			if ( panel && panel->HitsFrame( point ) )
			{
				panel->HandleDroppedMessage( message, point );
			}
			else
			{
				HandleDroppedMessage( message, point );
			}
		}

		return;
	}

	switch ( message->what )
	{
	case kPanelWindowViewTimer:
		{
			if ( DoIconSmallerWithTime() == 0 )
			{
				fTimer->SetInterval( 999999999 );
			}
			break;
		}
	case T_MENU_CLOSED:
		{
			DebugCall( 8, "Got T_MENU_CLOSED" );

			TAwarePopupMenu *source;
			if ( message->FindPointer( "source", (void**)&source ) == B_OK )
			{
				if ( source == fOpenMenu )
				{
					DebugCall( 9, "fOpenMenu is now 0" );

					fOpenMenu = 0;
					BPoint point;
					uint32 buttons;
					GetMouse( &point, &buttons );
					if ( !Bounds().Contains( point ) )
						Window()->PostMessage(B_EXITED_VIEW);
				}
			}
			break;
		}
	case B_SOME_APP_LAUNCHED:
		{
			team_id tid;
			if ( message->FindInt32( "be:team", &tid ) != B_OK )
				break;
			const char *sig;
			if ( message->FindString( "be:signature", &sig ) != B_OK )
				break;
			entry_ref ref;
			if ( message->FindRef( "be:ref", &ref ) != B_OK )
				break;
			int32 flags;
			if ( message->FindInt32( "be:flags", &flags ) != B_OK )
				break;

			if ( sig && strlen(sig) && ( ( flags & B_BACKGROUND_APP ) == 0 ) )
				AddTeam( tid, sig, ref );

			break;
		}
	case B_SOME_APP_QUIT:
		{
			team_id tid;
			if ( message->FindInt32( "be:team", &tid ) != B_OK )
				break;

			RemoveTeam( tid );

			break;
		}
	case B_SOME_APP_ACTIVATED:
		{
			team_id tid;
			if ( message->FindInt32( "be:team", &tid ) == B_OK )
			{
				TAppPanelIcon *icon = ItemWith( tid );

				if ( icon != fLastActiveAppIcon )
				{
					DebugCall( 10, "B_SOME_APP_ACTIVATED %p[..]->%p[%i]", fLastActiveAppIcon, icon, tid );

					if ( fLastActiveAppIcon )
						fLastActiveAppIcon->SetActive( false );
					if ( icon )
						icon->SetActive( true );
					fLastActiveAppIcon = icon;
				}
			}

			BString temp;
			message->FindString( "be:signature", &temp );

			if ( temp != "application/x-vnd.Be-TSKB" )
				fLastActivatedAppSig = temp;

			break;
		}
	case kDoBubbleHelp:
		{
			BPoint point;
			uint32 buttons;
			GetMouse(&point, &buttons);
			if ( fPreviousMousePosition != point )
			{
				if ( fBubbleCounter > 0 )
				{
					if ( fBubbleCounter >= 6 )
					{
						fBubbleHelp->HideBubble();
					}
					fBubbleCounter = 0;
				}
				fPreviousMousePosition = point;
			}
			else
			{
				BRegion region;
				GetClippingRegion(&region);
				if ( region.Contains( point ) )
				{
					fBubbleCounter ++;
					if ( fBubbleCounter == 6 )
					{
						ConvertToScreen(&point);
						TBubbleTarget *target = fBubbleHelp->TargetAt( point );
						if (dynamic_cast<TTrackerIcon*>(target)) {
							TTrackerIcon *trackerIcon = dynamic_cast<TTrackerIcon*>(target);
							point.x = Window()->Frame().left + trackerIcon->ContentLocation().x + trackerIcon->Frame().Width() + 4;
							point.y = Window()->Frame().top;
							float height = TBubbleHelp::BubbleHeight(target);
							point.y += height;
							point.y += (Window()->Frame().Height() - height)/2 -4;
						}
						fBubbleHelp->ShowBubble( point, target );
					}
//					else if ( fBubbleCounter == 12 )
//					{
//						fBubbleHelp->HideBubble();
//					}
				}
			}
			break;
		}
	case 'flsh':
		{
			BMessenger target;
			if ( message->FindMessenger("source", &target ) == B_OK && target.IsValid() )
			{
				TAppPanelIcon *teamicon = ItemWith( target.Team() );
				if ( teamicon )
				{
//					todo: flashing
					teamicon->Flash();
				}
			}
			break;
		}
	case 'mctx':
		{
//			todo: context menus
			break;
		}
	default:
		BView::MessageReceived(message);
	}
}
Ejemplo n.º 13
0
void
CalcView::Paste(BMessage* message)
{
	// handle files first
	int32 count;
	if (message->GetInfo("refs", NULL, &count) == B_OK) {
		entry_ref ref;
		ssize_t read;
		BFile file;
		char buffer[256];
		memset(buffer, 0, sizeof(buffer));
		for (int32 i = 0; i < count; i++) {
			if (message->FindRef("refs", i, &ref) == B_OK) {
				if (file.SetTo(&ref, B_READ_ONLY) == B_OK) {
					read = file.Read(buffer, sizeof(buffer) - 1);
					if (read <= 0)
						continue;
					BString expression(buffer);
					int32 j = expression.Length();
					while (j > 0 && expression[j - 1] == '\n')
						j--;
					expression.Truncate(j);
					if (expression.Length() > 0)
						fExpressionTextView->Insert(expression.String());
				}
			}
		}
		return;
	}
	// handle color drops
	// read incoming color
	const rgb_color* dropColor = NULL;
	ssize_t dataSize;
	if (message->FindData("RGBColor", B_RGB_COLOR_TYPE,
			(const void**)&dropColor, &dataSize) == B_OK
		&& dataSize == sizeof(rgb_color)) {

		// calculate view relative drop point
		BPoint dropPoint = ConvertFromScreen(message->DropPoint());

		// calculate current keypad area
		float sizeDisp = fHeight * kDisplayScaleY;
		BRect keypadRect(0.0, sizeDisp, fWidth, fHeight);

		// check location of color drop
		if (keypadRect.Contains(dropPoint) && dropColor != NULL) {
			fBaseColor = *dropColor;
			fHasCustomBaseColor =
				fBaseColor != ui_color(B_PANEL_BACKGROUND_COLOR);
			_Colorize();
			// redraw
			Invalidate();
		}

	} else {
		// look for text/plain MIME data
		const char* text;
		ssize_t numBytes;
		if (message->FindData("text/plain", B_MIME_TYPE,
				(const void**)&text, &numBytes) == B_OK) {
			BString temp;
			temp.Append(text, numBytes);
			fExpressionTextView->Insert(temp.String());
		}
	}
}
Ejemplo n.º 14
0
void BComboBox::ChoiceListView::MouseDown(BPoint where)
{
	BRect rect(Window()->Frame());
	ConvertFromScreen(&rect);
	if (!rect.Contains(where))
	{
		// hide the popup window when the user clicks outside of it
		if (fParent->Window()->Lock())
		{
			fParent->HidePopupWindow();
			fParent->Window()->Unlock();
		}

		// HACK: the window is locked and unlocked so that it will get
		// activated before we potentially send the mouse down event in the
		// code below.  Is there a way to wait until the window is activated
		// before sending the mouse down? Should we call
		// fParent->Window()->MakeActive(true) here?
		
		if (fParent->Window()->Lock())
		{
			// resend the mouse event to the textinput, if necessary
			BTextView *text = fParent->TextView();
			BPoint screenWhere(ConvertToScreen(where));
			rect = text->Window()->ConvertToScreen(text->Frame());
			if (rect.Contains(screenWhere))
			{
				//printf("  resending mouse down to textinput\n");
				BMessage *msg = new BMessage(*Window()->CurrentMessage());
				msg->RemoveName("be:view_where");
				text->ConvertFromScreen(&screenWhere);
				msg->AddPoint("be:view_where", screenWhere);
				text->Window()->PostMessage(msg, text);
				delete msg;
			}
			fParent->Window()->Unlock();
		}
		
		return;
	}

	rect = Bounds();
	if (!rect.Contains(where))
		return;
	
	fTrackingMouseDown = true;
	// check for double click
	bigtime_t now = system_time();
	bigtime_t clickSpeed;
	get_click_speed(&clickSpeed);
	if ((now - fClickTime < clickSpeed)
		&& ((abs((int)(fClickLoc.x - where.x)) < 3)
		&& (abs((int)(fClickLoc.y - where.y)) < 3)))
	{
		// this is a double click
		// XXX: what to do here?
		printf("BComboBox::ChoiceListView::MouseDown() -- unhandled double click\n");
	}
	fClickTime = now;
	fClickLoc = where;

	float h = LineHeight();
	int32 oldIndex = fSelIndex;
	fSelIndex = (int32)floor(where.y / h);
	int32 choices = fParent->fChoiceList->CountChoices();
	if (fSelIndex < 0 || fSelIndex >= choices)
		fSelIndex = -1;

	if (oldIndex != fSelIndex)
	{
		InvalidateItem(oldIndex);
		InvalidateItem(fSelIndex);
	}
	// XXX: this probably isn't necessary since we are doing a SetEventMask
	// whenever the popup window becomes visible which routes all mouse events
	// to this view
//	SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
}
Ejemplo n.º 15
0
void
CTrackListView::MessageReceived(
	BMessage *message)
{
	D_MESSAGE(("CTrackListView::MessageReceived()\n"));

	switch(message->what)
	{
		case CObservable::UPDATED:
		{
			int32 trackHint, docHint;
			int32 trackID;
		
			if (message->FindInt32("TrackID", &trackID) != B_OK)
				trackID = -1;
			if (message->FindInt32("TrackAttrs", &trackHint) != B_OK)
				trackHint = 0;
			if (message->FindInt32("DocAttrs", &docHint ) != B_OK)
				docHint = 0;
		
			if (trackHint != 0 || docHint != 0)
			{
				if (trackID >= 0)
				{
					for (int i = 0; i < CountItems(); i++)
					{
						CTrackListItem *item = dynamic_cast<CTrackListItem *>
											   (ItemAt(i));
						if (item && (item->GetTrackID() == trackID))
						{
							if (trackHint & (CTrack::Update_Name | CTrack::Update_Flags))
							{
								item->Update(this, be_plain_font);
								InvalidateItem(i);
							}
						}
					}
				}
				
				if ((docHint & CMeVDoc::Update_AddTrack)
				 || (docHint & CMeVDoc::Update_DelTrack)
				 || (docHint & CMeVDoc::Update_TrackOrder))
				{
					BuildTrackList();
				}
			}
			break;
		}
		case CTrackListItem::EDIT_TRACK:
		{
			D_MESSAGE((" -> CTrackListItem::EDIT_TRACK\n"));

			int32 selection = CurrentSelection();
			if (selection >= 0)
			{
				CTrackListItem *item = (CTrackListItem *)ItemAt(selection);
				if (item)
					m_doc->ShowWindowFor(item->GetTrack());
			}
			break;
		}
		case CTrackListItem::MUTE_TRACK:
		{
			D_MESSAGE((" -> CTrackListItem::MUTE_TRACK\n"));

			int32 selection = CurrentSelection();
			if (selection >= 0)
			{
				CTrackListItem *item = (CTrackListItem *)ItemAt(selection);
				CTrack *track = item->GetTrack();
				track->SetMuted(!track->Muted());
				track->NotifyUpdate(CTrack::Update_Name, NULL);
				m_doc->SetModified();
			}
			break;
		}
		case CTrackListItem::SOLO_TRACK:
		{
			D_MESSAGE((" -> CTrackListItem::SOLO_TRACK\n"));

			int32 selection = CurrentSelection();
			if (selection >= 0)
			{
				// nyi
			}
			break;
		}
		case CTrackListItem::DELETE_TRACK:
		{
			D_MESSAGE((" -> CTrackListItem::DELETE_TRACK\n"));

			int32 selection = CurrentSelection();
			if (selection >= 0)
			{
				CTrackListItem *item = (CTrackListItem *)ItemAt(selection);
				CTrack *track = item->GetTrack();
				CTrackDeleteUndoAction *undoAction;
				undoAction = new CTrackDeleteUndoAction(track);
				m_doc->AddUndoAction(undoAction);
			}
			break;
		}
		case CTrackListItem::RENAME_TRACK:
		{
			D_MESSAGE((" -> CTrackListItem::RENAME_TRACK\n"));

			int32 index = CurrentSelection();
			if (index < 0)
				return;
			CTrackListItem *item = dynamic_cast<CTrackListItem *>(ItemAt(index));
			if (item)
				item->StartEdit(this, index, ItemFrame(index));
			break;
		}
		case CTrackListItem::TRACK_NAME_EDITED:
		{
			D_MESSAGE((" -> CTrackListItem::TRACK_NAME_EDITED\n"));

			int32 index;
			BString name;
			if (message->FindInt32("index", &index) != B_OK)
				return;
			CTrackListItem *item = dynamic_cast<CTrackListItem *>(ItemAt(index));
			if (!item)
				return;
			item->StopEdit();
			if (message->FindString("text", &name) == B_OK)
			{
				// name changed
				CTrack *track = item->GetTrack();
				CTrackRenameUndoAction *undoAction;
				undoAction = new CTrackRenameUndoAction(track, name);
				m_doc->AddUndoAction(undoAction);
			}
			MakeFocus(true);
			break;
		}
		case MeVDragMsg_ID:
		{
			D_MESSAGE((" -> MeVDragMsg_ID\n"));

			int32 type;
			if ((message->FindInt32("Type", &type) != B_OK)
			 || (type != DragTrack_ID))
				return;

			// change of track order requested
			int32 index;
			message->FindInt32("Index", &index);
			// find the target index
			BPoint point = ConvertFromScreen(message->DropPoint());
			point.y -= ItemFrame(0).Height();
			int32 dragIndex;
			if (point.y < 0.0) 
				dragIndex = -1;
			else 
			{
				dragIndex = IndexOf(point);
				if (dragIndex < 0)	
					dragIndex = CountItems() - 1;
			}
			// reorder tracks
			if (dragIndex < index)
			{
				m_doc->ChangeTrackOrder(index, dragIndex + 1);
				m_doc->SetModified();
			}
			else if (dragIndex > index)
			{
				m_doc->ChangeTrackOrder(index, dragIndex);
				m_doc->SetModified();
			}

			break;
		}
		default:
		{
			BListView::MessageReceived(message);
			break;
		}
	}
}
Ejemplo n.º 16
0
void CCellView::HandleDrop(BMessage *inMessage)
{
	long l;
	void * p;
	BPoint dp = inMessage->DropPoint();
	
	fDragIsAcceptable = false;
	
	if (inMessage->FindPointer("container", &p) == B_NO_ERROR)
	{
		key_info ki;
		get_key_info(&ki);
		
		CContainer *srcContainer;
		range srcRange, dstRange;
		CCellView *srcView;
		int action;
		
		srcContainer = (CContainer *)p;
		FailOSErr(inMessage->FindData("range", 'rang', (const void**)&p, &l), errMessageMissing);
		srcRange = *(range *)p;
		FailOSErr(inMessage->FindPointer("cellview", &p), errMessageMissing);
		srcView = (CCellView *)p;
		
		if (srcView != this)
			action = dragCopy;
		else
			action = dragMove;
		
		inMessage->FindBool("dragacopy", &fDragACopy);
		
		if (srcView == this &&
		    (ki.modifiers & B_CONTROL_KEY ||
			fDragACopy))
		{
			BPopUpMenu popup("dragpopup", false);
			popup.SetFont(be_plain_font);
			popup.AddItem(new BMenuItem(GetMessage(msgLinkHere), NULL));
			popup.AddItem(new BMenuItem(GetMessage(msgMoveHere), NULL));
			popup.AddItem(new BMenuItem(GetMessage(msgCopyHere), NULL));
			popup.AddSeparatorItem();
			popup.AddItem(new BMenuItem(GetMessage(msgCancel), NULL));
			
			BMenuItem *item = popup.Go(dp, false, true);
			int result = item ? popup.IndexOf(item) : -1;
			switch (result)
			{
				case 0: action = dragLink; break;
				case 1: action = dragMove; break;
				case 2: action = dragCopy; break;
				default:
					ClearAnts();
					fCurCell = fSelection.TopLeft();
					return;
			}
		}
	
		dstRange = srcRange;
		dstRange.OffsetBy(fCurCell.h - dstRange.left,
			fCurCell.v - dstRange.top);
		
		((CCellWindow *)Window())->
			RegisterCommand(new CDragCommand(this, srcContainer,
				fContainer, &srcRange, &dstRange, action));
	}
	else if (inMessage->FindData("text/plain", B_MIME_DATA, (const void **)&p, &l) == B_NO_ERROR)
	{
		cell dc;
		
		ConvertFromScreen(&dp);
		GetCellHitBy(dp, dc);
		
		BMemoryIO buf(p, l);
		CContainer *srcContainer = new CContainer;
		range srcRange, dstRange;
		
		CTextConverter conv(buf, srcContainer);
		conv.ConvertFromText(srcRange);
		
		dstRange = srcRange;
		dstRange.OffsetBy(dc.h - srcRange.left, dc.v - srcRange.top);
		
		((CCellWindow *)Window())->
			RegisterCommand(new CDragCommand(this, srcContainer,
				fContainer, &srcRange, &dstRange, dragMove));

		srcContainer->Release();
	}
	else
	{
		beep();
		ClearAnts();
		fCurCell = fSelection.TopLeft();
	}
} /* CCellView::HandleDrop */
Ejemplo n.º 17
0
void MatrixControl::MessageReceived( BMessage *message)
{
switch (message->what)
	{
	case CONST_dragrow:
		{
		int32 source_row;
		BPoint target;
		BRect *rect;
		MatrixControl *con;
		void **x;
		
		message->FindInt32("row", &source_row);
		message->FindPoint("_drop_point_", &target);
		message->FindPointer("matrix_control", x);
		con = (MatrixControl *) *x;
    	if (con != this) {
    					 extra::OKBox ("You can´t drag from another window!");
    					 break;
    					 }
		target = ConvertFromScreen(target);

		
		for (int i=0; i<matrix_dimension; ++i)
			{
			rect = new BRect( 20, (i+1)*square_size+5, square_size * (matrix_dimension+1) ,(i+1)*square_size+10 );
			
			if (i != source_row)
			{
			if (rect->Contains(target)==true)
				{
				SwitchRows(source_row, i);
				Invalidate();
				} // if clause
			}
			
			delete rect;
			} // for loop

		} //case diferentiation
	case CONST_dragcolumn:
		{
		int32 source_row;
		BPoint target;
		BRect *rect;
		MatrixControl *con;
		void **x;
		
		message->FindInt32("column", &source_row);
		message->FindPoint("_drop_point_", &target);
		message->FindPointer("matrix_control", x);
		con = (MatrixControl *) *x;
    	if (con != this) 
    			{
    			extra::OKBox("You can´t drag from another window!");
    			break;
    			}

		target = ConvertFromScreen(target);
		
		for (int i=0; i<matrix_dimension; ++i)
			{
			rect = new BRect((i+1)*square_size-10, 20 ,(i+1)*square_size-5 , square_size * matrix_dimension);
			
			if (i != source_row)
			{
			if (rect->Contains(target)==true)
				{
				SwitchColumns(source_row, i);
				Invalidate();
				} // if clause
			}
			
			delete rect;
			} // for loop

		} //case diferentiation
	} //switch statement 
} //function
Ejemplo n.º 18
0
void
BDragger::MessageReceived(BMessage *msg)
{
	switch (msg->what) {
		case B_TRASH_TARGET:
			if (fShelf != NULL)
				Window()->PostMessage(kDeleteReplicant, fTarget, NULL);
			else {
				(new BAlert("??",
					"Can't delete this replicant from its original "
					"application. Life goes on.",
					"OK", NULL, NULL, B_WIDTH_FROM_WIDEST,
					B_WARNING_ALERT))->Go(NULL);
			}
			break;

		case _SHOW_DRAG_HANDLES_:
			// This code is used whenever the "are draggers drawn" option is
			// changed.
			if (fRelation == TARGET_IS_CHILD) {
				fTransition = true;
				Draw(Bounds());
				Flush();
				fTransition = false;
			} else {
				if ((fShelf && (fShelf->AllowsDragging() && AreDraggersDrawn()))
					|| AreDraggersDrawn())
					Show();
				else
					Hide();
			}
			break;

		case kMsgDragStarted:
			if (fTarget != NULL) {
				BMessage archive(B_ARCHIVED_OBJECT);

				if (fRelation == TARGET_IS_PARENT)
					fTarget->Archive(&archive);
				else if (fRelation == TARGET_IS_CHILD)
					Archive(&archive);
				else {
					if (fTarget->Archive(&archive)) {
						BMessage archivedSelf(B_ARCHIVED_OBJECT);

						if (Archive(&archivedSelf))
							archive.AddMessage("__widget", &archivedSelf);
					}
				}

				archive.AddInt32("be:actions", B_TRASH_TARGET);
				BPoint offset;
				drawing_mode mode;
				BBitmap *bitmap = DragBitmap(&offset, &mode);
				if (bitmap != NULL)
					DragMessage(&archive, bitmap, mode, offset, this);
				else {
					DragMessage(&archive,
						ConvertFromScreen(fTarget->ConvertToScreen(fTarget->Bounds())),
						this);
				}
			}
			break;

		default:
			BView::MessageReceived(msg);
			break;
	}
}
Ejemplo n.º 19
0
void
ActivityView::MessageReceived(BMessage* message)
{
	// if a color is dropped, use it as background
	if (message->WasDropped()) {
		rgb_color* color;
		ssize_t size;
		if (message->FindData("RGBColor", B_RGB_COLOR_TYPE, 0,
				(const void**)&color, &size) == B_OK
			&& size == sizeof(rgb_color)) {
			BPoint dropPoint = message->DropPoint();
			ConvertFromScreen(&dropPoint);

			if (_HistoryFrame().Contains(dropPoint)) {
				fHistoryBackgroundColor = *color;
				Invalidate(_HistoryFrame());
			} else {
				// check each legend color box
				BAutolock _(fSourcesLock);

				BRect legendFrame = _LegendFrame();
				for (int32 i = 0; i < fSources.CountItems(); i++) {
					BRect frame = _LegendColorFrameAt(legendFrame, i);
					if (frame.Contains(dropPoint)) {
						fSources.ItemAt(i)->SetColor(*color);
						Invalidate(_HistoryFrame());
						Invalidate(frame);
						return;
					}
				}

				if (dynamic_cast<ActivityMonitor*>(be_app) == NULL) {
					// allow background color change in the replicant only
					fLegendBackgroundColor = *color;
					SetLowColor(fLegendBackgroundColor);
					Invalidate(legendFrame);
				}
			}
			return;
		}
	}

	switch (message->what) {
		case B_ABOUT_REQUESTED:
		{
			BAboutWindow* window = new BAboutWindow(kAppName, kSignature);

			const char* authors[] = {
				"Axel Dörfler",
				NULL
			};

			window->AddCopyright(2008, "Haiku, Inc.");
			window->AddAuthors(authors);

			window->Show();

			break;
		}
		case kMsgUpdateResolution:
		{
			int32 resolution;
			if (message->FindInt32("resolution", &resolution) != B_OK)
				break;

			_UpdateResolution(resolution, false);
			break;
		}

		case kMsgTimeIntervalUpdated:
			bigtime_t interval;
			if (message->FindInt64("interval", &interval) != B_OK)
				break;

			if (interval < 10000)
				interval = 10000;

			atomic_set64(&fRefreshInterval, interval);
			break;

		case kMsgToggleDataSource:
		{
			int32 index;
			if (message->FindInt32("index", &index) != B_OK)
				break;

			const DataSource* baseSource = DataSource::SourceAt(index);
			if (baseSource == NULL)
				break;

			DataSource* source = FindDataSource(baseSource);
			if (source == NULL)
				AddDataSource(baseSource);
			else
				RemoveDataSource(baseSource);

			Invalidate();
			break;
		}

		case kMsgToggleLegend:
			fShowLegend = !fShowLegend;
			Invalidate();
			break;

		case B_MOUSE_WHEEL_CHANGED:
		{
			float deltaY = 0.0f;
			if (message->FindFloat("be:wheel_delta_y", &deltaY) != B_OK
				|| deltaY == 0.0f)
				break;

			int32 resolution = fDrawResolution;
			if (deltaY > 0)
				resolution *= 2;
			else
				resolution /= 2;

			_UpdateResolution(resolution);
			break;
		}

		default:
			BView::MessageReceived(message);
			break;
	}
}
Ejemplo n.º 20
0
void MediaRoutingView::messageDropped(
	BPoint point,
	BMessage *message)
{
	D_METHOD(("MediaRoutingView::messageDropped()\n"));

	switch (message->what)
	{
		case DormantNodeView::M_INSTANTIATE_NODE:
		{
			D_MESSAGE(("MediaRoutingView::messageDropped(DormantNodeView::M_INSTANTIATE_NODE)\n"));
			type_code type;
			int32 count;
			if (message->GetInfo("which", &type, &count) == B_OK)
			{
				for (int32 n = 0; n < count; n++)
				{
					dormant_node_info info;
					const void *data;
					ssize_t dataSize;
					if (message->FindData("which", B_RAW_TYPE, &data, &dataSize) == B_OK)
					{
						memcpy(reinterpret_cast<void *>(&info), data, dataSize);
						NodeRef* droppedNode;
						status_t error;
						error = manager->instantiate(info, &droppedNode);
						if (!error)
						{
							m_lastDroppedNode = droppedNode->id();
							BPoint dropPoint, dropOffset;
							dropPoint = message->DropPoint(&dropOffset);
							m_lastDropPoint = align(ConvertFromScreen(dropPoint - dropOffset));
						}
						else
						{
							BString s;
							s << "Could not instantiate '" << info.name << "'";
							showErrorMessage(s, error);
						}
					}	
				}
			}
			break;
		}
		case B_SIMPLE_DATA:
		{
			D_MESSAGE(("MediaRoutingView::messageDropped(B_SIMPLE_DATA)\n"));
			entry_ref fileRef;
			if (message->FindRef("refs", &fileRef) == B_OK)
			{
				_checkDroppedFile(&fileRef, ConvertFromScreen(message->DropPoint()));
			}
			break;
		}
		case B_PASTE:
		{
			D_MESSAGE(("MediaRoutingView::messageDropped(B_PASTE)\n"));
			ssize_t size;
			const rgb_color *color; // [e.moon 21nov99] fixed const error
			if (message->FindData("RGBColor", B_RGB_COLOR_TYPE, reinterpret_cast<const void **>(&color), &size) == B_OK)
			{
				_changeBackground(*color);
			}
			break;
		}
		default:
		{
			DiagramView::messageDropped(point, message);
		}
	}
}