00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
#ifndef __KATE_ATTRIBUTE_H__
00020
#define __KATE_ATTRIBUTE_H__
00021
00022
#include "katefont.h"
00023
00024
#include <qcolor.h>
00025
00032 class KateAttribute
00033 {
00034
public:
00035
enum items {
00036 Weight = 0x1,
00037 Bold = 0x2,
00038 Italic = 0x4,
00039 Underline = 0x8,
00040 StrikeOut = 0x10,
00041 Outline = 0x20,
00042 TextColor = 0x40,
00043 SelectedTextColor = 0x80,
00044 BGColor = 0x100,
00045 SelectedBGColor = 0x200,
00046 Overline = 0x400
00047 };
00048
00049
KateAttribute();
00050
virtual ~
KateAttribute();
00051
00052
QFont font(
const QFont& ref);
00053
00054
inline int width(KateFontStruct& fs,
const QString& text,
int col,
int tabWidth)
const
00055
{
return fs.width(text, col, bold(), italic(), tabWidth); };
00056
00057
00058
inline int width(KateFontStruct& fs,
const QChar& c,
int tabWidth)
const
00059
{
return fs.width(c, bold(), italic(), tabWidth); };
00060
00061
inline bool itemSet(
int item)
const
00062
{
return item & m_itemsSet; };
00063
00064
inline bool isSomethingSet()
const
00065
{
return m_itemsSet; };
00066
00067
inline int itemsSet()
const
00068
{
return m_itemsSet; };
00069
00070
inline void clearAttribute(
int item)
00071 { m_itemsSet &= (~item); }
00072
00073
inline int weight()
const
00074
{
return m_weight; };
00075
00076
void setWeight(
int weight);
00077
00078
inline bool bold()
const
00079
{
return weight() >= QFont::Bold; };
00080
00081
void setBold(
bool enable =
true);
00082
00083
inline bool italic()
const
00084
{
return m_italic; };
00085
00086
void setItalic(
bool enable =
true);
00087
00088
inline bool overline()
const
00089
{
return m_overline; };
00090
00091
void setOverline(
bool enable =
true);
00092
00093
inline bool underline()
const
00094
{
return m_underline; };
00095
00096
void setUnderline(
bool enable =
true);
00097
00098
inline bool strikeOut()
const
00099
{
return m_strikeout; };
00100
00101
void setStrikeOut(
bool enable =
true);
00102
00103
inline const QColor& outline()
const
00104
{
return m_outline; };
00105
00106
void setOutline(
const QColor& color);
00107
00108
inline const QColor& textColor()
const
00109
{
return m_textColor; };
00110
00111
void setTextColor(
const QColor& color);
00112
00113
inline const QColor& selectedTextColor()
const
00114
{
return m_selectedTextColor; };
00115
00116
void setSelectedTextColor(
const QColor& color);
00117
00118
inline const QColor& bgColor()
const
00119
{
return m_bgColor; };
00120
00121
void setBGColor(
const QColor& color);
00122
00123
inline const QColor& selectedBGColor()
const
00124
{
return m_selectedBGColor; };
00125
00126
void setSelectedBGColor(
const QColor& color);
00127
00128
KateAttribute& operator+=(
const KateAttribute& a);
00129
00130
friend bool operator ==(
const KateAttribute& h1,
const KateAttribute& h2);
00131
friend bool operator !=(
const KateAttribute& h1,
const KateAttribute& h2);
00132
00133
virtual void changed() { m_changed =
true; };
00134
bool isChanged() {
bool ret = m_changed; m_changed =
false;
return ret; };
00135
00136
void clear();
00137
00138
private:
00139
int m_weight;
00140
bool m_italic, m_underline, m_overline,m_strikeout, m_changed;
00141
QColor m_outline, m_textColor, m_selectedTextColor, m_bgColor, m_selectedBGColor;
00142
int m_itemsSet;
00143 };
00144
00145
#endif
00146
00147