Exemple #1
0
void MenuBar::DrawItem(GC &gc, int n)
{
	if (n<0 || n>=list.count()) return;
	
	UiCondList ucl;
	if (n == select && InFocus()) ucl.Set(uiCurrentItem, true);
		
	int color_text = UiGetColor(uiColor, uiItem, &ucl, 0x0);
	int color_bg = UiGetColor(uiBackground, uiItem, &ucl, 0xFFFFFF);

	gc.Set(GetFont());
	crect itemRect = ItemRect(n);

	gc.SetFillColor(color_bg);
	if (n == select && InFocus()) gc.FillRect(itemRect);	

	if (n == select) {
		DrawBorder(gc, itemRect, UiGetColor(uiCurrentItemFrame, uiItem, &ucl, 0xFFFFFF));
	}

	gc.SetTextColor( color_text );
	
	const unicode_t *text = list[n].text.ptr();
	cpoint tsize = gc.GetTextExtents(text);
	int x = itemRect.left + (itemRect.Width()-tsize.x)/2;
	int y = itemRect.top + (itemRect.Height()-tsize.y)/2;
	
#ifdef _WIN32	
	gc.TextOut(x,y,text);
#else	
	gc.TextOutF(x,y,text);
#endif	
}
void Win::SetFocus()
{
	if (InFocus()) return;
	if (!IsVisible()) return;
//	if (type != WT_POPUP && parent) parent->SetFocus();
	::SetFocus(handle);
}
Exemple #3
0
	void VListWin::Paint( GC& gc, const crect& paintRect )
	{
		crect rect = ClientRect();

		switch ( borderType )
		{
			case SINGLE_BORDER:
				DrawBorder( gc, rect, InFocus() ? 0x00C000 : borderColor );
				break;

			case BORDER_3D:
				Draw3DButtonW2( gc, rect, bgColor, false );

			default:
				;
		}

		if ( !scrollRect.IsEmpty() )
		{
			gc.SetFillColor( 0xD0D0D0 );
			gc.FillRect( scrollRect ); //CCC
		}

		if ( itemHeight > 0 )
		{
			int n = ( rect.Height() + ( itemHeight - 1 ) ) / itemHeight;
			crect r = this->listRect;
			int bottom = r.bottom;
			r.bottom = r.top + itemHeight;

			for ( int i = 0; i < n; i++ )
			{
				gc.SetClipRgn( &r );
				crect r1( r );
				r1.left -= xOffset;
				this->DrawItem( gc, i + first, r1 );
				r.top += itemHeight;
				r.bottom += itemHeight;

				if ( r.bottom > bottom ) { r.bottom = bottom; }
			}
		}
		else
		{
			//на всякий случай
			rect.Dec();
			gc.SetFillColor( bgColor );
			gc.FillRect( rect );
		}
	}
Exemple #4
0
bool MenuBar::EventMouse(cevent_mouse* pEvent)
{
	int n;
	if (pEvent->Type() == EV_MOUSE_PRESS)
	{
		n = GetPointItem(pEvent->Point());
		if (n>=0) {
			SetSelect(n);
			OpenSub();
			return true;
		}
		if (sub.ptr())
		{
			crect rect = ScreenRect();
			crect sr = sub->ScreenRect();
			pEvent->Point().x += rect.left - sr.left;
			pEvent->Point().y += rect.top - sr.top;
			if (sub->EventMouse(pEvent)) return true;
			SetSelect(-1);
			if (Parent()) Parent()->Command(CMD_MENU_INFO, SCMD_MENU_CANCEL, this, 0);
		}
		return true;
	} else  if (pEvent->Type() == EV_MOUSE_MOVE) {
		n = GetPointItem(pEvent->Point());
		if (n>=0) {
			if (lastMouseSelect != n) {
				lastMouseSelect = n;
				SetSelect(n);
			}
			return true;
		}
		if (!sub.ptr() && !InFocus()) {
			lastMouseSelect = -1;
			SetSelect(-1);
			return true;
		}
		
		if (sub.ptr())
		{
			crect rect = ScreenRect();
			crect sr = sub->ScreenRect();
			pEvent->Point().x += rect.left - sr.left;
			pEvent->Point().y += rect.top - sr.top;
			return sub->EventMouse(pEvent);
		}
		
		return true;
	}
	return false;
}
	void SButton::Paint( GC& gc, const crect& paintRect )
	{
		crect cr = ClientRect();

		unsigned colorBg = UiGetColor( uiBackground, 0, 0, 0xFFFFFF );

		gc.SetFillColor( colorBg ); //CCC
		gc.FillRect( cr );

		if ( group > 0 )
		{
			DrawCE( gc, 1, ( cr.Height() - 13 ) / 2, IsSet() );
		}
		else
		{
			DrawCB( gc, 1, ( cr.Height() - 13 ) / 2, IsSet() );
		}

		gc.Set( GetFont() );
		cpoint tsize = text.GetTextExtents(gc);

		gc.SetFillColor( colorBg );
		//gc.SetTextColor( UiGetColor( uiColor, 0, 0, 0 ) );

		//gc.TextOutF( 14 + 1 + 1 + 1 , ( cr.Height() - tsize.y ) / 2, text.data() );
		UiCondList ucl;
		int color_text = UiGetColor(uiColor, uiItem, &ucl, 0x0);
		int color_hotkey = UiGetColor(uiHotkeyColor, uiItem, &ucl, 0x0);
		text.DrawItem(gc, 14 + 1 + 1 + 1, (cr.Height() - tsize.y) / 2, color_text, color_hotkey);

		if ( InFocus() )
		{
			crect rect;
			rect.left = 14 + 2;
			rect.top = ( cr.Height() - tsize.y - 2 ) / 2;
			rect.right = rect.left + tsize.x + 4;
			rect.bottom = rect.top + tsize.y + 2;
			DrawBorder( gc, rect, UiGetColor( uiFocusFrameColor, 0, 0, 0 ) ); //CCC
		}
	}
Exemple #6
0
void GUICONTROL::OnSelect(float x, float y) const
{
	if (!InFocus(x, y))
		return;

	if (onselectx.connected())
	{
		float sx = (x - m_xmin) / (m_xmax - m_xmin);
		sx = (sx <= 1) ? (sx >= 0) ? sx : 0 : 1;
		std::stringstream s;
		s << sx;
		onselectx(s.str());
	}

	if (onselecty.connected())
	{
		float sy = (y - m_ymin) / (m_ymax - m_ymin);
		std::stringstream s;
		s << sy;
		onselectx(s.str());
	}
}
	void Button::Paint( GC& gc, const crect& paintRect )
	{
		unsigned colorBg = UiGetColor(uiBackground, uiClassButton, 0, 0x808080); //GetColor(0);
		crect cr = this->ClientRect();
		crect rect = cr;
		DrawBorder( gc, rect, ColorTone( colorBg, +20 ) );
		rect.Dec();
		DrawBorder( gc, rect, ColorTone( colorBg, -200 ) );
		rect.Dec();

		gc.SetFillColor( colorBg );
		gc.FillRect( rect );

		if ( pressed )
		{
#if USE_3D_BUTTONS
			Draw3DButtonW2( gc, rect, colorBg, false );
#endif
			rect.Dec();
			rect.Dec();
		}
		else
		{
#if USE_3D_BUTTONS
			Draw3DButtonW2( gc, rect, colorBg, true );
#endif
			rect.Dec();

			if ( InFocus() )
			{
				DrawBorder( gc, rect, /*GetColor(IC_FOCUS_MARK)*/ UiGetColor( uiFocusFrameColor, 0, 0, 0 ) );
			}

#if USE_3D_BUTTONS
			rect.Dec();
#endif
		}

		//gc.SetTextColor( /*GetColor(IsEnabled() ? IC_TEXT : IC_GRAY_TEXT)*/ UiGetColor( uiColor, 0, 0, 0 ) );
		gc.Set( GetFont() );
		cpoint tsize = text.GetTextExtents(gc);

		/*
		int l = tsize.x + (icon.ptr() ? icon->Width() + ICONX_RIGHTSPACE : 0);

		int w = rect.Width() - LEFTSPACE - RIGHTSPACE;

		if (icon.ptr()) w-=ICONX_RIGHTSPACE;

		//int x = rect.left + LEFTSPACE + (w > l ? (w - l)/2 : 0) +(pressed?2:0);
		int x = rect.left + LEFTSPACE + (w-l)/2 +(pressed?2:0);
		*/

		int l = tsize.x + ( icon.ptr() ? icon->Width() + ICONX_RIGHTSPACE : 0 );
		int w = rect.Width();
		int x = rect.left + ( w > l ? ( w - l ) / 2 : 0 ) + ( pressed ? 2 : 0 );


		if ( icon.ptr() )
		{
			gc.DrawIcon( x, rect.top + ( rect.Height() - icon->Height() ) / 2 + ( pressed ? 2 : 0 ), icon.ptr() );
			x += icon->Width() + ICONX_RIGHTSPACE;
		}

		gc.SetClipRgn( &rect );
		text.DrawItem(gc, x, rect.top + (rect.Height() - tsize.y) / 2 + (pressed ? 2 : 0), 
			UiGetColor(uiColor, uiClassButton, 0, 0), 
			UiGetColor(uiHotkeyColor, uiClassButton, 0, 0));
	}
Exemple #8
0
void MenuBar::EventEnterLeave(cevent *pEvent)
{
	if (pEvent->Type() == EV_LEAVE && !InFocus() && !sub.ptr())
		SetSelect(-1);

}