-
Notifications
You must be signed in to change notification settings - Fork 0
/
uDrawer.h
99 lines (79 loc) · 3.13 KB
/
uDrawer.h
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//---------------------------------------------------------------------------
#ifndef uDrawerH
#define uDrawerH
#include <windows.h>
#include <vcl.h>
#include <list>
#include "config.h"
#include "uFormat.h"
namespace SHEdit
{
class NSpan;
class TSHEdit;
class FontStyle;
/*!
* Drawer
* ======
* Drawer ensures drawing everything that it is told to draw. It is usually told by TSHEdit to move parts of already-painted information upwards or downwards, to update/repaint cursor and to update it's fontsize or linenumwidth parameters, while by Parser it is ordered to draw text, endlines and eof.
*
* When drawing text, the Drawer::x is incremented with width of drawn text waiting for endline to bleach the rest of screen and reset the x again to 0. Also information about length of longest line is kept for setting of horizontal scrollbar's parameters. Just highest 'ever reached' width is kept - in current structure there's no way to keep this parameter up to date (and it's just a visual glitch).
*
* Here is not much to document either, just to mention that everything that is not apparently pixel position is usually screen-line position (that means i.e. nth visible line).
*
* One more note - UpdateFontSize and updateLinenumWidth does not automatically repaint screen - screen repaint has to be triggered manually.
* */
//---------------------------------------------------------------------------
class Drawer
{
private:
TSHEdit * parent;
TCanvas * canvas;
TCanvas * drawcanvas;
Graphics::TBitmap * bitmap;
inline int RightBorder();
inline int BottomBorder();
int x, y;
int cx, cy;
bool con; //cursorOn
TColor cursorBGcolor;
int fontsize;
int linesize;
int linenumwidth;
int lastlinenumcount; //to be able to update lw automatically
bool linenumsenabled;
int debugtasks;
int debugcount;
int HPos, HMax;
void __fastcall UpdateHBar();
#ifdef SHEDIT_DEBUG
void Write(String message);
void QueueDump();
void StressTest();
#endif
void DrawCursor();
void __fastcall DrawText(String text, bool newline, short linenum, FontStyle format);
void __fastcall DrawMove(int from, int to, int by);
void __fastcall DrawEof(short linenum);
void __fastcall UpdateCursor(int x, int y);
void __fastcall DrawResize(int w, int h);
void __fastcall DrawEndl(short linenum, FontStyle format);
void __fastcall DrawLinenum(int from);
void __fastcall Paint();
friend class TSHEdit;
friend class Parser;
public:
__fastcall Drawer(TCanvas * Canvas, TSHEdit * parent) ;
virtual __fastcall ~Drawer();
void __fastcall SetFontsize(int size);
bool __fastcall UpdateLinenumWidth(int count);
int __fastcall GetLinenumWidth();
int __fastcall GetFontsize();
int __fastcall GetLinesize();
void __fastcall SetLinenumsEnabled(bool enable);
bool __fastcall GetLinenumsEnabled();
public:
friend class TSHEdit;
};
}
//---------------------------------------------------------------------------
#endif