My Project
text.cpp
Go to the documentation of this file.
1 #include "stdafx.h"
2 #include "../stdafx.h"
3 #include "text.h"
4 
6 {
7  this->font.lfHeight = 25;
8  this->font.lfWidth = 0;
9  this->font.lfEscapement = 0;
10  this->font.lfOrientation = 0;
11  this->font.lfWeight = 500;
12  this->font.lfItalic = 0;
13  this->font.lfUnderline = 0;
14  this->font.lfStrikeOut = 0;
15  this->font.lfCharSet = RUSSIAN_CHARSET;
16  this->font.lfOutPrecision = 0;
17  this->font.lfClipPrecision = 0;
18  this->font.lfQuality = 0;
19  this->font.lfPitchAndFamily = 0;
20  wcscpy_s(this->font.lfFaceName, TEXT("Arial"));
21  this->COLOR = RGB(0, 0, 0);
22 }
23 
24 Text::Text(int X, int Y, WCHAR* TEXT) : Text()
25 {
26  this->X = X;
27  this->Y = Y;
28  this->TEXT = TEXT;
29  this->display(X, Y, 0, 0, TEXT);
30 }
31 
32 bool Text::display(int X1, int Y1, int X2, int Y2, WCHAR* TEXT)
33 {
34  this->X = X1;
35  this->Y = Y1;
36  this->TEXT = TEXT;
37  HFONT hfont;
38  hfont = ::CreateFontIndirect(&this->font);
39  SelectObject(this->hdc, hfont);
40  SetBkMode(this->hdc, TRANSPARENT);
41  return TextOutW(this->hdc, X1, Y1, TEXT, wcslen(TEXT));
42 }
43 
45 {
46  this->SetColor(this->COLOR);
47  return this->display(this->X, this->Y, 0, 0, this->TEXT);
48 }
49 
50 Text* Text::SetColor(COLORREF color)
51 {
52  this->COLOR = color;
53  SetTextColor(this->hdc,this->COLOR);
54  return this;
55 }
56 
58 {
59  this->font.lfWeight = w;
60  return this;
61 }
62 
64 {
65  this->font.lfHeight = h;
66  return this;
67 }
68 
70 {
71  this->font.lfWidth = w;
72  return this;
73 }
Button interface class Provide interface for creating/removing custom text.
Definition: text.h:24
Text * SetWeight(int w)
Definition: text.cpp:57
Text interface class.
bool redraw() override
Definition: text.cpp:44
Text()
Definition: text.cpp:5
Text * SetColor(COLORREF color)
Definition: text.cpp:50
Text * SetSymbolWidth(int w)
Definition: text.cpp:69
bool display(int X1, int Y1, int X2, int Y2, WCHAR *TEXT) override
Definition: text.cpp:32
Text * SetHeight(int h)
Definition: text.cpp:63