krita

kis_selection_manager.h

00001 /*
00002  *  Copyright (c) 2004 Boudewijn Rempt <boud@valdyas.org>
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program 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
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  */
00018 #ifndef KIS_SELECTION_MANAGER_
00019 #define KIS_SELECTION_MANAGER_
00020 
00021 #include "qobject.h"
00022 #include "qptrlist.h"
00023 
00024 #include "kis_image.h"
00025 #include <koffice_export.h>
00026 
00027 class KAction;
00028 class KisView;
00029 class KisDoc;
00030 class KisClipboard;
00031 
00036 class KRITACORE_EXPORT KisSelectionManager : public QObject {
00037 
00038     Q_OBJECT
00039 
00040 public:
00041 
00042     KisSelectionManager(KisView * parent, KisDoc * doc);
00043     virtual ~KisSelectionManager();
00044 
00045     void setup(KActionCollection * collection);
00046 
00047     void addSelectionAction(KAction * action);
00048 
00049 public:
00053     bool displaySelection();
00054     
00055 public slots:
00056 
00057     void updateGUI();
00058     void imgSelectionChanged(KisImageSP img);
00059     void clipboardDataChanged();
00060 
00061     void cut();
00062     void copy();
00063     KisLayerSP paste();
00064     void pasteNew();
00065     void cutToNewLayer();
00066     void selectAll();
00067     void deselect();
00068     void clear();
00069     void fillForegroundColor();
00070     void fillBackgroundColor();
00071     void fillPattern();
00072     void reselect();
00073     void invert();
00074     void copySelectionToNewLayer();
00075     void feather();
00076     void border();
00077     void expand();
00078     void contract();
00079     void smooth();
00080     void similar();
00081     void transform();
00082     void load();
00083     void save();
00084     void toggleDisplaySelection();
00085 
00086 public:
00087     void grow (Q_INT32 xradius, Q_INT32 yradius);
00088     void shrink (Q_INT32 xradius, Q_INT32 yradius, bool edge_lock);
00089     void border(Q_INT32 xradius, Q_INT32 yradius);
00090     // the following functions are needed for the siox tool
00091     // they might be also usefull on its own
00092     void erode();
00093     void dilate();
00094 
00095 private:
00096     void fill(const KisColor& color, bool fillWithPattern, const QString& transactionText);
00097     
00098     void computeBorder (Q_INT32  *circ, Q_INT32  xradius, Q_INT32  yradius);
00099     inline void rotatePointers (Q_UINT8  **p, Q_UINT32 n);
00100     void computeTransition (Q_UINT8* transition, Q_UINT8** buf, Q_INT32 width);
00101 
00102     KisView * m_parent;
00103     KisDoc * m_doc;
00104 
00105     KisClipboard * m_clipboard;
00106 
00107     KAction *m_copy;
00108     KAction *m_cut;
00109     KAction *m_paste;
00110     KAction *m_pasteNew;
00111     KAction *m_cutToNewLayer;
00112     KAction *m_selectAll;
00113     KAction *m_deselect;
00114     KAction *m_clear;
00115     KAction *m_reselect;
00116     KAction *m_invert;
00117     KAction *m_toNewLayer;
00118     KAction *m_feather;
00119     KAction *m_border;
00120     KAction *m_expand;
00121     KAction *m_smooth;
00122     KAction *m_contract;
00123     KAction *m_similar;
00124     KAction *m_transform;
00125     KAction *m_load;
00126     KAction *m_save;
00127     KAction *m_fillForegroundColor;
00128     KAction *m_fillBackgroundColor;
00129     KAction *m_fillPattern;
00130     KToggleAction *m_toggleDisplaySelection;
00131 
00132     QPtrList<KAction> m_pluginActions;
00133 
00134 };
00135 
00136 #endif // KIS_SELECTION_MANAGER_
KDE Home | KDE Accessibility Home | Description of Access Keys