karbon

vpatterntool.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2001, 2002, 2003 The Karbon Developers
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef __VPATTERNTOOL_H__
00021 #define __VPATTERNTOOL_H__
00022 
00023 #include <kdialogbase.h>
00024 
00025 #include "vtool.h"
00026 #include "vpattern.h"
00027 #include "KoRect.h"
00028 
00029 class QHButtonGroup;
00030 class QToolButton;
00031 class KoIconChooser;
00032 
00033 class VPatternWidget : public KDialogBase
00034 {
00035 Q_OBJECT
00036 
00037 public:
00038     VPatternWidget( QPtrList<KoIconItem>* patterns, VTool* tool, QWidget* parent = 0L );
00039     ~VPatternWidget();
00040 
00041     VPattern* selectedPattern();
00042 
00043 public slots:
00044     void importPattern();
00045     void deletePattern();
00046 
00047     void slotButtonClicked( int id );
00048     void patternSelected( KoIconItem* );
00049 
00050 private:
00051     KoIconChooser*        m_patternChooser;
00052     QHButtonGroup*        m_buttonGroup;
00053     QToolButton*          m_importPatternButton;
00054     QToolButton*          m_deletePatternButton;
00055     VTool*                m_tool;
00056     VPattern*             m_pattern;
00057 }; // VPatternWidget
00058 
00059 
00060 class VPatternTool : public VTool
00061 {
00062     Q_OBJECT
00063 
00064 public:
00065     VPatternTool( KarbonView *view );
00066     virtual ~VPatternTool();
00067 
00068     virtual void activate();
00069     virtual void deactivate();
00070 
00071     virtual void setup(KActionCollection *collection);
00072     virtual QString uiname() { return i18n( "Pattern Tool" ); }
00073     virtual QString contextHelp();
00074     virtual bool showDialog() const;
00075 
00076     virtual void draw( VPainter* painter );
00077 
00078 protected:
00079     virtual void draw();
00080 
00081     virtual void mouseButtonRelease();
00082     virtual void mouseButtonPress();
00083     virtual void mouseDragRelease();
00084     virtual void mouseDrag();
00085     /*virtual void mouseDragShiftPressed(); // To use to scale the pattern.
00086     virtual void mouseDragShiftReleased(); */
00087     virtual void cancel();
00088     virtual void setCursor() const;
00089     virtual bool keyReleased( Qt::Key key );
00090 
00097     bool getPattern( VPattern &pattern );
00098 
00099 protected slots:
00100     void targetChanged();
00101 
00102 private:
00103     enum { normal, moveOrigin, moveVector, createNew } m_state;
00104 
00105     VPattern             m_pattern;
00106     KoPoint              m_current;  
00107     KoPoint              m_fixed;    
00108     VPatternWidget* m_optionsWidget; 
00109     KoRect               m_origin;   
00110     KoRect               m_vector;   
00111     int                  m_handleSize; 
00112     bool                 m_active;   
00113 }; // VPatternTool
00114 
00115 #endif /* __VPATTERNTOOL_H__ */
00116 
KDE Home | KDE Accessibility Home | Description of Access Keys