moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames...
[kdeedu.git] / kbruch / src / fractionbasewidget.h
blob4472ade38122799a0b39add61d13098e39102110
1 /***************************************************************************
2 fractionbasewidget.h - base fraction painting
3 -------------------
4 begin : 2004/05/30
5 copyright : (C) 2004 by Sebastian Stein
6 email : seb.kde@hpfsc.de
7 ***************************************************************************/
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
18 #ifndef FRACTIONBASEWIDGET_H
19 #define FRACTIONBASEWIDGET_H
21 /** the space between a ratio and an operation */
22 #define _MARGIN_X 5
24 #ifdef DEBUG
25 #include <kdebug.h>
26 #endif
28 #include "ratio.h"
30 #include <qwidget.h>
33 /*! base class for painting fractions
35 * \author Sebastian Stein */
36 class FractionBaseWidget : public QWidget
38 Q_OBJECT
40 public:
41 /** constructor */
42 FractionBaseWidget(QWidget * parent, const char * name);
44 /** destructor */
45 ~FractionBaseWidget();
47 /** updates the widget by first getting the settings and then repainting */
48 void updateAndRepaint();
50 protected:
52 /* store the different colors */
53 QColor m_colorNumber;
54 QColor m_colorLine;
55 QColor m_colorOperation;
57 /* the font to paint with */
58 QFont m_font;
60 /** overrideing the paint event of QWidget */
61 virtual void paintEvent(QPaintEvent*) = 0;
63 /** paints a ratio at the given position */
64 void paintRatio(QPainter & paint, ratio tmp_ratio, int & x_pos, QFontMetrics & fm, bool show_mixed, bool addMargin = true);
66 /** paints a string in the vertical middle (aligned to the operation signs) */
67 void paintMiddle(QPainter & paint, const QString& paint_str, int & x_pos, QFontMetrics & fm, QColor color, bool addMargin = true);
69 private:
70 /** sets the font and color; values taken from settingsclass */
71 void setColorAndFont();
74 #endif