コード例 #1
0
ファイル: wg_menubar.cpp プロジェクト: tordj/WonderGUI
	uint32_t Menubar::_getItemAtAbsPos( int x, int y )
	{
		Coord pos = toLocal( Coord(x, y) );
	
		if( m_pSkin )
			pos = m_pSkin->contentRect( pos, StateEnum::Normal ).pos();
	
		if( y > 0 && x > 0 && y < (int) size().h )
		{
			int bordersWidth = _getEntryBorder().width();
	
			MenuBarItem * pItem = m_items.first();
			int		item = 1;
			while( pItem )
			{
				if(pItem->isVisible())
				{
					x -= pItem->m_width+bordersWidth;
	
					if( x < 0 )
						return item;
				}
	
				pItem = pItem->next();
				item++;
			}
		}
	
		return 0;
	}
コード例 #2
0
ファイル: wg_menubar.cpp プロジェクト: tordj/WonderGUI
	bool Menubar::_openMenu( int nb )
	{
		MenuBarItem * pItem = m_items.get(nb-1);
		if( pItem == 0 || !pItem->m_pMenu )
			return false;
	
		Coord pos = toLocal( Coord(0, 0) );
	
		if( m_pSkin )
			pos = m_pSkin->contentRect( pos, StateEnum::Normal ).pos();
	
		int bordersWidth = _getEntryBorder().width();
	
		MenuBarItem * pI = m_items.first();
		while( pI != pItem )
		{
			if( pI->isVisible() )
				pos.x += pI->m_width + bordersWidth;
	
			pI = pI->next();
		}
	
		Rect	r(pos, pI->m_width+bordersWidth, size().h );
	
	
		PopupLayer * pLayer = 0;
		if( parent() )
			pLayer = parent()->_getPopupLayer();
		if( !pLayer )
			return false;
	
		pLayer->openPopup( pItem->m_pMenu, this, r - pLayer->globalPos(), Origo::SouthWest );
		return true;
	}
コード例 #3
0
ファイル: wg_menubar.cpp プロジェクト: maerson/GUI-WonderGUI
Uint32 WgMenubar::_getItemAtAbsPos( int x, int y )
{
	WgCoord pos = ToLocal( WgCoord(x, y) );

	if( m_pSkin )
		pos = m_pSkin->ContentRect( pos, WG_STATE_NORMAL ).Pos();

	if( y > 0 && x > 0 && y < (int) Size().h )
	{
		int bordersWidth = _getEntryBorder().Width();

		WgMenuBarItem * pItem = m_items.First();
		int		item = 1;
		while( pItem )
		{
			if(pItem->IsVisible())
			{
				x -= pItem->m_width+bordersWidth;

				if( x < 0 )
					return item;
			}

			pItem = pItem->Next();
			item++;
		}
	}

	return 0;
}
コード例 #4
0
ファイル: wg_menubar.cpp プロジェクト: maerson/GUI-WonderGUI
bool WgMenubar::_openMenu( int nb )
{
	WgMenuBarItem * pItem = m_items.Get(nb-1);
	if( pItem == 0 || !pItem->m_pMenu )
		return false;

	WgCoord pos = ToLocal( WgCoord(0, 0) );

	if( m_pSkin )
		pos = m_pSkin->ContentRect( pos, WG_STATE_NORMAL ).Pos();

	int bordersWidth = _getEntryBorder().Width();

	WgMenuBarItem * pI = m_items.First();
	while( pI != pItem )
	{
		if( pI->IsVisible() )
			pos.x += pI->m_width + bordersWidth;

		pI = pI->Next();
	}

	WgRect	r(pos, pI->m_width+bordersWidth, Size().h );


	WgPopupLayer * pLayer = 0;
	if( Parent() )
		pLayer = Parent()->_getPopupLayer();
	if( !pLayer )
		return false;

	pLayer->OpenPopup( pItem->m_pMenu, this, r - pLayer->GlobalPos(), WG_SOUTHWEST );
	return true;
}
コード例 #5
0
ファイル: wg_menubar.cpp プロジェクト: tordj/WonderGUI
	void Menubar::_render( GfxDevice * pDevice, const Rect& _canvas, const Rect& _window, const Rect& _clip )
	{
		Widget::_render(pDevice,_canvas,_window,_clip);
	
		// Take backgrounds content borders into account
	
		Rect	window;
		Rect	clip;
	
		if( m_pSkin )
		{
			window = m_pSkin->contentRect( _canvas, m_state );
			clip.intersection( window, _clip );
		}
		else
		{
			window = _canvas;
			clip = _clip;
		}
	
		// Go throught the MenuBarItems and print their text and render their rectangles.
	
		MenuBarItem * pI = m_items.first();
		uint32_t posX = window.x;
	
		Pen pen;
	
	
		TextAttr	attr;
		TextTool::addPropAttributes( attr, Base::getDefaultTextprop(), StateEnum::Normal);
		TextTool::addPropAttributes( attr, m_pTextProp, StateEnum::Normal);
	
		pen.setAttributes( attr );
		pen.setClipRect( clip );
		pen.setDevice( pDevice );
	
		uint32_t printPosY = window.y + ( window.h - pen.getLineHeight() )/2 + pen.getBaseline();
	
		uint32_t itemNb = 1;
		while( pI )
		{
			if( pI->isVisible() )
			{
				State	state = StateEnum::Disabled;
				if( m_state.isEnabled() && pI->m_bEnabled )
				{
					state = StateEnum::Normal;
	
					if( itemNb == m_selectedItem )
						state = StateEnum::Pressed;
					else if( itemNb == m_markedItem )
						state = StateEnum::Hovered;
				}
	
				Border b = _getEntryBorder();
	
	//			ColorsetPtr pTextColors;
				
	//			if( m_pSkin )
	//				pTextColors = m_pSkin->TextColors();
	
				if( m_pEntrySkin )
				{
					Rect	dest( posX, window.y, pI->m_width + b.width(), window.h );
					m_pEntrySkin->render( pDevice, dest, state, clip );
	
	//				pTextColors = m_pEntrySkin->TextColors();
				}
	
				pen.setPos( Coord(posX + b.left, printPosY) );
	
				TextAttr	attr;
				TextTool::addPropAttributes( attr, Base::getDefaultTextprop(), state );
	//			TextTool::setAttrColor( attr, pTextColors, mode );
				TextTool::addPropAttributes( attr, m_pTextProp, state );
				pen.setAttributes( attr );
	
				pDevice->printLine( pen, attr, pI->m_pText );
	
				posX += pI->m_width + b.width();
			}
			itemNb++;
			pI = pI->next();
		}
	}
コード例 #6
0
ファイル: wg_menubar.cpp プロジェクト: maerson/GUI-WonderGUI
void WgMenubar::_onRender( WgGfxDevice * pDevice, const WgRect& _canvas, const WgRect& _window, const WgRect& _clip )
{
	WgWidget::_onRender(pDevice,_canvas,_window,_clip);

	// Take backgrounds content borders into account

	WgRect	window;
	WgRect	clip;

	if( m_pSkin )
	{
		window = m_pSkin->ContentRect( _canvas, m_state );
		clip.Intersection( window, _clip );
	}
	else
	{
		window = _canvas;
		clip = _clip;
	}

	// Go throught the MenuBarItems and print their text and render their rectangles.

	WgMenuBarItem * pI = m_items.First();
	Uint32 posX = window.x;

	WgPen pen;


	WgTextAttr	attr;
	WgTextTool::AddPropAttributes( attr, WgBase::GetDefaultTextprop(), WG_STATE_NORMAL);
	WgTextTool::AddPropAttributes( attr, m_pTextProp, WG_STATE_NORMAL);

	pen.SetAttributes( attr );
	pen.SetClipRect( clip );
	pen.SetDevice( pDevice );

	Uint32 printPosY = window.y + ( window.h - pen.GetLineHeight() )/2 + pen.GetBaseline();

	Uint32 itemNb = 1;
	while( pI )
	{
		if( pI->IsVisible() )
		{
			WgState	state = WG_STATE_DISABLED;
			if( m_state.IsEnabled() && pI->m_bEnabled )
			{
				state = WG_STATE_NORMAL;

				if( itemNb == m_selectedItem )
					state = WG_STATE_PRESSED;
				else if( itemNb == m_markedItem )
					state = WG_STATE_HOVERED;
			}

			WgBorder b = _getEntryBorder();

//			WgColorsetPtr pTextColors;
			
//			if( m_pSkin )
//				pTextColors = m_pSkin->TextColors();

			if( m_pEntrySkin )
			{
				WgRect	dest( posX, window.y, pI->m_width + b.Width(), window.h );
				m_pEntrySkin->Render( pDevice, dest, state, clip );

//				pTextColors = m_pEntrySkin->TextColors();
			}

			pen.SetPos( WgCoord(posX + b.left, printPosY) );

			WgTextAttr	attr;
			WgTextTool::AddPropAttributes( attr, WgBase::GetDefaultTextprop(), state );
//			WgTextTool::SetAttrColor( attr, pTextColors, mode );
			WgTextTool::AddPropAttributes( attr, m_pTextProp, state );
			pen.SetAttributes( attr );

			pDevice->PrintLine( pen, attr, pI->m_pText );

			posX += pI->m_width + b.Width();
		}
		itemNb++;
		pI = pI->Next();
	}
}