-rw-r--r-- | inputmethods/dasher/QtDasherScreen.cc | 3 | ||||
-rw-r--r-- | inputmethods/dasher/QtDasherScreen.h | 2 |
2 files changed, 0 insertions, 5 deletions
diff --git a/inputmethods/dasher/QtDasherScreen.cc b/inputmethods/dasher/QtDasherScreen.cc index 6820105..d05ef49 100644 --- a/inputmethods/dasher/QtDasherScreen.cc +++ b/inputmethods/dasher/QtDasherScreen.cc | |||
@@ -1,117 +1,114 @@ | |||
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 | |||
22 | QtDasherScreen::QtDasherScreen (int _width, int _height, | 19 | QtDasherScreen::QtDasherScreen (int _width, int _height, |
23 | CDasherInterface *_interface, | 20 | CDasherInterface *_interface, |
24 | QWidget * _parent, Dasher::CDashEditbox *edit): | 21 | QWidget * _parent, Dasher::CDashEditbox *edit): |
25 | QWidget(_parent), interface( _interface ), | 22 | QWidget(_parent), interface( _interface ), |
26 | fontname( "fixed" ), // fontsize(12), | 23 | fontname( "fixed" ), // fontsize(12), |
27 | Dasher::CDasherScreen(_width, _height) | 24 | Dasher::CDasherScreen(_width, _height) |
28 | { | 25 | { |
29 | // font = new QFont (fontname, fontsize); | 26 | // font = new QFont (fontname, fontsize); |
30 | painter = new QPainter (); | 27 | painter = new QPainter (); |
31 | 28 | ||
32 | pixmap = new QPixmap (_width, _height); | 29 | pixmap = new QPixmap (_width, _height); |
33 | pixmap->setOptimization(QPixmap::BestOptim); | 30 | pixmap->setOptimization(QPixmap::BestOptim); |
34 | interface->SetSettingsStore(new CSettingsStore); | 31 | interface->SetSettingsStore(new CSettingsStore); |
35 | 32 | ||
36 | interface->ChangeLanguageModel(0); | 33 | interface->ChangeLanguageModel(0); |
37 | interface->ChangeView(0); | 34 | interface->ChangeView(0); |
38 | interface->ChangeEdit(edit); | 35 | interface->ChangeEdit(edit); |
39 | 36 | ||
40 | interface->GetFontSizes(&FontSizes); | 37 | interface->GetFontSizes(&FontSizes); |
41 | 38 | ||
42 | for (int i=0; i<FontSizes.size(); i++) { | 39 | for (int i=0; i<FontSizes.size(); i++) { |
43 | if (FontSizes[i]>Fonts.size()) | 40 | if (FontSizes[i]>Fonts.size()) |
44 | Fonts.resize((FontSizes[i])+1); | 41 | Fonts.resize((FontSizes[i])+1); |
45 | Fonts[FontSizes[i]]= QFont (fontname.c_str(), FontSizes[i]); | 42 | Fonts[FontSizes[i]]= QFont (fontname.c_str(), FontSizes[i]); |
46 | Fonts[FontSizes[i]].setPixelSize(FontSizes[i]); | 43 | Fonts[FontSizes[i]].setPixelSize(FontSizes[i]); |
47 | } | 44 | } |
48 | 45 | ||
49 | interface->ChangeScreen(this); | 46 | interface->ChangeScreen(this); |
50 | 47 | ||
51 | paused=true; | 48 | paused=true; |
52 | 49 | ||
53 | QTimer *tmr = new QTimer(this); | 50 | QTimer *tmr = new QTimer(this); |
54 | connect (tmr, SIGNAL(timeout()), SLOT(timer())); | 51 | connect (tmr, SIGNAL(timeout()), SLOT(timer())); |
55 | tmr->start(200); | 52 | tmr->start(200); |
56 | 53 | ||
57 | } | 54 | } |
58 | 55 | ||
59 | long QtDasherScreen::get_time() | 56 | long QtDasherScreen::get_time() |
60 | { | 57 | { |
61 | long s_now; | 58 | long s_now; |
62 | long ms_now; | 59 | long ms_now; |
63 | 60 | ||
64 | struct timeval tv; | 61 | struct timeval tv; |
65 | struct timezone tz; | 62 | struct timezone tz; |
66 | 63 | ||
67 | gettimeofday( &tv, &tz ); | 64 | gettimeofday( &tv, &tz ); |
68 | 65 | ||
69 | s_now = tv.tv_sec-1054487600; | 66 | s_now = tv.tv_sec-1054487600; |
70 | 67 | ||
71 | ms_now = tv.tv_usec / 1000; | 68 | ms_now = tv.tv_usec / 1000; |
72 | 69 | ||
73 | return( long(s_now*1000 + ms_now) ); | 70 | return( long(s_now*1000 + ms_now) ); |
74 | 71 | ||
75 | } | 72 | } |
76 | 73 | ||
77 | QtDasherScreen::~QtDasherScreen() | 74 | QtDasherScreen::~QtDasherScreen() |
78 | { | 75 | { |
79 | delete painter; | 76 | delete painter; |
80 | delete interface; | 77 | delete interface; |
81 | delete edit; | 78 | delete edit; |
82 | } | 79 | } |
83 | 80 | ||
84 | QColor QtDasherScreen::getColor(int Color, const Opts::ColorSchemes ColorScheme) const | 81 | QColor QtDasherScreen::getColor(int Color, const Opts::ColorSchemes ColorScheme) const |
85 | { | 82 | { |
86 | switch (ColorScheme) { | 83 | switch (ColorScheme) { |
87 | case Dasher::Opts::Nodes1: | 84 | case Dasher::Opts::Nodes1: |
88 | switch (Color) { | 85 | switch (Color) { |
89 | case 0: return QColor (180, 245, 180); | 86 | case 0: return QColor (180, 245, 180); |
90 | case 1: return QColor (160, 200, 160); | 87 | case 1: return QColor (160, 200, 160); |
91 | case 2: return QColor (0, 255, 255); | 88 | case 2: return QColor (0, 255, 255); |
92 | default: abort (); | 89 | default: abort (); |
93 | } | 90 | } |
94 | case Dasher::Opts::Nodes2: | 91 | case Dasher::Opts::Nodes2: |
95 | switch (Color) { | 92 | switch (Color) { |
96 | case 0: return QColor (255, 185, 255); | 93 | case 0: return QColor (255, 185, 255); |
97 | case 1: return QColor (140, 200, 255); | 94 | case 1: return QColor (140, 200, 255); |
98 | case 2: return QColor (255, 175, 175); | 95 | case 2: return QColor (255, 175, 175); |
99 | default: abort (); | 96 | default: abort (); |
100 | } | 97 | } |
101 | case Dasher::Opts::Special1: return QColor (240, 240, 240); | 98 | case Dasher::Opts::Special1: return QColor (240, 240, 240); |
102 | case Dasher::Opts::Special2: return QColor (255, 255, 255); | 99 | case Dasher::Opts::Special2: return QColor (255, 255, 255); |
103 | case Dasher::Opts::Groups: | 100 | case Dasher::Opts::Groups: |
104 | switch (Color) { | 101 | switch (Color) { |
105 | case 0: return QColor (255, 255, 0); | 102 | case 0: return QColor (255, 255, 0); |
106 | case 1: return QColor (255, 100, 100); | 103 | case 1: return QColor (255, 100, 100); |
107 | case 2: return QColor (0, 255, 0); | 104 | case 2: return QColor (0, 255, 0); |
108 | default: abort (); | 105 | default: abort (); |
109 | } | 106 | } |
110 | case Dasher::Opts::Objects: return QColor (0, 0, 0); | 107 | case Dasher::Opts::Objects: return QColor (0, 0, 0); |
111 | default: abort(); | 108 | default: abort(); |
112 | } | 109 | } |
113 | } | 110 | } |
114 | 111 | ||
115 | void QtDasherScreen::DrawRectangle(int x1, int y1, int x2, int y2, | 112 | void QtDasherScreen::DrawRectangle(int x1, int y1, int x2, int y2, |
116 | int Color, Opts::ColorSchemes ColorScheme) const | 113 | int Color, Opts::ColorSchemes ColorScheme) const |
117 | { | 114 | { |
diff --git a/inputmethods/dasher/QtDasherScreen.h b/inputmethods/dasher/QtDasherScreen.h index f359113..c4d3b59 100644 --- a/inputmethods/dasher/QtDasherScreen.h +++ b/inputmethods/dasher/QtDasherScreen.h | |||
@@ -1,117 +1,115 @@ | |||
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 | |||
26 | using namespace Dasher; | 24 | using namespace Dasher; |
27 | 25 | ||
28 | class QtDasherScreen : public QWidget, public Dasher::CDasherScreen | 26 | class QtDasherScreen : public QWidget, public Dasher::CDasherScreen |
29 | 27 | ||
30 | { | 28 | { |
31 | Q_OBJECT | 29 | Q_OBJECT |
32 | public: | 30 | public: |
33 | QtDasherScreen (int _width, int _height, | 31 | QtDasherScreen (int _width, int _height, |
34 | CDasherInterface *_interface, | 32 | CDasherInterface *_interface, |
35 | QWidget * _parent=0, Dasher::CDashEditbox* edit=0); | 33 | QWidget * _parent=0, Dasher::CDashEditbox* edit=0); |
36 | QtDasherScreen::~QtDasherScreen(); | 34 | QtDasherScreen::~QtDasherScreen(); |
37 | 35 | ||
38 | void SetFont(std::string Name) | 36 | void SetFont(std::string Name) |
39 | { fontname = Name; /* set_the_font(); */ } | 37 | { fontname = Name; /* set_the_font(); */ } |
40 | 38 | ||
41 | void SetFontSize(Dasher::Opts::FontSize fontsize) | 39 | void SetFontSize(Dasher::Opts::FontSize fontsize) |
42 | { | 40 | { |
43 | #warning QtDasherScreen::SetFontSize() not implemented | 41 | #warning QtDasherScreen::SetFontSize() not implemented |
44 | } | 42 | } |
45 | Dasher::Opts::FontSize GetFontSize() | 43 | Dasher::Opts::FontSize GetFontSize() |
46 | { | 44 | { |
47 | #warning QtDasherScreen::GetFontSize() not implemented | 45 | #warning QtDasherScreen::GetFontSize() not implemented |
48 | return (Dasher::Opts::Normal); | 46 | return (Dasher::Opts::Normal); |
49 | } | 47 | } |
50 | 48 | ||
51 | void TextSize(symbol Character, int* Width, int* Height, int Size) const | 49 | void TextSize(symbol Character, int* Width, int* Height, int Size) const |
52 | { | 50 | { |
53 | // should probably use QPainter::boundingRect() | 51 | // should probably use QPainter::boundingRect() |
54 | *Width = *Height = Fonts[Size].pixelSize(); | 52 | *Width = *Height = Fonts[Size].pixelSize(); |
55 | 53 | ||
56 | } | 54 | } |
57 | void DrawText(symbol Character, int x1, int y1, int Size) const | 55 | void DrawText(symbol Character, int x1, int y1, int Size) const |
58 | { | 56 | { |
59 | // QFont font = QFont (fontname.c_str(), Size); | 57 | // QFont font = QFont (fontname.c_str(), Size); |
60 | // font.setPixelSize(Size); | 58 | // font.setPixelSize(Size); |
61 | QPoint point = QPoint(x1, y1+Size/2); | 59 | QPoint point = QPoint(x1, y1+Size/2); |
62 | 60 | ||
63 | painter->setFont (Fonts[Size]); | 61 | painter->setFont (Fonts[Size]); |
64 | painter->drawText (point, | 62 | painter->drawText (point, |
65 | QString(interface->GetDisplayText(Character).c_str())); | 63 | QString(interface->GetDisplayText(Character).c_str())); |
66 | } | 64 | } |
67 | 65 | ||
68 | void DrawRectangle(int x1, int y1, int x2, int y2, | 66 | void DrawRectangle(int x1, int y1, int x2, int y2, |
69 | int Color, Opts::ColorSchemes ColorScheme) const; | 67 | int Color, Opts::ColorSchemes ColorScheme) const; |
70 | void Polyline(point* Points, int Number) const; | 68 | void Polyline(point* Points, int Number) const; |
71 | void DrawPolygon(point* Points, int Number, int Color, | 69 | void DrawPolygon(point* Points, int Number, int Color, |
72 | Opts::ColorSchemes ColorScheme) const; | 70 | Opts::ColorSchemes ColorScheme) const; |
73 | 71 | ||
74 | std::vector<int> FontSizes; | 72 | std::vector<int> FontSizes; |
75 | std::vector<QFont> Fonts; | 73 | std::vector<QFont> Fonts; |
76 | 74 | ||
77 | void Blank() const { | 75 | void Blank() const { |
78 | painter->begin(pixmap); | 76 | painter->begin(pixmap); |
79 | painter->setPen (NoPen); | 77 | painter->setPen (NoPen); |
80 | painter->fillRect(0, 0, m_iWidth, m_iHeight, | 78 | painter->fillRect(0, 0, m_iWidth, m_iHeight, |
81 | QColor(255,255,255)); | 79 | QColor(255,255,255)); |
82 | } | 80 | } |
83 | void Display() { | 81 | void Display() { |
84 | painter->end(); | 82 | painter->end(); |
85 | repaint(); | 83 | repaint(); |
86 | } | 84 | } |
87 | 85 | ||
88 | void paintEvent( QPaintEvent * ) | 86 | void paintEvent( QPaintEvent * ) |
89 | { | 87 | { |
90 | bitBlt(this, 0, 0, pixmap); | 88 | bitBlt(this, 0, 0, pixmap); |
91 | } | 89 | } |
92 | 90 | ||
93 | void mousePressEvent (QMouseEvent *e); | 91 | void mousePressEvent (QMouseEvent *e); |
94 | void mouseReleaseEvent (QMouseEvent *e); | 92 | void mouseReleaseEvent (QMouseEvent *e); |
95 | 93 | ||
96 | protected: | 94 | protected: |
97 | QColor getColor(int Color, const Opts::ColorSchemes ColorScheme) const; | 95 | QColor getColor(int Color, const Opts::ColorSchemes ColorScheme) const; |
98 | 96 | ||
99 | long QtDasherScreen::get_time(); | 97 | long QtDasherScreen::get_time(); |
100 | 98 | ||
101 | CDasherInterface* interface; | 99 | CDasherInterface* interface; |
102 | Dasher::CDashEditbox* edit; | 100 | Dasher::CDashEditbox* edit; |
103 | 101 | ||
104 | bool paused; | 102 | bool paused; |
105 | 103 | ||
106 | QPainter* painter; | 104 | QPainter* painter; |
107 | 105 | ||
108 | QPixmap* pixmap; | 106 | QPixmap* pixmap; |
109 | 107 | ||
110 | std::string fontname; | 108 | std::string fontname; |
111 | 109 | ||
112 | protected slots: | 110 | protected slots: |
113 | void timer(); | 111 | void timer(); |
114 | 112 | ||
115 | }; | 113 | }; |
116 | 114 | ||
117 | #endif | 115 | #endif |