karbon

vgradienttabwidget.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2001, The Karbon Developers
00003    Copyright (C) 2002, The Karbon Developers
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef _VGRADIENTTABWIDGET_H_
00022 #define _VGRADIENTTABWIDGET_H_
00023 
00024 #include <qwidget.h>
00025 #include <qtabwidget.h>
00026 #include <qlistbox.h>
00027 #include <koffice_export.h>
00028 #include "vgradient.h"
00029 
00030 class KComboBox;
00031 class VGradientWidget;
00032 class KListBox;
00033 class KIntNumInput;
00034 class QPushButton;
00035 class QGroupBox;
00036 class KarbonResourceServer;
00037 
00038 
00039 class VGradientListItem : public QListBoxItem
00040 {
00041 public:
00042     VGradientListItem( const VGradient& gradient, QString filename );
00043     VGradientListItem( const VGradientListItem& );
00044     ~VGradientListItem();
00045 
00046     QPixmap& pixmap() { return m_pixmap; }
00047     const VGradient* gradient() const { return m_gradient; }
00048     QString filename() { return m_filename; }
00049     bool canDelete() { return m_delete; }
00050 
00051     virtual int height( const QListBox* ) const { return 16; }
00052     virtual int width( const QListBox* lb ) const;
00053 
00054 protected:
00055     virtual void paint( QPainter* p );
00056 
00057 private:
00058     VGradient   *m_gradient;
00059     QPixmap     m_pixmap;
00060     QString     m_filename;
00061     bool        m_delete;
00062 }; // VGradientListItem
00063 
00064 class VGradientPreview : public QWidget
00065 {
00066     public:
00067         VGradientPreview( VGradient& gradient, double& opacity, QWidget* parent = 0L, const char* name = 0L );
00068         ~VGradientPreview();
00069 
00070         virtual void paintEvent( QPaintEvent* );
00071         
00072     protected:
00073         VGradient*     m_gradient;
00074         double*         m_opacity;
00075 }; // VGradientPreview
00076 
00077 class KARBONBASE_EXPORT VGradientTabWidget : public QTabWidget
00078 {
00079     Q_OBJECT
00080 
00081     public:
00082         enum VGradientTarget {
00083             STROKE,
00084             FILL
00085         };
00086     
00087         VGradientTabWidget( VGradient& gradient, KarbonResourceServer* server, QWidget* parent = 0L, const char* name = 0L );
00088         ~VGradientTabWidget();
00089 
00090         const VGradient& gradient();
00091         void setGradient( VGradient& gradient );
00092 
00093         VGradientTarget target();
00094         void setTarget( VGradientTarget target );
00095 
00096         double opacity() const;
00097         void setOpacity( double opacity );
00098 
00099     public slots:
00100         void combosChange( int );
00101         void addGradientToPredefs();
00102         void changeToPredef( QListBoxItem* );
00103         void predefSelected( QListBoxItem* );
00104         void deletePredef();
00105         void opacityChanged( int );
00106 
00107     protected:
00108         void setupUI();
00109         void initUI();
00110         void setupConnections();
00111         
00112     private:
00113         QGroupBox               *m_editGroup;
00114         VGradientWidget         *m_gradientWidget;
00115         KComboBox               *m_gradientTarget;
00116         KComboBox               *m_gradientRepeat;
00117         KComboBox               *m_gradientType;
00118         VGradientPreview        *m_gradientPreview;
00119         KListBox                *m_predefGradientsView;
00120         QPushButton             *m_predefDelete;
00121         QPushButton             *m_predefImport;
00122         QPushButton             *m_addToPredefs;
00123         KIntNumInput            *m_opacity;
00124 
00125         VGradient             m_gradient;
00127         KarbonResourceServer* m_resourceServer;
00128         double                m_gradOpacity;
00129 }; // VGradientTabWidget
00130 
00131 #endif /* _VGRADIENTTABWIDGET_H_ */
KDE Home | KDE Accessibility Home | Description of Access Keys