Example #1
0
RECT aRect::getGlobalGUI_RECT()
{
	RECT rect;
	rect.left   = globalLeft();
	rect.right  = globalRight();
	rect.top	= globalTop();
	rect.bottom = globalBottom();
	return rect;
}
Example #2
0
void aListBox::render()
{
	if ( showWindow )
	{
		bool bTop  =0;
		bool bBottom = 0;

		gos_SetRenderState( gos_State_Texture, 0 );
		gos_SetRenderState(gos_State_Filter, gos_FilterNone);
		gos_SetRenderState( gos_State_AlphaMode, gos_Alpha_AlphaInvAlpha );
		gos_SetRenderState( gos_State_ZCompare, 0 );
		gos_SetRenderState( gos_State_ZWrite, 0 );

		gos_DrawQuads( location, 4 );

		long topHeight = 0;
		long bottomHeight = 0;


		bool bItemOutOfRange = 0;
		for ( int i = 0; i < itemCount; i++ )
		{
			if ( items[i]->globalBottom() > globalTop()
				&& items[i]->globalTop() < globalBottom() )
			{
				items[i]->render();

				if ( items[i]->globalTop() < globalTop() )
				{
					topHeight = items[i]->height();
					bTop = 1;
					bItemOutOfRange = true;
				}
				if ( items[i]->globalBottom() >= globalBottom() )
				{
					bBottom = 1;
					if ( !bottomHeight )
						bottomHeight = items[i]->height();

					bItemOutOfRange = true;
				}
			}
			else 
			{
				bItemOutOfRange = true;
			}
		}

		// draw black box above this
		if ( bTop || bBottom )
		{
			GUI_RECT rect = { globalX(), globalY() - topHeight, globalX() + width(), globalY() };
			if ( bTop )
				drawRect( rect, 0xff000000 ); 
			rect.top = globalY() + height()+1;
			rect.bottom =globalY() + height() + bottomHeight+2;
			if ( bBottom )
				drawRect( rect, 0xff000000 );
		}
		if ( scrollBar )
		{
			if ( bItemOutOfRange )
			{
				scrollBar->Enable( 1 );
			}

			else 
				scrollBar->Enable( 0 );

			scrollBar->render();
		}

			
	}
}
Example #3
0
void aListBox::update()
{
	if ( showWindow )
	{ /* if the listbox is invisible, then we probably don't want to update it either */
		if ( scrollBar )
			scrollBar->update();


		int prevCheck = GetCheckedItem();
		int newCheck = -1;


		int iSel = -1;
		int iHighlight = -1;
		long mouseX = userInput->getMouseX();
		long mouseY = userInput->getMouseY();

		bool bInside = pointInside( mouseX, mouseY );
		if ( bInside && helpID )
		{
			::helpTextID = helpID;
		}

		for ( int i = 0; i < itemCount; i++ )
		{
			if ( bInside &&
				items[i]->pointInside(mouseX, mouseY) && items[i]->isShowing()
				&& items[i]->getState() != aListItem::DISABLED )
			{
				if ( userInput->isLeftClick() )
				{
					iSel = i;
					if ( items[i]->getState() != aListItem::SELECTED )
						g_soundSystem->playDigitalSample( clickSFX );
				}
				else 
				{
					iHighlight = i;
				}
			}

			if ( items[i]->globalBottom() > globalTop()
				&& items[i]->globalTop() < globalBottom() )
				{
					items[i]->showGUIWindow( 1 );
				}
				else
				{
					items[i]->showGUIWindow( 0 );
				}
		}

		for ( i = 0; i < itemCount; i++ )
		{
			if ( iSel == i )
			{
				items[i]->setState( aListItem::SELECTED );	
				itemSelected = i;
			}
			else if ( iHighlight == i && items[i]->getState() != aListItem::SELECTED )
			{
				if ( items[i]->getState() != aListItem::HIGHLITE )
						g_soundSystem->playDigitalSample( highlightSFX );
				items[i]->setState( aListItem::HIGHLITE );				
			}
			else if ( (iSel != -1 || items[i]->getState() != aListItem::SELECTED)
				&& items[i]->getState() != aListItem::DISABLED )
				items[i]->setState( aListItem::ENABLED );

			items[i]->update();

		}

		for ( i = 0; i < itemCount; i++ )
		{
			if ( items[i]->isChecked() && i != prevCheck )
			{
				newCheck = i;
			}
		}

		if ( singleCheck && newCheck != -1 && prevCheck != -1)
		{
			items[prevCheck]->setCheck( 0 );
		}
	}

	


}