diff options
Diffstat (limited to 'chalk/sdk')
-rw-r--r-- | chalk/sdk/Makefile.am | 23 | ||||
-rw-r--r-- | chalk/sdk/kis_annotation.h | 89 | ||||
-rw-r--r-- | chalk/sdk/kis_canvas_controller.h | 200 | ||||
-rw-r--r-- | chalk/sdk/kis_canvas_observer.h | 55 | ||||
-rw-r--r-- | chalk/sdk/kis_canvas_subject.h | 192 | ||||
-rw-r--r-- | chalk/sdk/kis_debug_areas.h | 34 | ||||
-rw-r--r-- | chalk/sdk/kis_generic_registry.h | 166 | ||||
-rw-r--r-- | chalk/sdk/kis_global.h | 83 | ||||
-rw-r--r-- | chalk/sdk/kis_id.h | 108 | ||||
-rw-r--r-- | chalk/sdk/kis_integer_maths.h | 111 | ||||
-rw-r--r-- | chalk/sdk/kis_progress_display_interface.h | 76 | ||||
-rw-r--r-- | chalk/sdk/kis_progress_subject.cc | 29 | ||||
-rw-r--r-- | chalk/sdk/kis_progress_subject.h | 45 | ||||
-rw-r--r-- | chalk/sdk/kis_shared_ptr_vector.h | 70 | ||||
-rw-r--r-- | chalk/sdk/kis_undo_adapter.h | 67 |
15 files changed, 1348 insertions, 0 deletions
diff --git a/chalk/sdk/Makefile.am b/chalk/sdk/Makefile.am new file mode 100644 index 00000000..0c7f4c18 --- /dev/null +++ b/chalk/sdk/Makefile.am @@ -0,0 +1,23 @@ +KDE_OPTIONS = nofinal + +INCLUDES = $(KOFFICE_INCLUDES) $(KOPAINTER_INCLUDES) \ + $(all_includes) + +noinst_LTLIBRARIES = libchalksdk.la +libchalksdk_la_SOURCES = kis_progress_subject.cc +libchalksdk_la_METASOURCES = AUTO + +include_HEADERS = \ + kis_annotation.h \ + kis_canvas_controller.h \ + kis_canvas_observer.h \ + kis_canvas_subject.h \ + kis_global.h \ + kis_id.h \ + kis_integer_maths.h \ + kis_progress_display_interface.h \ + kis_progress_subject.h \ + kis_shared_ptr_vector.h \ + kis_undo_adapter.h \ + kis_generic_registry.h + diff --git a/chalk/sdk/kis_annotation.h b/chalk/sdk/kis_annotation.h new file mode 100644 index 00000000..0753af8f --- /dev/null +++ b/chalk/sdk/kis_annotation.h @@ -0,0 +1,89 @@ +/* + * This file is part of the KDE project + * + * Copyright (c) 2005 Boudewijn Rempt <boud@valdyas.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef _KIS_ANNOTATION_H_ +#define _KIS_ANNOTATION_H_ + +#include <ksharedptr.h> +#include "kis_shared_ptr_vector.h" + +#include <tqstring.h> +#include <tqcstring.h> +#include <tqmemarray.h> + +/** + * An data extension mechanism for Chalk. + * + * An annotation can be of something like a TQByteArray or a TQString op a more specific + * datatype that can be attached to an image (or maybe later, if needed, to a layer) + * and contains data that must be associated with an image for purposes of import/export. + * + * Annotations will be saved to chalk images and may be exported in filetypes that support + * them. + * + * Examples of annotations are EXIF data and ICC profiles. + */ +class KisAnnotation : public KShared { + + +public: + + /** + * Creates a new annotation object. The annotation object cannot be changed later + * + * @param type a non-localized string identifying the type of the annotation + * @param description a localized string describing the annotation + * @param data a binary blob containing the annotation data + */ + KisAnnotation(const TQString & type, const TQString & description, const TQByteArray & data) + : m_type(type), + m_description(description), + m_annotation(data) {}; + + /** + * @return a non-localized string identifiying the type of the annotation + */ + TQString & type() {return m_type;}; + + /** + * @return a localized string describing the type of the annotations + * for user interface purposes. + */ + TQString & description() {return m_description;}; + + /** + * @return a binary blob representation of this annotation + */ + TQByteArray & annotation() { return m_annotation;}; + +private: + + TQString m_type; + TQString m_description; + TQByteArray m_annotation; + +}; + +typedef KSharedPtr<KisAnnotation> KisAnnotationSP; +typedef KisSharedPtrVector<KisAnnotation> vKisAnnotationSP; +typedef vKisAnnotationSP::iterator vKisAnnotationSP_it; +typedef vKisAnnotationSP::const_iterator vKisAnnotationSP_cit; + +#endif // _KIS_ANNOTATION_H_ diff --git a/chalk/sdk/kis_canvas_controller.h b/chalk/sdk/kis_canvas_controller.h new file mode 100644 index 00000000..6ed8f1b9 --- /dev/null +++ b/chalk/sdk/kis_canvas_controller.h @@ -0,0 +1,200 @@ +/* + * Copyright (c) 2003 Patrick Julien <freak@codepimps.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef KIS_CANVAS_CONTROLLER_H_ +#define KIS_CANVAS_CONTROLLER_H_ + +#include <tqglobal.h> +#include <tqpoint.h> +#include <tqrect.h> +#include "kis_types.h" + +class TQWidget; +class KisTool; +class KisRect; +class KisPoint; +class KisCanvas; +class KisInputDevice; + +/** + * Interface for classes that implement a canvas; i.e., a widget where KisImages + * are painted onto. This is the "view" part of the model-view-controller paradigm; + * the naming is a confusing historical artefact. + */ +class KisCanvasController { +public: + KisCanvasController() {}; + virtual ~KisCanvasController() {}; + +public: + + /** + * @return the canvas object + */ + virtual KisCanvas *kiscanvas() const = 0; + + + /** + * @return the value of the horizontal scrollbar. + */ + virtual TQ_INT32 horzValue() const = 0; + + /** + * @return the value of the vertical scrollbar + */ + virtual TQ_INT32 vertValue() const = 0; + + /** + * Sets the horizontal and vertical scrollbars to the specified values + * + * @param x the value the horizontal scrollbar is set to + * @param y the value the vertical scrollbar is set to + */ + virtual void scrollTo(TQ_INT32 x, TQ_INT32 y) = 0; + + /** + * Tell all of the canvas to tqrepaint itself. + */ + virtual void updateCanvas() = 0; + + + /** + * Tell the canvas to tqrepaint the rectangle defined by x, y, w and h. + * The coordinates are image coordinates. + */ + virtual void updateCanvas(TQ_INT32 x, TQ_INT32 y, TQ_INT32 w, TQ_INT32 h) = 0; + + /** + * Tell the canvas tqrepaint the specified rectangle. The coordinates + * are image coordinates, not view coordinates. + */ + virtual void updateCanvas(const TQRect& rc) = 0; + + /** + * Increase the zoomlevel one step + */ + virtual void zoomIn() = 0; + + /** + * Increase the zoomlevel one step and make sure that x,y is the center point of the view. + * + * @param x The x coordinate of the visible point in image coordinates + * @param y the y coordinate of the visible point in image coordinates + */ + virtual void zoomIn(TQ_INT32 x, TQ_INT32 y) = 0; + + /** + * Decrease the zoomlevel one step + */ + virtual void zoomOut() = 0; + + + /** + * Decrease the zoomlevel one step and make sure that x,y is the center point of the view. + * + * @param x the x coordinate of the visible point in image coordinates + * @param y the y coordinate of the visible point in image coordinates + */ + virtual void zoomOut(TQ_INT32 x, TQ_INT32 y) = 0; + + /** + * To centre the view on the given point with the given zoom factor. + * + * @param x the x coordinate of the center point in image coordinates + * @param y the y coordinate of the center point in image coordinates + * @param zf the zoomfactor + */ + virtual void zoomAroundPoint(double x, double y, double zf) = 0; + + /** + * Make the rect defined by x, y, w and h visible, zooming in or + * out as necessary. The view will be centered around the center point + * of the specified rect. + */ + virtual void zoomTo(TQ_INT32 x, TQ_INT32 y, TQ_INT32 w, TQ_INT32 h) = 0; + + /** + * Make the rect defined by x, y, w and h visible, zooming in or + * out as necessary. The view will be centered around the center point + * of the specified rect. + */ + virtual void zoomTo(const TQRect& r) = 0; + + /** + * Make the rect defined by x, y, w and h visible, zooming in or + * out as necessary. The view will be centered around the center point + * of the specified rect. + */ + virtual void zoomTo(const KisRect& r) = 0; + + /** + * Conversion functions from view coordinates to image coordinates + * + * You can get the rectangle of the image that's visible using the + * viewToWindow() functions (KisCanvasController). E.g. + * viewToWindow(TQRect(0, 0, canvasWidth, canvasHeight)). + * + * Here, the view is the canvas widget in the view widget, and the window + * is the window on the image. + */ + virtual TQPoint viewToWindow(const TQPoint& pt) = 0; + virtual KisPoint viewToWindow(const KisPoint& pt) = 0; + virtual TQRect viewToWindow(const TQRect& rc) = 0; + virtual KisRect viewToWindow(const KisRect& rc) = 0; + virtual void viewToWindow(TQ_INT32 *x, TQ_INT32 *y) = 0; + + /** + * Conversion functions from image coordinates to view coordinates + */ + virtual TQPoint windowToView(const TQPoint& pt) = 0; + virtual KisPoint windowToView(const KisPoint& pt) = 0; + virtual TQRect windowToView(const TQRect& rc) = 0; + virtual KisRect windowToView(const KisRect& rc) = 0; + virtual void windowToView(TQ_INT32 *x, TQ_INT32 *y) = 0; + + /** + * Set the cursor shown when the pointer is over the canvas widget to + * the specified cursor. + * + * @param cursor the new cursor + * @return the old cursor + */ + virtual TQCursor setCanvasCursor(const TQCursor & cursor) = 0; + + /** + * Set the active input device to the specified input device, This + * could be a mouse, a stylus, an eraser or any other pointing input + * device. + * + * @param inputDevice the new input device + */ + virtual void setInputDevice(KisInputDevice inputDevice) = 0; + + /** + * @return the current input device, such as a mouse or a stylus + */ + virtual KisInputDevice currentInputDevice() const = 0; + + +private: + KisCanvasController(const KisCanvasController&); + KisCanvasController& operator=(const KisCanvasController&); +}; + +#endif // KIS_CANVAS_CONTROLLER_H_ + diff --git a/chalk/sdk/kis_canvas_observer.h b/chalk/sdk/kis_canvas_observer.h new file mode 100644 index 00000000..e62d23f3 --- /dev/null +++ b/chalk/sdk/kis_canvas_observer.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2003 Patrick Julien <freak@codepimps.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef KIS_CANVAS_OBSERVER_H_ +#define KIS_CANVAS_OBSERVER_H_ + +class KisCanvasSubject; + +/** + * This is the base interface plugins use to implement the Observer + * design pattern. Observer can register themselves with an implementation + * of KisCanvasSubject. The KisCanvasSubject will then call update() + * on all registered observers whenever something interesting has happened. + * + * (This is something my predecessor should have done with signals and slots, + * I think...) + */ +class KisCanvasObserver { +public: + KisCanvasObserver() {}; + virtual ~KisCanvasObserver() {}; + +public: + /** + * Implement this function to query the KisCanvasSubject implementation + * about state that may be interesting, such as current paint color and + * so on. + * + * @param subject the KisCanvasSubject that may know something that's + * interesting for us. + */ + virtual void update(KisCanvasSubject *subject) = 0; + +private: + KisCanvasObserver(const KisCanvasObserver&); + KisCanvasObserver& operator=(const KisCanvasObserver&); +}; + +#endif // KIS_CANVAS_OBSERVER_H_ + diff --git a/chalk/sdk/kis_canvas_subject.h b/chalk/sdk/kis_canvas_subject.h new file mode 100644 index 00000000..07713576 --- /dev/null +++ b/chalk/sdk/kis_canvas_subject.h @@ -0,0 +1,192 @@ +/* + * Copyright (c) 2003 Patrick Julien <freak@codepimps.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef KIS_CANVAS_SUBJECT_H_ +#define KIS_CANVAS_SUBJECT_H_ + +#include "kis_types.h" +#include "kis_id.h" + +class KisDoc; +class KisBrush; +class KisCanvasController; +class KisCanvasObserver; +class KisGradient; +class KisPattern; +class KisPaintOpFactory; +class KisToolControllerInterface; +class KisUndoAdapter; +class KisProgressDisplayInterface; +class KisSelectionManager; +class TQWidget; +class TQCursor; +class KisColor; +class KoPaletteManager; +class KisProfile; +class KisPaintOpSettings; +class KisPerspectiveGridManager; + +/** + * KisCanvasSubject is part of the Observer pattern. Classes implementing KisCanvasObserver + * that have attached themselves to a class implementing this interface will be notified + * whenever any of the methods defined in this class will return something different. + * + * Historical notes: This class has grown a bit an now seems to be the abstract definition + * of the View part in the Model-View-Controller pattern. We need to fix this! + */ +class KisCanvasSubject { + +public: + KisCanvasSubject() {}; + virtual ~KisCanvasSubject() {}; + +public: + + /** + * From now on, the observer will be notified of changes in + * brush, foreground color, background color, pattern, gradient + * and paintop + */ + virtual void attach(KisCanvasObserver *observer) = 0; + + /** + * From now on, the specified observer will no longer be informed + * of changes. + */ + virtual void detach(KisCanvasObserver *observer) = 0; + + /** + * Calling this method will notify all observers. Do not call this + * method from the Update method of a KisCanvasObserver! + */ + virtual void notifyObservers() = 0; + + /** + * @return the image that is currently active. + */ + virtual KisImageSP currentImg() const = 0; + + /** + * @return the background color + */ + virtual KisColor bgColor() const = 0; + + /** + * Set the background color. This should cause all observers to be notified. Do not call from KisCanvasObserver::update()! + * + * @param c the new background color + */ + virtual void setBGColor(const KisColor& c) = 0; + + /** + * @return the currently set foreground or painting color + */ + virtual KisColor fgColor() const = 0; + + /** + * Set the foreground or painting color. This should cause all observers to be notified. Do not call from KisCanvasObserver::update()! + * + * @param c the new foreground color + */ + virtual void setFGColor(const KisColor& c) = 0; + + /** + * @return the exposure value. This determines which exposure of multiple exposure or HDR images will be displayed + */ + virtual float HDRExposure() const = 0; + + /** + * Set the exposure value. This determines which exposure of multiple exposure or HDR images will be displayed. All observers should be notified. + * + * @param exposure the new exposure value + */ + virtual void setHDRExposure(float exposure) = 0; + + /** + * @return the current brush object. + */ + virtual KisBrush *currentBrush() const = 0; + + /** + * @return the current pattern object. + */ + virtual KisPattern *currentPattern() const = 0; + + /** + * @return the current gradient object + */ + virtual KisGradient *currentGradient() const = 0; + + /** + * @return the identification of the current paintop object, not the paintop object itself. + */ + virtual KisID currentPaintop() const = 0; + + /** + * @return the settings for the current paintop object, or 0 if there are no options set. + */ + virtual const KisPaintOpSettings *currentPaintopSettings() const = 0; + + /** + * @return the currently applied zoom factor. XXX: Shouldn't this be in the canvas controller? + */ + virtual double zoomFactor() const = 0; + + /** + * retrieve the undo adapater -- there is one undo adapter + * per document, and it collects all transactions + */ + virtual KisUndoAdapter *undoAdapter() const = 0; + + /** + * @return the interface to the canvas widget + */ + virtual KisCanvasController *canvasController() const = 0; + + /// XXX: Remove this method + virtual KisToolControllerInterface *toolController() const = 0; + + /// XXX: Remove this method + virtual KisDoc * document() const = 0; + + /// XXX: Remove this method + virtual KisProgressDisplayInterface *progressDisplay() const = 0; + + /// XXX: Remove this method + virtual KisSelectionManager * selectionManager() = 0; + + /// XXX: Remove this method + virtual KoPaletteManager * paletteManager() = 0; + + /** + * Get the profile that this view uses to display itself on + * he monitor. + */ + virtual KisProfile * monitorProfile() = 0; + + /** + * Get the perspective grid manager. + */ + virtual KisPerspectiveGridManager* perspectiveGridManager() = 0; +private: + KisCanvasSubject(const KisCanvasSubject&); + KisCanvasSubject& operator=(const KisCanvasSubject&); +}; + +#endif // KIS_CANVAS_SUBJECT_H_ + diff --git a/chalk/sdk/kis_debug_areas.h b/chalk/sdk/kis_debug_areas.h new file mode 100644 index 00000000..67cb3566 --- /dev/null +++ b/chalk/sdk/kis_debug_areas.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2005 Boudewijn Rempt <boud@valdyas.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#ifndef KIS_DEBUG_AREAS_H_ +#define KIS_DEBUG_AREAS_H_ + +#define DBG_AREA_CORE 41001 +#define DBG_AREA_REGISTRY 40002 +#define DBG_AREA_TOOLS 41003 +#define DBG_AREA_CMS 41004 +#define DBG_AREA_FILTERS 41005 +#define DBG_AREA_PLUGINS 41006 +#define DBG_AREA_UI 41007 +#define DBG_AREA_FILE 41008 +#define DBG_AREA_MATH 41009 +#define DBG_AREA_RENDER 41010 +#define DBG_AREA_SCRIPT 41011 + + +#endif diff --git a/chalk/sdk/kis_generic_registry.h b/chalk/sdk/kis_generic_registry.h new file mode 100644 index 00000000..a806ea50 --- /dev/null +++ b/chalk/sdk/kis_generic_registry.h @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2004 Cyrille Berger <cberger@cberger.net> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef _KIS_GENERIC_REGISTRY_H_ +#define _KIS_GENERIC_REGISTRY_H_ + +#include <map> + +#include <tqstring.h> +#include <kdebug.h> + +#include <kis_id.h> + +/** + * Base class for registry objects in Chalk. Chalk registries + * contain resources such as filters, tools or colorspaces. + * + * Items are mapped by KisID. A KisID is the combination of + * a non-localized string that can be used in files and a + * user-visible, translated string that can be used in the + * user interface. + */ +template<typename _T> +class KisGenericRegistry { +protected: + typedef std::map<KisID, _T> storageMap; +public: + KisGenericRegistry() { }; + virtual ~KisGenericRegistry() { }; +public: + + /** + * add an object to the registry + * @param item the item to add (NOTE: _T must have an KisID id() function) + */ + void add(_T item) + { + m_storage.insert( typename storageMap::value_type( item->id(), item) ); + } + /** + * add an object to the registry + * @param id the id of the object + * @param item the item + */ + void add(KisID id, _T item) + { + m_storage.insert(typename storageMap::value_type(id, item)); + } + /** + * This function remove an item from the registry + * @return the object which have been remove from the registry and which can be safely delete + */ + _T remove(const KisID& name) + { + _T p = 0; + typename storageMap::iterator it = m_storage.find(name); + if (it != m_storage.end()) { + m_storage.erase(it); + p = it->second; + } + return p; + } + /** + * This function remove an item from the registry + * @param id the identifiant of the object + * @return the object which have been remove from the registry and which can be safely delete + */ + _T remove(const TQString& id) + { + return remove(KisID(id,"")); + } + /** + * This function allow to get an object from its KisID + * @param name the KisID of the object + * @return _T the object + */ + _T get(const KisID& name) const + { + _T p = 0; + typename storageMap::const_iterator it = m_storage.find(name); + if (it != m_storage.end()) { + p = it->second; + } + return p; + } + + /** + * Get a single entry based on the identifying part of KisID, not the + * the descriptive part. + */ + _T get(const TQString& id) const + { + return get(KisID(id, "")); + } + + /** + * @param id + * @return true if there is an object corresponding to id + */ + bool exists(const KisID& id) const + { + typename storageMap::const_iterator it = m_storage.find(id); + return (it != m_storage.end()); + } + + bool exists(const TQString& id) const + { + return exists(KisID(id, "")); + } + /** + * This function allow to search a KisID from the name. + * @param t the name to search + * @param result The result is filled in this variable + * @return true if the search has been successfull, false otherwise + */ + bool search(const TQString& t, KisID& result) const + { + for(typename storageMap::const_iterator it = m_storage.begin(); + it != m_storage.end(); ++it) + { + if(it->first.name() == t) + { + result = it->first; + return true; + } + } + return false; + } + + /** This function return a list of all the keys + */ + KisIDList listKeys() const + { + KisIDList list; + typename storageMap::const_iterator it = m_storage.begin(); + typename storageMap::const_iterator endit = m_storage.end(); + while( it != endit ) + { + list.append(it->first); + ++it; + } + return list; + } + +protected: + KisGenericRegistry(const KisGenericRegistry&) { }; + KisGenericRegistry operator=(const KisGenericRegistry&) { }; + storageMap m_storage; +}; + +#endif diff --git a/chalk/sdk/kis_global.h b/chalk/sdk/kis_global.h new file mode 100644 index 00000000..249d312e --- /dev/null +++ b/chalk/sdk/kis_global.h @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2000 Matthias Elter <elter@kde.org> + * Copyright (c) 2002 Patrick Julien <freak@codepimps.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#ifndef KISGLOBAL_H_ +#define KISGLOBAL_H_ + +#include <config.h> +#include LCMS_HEADER +#include <limits.h> +#include <tqglobal.h> +#include <kglobal.h> + +#define KRITA_VERSION VERSION + +const TQ_UINT8 TQ_UINT8_MAX = UCHAR_MAX; +const TQ_UINT16 TQ_UINT16_MAX = 65535; + +const TQ_INT32 TQ_INT32_MAX = (2147483647); +const TQ_INT32 TQ_INT32_MIN = (-2147483647-1); + +const TQ_UINT8 OPACITY_TRANSPARENT = 0; +const TQ_UINT8 OPACITY_OPAQUE = UCHAR_MAX; + +const TQ_UINT8 MAX_SELECTED = UCHAR_MAX; +const TQ_UINT8 MIN_SELECTED = 0; +const TQ_UINT8 SELECTION_THRESHOLD = 1; + +enum enumCursorStyle { + CURSOR_STYLE_TOOLICON = 0, + CURSOR_STYLE_CROSSHAIR = 1, + CURSOR_STYLE_POINTER = 2, + CURSOR_STYLE_OUTLINE = 3 +}; + +enum enumResourceTypes { + RESOURCE_PAINTOP, + RESOURCE_FILTER, + RESOURCE_TOOL, + RESOURCE_COLORSPACE +}; + +/* + * Most wacom pads have 512 levels of pressure; TQt only supports 256, and even + * this is downscaled to 127 levels because the line would be too jittery, and + * the amount of tqmasks take too much memory otherwise. + */ +const TQ_INT32 PRESSURE_LEVELS= 127; +const double PRESSURE_MIN = 0.0; +const double PRESSURE_MAX = 1.0; +const double PRESSURE_DEFAULT = (PRESSURE_MAX - PRESSURE_MIN) / 2; +const double PRESSURE_THRESHOLD = 5.0 / 255.0; + +#define CLAMP(x,l,u) ((x)<(l)?(l):((x)>(u)?(u):(x))) + + +namespace chalk { + + // String constants for palettes and palette widgets + const TQString TOOL_OPTION_WIDGET ("tooloptions"); + + const TQString CONTROL_PALETTE ("controlpalette"); + const TQString PAINTBOX ("paintbox"); + const TQString COLORBOX ("colorbox"); + const TQString LAYERBOX ("layerbox"); +} + +#endif // KISGLOBAL_H_ + diff --git a/chalk/sdk/kis_id.h b/chalk/sdk/kis_id.h new file mode 100644 index 00000000..d15c5f27 --- /dev/null +++ b/chalk/sdk/kis_id.h @@ -0,0 +1,108 @@ +/* + * This file is part of the KDE project + * + * Copyright (c) 2005 Boudewijn Rempt <boud@valdyas.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef _KIS_ID_H_ +#define _KIS_ID_H_ + +#include <tqvaluelist.h> +#include <tqstring.h> + +/** + * Chalk has a large number of extensible resources. Think: + * + * - Brushes + * - Palettes + * - Patterns + * - Gradients + * - Color models + * - Filters + * - Composition operations + * - Paint operations + * - Tools + * - Docker tabs + * + * and more... + * + * Many of these resources are stored in KisGenericRegistry-based + * registries. If we store these resources with a descriptive string + * as a key use the same string in our UI, then our UI will not be + * localizable, because the identifications of particular resources + * will be stored in files, and those files need to be exchangeable. + * + * So, instead we use and ID class that couples an identification + * string that will be the same across all languages, an i18n-able + * string that will be used in comboboxes and that has a fast equality + * operator to make it well suited for use as key in a registry map. + * + * That last bit has not been solved yet. + * + */ +class KisID { + + +public: + + KisID() : m_id(TQString()), m_name(TQString()) {} + + KisID(const TQString & id, const TQString & name = TQString()) + : m_id(id), + m_name(name) {}; + + TQString id() const { return m_id; }; + TQString name() const { return m_name; }; + + friend inline bool operator==(const KisID &, const KisID &); + friend inline bool operator!=(const KisID &, const KisID &); + friend inline bool operator<(const KisID &, const KisID &); + friend inline bool operator>(const KisID &, const KisID &); + +private: + + TQString m_id; + TQString m_name; + +}; + +inline bool operator==(const KisID &v1, const KisID &v2) +{ + return v1.m_id == v2.m_id; +} + +inline bool operator!=(const KisID &v1, const KisID &v2) +{ + return v1.m_id != v2.m_id; +} + + +inline bool operator<(const KisID &v1, const KisID &v2) +{ + return v1.m_id < v2.m_id; +} + + +inline bool operator>(const KisID &v1, const KisID &v2) +{ + return v1.m_id < v2.m_id; +} + + +typedef TQValueList<KisID> KisIDList; + +#endif // _KIS_ID_H_ diff --git a/chalk/sdk/kis_integer_maths.h b/chalk/sdk/kis_integer_maths.h new file mode 100644 index 00000000..c8db9aee --- /dev/null +++ b/chalk/sdk/kis_integer_maths.h @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2005 Adrian Page <adrian@pagenet.plus.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef KIS_INTEGER_MATHS_H +#define KIS_INTEGER_MATHS_H + +#define UINT8_MAX 255u +#define UINT8_MIN 0u + +#define UINT16_MAX 65535u +#define UINT16_MIN 0u + +#define UINT32_MAX (4294967295u) +#define UINT32_MIN 0u + +#define INT16_MAX 32767 +#define INT16_MIN -32768 + +/// take a and scale it up by 256*b/255 +inline uint UINT8_SCALEBY(uint a, uint b) +{ + uint c = a * b + 0x80u; + return (c >> 8) + c; +} + +inline uint UINT8_MULT(uint a, uint b) +{ + uint c = a * b + 0x80u; + return ((c >> 8) + c) >> 8; +} + +inline uint UINT8_DIVIDE(uint a, uint b) +{ + uint c = (a * UINT8_MAX + (b / 2u)) / b; + return c; +} + +inline uint UINT8_BLEND(uint a, uint b, uint alpha) +{ + // Basically we do a*alpha + b*(1-alpha) + // However refactored to (a-b)*alpha + b since that saves a multiplication + // Signed arithmetic is needed since a-b might be negative + int c = ((int(a) - int(b)) * int(alpha)) >> 8; + + return uint(c + b); +} + +inline uint UINT16_MULT(uint a, uint b) +{ + uint c = a * b + 0x8000u; + return ((c >> 16) + c) >> 16; +} + +inline int INT16_MULT(int a, int b) +{ + return (a*b) / INT16_MAX; +} + +inline uint UINT16_DIVIDE(uint a, uint b) +{ + uint c = (a * UINT16_MAX + (b / 2u)) / b; + return c; +} + +inline uint UINT16_BLEND(uint a, uint b, uint alpha) +{ + // Basically we do a*alpha + b*(1-alpha) + // However refactored to (a-b)*alpha + b since that saves a multiplication + // Signed arithmetic is needed since a-b might be negative + int c = ((int(a) - int(b)) * int(alpha)) >> 16; + return uint(c + b); +} + +inline uint UINT8_TO_UINT16(uint c) +{ + return c | (c<<8); +} + +inline uint UINT16_TO_UINT8(uint c) +{ + //return round(c / 257.0); + //For all UINT16 this calculation is the same and a lot faster (off by c/65656 which for every c is 0) + c = c - (c >> 8) + 128; + return c >>8; +} + +inline int INT16_BLEND(int a, int b, uint alpha) +{ + // Basically we do a*alpha + b*(1-alpha) + // However refactored to (a-b)*alpha + b since that saves a multiplication + int c = ((int(a) - int(b)) * int(alpha)) >> 16; + return c + b; +} + +#endif + diff --git a/chalk/sdk/kis_progress_display_interface.h b/chalk/sdk/kis_progress_display_interface.h new file mode 100644 index 00000000..2674c6ab --- /dev/null +++ b/chalk/sdk/kis_progress_display_interface.h @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2004 Adrian Page <adrian@pagenet.plus.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef KIS_PROGRESS_DISPLAY_INTERFACE_H_ +#define KIS_PROGRESS_DISPLAY_INTERFACE_H_ + +class KisProgressSubject; + + +namespace KisProgress { + + const int ProgressEventBase = TQEvent::User + 42 + 42; + + class UpdateEvent : TQCustomEvent { + + public: + + UpdateEvent(int percent) : TQCustomEvent(ProgressEventBase + 1), m_percent(percent) {}; + int m_percent; + }; + + class UpdateStageEvent : TQCustomEvent { + + public: + + UpdateStageEvent(const TQString & stage, int percent) : TQCustomEvent(ProgressEventBase + 2 ), m_stage(stage), m_percent(percent) {}; + TQString m_stage; + int m_percent; + }; + + class DoneEvent : TQCustomEvent { + DoneEvent() : TQCustomEvent(ProgressEventBase + 3){}; + }; + + class ErrorEvent : TQCustomEvent { + ErrorEvent() : TQCustomEvent(ProgressEventBase + 4){}; + }; + + class DestroyedEvent: TQCustomEvent { + DestroyedEvent() : TQCustomEvent(ProgressEventBase + 5){}; + }; + + +} + + + +class KisProgressDisplayInterface { +public: + KisProgressDisplayInterface() {} + virtual ~KisProgressDisplayInterface() {} + + virtual void setSubject(KisProgressSubject *subject, bool modal, bool canCancel) = 0; + +private: + KisProgressDisplayInterface(const KisProgressDisplayInterface&); + KisProgressDisplayInterface& operator=(const KisProgressDisplayInterface&); +}; + +#endif // KIS_PROGRESS_DISPLAY_INTERFACE_H_ + diff --git a/chalk/sdk/kis_progress_subject.cc b/chalk/sdk/kis_progress_subject.cc new file mode 100644 index 00000000..fa53086b --- /dev/null +++ b/chalk/sdk/kis_progress_subject.cc @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2002 Patrick Julien <freak@codepimps.org> + * 2004 Adrian Page <adrian@pagenet.plus.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include <kdebug.h> + +#include "kis_progress_subject.h" + +KisProgressSubject::~KisProgressSubject() +{ +} + +#include "kis_progress_subject.moc" + diff --git a/chalk/sdk/kis_progress_subject.h b/chalk/sdk/kis_progress_subject.h new file mode 100644 index 00000000..59a8acb1 --- /dev/null +++ b/chalk/sdk/kis_progress_subject.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2002 Patrick Julien <freak@codepimps.org> + * 2004 Adrian Page <adrian@pagenet.plus.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#ifndef KIS_PROGRESS_SUBJECT_H_ +#define KIS_PROGRESS_SUBJECT_H_ + +#include <tqobject.h> +#include <koffice_export.h> + +class KRITAUI_EXPORT KisProgressSubject : public TQObject { + Q_OBJECT + TQ_OBJECT + +protected: + KisProgressSubject() {}; + KisProgressSubject(TQObject * tqparent, const char * name) : TQObject(tqparent, name) {}; + virtual ~KisProgressSubject(); + +public: + virtual void cancel() = 0; + +signals: + void notifyProgress(int percent); + void notifyProgressStage(const TQString& stage, int percent); + void notifyProgressDone(); + void notifyProgressError(); +}; + +#endif // KIS_PROGRESS_SUBJECT_H_ + diff --git a/chalk/sdk/kis_shared_ptr_vector.h b/chalk/sdk/kis_shared_ptr_vector.h new file mode 100644 index 00000000..679bdd9f --- /dev/null +++ b/chalk/sdk/kis_shared_ptr_vector.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2004 Adrian Page <adrian@pagenet.plus.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef KIS_SHARED_PTR_VECTOR_H +#define KIS_SHARED_PTR_VECTOR_H + +#include <tqvaluevector.h> + +#include <ksharedptr.h> + +/** + * TQValueVector does not always destroy an element when it is erased. + * If the items it is holding are KSharedPtr, this can result in hidden + * references to objects that cannot be accounted for. This class + * sets the KSharedPtr to 0 on erase, which dereferences the object as + * expected. + */ +template <class T> +class KisSharedPtrVector : public TQValueVector< KSharedPtr<T> > +{ + typedef TQValueVector< KSharedPtr<T> > super; +public: + KisSharedPtrVector() {} + + void pop_back() + { + if (!super::empty()) { + super::back() = 0; + super::pop_back(); + } + } + + typename super::iterator erase(typename super::iterator it) + { + *it = 0; + return super::erase(it); + } + + typename super::iterator erase(typename super::iterator first, typename super::iterator last) + { + tqFill(first, last, 0); + return super::erase(first, last); + } + + bool tqcontains(KSharedPtr<T> ptr) const + { + for (int i = 0, n = super::count(); i < n; ++i) + if (super::at(i) == ptr) + return true; + return false; + } +}; + +#endif // KIS_SHARED_PTR_VECTOR_H + diff --git a/chalk/sdk/kis_undo_adapter.h b/chalk/sdk/kis_undo_adapter.h new file mode 100644 index 00000000..cb9172ee --- /dev/null +++ b/chalk/sdk/kis_undo_adapter.h @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2003 Patrick Julien <freak@codepimps.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef KIS_UNDO_ADAPTER_H_ +#define KIS_UNDO_ADAPTER_H_ + +#include <tqglobal.h> + +class TQString; +class KCommand; + +/** + * Undo listeners want to be notified of undo and redo actions. + * add notification is given _before_ the command is added to the + * stack. + * execute notification is given on undo and redo + */ +class KisCommandHistoryListener { + +public: + + KisCommandHistoryListener(){}; + + virtual void notifyCommandAdded(KCommand * cmd) = 0; + virtual void notifyCommandExecuted(KCommand * cmd) = 0; +}; + +class KisUndoAdapter { +public: + KisUndoAdapter() {}; + virtual ~KisUndoAdapter() {}; + +public: + + virtual void setCommandHistoryListener(const KisCommandHistoryListener *) = 0; + virtual void removeCommandHistoryListener(const KisCommandHistoryListener *) = 0; + + virtual KCommand * presentCommand() = 0; + virtual void addCommand(KCommand *cmd) = 0; + virtual void setUndo(bool undo) = 0; + virtual bool undo() const = 0; + virtual void beginMacro(const TQString& macroName) = 0; + virtual void endMacro() = 0; + +private: + KisUndoAdapter(const KisUndoAdapter&); + KisUndoAdapter& operator=(const KisUndoAdapter&); +}; + + +#endif // KIS_UNDO_ADAPTER_H_ + |