Ejemplo n.º 1
0
void TPanelWindowView::ReArrangeTabsThread()
{
	BPoint pw;
	uint32 mods;

	Window()->Lock();
	GetMouse(&pw, &mods);
	Window()->Unlock();

	TInnerPanel *dragged = PanelAt(pw);
	int draggedindex = IndexOf(dragged);
	uint32 dragged_but = mods;

	while (1)
	{
		Window()->Lock();
		GetMouse(&pw, &mods);
		Window()->Unlock();
		if ( mods != dragged_but )
			break;
		pw.y = dragged->Frame().top +1;

		TInnerPanel *panel = PanelAt(pw);
		int index = -1;
		if ( panel )
			index = IndexOf(panel);
		if ( index < 0 || (index+2) == draggedindex || (index-2) == draggedindex )
		{
			int targetindex = -1;
			if ( index == -1 )
			{
				if ( pw.x < dragged->Frame().left )
					targetindex = 0;
				else
					targetindex = CountPanels()-1;
			}
			else if ( index < draggedindex )
				targetindex = index+1;
			else if ( index > draggedindex )
				targetindex = index-1;
			if ( targetindex != draggedindex )
			{
				MoveTabTo( dragged, targetindex );
				draggedindex = targetindex;
			}
		}
		snooze(50000);
	}
}
Ejemplo n.º 2
0
//---------------------------------------------------------------------------
void __fastcall TSynchronizeChecklistDialog::StatusBarMouseDown(
  TObject * /*Sender*/, TMouseButton /*Button*/, TShiftState Shift, int X,
  int /*Y*/)
{
  int IPanel = PanelAt(X);

  if (IPanel >= 0)
  {
    TListItem * Item = SelectAll(true, IPanel, Shift.Contains(ssCtrl));
    if (Item != NULL)
    {
      Item->MakeVisible(false);
      Item->Focused = true;
      ListView->SetFocus();
    }
  }
}
Ejemplo n.º 3
0
void TPanelWindowView::MouseUp( BPoint point )
{
	if ( !fIsDraggingFromOutside )
	{
		uint32 buttons;
		GetMouse( &point, &buttons );
		TInnerPanel *panel = PanelAt( point );
		if ( panel )
			panel->MouseUp(point, buttons);
	}
	else
	{
		fIsDraggingFromOutside = false;
		if ( fPreviousMouseMovedPanel )
		{
			fPreviousMouseMovedPanel->IsDragging( point, B_ENDED_DRAGGING );
			fPreviousMouseMovedPanel = 0;
		}
	}
}
Ejemplo n.º 4
0
//---------------------------------------------------------------------------
void __fastcall TSynchronizeChecklistDialog::StatusBarMouseMove(
  TObject * /*Sender*/, TShiftState /*Shift*/, int X, int /*Y*/)
{
  UnicodeString Hint;
  int IPanel = PanelAt(X);

  if (IPanel >= 0)
  {
    Hint = StatusBar->Panels->Items[IPanel]->Text;
    if (IPanel > 0)
    {
      Hint = FORMAT(L"%s\n%s", (Hint, FGeneralHint));
    }
  }

  if (Hint != StatusBar->Hint)
  {
    Application->CancelHint();
    StatusBar->Hint = Hint;
  }
}
Ejemplo n.º 5
0
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);
	}
}
Ejemplo n.º 6
0
void TPanelWindowView::MouseMoved(BPoint point, uint32 transit, const BMessage * /* message */ )
{
	uint32 buttons;
	GetMouse( &point, &buttons );

	switch(transit)
	{
		case B_ENTERED_VIEW:
			Window()->PostMessage(B_ENTERED_VIEW);
			break;
		case B_EXITED_VIEW:
			if ( !fOpenMenu ) 
				Window()->PostMessage(B_EXITED_VIEW);
			break;
	}

	if ( buttons & ( transit == B_ENTERED_VIEW ) )
		fIsDraggingFromOutside = true;
	else if ( transit == B_EXITED_VIEW && fIsDraggingFromOutside)
	{
		fIsDraggingFromOutside = false;
		if ( fPreviousMouseMovedPanel )
		{
			fPreviousMouseMovedPanel->IsDragging( point, B_ENDED_DRAGGING );
			fPreviousMouseMovedPanel = 0;
		}
	}

	if ( transit == B_EXITED_VIEW )
	{
		if ( fHighlightedIcon )
		{
			SetHighlightedIcon( fHighlightedIcon->fParent, 0 );
		}
		if ( fPreviousMouseMovedPanel )
		{
			fPreviousMouseMovedPanel->MouseMoved( point, B_EXITED_VIEW );
			fPreviousMouseMovedPanel = 0;
		}
	}
	else
	{
		TInnerPanel *panel = PanelAt( point );

		if ( fIsDraggingFromOutside )
		{
			if ( panel == fPreviousMouseMovedPanel )
			{
				if ( panel )
					panel->IsDragging( point, B_IS_DRAGGING );
			}
			else
			{
				if ( panel )
					panel->IsDragging( point, B_STARTED_DRAGGING );
				if ( fPreviousMouseMovedPanel )
					fPreviousMouseMovedPanel->IsDragging( point, B_ENDED_DRAGGING );
			}
	
			fPreviousMouseMovedPanel = panel;
		}
		else
		{
			if ( panel == fPreviousMouseMovedPanel )
			{
				if ( panel )
					panel->MouseMoved( point, B_INSIDE_VIEW );
			}
			else
			{
				if ( panel )
					panel->MouseMoved( point, B_ENTERED_VIEW );
				if ( fPreviousMouseMovedPanel )
					fPreviousMouseMovedPanel->MouseMoved( point, B_EXITED_VIEW );
			}

			fPreviousMouseMovedPanel = panel;
		}
	}
}
Ejemplo n.º 7
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.º 8
0
void TPanelWindowView::HandleDroppedMessage( BMessage *message, BPoint point )
{
	if ( message->what == B_PASTE )
	{
		rgb_color *r;
		ssize_t s;

		if ( message->FindData( "RGBColor", B_RGB_COLOR_TYPE, (const void**)&r, &s ) == B_OK )
		{
			BMessage msg;
			msg.AddData( "data", B_RGB_COLOR_TYPE, r, sizeof(rgb_color) );
			SetOptions( "BackColor", &msg );
		}
	}
	else if ( message->what == B_SIMPLE_DATA || message->what == 'MIME' )
	{
		TInnerPanel *panel = PanelAt( point );

		if ( (fShortcutPanelList.CountItems() == 0) || ( modifiers() & B_CONTROL_KEY ) )
		{
			bool left = false;
			if ( point.x < (panel->Frame().left+(panel->Frame().Width()/2) ) )
			{
				left = true;
			}
						
			TShortcutPanel *cpanel = new TShortcutPanel(this);
			AddPanel( cpanel, left ? panel : 0 );
			panel = cpanel;
		}

		TShortcutPanel *pn = dynamic_cast<TShortcutPanel*>( panel );

		if ( !pn )
			pn = static_cast<TShortcutPanel*>( fShortcutPanelList.FirstItem() );

		if ( pn )
		{
			entry_ref ref;
			char *data;
			ssize_t size;
			int32 index = pn->IndexOf(pn->IconAt(point, true));
			if ( message->FindRef( "refs", &ref ) == B_OK )
			{
				AddShortcut( pn, ref, index );
			}
			else if ( message->FindData( "text/plain", 'MIME', (const void**)&data, &size ) == B_OK )
			{
				char _data[256];
				strncpy( _data, data, size );
				data[size] = 0;
				BString string( data );

				if ( string == "clock" )
					pn->AddItem( new TClockIcon(), index );
				else if ( string == "trash" )
					pn->AddItem( new TTrashIcon(), index );
				else if ( string == "workspaces" )
					pn->AddItem( new TWorkspacesIcon(), index );
				else if ( string == "separator" )
					pn->AddItem( new TSeparatorIcon(), index );
				else if ( string == "showdesktop" )
					pn->AddItem( new TShowDesktopIcon(), index );
				else if ( string == "!experimental!replicant_tab" )
				{
// todo: Fix this and the header thingo
//					AddPanel( new TReplicantShelfPanel(this) );
//					ChangedSize(0);
				}
				else if ( !strcasecmp( string.String(), "beos") )
				{
					BAlert *alert = new BAlert( "Easter Egg", "Is BeOS the best desktop operating system ever?", "Of Course!!!", "Don't think so...", "What's BeOS?" );
					int32 what = alert->Go();
					if ( what == 1 )
						(new BAlert("Answer", "BLASPHEMY!!!", "I'm evil"))->Go();
					else if ( what == 2 )
						(new BAlert("Answer", "MEDICCC! MEDICCC! We need a medic here!!", "Uh?"))->Go();
				}
				else if ( !strcasecmp( string.String(), "dockbert" ) )
				{
					char s[512];
					sprintf(s, "Build Info:\nVersion: %s %s [build %s]\nBuild Date: %s", BUILDVERSION, BUILDSTATUS, BUILDNR, BUILDDATE );
					(new BAlert( "Build Info", s, "Nice" ))->Go();
				}
				else if ( !strcasecmp( string.String(), "black-karma" ) )
				{
					(new BAlert( "Easter Egg", "hm.. two nice people developing for the best OS ever.. nice and simple.. even logic :-) Say hi to Hugo ([email protected]) or to Daniel ([email protected])", "Uh?!" ))->Go();
				}
				else if ( !strcasecmp( string.String(), "microsoft" ) || !strcasecmp( string.String(), "apple" ) )
				{
					(new BAlert( "Easter Egg", "Evil!", "eckkkkk" ))->Go();
					be_app->PostMessage(B_QUIT_REQUESTED);
				}
				else
				{
					BEntry entry( string.String() );
					if ( entry.GetRef( &ref) == B_OK )
					{
						AddShortcut( pn, ref );
					}
				}
			}
		}
	}
}