00001 #ifndef _SETTING_H
00002 #define _SETTING_H
00003
00004 #include <qlayout.h>
00005 #include <qwidget.h>
00006 #include <qlabel.h>
00007 #include <qlineedit.h>
00008 #include <qpushbutton.h>
00009 #include <qdragobject.h>
00010 #include <qtableview.h>
00011 #include <qapplication.h>
00012 #include <qcheckbox.h>
00013 #include <qvgroupbox.h>
00014 #include <qhgroupbox.h>
00015 #include <qfontdatabase.h>
00016 #include <qlistbox.h>
00017 #include <qcombobox.h>
00018
00019 class Setting : public QWidget
00020 {
00021 Q_OBJECT
00022 public:
00023 Setting(int numWin=0,QWidget* parent=0,const char *name=0);
00024 static QPushButton *applica;
00025 static QPushButton *salva;
00026 static int redColorTmp;
00027 static int greenColorTmp;
00028 static int bluColorTmp;
00029 static QFont font_tmp;
00030
00031 private:
00032 QWidget *win;
00033 int nW;
00034 void modifica_stringa(int *,int);
00035 void modifica_font(QFont *,QFont);
00036 private slots:
00037 void applica_modifiche();
00038 void salva_modifiche();
00039 void chiudi_finestra();
00040 void modifica_bottoni(const QFont &);
00041 };
00042
00043 class QFontDialogCustom : public QWidget
00044 {
00045 public:
00046 QFontDialogCustom(){};
00047 QLabel * familyAccel;
00048 QLineEdit * familyEdit;
00049 QListBox * familyList;
00050
00051 QLabel * styleAccel;
00052 QLineEdit * styleEdit;
00053 QListBox * styleList;
00054
00055 QLabel * sizeAccel;
00056 QLineEdit * sizeEdit;
00057 QListBox * sizeList;
00058
00059 QVGroupBox * effects;
00060 QCheckBox * strikeout;
00061 QCheckBox * underline;
00062 QLabel * colorAccel;
00063 QComboBox * color;
00064
00065 QHGroupBox * sample;
00066 QLineEdit * sampleEdit;
00067
00068 QLabel * scriptAccel;
00069 QComboBox * scriptCombo;
00070
00071 QBoxLayout * buttonLayout;
00072 QBoxLayout * effectsLayout;
00073 QBoxLayout * sampleLayout;
00074 QBoxLayout * sampleEditLayout;
00075
00076 QFontDatabase fdb;
00077 QString family;
00078 QString charSet;
00079 QString style;
00080 QString size;
00081
00082 QStringList familyNames;
00083 QStringList charSetNames;
00084 QStringList charSetSamples;
00085 bool usingStandardSizes;
00086 };
00087
00088 class Caratteri : public QWidget
00089 {
00090 Q_OBJECT
00091 public:
00092 Caratteri(QWidget *parent=0,const char *name=0);
00093
00094 signals:
00095 void fontHighlighted(const QFont &font);
00096 void fontSelected(const QFont &font);
00097 private:
00098 virtual void updateFamilies();
00099 virtual void updateScripts();
00100 virtual void updateStyles();
00101 virtual void updateSizes();
00102
00103 void modifica_font(QFont *,QFont);
00104
00105 bool eventFilter(QObject *,QEvent *);
00106
00107 QFontDialogCustom *d;
00108
00109 QListBox *familyListBox() const;
00110 QListBox *styleListBox() const;
00111 QListBox *sizeListBox() const;
00112 QListBox *scriptCombo() const;
00113
00114 void setFont(const QFont &font);
00115 QFont font() const;
00116
00117 #if 0
00118 QString family() const;
00119 QString script() const;
00120 QString style() const;
00121 QString size() const;
00122 #endif;
00123
00124 private slots:
00125 void familyHighlighted(const QString &);
00126 void familyHighlighted(int);
00127 void scriptHighlighted(const QString &);
00128 void scriptHighlighted(int);
00129 void styleHighlighted(const QString &);
00130 void updateSample();
00131 void sizeChanged(const QString &);
00132 void sizeHighlighted(const QString &);
00133
00134 void emitSelectedFont();
00135 };
00136
00137 struct QWellArrayData;
00138
00139 class QWellArray : public QTableView
00140 {
00141 Q_OBJECT
00142 Q_PROPERTY( int numCols READ numCols )
00143 Q_PROPERTY( int numRows READ numRows )
00144 Q_PROPERTY( int selectedColumn READ selectedColumn )
00145 Q_PROPERTY( int selectedRow READ selectedRow )
00146
00147 public:
00148 QWellArray( QWidget *parent=0, const char *name=0, bool popup = FALSE );
00149 QString cellContent( int row, int col ) const;
00150 int numCols() { return nCols; }
00151 int numRows() { return nRows; }
00152 int numCols() const { return nCols; }
00153 int numRows() const { return nRows; }
00154 int selectedColumn() { return selCol; }
00155 int selectedRow() { return selRow; }
00156 int selectedColumn() const { return selCol; }
00157 int selectedRow() const { return selRow; }
00158 virtual void setSelected( int row, int col );
00159 void setCellSize( int w, int h ) { setCellWidth(w);setCellHeight( h ); }
00160 QSize sizeHint() const;
00161 virtual void setDimension( int rows, int cols );
00162 virtual void setCellBrush( int row, int col, const QBrush & );
00163 QBrush cellBrush( int row, int col );
00164
00165 signals:
00166 void selected( int row, int col );
00167
00168 protected:
00169 virtual void setCurrent( int row, int col );
00170 virtual void drawContents( QPainter *, int row, int col, const QRect& );
00171 void drawContents( QPainter * );
00172 void paintCell( QPainter*, int row, int col );
00173 void mousePressEvent( QMouseEvent* );
00174 void mouseReleaseEvent( QMouseEvent* );
00175 void mouseMoveEvent( QMouseEvent* );
00176 void keyPressEvent( QKeyEvent* );
00177 void focusInEvent( QFocusEvent* );
00178 void focusOutEvent( QFocusEvent* );
00179
00180 private:
00181 int curRow;
00182 int curCol;
00183 int selRow;
00184 int selCol;
00185 int nCols;
00186 int nRows;
00187 bool smallStyle;
00188 QWellArrayData *d;
00189
00190 private:
00191 #if defined(Q_DISABLE_COPY)
00192 QWellArray( const QWellArray & );
00193 QWellArray& operator=( const QWellArray & );
00194 #endif
00195 };
00196
00197 struct QWellArrayData {
00198 QBrush *brush;
00199 };
00200
00201 class QColorWell : public QWellArray
00202 {
00203 public:
00204 QColorWell( QWidget *parent, int r, int c, QRgb *vals )
00205 :QWellArray( parent, "" ), values( vals ), mousePressed( FALSE ), oldCurrent( -1, -1 )
00206 { setDimension(r,c); setWFlags( WResizeNoErase ); }
00207 QSizePolicy sizePolicy() const;
00208
00209 protected:
00210 void drawContents( QPainter *, int row, int col, const QRect& );
00211 void drawContents( QPainter *p ) { QWellArray::drawContents(p); }
00212 void mousePressEvent( QMouseEvent *e );
00213 void mouseMoveEvent( QMouseEvent *e );
00214 void mouseReleaseEvent( QMouseEvent *e );
00215 #ifndef QT_NO_DRAGANDDROP
00216 void dragEnterEvent( QDragEnterEvent *e );
00217 void dragLeaveEvent( QDragLeaveEvent *e );
00218 void dragMoveEvent( QDragMoveEvent *e );
00219 void dropEvent( QDropEvent *e );
00220 #endif
00221
00222 private:
00223 QRgb *values;
00224 bool mousePressed;
00225 QPoint pressPos;
00226 QPoint oldCurrent;
00227
00228 };
00229
00230
00231 class QColorPicker : public QFrame
00232 {
00233 Q_OBJECT
00234 public:
00235 QColorPicker(QWidget* parent=0, const char* name=0);
00236 ~QColorPicker();
00237
00238 public slots:
00239 void setCol( int h, int s );
00240
00241 signals:
00242 void newCol( int h, int s );
00243
00244 protected:
00245 QSize sizeHint() const;
00246 QSizePolicy sizePolicy() const;
00247 void drawContents(QPainter* p);
00248 void mouseMoveEvent( QMouseEvent * );
00249 void mousePressEvent( QMouseEvent * );
00250
00251 private:
00252 int hue;
00253 int sat;
00254
00255 QPoint colPt();
00256 int huePt( const QPoint &pt );
00257 int satPt( const QPoint &pt );
00258 void setCol( const QPoint &pt );
00259
00260 QPixmap *pix;
00261 };
00262
00263 class QColorLuminancePicker : public QWidget
00264 {
00265 Q_OBJECT
00266 public:
00267 QColorLuminancePicker(QWidget* parent=0, const char* name=0);
00268 ~QColorLuminancePicker();
00269
00270 public slots:
00271 void setCol( int h, int s, int v );
00272 void setCol( int h, int s );
00273
00274 signals:
00275 void newHsv( int h, int s, int v );
00276
00277 protected:
00278 void paintEvent( QPaintEvent*);
00279 void mouseMoveEvent( QMouseEvent * );
00280 void mousePressEvent( QMouseEvent * );
00281
00282 private:
00283 enum { foff = 3, coff = 4 };
00284 int val;
00285 int hue;
00286 int sat;
00287
00288 int y2val( int y );
00289 int val2y( int val );
00290 void setVal( int v );
00291
00292 QPixmap *pix;
00293 };
00294
00295 class QColorShowLabel : public QFrame
00296 {
00297 Q_OBJECT
00298
00299 public:
00300 QColorShowLabel( QWidget *parent ) :QFrame( parent ) {
00301 setFrameStyle( QFrame::Panel|QFrame::Sunken );
00302 setBackgroundMode( PaletteBackground );
00303 setAcceptDrops( TRUE );
00304 mousePressed = FALSE;
00305 }
00306 void setColor( QColor c ) { col = c; }
00307
00308 signals:
00309 void colorDropped( QRgb );
00310
00311 protected:
00312 void drawContents( QPainter *p );
00313 void mousePressEvent( QMouseEvent *e );
00314 void mouseMoveEvent( QMouseEvent *e );
00315 void mouseReleaseEvent( QMouseEvent *e );
00316 #ifndef QT_NO_DRAGANDDROP
00317 void dragEnterEvent( QDragEnterEvent *e );
00318 void dragLeaveEvent( QDragLeaveEvent *e );
00319 void dropEvent( QDropEvent *e );
00320 #endif
00321
00322 private:
00323 QColor col;
00324 bool mousePressed;
00325 QPoint pressPos;
00326
00327 };
00328
00329 class QColNumLineEdit : public QLineEdit
00330 {
00331 public:
00332 QColNumLineEdit( QWidget *parent, const char* name = 0 )
00333 : QLineEdit( parent, name ) { setMaxLength( 3 );}
00334 QSize sizeHint() const {
00335 return QSize( 30,
00336 QLineEdit::sizeHint().height() ); }
00337 void setNum( int i ) {
00338 QString s;
00339 s.setNum(i);
00340 blockSignals(TRUE);
00341 setText( s );
00342 blockSignals(FALSE);
00343 }
00344 int val() const { return text().toInt(); }
00345 };
00346
00347
00348
00349
00350 class QColorShower : public QWidget
00351 {
00352 Q_OBJECT
00353 public:
00354 QColorShower( QWidget *parent, const char *name = 0 );
00355
00356
00357 void setHsv( int h, int s, int v );
00358
00359 int currentAlpha() const { return alphaEd->val(); }
00360 void setCurrentAlpha( int a ) { alphaEd->setNum( a ); }
00361 void showAlpha( bool b );
00362
00363
00364 QRgb currentColor() const { return curCol; }
00365
00366 public slots:
00367 void setRgb( QRgb rgb );
00368
00369 signals:
00370 void newCol( QRgb rgb );
00371
00372 private slots:
00373 void rgbEd();
00374 void hsvEd();
00375 private:
00376 void showCurrentColor();
00377 int hue, sat, val;
00378 QRgb curCol;
00379 QColNumLineEdit *hEd;
00380 QColNumLineEdit *sEd;
00381 QColNumLineEdit *vEd;
00382 QColNumLineEdit *rEd;
00383 QColNumLineEdit *gEd;
00384 QColNumLineEdit *bEd;
00385 QColNumLineEdit *alphaEd;
00386 QLabel *alphaLab;
00387 QColorShowLabel *lab;
00388 bool rgbOriginal;
00389 };
00390
00391
00392
00393 class Colori : public QWidget
00394 {
00395 Q_OBJECT
00396 public:
00397 Colori(QWidget *parent=0,const char *name=0);
00398 static QRgb getRgba( QRgb, bool* ok = 0,QWidget *parent=0, const char* name=0 );
00399 static int customCount();
00400 static QRgb customColor( int );
00401 static void setCustomColor( int, QRgb );
00402 void setColor( QColor );
00403 QColor color() const;
00404
00405 private:
00406 void setSelectedAlpha( int );
00407 int selectedAlpha() const;
00408 void showCustom( bool=TRUE );
00409 QRgb currentColor() const { return cs->currentColor(); }
00410 void setCurrentColor( QRgb rgb );
00411 int currentAlpha() const { return cs->currentAlpha(); }
00412 void setCurrentAlpha( int a ) { cs->setCurrentAlpha( a ); }
00413 void showAlpha( bool b ) { cs->showAlpha( b ); }
00414 QColorPicker *cp;
00415 QColorLuminancePicker *lp;
00416 QWellArray *custom;
00417 QWellArray *standard;
00418 QColorShower *cs;
00419 int nextCust;
00420 bool compact;
00421 void modifica_stringa(int*,int);
00422
00423 private slots:
00424 void addCustom();
00425 void newHsv( int h, int s, int v );
00426 void newColorTypedIn( QRgb rgb );
00427 void newCustom( int, int );
00428 void newStandard( int, int );
00429 void modifica_bottoni(int,int);
00430 };
00431
00432 #endif