RedPanda-CPP/RedPandaIDE/qsynedit/TextPainter.h

66 lines
1.9 KiB
C
Raw Normal View History

2021-05-14 23:56:43 +08:00
#ifndef TEXTPAINTER_H
#define TEXTPAINTER_H
#include <QColor>
#include <QPainter>
#include <QString>
#include "Types.h"
2021-05-16 20:36:00 +08:00
#include "highlighter/base.h"
2021-05-14 23:56:43 +08:00
class SynEdit;
class SynEditTextPainter
{
2021-05-16 20:36:00 +08:00
struct SynTokenAccu {
int Columns;
int ColumnsBefore;
2021-05-14 23:56:43 +08:00
QString s;
QColor FG;
QColor BG;
SynFontStyles Style;
};
public:
SynEditTextPainter(SynEdit * edit);
QColor colEditorBG();
void ComputeSelectionInfo();
void setDrawingColors(bool Selected);
int ColumnToXValue(int Col);
2021-05-16 20:36:00 +08:00
void PaintToken(const QString& Token, int TokenLen, int ColumnsBefore,
2021-05-14 23:56:43 +08:00
int First, int Last, bool isSelection);
2021-05-16 20:36:00 +08:00
void PaintEditAreas(PSynEditingAreaList areaList);
void PaintHighlightToken(bool bFillToEOL);
bool TokenIsSpaces(bool& bSpacesTest, const QString& Token, bool& bIsSpaces);
void AddHighlightToken(const QString& Token, int ColumnsBefore, int TokenColumns,
int cLine, PSynHighlighterAttribute p_Attri);
void PaintFoldAttributes();
void GetBraceColorAttr(int level, const PSynHighlighterAttribute& attr);
void PaintLines();
2021-05-14 23:56:43 +08:00
private:
SynEdit* edit;
QPainter* painter;
bool bDoRightEdge; // right edge
int nRightEdge;
// selection info
bool bAnySelection; // any selection visible?
DisplayCoord vSelStart; // start of selected area
DisplayCoord vSelEnd; // end of selected area
// info about normal and selected text and background colors
bool bSpecialLine, bLineSelected, bCurrentLine;
QColor colFG, colBG;
QColor colSelFG, colSelBG;
// info about selection of the current line
int nLineSelStart, nLineSelEnd;
bool bComplexLine;
// painting the background and the text
QRect rcLine, rcToken;
int vFirstLine, vLastLine;
2021-05-16 20:36:00 +08:00
QRect AClip;
int aFirstRow, aLastRow, FirstCol, LastCol;
SynTokenAccu TokenAccu;
2021-05-14 23:56:43 +08:00
};
#endif // TEXTPAINTER_H