author | mjg59 <mjg59> | 2003-12-10 03:57:04 (UTC) |
---|---|---|
committer | mjg59 <mjg59> | 2003-12-10 03:57:04 (UTC) |
commit | becbcfae3bf3b5a714e7d3e39b924e08761739c2 (patch) (side-by-side diff) | |
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 @@ #include "QtDasherPlugin.h" #include <qpe/global.h> #include <qpainter.h> #include <qlist.h> #include <qbitmap.h> #include <qlayout.h> #include <qvbox.h> #include <qdialog.h> #include <qscrollview.h> #include <qpopupmenu.h> #include <qhbuttongroup.h> #include <qpushbutton.h> #include <qmessagebox.h> #include <qwindowsystem_qws.h> QtDasherPlugin::QtDasherPlugin(QWidget* parent, const char* name, WFlags f) : QFrame(parent,name,f) { (new QHBoxLayout(this))->setAutoAdd(TRUE); interface = new CDasherInterface; - interface->SetSystemLocation("/opt/QtPalmtop/share/dasher"); + interface->SetSystemLocation("/opt/QtPalmtop/share/dasher/"); interface->Unpause(0); interface->Start(); d = new QtDasherScreen(240,100,interface,this,this); interface->ChangeMaxBitRate(2.5); d->show(); utf8_codec = new QUtf8Codec; } QSize QtDasherPlugin::sizeHint() const { return QSize(240,100); } QtDasherPlugin::~QtDasherPlugin() { delete d; } void QtDasherPlugin::resetState() { flushcount=0; interface->Start(); interface->Redraw(); } void QtDasherPlugin::unflush() { if (flushcount==0) return; for (flushcount; flushcount>0; flushcount--) { deletetext(); } } void QtDasherPlugin::output(int Symbol) { std::string label = interface->GetEditText(Symbol); QString unicodestring = utf8_codec->toUnicode(label.c_str()); for (int i=0; i<int(unicodestring.length()); i++) { emit key( unicodestring[i].unicode(), 0, 0, true, false ); emit key( unicodestring[i].unicode(), 0, 0, false, false ); } } void QtDasherPlugin::deletetext() { emit key( 0, Qt::Key_Backspace, 0, true, false); emit key( 0, Qt::Key_Backspace, 0, false, false); } void QtDasherPlugin::flush(int Symbol) { if (Symbol==0) return; output(Symbol); flushcount++; } 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 @@ // QtDasherScreen.cc // (c) 2003 Yann Dirson // Derived from GtkDasherCanvas.cc // (c) 2002 Philip Cowans #include <iostream> #include <string> #include <qpointarray.h> #include <qpoint.h> #include "QtDasherScreen.h" #include "DasherScreen.h" #include "SettingsStore.h" #define MAXFONTSIZE 25 #define MINFONTSIZE 8 +#include <iconv.h> +#include <iostream> + QtDasherScreen::QtDasherScreen (int _width, int _height, CDasherInterface *_interface, QWidget * _parent, Dasher::CDashEditbox *edit): QWidget(_parent), interface( _interface ), - fontname( "fixed" ), // fontsize(12), + fontname( "fixed" ), fontsize(12), Dasher::CDasherScreen(_width, _height) { - // font = new QFont (fontname, fontsize); + font = QFont (fontname.c_str(), fontsize); painter = new QPainter (); pixmap = new QPixmap (_width, _height); pixmap->setOptimization(QPixmap::BestOptim); interface->SetSettingsStore(new CSettingsStore); interface->ChangeLanguageModel(0); interface->ChangeView(0); interface->ChangeEdit(edit); - interface->GetFontSizes(&FontSizes); +/* interface->GetFontSizes(&FontSizes); for (int i=0; i<FontSizes.size(); i++) { if (FontSizes[i]>Fonts.size()) Fonts.resize((FontSizes[i])+1); Fonts[FontSizes[i]]= QFont (fontname.c_str(), FontSizes[i]); - Fonts[FontSizes[i]].setPixelSize(FontSizes[i]); +// Fonts[FontSizes[i]].setPixelSize(FontSizes[i]); } - +*/ interface->ChangeScreen(this); paused=true; QTimer *tmr = new QTimer(this); connect (tmr, SIGNAL(timeout()), SLOT(timer())); tmr->start(200); } long QtDasherScreen::get_time() { long s_now; long ms_now; struct timeval tv; struct timezone tz; gettimeofday( &tv, &tz ); s_now = tv.tv_sec-1054487600; ms_now = tv.tv_usec / 1000; return( long(s_now*1000 + ms_now) ); } QtDasherScreen::~QtDasherScreen() { delete painter; delete interface; delete edit; } QColor QtDasherScreen::getColor(int Color, const Opts::ColorSchemes ColorScheme) const { switch (ColorScheme) { case Dasher::Opts::Nodes1: switch (Color) { case 0: return QColor (180, 245, 180); case 1: return QColor (160, 200, 160); case 2: return QColor (0, 255, 255); default: abort (); } case Dasher::Opts::Nodes2: switch (Color) { case 0: return QColor (255, 185, 255); case 1: return QColor (140, 200, 255); case 2: return QColor (255, 175, 175); default: abort (); } case Dasher::Opts::Special1: return QColor (240, 240, 240); case Dasher::Opts::Special2: return QColor (255, 255, 255); case Dasher::Opts::Groups: switch (Color) { case 0: return QColor (255, 255, 0); case 1: return QColor (255, 100, 100); case 2: return QColor (0, 255, 0); default: abort (); } case Dasher::Opts::Objects: return QColor (0, 0, 0); default: abort(); } } void QtDasherScreen::DrawRectangle(int x1, int y1, int x2, int y2, int Color, Opts::ColorSchemes ColorScheme) const { painter->setBrush (getColor (Color, ColorScheme)); painter->drawRect (x1, y1, x2-x1, y2-y1); } static void Points_to_QPointArray(const Dasher::CDasherScreen::point* const points, int number, QPointArray &qpa) { for (int i = 0; i < number; i++) { qpa.setPoint (i, points[i].x, points[i].y); } } void QtDasherScreen::Polyline(point* Points, int Number) const { QPointArray qpa(Number); Points_to_QPointArray (Points, Number, qpa); painter->setPen (SolidLine); painter->drawPolyline (qpa); painter->setPen (NoPen); } void QtDasherScreen::DrawPolygon(point* Points, int Number, int Color, Opts::ColorSchemes ColorScheme) const { painter->setBrush (getColor (Color, ColorScheme)); QPointArray qpa(Number); Points_to_QPointArray (Points, Number, qpa); painter->drawPolygon (qpa); } void QtDasherScreen::mousePressEvent (QMouseEvent *e) { paused=false; interface->Unpause(get_time()); } void QtDasherScreen::mouseReleaseEvent(QMouseEvent *e) { QPoint p = e->pos(); interface->PauseAt(p.x(), p.y()); paused=true; } void QtDasherScreen::timer() { if (paused==false) { QPoint cursorpos; cursorpos=this->cursor().pos(); cursorpos=mapFromGlobal(cursorpos); interface->TapOn(cursorpos.x(), cursorpos.y(), get_time()); } } 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 @@ // QtDasherScreen.h // (c) 2003 Yann Dirson // Derived from GtkDasherCanvas.h // (c) 2002 Philip Cowans #ifndef QT_DASHER_SCREEN_H #define QT_DASHER_SCREEN_H #include <string> #include <sys/time.h> #include <qwidget.h> #include <qpainter.h> #include <qfont.h> #include <qstring.h> #include <qpixmap.h> #include <qtimer.h> #include <qcursor.h> #include "DasherScreen.h" #include "DashEdit.h" #include "DasherInterface.h" +#include <iconv.h> + using namespace Dasher; class QtDasherScreen : public QWidget, public Dasher::CDasherScreen { Q_OBJECT public: QtDasherScreen (int _width, int _height, CDasherInterface *_interface, QWidget * _parent=0, Dasher::CDashEditbox* edit=0); QtDasherScreen::~QtDasherScreen(); void SetFont(std::string Name) { fontname = Name; /* set_the_font(); */ } void SetFontSize(Dasher::Opts::FontSize fontsize) { #warning QtDasherScreen::SetFontSize() not implemented } Dasher::Opts::FontSize GetFontSize() { #warning QtDasherScreen::GetFontSize() not implemented return (Dasher::Opts::Normal); } void TextSize(symbol Character, int* Width, int* Height, int Size) const { // should probably use QPainter::boundingRect() - *Width = *Height = Fonts[Size].pixelSize(); + *Width = *Height = font.pixelSize(); } void DrawText(symbol Character, int x1, int y1, int Size) const { // QFont font = QFont (fontname.c_str(), Size); // font.setPixelSize(Size); QPoint point = QPoint(x1, y1+Size/2); - painter->setFont (Fonts[Size]); + painter->setFont (font); painter->drawText (point, QString(interface->GetDisplayText(Character).c_str())); } void DrawRectangle(int x1, int y1, int x2, int y2, int Color, Opts::ColorSchemes ColorScheme) const; void Polyline(point* Points, int Number) const; void DrawPolygon(point* Points, int Number, int Color, Opts::ColorSchemes ColorScheme) const; std::vector<int> FontSizes; std::vector<QFont> Fonts; - + QFont font; + int fontsize; void Blank() const { painter->begin(pixmap); painter->setPen (NoPen); painter->fillRect(0, 0, m_iWidth, m_iHeight, QColor(255,255,255)); } void Display() { painter->end(); repaint(); } void paintEvent( QPaintEvent * ) { bitBlt(this, 0, 0, pixmap); } void mousePressEvent (QMouseEvent *e); void mouseReleaseEvent (QMouseEvent *e); protected: QColor getColor(int Color, const Opts::ColorSchemes ColorScheme) const; long QtDasherScreen::get_time(); CDasherInterface* interface; Dasher::CDashEditbox* edit; bool paused; QPainter* painter; QPixmap* pixmap; std::string fontname; protected slots: void timer(); }; #endif |