Exemple #1
0
	void
	DocWindowFrame::onButtonPressEvent(
		xcb_button_press_event_t*	event)
	{
		printf("Beginning drag\n");

		beginDrag(mFrameWindow, event->detail,
				event->root_x, event->root_y,
				event->event_x, event->event_y);

		int32_t			x, y;
		getCurrentDragPos(x, y);
		drawDragOutline(x, y);

	}
Exemple #2
0
void Camera::EventHandler(const Event &e)
{
	if(type == TRACKBALL)
	{
		if(e.Type == E_MOUSEPRESS)
		{
			if(e.MouseInput.Type == LMOUSE_PRESS)
			{
				beginDrag(e.MouseInput.X,e.MouseInput.Y);
			}
			else if(e.MouseInput.Type == LMOUSE_RELEASE)
			{
				isDragging = false;
			}
		}
		else if(e.Type == E_MOUSEMOVE && isDragging)
		{
			drag(e.MouseInput.X,e.MouseInput.Y);
		}
	}
}
 MRESULT EXPENTRY icqFrameWindow(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
 {
    switch(msg)
    {
    case WM_DDE_INITIATEACK:
       return (MRESULT) icqDDEInitiateAck(hwnd, (HWND)mp1, (PDDEINIT)mp2);

    case WM_DDE_DATA:
       DBGMessage("WM_DDE_DATA");
       icqDDEData(hwnd, (PDDESTRUCT) mp2);
       break;

    case WM_CLOSE:
       DBGMessage("WM_CLOSE");
       close(hwnd);
       break;

    case WM_CREATE:
       icqskin_cfgWindow(hwnd,ICQFRAME,0);
       break;

    case WM_DESTROY:
       destroy(hwnd);
       break;

    case WM_ERASEBACKGROUND:
       erase(hwnd,(HPS) mp1, (PRECTL) mp2);
       break;

    case WM_SIZE:
       resize(hwnd,SHORT1FROMMP(mp2),SHORT2FROMMP(mp2));
       broadcast(hwnd,WMICQ_AUTOSIZE,0,0);
       break;

    case WM_PAINT:
       paint(hwnd);
       break;

    case WM_SETICON:
       WinSendMsg(WinQueryWindow(hwnd,QW_PARENT),msg,mp1,mp2);
       break;

    case WM_COMMAND:
       action(hwnd,SHORT1FROMMP(mp1), SHORT1FROMMP(mp2));
       break;

    case WM_PRESPARAMCHANGED:
       ppchanged(hwnd,LONGFROMMP(mp1));
       break;

    case WM_SETWINDOWPARAMS:
       return setparm(hwnd, PVOIDFROMMP(mp1), mp2);

    case WMICQ_SETNAME:
//       strncpy( ((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->name, (const char *) mp1, 19);
       ((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->name = (const char *) mp1;
       break;

    case WMICQ_SETICQHANDLE:
       DBGTracex(mp1);
       ((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->icq = (HICQ) mp1;
       break;

    case WMICQ_GETICQHANDLE:
       return (MRESULT) ((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->icq;

    case WMICQ_SETBUTTONTBL:
       setbuttons(hwnd,(const struct icqButtonTable *) mp1, (int) mp2);
       break;

    case WMICQ_QUERYPALLETE:
       return (MRESULT) ((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->pal;

    case WMICQ_EVENT:  // MP1 = type,code,user  MP2 = parm
       event(hwnd,CHAR3FROMMP(mp1),CHAR4FROMMP(mp1),SHORT1FROMMP(mp1),(ULONG) mp2);
       break;

    case WMICQ_SELECTPAL:
       icqskin_loadPallete( (HPS) mp1, 0, ((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->pal);
       break;

    case 0x041E:
       return WinDefWindowProc(hwnd, msg, mp1, mp2);

    case 0x041F:
       return WinDefWindowProc(hwnd, msg, mp1, mp2);

    case WM_BEGINDRAG:
       return beginDrag(hwnd, (POINTS *) &mp1);

    case WM_ENDDRAG:
       return endDrag(hwnd);

    case WM_TIMER:
       timer(hwnd);
       break;

#ifdef SKINNED_GUI
    case WMICQ_QUERYBGIMAGE:
       return (MRESULT) ((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->bg;
#else
    case WMICQ_QUERYBGIMAGE:
       return (MRESULT) NO_IMAGE;
#endif

    case WM_OWNERPOSCHANGE:
       DBGMessage("WM_OWNERPOSCHANGE");
       return WinDefWindowProc(hwnd,msg,mp1,mp2);

    case WM_MOUSEMOVE:
       if(WinQueryCapture(HWND_DESKTOP) == hwnd);
          saveMouse(hwnd,SHORT1FROMMP(mp1),SHORT2FROMMP(mp1));
       return WinDefWindowProc(hwnd,msg,mp1,mp2);

    case WMICQ_CLEAR:
       clearSkin( (ICQFRAME *) WinQueryWindowPtr(hwnd,0));
       break;

    case WMICQ_LOADSKIN:
       loadSkin(hwnd,(const char *) mp1, (SKINFILESECTION *) mp2);
       break;

    case WMICQ_SKINCHILDS:
       loadSkin4Childs(hwnd,(const char *) mp1, (SKINFILESECTION *) mp2);
       break;

    case WMICQ_RESTORE:
       restoreWindow(hwnd,(const char *) mp1,SHORT1FROMMP(mp2),SHORT2FROMMP(mp2));
       break;

    case WMICQ_STORE:
       storeWindow(hwnd,(const char *) mp1);
       break;

    case WMICQ_CONFIGURE:
       configure(hwnd,(int) mp1);
       break;

    case WMICQ_SETMSGCHILD:
       createchild(hwnd, (const MSGCHILD *) mp1, SHORT1FROMMP(mp2));
       break;

    case WMICQ_SKINELEMENT:
       skinElement(hwnd,(HWND) mp1, (const char **) mp2);
       break;

    case WMICQ_DRAWCONTENTS:
       break;

    case WMICQ_AUTOSIZE:
       autoSize(hwnd);
       break;

    case WMICQ_SIZEBUTTONS:
       return (MRESULT) sizeButtonBar(hwnd,SHORT1FROMMP(mp1),SHORT2FROMMP(mp1),(const USHORT *) mp2);

    case WMICQ_INVALIDATE:
       DBGMessage("WMICQ_INVALIDATE");
       WinInvalidateRect(hwnd,NULL,TRUE);
       break;

    /*---[ SysTray ]--------------------------------------------*/

    case WM_BUTTON2CLICK | 0x2000:
       icqShowPopupMenu(((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->icq, 0, ICQMNU_MODES, 0, 0);
       return (MRESULT) TRUE;

    case WM_BUTTON1CLICK | 0x2000:
       openMessage(((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->icq);
       return (MRESULT) TRUE;

    case WM_TRAYEXIT:	// When tray exits/crashes, it posts WM_TRAYEXIT (0xCD20) to all tray windows.
       icqDisableSysTray(((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->icq);
       return (MRESULT) TRUE;

    /*---[ Default window processing ]--------------------------*/

    default:
       return WinDefWindowProc(hwnd,msg,mp1,mp2);
    }
    return 0;
 }
Exemple #4
0
/*********************************************
		SDL event loop
**********************************************/
void App::utilEventLoop(){

	SDL_Event event;

    while ( !done ){
	   
	    while ( SDL_PollEvent( &event ) ){
	    
	    	//Hand the event off to the GUI first. If the GUI handles it, it's
	    	//done. 
#ifdef ENABLE_GUI
	    	if(processGUIEvent(event)){
	    		continue;
	    	}
#endif
	    
		    switch( event.type ){
						      
			case SDL_VIDEORESIZE:
			    //handle resize event
			    surface = SDL_SetVideoMode( event.resize.w, event.resize.h, 
			    							16, videoFlags );
			    if ( !surface ){
				    ERR( "Could not get a surface after resize: %s\n", 
				    	SDL_GetError( ) );
				    notifyShutdown();
				}
			    resizeWindow( event.resize.w, event.resize.h );
#ifdef ENABLE_GUI
			    resizeGUI( event.resize.w, event.resize.h );
#endif
			    break;
			
			case SDL_QUIT:
			    //handle quit requests
			    notifyShutdown();
			    break;
			
			case SDL_MOUSEBUTTONDOWN:
								
				if(mFlowMgr->onClick(event.button.button, 
									fMouseX, fMouseY, fMouseZ)){
					break;
				}			
				
				onMouseEvent(event.button.button, SDL_MOUSEBUTTONDOWN); 
				beginDrag();
												
				break;	
				
			case SDL_MOUSEBUTTONUP:
				onMouseEvent(event.button.button, SDL_MOUSEBUTTONUP); 
				endDrag();
				break;	
				
			case SDL_KEYDOWN:
				handleKeyEvent(&event.key.keysym, event.type);
				break;
			
			case SDL_KEYUP:
				handleKeyEvent(&event.key.keysym, event.type);
				break;
			
			default:
			    break;
			}
		}
		
	    if (!done){
	    
	    	//Do one frames worth of work and figure out the length of time
	    	uint32_t startTime = SDL_GetTicks();
			renderMain();
			updateMain();
			uint32_t endTime = SDL_GetTicks();
			
			//Figure out the scaling factor for FPS-independent movement
			uint32_t diff = endTime - startTime;
			
			if (iMaxFrameRate > 0 && diff < 1000 / iMaxFrameRate) {
				SDL_Delay((1000 / iMaxFrameRate) - diff);
				diff = 1000 / iMaxFrameRate;
			}
			
			fTimeScale = (float)diff * fTimeScaleScale;
			
			//Every hour, do a cleanup
			if(fCleanupTimer < 0.0f){
				ps()->doPeriodicCleanup();				
				fCleanupTimer = CLEANUP_TIMER;
			}
			
			//Update our various timers
			fCleanupTimer -= fTimeScale;
			fUptime += fTimeScale;
			fParticleFPS = fTimeScale;
		}
	}
	
}
Exemple #5
0
void MechBayScreen::update()
{

	mechListBox.disableItemsThatCanNotGoInFG();

	if ( !pIcons[0].getMech() )
		getButton( MB_MSG_REMOVE )->disable( true );

	// update current text
	char str[64];

	// RP
	sprintf( str, "%ld ", LogisticsData::instance->getCBills() );
	textObjects[1].setText( str );

	long mouseX = userInput->getMouseX();
	long mouseY = userInput->getMouseY();
	if ( userInput->isLeftClick() && dropWeightMeter.pointInside( mouseX, mouseY ) )
	{
		soundSystem->playDigitalSample( LOG_WRONGBUTTON );
	}
	
	// current drop weight
	char tmpStr[128];
	cLoadString( IDS_MB_WEIGHT, tmpStr, 63 );
	long currentDropWeight = LogisticsData::instance->getCurrentDropWeight();
	long maxDropWeight = LogisticsData::instance->getMaxDropWeight();

	sprintf( str, tmpStr, currentDropWeight, maxDropWeight );
	textObjects[6].setText( str );


	// update drag and drop
	// must be done before Icon's are updated, or we can get out of sync
	if ( pDragMech )
	{
		dragIcon.moveTo( userInput->getMouseX() - dragIcon.width() / 2, 
			userInput->getMouseY() - dragIcon.height() / 2 );

		bool bLeft = 0;
		bool bRight = 0;
		
		GUI_RECT testRect;
		testRect.left = mechListBox.globalX();
		testRect.right = mechListBox.globalX() + mechListBox.width();
		testRect.top = mechListBox.globalY();
		testRect.bottom = mechListBox.globalY() + mechListBox.height();


		if ( dragIcon.rectIntersect( testRect ) )
		{
			// set the focus
		}	bRight = true;

		testRect.left = pIcons[0].globalX();
		testRect.right = pIcons[ICON_COUNT - 1].globalX() + pIcons[0].width();
		testRect.top = pIcons[0].globalY();
		testRect.bottom = pIcons[ICON_COUNT-1].globalY() + pIcons[0].height();

		if ( dragIcon.rectIntersect( testRect ) )
		{
			bLeft = true;
		}
		else 
			bLeft = 0;

		if ( userInput->leftMouseReleased() || userInput->isLeftDoubleClick() )
		{
			if ( dragLeft )
			{
				if ( bLeft )
				{
					LogisticsData::instance->removeMechFromForceGroup( pDragMech, false );
					LogisticsData::instance->addMechToForceGroup( pDragMech, forceGroupCount+1 );
					forceGroupCount++;

					reinitMechs();
				}
				else
				{
					if ( 0 == LogisticsData::instance->getVariantsInInventory( pDragMech->getVariant(), 0 ) )
					{ 
						MechListBoxItem* item = new MechListBoxItem( pDragMech, 0 );
						int index = mechListBox.AddItem( item );
						mechListBox.SelectItem( index );
					}
					LogisticsData::instance->removeMechFromForceGroup( pDragMech, true );
					forceGroupCount--;
					reinitMechs();

					removeWeightAmount = pDragMech->getMaxWeight();
					removeWeightAnim.begin();
					addWeightAnim.end();
				}
			}
			else
			{
				if ( bLeft )
				{
					reinitMechs();
					addWeightAmount = pDragMech->getMaxWeight();
					addWeightAnim.begin();
					removeWeightAnim.end();
		
				}
				else
				{
					if ( 0 == LogisticsData::instance->getVariantsInInventory( pDragMech->getVariant(), 0 ) )
					{
						MechListBoxItem* item = new MechListBoxItem( pDragMech, 0 );
						int index = mechListBox.AddItem( item );
						mechListBox.SelectItem( index );
					}
					LogisticsData::instance->removeMechFromForceGroup( pDragMech, true );
					reinitMechs();

				}
			}
		
			pDragMech = 0;
		}

	}


	// update icon selection
	int newSel = -1;
	int oldSel = -1;
	int removeMech = -1;
	for ( int i = 0; i < ICON_COUNT; i++ )
	{
		pIcons[i].update();
		if ( pIcons[i].justSelected() )
			newSel = i;
		else if ( pIcons[i].isSelected() )
			oldSel = i;

		bool bInside = pIcons[i].pointInside( userInput->getMouseX(), userInput->getMouseY() );

		if ( bInside && userInput->isLeftDoubleClick() && pIcons[i].getMech() )
		{
			 removeMech = i;
		}
		else if ( userInput->isLeftDrag() 
			&& pIcons[i].pointInside( userInput->getMouseDragX(), userInput->getMouseDragY() ) )
		{
			beginDrag( pIcons[i].getMech() );
		}
	}

	if ( newSel != -1 )
	{
		if ( oldSel != -1 )
			pIcons[oldSel].select( 0 );
		mechListBox.SelectItem( -1 );
		
	}
	if ( removeMech != -1 )
	{
		 removeSelectedMech();
	}


	if ( !MPlayer || !ChatWindow::instance()->pointInside(userInput->getMouseX(), userInput->getMouseY()) )
		LogisticsScreen::update();
	
	if ( newSel == -1 && oldSel == -1 )
	{
		// disable the remove button
		getButton( MB_MSG_REMOVE )->disable(1);
	}
	else
		getButton( MB_MSG_REMOVE )->disable(0);

	
	// update list box, 
	oldSel = mechListBox.GetSelectedItem();
	mechListBox.update();
	newSel = mechListBox.GetSelectedItem( );

	// did anything change?
	if ( oldSel != newSel && newSel != -1)
	{
		unselectDeploymentTeam();
	}

	// component list box
	loadoutListBox.update();	

	addWeightAnim.update();
	removeWeightAnim.update();

	LogisticsMech* pTmp = mechListBox.getCurrentMech();
	if ( !pTmp )
	{
		pTmp = getFGSelMech();
	}

	if ( pTmp )
		setMech( pTmp, 0);

	// update buttons!
	if ( newSel == -1 || !LogisticsData::instance->canAddMechToForceGroup( mechListBox.getCurrentMech() ) )
	{
		// disable the add button
		getButton( MB_MSG_ADD )->disable(1);
	}
	else
		getButton( MB_MSG_ADD )->disable(0);

		

	if ( MPlayer && ( !MPlayer->missionSettings.variants || !pCurMech ) )
	{
		getButton( MB_MSG_CHANGE_LOADOUT )->disable( true );
	}
	else if ( LogisticsData::instance->skipPurchasing() )
	{
		getButton( MB_MSG_CHANGE_LOADOUT )->disable( true );
		getButton( MB_MSG_BUY )->disable( true );
	}
	else 
	{
		getButton( MB_MSG_CHANGE_LOADOUT )->disable( false );
		getButton( MB_MSG_BUY )->disable( false );

		if ( !pCurMech )
			getButton( MB_MSG_CHANGE_LOADOUT )->disable( true );
		else
		{
			getButton( MB_MSG_CHANGE_LOADOUT )->disable( false );
			mechCamera->update();
		}
	}





	if ( MPlayer && ChatWindow::instance() )
		ChatWindow::instance()->update();



}
void PilotReadyScreen::update()
{
	if ( MPlayer )
	{
		if ( MPlayer->playersReadyToLoad() )
			status = NEXT;
	}

	if ( getButton( MB_MSG_PREV )->isEnabled() ) // this is disabled if the user has already pressed launch )
	{
		// update current text
		char str[64];

		// RP
		sprintf( str, "%ld ", LogisticsData::instance->getCBills() );
		textObjects[1].setText( str );

		for ( int i = 0; i < 4; i++ )
			skillIcons[i].update();
		

		// desel icons if necessary
		bool bAllFull = 1;
		int newSel = -1;
		int oldSel = -1;
		bool bHasMech = 0;
		int newRightSel = -1;
		for ( i = 0; i < ICON_COUNT; i++ )
		{
			pIcons[i].update();
			if ( pIcons[i].justSelected() )
				newSel = i;
			else if ( pIcons[i].isSelected() )
				oldSel = i;

			bool bInside = pIcons[i].pointInside( userInput->getMouseX(), userInput->getMouseY() ); 

			
			if ( userInput->isLeftDoubleClick() && bInside && pIcons[i].getMech() )
			{
				removeSelectedPilot();
			}
			if ( userInput->isRightClick() && bInside && pIcons[i].getMech() )
			{
				newRightSel = i;
			}
			else if ( userInput->isLeftDrag() 
				&& bInside
				&& pIcons[i].pointInside( userInput->getMouseDragX(), userInput->getMouseDragY() )
				&& pIcons[i].getMech() )
			{
				beginDrag( pIcons[i].getMech()->getPilot() );
				pIcons[i].dimPilot( true );
				pIcons[i].setPilot( NULL );
			}

			if ( pIcons[i].getMech() && !pIcons[i].getPilot() )
				bAllFull = 0;

			if ( pIcons[i].getMech() )
				bHasMech = true;
		}

		if ( newSel != -1 )
		{
			if ( oldSel != -1 )
				pIcons[oldSel].select( 0 );

			if ( pIcons[newSel].getPilot() )
			{
				setPilot( pIcons[newSel].getPilot() );
			}
			else
				setMech( pIcons[newSel].getMech() );
		}

		if ( newRightSel != -1 )
		{
			setMech( pIcons[newRightSel].getMech() );
		}

		long curSel = newSel == -1 ? oldSel : newSel;

	
		if ( !MPlayer || !ChatWindow::instance()->pointInside(userInput->getMouseX(), userInput->getMouseY()) )
			LogisticsScreen::update();

		if ( mechSelected && 
			( !MPlayer || !ChatWindow::instance()->pointInside(userInput->getMouseX(), userInput->getMouseY()) ))
		{
			if ( userInput->getMouseY() > 317 )
			{
				helpID = 0;
				textObjects[helpTextArrayID].setText( "" );
			}
			mechDisplay.update();
		}

		
		if ( !bAllFull ) // disable the next button until all have pilots
		{
			buttons[1].disable( 1 );

			if ( curSel == -1 || pIcons[curSel].getPilot() )
				buttons[2].disable( 1 );
			else
				buttons[2].disable( 0 );
		}
		else
		{
			if ( bHasMech )
				buttons[1].disable( 0 );
			else
				buttons[1].disable( 1 );

			buttons[2].disable( 1 );
		}


		if ( ( newSel == -1 && oldSel == -1 )|| !pIcons[curSel].getPilot())
		{
			// disable the remove button
			buttons[3].disable(1);
		}
		else
			buttons[3].disable(0);


		for ( i = 0; i < MAX_MEDAL; i++ ) // so we get rollovers
			medalIcons[i].update();

		
		// update drag and drop
		if ( pDragPilot )
		{
			dragIcon.moveTo( userInput->getMouseX() - dragIcon.width() / 2, 
				userInput->getMouseY() - dragIcon.height() / 2 );

			LogisticsMechIcon* pSelIcon = 0;
			
			for ( int i = 0; i < ICON_COUNT; i++ )
			{
				if ( pIcons[i].pointInside( userInput->getMouseX(), userInput->getMouseY() )
					&& pIcons[i].getMech() )
				{
					pSelIcon = &pIcons[i];
					break;
				}
			}
		

			if ( userInput->leftMouseReleased(  ) )
			{
				endDrag(pSelIcon);	
			}

		}

		pilotListBox.update();

	
	}

	if ( MPlayer && ChatWindow::instance() )
		ChatWindow::instance()->update();



}
void MechLabScreen::updateDiagramInput()
{
	long mouseX = userInput->getMouseX();
	long mouseY = userInput->getMouseY();


	if ( rects[13].pointInside( mouseX, mouseY ) )
	{
		long x, y, x2, y2;
		getMouseDiagramCoords( x, y );	
		
		if ( x != -2 )
		{
			// now offset by size of the component
			if ( pDragComponent )
			{
				long screenX, screenY;
				diagramToScreen( x, y, screenX, screenY );

				x -= pDragComponent->getComponentWidth()/2;
				y -= pDragComponent->getComponentHeight()/2;

				if ( mouseX - screenX > LogisticsComponent::XICON_FACTOR/2
					&& pDragComponent->getComponentWidth()/2)
				{
					x += 1;
				}	
			}

			if ( x < 0 )
				x = 0;

			if ( x >= pVariant->getComponentAreaWidth() - 1 ) 
				x = pVariant->getComponentAreaWidth() - 1;

			if ( y < 0 )
				y = 0;

			if ( y >= pVariant->getComponentAreaHeight() - 1 )
				y = pVariant->getComponentAreaHeight() - 1;

			
			if ( pDragComponent )
			{
				x2 = x + pDragComponent->getComponentWidth();
				y2 = y + pDragComponent->getComponentHeight();	

				if ( x2 > pVariant->getComponentAreaWidth() )
				{
					x = pVariant->getComponentAreaWidth() - pDragComponent->getComponentWidth();
					x2 = pVariant->getComponentAreaWidth();
				}

				if ( y2 > pVariant->getComponentAreaHeight() )
				{
					y = pVariant->getComponentAreaHeight() - pDragComponent->getComponentHeight();
					y2 = pVariant->getComponentAreaHeight();
				}
			}
			else
			{
				x2 = x + 1;
				y2 = y + 1;
			}
		
			long tmpX, tmpY;

			diagramToScreen( x, y, tmpX, tmpY );			

			// update outline rect
			if ( selRect )
				selRect->moveTo( tmpX, tmpY );			


			// highlight text if appropriate
			LogisticsComponent* pComp = pVariant->getCompAtLocation(x, y, tmpX, tmpY );
			if ( pComp )
			{
				long compX, compY, compX2, compY2;
				diagramToScreen( tmpX, tmpY, compX, compY );
				diagramToScreen( tmpX + pComp->getComponentWidth(), tmpY + pComp->getComponentHeight(), compX2, compY2 );
				if ( (compX <= userInput->getMouseX() && compX2 >= userInput->getMouseX()
					&& compY <= userInput->getMouseY() && compY2 >= userInput->getMouseY())
					|| tmpX == -2 )
				{
					::helpTextID = IDS_HELP_COMP0 + pComp->getID();
				}
			}
		}
		else if ( selRect )
		{
			selRect->moveTo( rects[6].left() + rects[6].width()/2 - selRect->width()/2,
							rects[6].top() + rects[6].height()/2 - selRect->height()/2);
		}
		// check for jump jet hot text
		if ( x == -2 && y == -2 )
		{
			long tmpX, tmpY;
			LogisticsComponent* pComp = pVariant->getCompAtLocation(x, y, tmpX, tmpY );
			if ( pComp )
			{
				long compX, compY, compX2, compY2;
				diagramToScreen( tmpX, tmpY, compX, compY );
				diagramToScreen( tmpX + pComp->getComponentWidth(), tmpY + pComp->getComponentHeight(), compX2, compY2 );
				if ( (compX <= userInput->getMouseX() && compX2 >= userInput->getMouseX()
					&& compY <= userInput->getMouseY() && compY2 >= userInput->getMouseY())
					|| tmpX == -2 )
				{
					::helpTextID = IDS_HELP_COMP0 + pComp->getID();
				}
			}
		}
		

		if ( pDragComponent )
		{
			if (NO_ERR == pVariant->canAddComponent( pDragComponent, x, y )
				&& x != -1 && y != -1 )
			{
				selRect->setColor( 0xffffffff );
			}
			else
				selRect->setColor( 0xffff0000 );			
		}			
		else if ( userInput->isLeftDrag() )
		{
			long i, j;
			getMouseDiagramCoords( i, j );

			if ( i != -1 && j != -1 )
			{
				LogisticsComponent* pComp = pVariant->getCompAtLocation(i, j, selI, selJ );
				if ( pComp && pComp == pSelectedComponent )
				{
					if ( canRemoveComponent( pComp ) )
					{
						componentListBox.SelectItem( -1 );
						beginDrag( pComp );
						bDragLeft = true;
						removeComponent( i, j );
						setComponent( pComp );
						updateDiagram();
					}
					else
						soundSystem->playDigitalSample( LOG_WRONGBUTTON );
				}
				else
					pSelectedComponent = 0;
			}

		}
		else if ( userInput->isLeftDoubleClick() )
		{
			long tmpI, tmpJ;
			getMouseDiagramCoords( tmpI, tmpJ );

			if ( tmpI != -1 && tmpJ != -1 )
			{
				selI = tmpI;
				selJ = tmpJ;
				LogisticsComponent* pComp = pVariant->getCompAtLocation(tmpI, tmpJ, selI, selJ );
				if ( pComp )
				{
					if ( canRemoveComponent( pComp ) )
					{
						removeComponent( selI, selJ );
						componentListBox.SelectItem( -1 );
						if ( -1 == selectFirstDiagramComponent() )
							selectFirstLBComponent();				
					}
					else
						soundSystem->playDigitalSample( LOG_WRONGBUTTON );
				}
			}
		
		}
		else if ( userInput->isLeftClick() )
		{
			long tmpI, tmpJ;
			getMouseDiagramCoords( tmpI, tmpJ );

			if ( tmpI != -1 && tmpJ != -1 )
			{
				selI = tmpI;
				selJ = tmpJ;
				LogisticsComponent* pComp = pVariant->getCompAtLocation(tmpI, tmpJ, selI, selJ );
				if ( pComp )
				{
					pSelectedComponent = pComp;
					setComponent( pComp );
					soundSystem->playDigitalSample( LOG_SELECT );
					componentListBox.SelectItem( -1 );
				}
			}
		}		
	}

	if ( userInput->leftMouseReleased() && pDragComponent )
			endDrag();


}