From c77821d0b4b3ae09e47ce6d6ca9d6b21dbb56d30 Mon Sep 17 00:00:00 2001 From: Vadim Dashevskiy Date: Mon, 4 Nov 2013 08:59:15 +0000 Subject: LCDFramework project removed, integrated to MirandaG15 project git-svn-id: http://svn.miranda-ng.org/main/trunk@6767 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- .../MirandaG15/src/LCDFramework/CLCDTextObject.cpp | 187 +++++++++++++++++++++ 1 file changed, 187 insertions(+) create mode 100644 plugins/MirandaG15/src/LCDFramework/CLCDTextObject.cpp (limited to 'plugins/MirandaG15/src/LCDFramework/CLCDTextObject.cpp') diff --git a/plugins/MirandaG15/src/LCDFramework/CLCDTextObject.cpp b/plugins/MirandaG15/src/LCDFramework/CLCDTextObject.cpp new file mode 100644 index 0000000000..1e06d87774 --- /dev/null +++ b/plugins/MirandaG15/src/LCDFramework/CLCDTextObject.cpp @@ -0,0 +1,187 @@ +#include "stdafx.h" +#include "CLCDGfx.h" +#include "CLCDObject.h" +#include "CLCDTextObject.h" + +//************************************************************************ +// constructor +//************************************************************************ +CLCDTextObject::CLCDTextObject() +{ + m_hFont = NULL; + m_iFontHeight = 0; + // Initialize DRAWTEXTPARAMS + ZeroMemory(&m_dtp, sizeof(DRAWTEXTPARAMS)); + m_dtp.cbSize = sizeof(DRAWTEXTPARAMS); + // Initialize alignment + m_iTextFormat = m_iTextAlignment = (DT_LEFT | DT_NOPREFIX); +} + +//************************************************************************ +// destructor +//************************************************************************ +CLCDTextObject::~CLCDTextObject() +{ + if(m_hFont) + { + DeleteObject(m_hFont); + } +} + +//************************************************************************ +// initializes the textobject +//************************************************************************ +bool CLCDTextObject::Initialize() +{ + m_hFont = (HFONT) GetStockObject(DEFAULT_GUI_FONT); + if(NULL != m_hFont) + { + SetFontFaceName(_T("Small Fonts")); + SetFontPointSize(6); + } + return true; +} + +//************************************************************************ +// deinitializes the textobject +//************************************************************************ +bool CLCDTextObject::Shutdown() +{ + return true; +} + +//************************************************************************ +// draws the textobject +//************************************************************************ +bool CLCDTextObject::Draw(CLCDGfx *pGfx) +{ + return true; +} + +//************************************************************************ +// updates the textobject +//************************************************************************ +bool CLCDTextObject::Update() +{ + return true; +} + +//************************************************************************ +// sets the textobject's font +//************************************************************************ +bool CLCDTextObject::SetFont(LOGFONT& lf) +{ + if (m_hFont) + { + DeleteObject(m_hFont); + m_hFont = NULL; + } + + m_hFont = CreateFontIndirect(&lf); + + if(!m_hFont) + return false; + + // Calculate the font's height + HDC hDC = CreateCompatibleDC(NULL); + SelectObject(hDC, m_hFont); + TEXTMETRIC tmFontInfo; + + GetTextMetrics(hDC,&tmFontInfo); + m_iFontHeight = tmFontInfo.tmHeight; + + DeleteObject(hDC); + + OnFontChanged(); + + return true; +} + +//************************************************************************ +// sets the textobject's font's facename +//************************************************************************ +void CLCDTextObject::SetFontFaceName(tstring strFontName) +{ + // if NULL, uses the default gui font + if (strFontName.empty()) + return; + + LOGFONT lf; + ZeroMemory(&lf, sizeof(lf)); + GetObject(m_hFont, sizeof(LOGFONT), &lf); + + _tcsncpy(lf.lfFaceName, strFontName.c_str(), LF_FACESIZE); + + SetFont(lf); +} + +//************************************************************************ +// sets the textobject's font's point size +//************************************************************************ +void CLCDTextObject::SetFontPointSize(int nPointSize) +{ + LOGFONT lf; + ZeroMemory(&lf, sizeof(lf)); + GetObject(m_hFont, sizeof(LOGFONT), &lf); + + lf.lfHeight = -MulDiv(nPointSize, 96, 72); + + SetFont(lf); +} + +//************************************************************************ +// sets the textobject's font to italic +//************************************************************************ +void CLCDTextObject::SetFontItalic(bool flag) { + LOGFONT lf; + ZeroMemory(&lf, sizeof(lf)); + GetObject(m_hFont, sizeof(LOGFONT), &lf); + + lf.lfItalic = flag; + + SetFont(lf); +} + +//************************************************************************ +// sets the textobject's font's weight +//************************************************************************ +void CLCDTextObject::SetFontWeight(int nWeight) +{ + LOGFONT lf; + ZeroMemory(&lf, sizeof(lf)); + GetObject(m_hFont, sizeof(LOGFONT), &lf); + + lf.lfWeight = nWeight; + + SetFont(lf); +} + +//************************************************************************ +// sets the textobject's alignment +//************************************************************************ +void CLCDTextObject::SetAlignment(int iAlignment) +{ + m_iTextFormat &= ~m_iTextAlignment; + m_iTextFormat |= iAlignment; + m_iTextAlignment = iAlignment; +} + +//************************************************************************ +// sets the textobject's wordwrap mode +//************************************************************************ +void CLCDTextObject::SetWordWrap(bool bWrap) +{ + m_bWordWrap = bWrap; + if (bWrap) + m_iTextFormat |= DT_WORDBREAK; + else + m_iTextFormat &= ~DT_WORDBREAK; +} + +//************************************************************************ +// called when the textobject's font has changed +//************************************************************************ +void CLCDTextObject::OnFontChanged() +{ + +} -- cgit v1.2.3