Exemplo n.º 1
0
bool CHexEdit::SetFontFaceName( const CString& sFaceName )
{
    LOGFONT lgfnt;

    GetTextFont( &lgfnt );
    strcpy( lgfnt.lfFaceName, sFaceName );
    SetTextFont( lgfnt );
    return true;
}
Exemplo n.º 2
0
bool CHexEdit::SetFontHeight( int nHeight )
{
    LOGFONT lgfnt;
    GetTextFont( &lgfnt );
    lgfnt.lfHeight  = -MulDiv(nHeight, GetDeviceCaps(GetDC()->m_hDC, LOGPIXELSY), 72);
    lgfnt.lfWidth   = 0;
    SetTextFont( lgfnt );
    return true;
}
Exemplo n.º 3
0
// --------------------------------------------------------------
void
GDeviceWin32::DrawString( float x, float y, const char * s, int inCharCount )
{
	if( s == 0 ) return;
	SetTextFont(mCurrTextFont);
	if( inCharCount < 0 )
		inCharCount = (int)strlen( s );
	::TextOut( mHDC, RInt( x ), RInt( y ), s, inCharCount );
}
Exemplo n.º 4
0
void ButtonComponent::ParseAttribute(const TiXmlAttribute* attribute)
{
	Component::ParseAttribute(attribute);
	if (IsEqual(attribute->Name(), "texture_focused"))
	{
		SetTexture(FOCUSED, attribute->Value());
	}
	else if (IsEqual(attribute->Name(), "texture_unfocused"))
	{
		SetTexture(UNFOCUSED, attribute->Value());
	}
	else if (IsEqual(attribute->Name(), "size"))
	{
		SetSize(ParseVector2f(attribute->Value()));
	}
	else if (IsEqual(attribute->Name(), "next_menu"))
	{
		m_nextMenu = attribute->Value();
	}
	else if (IsEqual(attribute->Name(), "type"))
	{
		SetType(GetTypeIndex(attribute->Value()));
	}
	else if (IsEqual(attribute->Name(), "style"))
	{
		SetStyle(GetStyleIndex(attribute->Value()));
	}
	else if (IsEqual(attribute->Name(), "text"))
	{
		SetText(attribute->Value());
	}
	else if (IsEqual(attribute->Name(), "text_font"))
	{
		SetTextFont(attribute->Value());
	}
	else if (IsEqual(attribute->Name(), "text_size"))
	{
		SetFontSize(attribute->UnsignedValue());
	}
	else if (IsEqual(attribute->Name(), "text_color"))
	{
		SetTextColor(ParseVector3f(attribute->Value()));
	}
	else if (IsEqual(attribute->Name(), "text_highlight_color"))
	{
		SetHighlightTextColor(ParseVector3f(attribute->Value()));
	}
	else if (IsEqual(attribute->Name(), "has_textures"))
	{
		SetIfHasTextures(attribute->BoolValue());
	}
	else if (IsEqual(attribute->Name(), "text_highlights"))
	{
		SetIfTextHighlights(attribute->BoolValue());
	}
}
Exemplo n.º 5
0
bool CHexEdit::SetFontItalic( bool bItalic )
{
    LOGFONT lgfnt;

    GetTextFont( &lgfnt );
    lgfnt.lfItalic  = bItalic ? TRUE : FALSE;

    SetTextFont( lgfnt );
    return true;
}
Exemplo n.º 6
0
void CXTPPopupItem::SetTextFont(CFont* pFntText)
{
    ASSERT(pFntText);
    if (!pFntText)
        return;

    LOGFONT lf;
    pFntText->GetLogFont(&lf);

    SetTextFont(&lf);
}
Exemplo n.º 7
0
bool CHexEdit::SetFontBold( bool bBold )
{
    LOGFONT lgfnt;

    GetTextFont( &lgfnt );
    lgfnt.lfWeight  = bBold?FW_BOLD:FW_DONTCARE;

    SetTextFont( lgfnt );

    return true;
}
void
ESChildOpenFontDialogBox::SetFont(_Font* pFont, bool bRedraw){
	SetTextFont(pFont, false);

	if( !m_textFont.IsNull() ){
		LOGFONT lf;
		m_textFont.GetLogFont(&lf);
		SetText(lf.lfFaceName, false, false);
		}

	if( bRedraw )
		Redraw(false);
	}
Exemplo n.º 9
0
GUITextBox::GUITextBox()
{
	Init();
	SetCaption(NULL);
	SetCaptionFont(NULL);
	SetCaptionColor(DEFAULT_TEXT_COLOR);
	SetText("");
	SetTextFont(NULL);
	SetTextColor(DEFAULT_TEXT_COLOR);
	SetTextCaretPos(0);
	SetShift(false);
	SetTextLength(0);
	SetMaxTextLength(DEFAULT_MAX_TEXT_LENGTH);
}
Exemplo n.º 10
0
void MadEdit::SetEncoding(const wxString &encname)
{
    if(encname.Lower() != m_Encoding->GetName().Lower())
    {
        //delete m_Encoding;
        m_Encoding=wxm::WXMEncodingManager::Instance().GetWxmEncoding(encname);
        m_Lines->SetEncoding(m_Encoding);
        m_Syntax->SetEncoding(m_Encoding);

        wxString fontname;
        m_Config->Read(wxString(wxT("/Fonts/"))+m_Encoding->GetName(), &fontname, m_Encoding->GetFontName());

        bool oldlf=m_LoadingFile;
        m_LoadingFile=true;
        SetTextFont(fontname, m_TextFont->GetPointSize(), false);
        m_LoadingFile=oldlf;

        if(!m_LoadingFile)
        {
            if(IsTextFile())    // data is text
            {
                ReformatAll();
            }
            else // hex data
            {
                AppearCaret();
                UpdateScrollBarPos();

                if(!m_CaretAtHexArea)
                {
                    UpdateTextAreaXPos();
                    m_LastTextAreaXPos = m_TextAreaXPos;
                }
            }

            DoStatusChanged();
            DoSelectionChanged();

            m_RepaintAll = true;
            Refresh(false);
        }
    }
}
bool CDJWStatic::SetTextFont( LONG nHeight, bool bBold, bool bItalic, const CString& sFaceName )
{
	LOGFONT lgfnt;

	lgfnt.lfHeight			= -MulDiv(nHeight, GetDeviceCaps(GetDC()->m_hDC, LOGPIXELSY), 72);
	lgfnt.lfWidth			= 0;
	lgfnt.lfEscapement		= 0;
	lgfnt.lfOrientation		= 0;
	lgfnt.lfWeight			= bBold?FW_BOLD:FW_DONTCARE;
	lgfnt.lfItalic			= bItalic?TRUE:FALSE;
	lgfnt.lfUnderline		= FALSE;
	lgfnt.lfStrikeOut		= FALSE;
	lgfnt.lfCharSet			= DEFAULT_CHARSET;
	lgfnt.lfOutPrecision	= OUT_DEFAULT_PRECIS;
	lgfnt.lfClipPrecision	= CLIP_DEFAULT_PRECIS;
	lgfnt.lfQuality			= DEFAULT_QUALITY;
	lgfnt.lfPitchAndFamily	= DEFAULT_PITCH | FF_DONTCARE;

	//strcpy_s( lgfnt.lfFaceName,(char*)(LPCTSTR)sFaceName );
	return SetTextFont( lgfnt );
}
Exemplo n.º 12
0
HFONT UserSelectFont( void ) 
{
    // Allow the user to specify the text font to use with
    // dynamic text scrolling.  Display the Windows ChooseFont() dialog.
    return (SetTextFont(TRUE));
}
Exemplo n.º 13
0
BOOL CTaskbarNotifier::LoadConfiguration(LPCTSTR szFileName)
{
	TCHAR szConfigDir[MAX_PATH];
	int nRed, nGreen, nBlue, sRed, sGreen, sBlue;
	int rcLeft, rcTop, rcRight, rcBottom;
	int bmpTrasparentRed, bmpTrasparentGreen, bmpTrasparentBlue;
	int fontSize;
	CString fontType, bmpFullPath, strBmpFileName;

	Hide();

	m_strConfigFilePath = szFileName;
	CIni ini(szFileName, _T("CONFIG"));
	_tcsncpy(szConfigDir, szFileName, _countof(szConfigDir));
	szConfigDir[_countof(szConfigDir)-1] = _T('\0');
	LPTSTR pszFileName = _tcsrchr(szConfigDir, _T('\\'));
	if (pszFileName == NULL)
		return FALSE;
	*(pszFileName + 1) = _T('\0');

	nRed   = ini.GetInt(_T("TextNormalRed"),255);
	nGreen = ini.GetInt(_T("TextNormalGreen"),255);
	nBlue  = ini.GetInt(_T("TextNormalBlue"),255);
	sRed   = ini.GetInt(_T("TextSelectedRed"),255);
	sGreen = ini.GetInt(_T("TextSelectedGreen"),255);
	sBlue  = ini.GetInt(_T("TextSelectedBlue"),255);
	bmpTrasparentRed   = ini.GetInt(_T("bmpTrasparentRed"),255);
	bmpTrasparentGreen = ini.GetInt(_T("bmpTrasparentGreen"),0);
	bmpTrasparentBlue  = ini.GetInt(_T("bmpTrasparentBlue"),255);
	fontType = ini.GetString(_T("FontType"), _T("MS Shell Dlg"));
	fontSize = ini.GetInt(_T("FontSize"), 8) * 10;
	m_dwTimeToStay = ini.GetInt(_T("TimeToStay"), 4000);
	m_dwTimeToShow = ini.GetInt(_T("TimeToShow"), 500); 
	m_dwTimeToHide = ini.GetInt(_T("TimeToHide"), 200);
	strBmpFileName = ini.GetString(_T("bmpFileName"), _T(""));
	if (!strBmpFileName.IsEmpty()) {
		if (PathIsRelative(strBmpFileName))
			bmpFullPath.Format(_T("%s%s"), szConfigDir, strBmpFileName);
		else
			bmpFullPath = strBmpFileName;
	}

	// get text rectangle coordinates
	rcLeft = ini.GetInt(_T("rcTextLeft"),5);
	rcTop  = ini.GetInt(_T("rcTextTop"),45);	
	rcRight  = ini.GetInt(_T("rcTextRight"),220 );
	rcBottom = ini.GetInt(_T("rcTextBottom"), 85);
	if (rcLeft<=0)	  rcLeft=1;
	if (rcTop<=0)	  rcTop=1;
	if (rcRight<=0)	  rcRight=1;
	if (rcBottom<=0)  rcBottom=1;
	SetTextRect(CRect(rcLeft,rcTop,rcRight,rcBottom));

	// get close button rectangle coordinates
	rcLeft = ini.GetInt(_T("rcCloseBtnLeft"),286);
	rcTop  = ini.GetInt(_T("rcCloseBtnTop"),40); 
	rcRight  = ini.GetInt(_T("rcCloseBtnRight"), 300);
	rcBottom = ini.GetInt(_T("rcCloseBtnBottom"), 54);
	if (rcLeft<=0)	  rcLeft=1;
	if (rcTop<=0)	  rcTop=1;
	if (rcRight<=0)	  rcRight=1;
	if (rcBottom<=0)  rcBottom=1;
	SetCloseBtnRect(CRect(rcLeft,rcTop,rcRight,rcBottom));

	// get history button rectangle coordinates
	rcLeft = ini.GetInt(_T("rcHistoryBtnLeft"),283);
	rcTop  = ini.GetInt(_T("rcHistoryBtnTop"),14);	
	rcRight  = ini.GetInt(_T("rcHistoryBtnRight"), 299);
	rcBottom = ini.GetInt(_T("rcHistoryBtnBottom"), 39);
	if (rcLeft<=0)	  rcLeft=1;
	if (rcTop<=0)	  rcTop=1;
	if (rcRight<=0)	  rcRight=1;
	if (rcBottom<=0)  rcBottom=1;
	SetHistoryBtnRect(CRect(rcLeft,rcTop,rcRight,rcBottom));

	if (bmpFullPath.IsEmpty() || !SetBitmap(bmpFullPath, bmpTrasparentRed, bmpTrasparentGreen, bmpTrasparentBlue))
	{
		CEnBitmap imgTaskbar;
		if (imgTaskbar.LoadImage(IDR_TASKBAR, _T("GIF")))
		{
			if (!SetBitmap(&imgTaskbar, bmpTrasparentRed, bmpTrasparentGreen, bmpTrasparentBlue))
				return FALSE;
		}
	}

	SetTextFont(fontType, fontSize, TN_TEXT_NORMAL,TN_TEXT_UNDERLINE);
	SetTextColor(RGB(nRed, nGreen, nBlue), RGB(sRed, sGreen, sBlue));
	return TRUE;
}
Exemplo n.º 14
0
BOOL CTaskbarNotifier::LoadConfiguration(LPCTSTR pszFilePath)
{
	struct _stat st;
	st.st_mtime = -1; // '-1' = missing file
	(void)_tstat(pszFilePath, &st);
	if (   m_strConfigFilePath.CompareNoCase(pszFilePath) == 0
		&& st.st_mtime == m_tConfigFileLastModified)
		return TRUE;

	TCHAR szConfigDir[MAX_PATH];
	int iTextNormalRed, iTextNormalGreen, iTextNormalBlue;
	int iTextSelectedRed, iTextSelectedGreen, iTextSelectedBlue;
	int iLeft, iTop, iRight, iBottom;
	int iBmpTransparentRed, iBmpTransparentGreen, iBmpTransparentBlue;
	int iFontSize;
	CString strFontType, strBmpFilePath, strBmpFileName;

	Hide();

	m_strConfigFilePath = pszFilePath;
	CIni ini(pszFilePath, _T("Config"));
	_tcsncpy(szConfigDir, pszFilePath, _countof(szConfigDir));
	szConfigDir[_countof(szConfigDir)-1] = _T('\0');
	LPTSTR pszFileName = _tcsrchr(szConfigDir, _T('\\'));
	if (pszFileName == NULL)
		return FALSE;
	*(pszFileName + 1) = _T('\0');

	iTextNormalRed = ini.GetInt(_T("TextNormalRed"), 255);
	iTextNormalGreen = ini.GetInt(_T("TextNormalGreen"), 255);
	iTextNormalBlue = ini.GetInt(_T("TextNormalBlue"), 255);

	iTextSelectedRed = ini.GetInt(_T("TextSelectedRed"), 255);
	iTextSelectedGreen = ini.GetInt(_T("TextSelectedGreen"), 255);
	iTextSelectedBlue = ini.GetInt(_T("TextSelectedBlue"), 255);

	// for backward compatibility read the old values (which had a typo) and then the new values
	iBmpTransparentRed = ini.GetInt(_T("BmpTrasparentRed"), 255);
	iBmpTransparentRed = ini.GetInt(_T("BmpTransparentRed"), iBmpTransparentRed);
	iBmpTransparentGreen = ini.GetInt(_T("BmpTrasparentGreen"), 0);
	iBmpTransparentGreen = ini.GetInt(_T("BmpTransparentGreen"), iBmpTransparentGreen);
	iBmpTransparentBlue = ini.GetInt(_T("BmpTrasparentBlue"), 255);
	iBmpTransparentBlue = ini.GetInt(_T("BmpTransparentBlue"), iBmpTransparentBlue);

	strFontType = ini.GetString(_T("FontType"), _T("MS Shell Dlg"));
	iFontSize = ini.GetInt(_T("FontSize"), 8) * 10;

	m_dwTimeToStay = ini.GetInt(_T("TimeToStay"), 4000);
	m_dwTimeToShow = ini.GetInt(_T("TimeToShow"), 500); 
	m_dwTimeToHide = ini.GetInt(_T("TimeToHide"), 200);

	strBmpFileName = ini.GetString(_T("BmpFileName"), _T(""));
	if (!strBmpFileName.IsEmpty()) {
		if (PathIsRelative(strBmpFileName))
			strBmpFilePath.Format(_T("%s%s"), szConfigDir, strBmpFileName);
		else
			strBmpFilePath = strBmpFileName;
	}

	// get text rectangle coordinates
	iLeft = ini.GetInt(_T("rcTextLeft"), 5);
	iTop = ini.GetInt(_T("rcTextTop"), 45);	
	iRight = ini.GetInt(_T("rcTextRight"), 220);
	iBottom = ini.GetInt(_T("rcTextBottom"), 85);
	if (iLeft <= 0)
		iLeft = 1;
	if (iTop <= 0)
		iTop = 1;
	if (iRight <= 0)
		iRight = 1;
	if (iBottom <= 0)
		iBottom = 1;
	SetTextRect(CRect(iLeft, iTop, iRight, iBottom));

	// get close button rectangle coordinates
	iLeft = ini.GetInt(_T("rcCloseBtnLeft"), 286);
	iTop = ini.GetInt(_T("rcCloseBtnTop"), 40); 
	iRight = ini.GetInt(_T("rcCloseBtnRight"), 300);
	iBottom = ini.GetInt(_T("rcCloseBtnBottom"), 54);
	if (iLeft <= 0)
		iLeft = 1;
	if (iTop <= 0)
		iTop = 1;
	if (iRight <= 0)
		iRight = 1;
	if (iBottom <= 0)
		iBottom = 1;
	SetCloseBtnRect(CRect(iLeft, iTop, iRight, iBottom));

	// get history button rectangle coordinates
	iLeft = ini.GetInt(_T("rcHistoryBtnLeft"), 283);
	iTop = ini.GetInt(_T("rcHistoryBtnTop"), 14);	
	iRight = ini.GetInt(_T("rcHistoryBtnRight"), 299);
	iBottom = ini.GetInt(_T("rcHistoryBtnBottom"), 39);
	if (iLeft <= 0)
		iLeft = 1;
	if (iTop <= 0)
		iTop = 1;
	if (iRight <= 0)
		iRight = 1;
	if (iBottom <= 0)
		iBottom = 1;
	SetHistoryBtnRect(CRect(iLeft, iTop, iRight, iBottom));

	if (strBmpFilePath.IsEmpty() || !SetBitmap(strBmpFilePath, iBmpTransparentRed, iBmpTransparentGreen, iBmpTransparentBlue))
	{
		CEnBitmap imgTaskbar;
		if (imgTaskbar.LoadImage(IDR_TASKBAR, _T("GIF")))
		{
			if (!SetBitmap(&imgTaskbar, iBmpTransparentRed, iBmpTransparentGreen, iBmpTransparentBlue))
				return FALSE;
		}
	}

	SetTextFont(strFontType, iFontSize, TN_TEXT_NORMAL, TN_TEXT_UNDERLINE);
	SetTextColor(RGB(iTextNormalRed, iTextNormalGreen, iTextNormalBlue), 
			     RGB(iTextSelectedRed, iTextSelectedGreen, iTextSelectedBlue));

	m_tConfigFileLastModified = st.st_mtime;
	return TRUE;
}
Exemplo n.º 15
0
wxFlatButton::wxFlatButton(wxWindow* parent,
                           const wxString& label,
                           const wxFlatButton::eTheme theme,
                           const wxBitmap& bmp,
                           const wxSize& size,
                           int style)
    : wxFlatButtonBase(parent)
    , m_theme(theme)
    , m_state(kStateNormal)
    , m_text(label)
    , m_bmp(bmp)
    , m_accelIndex(wxNOT_FOUND)
    , m_kind(kKindNormal)
    , m_isChecked(false)
    , m_contextMenu(NULL)
    , m_isDisabled(false)
    , m_style(style)
{
    SetBackgroundStyle(wxBG_STYLE_PAINT);

    // Parse the label
    wxString tmpLabel;
    m_text.Replace("&&", "@@");
    // Parse the label
    for(size_t i = 0; i < m_text.length(); ++i) {
        if(m_accelIndex == wxNOT_FOUND && m_text.GetChar(i) == '&') {
            m_accelIndex = i;
            continue;
        } else {
            tmpLabel << m_text.GetChar(i);
        }
    }

    tmpLabel.Replace("@@", "&");
    m_text.swap(tmpLabel);

    // Colours - dark theme
    if(m_theme == kThemeDark) {
        SetPenNormalColour("rgb(48, 48, 48)");
        SetPenPressedColour("rgb(125, 125, 125)");
        SetBgPressedColour("rgb(48, 48, 48)");
        SetBgHoverColour("rgb(80, 80, 80)");
        SetBgColour("rgb(65, 65, 65)");
        m_penHoverColourInner = "rgb(160, 160, 160)";
        m_penHoverOuterColour = GetPenNormalColour();
        SetTextColour("rgb(248, 248, 242)");
        SetTextColourDisabled("rgb(109, 109, 109)");
        if(m_bmp.IsOk()) {
            m_bmpDisabled = m_bmp.ConvertToDisabled(100);
        }

    } else {
        wxColour paneColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
        wxColour bgColour = paneColour.ChangeLightness(150);
        wxColour penColour = paneColour.ChangeLightness(90);

        SetPenNormalColour(penColour);
        SetBgColour(bgColour);

        SetPenPressedColour("rgb(90, 90, 90)");
        SetBgPressedColour("rgb(120, 120, 120)");

        SetBgHoverColour(bgColour);
        m_penHoverColourInner = "WHITE";
        m_penHoverOuterColour = "TURQUOISE";
        SetTextColour("rgb(15, 15, 15)");
        SetTextColourDisabled(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT));
        if(m_bmp.IsOk()) {
            m_bmpDisabled = m_bmp.ConvertToDisabled();
        }
    }

    SetTextFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
    if(size != wxDefaultSize) {
        SetMinSize(size);
    } else {
        SetMinSize(GetBestSize());
    }
}
Exemplo n.º 16
0
HRESULT ID3DApplication::Create(    int iWidth,
                                    int iHeight,
                                    int iBPP,
                                    BOOL bWindowed,
                                    LPCTSTR strTitle,
                                    DWORD dwFlags)
{
    if (!CreateAppWindow(    iWidth,
                            iHeight,
                            bWindowed,
                            strTitle))
    {
        return E_FAIL;
    }

    // create the Direct3D
    m_pD3D = ::Direct3DCreate9(D3D_SDK_VERSION);
    if (!m_pD3D)
    {
        return E_FAIL;
    }

    bool aa = Config::getInstance()->getValueAsBool("antialias", false);
    D3DMULTISAMPLE_TYPE samples = D3DMULTISAMPLE_NONE;
    if (aa) {
        if( FAILED(m_pD3D->CheckDeviceMultiSampleType( D3DADAPTER_DEFAULT, 
					        D3DDEVTYPE_HAL , D3DFMT_R8G8B8, FALSE, 
                            samples, NULL ) ) )
                            return E_FAIL;

        switch (Config::getInstance()->getValueAsInt("antialias samples", 2))
        {
        case 2: samples = D3DMULTISAMPLE_2_SAMPLES; break;
        case 3: samples = D3DMULTISAMPLE_3_SAMPLES; break;
        case 4: samples = D3DMULTISAMPLE_4_SAMPLES; break;
        case 5: samples = D3DMULTISAMPLE_5_SAMPLES; break;
        case 6: samples = D3DMULTISAMPLE_6_SAMPLES; break;
        case 7: samples = D3DMULTISAMPLE_7_SAMPLES; break;
        case 8: samples = D3DMULTISAMPLE_8_SAMPLES; break;
        case 9: samples = D3DMULTISAMPLE_9_SAMPLES; break;
        case 10: samples = D3DMULTISAMPLE_10_SAMPLES; break;
        case 11: samples = D3DMULTISAMPLE_11_SAMPLES; break;
        case 12: samples = D3DMULTISAMPLE_12_SAMPLES; break;
        case 13: samples = D3DMULTISAMPLE_13_SAMPLES; break;
        case 14: samples = D3DMULTISAMPLE_14_SAMPLES; break;
        case 15: samples = D3DMULTISAMPLE_15_SAMPLES; break;
        case 16: samples = D3DMULTISAMPLE_16_SAMPLES; break;
        default:
            return E_FAIL;
        }
    }

    // initialise the present parameters
    HRESULT hres;
    m_Present.hDeviceWindow = GetWindow();

    // initialise automatic z-buffering
    m_Present.EnableAutoDepthStencil = TRUE;

    if (IsWindowed())
    {
        // init windowed mode present parameters
        m_Present.BackBufferWidth = GetWindowRect().right;
        m_Present.BackBufferHeight = GetWindowRect().bottom;
        m_Present.Windowed = TRUE;
        m_Present.BackBufferCount = 1;

        // antialias
        if (aa)
        {
            m_Present.SwapEffect      = D3DSWAPEFFECT_DISCARD;
            m_Present.MultiSampleType = samples;
        }
        else
        {
            m_Present.SwapEffect = D3DSWAPEFFECT_COPY;
        }

        // force z-buffer to 16 bit format, without stencil bits
        m_Present.AutoDepthStencilFormat = D3DFMT_D16;

        // get the desktop display mode
        D3DDISPLAYMODE dm;
        m_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &dm);
        m_Present.BackBufferFormat = dm.Format;
    }
    else
    {
        // init fullscreen mode present parameters
        m_Present.BackBufferWidth = iWidth;
        m_Present.BackBufferHeight = iHeight;
//        m_Present.SwapEffect = D3DSWAPEFFECT_FLIP;
        m_Present.FullScreen_RefreshRateInHz = 0;

        // vsync
        if (Config::getInstance()->getValueAsBool("vsync", false))
        {
            m_Present.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
        }
        else
        {
            m_Present.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
        }

        // antialias
        if (aa)
        {
            m_Present.SwapEffect      = D3DSWAPEFFECT_DISCARD;
            m_Present.MultiSampleType = samples;
        }
        else
        {
            m_Present.SwapEffect = D3DSWAPEFFECT_FLIP;
        }

        switch (iBPP)
        {
        case 8:
            // forgetaboutit... not supported anymore
            return E_FAIL;
            break;

        case 16:
            m_Present.BackBufferFormat = D3DFMT_R5G6B5;
            m_Present.AutoDepthStencilFormat = D3DFMT_D16;
            break;

        case 24:
            // forgetaboutit... not supported anymore
            return E_FAIL;
            break;

        case 32:
            m_Present.BackBufferFormat = D3DFMT_X8R8G8B8;
            m_Present.AutoDepthStencilFormat = D3DFMT_D16;
            break;

        default:
            // unknown bits per pixel value
            return E_FAIL;
        }
    }


    // Create Direct3D device
    // use the fallback mechanism to select best possible
    // 3d device type
    hres = m_pD3D->CreateDevice(    D3DADAPTER_DEFAULT,
                                    D3DDEVTYPE_HAL,
                                    GetWindow(),
                                    D3DCREATE_HARDWARE_VERTEXPROCESSING,
                                    &m_Present,
                                    &m_pDevice);
    if (FAILED(hres))
    {
        hres = m_pD3D->CreateDevice(    D3DADAPTER_DEFAULT,
                                        D3DDEVTYPE_HAL,
                                        GetWindow(),
                                        D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                                        &m_Present,
                                        &m_pDevice);
    }
    if (FAILED(hres))
    {
        hres = m_pD3D->CreateDevice(    D3DADAPTER_DEFAULT,
                                        D3DDEVTYPE_REF,
                                        GetWindow(),
                                        D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                                        &m_Present,
                                        &m_pDevice);
    }
    if (FAILED(hres))
    {
        // failed to create any meaningful 3d device...
        Release();
        return hres;
    }



    SetDeviceDefaults();


    // init the text drawing system
    hres = D3DXCreateSprite(m_pDevice, &m_pSprite);
    if (FAILED(hres))
    {
        Release();
        return hres;
    }

    // init the font
    hres = SetTextFont(NULL);
    if (FAILED(hres))
    {
        Release();
        return hres;
    }



    // init the timer
    GetTimer().Create();

    // call the pure virtual OnCreate
    hres = OnCreate();
    if (FAILED(hres))
    {
        Release();
        return hres;
    }

    SetActive(TRUE);
    return S_OK;
}
Exemplo n.º 17
0
HRESULT PlayMovieInWindow(LPTSTR szFile)
{
    USES_CONVERSION;
    WCHAR wFile[MAX_PATH];
    HRESULT hr;

    // Check input string
    if (szFile == NULL)
        return E_POINTER;

    // Clear open dialog remnants before calling RenderFile()
    UpdateWindow(ghApp);

    // Convert filename to wide character string
    wcsncpy(wFile, T2W(szFile), NUMELMS(wFile)-1);
    wFile[MAX_PATH-1] = 0;

    // Get the interface for DirectShow's GraphBuilder
    JIF(CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, 
                         IID_IGraphBuilder, (void **)&pGB));

    if(SUCCEEDED(hr))
    {
        // Create the Video Mixing Renderer and add it to the graph
        JIF(InitializeWindowlessVMR());
                
        // Have the graph builder construct its the appropriate graph automatically
        JIF(pGB->RenderFile(wFile, NULL));

        // QueryInterface for DirectShow interfaces
        JIF(pGB->QueryInterface(IID_IMediaControl, (void **)&pMC));
        JIF(pGB->QueryInterface(IID_IMediaEventEx, (void **)&pME));
        JIF(pGB->QueryInterface(IID_IMediaSeeking, (void **)&pMS));

        // Is this an audio-only file (no video component)?
        if (CheckVideoVisibility())
        {
            JIF(InitVideoWindow(1, 1));
        }
        else
        {
            // This sample requires a video clip to be loaded
            Msg(TEXT("This sample requires media with a video component.  ")
                TEXT("Please select another file."));
            return E_FAIL;
        }

        // Have the graph signal event via window callbacks for performance
        JIF(pME->SetNotifyWindow((OAHWND)ghApp, WM_GRAPHNOTIFY, 0));

        // Add the bitmap (static image or dynamic text) to the VMR's input
        if (g_dwTickerFlags & MARK_STATIC_IMAGE)
        {
            hr = BlendApplicationImage(ghApp);
            if (FAILED(hr))
                PostMessage(ghApp, WM_CLOSE, 0, 0);

            CheckMenuItem(ghMenu, ID_TICKER_STATIC_IMAGE, MF_CHECKED);
            CheckMenuItem(ghMenu, ID_TICKER_DYNAMIC_TEXT, MF_UNCHECKED);
        }
        else                                        // MARK_DYNAMIC_TEXT
        {
            if (!g_hFont)
                g_hFont = SetTextFont(FALSE);  // Don't display the Windows Font Select dialog

            // If the initial blend fails, post a close message to exit the app
            hr = BlendApplicationText(ghApp, g_szAppText);
            if (FAILED(hr))
                PostMessage(ghApp, WM_CLOSE, 0, 0);

            CheckMenuItem(ghMenu, ID_TICKER_STATIC_IMAGE, MF_UNCHECKED);
            CheckMenuItem(ghMenu, ID_TICKER_DYNAMIC_TEXT, MF_CHECKED);
        }

        // Complete the window setup
        ShowWindow(ghApp, SW_SHOWNORMAL);
        UpdateWindow(ghApp);
        SetForegroundWindow(ghApp);
        SetFocus(ghApp);

#ifdef REGISTER_FILTERGRAPH
        if (FAILED(AddGraphToRot(pGB, &g_dwGraphRegister)))
        {
            Msg(TEXT("Failed to register filter graph with ROT!"));
            g_dwGraphRegister = 0;
        }
#endif

        // Run the graph to play the media file
        JIF(pMC->Run());

        // Start animation by default
        PostMessage(ghApp, WM_COMMAND, ID_SLIDE, 0);
    }

    return hr;
}