Ejemplo n.º 1
0
WgMenuItem * WgMenu::_getItemAtPos( int x, int y )
{
	WgBorder	contentBorder = _getPadding();

	x -= contentBorder.left;
	y -= contentBorder.top;

	y += m_contentOfs;

	if( y > 0 && x > 0 && x < (int) ( Geo().w - contentBorder.right ) )
	{
		WgMenuItem * pItem = m_items.First();
		while( pItem )
		{
			if( pItem->IsVisible() )
			{
				if( pItem->GetType() == SEPARATOR )
					y -= m_sepHeight;
				else
					y -= m_entryHeight;

				if( y < 0 )
				{
					return pItem;
				}
			}
			pItem = pItem->Next();
		}
	}

	return 0;
}
Ejemplo n.º 2
0
// ERR packet (see http://dev.mysql.com/doc/internals/en/packet-ERR_Packet.html)
static void _responseError(mysql_t *mysql) {
        mysql->state = MySQL_Error;
        mysql->response.data.error.code = _getUInt2(&mysql->response);
        if (mysql->capabilities & CLIENT_PROTOCOL_41)
                _getPadding(&mysql->response, 6); // skip sql_state_marker and sql_state which we don't use
        mysql->response.data.error.message = _getString(&mysql->response);
        THROW(IOException, "Server returned error code %d -- %s", mysql->response.data.error.code, mysql->response.data.error.message);
}
Ejemplo n.º 3
0
WgRect WgMenu::_scrollbarGeo( const WgRect& menuGeo ) const
{
	if( m_scrollbarHook._widget() )
	{
		WgRect contentGeo = menuGeo - _getPadding();
		WgRect scrollbarGeo( contentGeo.x + contentGeo.w - m_scrollbarHook.m_size.w, contentGeo.y, m_scrollbarHook.m_size.w, contentGeo.h );	//TODO: Scrollbar is now hardcoded to right side.
		return scrollbarGeo;
	}
	else
		return WgRect();
}
Ejemplo n.º 4
0
void WgMenu::_setViewOfs(int pos)
{
	int viewHeight = Size().h - _getPadding().Height();

	if( pos + viewHeight > m_contentHeight )
		pos = m_contentHeight - viewHeight;

	if( pos < 0 )
		pos = 0;

	if( pos != (int) m_contentOfs )
	{
		m_contentOfs = pos;
		_requestRender();
	}
}
Ejemplo n.º 5
0
float WgMenu::_setPosition( float fraction )
{
	if( fraction < 0.f )
		fraction = 0.f;

	if( fraction > 1.f )
		fraction = 1.f;

	int viewHeight = Size().h - _getPadding().Height();

	int ofs = (int) (fraction * (m_contentHeight-viewHeight));

	_setViewOfs(ofs);

	return fraction;
}
Ejemplo n.º 6
0
// Initial handshake packet (see http://dev.mysql.com/doc/internals/en/connection-phase-packets.html#packet-Protocol::Handshake)
static void _responseHandshake(mysql_t *mysql) {
        mysql->state = MySQL_Handshake;
        // Protocol is 10 for MySQL 5.x
        if (mysql->response.header != 10)
                THROW(IOException, "Invalid protocol version %d", mysql->response.header);
        mysql->response.data.handshake.version = _getString(&mysql->response);
        mysql->response.data.handshake.connectionid = _getUInt4(&mysql->response);
        snprintf(mysql->response.data.handshake.authdata, 9, "%s", _getString(&mysql->response)); // auth_plugin_data_part_1
        mysql->response.data.handshake.capabilities = _getUInt2(&mysql->response); // capability flags (lower 2 bytes)
        mysql->response.data.handshake.characterset = _getUInt1(&mysql->response);
        mysql->response.data.handshake.status = _getUInt2(&mysql->response);
        mysql->response.data.handshake.capabilities |= _getUInt2(&mysql->response) << 16; // merge capability flags (lower 2 bytes + upper 2 bytes)
        mysql->response.data.handshake.authdatalen = _getUInt1(&mysql->response);
        _getPadding(&mysql->response, 10); // reserved bytes
        if (mysql->response.data.handshake.capabilities & CLIENT_SECURE_CONNECTION)
                snprintf(mysql->response.data.handshake.authdata + 8, 13, "%s", _getString(&mysql->response)); // auth_plugin_data_part_2
        mysql->capabilities = mysql->response.data.handshake.capabilities; // Save capabilities
        DEBUG("MySQL Server: Protocol: %d, Version: %s, Connection ID: %d\n", mysql->response.header, mysql->response.data.handshake.version, mysql->response.data.handshake.connectionid);
}
Ejemplo n.º 7
0
int WgMenu::_getViewSize()
{
	return Size().h-_getPadding().Height();
}
Ejemplo n.º 8
0
float WgMenu::_getHandlePosition()
{
	return ((float)m_contentOfs) / (m_contentHeight-(Size().h-_getPadding().Height()));
}
Ejemplo n.º 9
0
float WgMenu::_wheelRolled( int distance )
{
	int viewHeight = Size().h - _getPadding().Height();
	_setViewOfs( m_contentOfs + m_entryHeight*distance );
	return _getHandlePosition();
}
Ejemplo n.º 10
0
float WgMenu::_jumpBwd()
{
	int viewHeight = Size().h - _getPadding().Height();
	_setViewOfs( m_contentOfs - (viewHeight - m_entryHeight) );
	return _getHandlePosition();
}
Ejemplo n.º 11
0
void WgMenu::_adjustSize()
{
	WgBorder contentBorder = _getPadding();

	int  w = contentBorder.Width();
	int	 h = contentBorder.Height();

	int minSep = m_sepBorder.Width();
	if( m_pSeparatorSkin )
		minSep += m_pSeparatorSkin->MinSize().w;

	WgMenuItem * pItem = m_items.First();
	while( pItem )
	{
		if( pItem->IsVisible() )
		{
			if( pItem->GetType() == SEPARATOR )
			{
				h += m_sepHeight;
				if( w < minSep )
					w = minSep;
			}
			else
			{
				h += m_entryHeight;

				int minW = ((WgMenuEntry*)pItem)->m_minWidth + contentBorder.Width() + m_iconFieldWidth + m_arrowFieldWidth;

				if( w < minW )
					w = minW;
			}
		}


		pItem = pItem->Next();
	}

	m_contentHeight = h - contentBorder.Height();

	if( h < m_entryHeight + contentBorder.Height() )
		h = m_entryHeight + contentBorder.Height();


	if( w != m_defaultSize.w || h != m_defaultSize.h )
	{
		m_defaultSize.w = w;
		m_defaultSize.h = h;
		_requestResize();
	}

	if( h > Size().h )
	{
		WgScrollbar * pScrollbar = m_scrollbarHook.Scrollbar();
		if( !pScrollbar )
		{
			pScrollbar = new WgScrollbar();
			pScrollbar->SetSkins( 0, m_pScrollbarBgSkin, m_pScrollbarHandleSkin, m_pScrollbarBtnBwdSkin, m_pScrollbarBtnFwdSkin );
			pScrollbar->SetButtonLayout( m_scrollbarBtnLayout );
			pScrollbar->SetScrollbarTarget(this);
		}
		WgSize scrollbarSize = pScrollbar->PreferredSize();

		m_scrollbarHook.m_size.w = scrollbarSize.w;
		m_scrollbarHook.m_size.h = Size().h - contentBorder.Height();

		m_scrollbarHook._setWidget(pScrollbar);

		_updateScrollbar( _getHandlePosition(), _getHandleSize() );
	}
	else
	{
		if( m_scrollbarHook._widget() )
		{
			m_scrollbarHook._setWidget(0);
		}
	}

	_setViewOfs(m_contentOfs);		// Refresh offset.
}