summaryrefslogtreecommitdiffstats
path: root/ksim/library/label.h
blob: 8ae9b644b7223487cd8f1db78a6110a2f8ba16c5 (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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/*  ksim - a system monitor for kde
 *
 *  Copyright (C) 2001  Robbie Ward <linuxphreak@gmx.co.uk>
 *
 *  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.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#ifndef KSIM__LABEL_H
#define KSIM__LABEL_H

#include <tqwidget.h>
#include "common.h"

#include <kdemacros.h>

namespace KSim
{
  /**
   * A widget that provides a text or image display
   * which supports themes from gkrellm
   *
   * @short Label widget
   * @author Robbie Ward <linuxphreak@gmx.co.uk>
   */
  class KDE_EXPORT Label : public TQWidget, public KSim::Base
  {
    Q_OBJECT
  TQ_OBJECT
    public:
      /**
       * Constructs a KSim::Label.
       *
       * @param parent is the parent widget
       *
       * Example usage:
       * <pre>
       *  KSim::Label *label = new KSim::Label(this);
       * </pre>
       * To create a KSim::Label with the normal theme look
       * @see KSim::ThemeLoader
       */
      Label(TQWidget *parent, const char *name = 0, WFlags fl = 0);
      /**
       * Constructs a KSimLabel.
       *
       * @param type is the theme type
       * @param parent is the parent widget
       *
       * Example usage:
       * <pre>
       *  KSim::Label *label = new KSim::Label(KSim::Types::None, this);
       * </pre>
       * To create a KSim::Label with the normal theme look,
       * NOTE: this is the same as the KSim::Label(TQWidget *, const char *, WFlags) ctor
       * @see KSim::ThemeLoader
       */
      Label(int type, TQWidget *parent, const char *name = 0, WFlags fl = 0);
      /**
       * Constructs a KSim::Label.
       *
       * @param type is the theme type
       * @param text is the default text to display
       * @param parent is the parent widget
       *
       * Example usage:
       * <pre>
       *  KSim::Label *label = new KSim:Label(KSim::Types::Host, "test label", this);
       * </pre>
       * To create a KSim::Label with the theme look of host
       * @see KSim::ThemeLoader
       */
      Label(int type, const TQString &text,
           TQWidget *parent, const char *name = 0, WFlags fl = 0);
      /**
       * destructs KSim::Label.
       */
      virtual ~Label();

      /**
       * returns the current text of the label
       * @see #setText
       */
      const TQString &text() const;
      /**
       * recreates the labels look & feel
       */
      virtual void configureObject(bool repaintWidget = true);
      /**
       * sets a pixmap for the label
       */
      void setPixmap(const TQPixmap &pixmap);
      /**
       * @return the side pixmap
       */
      const TQPixmap &pixmap() const;
      /**
       * reimplemented for internal reasons
       */
      virtual TQSize sizeHint() const;
      /**
       * reimplemented for internal reasons
       */
      virtual TQSize minimumSizeHint() const;

    public slots:
      /**
       * clears the current text in the label
       */
      void clear();
      /**
       * sets the current label of the widget to @ref text
       * @see text()
       */
      void setText(const TQString &text);

    protected:
      /**
       * reimplemented for internal reasons
       */
      virtual void extraTypeCall();
      /**
       * set wether the shadow should be shown or not
       */
      void setShowShadow(bool show);
      /**
       * @return true if the shadow is to be shown, else false
       */
      bool showShadow() const;
      /**
       * Set the text color
       */
      void setTextColour(const TQColor &color);
      /**
       * @return the text color
       */
      const TQColor &textColour() const;
      /**
       * Set the shadow color
       */
      void setShadowColour(const TQColor &color);
      /**
       * @return the shadow color
       */
      const TQColor &shadowColour() const;
      /**
       * Set the config values depending on the chart type
       */
      void setConfigValues();
      /**
       * reimplemented for internal reasons
       */
      virtual void paintEvent(TQPaintEvent *);
      /**
       * reimplemented for internal reasons
       */
      virtual void resizeEvent(TQResizeEvent *);
      /**
       * draw the text onto the label
       */
      void drawText(TQPainter *painter, const TQRect &rect,
          const TQColor &color, const TQString &text);
      /**
       * draw the pixmap onto the label
       */
      void drawPixmap(TQPainter *painter,
          const TQRect &rect, const TQPixmap &pixmap);
      /**
       * sets the location of the text
       */
      void setTextLocation(const TQRect &rect);
      /**
       * @return the location of the text
       */
      const TQRect &textLocation() const;
      /**
       * sets the location of the shadow text
       */
      void setShadowLocation(const TQRect &rect);
      /**
       * @return the location of the shadow text
       */
      const TQRect &shadowLocation() const;
      /**
       * sets the background image to be painted
       */
      void setThemePixmap(const TQString &image);
      void relayoutLabel(const TQSize &old, bool tqrepaint = true);

    private:
      /**
       * initiates the widget
       */
      void initWidget(int type);

      class Private;
      Private *d;
  };
}
#endif