• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeutils API Reference
  • KDE Home
  • Contact Us
 

superkaramba

  • sources
  • kde-4.12
  • kdeutils
  • superkaramba
  • src
  • meters
textfield.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2003 by Ralph M. Churchill *
3  * mrchucho@yahoo.com *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  ***************************************************************************/
10 
11 #include "textfield.h"
12 
13 #include <QFontMetrics>
14 
15 TextField::TextField()
16 {
17  setFontSize(12);
18  setColor(QColor(192, 192, 192));
19  setBGColor(QColor(0, 0, 0));
20  setFont("Helvetica");
21  setAlignment(Qt::AlignLeft);
22  setFixedPitch(false);
23  setShadow(0);
24 }
25 
26 TextField::~TextField()
27 {}
28 
29 TextField::TextField(const TextField& def)
30 {
31  setFontSize(def.getFontSize());
32 
33  setColor(def.getColor());
34  setBGColor(def.getBGColor());
35 
36  setFont(def.getFont());
37  setAlignment(def.getAlignment());
38  setFixedPitch(def.getFixedPitch());
39  setShadow(def.getShadow());
40 }
41 
42 TextField& TextField::operator=(const TextField& rhs)
43 {
44  if (this == &rhs)
45  return *this;
46 
47  setFontSize(rhs.getFontSize());
48 
49  setColor(rhs.getColor());
50  setBGColor(rhs.getBGColor());
51 
52  setFont(rhs.getFont());
53  setAlignment(rhs.getAlignment());
54  setFixedPitch(rhs.getFixedPitch());
55  setShadow(rhs.getShadow());
56 
57  return *this;
58 }
59 
60 void TextField::setColor(QColor clr)
61 {
62  color = clr;
63 }
64 
65 QColor TextField::getColor() const
66 {
67  return color;
68 }
69 
70 void TextField::setBGColor(QColor clr)
71 {
72  bgColor = clr;
73 }
74 
75 QColor TextField::getBGColor() const
76 {
77  return bgColor;
78 }
79 
80 
81 void TextField::setFont(const QString &f)
82 {
83  font.setFamily(f);
84  lineHeight = QFontMetrics(font).height();
85 }
86 
87 
88 QString TextField::getFont() const
89 {
90  return font.family();
91 }
92 
93 void TextField::setFontSize(int size)
94 {
95  font.setPointSize(size);
96  lineHeight = QFontMetrics(font).height();
97 }
98 
99 int TextField::getFontSize() const
100 {
101  return font.pointSize();
102 }
103 
104 void TextField::setAlignment(const QString &align)
105 {
106  QString a = align.toUpper();
107  if (a == "LEFT" || a.isEmpty())
108  alignment = Qt::AlignLeft;
109  if (a == "RIGHT")
110  alignment = Qt::AlignRight;
111  if (a == "CENTER")
112  alignment = Qt::AlignHCenter;
113 }
114 
115 void TextField::setAlignment(int af)
116 {
117  alignment = af;
118 }
119 
120 int TextField::getAlignment() const
121 {
122  return alignment;
123 }
124 
125 QString TextField::getAlignmentAsString() const
126 {
127  if (alignment == Qt::AlignHCenter)
128  return "CENTER";
129  else if (alignment == Qt::AlignRight)
130  return "RIGHT";
131  else
132  return "LEFT";
133 }
134 
135 void TextField::setFixedPitch(bool fp)
136 {
137  font.setFixedPitch(fp);
138 }
139 
140 bool TextField::getFixedPitch() const
141 {
142  return font.fixedPitch();
143 }
144 
145 void TextField::setShadow(int s)
146 {
147  shadow = s;
148 }
149 
150 int TextField::getShadow() const
151 {
152  return shadow;
153 }
154 
155 int TextField::getLineHeight() const
156 {
157  return lineHeight;
158 }
TextField::lineHeight
int lineHeight
Definition: textfield.h:56
TextField::getFontSize
int getFontSize() const
Definition: textfield.cpp:99
TextField::setBGColor
void setBGColor(QColor clr)
Definition: textfield.cpp:70
TextField::getShadow
int getShadow() const
Definition: textfield.cpp:150
TextField::setFont
void setFont(const QString &)
Definition: textfield.cpp:81
TextField::setShadow
void setShadow(int)
Definition: textfield.cpp:145
TextField::bgColor
QColor bgColor
Definition: textfield.h:54
TextField::getFont
QString getFont() const
Definition: textfield.cpp:88
TextField::getColor
QColor getColor() const
Definition: textfield.cpp:65
TextField::color
QColor color
Definition: textfield.h:53
TextField::getBGColor
QColor getBGColor() const
Definition: textfield.cpp:75
TextField::operator=
TextField & operator=(const TextField &)
Definition: textfield.cpp:42
TextField::setAlignment
void setAlignment(int)
Definition: textfield.cpp:115
TextField::getAlignment
int getAlignment() const
Definition: textfield.cpp:120
TextField::setColor
void setColor(QColor clr)
Definition: textfield.cpp:60
TextField::setFixedPitch
void setFixedPitch(bool)
Definition: textfield.cpp:135
TextField::shadow
int shadow
Definition: textfield.h:55
textfield.h
TextField::font
QFont font
Definition: textfield.h:52
TextField::getFixedPitch
bool getFixedPitch() const
Definition: textfield.cpp:140
TextField::~TextField
~TextField()
Definition: textfield.cpp:26
TextField::getLineHeight
int getLineHeight() const
Definition: textfield.cpp:155
TextField::TextField
TextField()
Definition: textfield.cpp:15
TextField::setFontSize
void setFontSize(int)
Definition: textfield.cpp:93
TextField
Ralph M.
Definition: textfield.h:22
TextField::getAlignmentAsString
QString getAlignmentAsString() const
Definition: textfield.cpp:125
TextField::alignment
int alignment
Definition: textfield.h:51
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:07:20 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

superkaramba

Skip menu "superkaramba"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeutils API Reference

Skip menu "kdeutils API Reference"
  • ark
  • filelight
  • kcalc
  • kcharselect
  • kdf
  • kfloppy
  • kgpg
  • kremotecontrol
  • ktimer
  • kwallet
  • superkaramba
  • sweeper

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal