OSDN Git Service

Shell Extension for Windows 11 or later (5)
[winmerge-jp/winmerge-jp.git] / Src / WinIMergeLib.h
1 /////////////////////////////////////////////////////////////////////////////\r
2 //    License (GPLv2+):\r
3 //    This program is free software; you can redistribute it and/or modify\r
4 //    it under the terms of the GNU General Public License as published by\r
5 //    the Free Software Foundation; either version 2 of the License, or\r
6 //    (at your option) any later version.\r
7 //\r
8 //    This program is distributed in the hope that it will be useful, but\r
9 //    WITHOUT ANY WARRANTY; without even the implied warranty of\r
10 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
11 //    General Public License for more details.\r
12 //\r
13 //    You should have received a copy of the GNU General Public License\r
14 //    along with this program; if not, write to the Free Software\r
15 //    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
16 /////////////////////////////////////////////////////////////////////////////\r
17 \r
18 #pragma once\r
19 \r
20 #include <Windows.h>\r
21 #include <wtypes.h>\r
22 \r
23 struct IImgMergeWindow\r
24 {\r
25         enum INSERTION_DELETION_DETECTION_MODE {\r
26                 INSERTION_DELETION_DETECTION_NONE = 0, INSERTION_DELETION_DETECTION_VERTICAL, INSERTION_DELETION_DETECTION_HORIZONTAL\r
27         };\r
28         enum OVERLAY_MODE {\r
29                 OVERLAY_NONE = 0, OVERLAY_XOR, OVERLAY_ALPHABLEND, OVERLAY_ALPHABLEND_ANIM\r
30         };\r
31         enum EVENT_TYPE {\r
32                 LBUTTONDOWN = 0, LBUTTONUP, LBUTTONDBLCLK, \r
33                 RBUTTONDOWN,     RBUTTONUP, RBUTTONDBLCLK,\r
34                 MOUSEMOVE, MOUSEWHEEL, CONTEXTMENU,\r
35                 KEYDOWN, KEYUP,\r
36                 SIZE, HSCROLL, VSCROLL, SETFOCUS, KILLFOCUS,\r
37                 REFRESH, SCROLLTODIFF, OPEN, NEW\r
38         };\r
39         enum DRAGGING_MODE {\r
40                 NONE = 0, MOVE, ADJUST_OFFSET, VERTICAL_WIPE, HORIZONTAL_WIPE,\r
41                 RECTANGLE_SELECT,\r
42                 MOVE_IMAGE = 256, RESIZE_WIDTH, RESIZE_HEIGHT, RESIZE_BOTH\r
43         };\r
44         enum OCR_RESULT_TYPE {\r
45                 TEXT_ONLY = 0, TEXT_PER_LINE_YAML, TEXT_PER_WORD_YAML\r
46         };\r
47         struct Event\r
48         {\r
49                 void *userdata;\r
50                 int pane;\r
51                 EVENT_TYPE eventType;\r
52                 int x;\r
53                 int y;\r
54                 unsigned flags;\r
55                 int delta;\r
56                 int width;\r
57                 int height;\r
58                 int keycode;\r
59                 int diffIndex;\r
60         };\r
61         typedef void (*EventListenerFunc)(const Event& evt);\r
62         virtual bool OpenImages(const wchar_t *filename1, const wchar_t *filename2) = 0;\r
63         virtual bool OpenImages(const wchar_t *filename1, const wchar_t *filename2, const wchar_t *filename3) = 0;\r
64         virtual bool ReloadImages() = 0;\r
65         virtual bool SaveImages() = 0;\r
66         virtual bool SaveImage(int pane) = 0;\r
67         virtual bool SaveImageAs(int pane, const wchar_t *filename) = 0;\r
68         virtual bool SaveDiffImageAs(int pane, const wchar_t *filename) = 0;\r
69         virtual const wchar_t *GetFileName(int pane) = 0;\r
70         virtual int  GetPaneCount() const = 0;\r
71         virtual RECT GetPaneWindowRect(int pane) const = 0;\r
72         virtual RECT GetWindowRect() const = 0;\r
73         virtual bool SetWindowRect(const RECT& rc) = 0;\r
74         virtual POINT GetCursorPos(int pane) const = 0;\r
75         virtual RGBQUAD GetPixelColor(int pane, int x, int y) const = 0;\r
76         virtual double GetColorDistance(int pane1, int pane2, int x, int y) const = 0;\r
77         virtual int  GetActivePane() const = 0;\r
78         virtual void SetActivePane(int pane) = 0;\r
79         virtual bool GetReadOnly(int pane) const = 0;\r
80         virtual void SetReadOnly(int pane, bool readOnly) = 0;\r
81         virtual bool GetHorizontalSplit() const = 0;\r
82         virtual void SetHorizontalSplit(bool horizontalSplit) = 0;\r
83         virtual int  GetCurrentPage(int pane) const = 0;\r
84         virtual void SetCurrentPage(int pane, int page) = 0;\r
85         virtual int  GetCurrentMaxPage() const = 0;\r
86         virtual void SetCurrentPageAll(int page) = 0;\r
87         virtual int  GetPageCount(int pane) const = 0;\r
88         virtual int  GetMaxPageCount() const = 0;\r
89         virtual COLORREF GetDiffColor() const = 0;\r
90         virtual void SetDiffColor(COLORREF clrDiffColor) = 0;\r
91         virtual COLORREF GetSelDiffColor() const = 0;\r
92         virtual void SetSelDiffColor(COLORREF clrSelDiffColor) = 0;\r
93         virtual double GetDiffColorAlpha() const = 0;\r
94         virtual void SetDiffColorAlpha(double diffColorAlpha) = 0;\r
95         virtual RGBQUAD GetBackColor() const = 0;\r
96         virtual void SetBackColor(RGBQUAD backColor) = 0;\r
97         virtual bool GetUseBackColor() const = 0;\r
98         virtual void SetUseBackColor(bool useBackColor) = 0;\r
99         virtual double GetZoom() const = 0;\r
100         virtual void SetZoom(double zoom) = 0;\r
101         virtual double GetColorDistanceThreshold() const = 0;\r
102         virtual void SetColorDistanceThreshold(double threshold) = 0;\r
103         virtual int  GetDiffBlockSize() const = 0;\r
104         virtual void SetDiffBlockSize(int blockSize) = 0;\r
105         virtual OVERLAY_MODE GetOverlayMode() const = 0;\r
106         virtual void SetOverlayMode(OVERLAY_MODE overlayMode) = 0;\r
107         virtual double GetOverlayAlpha() const = 0;\r
108         virtual void SetOverlayAlpha(double alpha) = 0;\r
109         virtual bool GetShowDifferences() const = 0;\r
110         virtual void SetShowDifferences(bool visible) = 0;\r
111         virtual bool GetBlinkDifferences() const = 0;\r
112         virtual void SetBlinkDifferences(bool visible) = 0;\r
113         virtual int  GetDiffCount() const = 0;\r
114         virtual int  GetConflictCount() const = 0;\r
115         virtual int  GetCurrentDiffIndex() const = 0;\r
116         virtual bool FirstDiff() = 0;\r
117         virtual bool LastDiff() = 0;\r
118         virtual bool NextDiff() = 0;\r
119         virtual bool PrevDiff() = 0;\r
120         virtual bool FirstConflict() = 0;\r
121         virtual bool LastConflict() = 0;\r
122         virtual bool NextConflict() = 0;\r
123         virtual bool PrevConflict() = 0; \r
124         virtual bool SelectDiff(int diffIndex) = 0;\r
125         virtual int  GetNextDiffIndex() const = 0;\r
126         virtual int  GetPrevDiffIndex() const = 0;\r
127         virtual int  GetNextConflictIndex() const = 0;\r
128         virtual int  GetPrevConflictIndex() const = 0;\r
129         virtual void CopyDiff(int diffIndex, int srcPane, int dstPane) = 0;\r
130         virtual void CopyDiffAll(int srcPane, int dstPane) = 0;\r
131         virtual int  CopyDiff3Way(int dstPane) = 0;\r
132         virtual bool IsUndoable() const = 0;\r
133         virtual bool IsRedoable() const = 0;\r
134         virtual bool Undo() = 0;\r
135         virtual bool Redo() = 0;\r
136         virtual bool IsModified(int pane) const = 0;\r
137         virtual HWND GetHWND() const = 0;\r
138         virtual HWND GetPaneHWND(int pane) const = 0;\r
139         virtual int  GetImageWidth(int pane) const = 0;\r
140         virtual int  GetImageHeight(int pane) const = 0;\r
141         virtual int  GetImageBitsPerPixel(int pane) const = 0;\r
142         virtual void AddImageOffset(int pane, int dx, int dy) = 0;\r
143         virtual POINT GetImageOffset(int pane) const = 0;\r
144         virtual void AddEventListener(EventListenerFunc func, void *userdata) = 0;\r
145         virtual DRAGGING_MODE GetDraggingMode() const = 0;\r
146         virtual void SetDraggingMode(DRAGGING_MODE draggingMode) = 0;\r
147         virtual size_t GetMetadata(int pane, char *buf, size_t bufsize) const = 0;\r
148         virtual INSERTION_DELETION_DETECTION_MODE GetInsertionDeletionDetectionMode() const = 0;\r
149         virtual void SetInsertionDeletionDetectionMode(INSERTION_DELETION_DETECTION_MODE insertionDeletionDetectionMode) = 0;\r
150         virtual COLORREF GetDiffDeletedColor() const = 0;\r
151         virtual void SetDiffDeletedColor(COLORREF clrDiffDeletedColor) = 0;\r
152         virtual COLORREF GetSelDiffDeletedColor() const = 0;\r
153         virtual void SetSelDiffDeletedColor(COLORREF clrSelDiffDeletedColor) = 0;\r
154         virtual bool ConvertToRealPos(int pane, const POINT& pt, POINT& ptReal) const = 0;\r
155         virtual float GetVectorImageZoomRatio() const = 0;\r
156         virtual void SetVectorImageZoomRatio(float zoom) = 0;\r
157         virtual bool CloseImages() = 0;\r
158         virtual bool NewImages(int nImages, int nPages, int width, int height) = 0;\r
159         virtual bool Copy() = 0;\r
160         virtual bool Cut() = 0;\r
161         virtual bool Delete() = 0;\r
162         virtual bool Paste() = 0;\r
163         virtual bool SelectAll() = 0;\r
164         virtual bool Cancel() = 0;\r
165         virtual RECT GetRectangleSelection(int pane) const = 0;\r
166         virtual bool IsCopyable() const = 0;\r
167         virtual bool IsCuttable() const = 0;\r
168         virtual bool IsPastable() const = 0;\r
169         virtual bool IsCancellable() const = 0;\r
170         virtual bool IsRectangleSelectionVisible(int pane) const = 0;\r
171         virtual BSTR ExtractTextFromImage(int pane, int page, OCR_RESULT_TYPE resultType) = 0;\r
172         virtual int GetSavePoint(int pane) const = 0;\r
173         virtual void SetSavePoint(int pane, int pos) = 0;\r
174         virtual float GetRotation(int pane) const = 0;\r
175         virtual void SetRotation(int pane, float angle) = 0;\r
176         virtual bool GetHorizontalFlip(int pane) const = 0;\r
177         virtual void SetHorizontalFlip(int pane, bool flip) = 0;\r
178         virtual bool GetVerticalFlip(int pane) const = 0;\r
179         virtual void SetVerticalFlip(int pane, bool flip) = 0;\r
180 };\r
181 \r
182 struct IImgToolWindow\r
183 {\r
184         using TranslateCallback = void(*)(int id, const wchar_t *org, size_t dstbufsize, wchar_t *dst);\r
185         virtual HWND GetHWND() const = 0;\r
186         virtual void Sync() = 0;\r
187         virtual void Translate(TranslateCallback translateCallback) = 0;\r
188 };\r
189 \r
190 extern "C"\r
191 {\r
192         IImgMergeWindow * WinIMerge_CreateWindow(HINSTANCE hInstance, HWND hWndParent, int nID = 0);\r
193         bool WinIMerge_DestroyWindow(IImgMergeWindow *pImgMergeWindow);\r
194         IImgToolWindow * WinIMerge_CreateToolWindow(HINSTANCE hInstance, HWND hWndParent, IImgMergeWindow *pImgMergeWindow);\r
195         bool WinIMerge_DestroyToolWindow(IImgToolWindow *pImgToolWindow);\r
196         IImgMergeWindow * WinIMerge_CreateWindowless();\r
197 };\r