Example #1
0
static void DrawFafaCheck(HWND w , HDC h) 
{
	RECT		r ;
	UINT		sel ;
	char		s[ CTLTITLE + 1 ] ;
	HFONT		fnt,was;

	fnt = GetFont() ;
	GetClientRect( w, & r ) ;
	GetWindowText( w, s, sizeof s ) ;
	sel = TstState( FB_SELECTED ) ;

	if (fnt)
		was = SelectObject(h,fnt) ;

	DrawCheck( h, & r, BTM_OFF + 2 * BtStyle( GetStyle() ) + sel, s ) ;

	if ( IsDisabled() )
		DrawButtonDisable( h, & r, 0 ) ;
	else if ( TstState( FB_FOCUS ) )
		DrawCheckFocus( h, & r, s ) ;

	if (fnt)
		SelectObject(h,was) ;
}
Example #2
0
void CGuiCheckBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	CDC *pDC         = CDC::FromHandle(lpDrawItemStruct->hDC);
	CRect m_rcClient(lpDrawItemStruct->rcItem);
	UINT m_State     = lpDrawItemStruct->itemState;
	CBrush cb;
	CRect m_rcTemp(m_rcClient);
	CPoint pt;
	CSize  m_Csize;
	CString m_szCaption;
	COLORREF m_Over = RGB(255, 193, 111);
	CPen cpOver(PS_SOLID, 1, RGB(255, 193, 111));
	int iMode      = pDC->SetBkMode(TRANSPARENT);
	int iExtile    = GetButtonStyle(); // obtenemos orientación del texto
	CRect m_rcText(m_rcClient);
	GetWindowText(m_szCaption);
	if (m_szCaption.GetLength() > 1)
		m_Csize= pDC->GetTextExtent(m_szCaption);

	// de acuerdo a la alineación del texto prepare la ubicación
	// del texto para Drawtex y DrawState
	
	if (m_rcClient.Height() > 13)
	{
		int Dif = m_rcClient.Height() - 13;
		Dif /= 2;
		m_rcTemp.top = Dif;
		m_rcTemp.bottom = m_rcTemp.top + 13;
	}
	if (iExtile & BS_LEFTTEXT)
	{
		m_rcTemp.left=	m_rcTemp.right - 13;
		pt = CPoint(m_rcTemp.left, m_rcTemp.top + 1);
	}
	else
	{
		m_rcTemp.right=	m_rcTemp.left + 13;
		pt = CPoint(m_rcTemp.right + 2, m_rcTemp.top + 1);
		m_rcText.left = m_rcTemp.right + 1;
	}
	
	// draw frame of checkbox
	pDC->Draw3dRect(m_rcTemp, m_clrHigh, m_clrHigh);
	m_rcTemp.DeflateRect(1, 1);
	DrawOrange(pDC, m_rcTemp);
	m_rcTemp.DeflateRect(1, 1);
	if (lpDrawItemStruct->itemState & ODS_DISABLED)
		pDC->DrawState(pt, m_Csize, m_szCaption, DSS_DISABLED, TRUE, 0, (HBRUSH)NULL);
	else 
	{
		pDC->DrawText(m_szCaption, m_rcText, DT_SINGLELINE | DT_LEFT | DT_VCENTER);			   		
		if (lpDrawItemStruct->itemState & ODS_SELECTED)
		{
			if (m_bOldTemp == TRUE)
				DrawCheck(pDC, m_rcTemp);
		}
		else
		{
			if (m_bCheckBtn == TRUE && m_bPressBtn == FALSE)
				DrawCheck(pDC, m_rcTemp);
			else
			{
				if (m_bOldTemp == TRUE && m_bPressBtn == TRUE)
					DrawCheck(pDC, m_rcTemp);
			}
		}
	}
}
Example #3
0
void
AwtMenuItem::DrawSelf(DRAWITEMSTRUCT& drawInfo)
{
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
    if (env->EnsureLocalCapacity(4) < 0) {
        return;
    }

    // self is sun.awt.windows.WMenuItemPeer
    jobject self = GetPeer(env);

    //  target is java.awt.MenuItem
    jobject target = env->GetObjectField(self, AwtObject::targetID);

    HDC hDC = drawInfo.hDC;
    RECT rect = drawInfo.rcItem;
    RECT textRect = rect;
    SIZE size;

    DWORD crBack,crText;
    HBRUSH hbrBack;

    jobject font = GetFont(env);
    jstring text = GetJavaString(env);
    size = AwtFont::getMFStringSize(hDC, font, text);

    /* 4700350: If the font size is taller than the menubar, change to the
     * default font.  Otherwise, menu text is painted over the title bar and
     * client area.  -bchristi
     */
    if (IsTopMenu() && size.cy > ::GetSystemMetrics(SM_CYMENU)) {
        env->DeleteLocalRef(font);
        font = env->NewLocalRef(GetDefaultFont(env));
        size = AwtFont::getMFStringSize(hDC, font, text);
    }

    /* Fix for bug 4257944 by [email protected]
    * check state of the parent
    */
    AwtMenu* menu = GetMenuContainer();
    DASSERT(menu != NULL && GetID() >= 0);

    //Check whether the MenuItem is disabled.
    BOOL bEnabled = (jboolean)env->GetBooleanField(target,
                                                   AwtMenuItem::enabledID);
    if (menu != NULL) {
        bEnabled = bEnabled && !menu->IsDisabledAndPopup();
    }

    if ((drawInfo.itemState) & (ODS_SELECTED)) {
        // Set background and text colors for selected item
        crBack = ::GetSysColor (COLOR_HIGHLIGHT);
        // Disabled text must be drawn in gray.
        crText = ::GetSysColor(bEnabled? COLOR_HIGHLIGHTTEXT : COLOR_GRAYTEXT);
    } else {
        // COLOR_MENUBAR is only defined on WindowsXP. Our binaries are
        // built on NT, hence the below ifdef.

#ifndef COLOR_MENUBAR
#define COLOR_MENUBAR 30
#endif
        // Set background and text colors for unselected item
        if (IS_WINXP && IsTopMenu() && AwtDesktopProperties::IsXPStyle()) {
            crBack = ::GetSysColor (COLOR_MENUBAR);
        } else {
            crBack = ::GetSysColor (COLOR_MENU);
        }
        // Disabled text must be drawn in gray.
        crText = ::GetSysColor (bEnabled ? COLOR_MENUTEXT : COLOR_GRAYTEXT);
    }

    // Fill item rectangle with background color
    hbrBack = ::CreateSolidBrush (crBack);
    DASSERT(hbrBack);
    VERIFY(::FillRect (hDC, &rect, hbrBack));
    VERIFY(::DeleteObject (hbrBack));

    // Set current background and text colors
    ::SetBkColor (hDC, crBack);
    ::SetTextColor (hDC, crText);

    int nOldBkMode = ::SetBkMode(hDC, OPAQUE);
    DASSERT(nOldBkMode != 0);

    //draw check mark
    int checkWidth = ::GetSystemMetrics(SM_CXMENUCHECK);
    // Workaround for CR#6401956
    if (IS_WINVISTA) {
        AdjustCheckWidth(checkWidth);
    }

    if (IsCheckbox()) {
        // means that target is a java.awt.CheckboxMenuItem
        jboolean state =
            (jboolean)env->GetBooleanField(target, AwtMenuItem::stateID);
        if (state) {
            DASSERT(drawInfo.itemState & ODS_CHECKED);
            RECT checkRect;
            ::CopyRect(&checkRect, &textRect);
            if (GetRTL())
                checkRect.left = checkRect.right - checkWidth;
            else
                checkRect.right = checkRect.left + checkWidth;

            DrawCheck(hDC, checkRect);
        }
    }

    ::SetBkMode(hDC, TRANSPARENT);
    int x = 0;
    //draw string
    if (!IsTopMenu()){
        textRect.left += checkWidth;
        x = (GetRTL()) ? textRect.right - checkWidth - size.cx : textRect.left;
    } else {
        x = textRect.left = (textRect.left + textRect.right - size.cx) / 2;
    }

    int y = (textRect.top+textRect.bottom-size.cy)/2;

    // Text must be drawn in emboss if the Menu is disabled and not selected.
    BOOL bEmboss = !bEnabled && !(drawInfo.itemState & ODS_SELECTED);
    if (bEmboss) {
        ::SetTextColor(hDC, GetSysColor(COLOR_BTNHILIGHT));
        AwtFont::drawMFString(hDC, font, text, x + 1, y + 1, GetCodePage());
        ::SetTextColor(hDC, GetSysColor(COLOR_BTNSHADOW));
    }
    AwtFont::drawMFString(hDC, font, text, x, y, GetCodePage());

    jstring shortcutLabel =
        (jstring)env->GetObjectField(self, AwtMenuItem::shortcutLabelID);
    if (!IsTopMenu() && shortcutLabel != NULL) {
        UINT oldAlign = 0;
        if (GetRTL()){
            oldAlign = ::SetTextAlign(hDC, TA_LEFT);
            AwtFont::drawMFString(hDC, font, shortcutLabel, textRect.left, y,
                                  GetCodePage());
        } else {
            oldAlign = ::SetTextAlign(hDC, TA_RIGHT);
            AwtFont::drawMFString(hDC, font, shortcutLabel,
                                  textRect.right - checkWidth, y,
                                  GetCodePage());
        }

        ::SetTextAlign(hDC, oldAlign);
    }

    VERIFY(::SetBkMode(hDC,nOldBkMode));

    env->DeleteLocalRef(target);
    env->DeleteLocalRef(text);
    env->DeleteLocalRef(font);
    env->DeleteLocalRef(shortcutLabel);
}
Example #4
0
void main()
{
    int sel = 0;

	redraw = 1;
	refresh = 1;
	

#ifndef CDROM
	xres_flags = XRES_SOFT;
	Enabled240p = 1;
	UseDefault = 0;
	EnabledSoft = 1;
	Enabled_C_BW = 0;
#endif

#ifdef CDROM
	RestoreGlobals();
#endif

#ifdef CDROM1	
	if(prev_select)
	{
		sel = prev_select;
		prev_select = 0;
	}
#endif

	disp_off();
	set_xres(320, xres_flags);
	if(Enabled240p)
		Set240p();

#ifndef CDROM
	disp_on();
	DrawIntro();
	disp_off();
#endif

    while(1)
    {   	
		vsync();
	
#ifdef CDROM1
		if(!HelpItem)
		{
#endif

        if(redraw)
        {
			RedrawMain();
            redraw = 0;
			refresh = 1;
			disp_on();
        }
		
		set_font_pal(15);
		
		if(refresh)
        {
            RefreshMain(sel);

            refresh = 0;
        }

        controller = joytrg(0);
		
		if (controller & JOY_SEL)
		{
#ifdef CDROM1
			x_g = 0;
#endif
			Options();
			redraw = 1;
		}
        
        if (controller & JOY_DOWN) 
        {
            sel++;
            if(sel > 14)
                sel = 0;
            refresh = 1;
        }

        if (controller & JOY_UP) 
        {
            sel--;
            if(sel < 0)
                sel = 14;
            refresh = 1;
        }
		
		if (controller & JOY_RUN)
		{
			showHelp(GENERAL_HELP);
			redraw = 1;
		}
#ifdef CDROM1
		}
		else
		{
			if(HelpItem <= OPTIONS_HELP)
			{
				sel = HelpItem;
				controller = JOY_I;
			}
				
			HelpItem = 0;
		}
#endif
		
		if (controller & JOY_I)
		{
			disp_off();
			ResetVideo();
			switch(sel)
			{
				case 0:
#ifndef CDROM1
					TestPatterns();
#else
					xres_flags_g = xres_flags;
					Enabled240p_g = Enabled240p;
					UseDefault_g = UseDefault;
					EnabledSoft_g = EnabledSoft;
					Enabled_C_BW_g = Enabled_C_BW;
					
					set_font_pal(14);
					put_string("Loading...", 27, 26);
					cd_execoverlay(PATTERNS_OVERLAY);
#endif
					break;
				case 1:
					DropShadow();
					break;
				case 2:
					StripedSprite();
					break;
				case 3:
					LagTest();
					break;
				case 4:
					ManualLagTest();
					break;
				case 5:
					ScrollTest();
					break;
				case 6:
					VScrollTest();
					break;
				case 7:
					DrawStripes();
					break;
				case 8:
					DrawCheck();
					break;
				case 9:
					LEDZoneTest();
					break;
				case 10:
					SoundTest();
					break;
				case 11:
					AudioSyncTest();
					break;
				case 12:
#ifdef CDROM1
					prev_select = sel;
#endif
					Options();
					break;
				case 13:
#ifdef CDROM1
					prev_select = sel;
#endif
					showHelp(GENERAL_HELP);
					break;
				case 14:
					DrawCredits();
					break;
			}
			redraw = 1;			
			disp_off();
		}
    }
}