diff --git a/commands/imagelib/effects/kpEffectCommandBase.h b/commands/imagelib/effects/kpEffectCommandBase.h index e9471da6..887e8335 100644 --- a/commands/imagelib/effects/kpEffectCommandBase.h +++ b/commands/imagelib/effects/kpEffectCommandBase.h @@ -1,67 +1,67 @@ /* Copyright (c) 2003-2007 Clarence Dang All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef kpEffectCommandBase_H #define kpEffectCommandBase_H -#include +#include #include "commands/kpCommand.h" #include "imagelib/kpImage.h" class kpEffectCommandBase : public kpCommand { public: kpEffectCommandBase (const QString &name, bool actOnSelection, kpCommandEnvironment *environ); ~kpEffectCommandBase () override; QString name () const override; SizeType size () const override; public: void execute () override; void unexecute () override; public: // Return true if applyEffect(applyEffect(image)) == image // to avoid storing the old image, saving memory. virtual bool isInvertible () const { return false; } protected: virtual kpImage applyEffect (const kpImage &image) = 0; private: struct kpEffectCommandBasePrivate *d; }; #endif // kpEffectCommandBase_H diff --git a/commands/imagelib/effects/kpEffectFlattenCommand.h b/commands/imagelib/effects/kpEffectFlattenCommand.h index 3fbfc7a8..2a66fdb2 100644 --- a/commands/imagelib/effects/kpEffectFlattenCommand.h +++ b/commands/imagelib/effects/kpEffectFlattenCommand.h @@ -1,59 +1,59 @@ /* Copyright (c) 2003-2007 Clarence Dang All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef kpEffectFlattenCommand_H #define kpEffectFlattenCommand_H -#include +#include #include "kpEffectCommandBase.h" #include "imagelib/kpImage.h" class kpEffectFlattenCommand : public kpEffectCommandBase { public: kpEffectFlattenCommand (const QColor &color1, const QColor &color2, bool actOnSelection, kpCommandEnvironment *environ); ~kpEffectFlattenCommand () override; // // kpEffectCommandBase interface // protected: kpImage applyEffect (const kpImage &image) override; QColor m_color1, m_color2; }; #endif // kpEffectFlattenCommand_H diff --git a/commands/imagelib/transforms/kpTransformResizeScaleCommand.h b/commands/imagelib/transforms/kpTransformResizeScaleCommand.h index 66aea121..23a63944 100644 --- a/commands/imagelib/transforms/kpTransformResizeScaleCommand.h +++ b/commands/imagelib/transforms/kpTransformResizeScaleCommand.h @@ -1,100 +1,100 @@ /* Copyright (c) 2003-2007 Clarence Dang All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef kpTransformResizeScaleCommand_H #define kpTransformResizeScaleCommand_H -#include +#include #include "imagelib/kpColor.h" #include "commands/kpCommand.h" #include "imagelib/kpImage.h" class QSize; class kpAbstractSelection; // REFACTOR: Split into multiple classes, each doing a different thing // e.g. resize, scale and smooth scale. // REFACTOR: Replace kpToolSelectionResizeScaleCommand with us. class kpTransformResizeScaleCommand : public kpCommand { public: enum Type { Resize, Scale, SmoothScale }; kpTransformResizeScaleCommand (bool actOnSelection, int newWidth, int newHeight, Type type, kpCommandEnvironment *environ); ~kpTransformResizeScaleCommand () override; QString name () const override; SizeType size () const override; public: int newWidth () const; void setNewWidth (int width); int newHeight () const; void setNewHeight (int height); QSize newSize () const; virtual void resize (int width, int height); public: bool scaleSelectionWithImage () const; private: void scaleSelectionRegionWithDocument (); public: void execute () override; void unexecute () override; protected: bool m_actOnSelection; int m_newWidth, m_newHeight; Type m_type; bool m_isLosslessScale; bool m_scaleSelectionWithImage; kpColor m_backgroundColor; int m_oldWidth, m_oldHeight; bool m_actOnTextSelection; kpImage m_oldImage, m_oldRightImage, m_oldBottomImage; kpAbstractSelection *m_oldSelectionPtr; }; #endif // kpTransformResizeScaleCommand_H diff --git a/commands/kpCommandHistoryBase.h b/commands/kpCommandHistoryBase.h index 891c9f5b..f6e5b2db 100644 --- a/commands/kpCommandHistoryBase.h +++ b/commands/kpCommandHistoryBase.h @@ -1,155 +1,156 @@ /* Copyright (c) 2003-2007 Clarence Dang All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef kpCommandHistoryBase_H #define kpCommandHistoryBase_H -#include -#include -#include +#include +#include +#include + #include "commands/kpCommandSize.h" class QAction; class KActionCollection; class KToolBarPopupAction; class kpAbstractImageSelection; class kpAbstractSelection; class kpCommand; class kpCommandEnvironment; class kpDocument; class kpMainWindow; class kpTextSelection; class kpViewManager; // Clone of KCommandHistory with features required by KolourPaint but which // could also be useful for other apps: // - nextUndoCommand()/nextRedoCommand() // - undo/redo history limited by both number and size // // Features not required by KolourPaint (e.g. commandExecuted()) are not // implemented and undo limit == redo limit. So compared to // KCommandHistory, this is only "almost source compatible". class kpCommandHistoryBase : public QObject { Q_OBJECT public: kpCommandHistoryBase (bool doReadConfig, KActionCollection *ac); ~kpCommandHistoryBase () override; public: // (provided for compatibility with KCommandHistory) int undoLimit () const; void setUndoLimit (int limit); int undoMinLimit () const; void setUndoMinLimit (int limit); int undoMaxLimit () const; void setUndoMaxLimit (int limit); kpCommandSize::SizeType undoMaxLimitSizeLimit () const; void setUndoMaxLimitSizeLimit (kpCommandSize::SizeType sizeLimit); public: // Read and write above config void readConfig (); void writeConfig (); public: void addCommand (kpCommand *command, bool execute = true); void clear (); protected slots: // (same as undo() & redo() except they don't call // trimCommandListsUpdateActions()) void undoInternal (); void redoInternal (); public slots: virtual void undo (); virtual void redo (); virtual void undoUpToNumber (QAction *which); virtual void redoUpToNumber (QAction *which); protected: QString undoActionText () const; QString redoActionText () const; QString undoActionToolTip () const; QString redoActionToolTip () const; void trimCommandListsUpdateActions (); void trimCommandList (QLinkedList *commandList); void trimCommandLists (); void updateActions (); public: kpCommand *nextUndoCommand () const; kpCommand *nextRedoCommand () const; void setNextUndoCommand (kpCommand *command); public slots: virtual void documentSaved (); signals: void documentRestored (); protected: KToolBarPopupAction *m_actionUndo, *m_actionRedo; // (Front element is the next one) QLinkedList m_undoCommandList; QLinkedList m_redoCommandList; int m_undoMinLimit, m_undoMaxLimit; kpCommandSize::SizeType m_undoMaxLimitSizeLimit; // What you have to do to get back to the document's unmodified state: // * -x: must Undo x times // * 0: unmodified // * +x: must Redo x times // * INT_MAX: can never become unmodified again // // ASSUMPTION: will never have INT_MAX commands in any list. int m_documentRestoredPosition; private: struct kpCommandHistoryBasePrivate * const d; }; #endif // kpCommandHistoryBase_H diff --git a/dialogs/imagelib/transforms/kpTransformPreviewDialog.h b/dialogs/imagelib/transforms/kpTransformPreviewDialog.h index 75194ce8..f0aa00f3 100644 --- a/dialogs/imagelib/transforms/kpTransformPreviewDialog.h +++ b/dialogs/imagelib/transforms/kpTransformPreviewDialog.h @@ -1,146 +1,146 @@ /* Copyright (c) 2003-2007 Clarence Dang All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef kpTransformPreviewDialog_H #define kpTransformPreviewDialog_H #include -#include +#include class QLabel; class QGridLayout; class QGroupBox; class kpColor; class kpDocument; class kpResizeSignallingLabel; class kpTransformDialogEnvironment; class kpTransformPreviewDialog : public QDialog { Q_OBJECT public: enum Features { Dimensions = 1, Preview = 2, AllFeatures = Dimensions | Preview }; // You must call slotUpdate() in your constructor kpTransformPreviewDialog (Features features, bool reserveTopRow, // e.g. "Skew (Image|Selection)" const QString &caption, // (in the Dimensions Group Box) e.g. "After Skew:" const QString &afterActionText, bool actOnSelection, kpTransformDialogEnvironment *_env, QWidget *parent); ~kpTransformPreviewDialog () override; private: void createDimensionsGroupBox (); void createPreviewGroupBox (); public: virtual bool isNoOp () const = 0; protected: kpDocument *document () const; QWidget *mainWidget () const; // All widgets must have mainWidget() as their parent void addCustomWidgetToFront (QWidget *w); // see in ctor void addCustomWidget (QWidget *w); void addCustomWidgetToBack (QWidget *w) { addCustomWidget (w); } virtual QSize newDimensions () const = 0; virtual QImage transformPixmap (const QImage &pixmap, int targetWidth, int targetHeight) const = 0; public: // Use to avoid excessive, expensive preview pixmap label recalcuations, // during init and widget relayouts. // // Setting to true automatically calls slotUpdateWithWaitCursor(). // // WARNING: This overrides a non-virtual method in QWidget. void setUpdatesEnabled (bool enable); private: void updateDimensions (); public: static double aspectScale (int newWidth, int newHeight, int oldWidth, int oldHeight); static int scaleDimension (int dimension, double scale, int min, int max); private: void updateShrunkenDocumentPixmap (); protected slots: void updatePreview (); // Call this whenever a value (e.g. an angle) changes // and the Dimensions & Preview need to be updated virtual void slotUpdate (); virtual void slotUpdateWithWaitCursor (); protected: // REFACTOR: Use d-ptr QString m_afterActionText; bool m_actOnSelection; int m_oldWidth, m_oldHeight; QWidget *m_mainWidget; QGroupBox *m_dimensionsGroupBox; QLabel *m_afterTransformDimensionsLabel; QGroupBox *m_previewGroupBox; kpResizeSignallingLabel *m_previewPixmapLabel; QSize m_previewPixmapLabelSizeWhenUpdatedPixmap; QImage m_shrunkenDocumentPixmap; QGridLayout *m_gridLayout; int m_gridNumRows; kpTransformDialogEnvironment *m_environ; }; #endif // kpTransformPreviewDialog_H diff --git a/dialogs/imagelib/transforms/kpTransformRotateDialog.h b/dialogs/imagelib/transforms/kpTransformRotateDialog.h index 12939f4c..8e2cf3d6 100644 --- a/dialogs/imagelib/transforms/kpTransformRotateDialog.h +++ b/dialogs/imagelib/transforms/kpTransformRotateDialog.h @@ -1,92 +1,92 @@ /* Copyright (c) 2003-2007 Clarence Dang All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef kpTransformRotateDialog_H #define kpTransformRotateDialog_H #include -#include +#include #include "imagelib/kpColor.h" #include "dialogs/imagelib/transforms/kpTransformPreviewDialog.h" class QButtonGroup; class QRadioButton; class QSpinBox; class kpTransformRotateDialog : public kpTransformPreviewDialog { Q_OBJECT public: kpTransformRotateDialog (bool actOnSelection, kpTransformDialogEnvironment *_env, QWidget *parent); ~kpTransformRotateDialog () override; private: static int s_lastWidth, s_lastHeight; static bool s_lastIsClockwise; static int s_lastAngleCustom; void createDirectionGroupBox (); void createAngleGroupBox (); public: bool isNoOp () const override; int angle () const; // 0 <= angle < 360 (clockwise); private: QSize newDimensions () const override; QImage transformPixmap (const QImage &pixmap, int targetWidth, int targetHeight) const override; private slots: void slotAngleCustomRadioButtonToggled (bool isChecked); void slotUpdate () override; private slots: void accept () override; private: QRadioButton *m_antiClockwiseRadioButton, *m_clockwiseRadioButton; QButtonGroup *m_angleButtonGroup; QRadioButton *m_angle90RadioButton, *m_angle180RadioButton, *m_angle270RadioButton, *m_angleCustomRadioButton; QSpinBox *m_angleCustomInput; }; #endif // kpTransformRotateDialog_H diff --git a/dialogs/kpDocumentSaveOptionsPreviewDialog.h b/dialogs/kpDocumentSaveOptionsPreviewDialog.h index 3bd967ff..0f35327f 100644 --- a/dialogs/kpDocumentSaveOptionsPreviewDialog.h +++ b/dialogs/kpDocumentSaveOptionsPreviewDialog.h @@ -1,82 +1,82 @@ /* Copyright (c) 2003-2007 Clarence Dang All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef kpDocumentSaveOptionsPreviewDialog_H #define kpDocumentSaveOptionsPreviewDialog_H #include "generic/widgets/kpSubWindow.h" -#include +#include class QCloseEvent; class QImage; class QLabel; class QMoveEvent; class QResizeEvent; class kpResizeSignallingLabel; class kpDocumentSaveOptionsPreviewDialog : public kpSubWindow { Q_OBJECT public: kpDocumentSaveOptionsPreviewDialog (QWidget *parent); ~kpDocumentSaveOptionsPreviewDialog () override; QSize preferredMinimumSize () const; protected: static const QSize s_pixmapLabelMinimumSize; signals: void moved (); void resized (); void finished (); public slots: void setFilePixmapAndSize (const QImage &filePixmap, qint64 fileSize); void updatePixmapPreview (); protected: void closeEvent (QCloseEvent *e) override; void moveEvent (QMoveEvent *e) override; void resizeEvent (QResizeEvent *e) override; protected: QImage *m_filePixmap; qint64 m_fileSize; kpResizeSignallingLabel *m_filePixmapLabel; QLabel *m_fileSizeLabel; }; #endif // kpDocumentSaveOptionsPreviewDialog_H diff --git a/document/kpDocument.h b/document/kpDocument.h index c572bc27..5c1b946c 100644 --- a/document/kpDocument.h +++ b/document/kpDocument.h @@ -1,360 +1,360 @@ /* Copyright (c) 2003-2007 Clarence Dang All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef KP_DOCUMENT_H #define KP_DOCUMENT_H -#include -#include -#include -#include +#include +#include +#include +#include #include "imagelib/kpImage.h" #include "pixmapfx/kpPixmapFX.h" #undef environ class QImage; class QIODevice; class QPixmap; class QPoint; class QRect; class QSize; class kpColor; class kpDocumentEnvironment; class kpDocumentSaveOptions; class kpDocumentMetaInfo; class kpAbstractImageSelection; class kpAbstractSelection; class kpTextSelection; // REFACTOR: rearrange method order to make sense and reflect kpDocument_*.cpp split. class kpDocument : public QObject { Q_OBJECT public: // REFACTOR: Hide constructor and have 2 factory methods: // // Method 1. Creates a blank document with dimensions x. // // Method 2. Calls open(). and (aka constructorWidth() // and constructorHeight()) need not be specified. // // ? kpDocument (int w, int h, kpDocumentEnvironment *environ); ~kpDocument () override; kpDocumentEnvironment *environ () const; void setEnviron (kpDocumentEnvironment *environ); // // File I/O - Open // static QImage getPixmapFromFile (const QUrl &url, bool suppressDoesntExistDialog, QWidget *parent, kpDocumentSaveOptions *saveOptions = nullptr, kpDocumentMetaInfo *metaInfo = nullptr); // REFACTOR: fix: open*() should only be called once. // Create a new kpDocument() if you want to open again. void openNew (const QUrl &url); bool open (const QUrl &url, bool newDocSameNameIfNotExist = false); static void getDataFromImage(const QImage &image, kpDocumentSaveOptions &saveOptions, kpDocumentMetaInfo &metaInfo); // // File I/O - Save // static bool lossyPromptContinue (const QImage &pixmap, const kpDocumentSaveOptions &saveOptions, QWidget *parent); static bool savePixmapToDevice (const QImage &pixmap, QIODevice *device, const kpDocumentSaveOptions &saveOptions, const kpDocumentMetaInfo &metaInfo, bool lossyPrompt, QWidget *parent, bool *userCancelled = nullptr); static bool savePixmapToFile (const QImage &pixmap, const QUrl &url, const kpDocumentSaveOptions &saveOptions, const kpDocumentMetaInfo &metaInfo, bool overwritePrompt, bool lossyPrompt, QWidget *parent); bool save (bool overwritePrompt = false, bool lossyPrompt = false); bool saveAs (const QUrl &url, const kpDocumentSaveOptions &saveOptions, bool overwritePrompt = true, bool lossyPrompt = true); // Returns whether save() or saveAs() have ever been called and returned true bool savedAtLeastOnceBefore () const; QUrl url () const; void setURL (const QUrl &url, bool isFromURL); // Returns whether the document's image was successfully opened from // or saved to the URL returned by url(). This is not true for a // new kpDocument and in the case of open() being passed // "newDocSameNameIfNotExist = true" when the URL doesn't exist. // // If this returns true and the kpDocument hasn't been modified, // this gives a pretty good indication that the image stored at url() // is equal to image() (unless the something has happened to that url // outside of KolourPaint). // // e.g. If the user types "kolourpaint doesnotexist.png" to start // KolourPaint, this method will return false. bool isFromURL (bool checkURLStillExists = true) const; // (will convert: empty Url --> "Untitled") QString prettyUrl () const; // (will convert: empty Url --> "Untitled") QString prettyFilename () const; // (guaranteed to return valid pointer) const kpDocumentSaveOptions *saveOptions () const; void setSaveOptions (const kpDocumentSaveOptions &saveOptions); const kpDocumentMetaInfo *metaInfo () const; void setMetaInfo (const kpDocumentMetaInfo &metaInfo); /* * Properties (modified, width, height, color depth...) */ void setModified (bool yes = true); bool isModified () const; bool isEmpty () const; // REFACTOR: Rename to originalWidth()? int constructorWidth () const; // as passed to the constructor int width (bool ofSelection = false) const; int oldWidth () const; // only valid in a slot connected to sizeChanged() void setWidth (int w, const kpColor &backgroundColor); // REFACTOR: Rename to originalHeight()? int constructorHeight () const; // as passed to the constructor int height (bool ofSelection = false) const; int oldHeight () const; // only valid in a slot connected to sizeChanged() void setHeight (int h, const kpColor &backgroundColor); QRect rect (bool ofSelection = false) const; // // Image access // // Returns a copy of part of the document's image (not including the // selection). kpImage getImageAt (const QRect &rect) const; void setImageAt (const kpImage &image, const QPoint &at); // "image(false)" returns a copy of the document's image, ignoring any // floating selection. // // "image(true)" returns a copy of a floating image selection's base // image (i.e. before selection transparency is applied), which may be // null if the image selection is a just a border. // // ASSUMPTION: For == true only, an image selection exists. kpImage image (bool ofSelection = false) const; kpImage *imagePointer () const; void setImage (const kpImage &image); // ASSUMPTION: If setting the selection's image, the selection must be // an image selection. void setImage (bool ofSelection, const kpImage &image); // // Selections // public: kpAbstractSelection *selection () const; kpAbstractImageSelection *imageSelection () const; kpTextSelection *textSelection () const; // Sets the document's selection to the given one and changes to the // matching selection tool. Tool changes occur in the following situations: // // 1. Setting a when a selection tool is not active. // // 2. Setting an image when the text tool is active. // ASSUMPTION: There is no text selection active when calling this // method (push it onto the document before calling this, // to avoid this problem). // // 3. Setting a text when an image selection tool is active. // ASSUMPTION: There is no image selection active when calling this // method (push it onto the document before calling this, // to avoid this problem). // // The justification for the above assumptions are to reduce the complexity // of this method's implementation -- changing from an image selection tool // to a text selection tool, or vice-versa, calls the end() method of the // current tool, which pushes any active selection onto the document. Since // this method sets the selection, losing the old selection in the middle of // the method would be tricky to work around. // // WARNING: Before calling this, you must ensure that the UI (kpMainWindow) // has the 's selection transparency or // for a text selection, its text style, selected. // TODO: Why can't we change it for them, if we change tool automatically for them already? void setSelection (const kpAbstractSelection &selection); // Returns the base image of the current image selection. If this is // null (because the selection is still a border), it extracts the // pixels of the document marked out by the border of the selection. // // ASSUMPTION: There is an imageSelection(). // // TODO: this always returns base image - need ver that applies selection // transparency. kpImage getSelectedBaseImage () const; // Sets the base image of the current image selection to the pixels // of the document marked out by the border of the selection. // // ASSUMPTION: There is an imageSelection() that is just a border // (no base image). void imageSelectionPullFromDocument (const kpColor &backgroundColor); // Deletes the current selection, if there is a selection(), else NOP void selectionDelete (); // Stamps a copy of the selection onto the document. // // For image selections, set to true, means that // the transparent image of the selection is used. If set to false, // the base image of the selection is used. This argument is ignored // for non-image selections. // // ASSUMPTION: There is a selection() with content, else NOP void selectionCopyOntoDocument (bool applySelTransparency = true); // Same as selectionCopyOntoDocument() but deletes the selection // afterwards. void selectionPushOntoDocument (bool applySelTransparency = true); // // Same as image() but returns a _copy_ of the document image // + any (even non-image) selection pasted on top. // // Even if the selection has no content, it is still pasted: // // 1. For an image selection, this makes no difference. // // 2. For a text selection: // // a) with an opaque background: the background rectangle is // included -- this is necessary since the rectangle is visually // there after all, and the intention of this method is to report // everything. // // b) with a transparent background: this makes no difference. // kpImage imageWithSelection () const; /* * Transformations * (convenience only - you could achieve the same effect (and more) with * kpPixmapFX: these functions do not affect the selection) */ void fill (const kpColor &color); void resize (int w, int h, const kpColor &backgroundColor); public slots: // these will emit signals! void slotContentsChanged (const QRect &rect); void slotSizeChanged (const QSize &newSize); signals: void documentOpened (); void documentSaved (); // Emitted whenever the isModified() flag changes from false to true. // This is the _only_ signal that may be emitted in addition to the others. void documentModified (); void contentsChanged (const QRect &rect); void sizeChanged (int newWidth, int newHeight); // see oldWidth(), oldHeight() void sizeChanged (const QSize &newSize); void selectionEnabled (bool on); // Emitted when setSelection() is given a selection such that we change // from a non-text-selection tool to the text selection tool or vice-versa. // reports whether the new selection is text (and therefore, // whether we've switched to the text tool). void selectionIsTextChanged (bool isText); private: int m_constructorWidth, m_constructorHeight; kpImage *m_image; QUrl m_url; bool m_isFromURL; bool m_savedAtLeastOnceBefore; kpDocumentSaveOptions *m_saveOptions; kpDocumentMetaInfo *m_metaInfo; bool m_modified; kpAbstractSelection *m_selection; int m_oldWidth, m_oldHeight; // There is no need to maintain binary compatibility at this stage. // The d-pointer is just so that you can experiment without recompiling // the kitchen sink. struct kpDocumentPrivate *d; }; #endif // KP_DOCUMENT_H diff --git a/generic/widgets/kpResizeSignallingLabel.h b/generic/widgets/kpResizeSignallingLabel.h index d06d944c..a8eb9a3c 100644 --- a/generic/widgets/kpResizeSignallingLabel.h +++ b/generic/widgets/kpResizeSignallingLabel.h @@ -1,56 +1,56 @@ /* Copyright (c) 2003-2007 Clarence Dang All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef KP_RESIZE_SIGNALLING_LABEL_H #define KP_RESIZE_SIGNALLING_LABEL_H -#include +#include class QResizeEvent; class kpResizeSignallingLabel : public QLabel { Q_OBJECT public: kpResizeSignallingLabel (const QString &string, QWidget *parent); kpResizeSignallingLabel (QWidget *parent); ~kpResizeSignallingLabel () override; signals: void resized (); protected: void resizeEvent (QResizeEvent *e) override; }; #endif // KP_RESIZE_SIGNALLING_LABEL_H diff --git a/imagelib/kpColor.h b/imagelib/kpColor.h index 30dc04d8..2a100a6a 100644 --- a/imagelib/kpColor.h +++ b/imagelib/kpColor.h @@ -1,156 +1,156 @@ /* Copyright (c) 2003-2007 Clarence Dang All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef KP_COLOR_H #define KP_COLOR_H -#include +#include class QDataStream; // // kpColor is an object-oriented abstraction of QRgb, for document image data. // In the future, other color models such as // 8-bit indexed will be supported. It also provides better error handling, // reporting (noisy qCCritical(kpLogImagelib)'s) and recovery compared to Qt. This abstraction // will allow us to eventually dump the Qt paint routines. // // In general, you should pass around kpColor objects instead of QRgb // and QColor. Only convert an opaque kpColor to a QColor (using toQColor()) // if you need to draw something on-screen. // // Constructing a kpColor object from QColor is usually wrong since QColor's // come from on-screen pixels, which may lack the full color resolution of // kpColor, due to the limited color range on e.g. a 16-bit screen. // class kpColor { public: kpColor (); kpColor (int red, int green, int blue, bool isTransparent = false); kpColor (const QRgb &rgba); kpColor (const kpColor &rhs); friend QDataStream &operator<< (QDataStream &stream, const kpColor &color); friend QDataStream &operator>> (QDataStream &stream, kpColor &color); kpColor &operator= (const kpColor &rhs); bool operator== (const kpColor &rhs) const; bool operator!= (const kpColor &rhs) const; // // Constants // public: // "lhs.isSimilarTo (rhs, kpColor::Exact)" is exactly the same as calling // "lhs == rhs". static const int Exact; static const kpColor Invalid; static const kpColor Transparent; // // Primary Colors + B&W // static const kpColor Red, Green, Blue; static const kpColor Black, White; // // Full-brightness Colors // static const kpColor Yellow, Purple, Aqua; // // Mixed Colors // static const kpColor Gray, LightGray, Orange; // // Pastel Colors // static const kpColor Pink, LightGreen, LightBlue, Tan; // // Dark Colors // static const kpColor DarkRed; // (identical) static const kpColor DarkOrange, Brown; static const kpColor DarkYellow, DarkGreen, DarkAqua, DarkBlue, DarkPurple, DarkGray; public: static int processSimilarity (double colorSimilarity); // Usage: isSimilarTo (rhs, kpColor::processSimilarity (.1)) checks for // Color Similarity within 10% bool isSimilarTo (const kpColor &rhs, int processedSimilarity) const; bool isValid () const; int red () const; int green () const; int blue () const; int alpha () const; bool isTransparent () const; // Cast operators will most likely result in careless conversions so // use explicit functions instead: QRgb toQRgb () const; QColor toQColor () const; private: // Catch accidental call to "const QRgb &rgba" (unsigned int) ctor // by e.g. "kpColor(Qt::black)" (Qt::black is an enum element that can cast // to "unsigned int"). kpColor (Qt::GlobalColor color); bool m_rgbaIsValid; QRgb m_rgba; mutable bool m_colorCacheIsValid; mutable QColor m_colorCache; }; #endif // KP_COLOR_H diff --git a/imagelib/kpDocumentMetaInfo.h b/imagelib/kpDocumentMetaInfo.h index eac697cc..887f4151 100644 --- a/imagelib/kpDocumentMetaInfo.h +++ b/imagelib/kpDocumentMetaInfo.h @@ -1,108 +1,108 @@ /* Copyright (c) 2003-2007 Clarence Dang All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef KP_DOCUMENT_META_INFO_H #define KP_DOCUMENT_META_INFO_H -#include -#include -#include -#include +#include +#include +#include +#include #include "commands/kpCommandSize.h" class QPoint; class QStringList; class kpDocumentMetaInfo { public: kpDocumentMetaInfo (); kpDocumentMetaInfo (const kpDocumentMetaInfo &rhs); virtual ~kpDocumentMetaInfo (); bool operator== (const kpDocumentMetaInfo &rhs) const; bool operator!= (const kpDocumentMetaInfo &rhs) const; kpDocumentMetaInfo &operator= (const kpDocumentMetaInfo &rhs); void printDebug (const QString &prefix) const; kpCommandSize::SizeType size () const; // // Constants (enforced by methods) // static const int MinDotsPerMeter, MaxDotsPerMeter; static const int MinOffset, MaxOffset; // See QImage documentation // is 0 if the resolution is unspecified. // Else, these methods automatically bound to be between // MinDotsPerMeter ... MaxDotsPerMeter inclusive. int dotsPerMeterX () const; void setDotsPerMeterX (int val); // is 0 if the resolution is unspecified. // Else, these methods automatically bound to be between // MinDotsPerMeter ... MaxDotsPerMeter inclusive. int dotsPerMeterY () const; void setDotsPerMeterY (int val); // These methods automatically bound each of X and Y to be between // MinOffset and MaxOffset inclusive. QPoint offset () const; void setOffset (const QPoint &point); QMap textMap () const; QList textKeys () const; // (if is empty, it returns an empty string) QString text (const QString &key) const; // (if is empty, the operation is ignored) void setText (const QString &key, const QString &value); private: struct kpDocumentMetaInfoPrivate *d; }; #endif // KP_DOCUMENT_META_INFO_H diff --git a/kpDefs.h b/kpDefs.h index f3ee9668..fa9f57a2 100644 --- a/kpDefs.h +++ b/kpDefs.h @@ -1,144 +1,144 @@ /* Copyright (c) 2003-2007 Clarence Dang All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef KP_DEFS_H #define KP_DEFS_H #include -#include -#include -#include -#include +#include +#include +#include +#include // approx. 2896x2896x32bpp or 3344x3344x24bpp (TODO: 24==32?) or 4096*4096x16bpp #define KP_BIG_IMAGE_SIZE (32 * 1048576) #define KP_INVALID_POINT QPoint (INT_MIN / 8, INT_MIN / 8) #define KP_INVALID_WIDTH (INT_MIN / 8) #define KP_INVALID_HEIGHT (INT_MIN / 8) #define KP_INVALID_SIZE QSize (INT_MIN / 8, INT_MIN / 8) #define KP_INCHES_PER_METER (100 / 2.54) #define KP_MILLIMETERS_PER_INCH 25.4 // // Settings // #define kpSettingsGroupRecentFiles "Recent Files" #define kpSettingsGroupGeneral "General Settings" #define kpSettingFirstTime "First Time" #define kpSettingShowGrid "Show Grid" #define kpSettingShowPath "Show Path" #define kpSettingDrawAntiAliased "Draw AntiAliased" #define kpSettingColorSimilarity "Color Similarity" #define kpSettingDitherOnOpen "Dither on Open if Screen is 15/16bpp and Image Num Colors More Than" #define kpSettingPrintImageCenteredOnPage "Print Image Centered On Page" #define kpSettingOpenImagesInSameWindow "Open Images in the Same Window" #define kpSettingsGroupFileSaveAs "File/Save As" #define kpSettingsGroupFileExport "File/Export" #define kpSettingsGroupEditCopyTo "Edit/Copy To" #define kpSettingForcedMimeType "Forced MimeType" #define kpSettingForcedColorDepth "Forced Color Depth" #define kpSettingForcedDither "Forced Dither" #define kpSettingForcedQuality "Forced Quality" #define kpSettingLastDocSize "Last Document Size" #define kpSettingMoreEffectsLastEffect "More Effects - Last Effect" #define kpSettingsGroupMimeTypeProperties "MimeType Properties Version 1.2-3" #define kpSettingMimeTypeMaximumColorDepth "Maximum Color Depth" #define kpSettingMimeTypeHasConfigurableColorDepth "Configurable Color Depth" #define kpSettingMimeTypeHasConfigurableQuality "Configurable Quality Setting" #define kpSettingsGroupUndoRedo "Undo/Redo Settings" #define kpSettingUndoMinLimit "Min Limit" #define kpSettingUndoMaxLimit "Max Limit" #define kpSettingUndoMaxLimitSizeLimit "Max Limit Size Limit" #define kpSettingsGroupThumbnail "Thumbnail Settings" #define kpSettingThumbnailShown "Shown" #define kpSettingThumbnailGeometry "Geometry" #define kpSettingThumbnailZoomed "Zoomed" #define kpSettingThumbnailShowRectangle "ShowRectangle" #define kpSettingsGroupPreviewSave "Save Preview Settings" #define kpSettingPreviewSaveGeometry "Geometry" #define kpSettingPreviewSaveUpdateDelay "Update Delay" #define kpSettingsGroupTools "Tool Settings" #define kpSettingLastTool "Last Used Tool" #define kpSettingToolBoxIconSize "Tool Box Icon Size" #define kpSettingsGroupText "Text Settings" #define kpSettingFontFamily "Font Family" #define kpSettingFontSize "Font Size" #define kpSettingBold "Bold" #define kpSettingItalic "Italic" #define kpSettingUnderline "Underline" #define kpSettingStrikeThru "Strike Thru" #define kpSettingsGroupFlattenEffect "Flatten Effect Settings" #define kpSettingFlattenEffectColor1 "Color1" #define kpSettingFlattenEffectColor2 "Color2" // // Session Restore Setting // // URL of the document in the main window. // // This key only exists if the document does. If it exists, it can be empty. // The URL need not point to a file that exists e.g. "kolourpaint doesnotexist.png". #define kpSessionSettingDocumentUrl QString::fromLatin1 ("Session Document Url") // The size of a document which is not from a URL e.g. "kolourpaint doesnotexist.png". // This key does not exist for documents from URLs. #define kpSessionSettingNotFromUrlDocumentSize QString::fromLatin1 ("Session Not-From-Url Document Size") #endif // KP_DEFS_H diff --git a/kpViewScrollableContainer.h b/kpViewScrollableContainer.h index bca0d06a..6ecd6c65 100644 --- a/kpViewScrollableContainer.h +++ b/kpViewScrollableContainer.h @@ -1,215 +1,215 @@ /* Copyright (c) 2003-2007 Clarence Dang All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef KP_VIEW_SCROLLABLE_CONTAINER_H #define KP_VIEW_SCROLLABLE_CONTAINER_H -#include -#include +#include +#include #include -#include +#include class QCursor; class QDragMoveEvent; class QEvent; class QKeyEvent; class QMouseEvent; class QPaintEvent; class QRect; class QResizeEvent; class QTimer; class kpView; class kpOverlay; //--------------------------------------------------------------------- // REFACTOR: refactor by sharing iface's with kpTool class kpGrip : public QWidget { Q_OBJECT public: enum GripType { Right = 1, Bottom = 2, BottomRight = Right | Bottom }; kpGrip (GripType type, QWidget *parent); GripType type () const; static QCursor cursorForType (GripType type); bool containsCursor(); bool isDrawing () const; static const int Size; signals: void beganDraw (); void continuedDraw (int viewDX, int viewDY, bool dueToDragScroll); void cancelledDraw (); void endedDraw (int viewDX, int viewDY); void statusMessageChanged (const QString &string); void releasedAllButtons (); public: QString haventBegunDrawUserMessage () const; QString userMessage () const; void setUserMessage (const QString &message); protected: void cancel (); protected: void keyReleaseEvent (QKeyEvent *e) override; void mousePressEvent (QMouseEvent *e) override; public: QPoint viewDeltaPoint () const; void mouseMovedTo (const QPoint &point, bool dueToDragScroll); protected: void mouseMoveEvent (QMouseEvent *e) override; void mouseReleaseEvent (QMouseEvent *e) override; void enterEvent (QEvent *e) override; void leaveEvent (QEvent *e) override; protected: GripType m_type; QPoint m_startPoint, m_currentPoint; QString m_userMessage; bool m_shouldReleaseMouseButtons; }; //--------------------------------------------------------------------- class kpViewScrollableContainer : public QScrollArea { Q_OBJECT public: kpViewScrollableContainer(QWidget *parent); QSize newDocSize () const; bool haveMovedFromOriginalDocSize () const; QString statusMessage () const; void clearStatusMessage (); kpView *view () const; void setView (kpView *view); void drawResizeLines(); // public only for kpOverlay signals: void contentsMoved(); void beganDocResize (); void continuedDocResize (const QSize &size); void cancelledDocResize (); void endedDocResize (const QSize &size); // (string.isEmpty() if kpViewScrollableContainer has nothing to say) void statusMessageChanged (const QString &string); void resized (); public slots: void recalculateStatusMessage (); void updateGrips (); // TODO: Why the need for view's zoomLevel? We have the view() anyway. bool beginDragScroll (int zoomLevel, bool *didSomething); bool beginDragScroll (int zoomLevel); bool endDragScroll (); private: void connectGripSignals (kpGrip *grip); QSize newDocSize (int viewDX, int viewDY) const; void calculateDocResizingGrip (); kpGrip *docResizingGrip () const; int bottomResizeLineWidth () const; int rightResizeLineWidth () const; QRect bottomResizeLineRect () const; QRect rightResizeLineRect () const; QRect bottomRightResizeLineRect () const; QRect mapViewToViewport (const QRect &viewRect); void updateResizeLines (int viewX, int viewY, int viewDX, int viewDY); void disconnectViewSignals (); void connectViewSignals (); QRect noDragScrollRect () const; void wheelEvent(QWheelEvent *e) override; void resizeEvent(QResizeEvent *e) override; private slots: void slotGripBeganDraw (); void slotGripContinuedDraw (int viewDX, int viewDY, bool dueToScrollView); void slotGripCancelledDraw (); void slotGripEndedDraw (int viewDX, int viewDY); void slotGripStatusMessageChanged (const QString &string); void slotContentsMoved (); void slotViewDestroyed (); bool slotDragScroll (bool *didSomething = nullptr); private: kpView *m_view; kpOverlay *m_overlay; kpGrip *m_bottomGrip, *m_rightGrip, *m_bottomRightGrip; kpGrip *m_docResizingGrip; QTimer *m_dragScrollTimer; int m_zoomLevel; bool m_scrollTimerRunOnce; int m_resizeRoundedLastViewX, m_resizeRoundedLastViewY; int m_resizeRoundedLastViewDX, m_resizeRoundedLastViewDY; bool m_haveMovedFromOriginalDocSize; QString m_gripStatusMessage; }; #endif // KP_VIEW_SCROLLABLE_CONTAINER_H diff --git a/layers/selections/text/kpTextStyle.h b/layers/selections/text/kpTextStyle.h index 6eb82907..c7ebfa25 100644 --- a/layers/selections/text/kpTextStyle.h +++ b/layers/selections/text/kpTextStyle.h @@ -1,107 +1,107 @@ /* Copyright (c) 2003-2007 Clarence Dang All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef KP_TEXT_STYLE_H #define KP_TEXT_STYLE_H -#include +#include #include "imagelib/kpColor.h" class QDataStream; class QFont; class QFontMetrics; class kpTextStyle { public: kpTextStyle (); kpTextStyle (const QString &fontFamily, int fontSize, bool isBold, bool isItalic, bool isUnderline, bool isStrikeThru, const kpColor &fcolor, const kpColor &bcolor, bool isBackgroundOpaque); ~kpTextStyle (); friend QDataStream &operator<< (QDataStream &stream, const kpTextStyle &textStyle); friend QDataStream &operator>> (QDataStream &stream, kpTextStyle &textStyle); bool operator== (const kpTextStyle &rhs) const; bool operator!= (const kpTextStyle &rhs) const; QString fontFamily () const; void setFontFamily (const QString &f); int fontSize () const; void setFontSize (int s); bool isBold () const; void setBold (bool yes = true); bool isItalic () const; void setItalic (bool yes = true); bool isUnderline () const; void setUnderline (bool yes = true); bool isStrikeThru () const; void setStrikeThru (bool yes = true); kpColor foregroundColor () const; void setForegroundColor (const kpColor &fcolor); // Note: This is the _input_ backgroundColor kpColor backgroundColor () const; void setBackgroundColor (const kpColor &bcolor); bool isBackgroundOpaque () const; void setBackgroundOpaque (bool yes = true); bool isBackgroundTransparent () const; void setBackgroundTransparent (bool yes = true); QFont font () const; QFontMetrics fontMetrics () const; private: QString m_fontFamily; int m_fontSize; bool m_isBold, m_isItalic, m_isUnderline, m_isStrikeThru; kpColor m_foregroundColor, m_backgroundColor; bool m_isBackgroundOpaque; }; #endif // KP_TEXT_STYLE_H diff --git a/layers/tempImage/kpTempImage.h b/layers/tempImage/kpTempImage.h index 4e8aa30a..331f11e8 100644 --- a/layers/tempImage/kpTempImage.h +++ b/layers/tempImage/kpTempImage.h @@ -1,110 +1,110 @@ /* Copyright (c) 2003-2007 Clarence Dang All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ // REFACTOR: maybe make us and kpAbstractSelection share a new kpLayer base? #ifndef kpTempImage_H #define kpTempImage_H -#include +#include #include "imagelib/kpImage.h" class kpViewManager; class kpTempImage { public: // REFACTOR: Extract into class hierarchy. enum RenderMode { SetImage, PaintImage, UserFunction }; // REFACTOR: Function pointers imply a need for a proper class hierarchy. typedef void (*UserFunctionType) (kpImage * /*destImage*/, const QPoint & /*topLeft*/, void * /*userData*/); /* * Specifies that its visibility is dependent on whether or * not the mouse cursor is inside a view. If false, the * image is always displayed. * * This is the only way of specifying the "UserFunction" * . must not draw outside * the claimed rectangle. */ kpTempImage (bool isBrush, RenderMode renderMode, const QPoint &topLeft, const kpImage &image); kpTempImage (bool isBrush, const QPoint &topLeft, UserFunctionType userFunction, void *userData, int width, int height); kpTempImage (const kpTempImage &rhs); kpTempImage &operator= (const kpTempImage &rhs); bool isBrush () const; RenderMode renderMode () const; QPoint topLeft () const; kpImage image () const; UserFunctionType userFunction () const; void *userData () const; bool isVisible (const kpViewManager *vm) const; QRect rect () const; int width () const; int height () const; // Returns whether a call to paint() may add a mask to <*destImage>. bool paintMayAddMask () const; /* * Draws itself onto <*destImage>, given that <*destImage> represents * the unzoomed of the kpDocument. You should check for * visibility before calling this function. */ void paint (kpImage *destImage, const QRect &docRect) const; private: bool m_isBrush; RenderMode m_renderMode; QPoint m_topLeft; kpImage m_image; // == m_image.{width,height}() unless m_renderMode == UserFunction. int m_width, m_height; UserFunctionType m_userFunction; void *m_userData; }; #endif // kpTempImage_H diff --git a/pixmapfx/kpPixmapFX.h b/pixmapfx/kpPixmapFX.h index 1b3920b9..fe84224c 100644 --- a/pixmapfx/kpPixmapFX.h +++ b/pixmapfx/kpPixmapFX.h @@ -1,250 +1,250 @@ // REFACTOR: Split this class into one for each distinct functionality category // (e.g. effects, mask operations)? /* Copyright (c) 2003-2007 Clarence Dang All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef KP_PIXMAP_FX_H #define KP_PIXMAP_FX_H -#include -#include +#include +#include #include #include "imagelib/kpColor.h" class QColor; class QImage; class QMatrix; class QPen; class QImage; class QPoint; class QPolygon; class QRect; class kpAbstractSelection; // // QPixmap (view) Manipulation. // // Anything that is supposed to be manipulating the document contents // (i.e. kpImage), should be moved to kpPainter. // // kpPainter uses us for its Qt backend but we don't use kpPainter. // TODO: We should not use kpColor nor kpImage for the same reason. // class kpPixmapFX { // // Get/Set Parts of Pixmap // public: // // Returns the pixel and mask data found at the in . // static QImage getPixmapAt (const QImage &pm, const QRect &rect); // // Sets the pixel and mask data at in <*destPixmapPtr> // to . Neither 's width nor height are allowed // to be bigger than 's (you can't copy more than you have). // On the other hand, you can copy less than the size of // - no scaling is done. // static void setPixmapAt (QImage *destPixmapPtr, const QRect &destRect, const QImage &srcPixmap); // // Sets the pixel and mask data at the rectangle in <*destPixmapPtr>, // with the top-left and dimensions , // to . // static void setPixmapAt (QImage *destPixmapPtr, const QPoint &destAt, const QImage &srcPixmap); static void setPixmapAt (QImage *destPixmapPtr, int destX, int destY, const QImage &srcPixmap); // // Draws on top of <*destPixmapPtr> at . // The mask of <*destPixmapPtr> is adjusted so that all opaque // pixels in will be opaque in <*destPixmapPtr>. // static void paintPixmapAt (QImage *destPixmapPtr, const QPoint &destAt, const QImage &srcPixmap); static void paintPixmapAt (QImage *destPixmapPtr, int destX, int destY, const QImage &srcPixmap); // // Returns the colour of the pixel at in . // If the pixel is transparent, a value is returned such that // kpTool::isColorTransparent() will return true. // static kpColor getColorAtPixel (const QImage &pm, const QPoint &at); static kpColor getColorAtPixel (const QImage &pm, int x, int y); // // Transforms // public: // // Resizes an image to the given width and height, // filling any new areas with . // static void resize (QImage *destPtr, int w, int h, const kpColor &backgroundColor); static QImage resize (const QImage &pm, int w, int h, const kpColor &backgroundColor); // // Scales an image to the given width and height. // If is true, a smooth scale will be used. // static void scale (QImage *destPtr, int w, int h, bool pretty = false); static QImage scale (const QImage &pm, int w, int h, bool pretty = false); // The minimum difference between 2 angles (in degrees) such that they are // considered different. This gives you at least enough precision to // rotate an image whose width <= 10000 such that its height increases // by just 1 (and similarly with height <= 10000 and width). // // Currently used for skew & rotate operations. static const double AngleInDegreesEpsilon; // // Skews an image. // // horizontal angle clockwise (-90 < x < 90) // vertical angle clockwise (-90 < x < 90) // color to fill new areas with // if > 0, the desired width of the resultant pixmap // if > 0, the desired height of the resultant pixmap // // Using & to generate preview pixmaps is // significantly more efficient than skewing and then scaling yourself. // static QMatrix skewMatrix (int width, int height, double hangle, double vangle); static QMatrix skewMatrix (const QImage &pixmap, double hangle, double vangle); static void skew (QImage *destPixmapPtr, double hangle, double vangle, const kpColor &backgroundColor, int targetWidth = -1, int targetHeight = -1); static QImage skew (const QImage &pm, double hangle, double vangle, const kpColor &backgroundColor, int targetWidth = -1, int targetHeight = -1); // // Rotates an image. // // clockwise angle to rotate by // color to fill new areas with // if > 0, the desired width of the resultant pixmap // if > 0, the desired height of the resultant pixmap // // Using & to generate preview pixmaps is // significantly more efficient than rotating and then scaling yourself. // static QMatrix rotateMatrix (int width, int height, double angle); static QMatrix rotateMatrix (const QImage &pixmap, double angle); static bool isLosslessRotation (double angle); static void rotate (QImage *destPixmapPtr, double angle, const kpColor &backgroundColor, int targetWidth = -1, int targetHeight = -1); static QImage rotate (const QImage &pm, double angle, const kpColor &backgroundColor, int targetWidth = -1, int targetHeight = -1); // // Drawing Shapes // public: // Returns a pen suitable for drawing a rectangle with 90 degree // corners ("MiterJoin"). This is necessary since Qt4 defaults to // "BevelJoin". is passed straight to QPen without modification. static QPen QPainterDrawRectPen (const QColor &color, int qtWidth); // Returns a pen suitable for drawing lines / polylines / polygons / // curves with rounded corners. This is necessary since Qt4 defaults // to square corners ("SquareCap") and "BevelJoin". // is passed straight to QPen without modification. static QPen QPainterDrawLinePen (const QColor &color, int qtWidth); static bool Only1PixelInPointArray(const QPolygon &points); // Draws a line from (x1,y1) to (x2,y2) onto , with // and . The corners are rounded and centred at those // coordinates so if > 1, the line is likely to extend past // a rectangle with those corners. // // If is valid, it draws a stippled line alternating // between long strips of and short strips of . static void drawPolyline (QImage *image, const QPolygon &points, const kpColor &color, int penWidth, const kpColor &stippleColor = kpColor::Invalid); // = shape completed else drawing but haven't finalised. // If not , the edge that would form the closure, if the // shape were finalised now, is highlighted specially. // // Odd-even fill. static void drawPolygon (QImage *image, const QPolygon &points, const kpColor &fcolor, int penWidth, const kpColor &bcolor = kpColor::Invalid, bool isFinal = true, const kpColor &fStippleColor = kpColor::Invalid); static void fillRect (QImage *image, int x, int y, int width, int height, const kpColor &color, const kpColor &stippleColor = kpColor::Invalid); static void drawStippleRect(QImage *image, int x, int y, int width, int height, const kpColor &fcolor, const kpColor &fStippleColor); }; #endif // KP_PIXMAP_FX_H diff --git a/tools/flow/kpToolFlowBase.h b/tools/flow/kpToolFlowBase.h index 7ef71a8b..ac41d72f 100644 --- a/tools/flow/kpToolFlowBase.h +++ b/tools/flow/kpToolFlowBase.h @@ -1,120 +1,120 @@ /* Copyright(c) 2003-2007 Clarence Dang All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef KP_TOOL_FLOW_BASE_H #define KP_TOOL_FLOW_BASE_H -#include +#include #include "layers/tempImage/kpTempImage.h" #include "tools/kpTool.h" class QPoint; class QString; class kpColor; class kpToolFlowCommand; class kpToolFlowBase : public kpTool { Q_OBJECT public: kpToolFlowBase(const QString &text, const QString &description, int key, kpToolEnvironment *environ, QObject *parent, const QString &name); ~kpToolFlowBase() override; // Returns the dirty rectangle for drawing a brush(of size // x) at . will end // up being the midpoint of the returned rectangle(subject to integer // precision). static QRect hotRectForMousePointAndBrushWidthHeight( const QPoint &mousePoint, int brushWidth, int brushHeight); void begin() override; void end() override; void beginDraw() override; void hover(const QPoint &point) override; // drawPoint() normally calls drawLine(point,point). Override drawPoint() // if you think you can be more efficient. virtual QRect drawPoint(const QPoint &point); virtual QRect drawLine(const QPoint &thisPoint, const QPoint &lastPoint) = 0; virtual bool drawShouldProceed(const QPoint & /*thisPoint*/, const QPoint & /*lastPoint*/, const QRect & /*normalizedRect*/) { return true; } void draw(const QPoint &thisPoint, const QPoint &lastPoint, const QRect &normalizedRect) override; void cancelShape() override; void releasedAllButtons() override; void endDraw(const QPoint &, const QRect &) override; protected: virtual QString haventBegunDrawUserMessage() const = 0; virtual bool haveSquareBrushes() const { return false; } virtual bool haveDiverseBrushes() const { return false; } bool haveAnyBrushes() const { return(haveSquareBrushes() || haveDiverseBrushes()); } virtual bool colorsAreSwapped() const { return false; } kpTempImage::UserFunctionType brushDrawFunction() const; void *brushDrawFunctionData() const; int brushWidth() const; int brushHeight() const; bool brushIsDiagonalLine() const; kpToolFlowCommand *currentCommand() const; virtual kpColor color(int which); QRect hotRect() const; protected slots: void updateBrushAndCursor(); void slotForegroundColorChanged(const kpColor &col) override; void slotBackgroundColorChanged(const kpColor &col) override; private: void clearBrushCursorData(); private: struct kpToolFlowBasePrivate *d; }; #endif // KP_TOOL_FLOW_BASE_H diff --git a/tools/kpTool.h b/tools/kpTool.h index bb3ba42c..13e3e856 100644 --- a/tools/kpTool.h +++ b/tools/kpTool.h @@ -1,465 +1,465 @@ /* Copyright (c) 2003-2007 Clarence Dang All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef KP_TOOL_H #define KP_TOOL_H -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "kpDefs.h" #ifdef Q_OS_WIN #include #undef environ // macro on win32 #endif class QFocusEvent; class QIcon; class QInputMethodEvent; class QKeyEvent; class QMouseEvent; class QImage; class QWheelEvent; class kpColor; class kpCommandHistory; class kpDocument; class kpView; class kpViewManager; class kpToolAction; class kpToolEnvironment; class kpToolToolBar; struct kpToolPrivate; // Base class for all tools. // REFACTOR: rearrange method order to make sense and reflect kpTool_*.cpp split. class kpTool : public QObject { Q_OBJECT public: // = user-visible name of the tool e.g. "Color Picker" // = user-visible description used for tooltips // e.g. "Lets you select a color from the image" // = optional shortcut key for switching to the tool, or 0 otherwise // e.g. Qt::Key_C // = internal QObject name (not user-visible) e.g. "tool_color_picker" // used for fetching the icon(), the name of the action() and // debug printing. kpTool (const QString &text, const QString &description, int key, kpToolEnvironment *environ, QObject *parent, const QString &name); ~kpTool () override; kpToolAction *action () const; QString text () const; static QString toolTipForTextAndShortcut (const QString &text, const QList &shortcut); QString toolTip () const; // Given a single , returns a shortcut with // (disabled when the user is editing text) and as an alternate, // +. static QList shortcutForKey (int key); static QRect neededRect (const QRect &rect, int lineWidth); static QImage neededPixmap (const QImage &image, const QRect &boundingRect); bool hasCurrentPoint () const; // Returns the position of the cursor relative to the topleft point of // the current view (viewUnderStartPoint() or viewUnderCursor() otherwise). // // If neither viewUnderStartPoint() nor viewUnderCursor() // (i.e. !hasCurrentPoint()), then it returns KP_INVALID_POINT. // // If is set (default), then it returns the position in the // document. This theoretically == m_currentPoint (when m_currentPoint // is defined) but I wouldn't bet on it. This function is useful when // m_currentPoint isn't necessarily defined (outside of beginDraw(),draw() // and hover()). // // If is not set, then it returns an unzoomed view coordinate. // // Keep in mind that if viewUnderStartPoint(), this can return coordinates // outside of the document/view. QPoint calculateCurrentPoint (bool zoomToDoc = true) const; private: // Only called by ctor to create action(). void initAction (); signals: void actionToolTipChanged(); public slots: // Call this when something below the mouse cursor may have changed // and/or if the view has moved relative to the cursor (as opposed to // the cursor moving relative to the view, which would trigger a // mouseMoveEvent and all would be well without such hacks) // e.g. when zooming or scrolling the view or when deleting a selection. // // This calls hover() or draw() to let the tool know. The Brush Tool // can then update the position of the Brush Cursor. The Selection // Tool can update the real cursor. The Line Tool can update the current // line. The statubar gets correct coordinates. etc. etc. void somethingBelowTheCursorChanged (); private: // Same as above except that you claim you know better than currentPoint() void somethingBelowTheCursorChanged (const QPoint ¤tPoint_, const QPoint ¤tViewPoint_); protected: int mouseButton () const; bool shiftPressed () const; bool controlPressed () const; bool altPressed () const; QPoint startPoint () const; QPoint currentPoint () const; QPoint currentViewPoint () const; QRect normalizedRect () const; QPoint lastPoint () const; public: // for kpMainWindow kpView *viewUnderStartPoint () const; protected: kpView *viewUnderCursor () const; public: // Called when the tool is selected. virtual void begin (); // Called when the tool is deselected. virtual void end (); // Returns true after begin() has been called but returns false after end() // after end() has been called. bool hasBegun () const; bool hasBegunDraw () const; virtual bool hasBegunShape () const; // Called when user double-left-clicks on a tool in the Tool Box. virtual void globalDraw (); // Called when the user clicks on a tool in the Tool Box even though it's // already the current tool (used by the selection tools to deselect). virtual void reselect (); signals: // emitted after beginDraw() has been called void beganDraw (const QPoint &point); // Emitted just before draw() is called in mouseMoveEvent(). Slots // connected to this signal should return in whether the // mouse pos may have changed. Used by drag scrolling. void movedAndAboutToDraw (const QPoint ¤tPoint, const QPoint &lastPoint, int zoomLevel, bool *scrolled); // emitted after endDraw() has been called void endedDraw (const QPoint &point); // emitted after cancelShape() has been called void cancelledShape (const QPoint &point); signals: // User clicked on the tool's action - i.e. select this tool void actionActivated(); protected: // (this method is called by kpTool just as it is needed - its value // is not cached, so it is allowed to return different things at // different times) // REFACTOR: Misleadingly named as it's also called in cancelShapeInternal(). // And it seems to be called in endShapeInternal() as well? virtual bool returnToPreviousToolAfterEndDraw () const { return false; } virtual bool careAboutModifierState () const { return false; } virtual bool careAboutColorsSwapped () const { return false; } virtual void beginDraw (); // mouse move without button pressed // (only m_currentPoint & m_currentViewPoint is defined) virtual void hover (const QPoint &point); // this is useful for "instant" tools like the Pen & Eraser virtual void draw (const QPoint &thisPoint, const QPoint &lastPoint, const QRect &normalizedRect); private: void drawInternal (); protected: // (m_mouseButton will not change from beginDraw()) virtual void cancelShape (); virtual void releasedAllButtons (); virtual void endDraw (const QPoint &thisPoint, const QRect &normalizedRect); // TODO: I think reimplementations of this should be calling this base // implementation, so that endDraw() happens before the custom // endShape() logic of the reimplementation. virtual void endShape (const QPoint &thisPoint = QPoint (), const QRect &normalizedRect = QRect ()) { endDraw (thisPoint, normalizedRect); } kpDocument *document () const; kpViewManager *viewManager () const; kpToolToolBar *toolToolBar () const; kpCommandHistory *commandHistory () const; kpToolEnvironment *environ () const; kpColor color (int which) const; kpColor foregroundColor () const; kpColor backgroundColor () const; double colorSimilarity () const; int processedColorSimilarity () const; public slots: void slotColorsSwappedInternal (const kpColor &newForegroundColor, const kpColor &newBackgroundColor); void slotForegroundColorChangedInternal (const kpColor &color); void slotBackgroundColorChangedInternal (const kpColor &color); void slotColorSimilarityChangedInternal (double similarity, int processedSimilarity); protected slots: // TODO: there is no reason why these should be slots virtual void slotColorsSwapped (const kpColor & /*newForegroundColor*/, const kpColor & /*newBackgroundColor*/) {} virtual void slotForegroundColorChanged (const kpColor & /*color*/) {} virtual void slotBackgroundColorChanged (const kpColor & /*color*/) {} virtual void slotColorSimilarityChanged (double /*similarity*/, int /*processedSimilarity*/) {} protected: // (only valid in slots connected to the respective signals above) kpColor oldForegroundColor () const; kpColor oldBackgroundColor () const; double oldColorSimilarity () const; protected: // returns true if m_currentPoint <= 1 pixel away from m_lastPoint // or if there was no lastPoint bool currentPointNextToLast () const; // (includes diagonal adjacency) bool currentPointCardinallyNextToLast () const; // (only cardinally adjacent i.e. horiz & vert; no diag) // TODO: We should rename these. // These are accessed from kpTool logic and our friends, kpCommandHistory, // kpMainWindow, kpToolToolBar and kpView. public: void beginInternal (); void endInternal (); void beginDrawInternal (); void endDrawInternal (const QPoint &thisPoint, const QRect &normalizedRect, bool wantEndShape = false); void cancelShapeInternal (); // TODO: Who is actually calling endShapeInternal()? // Tools seem to call endShape() directly. void endShapeInternal (const QPoint &thisPoint = QPoint (), const QRect &normalizedRect = QRect ()); // // Mouse Events // public: // Note: _All_ events are forwarded from a kpView. // The existence of a kpView implies the existence of a kpDocument. // If you're reimplementing any of these, you probably don't know what // you're doing - reimplement begin(),beginDraw(),draw(),cancelShape(), // endDraw() etc. instead. virtual void mousePressEvent (QMouseEvent *e); virtual void mouseMoveEvent (QMouseEvent *e); virtual void mouseReleaseEvent (QMouseEvent *e); virtual void wheelEvent (QWheelEvent *e); // // Keyboard Events // protected: void seeIfAndHandleModifierKey (QKeyEvent *e); void arrowKeyPressDirection (const QKeyEvent *e, int *dx, int *dy); void seeIfAndHandleArrowKeyPress (QKeyEvent *e); bool isDrawKey (int key); void seeIfAndHandleBeginDrawKeyPress (QKeyEvent *e); void seeIfAndHandleEndDrawKeyPress (QKeyEvent *e); public: virtual void keyPressEvent (QKeyEvent *e); virtual void keyReleaseEvent (QKeyEvent *e); virtual void inputMethodEvent (QInputMethodEvent *) {} private: void keyUpdateModifierState (QKeyEvent *e); void notifyModifierStateChanged (); protected: virtual void setShiftPressed (bool pressed); virtual void setControlPressed (bool pressed); virtual void setAltPressed (bool pressed); // // Other Events - 1. View Events // public: // WARNING: Do not call this "event()" as our QObject parent has a // virtual function called that, that will pass us // QObject events. We only care about events forwarded by // kpView. // REFACTOR: rename mousePressEvent() -> viewMousePressEvent() etc. // to remind us that events are coming from the view - the tool // is not a visible object. virtual bool viewEvent (QEvent *e); public: virtual void focusInEvent (QFocusEvent *e); virtual void focusOutEvent (QFocusEvent *e); public: virtual void enterEvent (QEvent *e); virtual void leaveEvent (QEvent *e); // // Other Events - 2. Non-view Events // REFACTOR: Group methods under this. // protected: // 0 = left, 1 = right, -1 = other (none, left+right, mid) static int mouseButton (Qt::MouseButtons mouseButtons); public: static int calculateLength (int start, int end); // // User Notifications (Status Bar) // public: // Returns "(Left|Right) click to cancel." where Left or Right is chosen // depending on which one is the _opposite_ of static QString cancelUserMessage (int mouseButton); QString cancelUserMessage () const; QString userMessage () const; // WARNING: setUserMessage() will store a message different to , // in unspecified ways (e.g. the name of the tool, followed // by a colon and a space, will be prepended). userMessage() // will return this different string. void setUserMessage (const QString &userMessage = QString ()); QPoint userShapeStartPoint () const; QPoint userShapeEndPoint () const; void setUserShapePoints (const QPoint &startPoint = KP_INVALID_POINT, const QPoint &endPoint = KP_INVALID_POINT, bool setSize = true); QSize userShapeSize () const; int userShapeWidth () const; int userShapeHeight () const; void setUserShapeSize (const QSize &size = KP_INVALID_SIZE); void setUserShapeSize (int width, int height); signals: void userMessageChanged (const QString &userMessage); void userShapePointsChanged (const QPoint &startPoint = KP_INVALID_POINT, const QPoint &endPoint = KP_INVALID_POINT); void userShapeSizeChanged (const QSize &size); public: // Call this before the user tries to cause the document or selection // to resize from x to x. // If at least one dimension increases, the new dimensions will take a // large amount of memory (which causes thrashing, instability) and // the old dimensions did not take a large amount of memory, ask the // user if s/he really wants to perform the operation. // // Returns true if the operation should proceed, false otherwise. // // In order to make the translators' lives possible, this function cannot // generate the , nor (without // concantenating sentences and words with tense). However, it is // recommended that you give them the following values: // // e.g.: // text = i18n ("

(Rotating|Skewing) the (image|selection) to" // " %1x%2 may take a substantial amount of memory." // " This can reduce system" // " responsiveness and cause other application resource" // " problems.

").arg (newWidth, newHeight) // // "

Are you sure you want to (rotate|skew) the" // " (image|selection)?

"); // caption = i18n ("Rotate (Image|Selection)?"); // continueButtonText = i18n ("Rotat&e (Image|Selection)"); static bool warnIfBigImageSize (int oldWidth, int oldHeight, int newWidth, int newHeight, const QString &text, const QString &caption, const QString &continueButtonText, QWidget *parent); private: kpToolPrivate *d; }; #endif // KP_TOOL_H diff --git a/tools/polygonal/kpToolPolygonalBase.h b/tools/polygonal/kpToolPolygonalBase.h index cd2c2b6d..6262a57c 100644 --- a/tools/polygonal/kpToolPolygonalBase.h +++ b/tools/polygonal/kpToolPolygonalBase.h @@ -1,201 +1,201 @@ /* Copyright (c) 2003-2007 Clarence Dang All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef kpToolPolygonalBase_H #define kpToolPolygonalBase_H -#include -#include +#include +#include #include "imagelib/kpColor.h" #include "imagelib/kpImage.h" #include "tools/kpTool.h" #include "widgets/toolbars/options/kpToolWidgetFillStyle.h" class QPolygon; class QString; class kpView; class kpToolWidgetFillStyle; struct kpToolPolygonalBasePrivate; // // This tool base class is for shapes that contain at least an initial line that // is dragged out (i.e. at least 2 control points). // // The tool can also choose to allow an additional point to be added for each // additional drag or click. // // To specify whichever behavior, subclasses must implement endDraw() from // kpTool and use points(): // // 1. If the shape is incomplete, call setUserMessage() with a message // telling the user what can be done next. // 2. If the shape is complete, call endShape(). See also MaxPoints. // // If additional points are supported by the user's implementation of endDraw(), // beginDraw() will enforce the following behavior: // // Clicking the mouse button not used for the initial line drag will // end the shape. // // This behavior cannot be altered by a subclass. // // beginDraw() will ensure that points() contains 2 points on the initial line // drag. It will add an extra point for each additional point that is dragged. // // You may wish to reimplement drawingALine() if your shape does not consist of // just connected lines e.g. while the Curve tool, on the initial drag, creates // a line (consisting of the 2 points returned by points()), future drags do not // create extra lines - they actually modify the Bezier control points. // // The actual rendering is performed by the function passed in // the constructor. // class kpToolPolygonalBase : public kpTool { Q_OBJECT public: typedef void (*DrawShapeFunc) (kpImage * /*image*/, const QPolygon &/*points*/, const kpColor &/*fcolor*/, int /*penWidth = 1*/, const kpColor &/*bcolor = kpColor::Invalid*/, bool /*isFinal*/); // kpToolPolygonalBase (const QString &text, const QString &description, DrawShapeFunc drawShapeFunc, int key, kpToolEnvironment *environ, QObject *parent, const QString &name); ~kpToolPolygonalBase () override; bool careAboutModifierState () const override { return true; } protected: // The maximum number of points() we should allow (mainly, to ensure // good performance). Enforced by implementors of endShape(). static const int MaxPoints = 50; virtual QString haventBegunShapeUserMessage () const = 0; public: void begin () override; void end () override; void beginDraw () override; protected: // Adjusts the current line (end points given by the last 2 points of points()) // in response to keyboard modifiers: // // No modifiers: Does nothing // Shift : Clamps the line to 45 degrees increments // Ctrl : Clamps the line to 30 degrees increments // Alt : [currently disabled] Makes the starting point the center // point of the line. // // It is possible to depress multiple modifiers for combined effects e.g. // Ctrl+Shift clamps the line to 30 and 45 degree increments i.e. // 0, 30, 45, 60, 90, 120, 135, 150, 180, 210, ... degrees. // // This really only makes sense if drawingALine() returns true, where draw() // will call applyModifiers() automatically. Otherwise, if it returns false, // it doesn't really make sense to call applyModifiers() (in a hypothetical // reimplementation of draw()) because you're not manipulating a line - but // you can still call applyModifiers() if you want. void applyModifiers (); // Returns the current points in the shape. It is updated by beginDraw() // (see the class description). // // draw() sets the last point to the currentPoint(). If drawingALine(), // draw() then calls applyModifiers(). QPolygon *points () const; // Returns the mouse button for the drag that created the initial line. // Use this - instead of mouseButton() - for determining whether you should // use the left mouse button's or right mouse button's color. This is because // the user presses the other mouse button to finish the shape (so mouseButton() // will return the wrong one, after the initial line). // // Only valid if kpTool::hasBegunShape() returns true. int originatingMouseButton () const; // Returns true if the current drag is visually a line from the 2nd last point // of points() to the last point of points() e.g. the initial line drag for // a Curve and all drags for a Polygon or Polyline. draw() will call // applyModifiers() and update the statusbar with those 2 points. // // Returns false if the current drag only draws something based on the last // point of points() e.g. a control point of a Bezier curve. draw() will // _not_ call applyModifiers(). It will update the statubar with just that // point. // // Reimplement this if not all points are used to construct connected lines. // For instance, the Curve tool will return "true" to construct a line, on // the initial drag. However, for the following 2 control points, it returns // "false". The Curve tool realizes it is an initial drag if points() only // returns 2 points. virtual bool drawingALine () const { return true; } public: void draw (const QPoint &, const QPoint &, const QRect &) override; private: kpColor drawingForegroundColor () const; protected: // This returns the invalid color so that there is never a fill. // This is in contrast to kpToolRectangularBase, which sometimes fills by // returning a valid color. // // Reimplemented in the Polygon tool for a fill. virtual kpColor drawingBackgroundColor () const; protected slots: void updateShape (); public: void cancelShape () override; void releasedAllButtons () override; void endShape (const QPoint & = QPoint (), const QRect & = QRect ()) override; bool hasBegunShape () const override; protected slots: void slotForegroundColorChanged (const kpColor &) override; void slotBackgroundColorChanged (const kpColor &) override; private: kpToolPolygonalBasePrivate * const d; }; #endif // kpToolPolygonalBase_H diff --git a/views/kpView.h b/views/kpView.h index a01dcf5b..4d0621f4 100644 --- a/views/kpView.h +++ b/views/kpView.h @@ -1,599 +1,599 @@ /* Copyright (c) 2003-2007 Clarence Dang All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef KP_VIEW_H #define KP_VIEW_H -#include +#include #include "kpDefs.h" class QDragEnterEvent; class QDragLeaveEvent; class QEvent; class QFocusEvent; class QKeyEvent; class QMouseEvent; class QPaintEvent; class QPixmap; class QResizeEvent; class kpAbstractSelection; class kpDocument; class kpTextSelection; class kpTool; class kpToolToolBar; class kpViewManager; class kpViewScrollableContainer; /** * @short Abstract base class for all views. * * This is the abstract base class for all views. A view is a widget that * renders a possibly zoomed onscreen representation of a document. * * 1 view corresponds to 1 document. * 1 document corresponds to 0 or more views. * * @see kpViewManager * * @author Clarence Dang */ class kpView : public QWidget { Q_OBJECT public: /** * Constructs a view. * * @param document The document this view is representing. * @param toolToolBar The tool tool bar. * @param viewManager The view manager. * @param buddyView The view this view watches over (e.g. a thumbnail * view would watch over the main view). May be 0. * See for example, highlightBuddyViewRectangle(). * @param scrollableContainer This view's scrollable container. * May be 0. * * You must call adjustEnvironment() at the end of your constructor. */ kpView (kpDocument *document, kpToolToolBar *toolToolBar, kpViewManager *viewManager, kpView *buddyView, kpViewScrollableContainer *scrollableContainer, QWidget *parent); /** * Destructs this view. Informs the viewManager() that the mouse * cursor is no longer above this view. */ ~kpView () override; // // Constants (enforced by methods) // static const int MinZoomLevel, MaxZoomLevel; /** * @returns the document. */ kpDocument *document () const; protected: /** * @returns the document's selection. */ kpAbstractSelection *selection () const; kpTextSelection *textSelection () const; public: /** * @returns the tool tool bar. */ kpToolToolBar *toolToolBar () const; protected: /** * @returns the currently selected tool. */ kpTool *tool () const; public: /** * @returns the view manager. */ kpViewManager *viewManager () const; /** * @returns the buddy view. */ kpView *buddyView () const; /** * @returns the buddyView()'s scrollable container. */ kpViewScrollableContainer *buddyViewScrollableContainer () const; /** * @returns this view's scrollable container. */ kpViewScrollableContainer *scrollableContainer () const; /** * @returns the horizontal zoom level (100 is unzoomed). */ int zoomLevelX (void) const; /** * @returns the vertical zoom level (100 is unzoomed). */ int zoomLevelY (void) const; /** * Sets the horizontal and vertical zoom levels. * * @param hzoom Horizontal zoom level. * @param vzoom Vertical zoom level. * * This method automatically bounds and to be between * MinZoomLevel and MaxZoomLevel inclusive. * * If reimplementing, you must call this base implementation. */ virtual void setZoomLevel (int hzoom, int vzoom); /** * @returns in views coordinates, where the top-left document() pixel * will be rendered (default: (0,0)). */ QPoint origin () const; /** * Sets the origin. * * @param origin New origin. * * If reimplementing, you must call this base implementation. */ virtual void setOrigin (const QPoint &origin); /** * @returns whether at this zoom level, the grid can be enabled. * This is based on whether the grid can be sensibly rendered. */ bool canShowGrid () const; /** * @returns whether the grid is currently shown. */ bool isGridShown () const; /** * Turns on/off the grid. * * @param yes Whether to enable the grid. */ void showGrid (bool yes = true); /** * @returns whether to draw a rectangle highlighting the area of * buddyView() visible through buddyViewScrollableContainer(). */ bool isBuddyViewScrollableContainerRectangleShown () const; /** * Turns on/off the rectangle highlighting the area of buddyView() * visible through buddyViewScrollableContainer() and redraws. * * @param yes Whether to turn on the rectangle. */ void showBuddyViewScrollableContainerRectangle (bool yes = true); protected: /** * @returns the current rectangle highlighting the area of buddyView() * visible through buddyViewScrollableContainer(), that is being * rendered by this view. */ QRect buddyViewScrollableContainerRectangle () const; protected slots: /** * Updates the buddyViewScrollableContainerRectangle() and redraws * appropriately. * * This is already connected to zoomLevelChanged() and originChanged(); * buddyView() and buddyViewScrollableContainer() signals. There is probably no * need to call this function directly. */ void updateBuddyViewScrollableContainerRectangle (); public: /** * @param viewX Horizontal position in view coordinates. * * @returns viewX transformed to document coordinates, based on the * origin() and zoomLevelX(). */ double transformViewToDocX (double viewX) const; /** * @param viewY Vertical position in view coordinates. * * @returns viewY transformed to document coordinates, based on the * origin() and zoomLevelY(). */ double transformViewToDocY (double viewY) const; /** * @param viewPoint Position in view coordinates. * * @returns viewPoint transformed to document coordinates, based on the * origin(), zoomLevelX() and zoomLevelY(). */ QPoint transformViewToDoc (const QPoint &viewPoint) const; /** * @param viewRect Rectangle in view coordinates. * * @returns viewRect transformed to document coordinates based on the * origin(), zoomLevelX() and zoomLevelY(). * * For bounding rectangles, you should use this function instead of * transformViewToDocX(), transformViewToDocY() or * transformViewToDoc(const QPoint &) which act on coordinates only. */ QRect transformViewToDoc (const QRect &viewRect) const; /** * @param docX Horizontal position in document coordinates. * * @returns docX transformed to view coordinates, based on the origin() * and zoomLevelX(). */ double transformDocToViewX (double docX) const; /** * @param docY Vertical position in document coordinates. * * @returns docY transformed to view coordinates, based on the origin() * and zoomLevelY(). */ double transformDocToViewY (double docY) const; /** * @param docPoint Position in document coordinates. * * @returns docPoint transformed to view coordinates, based on the * origin(), zoomLevelX(), zoomLevelY(). */ QPoint transformDocToView (const QPoint &docPoint) const; /** * @param docRect Rectangle in document coordinates. * * @return docRect transformed to view coordinates, based on the * origin(), zoomLevelX() and zoomLevelY(). * * For bounding rectangles, you should use this function instead of * transformDocToViewX(), transformDocToViewY() or * transformDocToView(const QPoint &) which act on coordinates only. */ QRect transformDocToView (const QRect &docRect) const; /** * @param viewPoint Position in view coordinates. * @param otherView View whose coordinate system the return value will * be in. * * @returns viewPoint transformed to the coordinate system of * @param otherView based on this and otherView's origin(), * zoomLevelX() and zoomLevelY(). This has less rounding * error than otherView->transformDocToView (transformViewToDoc (viewPoint)). */ QPoint transformViewToOtherView (const QPoint &viewPoint, const kpView *otherView); /** * @returns the approximate view width required to display the entire * document(), based on the zoom level only. */ int zoomedDocWidth () const; /** * @returns the approximate view height required to display the entire * document(), based on the zoom level only. */ int zoomedDocHeight () const; protected: /** * Updates the viewManager() on whether or not the mouse is directly * above this view. Among other things, this ensures the brush cursor * is updated. * * This should be called in event handlers. * * @param yes Whether the mouse is directly above this view. */ void setHasMouse (bool yes = true); public: /** * Adds a region (in view coordinates) to the dirty area that is * repainted when the parent @ref kpViewManager is set not to queue * updates. * * @param region Region (in view coordinates) that needs repainting. */ void addToQueuedArea (const QRegion ®ion); /** * Convenience function. Same as above. * * Adds a rectangle (in view coordinates) to the dirty area that is * repainted when the parent @ref kpViewManager is set not to queue * updates. * * @param rect Rectangle (in view coordinates) that needs repainting. */ void addToQueuedArea (const QRect &rect); /** * Removes the dirty region that has been queued for updating. * Does not update the view. */ void invalidateQueuedArea (); /** * Updates the part of the view described by dirty region and then * calls invalidateQueuedArea(). Does nothing if @ref kpViewManager * is set to queue updates. */ void updateQueuedArea (); QVariant inputMethodQuery (Qt::InputMethodQuery query) const override; public slots: /** * Call this when the "environment" (e.g. document size) changes. The * environment is defined by the caller and should be based on the type * of view. For instance, an unzoomed thumbnail view would also * include in its environment the contents position of an associated * scrollable container. * * This is never called by the kpView base class. * * Implementors should change whatever state is necessary for their * type of view. For instance, an unzoomed view would resize itself; * a zoomed thumbnail would change the zoom level. */ virtual void adjustToEnvironment () = 0; public: // If is not KP_INVALID_POINT, it spits it back. // Else, it returns the current mouse position in view coordinates. // REFACTOR: Seems like a bad API. QPoint mouseViewPoint (const QPoint &returnViewPoint = KP_INVALID_POINT) const; signals: /** * Emitted after all zooming code has been executed. * * @param zoomLevelX New zoomLevelX() * @param zoomLevelY New zoomLevelY() */ void zoomLevelChanged (int zoomLevelX, int zoomLevelY); /** * Emitted after all resizing code has been executed. * * @param size New view size. */ void sizeChanged (const QSize &size); /** * Convenience signal - same as above. * * Emitted after all resizing code has been executed. * * @param width New view width. * @param height New view height. */ void sizeChanged (int width, int height); /** * Emitted after all origin changing code has been executed. * * @param origin The new origin. */ void originChanged (const QPoint &origin); // // Selections // public: QRect selectionViewRect () const; // (if is KP_INVALID_POINT, it uses QCursor::pos()) QPoint mouseViewPointRelativeToSelection (const QPoint &viewPoint = KP_INVALID_POINT) const; bool mouseOnSelection (const QPoint &viewPoint = KP_INVALID_POINT) const; int textSelectionMoveBorderAtomicSize () const; bool mouseOnSelectionToMove (const QPoint &viewPoint = KP_INVALID_POINT) const; protected: bool selectionLargeEnoughToHaveResizeHandlesIfAtomicSize (int atomicSize) const; public: int selectionResizeHandleAtomicSize () const; bool selectionLargeEnoughToHaveResizeHandles () const; QRegion selectionResizeHandlesViewRegion (bool forRenderer = false) const; enum SelectionResizeType { None = 0, Left = 1, Right = 2, Top = 4, Bottom = 8 }; // Returns a bitwise OR of the SelectionResizeType's int mouseOnSelectionResizeHandle (const QPoint &viewPoint = KP_INVALID_POINT) const; bool mouseOnSelectionToSelectText (const QPoint &viewPoint = KP_INVALID_POINT) const; // // Events // protected: void mouseMoveEvent (QMouseEvent *e) override; void mousePressEvent (QMouseEvent *e) override; void mouseReleaseEvent (QMouseEvent *e) override; public: // (needs to be public as it may also get event from // QScrollView::contentsWheelEvent()) void wheelEvent (QWheelEvent *e) override; protected: void keyPressEvent (QKeyEvent *e) override; void keyReleaseEvent (QKeyEvent *e) override; protected: void inputMethodEvent (QInputMethodEvent *e) override; protected: bool event (QEvent *e) override; protected: void focusInEvent (QFocusEvent *e) override; void focusOutEvent (QFocusEvent *e) override; protected: void enterEvent (QEvent *e) override; void leaveEvent (QEvent *e) override; protected: void dragEnterEvent (QDragEnterEvent *) override; void dragLeaveEvent (QDragLeaveEvent *) override; protected: void resizeEvent (QResizeEvent *e) override; // // Painting // protected: // Returns the document rectangle that, when scaled to the view, // is "guaranteed" to at least cover and possibly more // ("guaranteed" in quotes because it doesn't seem so reliable for // zoom levels that aren't multiples of 100%). QRect paintEventGetDocRect (const QRect &viewRect) const; public: /** * Draws an opaque background representing transparency. * * Currently, it draws a checkerboard which, if it were to be drawn * in its entirety, is tiled from . * * @param painter Painter. * @param patternOrigin Logical top-left point of the checkerboard, * relative to the painter, if it were to be * drawn in its entirety. * @param viewRect Rectangle to paint in relative to the painter. * @param isPreview Whether the view is for a preview as opposed to * e.g. editing. If set, this function may render * slightly differently. */ static void drawTransparentBackground (QPainter *painter, const QPoint &patternOrigin, const QRect &viewRect, bool isPreview = false); protected: // Draws a checkerboard that looks static even if the view is scrollable. void paintEventDrawCheckerBoard (QPainter *painter, const QRect &viewRect); // Draws the selection and its border onto . // is the part of the document given by . void paintEventDrawSelection (QImage *destPixmap, const QRect &docRect); // Draws the parts of the selection's resize handles that are inside // onto the view void paintEventDrawSelectionResizeHandles (const QRect &clipRect); void paintEventDrawTempImage (QImage *destPixmap, const QRect &docRect); // Draws the parts of the grid lines that are inside on // . void paintEventDrawGridLines (QPainter *painter, const QRect &viewRect); void paintEventDrawDoc_Unclipped (const QRect &viewRect); void paintEvent (QPaintEvent *e) override; private: struct kpViewPrivate *d; }; #endif // KP_VIEW_H diff --git a/widgets/imagelib/effects/kpEffectFlattenWidget.h b/widgets/imagelib/effects/kpEffectFlattenWidget.h index f18eb6fa..bfa2d74f 100644 --- a/widgets/imagelib/effects/kpEffectFlattenWidget.h +++ b/widgets/imagelib/effects/kpEffectFlattenWidget.h @@ -1,80 +1,80 @@ /* Copyright (c) 2003-2007 Clarence Dang All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef kpEffectFlattenWidget_H #define kpEffectFlattenWidget_H -#include +#include #include "kpEffectWidgetBase.h" class QCheckBox; class KColorButton; class kpEffectFlattenWidget : public kpEffectWidgetBase { Q_OBJECT public: kpEffectFlattenWidget (bool actOnSelection, QWidget *parent); ~kpEffectFlattenWidget () override; static QColor s_lastColor1, s_lastColor2; QColor color1 () const; QColor color2 () const; // // kpEffectWidgetBase interface // QString caption () const override; bool isNoOp () const override; kpImage applyEffect (const kpImage &image) override; kpEffectCommandBase *createCommand ( kpCommandEnvironment *cmdEnviron) const override; protected slots: void slotEnableChanged (bool enable); protected: QCheckBox *m_enableCheckBox; KColorButton *m_color1Button, *m_color2Button; }; #endif // kpEffectFlattenWidget_H diff --git a/widgets/imagelib/effects/kpEffectWidgetBase.h b/widgets/imagelib/effects/kpEffectWidgetBase.h index dbe7f94a..7b094f23 100644 --- a/widgets/imagelib/effects/kpEffectWidgetBase.h +++ b/widgets/imagelib/effects/kpEffectWidgetBase.h @@ -1,73 +1,73 @@ /* Copyright (c) 2003-2007 Clarence Dang All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef kpEffectWidgetBase_H #define kpEffectWidgetBase_H -#include +#include #include "imagelib/kpImage.h" class kpCommandEnvironment; class kpEffectCommandBase; class kpEffectWidgetBase : public QWidget { Q_OBJECT public: kpEffectWidgetBase (bool actOnSelection, QWidget *parent); ~kpEffectWidgetBase () override; signals: void settingsChangedNoWaitCursor (); void settingsChanged (); // (same as settingsChanged() but preview doesn't update until there // has been no activity for a while - used for sliders in slow effects) void settingsChangedDelayed (); public: virtual QString caption () const; virtual bool isNoOp () const = 0; virtual kpImage applyEffect (const kpImage &image) = 0; virtual kpEffectCommandBase *createCommand ( kpCommandEnvironment *cmdEnviron) const = 0; protected: bool m_actOnSelection; }; #endif // kpEffectWidgetBase_H diff --git a/widgets/kpDocumentSaveOptionsWidget.h b/widgets/kpDocumentSaveOptionsWidget.h index 58fd1b12..34a6e1ca 100644 --- a/widgets/kpDocumentSaveOptionsWidget.h +++ b/widgets/kpDocumentSaveOptionsWidget.h @@ -1,156 +1,156 @@ /* Copyright (c) 2003-2007 Clarence Dang All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef kpDocumentSaveOptionsWidget_H #define kpDocumentSaveOptionsWidget_H -#include -#include -#include +#include +#include +#include #include "imagelib/kpDocumentMetaInfo.h" #include "document/kpDocumentSaveOptions.h" class QComboBox; class QImage; class QLabel; class QTimer; class QSpinBox; class QPushButton; class kpDocumentSaveOptionsPreviewDialog; class kpDocumentSaveOptionsWidget : public QWidget { Q_OBJECT public: kpDocumentSaveOptionsWidget (const QImage &docPixmap, const kpDocumentSaveOptions &saveOptions, const kpDocumentMetaInfo &metaInfo, QWidget *parent); kpDocumentSaveOptionsWidget (QWidget *parent); private: void init (); public: ~kpDocumentSaveOptionsWidget () override; // is usually the filedialog void setVisualParent (QWidget *visualParent); protected: bool mimeTypeHasConfigurableColorDepth () const; bool mimeTypeHasConfigurableQuality () const; public: QString mimeType () const; public slots: void setMimeType (const QString &string); public: int colorDepth () const; bool dither () const; protected: static int colorDepthComboItemFromColorDepthAndDither (int depth, bool dither); public slots: void setColorDepthDither (int depth, bool dither = kpDocumentSaveOptions::initialDither ()); protected slots: void slotColorDepthSelected (); public: int quality () const; public slots: void setQuality (int newQuality); public: kpDocumentSaveOptions documentSaveOptions () const; public slots: void setDocumentSaveOptions (const kpDocumentSaveOptions &saveOptions); public: void setDocumentPixmap (const QImage &documentPixmap); void setDocumentMetaInfo (const kpDocumentMetaInfo &metaInfo); protected: enum Mode { // (mutually exclusive) None, ColorDepth, Quality }; Mode mode () const; void setMode (Mode mode); protected slots: void repaintLabels (); protected slots: void showPreview (bool yes = true); void hidePreview (); void updatePreviewDelayed (); void updatePreview (); void updatePreviewDialogLastRelativeGeometry (); protected: QWidget *m_visualParent; Mode m_mode; QImage *m_documentPixmap; kpDocumentSaveOptions m_baseDocumentSaveOptions; kpDocumentMetaInfo m_documentMetaInfo; QLabel *m_colorDepthLabel; QComboBox *m_colorDepthCombo; int m_colorDepthComboLastSelectedItem; QWidget *m_colorDepthSpaceWidget; QLabel *m_qualityLabel; QSpinBox *m_qualityInput; QPushButton *m_previewButton; kpDocumentSaveOptionsPreviewDialog *m_previewDialog; QRect m_previewDialogLastRelativeGeometry; QTimer *m_updatePreviewTimer; int m_updatePreviewDelay; QTimer *m_updatePreviewDialogLastRelativeGeometryTimer; }; #endif // kpDocumentSaveOptionsWidget_H diff --git a/widgets/kpDualColorButton.h b/widgets/kpDualColorButton.h index f058c674..ac538f49 100644 --- a/widgets/kpDualColorButton.h +++ b/widgets/kpDualColorButton.h @@ -1,96 +1,96 @@ /* Copyright (c) 2003-2007 Clarence Dang All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef kpDualColorButton_H #define kpDualColorButton_H -#include +#include #include "imagelib/kpColor.h" class kpDualColorButton : public QFrame { Q_OBJECT public: kpDualColorButton (QWidget *parent); kpColor color (int which) const; kpColor foregroundColor () const; kpColor backgroundColor () const; public slots: void setColor (int which, const kpColor &color); void setForegroundColor (const kpColor &color); void setBackgroundColor (const kpColor &color); signals: // If you connect to this signal, ignore the following // foregroundColorChanged() and backgroundColorChanged() signals void colorsSwapped (const kpColor &newForegroundColor, const kpColor &newBackgroundColor); void foregroundColorChanged (const kpColor &color); void backgroundColorChanged (const kpColor &color); public: // (only valid in slots connected to foregroundColorChanged()) kpColor oldForegroundColor () const; // (only valid in slots connected to backgroundColorChanged()) kpColor oldBackgroundColor () const; public: QSize sizeHint () const override; protected: QRect swapPixmapRect () const; QRect foregroundBackgroundRect () const; QRect foregroundRect () const; QRect backgroundRect () const; void dragEnterEvent (QDragEnterEvent *e) override; void dragMoveEvent (QDragMoveEvent *e) override; void dropEvent (QDropEvent *e) override; void mousePressEvent (QMouseEvent *e) override; void mouseMoveEvent (QMouseEvent *e) override; void mouseReleaseEvent (QMouseEvent *e) override; void mouseDoubleClickEvent (QMouseEvent *e) override; void paintEvent (QPaintEvent *e) override; QPoint m_dragStartPoint; kpColor m_color [2]; kpColor m_oldColor [2]; }; #endif // kpDualColorButton_H diff --git a/widgets/kpTransparentColorCell.h b/widgets/kpTransparentColorCell.h index 5e06b01b..cf1745e0 100644 --- a/widgets/kpTransparentColorCell.h +++ b/widgets/kpTransparentColorCell.h @@ -1,66 +1,66 @@ /* Copyright (c) 2003-2007 Clarence Dang All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef kpTransparentColorCell_H #define kpTransparentColorCell_H -#include +#include class kpColor; class kpTransparentColorCell : public QFrame { Q_OBJECT public: kpTransparentColorCell (QWidget *parent); QSize sizeHint () const override; signals: void transparentColorSelected (int mouseButton); // lazy void foregroundColorChanged (const kpColor &color); void backgroundColorChanged (const kpColor &color); protected: void mousePressEvent (QMouseEvent *e) override; void contextMenuEvent (QContextMenuEvent *e) override; void mouseReleaseEvent (QMouseEvent *e) override; void paintEvent (QPaintEvent *e) override; QPixmap m_pixmap; }; #endif // kpTransparentColorCell_H diff --git a/widgets/toolbars/kpColorToolBar.h b/widgets/toolbars/kpColorToolBar.h index cba2e164..f67c05ef 100644 --- a/widgets/toolbars/kpColorToolBar.h +++ b/widgets/toolbars/kpColorToolBar.h @@ -1,124 +1,124 @@ /* Copyright (c) 2003-2007 Clarence Dang All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef KP_COLOR_TOOLBAR_H #define KP_COLOR_TOOLBAR_H #include -#include -#include +#include +#include #include "imagelib/kpColor.h" class QBoxLayout; class kpColorCells; class kpColorPalette; class kpColorSimilarityToolBarItem; class kpDualColorButton; // COMPAT: Vertical orientation and undocking were broken by the Qt4 port // so kpMainWindow::init() keeps this tool bar in a constant position for // the time being. To help make this workaround possible, we use QDockWidget, // instead of KToolBar, to prevent XMLGUI from managing the tool // bar position. This also allows us to use QMainWindow::setCorner(). // // A nice must-have side-effect is that we are now resizeable, which // is good for configurable (and potentially large) color collections. // So we should probably keep it as a QDockWidget in the long-term // and once we fix orientation and undocking, we should put XMLGUI // support back in, somehow (create a "KDockWidget" class?). class kpColorToolBar : public QDockWidget { Q_OBJECT public: kpColorToolBar (const QString &label, QWidget *parent); kpColorCells *colorCells () const; kpColor color (int which) const; void setColor (int which, const kpColor &color); kpColor foregroundColor () const; kpColor backgroundColor () const; double colorSimilarity () const; void setColorSimilarity (double similarity); int processedColorSimilarity () const; void openColorSimilarityDialog (); void flashColorSimilarityToolBarItem (); signals: // If you connect to this signal, ignore the following // foregroundColorChanged() and backgroundColorChanged() signals void colorsSwapped (const kpColor &newForegroundColor, const kpColor &newBackgroundColor); void foregroundColorChanged (const kpColor &color); void backgroundColorChanged (const kpColor &color); void colorSimilarityChanged (double similarity, int processedSimilarity); public: // (only valid in slots connected to foregroundColorChanged()) kpColor oldForegroundColor () const; // (only valid in slots connected to backgroundColorChanged()) kpColor oldBackgroundColor () const; // (only valid in slots connected to colorSimilarityChanged()) double oldColorSimilarity () const; public slots: void setForegroundColor (const kpColor &color); void setBackgroundColor (const kpColor &color); private slots: void updateNameOrUrlLabel (); protected: // Eat color drops (which are usually accidental drags from one of our // child widgets) to prevent them from being pasted as text in the // main window (by kpMainWindow::dropEvent()). void dragEnterEvent (QDragEnterEvent *e) override; void dragMoveEvent (QDragMoveEvent *e) override; private: void adjustToOrientation (Qt::Orientation o); QBoxLayout *m_boxLayout; kpDualColorButton *m_dualColorButton; kpColorPalette *m_colorPalette; kpColorSimilarityToolBarItem *m_colorSimilarityToolBarItem; }; #endif // KP_COLOR_TOOLBAR_H diff --git a/widgets/toolbars/kpToolToolBar.h b/widgets/toolbars/kpToolToolBar.h index e0a42306..7adf60eb 100644 --- a/widgets/toolbars/kpToolToolBar.h +++ b/widgets/toolbars/kpToolToolBar.h @@ -1,123 +1,123 @@ /* Copyright (c) 2003-2007 Clarence Dang Copyright (c) 2011 Martin Koller All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef KP_TOOL_TOOL_BAR_H #define KP_TOOL_TOOL_BAR_H -#include +#include #include class QAbstractButton; class QBoxLayout; class QButtonGroup; class QGridLayout; class QWidget; class kpTool; class kpToolButton; class kpToolWidgetBase; class kpToolWidgetBrush; class kpToolWidgetEraserSize; class kpToolWidgetFillStyle; class kpToolWidgetLineWidth; class kpToolWidgetOpaqueOrTransparent; class kpToolWidgetSpraycanSize; class kpToolToolBar : public KToolBar { Q_OBJECT public: kpToolToolBar (const QString &name, int colsOrRows, QMainWindow *parent); ~kpToolToolBar () override; void registerTool(kpTool *tool); void unregisterTool(kpTool *tool); kpTool *tool () const; void selectTool (const kpTool *tool, bool reselectIfSameTool = false); kpTool *previousTool () const; void selectPreviousTool (); void hideAllToolWidgets (); // could this be cleaner (the tools have to access them individually somehow)? kpToolWidgetBrush *toolWidgetBrush () const { return m_toolWidgetBrush; } kpToolWidgetEraserSize *toolWidgetEraserSize () const { return m_toolWidgetEraserSize; } kpToolWidgetFillStyle *toolWidgetFillStyle () const { return m_toolWidgetFillStyle; } kpToolWidgetLineWidth *toolWidgetLineWidth () const { return m_toolWidgetLineWidth; } kpToolWidgetOpaqueOrTransparent *toolWidgetOpaqueOrTransparent () const { return m_toolWidgetOpaqueOrTransparent; } kpToolWidgetSpraycanSize *toolWidgetSpraycanSize () const { return m_toolWidgetSpraycanSize; } kpToolWidgetBase *shownToolWidget (int which) const; signals: void sigToolSelected (kpTool *tool); // tool may be 0 void toolWidgetOptionSelected (); private slots: void slotToolButtonClicked (); void slotToolActionActivated (); void adjustToOrientation(Qt::Orientation o); void slotIconSizeChanged(const QSize &); void slotToolButtonStyleChanged(Qt::ToolButtonStyle style); private: void addButton (QAbstractButton *button, Qt::Orientation o, int num); void adjustSizeConstraint(); int m_vertCols; QButtonGroup *m_buttonGroup; QWidget *m_baseWidget; QBoxLayout *m_baseLayout; QGridLayout *m_toolLayout; kpToolWidgetBrush *m_toolWidgetBrush; kpToolWidgetEraserSize *m_toolWidgetEraserSize; kpToolWidgetFillStyle *m_toolWidgetFillStyle; kpToolWidgetLineWidth *m_toolWidgetLineWidth; kpToolWidgetOpaqueOrTransparent *m_toolWidgetOpaqueOrTransparent; kpToolWidgetSpraycanSize *m_toolWidgetSpraycanSize; QList m_toolWidgets; QList m_toolButtons; kpTool *m_previousTool, *m_currentTool; }; #endif // KP_TOOL_TOOL_BAR_H diff --git a/widgets/toolbars/options/kpToolWidgetBase.h b/widgets/toolbars/options/kpToolWidgetBase.h index ad9251b7..d99ea3e6 100644 --- a/widgets/toolbars/options/kpToolWidgetBase.h +++ b/widgets/toolbars/options/kpToolWidgetBase.h @@ -1,114 +1,114 @@ /* Copyright (c) 2003-2007 Clarence Dang All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef KP_TOOL_WIDGET_BASE_H #define KP_TOOL_WIDGET_BASE_H -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include class QMouseEvent; // TODO: This is a crazy and overcomplicated class that invents its own (buggy) // layout management. It should be simplified or removed. class kpToolWidgetBase : public QFrame { Q_OBJECT public: // (must provide a for config to work) kpToolWidgetBase (QWidget *parent, const QString &name); ~kpToolWidgetBase () override; public: void addOption (const QPixmap &pixmap, const QString &toolTip = QString()); void startNewOptionRow (); // Call this at the end of your constructor. // If the default row & col could not be read from the config, // & are passed to setSelected(). void finishConstruction (int fallBackRow, int fallBackCol); private: QList spreadOutElements (const QList &sizes, int maxSize); public: // (only have to use these if you don't use finishConstruction()) // (rereads from config file) QPair defaultSelectedRowAndCol () const; int defaultSelectedRow () const; int defaultSelectedCol () const; void saveSelectedAsDefault () const; void relayoutOptions (); public: int selectedRow () const; int selectedCol () const; int selected () const; bool hasPreviousOption (int *row = nullptr, int *col = nullptr) const; bool hasNextOption (int *row = nullptr, int *col = nullptr) const; public slots: // (returns whether and were in range) virtual bool setSelected (int row, int col, bool saveAsDefault); bool setSelected (int row, int col); bool selectPreviousOption (); bool selectNextOption (); signals: void optionSelected (int row, int col); protected: bool event (QEvent *e) override; void mousePressEvent (QMouseEvent *e) override; void paintEvent (QPaintEvent *e) override; QWidget *m_baseWidget; QList < QList > m_pixmaps; QList < QList > m_toolTips; QList < QList > m_pixmapRects; int m_selectedRow, m_selectedCol; }; #endif // KP_TOOL_WIDGET_BASE_H diff --git a/widgets/toolbars/options/kpToolWidgetBrush.h b/widgets/toolbars/options/kpToolWidgetBrush.h index ff567d12..478c507a 100644 --- a/widgets/toolbars/options/kpToolWidgetBrush.h +++ b/widgets/toolbars/options/kpToolWidgetBrush.h @@ -1,80 +1,80 @@ /* Copyright (c) 2003-2007 Clarence Dang All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef KP_TOOL_WIDGET_BRUSH_H #define KP_TOOL_WIDGET_BRUSH_H #include "kpToolWidgetBase.h" #include "imagelib/kpColor.h" #include "layers/tempImage/kpTempImage.h" -#include +#include class kpToolWidgetBrush : public kpToolWidgetBase { Q_OBJECT public: kpToolWidgetBrush (QWidget *parent, const QString &name); ~kpToolWidgetBrush () override; private: QString brushName (int shape, int whichSize) const; public: int brushSize () const; bool brushIsDiagonalLine () const; struct DrawPackage { int row; int col; kpColor color; }; // Call the function returned by to render the current // brush onto an image/document, in . Pass the pointer returned by // to it. // // TODO: change function + data -> object kpTempImage::UserFunctionType drawFunction () const; static DrawPackage drawFunctionDataForRowCol (const kpColor &color, int row, int col); DrawPackage drawFunctionData (const kpColor &color) const; signals: void brushChanged (); protected slots: bool setSelected (int row, int col, bool saveAsDefault) override; }; #endif // KP_TOOL_WIDGET_BRUSH_H diff --git a/widgets/toolbars/options/kpToolWidgetEraserSize.h b/widgets/toolbars/options/kpToolWidgetEraserSize.h index c2dd5d8b..67cd3736 100644 --- a/widgets/toolbars/options/kpToolWidgetEraserSize.h +++ b/widgets/toolbars/options/kpToolWidgetEraserSize.h @@ -1,81 +1,81 @@ /* Copyright (c) 2003-2007 Clarence Dang All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef KP_TOOL_WIDGET_ERASER_SIZE_H #define KP_TOOL_WIDGET_ERASER_SIZE_H #include "kpToolWidgetBase.h" #include "imagelib/kpColor.h" #include "layers/tempImage/kpTempImage.h" -#include +#include class kpColor; class kpToolWidgetEraserSize : public kpToolWidgetBase { Q_OBJECT public: kpToolWidgetEraserSize (QWidget *parent, const QString &name); ~kpToolWidgetEraserSize () override; int eraserSize () const; struct DrawPackage { int selected; kpColor color; }; // Call the function returned by to render the current // brush onto an image/document, in . Pass the pointer returned by // to it. // // is to same as but adds a black // border suitable as a cursor only. // // TODO: change function + data -> object kpTempImage::UserFunctionType drawFunction () const; kpTempImage::UserFunctionType drawCursorFunction () const; static DrawPackage drawFunctionDataForSelected (const kpColor &color, int selectedIndex); DrawPackage drawFunctionData (const kpColor &color) const; signals: void eraserSizeChanged (int size); protected slots: bool setSelected (int row, int col, bool saveAsDefault) override; }; #endif // KP_TOOL_WIDGET_ERASER_SIZE_H