Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

pickboardcfg.h

Go to the documentation of this file.
00001 /**********************************************************************
00002 ** Copyright (C) 2000-2002 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of the Qtopia Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
00018 **
00019 **********************************************************************/
00020 #ifndef PICKBOARDCFG_H
00021 #define PICKBOARDCFG_H
00022 
00023 #include <qpe/qdawg.h>
00024 
00025 #include <qpushbutton.h>
00026 #include <qhbuttongroup.h>
00027 #include <qdialog.h>
00028 #include <qlist.h>
00029 
00030 // Internal stuff...
00031 
00032 class PickboardPicks;
00033 
00034 class LetterButton : public QPushButton {
00035     Q_OBJECT
00036 public:
00037     LetterButton(const QChar& letter, QWidget* parent);
00038 private slots:
00039     void toggleCase();
00040 private:
00041     bool skip;
00042 };
00043 
00044 class LetterChoice : public QButtonGroup {
00045     Q_OBJECT
00046 public:
00047     LetterChoice(QWidget* parent, const QString& set);
00048 
00049     QChar choice() { return ch; }
00050 
00051 signals:
00052     void changed();
00053 
00054 private slots:
00055     void change();
00056 
00057 private:
00058     QChar ch;
00059 };
00060 
00061 class PickboardAdd : public QDialog {
00062     Q_OBJECT
00063 public:
00064     PickboardAdd(QWidget* owner, const QStringList& setlist);
00065     ~PickboardAdd();
00066 
00067     QString word() const;
00068     bool exec();
00069 
00070 private slots:
00071     void checkAllDone();
00072 
00073 private:
00074     QPushButton *yes;
00075     LetterChoice **lc;
00076     int nlc;
00077 };
00078 
00079 class PickboardConfig : public QObject {
00080     Q_OBJECT
00081 public:
00082     PickboardConfig(PickboardPicks* p) : parent(p), nrows(2), pressx(-1) { }
00083     virtual ~PickboardConfig();
00084     virtual void pickPoint(const QPoint& p, bool press);
00085     virtual void draw(QPainter*)=0;
00086     virtual void fillMenu(QPopupMenu&);
00087     virtual void doMenu(int);
00088 
00089 protected:
00090     void updateRows(int from, int to);
00091     virtual void updateItem(int r, int i);
00092     virtual void pickInRow(int r, int xpos, bool press)=0;
00093 
00094     void changeMode(int m);
00095     virtual void generateText(const QString& s);
00096     void generateKey( int k );
00097 
00098     virtual void pick(bool press, int row, int item)=0;
00099 
00100 protected:
00101     PickboardPicks* parent;
00102     int nrows;
00103 private:
00104     int pressrow, pressx;
00105 };
00106 
00107 class StringConfig : public PickboardConfig {
00108     Q_OBJECT
00109 public:
00110     StringConfig(PickboardPicks* p) : PickboardConfig(p) { }
00111 
00112     void draw(QPainter* p);
00113 
00114 protected:
00115     virtual QString text(int r, int i)=0;
00116     virtual bool spreadRow(int i)=0;
00117     virtual QColor rowColor(int) { return Qt::black; }
00118     virtual void pickInRow(int r, int xpos, bool press);
00119     virtual void updateItem(int r, int i);
00120     virtual bool highlight(int,int) const;
00121 };
00122 
00123 class CharStringConfig : public StringConfig {
00124     Q_OBJECT
00125     QString input;
00126     QStringList chars;
00127 public:
00128     CharStringConfig(PickboardPicks* p) : StringConfig(p) { }
00129 
00130     void addChar(const QString& s);
00131     virtual void doMenu(int);
00132 
00133 protected:
00134     QString text(int r, int i);
00135     bool spreadRow(int i);
00136     void pick(bool press, int row, int item);
00137 };
00138 
00139 class DictFilterConfig : public StringConfig {
00140     Q_OBJECT
00141     QStringList matches;
00142     QStringList sets_a;
00143     QStringList sets;
00144     QStringList othermodes;
00145     int lit0;
00146     int lit1;
00147     int shift;
00148     QString capitalize(const QString& s);
00149     QStringList capitalize(const QStringList& s);
00150 
00151 public:
00152     QStringList input;
00153     DictFilterConfig(PickboardPicks* p) : StringConfig(p)
00154     {
00155         shift = 0;
00156         lit0 = -1;
00157         lit1 = -1;
00158     }
00159 
00160     void addSet(const QString& apperance, const QString& set);
00161     void addMode(const QString& s);
00162 
00163     void fillMenu(QPopupMenu& menu);
00164     void doMenu(int i);
00165     
00166     void add(const QString& set);
00167 
00168 protected:
00169     QString text(int r, int i);
00170 
00171     bool spreadRow(int i);
00172 
00173     void pick(bool press, int row, int item);
00174 
00175     bool scanMatch(const QString& set, const QChar& l) const;
00176     void scan(const QDawg::Node* n, int ipos, const QString& str, int length, bool extend);
00177     void scanLengths(const QDawg::Node* n, int ipos, int& bitarray);
00178 
00179     bool highlight(int r,int c) const;
00180 };
00181 
00182 class CharConfig : public StringConfig {
00183     Q_OBJECT
00184     QStringList chars1;
00185     QStringList chars2;
00186 public:
00187     CharConfig(PickboardPicks* p) : StringConfig(p) { }
00188     void addChar(int r, const QString& s);
00189 
00190 protected:
00191     QString text(int r, int i);
00192     bool spreadRow(int);
00193     void pick(bool press, int row, int item);
00194 };
00195 
00196 class KeycodeConfig : public PickboardConfig {
00197     QValueList<int> keys1;
00198     QValueList<int> keys2;
00199     QValueList<QPixmap> keypm1;
00200     QValueList<QPixmap> keypm2;
00201     enum { xw = 8, xmarg = 8 };
00202 
00203 public:
00204     KeycodeConfig(PickboardPicks* p) : PickboardConfig(p) { }
00205     void addKey(int r, const QPixmap& pm, int code);
00206     void addGap(int r, int w);
00207 
00208     void draw(QPainter* p);
00209 
00210 protected:
00211     void pickInRow(int r, int xpos, bool press);
00212     QValueList<QPixmap> row(int i);
00213 
00214     void pick(bool press, int row, int item);
00215 };
00216 
00217 
00218 #endif

Generated on Sat Nov 5 16:16:04 2005 for OPIE by  doxygen 1.4.2