00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
#ifndef __KATE_RENDERER_H__
00023
#define __KATE_RENDERER_H__
00024
00025
#include "katecursor.h"
00026
#include "kateattribute.h"
00027
#include "katetextline.h"
00028
00029
#include <qfont.h>
00030
#include <qfontmetrics.h>
00031
00032
class KateDocument;
00033
class KateView;
00034
class KateLineRange;
00035
class KateRendererConfig;
00036
00042 class KateRenderer
00043 {
00044
public:
00048 enum caretStyles {
00049 Insert,
00050 Replace
00051 };
00052
00058
KateRenderer(KateDocument* doc, KateView *view = 0);
00059
00063
~KateRenderer();
00064
00069
void updateAttributes ();
00070
00075 inline bool drawCaret()
const {
return m_drawCaret; }
00076
00081
void setDrawCaret(
bool drawCaret);
00082
00087 inline KateRenderer::caretStyles caretStyle()
const {
return m_caretStyle; }
00088
00093
void setCaretStyle(KateRenderer::caretStyles style);
00094
00100 inline bool showTabs()
const {
return m_showTabs; }
00101
00106
void setShowTabs(
bool showTabs);
00107
00112
void setTabWidth(
int tabWidth);
00113
00118 inline bool showSelections()
const {
return m_showSelections; }
00119
00125
void setShowSelections(
bool showSelections);
00126
00130
void increaseFontSizes();
00131
void decreaseFontSizes();
00132
const QFont* currentFont();
00133
const QFontMetrics* currentFontMetrics();
00134
00139
bool isPrinterFriendly() const;
00140
00146
void setPrinterFriendly(
bool printerFriendly);
00147
00152
00153 uint spaceWidth();
00154 uint textWidth(const
KateTextLine::Ptr &,
int cursorCol);
00155 uint textWidth(const
KateTextLine::Ptr &textLine, uint startcol, uint maxwidth,
bool *needWrap,
int *endX = 0);
00156 uint textWidth(const
KateTextCursor &cursor);
00157
00158
00159 uint textWidth(
KateTextCursor &cursor,
int xPos, uint startCol = 0);
00160
00161
00170 uint textPos(uint line,
int xPos, uint startCol = 0,
bool nearest=true);
00174 uint textPos(const
KateTextLine::Ptr &,
int xPos, uint startCol = 0,
bool nearest=true);
00175
00176
00177 uint fontHeight();
00178
00179
00180 uint documentHeight();
00181
00182
00183
bool selectBounds(uint line, uint &start, uint &end, uint lineLength);
00184
00192
void paintTextLine(
QPainter& paint, const KateLineRange* range,
int xStart,
int xEnd, const
KateTextCursor* cursor = 0L, const KateTextRange* bracketmark = 0L);
00193
00194
KateAttribute* attribute(uint pos);
00195
00196 private:
00197 KateDocument* m_doc;
00198 KateView *m_view;
00199
00200
00201
int m_tabWidth;
00202 uint m_schema;
00203
00204
00205
KateRenderer::caretStyles m_caretStyle;
00206
bool m_drawCaret;
00207
bool m_showSelections;
00208
bool m_showTabs;
00209
bool m_printerFriendly;
00210
00211
QMemArray<
KateAttribute> *m_attributes;
00212
00216 public:
00217 inline KateRendererConfig *config () {
return m_config; };
00218
00219
void updateConfig ();
00220
00221
private:
00222 KateRendererConfig *m_config;
00223 };
00224
00225
#endif