Example #1
0
void CCMenuItemColor::updateColor() {
    if(isSelected()) {
        _displayedColor.r = _realColor.r = m_selectedColor.r;
        _displayedColor.g = _realColor.g = m_selectedColor.g;
        _displayedColor.b = _realColor.b = m_selectedColor.b;
        _displayedOpacity = _realOpacity = m_selectedColor.a;
    } else if(isFocus()) {
        _displayedColor.r = _realColor.r = m_focusColor.r;
        _displayedColor.g = _realColor.g = m_focusColor.g;
        _displayedColor.b = _realColor.b = m_focusColor.b;
        _displayedOpacity = _realOpacity = m_focusColor.a;
    } else if(isEnabled()) {
        _displayedColor.r = _realColor.r = m_normalColor.r;
        _displayedColor.g = _realColor.g = m_normalColor.g;
        _displayedColor.b = _realColor.b = m_normalColor.b;
        _displayedOpacity = _realOpacity = m_normalColor.a;
    } else {
        _displayedColor.r = _realColor.r = m_disabledColor.r;
        _displayedColor.g = _realColor.g = m_disabledColor.g;
        _displayedColor.b = _realColor.b = m_disabledColor.b;
        _displayedOpacity = _realOpacity = m_disabledColor.a;
    }
    
    for(unsigned int i = 0; i < 4; i++) {
        m_pSquareColors[i].r = _displayedColor.r / 255.0f;
        m_pSquareColors[i].g = _displayedColor.g / 255.0f;
        m_pSquareColors[i].b = _displayedColor.b / 255.0f;
        m_pSquareColors[i].a = _displayedOpacity / 255.0f;
    }
}
Example #2
0
void EHUD::TimeStep()
{
	HUDEVENT * ev;
	for (int i = 0; i < events.size(); i++)
	{
		if (!events[i])
			continue;
		ev = events[i];

		if (!isNull(ev->From))
		{
			if (!isFocus(ev->From))
				continue;
		}
		oapiAnnotationSetText(ev->hNote,ev->Ann->msg);
	}
	Prune();
}
Example #3
0
void GTextCtrl::onRender()
{
	Vec2i pos = getWorldPos();
	Vec2i size = getSize();

	glEnable(GL_BLEND);
	glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
	glColor4f( 0.1, 0.1 , 0.1 , 0.8f );
	drawRect( pos , size );
	glColor3f( 1,1,1);
	glDisable(GL_BLEND);


	if( isFocus() )
		text->setColor(Color(50,255,50));
	else
		text->setColor(Color(150,150,150));

	getRenderSystem()->drawText( text , pos + size / 2 );
}
Example #4
0
bool XWidget::devEvent(X_Event *event)
{
	//如果是此组件
	if(JUDGEMOUSE(event,widget_rect))
	{
		//先判断子组件是否符合
		if(layout && layout->responseEvent(event) )
		{
			return true;
		}

		switch(event->type)
		{
#ifdef USE_MOUSE
			case SDL_MOUSEMOTION:
				{
					mouseEnterEvent(event);
					
					if(isFocus() && event->motion->state == SDL_PRESSED)
					{
						focusEnter();	
					}else if(!isFocus() && event->motion->state == SDL_PRESSED)
					{
						XAbstractWidget::focus_widget->focusLeave();	
					}
				}
				break;
				
			case SDL_MOUSEBUTTONDOWN:
				{
					switch(event->mouse_type)
					{
						case X_BUTTON_LEFT:
							{
								XAbstractWidget::setFocusWidget(this);
								mouseLPressEvent(event);
							}
							break;
							
						case X_BUTTON_RIGHT:
							{
								mouseRPressEvent(event);	
							}
							
						case X_BUTTON_WHEELUP:
							{
								mouseWheelUp(event);
							}
							break;
							
						case X_BUTTON_WHEELDOWN:
							{
								mouseWheelDown(event);
							}
							break;
							
						case X_BUTTON_MIDDLE:
							{
								mouseMPressEvent(event);	
							}
							break;
					}
						
					if(mouse_listener)
					{
						mouse_listener->mousePressed(event,(ID)this);
					}
				
				}
				break;
				
 			case SDL_MOUSEBUTTONUP:
				{	
					switch(event->mouse_type)
					{
						case X_BUTTON_LEFT:
							{
								//printf("this=%x,focus=%x\n",this,XWidgetProcess::focus_widget);
								if(isFocus())
								{
									mouseLReleaseEvent(event);
								}
							}
							break;
							
						case X_BUTTON_RIGHT:
							{
								mouseRReleaseEvent(event);	
							}
							break;
						case X_BUTTON_WHEELUP:
							{
								mouseWheelUp(event);
							}
							break;
							
						case X_BUTTON_WHEELDOWN:
							{
								mouseWheelDown(event);
							}
							break;
							
						case X_BUTTON_MIDDLE:
							{
								mouseMReleaEvent(event);	
							}
							break;
					}
				
					if(mouse_listener)
					{
						mouse_listener->mouseReleased(event,(ID)this);
					}
				}
				break;
#endif
		}
		return true;
	}
#ifdef USE_KEYBOARD
	switch(event->type)
	{
			case X_KEYDOWN:
				{
					keydownEvent(event);
				}
				break;
			case X_KEYUP:
				{
					keyReleaseEvent(event);
				}
				break;
	}
#endif
	return false;	
}