blob: 4b1cee257748570521677f2054b30dc6104a7c42 (
plain)
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
/***************************************************************************
* Copyright (C) 2003 by Ralph M. Churchill *
* [email protected] *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#include "textfield.h"
#include <tqfontmetrics.h>
#include <kdebug.h>
TextField::TextField( )
{
setFontSize(12);
setColor(TQColor(192, 192, 192));
setBGColor(TQColor(0, 0, 0));
setFont("Helvetica");
setAlignment(TQt::AlignLeft);
setFixedPitch(false);
setShadow(0);
}
TextField::~TextField()
{
}
TextField::TextField( const TextField& def )
{
setFontSize( def.getFontSize() );
setColor(def.getColor());
setBGColor(def.getBGColor());
setFont( def.getFont() );
setAlignment( def.getAlignment() );
setFixedPitch( def.getFixedPitch() );
setShadow( def.getShadow() );
}
TextField& TextField::operator=(const TextField& rhs)
{
if( this == &rhs)
return *this;
setFontSize( rhs.getFontSize() );
setColor(rhs.getColor());
setBGColor(rhs.getBGColor());
setFont( rhs.getFont() );
setAlignment( rhs.getAlignment() );
setFixedPitch( rhs.getFixedPitch() );
setShadow( rhs.getShadow() );
return *this;
}
void TextField::setColor(TQColor clr)
{
color = clr;
}
TQColor TextField::getColor() const
{
return color;
}
void TextField::setBGColor(TQColor clr)
{
bgColor = clr;
}
TQColor TextField::getBGColor() const
{
return bgColor;
}
void TextField::setFont(const TQString &f)
{
font.setFamily(f);
lineHeight = TQFontMetrics(font).height();
}
TQString TextField::getFont() const
{
return font.family();
}
void TextField::setFontSize(int size)
{
font.setPointSize(size);
lineHeight = TQFontMetrics(font).height();
}
int TextField::getFontSize() const
{
return font.pointSize();
}
void TextField::setAlignment( const TQString &align )
{
TQString a = align.upper();
if( a == "LEFT" || a.isEmpty() )
alignment = TQt::AlignLeft;
if( a == "RIGHT" )
alignment = TQt::AlignRight;
if( a == "CENTER" )
alignment = TQt::AlignHCenter;
}
void TextField::setAlignment( int af )
{
alignment = af;
}
int TextField::getAlignment() const
{
return alignment;
}
TQString TextField::getAlignmentAsString() const
{
if( alignment == TQt::AlignHCenter )
return "CENTER";
else if( alignment == TQt::AlignRight )
return "RIGHT";
else
return "LEFT";
}
void TextField::setFixedPitch( bool fp)
{
font.setFixedPitch( fp );
}
bool TextField::getFixedPitch() const
{
return font.fixedPitch();
}
void TextField::setShadow ( int s )
{
shadow = s;
}
int TextField::getShadow() const
{
return shadow;
}
int TextField::getLineHeight() const
{
return lineHeight;
}
|