MyScript Interactive Ink SDK 4.2.0
Editor.h
1// Copyright @ MyScript. All rights reserved.
2
3#pragma once
4
5#include <iink/ContentSelection.h>
6#include <iink/Engine.h>
7#include <iink/graphics/Point.h>
8#include <iink/graphics/Rectangle.h>
9#include <iink/MimeType.h>
10#include <iink/PlaceholderController.h>
11#include <iink/PointerEvent.h>
12#include <iink/text/IFontMetricsProvider.h>
13
14#include <cstdint>
15#include <memory>
16#include <type_traits>
17#include <vector>
18
19namespace myscript {
20namespace iink {
21
22class Engine;
23class Configuration;
24class ContentBlock;
25class ContentPart;
26class IEditorListener;
27class IGestureHandler;
28class IImagePainter;
29class MathSolverController;
30class ParameterSet;
31class Renderer;
32class ToolController;
33
34namespace graphics {
35
36class ICanvas;
37struct Transform;
38
39}
40
45{
46 ALLOWED = 0,
48 UNSUPPORTED = 1 << 0,
49 NULL_SELECTION = 1 << 1,
50 PARTIAL_BLOCKS = 1 << 2,
51 MULTIPLE_BLOCKS = 1 << 3,
53 TEXT_BLOCKS = 1 << 5,
54 MATH_BLOCKS = 1 << 6,
55 DRAWING_BLOCKS = 1 << 7,
56 GUIDES = 1 << 8,
57 INVALID = 1 << 9,
58 NON_INVERTIBLE = 1 << 10,
59 BAD_NUMERIC = 1 << 11,
60 HAS_ROTATION = 1 << 12,
61 HAS_SCALE = 1 << 13,
63 HAS_SHEAR = 1 << 15,
64 HAS_TRANSLATION = 1 << 16,
65};
66
72enum class TextFormat
73{
74 H1 = 0,
75 H2 = 1,
76 PARAGRAPH = 2,
77 LIST_BULLET = 3,
78 LIST_CHECKBOX = 4,
79 LIST_NUMBERED = 5,
80};
81
88{
89 IndentationLevels(size_t low_, size_t high_, size_t max_)
90 : low(low_), high(high_), max(max_) {}
91
92 size_t low;
93 size_t high;
94 size_t max;
95};
96
101{
102 NONE = 0,
103 LASSO = 1,
104 ITEM = 2,
105 RESIZE = 3,
106 REFLOW = 4
107};
108
116{
117public:
118
119 virtual ~Editor() = default;
120
126 virtual void addListener(std::shared_ptr<IEditorListener> listener) noexcept = 0;
127
133 virtual void removeListener(std::shared_ptr<IEditorListener> listener) noexcept = 0;
134
142 virtual void setGestureHandler(std::shared_ptr<IGestureHandler> handler) = 0;
143
149 virtual void removeGestureHandler() = 0;
150
156 virtual void setFontMetricsProvider(std::shared_ptr<myscript::iink::text::IFontMetricsProvider> fontMetricsProvider) noexcept = 0;
157
163 virtual std::shared_ptr<Engine> getEngine() noexcept = 0;
164
170 virtual std::shared_ptr<Renderer> getRenderer() noexcept = 0;
171
179 virtual std::shared_ptr<PlaceholderController> getPlaceholderController() = 0;
180
188 virtual std::shared_ptr<ToolController> getToolController() noexcept = 0;
189
197 virtual std::shared_ptr<MathSolverController> getMathSolverController() = 0;
198
204 virtual std::shared_ptr<ContentPart> getPart() noexcept = 0;
205
216 virtual void setPart(std::shared_ptr<ContentPart> part) = 0;
217
223 virtual void clear() = 0;
224
230 virtual bool canUndo() noexcept = 0;
231
236 virtual void undo() = 0;
237
243 virtual bool canRedo() noexcept = 0;
244
249 virtual void redo() = 0;
250
267 virtual int getUndoStackIndex() = 0;
268
278 virtual int getPossibleUndoCount() = 0;
279
289 virtual int getPossibleRedoCount() = 0;
290
304 virtual String getUndoRedoIdAt(int stackIndex) = 0;
305
326 virtual String pointerDown(float x, float y, int64_t t, float f, PointerType pointerType, int pointerId) = 0;
327
354 virtual String pointerDown(float x, float y, int64_t t, float f, float tilt, float orientation, PointerType pointerType, int pointerId) = 0;
355
373 virtual void pointerMove(float x, float y, int64_t t, float f, PointerType pointerType, int pointerId) = 0;
374
398 virtual void pointerMove(float x, float y, int64_t t, float f, float tilt, float orientation, PointerType pointerType, int pointerId) = 0;
399
416 virtual void pointerUp(float x, float y, int64_t t, float f, PointerType pointerType, int pointerId) = 0;
417
440 virtual void pointerUp(float x, float y, int64_t t, float f, float tilt, float orientation, PointerType pointerType, int pointerId) = 0;
441
447 virtual void pointerCancel(int pointerId) = 0;
448
464 virtual void pointerEvents(const std::vector<PointerEvent>& events, bool processGestures = true) = 0;
465
475 virtual void setViewSize(int width, int height) = 0;
476
484 virtual int getViewWidth() = 0;
485
493 virtual int getViewHeight() = 0;
494
503 virtual void clampViewOffset(graphics::Point& viewOffset) = 0;
504
514 virtual void setTheme(const String& styleSheet) = 0;
515
521 virtual String getTheme() const noexcept = 0;
522
528 virtual std::shared_ptr<ContentBlock> getRootBlock() = 0;
529
538 virtual std::shared_ptr<ContentBlock> getBlockById(const String& id) = 0;
539
550 virtual bool isEmpty(std::shared_ptr<ContentSelection> selection) = 0;
551
558 virtual std::vector<String> getSupportedAddBlockTypes() noexcept = 0;
559
567 virtual std::vector<MimeType> getSupportedAddBlockDataMimeTypes(const String& type) noexcept = 0;
568
587 virtual std::shared_ptr<ContentBlock> addBlock(float x, float y, const String& type) = 0;
588
613 virtual std::shared_ptr<ContentBlock> addBlock(float x, float y, const String& type, MimeType mimeType, const String& data) = 0;
614
639 virtual std::shared_ptr<ContentBlock> addImage(float x, float y, const String& inputFile, MimeType mimeType) = 0;
640
653 virtual void erase(std::shared_ptr<ContentSelection> selection) = 0;
654
664 virtual std::shared_ptr<ContentBlock> hitBlock(float x, float y) = 0;
665
677 virtual std::shared_ptr<ContentBlock> hitSubBlock(float x, float y) = 0;
678
689 virtual std::vector<ConversionState> getSupportedTargetConversionStates(std::shared_ptr<ContentSelection> selection) = 0;
690
706 virtual void convert(std::shared_ptr<ContentSelection> selection, ConversionState targetState) = 0;
707
717 virtual std::vector<MimeType> getSupportedExportMimeTypes(std::shared_ptr<ContentSelection> selection) = 0;
718
740 virtual String export_(std::shared_ptr<ContentSelection> selection, MimeType mimeType, std::shared_ptr<ParameterSet> overrideConfiguration = nullptr) = 0;
741
767 virtual void export_(std::shared_ptr<ContentSelection> selection, const String& outputFile, std::shared_ptr<IImagePainter> imagePainter, std::shared_ptr<ParameterSet> overrideConfiguration = nullptr) = 0;
768
794 virtual void export_(std::shared_ptr<ContentSelection> selection, const String& outputFile, MimeType mimeType, std::shared_ptr<IImagePainter> imagePainter, std::shared_ptr<ParameterSet> overrideConfiguration = nullptr) = 0;
795
805 virtual std::vector<MimeType> getSupportedImportMimeTypes(std::shared_ptr<ContentSelection> selection) = 0;
806
823 virtual void import_(MimeType mimeType, const String& data, std::shared_ptr<ContentSelection> selection = nullptr, std::shared_ptr<ParameterSet> overrideConfiguration = nullptr) = 0;
824
837 virtual void copy(std::shared_ptr<ContentSelection> selection) = 0;
838
856 virtual void paste(float x, float y) = 0;
857
863 virtual bool isIdle() noexcept = 0;
864
868 virtual void waitForIdle() noexcept = 0;
869
878 virtual bool isScrollAllowed() noexcept = 0;
879
885 virtual std::shared_ptr<Configuration> getConfiguration() noexcept = 0;
886
902 virtual void drawStroke(const std::vector<PointerEvent>& events, std::shared_ptr<graphics::ICanvas> canvas) = 0;
903
913 virtual bool hasSelection() = 0;
914
926 virtual std::shared_ptr<ContentSelection> getSelection() = 0;
927
941 virtual void setSelection(std::shared_ptr<ContentSelection> selection) = 0;
942
955 virtual std::shared_ptr<ContentSelection> hitSelection(float x, float y) = 0;
956
970 virtual std::vector<String> getIntersectingBlocks(std::shared_ptr<ContentSelection> selection) = 0;
971
985 virtual std::vector<String> getIncludedBlocks(std::shared_ptr<ContentSelection> selection) = 0;
986
987
1001 virtual std::underlying_type<TransformError>::type getTransformStatus(std::shared_ptr<ContentSelection> selection, const myscript::iink::graphics::Transform& transform) = 0;
1002
1018 virtual void transform(std::shared_ptr<ContentSelection> selection, const myscript::iink::graphics::Transform& transform) = 0;
1019
1033 virtual void applyStyle(std::shared_ptr<ContentSelection> selection, const String& style) = 0;
1034
1046 virtual std::vector<TextFormat> getSupportedTextFormats(std::shared_ptr<ContentSelection> selection) = 0;
1047
1060 virtual void setTextFormat(std::shared_ptr<ContentSelection> selection, TextFormat format) = 0;
1061
1072
1086
1097
1113 virtual void setSelectionType(std::shared_ptr<ContentSelection> selection, const String& type, bool forceSingleBlock) = 0;
1114
1127 virtual std::vector<String> getAvailableSelectionTypes(std::shared_ptr<ContentSelection> selection) = 0;
1128
1144 virtual IndentationLevels getIndentationLevels(std::shared_ptr<ContentSelection> selection) = 0;
1145
1166 virtual void indent(std::shared_ptr<ContentSelection> selection, int offset) = 0;
1167
1180 virtual myscript::iink::graphics::Rectangle getBox(std::shared_ptr<ContentSelection> selection) = 0;
1181
1195 virtual std::underlying_type<ConversionState>::type getConversionState(std::shared_ptr<ContentSelection> selection) = 0;
1196};
1197
1198}
1199}
Definition: Configuration.h:19
Definition: ContentBlock.h:22
Definition: ContentPart.h:25
Definition: ContentSelection.h:33
Definition: Editor.h:116
virtual std::shared_ptr< ContentSelection > getSelection()=0
virtual void setTheme(const String &styleSheet)=0
virtual int getPossibleUndoCount()=0
virtual bool isScrollAllowed() noexcept=0
virtual std::shared_ptr< PlaceholderController > getPlaceholderController()=0
virtual void setGestureHandler(std::shared_ptr< IGestureHandler > handler)=0
virtual void erase(std::shared_ptr< ContentSelection > selection)=0
virtual ContentSelectionMode getSelectionMode()=0
virtual void setFontMetricsProvider(std::shared_ptr< myscript::iink::text::IFontMetricsProvider > fontMetricsProvider) noexcept=0
virtual void drawStroke(const std::vector< PointerEvent > &events, std::shared_ptr< graphics::ICanvas > canvas)=0
virtual void removeListener(std::shared_ptr< IEditorListener > listener) noexcept=0
virtual std::vector< String > getAvailableSelectionTypes(std::shared_ptr< ContentSelection > selection)=0
virtual int getViewHeight()=0
virtual std::vector< TextFormat > getSupportedTextFormats(std::shared_ptr< ContentSelection > selection)=0
virtual std::shared_ptr< ContentBlock > getBlockById(const String &id)=0
virtual void clampViewOffset(graphics::Point &viewOffset)=0
virtual std::underlying_type< ConversionState >::type getConversionState(std::shared_ptr< ContentSelection > selection)=0
virtual std::shared_ptr< ContentPart > getPart() noexcept=0
virtual void setViewSize(int width, int height)=0
virtual bool canRedo() noexcept=0
virtual void undo()=0
virtual void setTextFormat(std::shared_ptr< ContentSelection > selection, TextFormat format)=0
virtual std::vector< String > getIntersectingBlocks(std::shared_ptr< ContentSelection > selection)=0
virtual int getPossibleRedoCount()=0
virtual std::vector< ContentSelectionMode > getAvailableSelectionModes()=0
virtual std::shared_ptr< ContentSelection > hitSelection(float x, float y)=0
virtual bool isIdle() noexcept=0
virtual std::shared_ptr< Engine > getEngine() noexcept=0
virtual std::vector< MimeType > getSupportedImportMimeTypes(std::shared_ptr< ContentSelection > selection)=0
virtual void applyStyle(std::shared_ptr< ContentSelection > selection, const String &style)=0
virtual myscript::iink::graphics::Rectangle getBox(std::shared_ptr< ContentSelection > selection)=0
virtual void removeGestureHandler()=0
virtual std::shared_ptr< ContentBlock > hitSubBlock(float x, float y)=0
virtual void addListener(std::shared_ptr< IEditorListener > listener) noexcept=0
virtual std::shared_ptr< ContentBlock > hitBlock(float x, float y)=0
virtual void pointerEvents(const std::vector< PointerEvent > &events, bool processGestures=true)=0
virtual std::shared_ptr< ContentBlock > getRootBlock()=0
virtual bool isEmpty(std::shared_ptr< ContentSelection > selection)=0
virtual void setSelectionMode(ContentSelectionMode mode)=0
virtual bool canUndo() noexcept=0
virtual std::vector< MimeType > getSupportedExportMimeTypes(std::shared_ptr< ContentSelection > selection)=0
virtual void setPart(std::shared_ptr< ContentPart > part)=0
virtual void convert(std::shared_ptr< ContentSelection > selection, ConversionState targetState)=0
virtual std::vector< MimeType > getSupportedAddBlockDataMimeTypes(const String &type) noexcept=0
virtual std::underlying_type< TransformError >::type getTransformStatus(std::shared_ptr< ContentSelection > selection, const myscript::iink::graphics::Transform &transform)=0
virtual std::shared_ptr< MathSolverController > getMathSolverController()=0
virtual void setSelection(std::shared_ptr< ContentSelection > selection)=0
virtual IndentationLevels getIndentationLevels(std::shared_ptr< ContentSelection > selection)=0
virtual void import_(MimeType mimeType, const String &data, std::shared_ptr< ContentSelection > selection=nullptr, std::shared_ptr< ParameterSet > overrideConfiguration=nullptr)=0
virtual std::shared_ptr< ContentBlock > addImage(float x, float y, const String &inputFile, MimeType mimeType)=0
virtual String getTheme() const noexcept=0
virtual void setSelectionType(std::shared_ptr< ContentSelection > selection, const String &type, bool forceSingleBlock)=0
virtual void paste(float x, float y)=0
virtual void pointerUp(float x, float y, int64_t t, float f, PointerType pointerType, int pointerId)=0
virtual std::vector< ConversionState > getSupportedTargetConversionStates(std::shared_ptr< ContentSelection > selection)=0
virtual std::shared_ptr< ContentBlock > addBlock(float x, float y, const String &type)=0
virtual std::vector< String > getIncludedBlocks(std::shared_ptr< ContentSelection > selection)=0
virtual int getUndoStackIndex()=0
virtual bool hasSelection()=0
virtual void redo()=0
virtual void waitForIdle() noexcept=0
virtual String export_(std::shared_ptr< ContentSelection > selection, MimeType mimeType, std::shared_ptr< ParameterSet > overrideConfiguration=nullptr)=0
virtual std::vector< String > getSupportedAddBlockTypes() noexcept=0
virtual String pointerDown(float x, float y, int64_t t, float f, PointerType pointerType, int pointerId)=0
virtual ~Editor()=default
virtual int getViewWidth()=0
virtual void transform(std::shared_ptr< ContentSelection > selection, const myscript::iink::graphics::Transform &transform)=0
virtual void pointerCancel(int pointerId)=0
virtual void indent(std::shared_ptr< ContentSelection > selection, int offset)=0
virtual String getUndoRedoIdAt(int stackIndex)=0
virtual void pointerMove(float x, float y, int64_t t, float f, PointerType pointerType, int pointerId)=0
virtual std::shared_ptr< Configuration > getConfiguration() noexcept=0
virtual std::shared_ptr< ToolController > getToolController() noexcept=0
virtual void clear()=0
virtual void copy(std::shared_ptr< ContentSelection > selection)=0
virtual std::shared_ptr< Renderer > getRenderer() noexcept=0
Definition: IImagePainter.h:19
Definition: MathSolverController.h:133
Definition: ParameterSet.h:16
Definition: PlaceholderController.h:38
Definition: Renderer.h:21
Definition: String.h:27
Definition: ToolController.h:31
Definition: ICanvas.h:26
TransformError
Definition: Editor.h:45
@ HAS_SCALE
Definition: Editor.h:61
@ TEXT_BLOCKS
Definition: Editor.h:53
@ INVALID
Definition: Editor.h:57
@ MATH_BLOCKS
Definition: Editor.h:54
@ NULL_SELECTION
Definition: Editor.h:49
@ ALLOWED
Definition: Editor.h:46
@ HAS_NEGATIVE_SCALE
Definition: Editor.h:62
@ HAS_SHEAR
Definition: Editor.h:63
@ GUIDES
Definition: Editor.h:56
@ MULTIPLE_BLOCKS
Definition: Editor.h:51
@ BAD_NUMERIC
Definition: Editor.h:59
@ BEAUTIFIED_BLOCKS
Definition: Editor.h:52
@ NON_INVERTIBLE
Definition: Editor.h:58
@ HAS_ROTATION
Definition: Editor.h:60
@ UNSUPPORTED
Definition: Editor.h:48
@ PARTIAL_BLOCKS
Definition: Editor.h:50
@ HAS_TRANSLATION
Definition: Editor.h:64
@ DRAWING_BLOCKS
Definition: Editor.h:55
TextFormat
Definition: Editor.h:73
ConversionState
Definition: ContentSelection.h:21
PointerType
Definition: PointerEvent.h:29
ContentSelectionMode
Definition: Editor.h:101
MimeType
Definition: MimeType.h:15
Definition: Configuration.h:10
Definition: Editor.h:88
IndentationLevels(size_t low_, size_t high_, size_t max_)
Definition: Editor.h:89
size_t max
Definition: Editor.h:94
size_t low
Definition: Editor.h:92
size_t high
Definition: Editor.h:93
Definition: PointerEvent.h:56
Definition: Transform.h:31