-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathCMultiLine.cpp
76 lines (62 loc) · 1.62 KB
/
CMultiLine.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "CMultiLine.h"
#include "CText.h"
#include "CApplication.h"
CMultiLine::CMultiLine()
{
mTextSurface = new CSurfWindow();
mCanFocus = false;
}
void CMultiLine::Clear()
{
mLines.clear();
mTextSurface->Reset();
}
void CMultiLine::AddLine(string text)
{
AddLine(text, CSurface::HAlignment::Left);
}
void CMultiLine::AddLine(string text, CSurface::HAlignment align)
{
mLines.push_back(text);
CSurface* textSurf = new CSurface();
textSurf->RenderTexture(CText::sFontSmall, text, CText::cBlack, 0, 0, CSurface::HAlignment::Left);
mTextSurface->BlitEx(textSurf, 0, mTextSurface->Height(), align);
delete(textSurf);
}
void CMultiLine::RenderSurface()
{
int len = mLines.size();
int i;
CSurface* textSuf = new CSurface();
for (i = 0; i < len; i++)
{
textSuf->RenderTexture(CText::sFontSmall, mLines[i], CText::cBlack, 0, 0, CSurface::HAlignment::Left);
mTextSurface->BlitEx(textSuf, 0, mTextSurface->Height());
}
}
void CMultiLine::Draw()
{
SDL_Renderer* renderer = CApplication::sRenderer;
Uint8 r, g, b, a;
int w, h;
SDL_GetRendererOutputSize(renderer, &w, &h);
if (mTextSurface == NULL || mTextSurface->Width() == 0 || mTextSurface->Height() == 0)
{
return;
}
//SDL_GetRenderDrawColor(renderer, &r, &g, &b, &a);
//SDL_Rect rect = {X, Y, mTextSurface->Width(),mTextSurface->Height()};
//SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
//SDL_RenderFillRect(renderer, &rect);
//SDL_SetRenderDrawColor(renderer, r, g, b, a);
mTextSurface->X = X;
mTextSurface->Y = Y;
if (mTextSurface->mSurface->h <= h)
{
mTextSurface->DrawTexture(renderer);
}
else
{
mTextSurface->DrawTexture(renderer, w, h);
}
}