Eneboo - Documentación para desarrolladores
src/qt/tools/designer/designer/styledbutton.h
Ir a la documentación de este archivo.
00001 /**********************************************************************
00002 ** Copyright (C) 2005-2007 Trolltech ASA.  All rights reserved.
00003 **
00004 ** This file is part of Qt Designer.
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 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
00012 ** licenses may use this file in accordance with the Qt Commercial License
00013 ** Agreement provided with the Software.
00014 **
00015 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00016 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00017 **
00018 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00019 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
00020 **   information about Qt Commercial License Agreements.
00021 **
00022 ** Contact info@trolltech.com if any conditions of this licensing are
00023 ** not clear to you.
00024 **
00025 **********************************************************************/
00026 
00027 #ifndef STYLEDBUTTON_H
00028 #define STYLEDBUTTON_H
00029 
00030 #include <qbutton.h>
00031 #include <qpixmap.h>
00032 
00033 class QColor;
00034 class QBrush;
00035 class FormWindow;
00036 
00037 class StyledButton : public QButton
00038 {
00039     Q_OBJECT
00040 
00041     Q_PROPERTY( QColor color READ color WRITE setColor )
00042     Q_PROPERTY( QPixmap pixmap READ pixmap WRITE setPixmap )
00043     Q_PROPERTY( EditorType editor READ editor WRITE setEditor )
00044     Q_PROPERTY( bool scale READ scale WRITE setScale )
00045 
00046     Q_ENUMS( EditorType )
00047 
00048 public:
00049     enum EditorType { ColorEditor, PixmapEditor };
00050 
00051     StyledButton( QWidget* parent = 0, const char* name = 0 );
00052     StyledButton( const QBrush& b, QWidget* parent = 0, const char* name = 0, WFlags f = 0 );
00053     ~StyledButton();
00054 
00055     void setEditor( EditorType );
00056     EditorType editor() const;
00057 
00058     void setColor( const QColor& );
00059     void setPixmap( const QPixmap& );
00060 
00061     QPixmap* pixmap() const;
00062     QColor color() const;
00063 
00064     void setScale( bool );
00065     bool scale() const;
00066 
00067     QSize sizeHint() const;
00068     QSize minimumSizeHint() const;
00069 
00070     void setFormWindow( FormWindow *fw ) { formWindow = fw; }
00071 
00072 public slots:
00073     virtual void onEditor();
00074 
00075 signals:
00076     void changed();
00077 
00078 protected:
00079     void mousePressEvent(QMouseEvent*);
00080     void mouseMoveEvent(QMouseEvent*);
00081 #ifndef QT_NO_DRAGANDDROP
00082     void dragEnterEvent ( QDragEnterEvent * );
00083     void dragMoveEvent ( QDragMoveEvent * );
00084     void dragLeaveEvent ( QDragLeaveEvent * );
00085     void dropEvent ( QDropEvent * );
00086 #endif // QT_NO_DRAGANDDROP
00087     void drawButton( QPainter* );
00088     void drawButtonLabel( QPainter* );
00089     void resizeEvent( QResizeEvent* );
00090     void scalePixmap();
00091 
00092 private:
00093     QPixmap* pix;
00094     QPixmap* spix;  // the pixmap scaled down to fit into the button
00095     QColor col;
00096     EditorType edit;
00097     bool s;
00098     FormWindow *formWindow;
00099     QPoint pressPos;
00100     bool mousePressed;
00101 };
00102 
00103 #endif //STYLEDBUTTON_H
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'