X64 transport [Part 5] (Update plugins.cpp)
[xy_vsfilter.git] / src / apps / mplayerc / StatusLabel.cpp
bloba6d19d07180787c669cddbc7be03802763cbb6a6
1 /*
2 * Copyright (C) 2003-2006 Gabest
3 * http://www.gabest.org
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
8 * any later version.
9 *
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GNU Make; see the file COPYING. If not, write to
17 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 * http://www.gnu.org/copyleft/gpl.html
22 // StatusLabel.cpp : implementation file
25 #include "stdafx.h"
26 #include "mplayerc.h"
27 #include "StatusLabel.h"
30 // CStatusLabel
32 IMPLEMENT_DYNAMIC(CStatusLabel, CStatic)
33 CStatusLabel::CStatusLabel(bool fRightAlign, bool fAddEllipses)
34 : m_fRightAlign(fRightAlign)
35 , m_fAddEllipses(fAddEllipses)
37 HDC hdc = ::GetDC(NULL);
38 double scale = 1.0*GetDeviceCaps(hdc, LOGPIXELSY) / 96.0;
39 ::ReleaseDC(0, hdc);
41 m_font.m_hObject = NULL;
43 if(!(::GetVersion()&0x80000000))
44 m_font.CreateFont(int(14.0 * scale), 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET,
45 OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE,
46 _T("Microsoft Sans Serif"));
47 if(!m_font.m_hObject)
48 m_font.CreateFont(int(14.0 * scale), 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET,
49 OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE,
50 _T("MS Sans Serif"));
53 CStatusLabel::~CStatusLabel()
57 BEGIN_MESSAGE_MAP(CStatusLabel, CStatic)
58 ON_WM_ERASEBKGND()
59 END_MESSAGE_MAP()
61 // CStatusLabel message handlers
63 void CStatusLabel::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
65 CDC dc;
66 dc.Attach(lpDrawItemStruct->hDC);
67 CString str;
68 GetWindowText(str);
69 CRect r;
70 GetClientRect(&r);
71 CFont* old = dc.SelectObject(&m_font);
72 dc.SetTextColor(0xffffff);
73 dc.SetBkColor(0);
74 CSize size = dc.GetTextExtent(str);
75 CPoint p = CPoint(m_fRightAlign ? r.Width() - size.cx : 0, (r.Height()-size.cy)/2);
77 if(m_fAddEllipses)
78 while(size.cx > r.Width()-3 && str.GetLength() > 3)
80 str = str.Left(str.GetLength()-4) + _T("...");
81 size = dc.GetTextExtent(str);
84 dc.TextOut(p.x, p.y, str);
85 dc.ExcludeClipRect(CRect(p, size));
86 dc.SelectObject(&old);
87 dc.FillSolidRect(&r, 0);
88 dc.Detach();
91 BOOL CStatusLabel::OnEraseBkgnd(CDC* pDC)
93 CRect r;
94 GetClientRect(&r);
95 pDC->FillSolidRect(&r, 0);
96 return TRUE;