コード例 #1
0
/// <summary>Draws some text to the screen at the specified coordinates
/// with the given color, drawing from the display parameters initialized
/// in this display manager's constructor.</summary>
/// <param name="pDevice">LPDIRECT3DDEVICE9 to render to.</param>
/// <param name="x">Screen X coordinate to draw to.</param>
/// <param name="y">Screen Y coordinate to draw to.</param>
/// <param name="alpha">Alpha level for the rectangle (transparency).</param>
/// <param name="r">Red color component for the colour of the rectangle.</param>
/// <param name="g">Green color component for the colour of the rectangle.</param>
/// <param name="b">Blue color component for the colour of the rectangle.</param>
/// <param name="message">String to draw.</param>
/// <param name="fontType">D3DDisplayManager::FontType value to describe the
/// type of font which should be used.</param>
bool D3DDisplayManager::DrawCooldownTextToScreen(LPDIRECT3DDEVICE9 pDevice,
		unsigned int x,	unsigned int y, int alpha, int r, int g, int b,
		LPCSTR message,	FontType fontType) {

	_CreateFont(pDevice);

	// Choose our font based on input
	LPD3DXFONT font;
	switch (fontType) {
		case FontType::TITLE:
			font = pTitleFont;
			break;
		default:
			font = pFont;
	}

	D3DCOLOR fontColor = D3DCOLOR_ARGB(alpha, r, g, b);
	RECT rct;
	rct.left = x;
	rct.right = x + ((mDisplayParams.backdropWidth / 5) * 4);
	rct.top = y;
	rct.bottom = rct.top + mDisplayParams.backdropHeight;

	// TODO: add better support for different resolutions:
	// Use a lookup table to adjust font size dynamically?

	// Draw the text
	pFontSprite->Begin(D3DXSPRITE_SORT_TEXTURE);
	font->DrawTextA(pFontSprite, message, -1, &rct, DT_RIGHT, fontColor);
	pFontSprite->End();
	return true;
}
コード例 #2
0
ファイル: pmnew.c プロジェクト: ABratovic/open-watcom-v2
/*
 * _NewWindow - create a new window
 */
unsigned _NewWindow( char *name, ... )
{
    LPWDATA     w;
    MENUITEM    menus;
    HWND        hwnd,frame,temp;
    char        str[80];
    int         x1,x2,y1,y2;
    ULONG       style;
    RECTL       rcl;
    va_list     al;

    _GetWindowNameAndCoords( name, str, &x1, &x2, &y1, &y2 );

    style = FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER | FCF_MINMAX |
            FCF_VERTSCROLL;
    frame = WinCreateStdWindow( _MainWindow,
                WS_VISIBLE | WS_CLIPSIBLINGS,
                &style, _ClassName, str, 0, NULL, 0, &hwnd );
    if( frame == 0 ) return( FALSE );
    WinSetOwner( hwnd, _MainWindow );

    va_start( al, name );
    w = _AnotherWindowData( hwnd, al );
    w->frame = frame;
    w->text_color = CLR_WHITE;
    w->background_color = CLR_BLACK;
    WinSendMsg( frame, WM_SETICON,
        MPFROMLONG( WinQuerySysPointer( HWND_DESKTOP, SPTR_APPICON, TRUE ) ), 0 );
    WinSetWindowBits( WinWindowFromID( w->frame, FID_VERTSCROLL ), QWL_STYLE,
                        SBS_AUTOTRACK, SBS_AUTOTRACK );

    _CreateFont( w );
    _PositionScrollThumb( w );
    WinQueryWindowRect( _MainWindow, &rcl );
    WinSetWindowPos( frame, HWND_TOP,
                x1*w->xchar,
                (rcl.yTop - rcl.yBottom)-y1*w->ychar-y2*w->ychar,
                x2*w->xchar,
                y2*w->ychar,
                SWP_SIZE | SWP_MOVE | SWP_ZORDER );

    menus.iPosition = _MainWindowData->window_count - 1;
    menus.afStyle = MIS_TEXT;
    menus.afAttribute = 0;
    menus.id = DID_WIND_STDIO + w->handles[0];
    menus.hwndSubMenu = NULL;
    menus.hItem = 0;
    if ( MIT_ERROR == (BOOL)WinSendMsg( menuHandle, ( ULONG )MM_INSERTITEM, MPFROMP( &menus ), MPFROMP( str ) ) ) abort();
    temp = WinWindowFromID( frame, FID_SYSMENU );
    WinSendMsg( temp, MM_QUERYITEM, MPFROM2SHORT(SC_SYSMENU, TRUE),
                               MPFROMP((PSZ)&menus) );
    WinSendMsg( menus.hwndSubMenu, MM_DELETEITEM, MPFROM2SHORT( SC_CLOSE, TRUE ), 0 );
    WinUpdateWindow( hwnd );
    WinSetFocus( HWND_DESKTOP, hwnd );
    return( TRUE );

} /* _NewWindow */
コード例 #3
0
ファイル: SFontPool.cpp プロジェクト: hdwdsj/SoUiTestProject
SFontPool::SFontPool(IRenderFactory *pRendFactory)
    :m_RenderFactory(pRendFactory)
{
    ::GetObjectA(::GetStockObject(DEFAULT_GUI_FONT), sizeof(LOGFONT), &m_lfDefault);
    m_lfDefault.lfHeight  = -12;
    m_lfDefault.lfQuality = CLEARTYPE_QUALITY;
    _tcscpy(m_lfDefault.lfFaceName,_T("宋体"));

    m_pFunOnKeyRemoved=OnKeyRemoved;
    SetKeyObject(FontKey(0,m_lfDefault.lfFaceName),_CreateFont(m_lfDefault));
}
コード例 #4
0
ファイル: SFontPool.cpp プロジェクト: hdwdsj/SoUiTestProject
void SFontPool::SetDefaultFont(LPCTSTR lpszFaceName, LONG lSize,BYTE byCharset/*=DEFAULT_CHARSET*/)
{
    SASSERT(GetCount()==1);//初始化前才可以调用该接口
    RemoveKeyObject(FontKey(0));

    _tcscpy_s(m_lfDefault.lfFaceName,_countof(m_lfDefault.lfFaceName),lpszFaceName);
    m_lfDefault.lfHeight = -abs(lSize);
    if(byCharset!=DEFAULT_CHARSET) 
        m_lfDefault.lfCharSet = byCharset;
    
    SetKeyObject(FontKey(0),_CreateFont(m_lfDefault));
}
コード例 #5
0
ファイル: SFontPool.cpp プロジェクト: hdwdsj/SoUiTestProject
IFontPtr SFontPool::GetFont(FONTSTYLE style,LPCTSTR pszFaceName)
{
    SStringT strFaceName(pszFaceName);
    if(strFaceName == m_lfDefault.lfFaceName) strFaceName = _T("");
    
    IFontPtr hftRet=0;
    FontKey key(style.dwStyle,strFaceName);
    if(HasKey(key))
    {
        hftRet=GetKeyObject(key);
    }
    else
    {
        if(strFaceName.IsEmpty()) strFaceName = m_lfDefault.lfFaceName;
        hftRet = _CreateFont(style,strFaceName);
        AddKeyObject(key,hftRet);
    }
    return hftRet;
}
コード例 #6
0
/// <summary>Draws a rectangle to the screen at the specified coordinates
/// with the given width, height and color.</summary>
/// <param name="pDevice">LPDIRECT3DDEVICE9 to render to.</param>
/// <param name="x">Screen X coordinate to draw to.</param>
/// <param name="y">Screen Y coordinate to draw to.</param>
/// <param name="width">Width of the rectangle.</param>
/// <param name="height">Height of the rectangle.</param>
/// <param name="alpha">Alpha level for the rectangle (transparency).</param>
/// <param name="r">Red color component for the colour of the rectangle.</param>
/// <param name="g">Green color component for the colour of the rectangle.</param>
/// <param name="b">Blue color component for the colour of the rectangle.</param>
bool D3DDisplayManager::DrawRectToScreen(LPDIRECT3DDEVICE9 pDevice, float x,
		float y, float width, float height, int alpha, int r, int g, int b) {

	_CreateFont(pDevice);

	D3DCOLOR rectColor = D3DCOLOR_ARGB(alpha, r, g, b);

	pLine->SetWidth(width);

	// Draw a line with the thickness of width / 2 to get the desired width
	D3DXVECTOR2 vLine[2];
	vLine[0].x = x + width / 2;
	vLine[0].y = y;
	vLine[1].x = x + width / 2;
	vLine[1].y = y + height;

	pLine->Begin();
	pLine->Draw(vLine, 2, rectColor);
	pLine->End();

	return true;
}
コード例 #7
0
ファイル: SFontPool.cpp プロジェクト: hdwdsj/SoUiTestProject
IFontPtr SFontPool::_CreateFont(FONTSTYLE style,const SStringT & strFaceName)
{
    LOGFONT lfNew;
        
    memcpy(&lfNew, &m_lfDefault, sizeof(LOGFONT));
    lfNew.lfWeight      = (style.fBold ? FW_BOLD : FW_NORMAL);
    lfNew.lfUnderline   = (FALSE != style.fUnderline);
    lfNew.lfItalic      = (FALSE != style.fItalic);
    lfNew.lfStrikeOut   = (FALSE != style.fStrike);
    if(style.fAbsSize)
        lfNew.lfHeight = -abs((short)style.cSize);
    else
        lfNew.lfHeight -= (short)style.cSize;  //cSize为正代表字体变大,否则变小
        
    lfNew.lfQuality = CLEARTYPE_QUALITY;
    
    if(style.byCharset!=DEFAULT_CHARSET) lfNew.lfCharSet = style.byCharset;
    
    _tcscpy_s(lfNew.lfFaceName,_countof(lfNew.lfFaceName),  strFaceName);
    
    return _CreateFont(lfNew);
}
コード例 #8
0
ファイル: Chart2D.cpp プロジェクト: ashabelnikov/secu3man
BOOL CChart2D::Create(DWORD dwStyle, CRect &rect, CWnd *pParent, UINT id)
{
 BOOL result = CWnd::CreateEx(WS_EX_CLIENTEDGE | WS_EX_STATICEDGE, NULL, NULL, dwStyle,
               rect.left, rect.top, rect.Width(), rect.Height(), pParent->GetSafeHwnd(), (HMENU)id);
 if (!result)
  AfxMessageBox(_T("Error creating Chart2D control's window!"));

 m_ctlRect = rect;
 m_ctlRect.DeflateRect(2, 2, 2, 2);
 pParent->ClientToScreen(m_ctlRect);
 ScreenToClient(m_ctlRect);
 _CreateFont();
 _CalcRect();
 _CalcMapFactors();

 if (result)
 {
  _SetStateColors(IsWindowEnabled());
  Invalidate(TRUE);
 }

 return result;
}