author | mjg59 <mjg59> | 2003-12-10 03:57:04 (UTC) |
---|---|---|
committer | mjg59 <mjg59> | 2003-12-10 03:57:04 (UTC) |
commit | becbcfae3bf3b5a714e7d3e39b924e08761739c2 (patch) (unidiff) | |
tree | 7ec5f6f90a9d529858da340150b415d87e7936ba | |
parent | 1f0b92e554b76852af210ceb277b3e9ecb09a43d (diff) | |
download | opie-becbcfae3bf3b5a714e7d3e39b924e08761739c2.zip opie-becbcfae3bf3b5a714e7d3e39b924e08761739c2.tar.gz opie-becbcfae3bf3b5a714e7d3e39b924e08761739c2.tar.bz2 |
Fix the search directory for the training file, remove the (non-working anyway) font size calculation code - with luck, this'll fix the failure to start under Opie
-rw-r--r-- | inputmethods/dasher/QtDasherPlugin.cc | 2 | ||||
-rw-r--r-- | inputmethods/dasher/QtDasherScreen.cc | 13 | ||||
-rw-r--r-- | inputmethods/dasher/QtDasherScreen.h | 9 |
3 files changed, 15 insertions, 9 deletions
diff --git a/inputmethods/dasher/QtDasherPlugin.cc b/inputmethods/dasher/QtDasherPlugin.cc index fe1712e..cf4fc2c 100644 --- a/inputmethods/dasher/QtDasherPlugin.cc +++ b/inputmethods/dasher/QtDasherPlugin.cc | |||
@@ -1,79 +1,79 @@ | |||
1 | #include "QtDasherPlugin.h" | 1 | #include "QtDasherPlugin.h" |
2 | 2 | ||
3 | #include <qpe/global.h> | 3 | #include <qpe/global.h> |
4 | 4 | ||
5 | #include <qpainter.h> | 5 | #include <qpainter.h> |
6 | #include <qlist.h> | 6 | #include <qlist.h> |
7 | #include <qbitmap.h> | 7 | #include <qbitmap.h> |
8 | #include <qlayout.h> | 8 | #include <qlayout.h> |
9 | #include <qvbox.h> | 9 | #include <qvbox.h> |
10 | #include <qdialog.h> | 10 | #include <qdialog.h> |
11 | #include <qscrollview.h> | 11 | #include <qscrollview.h> |
12 | #include <qpopupmenu.h> | 12 | #include <qpopupmenu.h> |
13 | #include <qhbuttongroup.h> | 13 | #include <qhbuttongroup.h> |
14 | #include <qpushbutton.h> | 14 | #include <qpushbutton.h> |
15 | #include <qmessagebox.h> | 15 | #include <qmessagebox.h> |
16 | #include <qwindowsystem_qws.h> | 16 | #include <qwindowsystem_qws.h> |
17 | 17 | ||
18 | QtDasherPlugin::QtDasherPlugin(QWidget* parent, const char* name, WFlags f) : QFrame(parent,name,f) | 18 | QtDasherPlugin::QtDasherPlugin(QWidget* parent, const char* name, WFlags f) : QFrame(parent,name,f) |
19 | { | 19 | { |
20 | (new QHBoxLayout(this))->setAutoAdd(TRUE); | 20 | (new QHBoxLayout(this))->setAutoAdd(TRUE); |
21 | interface = new CDasherInterface; | 21 | interface = new CDasherInterface; |
22 | interface->SetSystemLocation("/opt/QtPalmtop/share/dasher"); | 22 | interface->SetSystemLocation("/opt/QtPalmtop/share/dasher/"); |
23 | interface->Unpause(0); | 23 | interface->Unpause(0); |
24 | interface->Start(); | 24 | interface->Start(); |
25 | d = new QtDasherScreen(240,100,interface,this,this); | 25 | d = new QtDasherScreen(240,100,interface,this,this); |
26 | interface->ChangeMaxBitRate(2.5); | 26 | interface->ChangeMaxBitRate(2.5); |
27 | d->show(); | 27 | d->show(); |
28 | utf8_codec = new QUtf8Codec; | 28 | utf8_codec = new QUtf8Codec; |
29 | } | 29 | } |
30 | 30 | ||
31 | QSize QtDasherPlugin::sizeHint() const | 31 | QSize QtDasherPlugin::sizeHint() const |
32 | { | 32 | { |
33 | return QSize(240,100); | 33 | return QSize(240,100); |
34 | } | 34 | } |
35 | 35 | ||
36 | QtDasherPlugin::~QtDasherPlugin() | 36 | QtDasherPlugin::~QtDasherPlugin() |
37 | { | 37 | { |
38 | delete d; | 38 | delete d; |
39 | } | 39 | } |
40 | 40 | ||
41 | void QtDasherPlugin::resetState() | 41 | void QtDasherPlugin::resetState() |
42 | { | 42 | { |
43 | flushcount=0; | 43 | flushcount=0; |
44 | interface->Start(); | 44 | interface->Start(); |
45 | interface->Redraw(); | 45 | interface->Redraw(); |
46 | } | 46 | } |
47 | 47 | ||
48 | void QtDasherPlugin::unflush() | 48 | void QtDasherPlugin::unflush() |
49 | { | 49 | { |
50 | if (flushcount==0) | 50 | if (flushcount==0) |
51 | return; | 51 | return; |
52 | for (flushcount; flushcount>0; flushcount--) { | 52 | for (flushcount; flushcount>0; flushcount--) { |
53 | deletetext(); | 53 | deletetext(); |
54 | } | 54 | } |
55 | } | 55 | } |
56 | 56 | ||
57 | void QtDasherPlugin::output(int Symbol) | 57 | void QtDasherPlugin::output(int Symbol) |
58 | { | 58 | { |
59 | std::string label = interface->GetEditText(Symbol); | 59 | std::string label = interface->GetEditText(Symbol); |
60 | QString unicodestring = utf8_codec->toUnicode(label.c_str()); | 60 | QString unicodestring = utf8_codec->toUnicode(label.c_str()); |
61 | for (int i=0; i<int(unicodestring.length()); i++) { | 61 | for (int i=0; i<int(unicodestring.length()); i++) { |
62 | emit key( unicodestring[i].unicode(), 0, 0, true, false ); | 62 | emit key( unicodestring[i].unicode(), 0, 0, true, false ); |
63 | emit key( unicodestring[i].unicode(), 0, 0, false, false ); | 63 | emit key( unicodestring[i].unicode(), 0, 0, false, false ); |
64 | } | 64 | } |
65 | } | 65 | } |
66 | 66 | ||
67 | void QtDasherPlugin::deletetext() | 67 | void QtDasherPlugin::deletetext() |
68 | { | 68 | { |
69 | emit key( 0, Qt::Key_Backspace, 0, true, false); | 69 | emit key( 0, Qt::Key_Backspace, 0, true, false); |
70 | emit key( 0, Qt::Key_Backspace, 0, false, false); | 70 | emit key( 0, Qt::Key_Backspace, 0, false, false); |
71 | } | 71 | } |
72 | 72 | ||
73 | void QtDasherPlugin::flush(int Symbol) | 73 | void QtDasherPlugin::flush(int Symbol) |
74 | { | 74 | { |
75 | if (Symbol==0) | 75 | if (Symbol==0) |
76 | return; | 76 | return; |
77 | output(Symbol); | 77 | output(Symbol); |
78 | flushcount++; | 78 | flushcount++; |
79 | } | 79 | } |
diff --git a/inputmethods/dasher/QtDasherScreen.cc b/inputmethods/dasher/QtDasherScreen.cc index d05ef49..7d77511 100644 --- a/inputmethods/dasher/QtDasherScreen.cc +++ b/inputmethods/dasher/QtDasherScreen.cc | |||
@@ -1,177 +1,180 @@ | |||
1 | // QtDasherScreen.cc | 1 | // QtDasherScreen.cc |
2 | // (c) 2003 Yann Dirson | 2 | // (c) 2003 Yann Dirson |
3 | // Derived from GtkDasherCanvas.cc | 3 | // Derived from GtkDasherCanvas.cc |
4 | // (c) 2002 Philip Cowans | 4 | // (c) 2002 Philip Cowans |
5 | 5 | ||
6 | #include <iostream> | 6 | #include <iostream> |
7 | #include <string> | 7 | #include <string> |
8 | 8 | ||
9 | #include <qpointarray.h> | 9 | #include <qpointarray.h> |
10 | #include <qpoint.h> | 10 | #include <qpoint.h> |
11 | 11 | ||
12 | #include "QtDasherScreen.h" | 12 | #include "QtDasherScreen.h" |
13 | #include "DasherScreen.h" | 13 | #include "DasherScreen.h" |
14 | #include "SettingsStore.h" | 14 | #include "SettingsStore.h" |
15 | 15 | ||
16 | #define MAXFONTSIZE 25 | 16 | #define MAXFONTSIZE 25 |
17 | #define MINFONTSIZE 8 | 17 | #define MINFONTSIZE 8 |
18 | 18 | ||
19 | #include <iconv.h> | ||
20 | #include <iostream> | ||
21 | |||
19 | QtDasherScreen::QtDasherScreen (int _width, int _height, | 22 | QtDasherScreen::QtDasherScreen (int _width, int _height, |
20 | CDasherInterface *_interface, | 23 | CDasherInterface *_interface, |
21 | QWidget * _parent, Dasher::CDashEditbox *edit): | 24 | QWidget * _parent, Dasher::CDashEditbox *edit): |
22 | QWidget(_parent), interface( _interface ), | 25 | QWidget(_parent), interface( _interface ), |
23 | fontname( "fixed" ), // fontsize(12), | 26 | fontname( "fixed" ), fontsize(12), |
24 | Dasher::CDasherScreen(_width, _height) | 27 | Dasher::CDasherScreen(_width, _height) |
25 | { | 28 | { |
26 | // font = new QFont (fontname, fontsize); | 29 | font = QFont (fontname.c_str(), fontsize); |
27 | painter = new QPainter (); | 30 | painter = new QPainter (); |
28 | 31 | ||
29 | pixmap = new QPixmap (_width, _height); | 32 | pixmap = new QPixmap (_width, _height); |
30 | pixmap->setOptimization(QPixmap::BestOptim); | 33 | pixmap->setOptimization(QPixmap::BestOptim); |
31 | interface->SetSettingsStore(new CSettingsStore); | 34 | interface->SetSettingsStore(new CSettingsStore); |
32 | 35 | ||
33 | interface->ChangeLanguageModel(0); | 36 | interface->ChangeLanguageModel(0); |
34 | interface->ChangeView(0); | 37 | interface->ChangeView(0); |
35 | interface->ChangeEdit(edit); | 38 | interface->ChangeEdit(edit); |
36 | 39 | ||
37 | interface->GetFontSizes(&FontSizes); | 40 | /* interface->GetFontSizes(&FontSizes); |
38 | 41 | ||
39 | for (int i=0; i<FontSizes.size(); i++) { | 42 | for (int i=0; i<FontSizes.size(); i++) { |
40 | if (FontSizes[i]>Fonts.size()) | 43 | if (FontSizes[i]>Fonts.size()) |
41 | Fonts.resize((FontSizes[i])+1); | 44 | Fonts.resize((FontSizes[i])+1); |
42 | Fonts[FontSizes[i]]= QFont (fontname.c_str(), FontSizes[i]); | 45 | Fonts[FontSizes[i]]= QFont (fontname.c_str(), FontSizes[i]); |
43 | Fonts[FontSizes[i]].setPixelSize(FontSizes[i]); | 46 | // Fonts[FontSizes[i]].setPixelSize(FontSizes[i]); |
44 | } | 47 | } |
45 | 48 | */ | |
46 | interface->ChangeScreen(this); | 49 | interface->ChangeScreen(this); |
47 | 50 | ||
48 | paused=true; | 51 | paused=true; |
49 | 52 | ||
50 | QTimer *tmr = new QTimer(this); | 53 | QTimer *tmr = new QTimer(this); |
51 | connect (tmr, SIGNAL(timeout()), SLOT(timer())); | 54 | connect (tmr, SIGNAL(timeout()), SLOT(timer())); |
52 | tmr->start(200); | 55 | tmr->start(200); |
53 | 56 | ||
54 | } | 57 | } |
55 | 58 | ||
56 | long QtDasherScreen::get_time() | 59 | long QtDasherScreen::get_time() |
57 | { | 60 | { |
58 | long s_now; | 61 | long s_now; |
59 | long ms_now; | 62 | long ms_now; |
60 | 63 | ||
61 | struct timeval tv; | 64 | struct timeval tv; |
62 | struct timezone tz; | 65 | struct timezone tz; |
63 | 66 | ||
64 | gettimeofday( &tv, &tz ); | 67 | gettimeofday( &tv, &tz ); |
65 | 68 | ||
66 | s_now = tv.tv_sec-1054487600; | 69 | s_now = tv.tv_sec-1054487600; |
67 | 70 | ||
68 | ms_now = tv.tv_usec / 1000; | 71 | ms_now = tv.tv_usec / 1000; |
69 | 72 | ||
70 | return( long(s_now*1000 + ms_now) ); | 73 | return( long(s_now*1000 + ms_now) ); |
71 | 74 | ||
72 | } | 75 | } |
73 | 76 | ||
74 | QtDasherScreen::~QtDasherScreen() | 77 | QtDasherScreen::~QtDasherScreen() |
75 | { | 78 | { |
76 | delete painter; | 79 | delete painter; |
77 | delete interface; | 80 | delete interface; |
78 | delete edit; | 81 | delete edit; |
79 | } | 82 | } |
80 | 83 | ||
81 | QColor QtDasherScreen::getColor(int Color, const Opts::ColorSchemes ColorScheme) const | 84 | QColor QtDasherScreen::getColor(int Color, const Opts::ColorSchemes ColorScheme) const |
82 | { | 85 | { |
83 | switch (ColorScheme) { | 86 | switch (ColorScheme) { |
84 | case Dasher::Opts::Nodes1: | 87 | case Dasher::Opts::Nodes1: |
85 | switch (Color) { | 88 | switch (Color) { |
86 | case 0: return QColor (180, 245, 180); | 89 | case 0: return QColor (180, 245, 180); |
87 | case 1: return QColor (160, 200, 160); | 90 | case 1: return QColor (160, 200, 160); |
88 | case 2: return QColor (0, 255, 255); | 91 | case 2: return QColor (0, 255, 255); |
89 | default: abort (); | 92 | default: abort (); |
90 | } | 93 | } |
91 | case Dasher::Opts::Nodes2: | 94 | case Dasher::Opts::Nodes2: |
92 | switch (Color) { | 95 | switch (Color) { |
93 | case 0: return QColor (255, 185, 255); | 96 | case 0: return QColor (255, 185, 255); |
94 | case 1: return QColor (140, 200, 255); | 97 | case 1: return QColor (140, 200, 255); |
95 | case 2: return QColor (255, 175, 175); | 98 | case 2: return QColor (255, 175, 175); |
96 | default: abort (); | 99 | default: abort (); |
97 | } | 100 | } |
98 | case Dasher::Opts::Special1: return QColor (240, 240, 240); | 101 | case Dasher::Opts::Special1: return QColor (240, 240, 240); |
99 | case Dasher::Opts::Special2: return QColor (255, 255, 255); | 102 | case Dasher::Opts::Special2: return QColor (255, 255, 255); |
100 | case Dasher::Opts::Groups: | 103 | case Dasher::Opts::Groups: |
101 | switch (Color) { | 104 | switch (Color) { |
102 | case 0: return QColor (255, 255, 0); | 105 | case 0: return QColor (255, 255, 0); |
103 | case 1: return QColor (255, 100, 100); | 106 | case 1: return QColor (255, 100, 100); |
104 | case 2: return QColor (0, 255, 0); | 107 | case 2: return QColor (0, 255, 0); |
105 | default: abort (); | 108 | default: abort (); |
106 | } | 109 | } |
107 | case Dasher::Opts::Objects: return QColor (0, 0, 0); | 110 | case Dasher::Opts::Objects: return QColor (0, 0, 0); |
108 | default: abort(); | 111 | default: abort(); |
109 | } | 112 | } |
110 | } | 113 | } |
111 | 114 | ||
112 | void QtDasherScreen::DrawRectangle(int x1, int y1, int x2, int y2, | 115 | void QtDasherScreen::DrawRectangle(int x1, int y1, int x2, int y2, |
113 | int Color, Opts::ColorSchemes ColorScheme) const | 116 | int Color, Opts::ColorSchemes ColorScheme) const |
114 | { | 117 | { |
115 | painter->setBrush (getColor (Color, ColorScheme)); | 118 | painter->setBrush (getColor (Color, ColorScheme)); |
116 | painter->drawRect (x1, y1, x2-x1, y2-y1); | 119 | painter->drawRect (x1, y1, x2-x1, y2-y1); |
117 | } | 120 | } |
118 | 121 | ||
119 | static void Points_to_QPointArray(const Dasher::CDasherScreen::point* const points, | 122 | static void Points_to_QPointArray(const Dasher::CDasherScreen::point* const points, |
120 | int number, | 123 | int number, |
121 | QPointArray &qpa) | 124 | QPointArray &qpa) |
122 | { | 125 | { |
123 | for (int i = 0; i < number; i++) { | 126 | for (int i = 0; i < number; i++) { |
124 | qpa.setPoint (i, points[i].x, points[i].y); | 127 | qpa.setPoint (i, points[i].x, points[i].y); |
125 | } | 128 | } |
126 | } | 129 | } |
127 | 130 | ||
128 | void QtDasherScreen::Polyline(point* Points, int Number) const | 131 | void QtDasherScreen::Polyline(point* Points, int Number) const |
129 | { | 132 | { |
130 | QPointArray qpa(Number); | 133 | QPointArray qpa(Number); |
131 | Points_to_QPointArray (Points, Number, qpa); | 134 | Points_to_QPointArray (Points, Number, qpa); |
132 | painter->setPen (SolidLine); | 135 | painter->setPen (SolidLine); |
133 | painter->drawPolyline (qpa); | 136 | painter->drawPolyline (qpa); |
134 | painter->setPen (NoPen); | 137 | painter->setPen (NoPen); |
135 | } | 138 | } |
136 | 139 | ||
137 | void QtDasherScreen::DrawPolygon(point* Points, int Number, int Color, | 140 | void QtDasherScreen::DrawPolygon(point* Points, int Number, int Color, |
138 | Opts::ColorSchemes ColorScheme) const | 141 | Opts::ColorSchemes ColorScheme) const |
139 | { | 142 | { |
140 | painter->setBrush (getColor (Color, ColorScheme)); | 143 | painter->setBrush (getColor (Color, ColorScheme)); |
141 | QPointArray qpa(Number); | 144 | QPointArray qpa(Number); |
142 | Points_to_QPointArray (Points, Number, qpa); | 145 | Points_to_QPointArray (Points, Number, qpa); |
143 | painter->drawPolygon (qpa); | 146 | painter->drawPolygon (qpa); |
144 | } | 147 | } |
145 | 148 | ||
146 | void QtDasherScreen::mousePressEvent (QMouseEvent *e) | 149 | void QtDasherScreen::mousePressEvent (QMouseEvent *e) |
147 | { | 150 | { |
148 | paused=false; | 151 | paused=false; |
149 | interface->Unpause(get_time()); | 152 | interface->Unpause(get_time()); |
150 | } | 153 | } |
151 | 154 | ||
152 | void QtDasherScreen::mouseReleaseEvent(QMouseEvent *e) | 155 | void QtDasherScreen::mouseReleaseEvent(QMouseEvent *e) |
153 | { | 156 | { |
154 | QPoint p = e->pos(); | 157 | QPoint p = e->pos(); |
155 | interface->PauseAt(p.x(), p.y()); | 158 | interface->PauseAt(p.x(), p.y()); |
156 | paused=true; | 159 | paused=true; |
157 | } | 160 | } |
158 | 161 | ||
159 | void QtDasherScreen::timer() | 162 | void QtDasherScreen::timer() |
160 | { | 163 | { |
161 | if (paused==false) { | 164 | if (paused==false) { |
162 | QPoint cursorpos; | 165 | QPoint cursorpos; |
163 | cursorpos=this->cursor().pos(); | 166 | cursorpos=this->cursor().pos(); |
164 | cursorpos=mapFromGlobal(cursorpos); | 167 | cursorpos=mapFromGlobal(cursorpos); |
165 | 168 | ||
166 | interface->TapOn(cursorpos.x(), cursorpos.y(), get_time()); | 169 | interface->TapOn(cursorpos.x(), cursorpos.y(), get_time()); |
167 | } | 170 | } |
168 | } | 171 | } |
169 | 172 | ||
170 | 173 | ||
171 | 174 | ||
172 | 175 | ||
173 | 176 | ||
174 | 177 | ||
175 | 178 | ||
176 | 179 | ||
177 | 180 | ||
diff --git a/inputmethods/dasher/QtDasherScreen.h b/inputmethods/dasher/QtDasherScreen.h index c4d3b59..c029a60 100644 --- a/inputmethods/dasher/QtDasherScreen.h +++ b/inputmethods/dasher/QtDasherScreen.h | |||
@@ -1,115 +1,118 @@ | |||
1 | // QtDasherScreen.h | 1 | // QtDasherScreen.h |
2 | // (c) 2003 Yann Dirson | 2 | // (c) 2003 Yann Dirson |
3 | // Derived from GtkDasherCanvas.h | 3 | // Derived from GtkDasherCanvas.h |
4 | // (c) 2002 Philip Cowans | 4 | // (c) 2002 Philip Cowans |
5 | 5 | ||
6 | #ifndef QT_DASHER_SCREEN_H | 6 | #ifndef QT_DASHER_SCREEN_H |
7 | #define QT_DASHER_SCREEN_H | 7 | #define QT_DASHER_SCREEN_H |
8 | 8 | ||
9 | #include <string> | 9 | #include <string> |
10 | #include <sys/time.h> | 10 | #include <sys/time.h> |
11 | 11 | ||
12 | #include <qwidget.h> | 12 | #include <qwidget.h> |
13 | #include <qpainter.h> | 13 | #include <qpainter.h> |
14 | #include <qfont.h> | 14 | #include <qfont.h> |
15 | #include <qstring.h> | 15 | #include <qstring.h> |
16 | #include <qpixmap.h> | 16 | #include <qpixmap.h> |
17 | #include <qtimer.h> | 17 | #include <qtimer.h> |
18 | #include <qcursor.h> | 18 | #include <qcursor.h> |
19 | 19 | ||
20 | #include "DasherScreen.h" | 20 | #include "DasherScreen.h" |
21 | #include "DashEdit.h" | 21 | #include "DashEdit.h" |
22 | #include "DasherInterface.h" | 22 | #include "DasherInterface.h" |
23 | 23 | ||
24 | #include <iconv.h> | ||
25 | |||
24 | using namespace Dasher; | 26 | using namespace Dasher; |
25 | 27 | ||
26 | class QtDasherScreen : public QWidget, public Dasher::CDasherScreen | 28 | class QtDasherScreen : public QWidget, public Dasher::CDasherScreen |
27 | 29 | ||
28 | { | 30 | { |
29 | Q_OBJECT | 31 | Q_OBJECT |
30 | public: | 32 | public: |
31 | QtDasherScreen (int _width, int _height, | 33 | QtDasherScreen (int _width, int _height, |
32 | CDasherInterface *_interface, | 34 | CDasherInterface *_interface, |
33 | QWidget * _parent=0, Dasher::CDashEditbox* edit=0); | 35 | QWidget * _parent=0, Dasher::CDashEditbox* edit=0); |
34 | QtDasherScreen::~QtDasherScreen(); | 36 | QtDasherScreen::~QtDasherScreen(); |
35 | 37 | ||
36 | void SetFont(std::string Name) | 38 | void SetFont(std::string Name) |
37 | { fontname = Name; /* set_the_font(); */ } | 39 | { fontname = Name; /* set_the_font(); */ } |
38 | 40 | ||
39 | void SetFontSize(Dasher::Opts::FontSize fontsize) | 41 | void SetFontSize(Dasher::Opts::FontSize fontsize) |
40 | { | 42 | { |
41 | #warning QtDasherScreen::SetFontSize() not implemented | 43 | #warning QtDasherScreen::SetFontSize() not implemented |
42 | } | 44 | } |
43 | Dasher::Opts::FontSize GetFontSize() | 45 | Dasher::Opts::FontSize GetFontSize() |
44 | { | 46 | { |
45 | #warning QtDasherScreen::GetFontSize() not implemented | 47 | #warning QtDasherScreen::GetFontSize() not implemented |
46 | return (Dasher::Opts::Normal); | 48 | return (Dasher::Opts::Normal); |
47 | } | 49 | } |
48 | 50 | ||
49 | void TextSize(symbol Character, int* Width, int* Height, int Size) const | 51 | void TextSize(symbol Character, int* Width, int* Height, int Size) const |
50 | { | 52 | { |
51 | // should probably use QPainter::boundingRect() | 53 | // should probably use QPainter::boundingRect() |
52 | *Width = *Height = Fonts[Size].pixelSize(); | 54 | *Width = *Height = font.pixelSize(); |
53 | 55 | ||
54 | } | 56 | } |
55 | void DrawText(symbol Character, int x1, int y1, int Size) const | 57 | void DrawText(symbol Character, int x1, int y1, int Size) const |
56 | { | 58 | { |
57 | // QFont font = QFont (fontname.c_str(), Size); | 59 | // QFont font = QFont (fontname.c_str(), Size); |
58 | // font.setPixelSize(Size); | 60 | // font.setPixelSize(Size); |
59 | QPoint point = QPoint(x1, y1+Size/2); | 61 | QPoint point = QPoint(x1, y1+Size/2); |
60 | 62 | ||
61 | painter->setFont (Fonts[Size]); | 63 | painter->setFont (font); |
62 | painter->drawText (point, | 64 | painter->drawText (point, |
63 | QString(interface->GetDisplayText(Character).c_str())); | 65 | QString(interface->GetDisplayText(Character).c_str())); |
64 | } | 66 | } |
65 | 67 | ||
66 | void DrawRectangle(int x1, int y1, int x2, int y2, | 68 | void DrawRectangle(int x1, int y1, int x2, int y2, |
67 | int Color, Opts::ColorSchemes ColorScheme) const; | 69 | int Color, Opts::ColorSchemes ColorScheme) const; |
68 | void Polyline(point* Points, int Number) const; | 70 | void Polyline(point* Points, int Number) const; |
69 | void DrawPolygon(point* Points, int Number, int Color, | 71 | void DrawPolygon(point* Points, int Number, int Color, |
70 | Opts::ColorSchemes ColorScheme) const; | 72 | Opts::ColorSchemes ColorScheme) const; |
71 | 73 | ||
72 | std::vector<int> FontSizes; | 74 | std::vector<int> FontSizes; |
73 | std::vector<QFont> Fonts; | 75 | std::vector<QFont> Fonts; |
74 | 76 | QFont font; | |
77 | int fontsize; | ||
75 | void Blank() const { | 78 | void Blank() const { |
76 | painter->begin(pixmap); | 79 | painter->begin(pixmap); |
77 | painter->setPen (NoPen); | 80 | painter->setPen (NoPen); |
78 | painter->fillRect(0, 0, m_iWidth, m_iHeight, | 81 | painter->fillRect(0, 0, m_iWidth, m_iHeight, |
79 | QColor(255,255,255)); | 82 | QColor(255,255,255)); |
80 | } | 83 | } |
81 | void Display() { | 84 | void Display() { |
82 | painter->end(); | 85 | painter->end(); |
83 | repaint(); | 86 | repaint(); |
84 | } | 87 | } |
85 | 88 | ||
86 | void paintEvent( QPaintEvent * ) | 89 | void paintEvent( QPaintEvent * ) |
87 | { | 90 | { |
88 | bitBlt(this, 0, 0, pixmap); | 91 | bitBlt(this, 0, 0, pixmap); |
89 | } | 92 | } |
90 | 93 | ||
91 | void mousePressEvent (QMouseEvent *e); | 94 | void mousePressEvent (QMouseEvent *e); |
92 | void mouseReleaseEvent (QMouseEvent *e); | 95 | void mouseReleaseEvent (QMouseEvent *e); |
93 | 96 | ||
94 | protected: | 97 | protected: |
95 | QColor getColor(int Color, const Opts::ColorSchemes ColorScheme) const; | 98 | QColor getColor(int Color, const Opts::ColorSchemes ColorScheme) const; |
96 | 99 | ||
97 | long QtDasherScreen::get_time(); | 100 | long QtDasherScreen::get_time(); |
98 | 101 | ||
99 | CDasherInterface* interface; | 102 | CDasherInterface* interface; |
100 | Dasher::CDashEditbox* edit; | 103 | Dasher::CDashEditbox* edit; |
101 | 104 | ||
102 | bool paused; | 105 | bool paused; |
103 | 106 | ||
104 | QPainter* painter; | 107 | QPainter* painter; |
105 | 108 | ||
106 | QPixmap* pixmap; | 109 | QPixmap* pixmap; |
107 | 110 | ||
108 | std::string fontname; | 111 | std::string fontname; |
109 | 112 | ||
110 | protected slots: | 113 | protected slots: |
111 | void timer(); | 114 | void timer(); |
112 | 115 | ||
113 | }; | 116 | }; |
114 | 117 | ||
115 | #endif | 118 | #endif |