Rev 495 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
259 | daniel-mar | 1 | /* |
2 | This file is part of "Filter Foundry", a filter plugin for Adobe Photoshop |
||
3 | Copyright (C) 2003-2009 Toby Thain, toby@telegraphics.com.au |
||
503 | daniel-mar | 4 | Copyright (C) 2018-2022 Daniel Marschall, ViaThinkSoft |
259 | daniel-mar | 5 | |
6 | This program is free software; you can redistribute it and/or modify |
||
7 | it under the terms of the GNU General Public License as published by |
||
8 | the Free Software Foundation; either version 2 of the License, or |
||
9 | (at your option) any later version. |
||
10 | |||
11 | This program is distributed in the hope that it will be useful, |
||
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
14 | GNU General Public License for more details. |
||
15 | |||
16 | You should have received a copy of the GNU General Public License |
||
17 | along with this program; if not, write to the Free Software |
||
18 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
19 | */ |
||
20 | |||
21 | /* Win32 user interface routines */ |
||
22 | |||
23 | #include "world.h" |
||
24 | |||
25 | #include "PIAbout.h" |
||
26 | |||
27 | #include <windows.h> |
||
28 | #include <commctrl.h> |
||
29 | |||
30 | #include "ff.h" |
||
439 | daniel-mar | 31 | #include "slider_win.h" |
259 | daniel-mar | 32 | #include "version.h" |
33 | |||
34 | HWND preview_hwnd; |
||
35 | HCURSOR hCurHandOpen; |
||
36 | HCURSOR hCurHandGrab; |
||
419 | daniel-mar | 37 | |
259 | daniel-mar | 38 | HCURSOR hCurHandQuestion; |
419 | daniel-mar | 39 | HICON hIconCautionSign; |
259 | daniel-mar | 40 | |
41 | extern HINSTANCE hDllInstance; |
||
42 | |||
43 | void DoAbout(AboutRecordPtr pb){ |
||
495 | daniel-mar | 44 | TCHAR* tmp1; |
45 | TCHAR* filters = (TCHAR*)malloc(4096); |
||
46 | if (filters == NULL) return; |
||
47 | memset(filters, 0, 4096); |
||
48 | tmp1 = filters; |
||
259 | daniel-mar | 49 | |
50 | if (gdata && gdata->standalone) { |
||
495 | daniel-mar | 51 | // strcpy(gdata->parm.szTitle, "TestTitle"); |
52 | // strcpy(gdata->parm.szAuthor, "TestAuthor"); |
||
53 | // strcpy(gdata->parm.szCopyright, "TestCopyright"); |
||
493 | daniel-mar | 54 | |
495 | daniel-mar | 55 | strcpy_advance_a(&tmp1, gdata->parm.szTitle); |
56 | strcpy_advance_id(&tmp1, MSG_ABOUT_BY_ID); |
||
57 | strcpy_advance_a(&tmp1, gdata->parm.szAuthor); |
||
58 | strcpy_advance(&tmp1, (TCHAR*)TEXT("\n")); |
||
493 | daniel-mar | 59 | |
495 | daniel-mar | 60 | strcpy_advance_a(&tmp1, gdata->parm.szCopyright); |
61 | strcpy_advance(&tmp1, (TCHAR*)TEXT("\n\n")); |
||
493 | daniel-mar | 62 | |
495 | daniel-mar | 63 | strcpy_advance_id(&tmp1, MSG_ABOUT_BUILT_USING_ID); |
493 | daniel-mar | 64 | #ifdef _WIN64 |
495 | daniel-mar | 65 | strcpy_advance(&tmp1, (TCHAR*)(TEXT(" ") TEXT(VERSION_STR) TEXT(" (64 bit)\n"))); |
493 | daniel-mar | 66 | #else |
495 | daniel-mar | 67 | strcpy_advance(&tmp1, (TCHAR*)(TEXT(" ") TEXT(VERSION_STR) TEXT(" (32 bit)\n"))); |
493 | daniel-mar | 68 | #endif |
69 | |||
495 | daniel-mar | 70 | strcpy_advance(&tmp1, (TCHAR*)(TEXT("(C) 2003-2009 Toby Thain, 2018-") TEXT(RELEASE_YEAR) TEXT(" Daniel Marschall\n"))); |
71 | strcpy_advance_id(&tmp1, MSG_ABOUT_LATEST_VERSION_FROM_ID); |
||
72 | strcpy_advance(&tmp1, (TCHAR*)TEXT("\n")); |
||
73 | strcpy_advance(&tmp1, (TCHAR*)TEXT(PROJECT_URL)); |
||
259 | daniel-mar | 74 | } else { |
493 | daniel-mar | 75 | #ifdef _WIN64 |
495 | daniel-mar | 76 | strcpy_advance(&tmp1, (TCHAR*)(TEXT("Filter Foundry ") TEXT(VERSION_STR) TEXT(" (64 bit)\n"))); |
493 | daniel-mar | 77 | #else |
495 | daniel-mar | 78 | strcpy_advance(&tmp1, (TCHAR*)(TEXT("Filter Foundry ") TEXT(VERSION_STR) TEXT(" (32 bit)\n"))); |
493 | daniel-mar | 79 | #endif |
495 | daniel-mar | 80 | strcpy_advance(&tmp1, (TCHAR*)(TEXT("(C) 2003-2009 Toby Thain, 2018-") TEXT(RELEASE_YEAR) TEXT(" Daniel Marschall\n\n"))); |
81 | strcpy_advance_id(&tmp1, MSG_ABOUT_LATEST_VERSION_FROM_ID); |
||
82 | strcpy_advance(&tmp1, (TCHAR*)(TEXT("\n") TEXT(PROJECT_URL) TEXT("\n\n"))); |
||
83 | strcpy_advance_id(&tmp1, MSG_ABOUT_CONTACT_AUTHOR_ID); |
||
84 | } |
||
493 | daniel-mar | 85 | |
495 | daniel-mar | 86 | showmessage(filters); |
87 | free(filters); |
||
259 | daniel-mar | 88 | } |
89 | |||
444 | daniel-mar | 90 | Boolean simplealert(TCHAR* s){ |
273 | daniel-mar | 91 | HWND hwnd; |
456 | daniel-mar | 92 | TCHAR title[256] = { 0 }; |
259 | daniel-mar | 93 | if (gdata && gdata->standalone) { |
444 | daniel-mar | 94 | #ifdef UNICODE |
95 | mbstowcs(&title[0], (const char*)gdata->parm.szTitle, 256); |
||
96 | #else |
||
97 | strcpy(&title[0], gdata->parm.szTitle); |
||
98 | #endif |
||
259 | daniel-mar | 99 | } |
444 | daniel-mar | 100 | else { |
101 | xstrcpy(&title[0], (TCHAR*)TEXT("Filter Foundry")); |
||
102 | } |
||
273 | daniel-mar | 103 | hwnd = gdata ? gdata->hWndMainDlg : NULL; |
413 | daniel-mar | 104 | return MessageBox(hwnd, s, title, MB_TASKMODAL|MB_ICONERROR|MB_OK) == IDOK; |
259 | daniel-mar | 105 | } |
106 | |||
444 | daniel-mar | 107 | Boolean simplewarning(TCHAR* s) { |
320 | daniel-mar | 108 | HWND hwnd; |
456 | daniel-mar | 109 | TCHAR title[256] = { 0 }; |
320 | daniel-mar | 110 | if (gdata && gdata->standalone) { |
444 | daniel-mar | 111 | #ifdef UNICODE |
112 | mbstowcs(&title[0], (const char*)gdata->parm.szTitle, 256); |
||
113 | #else |
||
114 | strcpy(&title[0], gdata->parm.szTitle); |
||
115 | #endif |
||
393 | daniel-mar | 116 | } else { |
444 | daniel-mar | 117 | xstrcpy(&title[0], (TCHAR*)TEXT("Filter Foundry")); |
320 | daniel-mar | 118 | } |
119 | hwnd = gdata ? gdata->hWndMainDlg : NULL; |
||
120 | return MessageBox(hwnd,s,title,MB_TASKMODAL|MB_ICONEXCLAMATION|MB_OK) == IDOK; |
||
121 | } |
||
122 | |||
444 | daniel-mar | 123 | Boolean showmessage(TCHAR *s) { |
273 | daniel-mar | 124 | HWND hwnd; |
456 | daniel-mar | 125 | TCHAR title[256] = { 0 }; |
259 | daniel-mar | 126 | if (gdata && gdata->standalone) { |
444 | daniel-mar | 127 | #ifdef UNICODE |
128 | mbstowcs(&title[0], (const char*)gdata->parm.szTitle, 256); |
||
129 | #else |
||
130 | strcpy(&title[0], gdata->parm.szTitle); |
||
131 | #endif |
||
259 | daniel-mar | 132 | } |
444 | daniel-mar | 133 | else { |
134 | xstrcpy(&title[0], (TCHAR*)TEXT("Filter Foundry")); |
||
135 | } |
||
273 | daniel-mar | 136 | hwnd = gdata ? gdata->hWndMainDlg : NULL; |
137 | return MessageBox(hwnd,s,title,MB_TASKMODAL|MB_ICONINFORMATION|MB_OK) == IDOK; |
||
259 | daniel-mar | 138 | } |
139 | |||
140 | INT_PTR CALLBACK maindlgproc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam); |
||
141 | |||
353 | daniel-mar | 142 | // Description: |
393 | daniel-mar | 143 | // Creates a tooltip for an item in a dialog box. |
353 | daniel-mar | 144 | // Parameters: |
145 | // idTool - identifier of an dialog box item. |
||
146 | // nDlg - window handle of the dialog box. |
||
147 | // pszText - string to use as the tooltip text. |
||
148 | // Returns: |
||
149 | // The handle to the tooltip. |
||
150 | // |
||
444 | daniel-mar | 151 | HWND CreateToolTip(int toolID, HWND hDlg, LPTSTR pszText) { |
354 | daniel-mar | 152 | // Source: https://docs.microsoft.com/en-us/windows/win32/controls/create-a-tooltip-for-a-control (modified) |
393 | daniel-mar | 153 | |
354 | daniel-mar | 154 | HWND hwndTool, hwndTip; |
155 | TOOLINFO toolInfo; |
||
156 | |||
353 | daniel-mar | 157 | if (!toolID || !hDlg || !pszText) { |
158 | return FALSE; |
||
159 | } |
||
160 | // Get the window of the tool. |
||
354 | daniel-mar | 161 | hwndTool = GetDlgItem(hDlg, toolID); |
353 | daniel-mar | 162 | |
163 | // Create the tooltip. g_hInst is the global instance handle. |
||
354 | daniel-mar | 164 | hwndTip = CreateWindowEx(0, TOOLTIPS_CLASS, NULL, |
353 | daniel-mar | 165 | WS_POPUP | TTS_ALWAYSTIP /* | TTS_BALLOON*/, |
166 | CW_USEDEFAULT, CW_USEDEFAULT, |
||
167 | CW_USEDEFAULT, CW_USEDEFAULT, |
||
168 | hDlg, NULL, |
||
169 | hDllInstance, NULL); |
||
170 | |||
171 | if (!hwndTool || !hwndTip) { |
||
172 | return (HWND)NULL; |
||
173 | } |
||
174 | |||
175 | // Associate the tooltip with the tool. |
||
354 | daniel-mar | 176 | memset(&toolInfo, 0, sizeof(TOOLINFO)); // toolInfo = { 0 }; |
353 | daniel-mar | 177 | toolInfo.cbSize = sizeof(toolInfo); |
178 | toolInfo.hwnd = hDlg; |
||
179 | toolInfo.uFlags = TTF_IDISHWND | TTF_SUBCLASS; |
||
180 | toolInfo.uId = (UINT_PTR)hwndTool; |
||
181 | toolInfo.lpszText = pszText; |
||
182 | SendMessage(hwndTip, TTM_ADDTOOL, 0, (LPARAM)&toolInfo); |
||
183 | |||
184 | return hwndTip; |
||
185 | } |
||
186 | |||
491 | daniel-mar | 187 | #define IDT_TIMER_INITPREVIEW_DRAW 'tDRW' |
445 | daniel-mar | 188 | |
453 | daniel-mar | 189 | WNDPROC lpControlEditWndProc[8]; |
190 | |||
191 | LRESULT CALLBACK ControlTextWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { |
||
192 | extern Boolean doupdates; |
||
193 | int sliderNum; |
||
194 | for (sliderNum = 0; sliderNum < 8; sliderNum++) { |
||
195 | if (hWnd == GetDlgItem(gdata->hWndMainDlg, FIRSTCTLTEXTITEM + sliderNum)) { |
||
196 | if ((uMsg == WM_KEYDOWN) && (wParam == VK_UP) && doupdates) |
||
197 | { |
||
198 | uint8_t sliderVal = slider[sliderNum] < 255 ? slider[sliderNum] + 1 : slider[sliderNum]; |
||
199 | slider[sliderNum] = sliderVal; |
||
200 | |||
201 | SETCTLTEXTINT(gdata->hWndMainDlg, FIRSTCTLTEXTITEM + sliderNum, sliderVal, false); |
||
202 | REPAINTCTL(gdata->hWndMainDlg, FIRSTCTLTEXTITEM + sliderNum); |
||
203 | |||
204 | recalc_preview(gpb, gdata->hWndMainDlg); |
||
205 | |||
206 | return 0; |
||
207 | } |
||
208 | if ((uMsg == WM_KEYDOWN) && (wParam == VK_DOWN) && doupdates) |
||
209 | { |
||
210 | uint8_t sliderVal = slider[sliderNum] > 0 ? slider[sliderNum] - 1 : slider[sliderNum]; |
||
211 | slider[sliderNum] = sliderVal; |
||
212 | |||
213 | SETCTLTEXTINT(gdata->hWndMainDlg, FIRSTCTLTEXTITEM + sliderNum, sliderVal, false); |
||
214 | REPAINTCTL(gdata->hWndMainDlg, FIRSTCTLTEXTITEM + sliderNum); |
||
215 | |||
216 | recalc_preview(gpb, gdata->hWndMainDlg); |
||
217 | |||
218 | return 0; |
||
219 | } |
||
220 | return CallWindowProc(lpControlEditWndProc[sliderNum], hWnd, uMsg, wParam, lParam); |
||
221 | } |
||
222 | } |
||
223 | return 0; // should not happen |
||
224 | } |
||
225 | |||
259 | daniel-mar | 226 | INT_PTR CALLBACK maindlgproc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam){ |
227 | static POINT origpos; |
||
228 | static Point origscroll; |
||
229 | static Boolean panning = false; |
||
230 | |||
231 | int item,i; |
||
232 | POINT newpos; |
||
233 | DRAWITEMSTRUCT *pdi; |
||
456 | daniel-mar | 234 | Point newscroll = { 0, 0 }; |
259 | daniel-mar | 235 | HGDIOBJ hfnt; |
236 | |||
237 | extern Boolean doupdates; |
||
485 | daniel-mar | 238 | extern FFBuffer preview_handle; |
259 | daniel-mar | 239 | |
477 | daniel-mar | 240 | if ((gdata->pluginDllSliderInfo.initialized) && (wMsg == gdata->pluginDllSliderInfo.messageId)) { |
422 | daniel-mar | 241 | // This is for the PLUGIN.DLL sliders only |
242 | if (doupdates) { |
||
444 | daniel-mar | 243 | int sliderNum = (int)wParam - FIRSTCTLITEM; |
454 | daniel-mar | 244 | int sliderVal = (lParam & 0xFFFF); |
453 | daniel-mar | 245 | if (sliderVal < 0) sliderVal = 0; |
456 | daniel-mar | 246 | else if (sliderVal > 255) sliderVal = 255; |
247 | slider[sliderNum] = (uint8_t)sliderVal; |
||
422 | daniel-mar | 248 | |
249 | SETCTLTEXTINT(hDlg, FIRSTCTLTEXTITEM + sliderNum, sliderVal, false); |
||
250 | REPAINTCTL(hDlg, FIRSTCTLTEXTITEM + sliderNum); |
||
251 | |||
252 | recalc_preview(gpb, hDlg); |
||
253 | } |
||
254 | return true; |
||
255 | } |
||
256 | |||
419 | daniel-mar | 257 | switch (wMsg) { |
445 | daniel-mar | 258 | case WM_TIMER: |
259 | switch (wParam) |
||
260 | { |
||
261 | case IDT_TIMER_INITPREVIEW_DRAW: |
||
446 | daniel-mar | 262 | KillTimer(hDlg, IDT_TIMER_INITPREVIEW_DRAW); |
445 | daniel-mar | 263 | recalc_preview(gpb, hDlg); |
264 | return 0; |
||
265 | } |
||
266 | break; |
||
259 | daniel-mar | 267 | case WM_INITDIALOG: |
268 | gdata->hWndMainDlg = hDlg; |
||
269 | |||
270 | if(gdata->standalone){ |
||
444 | daniel-mar | 271 | SetWindowTextA(hDlg,gdata->parm.szTitle); // window title bar |
259 | daniel-mar | 272 | } |
273 | centre_window(hDlg); |
||
274 | |||
275 | hfnt = GetStockObject(ANSI_FIXED_FONT); |
||
276 | |||
444 | daniel-mar | 277 | hCurHandOpen = LoadCursorA(hDllInstance, "HAND_OPEN"); |
278 | hCurHandGrab = LoadCursorA(hDllInstance, "HAND_GRAB"); |
||
279 | hCurHandQuestion = LoadCursorA(hDllInstance, "HAND_QUESTION"); |
||
259 | daniel-mar | 280 | |
444 | daniel-mar | 281 | hIconCautionSign = LoadIconA(hDllInstance, "CAUTION_ICO"); |
419 | daniel-mar | 282 | |
283 | // Note: The whole class "Preview" gets the mouse cursor, not just the single item! |
||
259 | daniel-mar | 284 | preview_hwnd = GetDlgItem(hDlg, PREVIEWITEM); |
285 | GetClientRect(preview_hwnd, &preview_rect); |
||
286 | SetClassLongPtr(preview_hwnd, GCLP_HCURSOR, (LONG_PTR)hCurHandOpen); |
||
287 | |||
419 | daniel-mar | 288 | // Note: The whole class "Caution" gets the mouse cursor, not just the single item! |
259 | daniel-mar | 289 | SetClassLongPtr(GetDlgItem(hDlg, FIRSTICONITEM), GCLP_HCURSOR, (LONG_PTR)hCurHandQuestion); |
290 | |||
291 | for(i = 0; i < 4; ++i){ |
||
492 | daniel-mar | 292 | TCHAR msg[0x100]; |
293 | LoadString(hDllInstance, MSG_ERROR_IN_EXPRESSION_CLICK_DETAILS_ID, &msg[0], 0x100); |
||
294 | CreateToolTip(FIRSTICONITEM + i, hDlg, msg); |
||
259 | daniel-mar | 295 | } |
296 | |||
492 | daniel-mar | 297 | { |
298 | TCHAR msg[0x100]; |
||
299 | LoadString(hDllInstance, MSG_ZOOM_IN_ID, &msg[0], 0x100); |
||
300 | CreateToolTip(ZOOMINITEM, hDlg, msg); |
||
301 | LoadString(hDllInstance, MSG_ZOOM_OUT_ID, &msg[0], 0x100); |
||
302 | CreateToolTip(ZOOMOUTITEM, hDlg, msg); |
||
303 | LoadString(hDllInstance, MSG_FULLY_ZOOM_INOUT_ID, &msg[0], 0x100); |
||
304 | CreateToolTip(ZOOMLEVELITEM, hDlg, msg); |
||
305 | } |
||
353 | daniel-mar | 306 | |
259 | daniel-mar | 307 | for(i = 0; i < 8; ++i){ |
478 | daniel-mar | 308 | FF_SetSliderRange(hDlg, FIRSTCTLITEM+i, 0, 255); |
259 | daniel-mar | 309 | SendDlgItemMessage(hDlg,FIRSTCTLTEXTITEM+i, EM_SETLIMITTEXT,3,0); |
310 | } |
||
311 | for(i = 0; i < 4; ++i){ |
||
312 | SendDlgItemMessage(hDlg,FIRSTEXPRITEM+i, EM_SETLIMITTEXT,MAXEXPR-1,0); // we need 1 byte as NUL terminator, so our formula can be max 1023 |
||
313 | SendDlgItemMessage(hDlg,FIRSTEXPRITEM+i, WM_SETFONT,(WPARAM)hfnt,false); |
||
314 | } |
||
315 | |||
453 | daniel-mar | 316 | // Implement "up" and "down" keys for the edit controls |
317 | // TODO: Better use a spin-edit? |
||
318 | for (i = 0; i < 8; ++i) { |
||
454 | daniel-mar | 319 | #ifdef _WIN64 |
320 | lpControlEditWndProc[i] = (WNDPROC)SetWindowLongPtr(GetDlgItem(hDlg, FIRSTCTLTEXTITEM + i), GWLP_WNDPROC, (LONG_PTR)&ControlTextWndProc); |
||
321 | #else |
||
453 | daniel-mar | 322 | lpControlEditWndProc[i] = (WNDPROC)SetWindowLongPtr(GetDlgItem(hDlg, FIRSTCTLTEXTITEM + i), GWL_WNDPROC, (LONG_PTR)&ControlTextWndProc); |
454 | daniel-mar | 323 | #endif |
453 | daniel-mar | 324 | } |
325 | |||
456 | daniel-mar | 326 | maindlginit(hDlg); |
327 | |||
461 | daniel-mar | 328 | // Win32s (Windows 3.11) compatibility |
329 | Win32sFixSuperclassing(hDlg, PREVIEWITEM, FIRSTCTLLABELITEM); |
||
330 | for (i=0; i<4; i++) Win32sFixSuperclassing(hDlg, FIRSTICONITEM + i, OPENITEM); |
||
460 | daniel-mar | 331 | |
456 | daniel-mar | 332 | // Some versions of Windows (NT 3.x) won't show the preview if it is calculated here. |
333 | // So we need to put it in a timer. |
||
334 | // Note that 1 millisecond is enough, even if the window needs longer than 1 millisecond to load. |
||
335 | //recalc_preview(gpb, hDlg); |
||
336 | SetTimer(hDlg, IDT_TIMER_INITPREVIEW_DRAW, 1, (TIMERPROC)NULL); |
||
337 | |||
259 | daniel-mar | 338 | break; |
339 | case WM_DESTROY: |
||
340 | gdata->hWndMainDlg = 0; |
||
341 | DestroyCursor(hCurHandOpen); |
||
342 | DestroyCursor(hCurHandGrab); |
||
343 | DestroyCursor(hCurHandQuestion); |
||
419 | daniel-mar | 344 | DestroyIcon(hIconCautionSign); |
259 | daniel-mar | 345 | break; |
346 | case WM_DRAWITEM: |
||
347 | pdi = (DRAWITEMSTRUCT*)lParam; |
||
348 | if(pdi->itemAction == ODA_DRAWENTIRE){ |
||
349 | switch(pdi->CtlID){ |
||
350 | case PREVIEWITEM: |
||
486 | daniel-mar | 351 | drawpreview(hDlg,pdi->hDC,lockBuffer(&preview_handle)); |
352 | unlockBuffer(&preview_handle); |
||
259 | daniel-mar | 353 | break; |
419 | daniel-mar | 354 | case FIRSTICONITEM: |
355 | case FIRSTICONITEM + 1: |
||
356 | case FIRSTICONITEM + 2: |
||
357 | case FIRSTICONITEM + 3: |
||
358 | DrawIcon(pdi->hDC, 0, 0, hIconCautionSign); |
||
359 | break; |
||
259 | daniel-mar | 360 | default: |
361 | return false; |
||
362 | } |
||
363 | }else |
||
364 | return false; // we couldn't handle the message |
||
365 | break; |
||
366 | case WM_COMMAND: |
||
367 | item = LOWORD(wParam); |
||
368 | switch(HIWORD(wParam)){ |
||
419 | daniel-mar | 369 | //case BN_CLICKED: |
370 | case STN_CLICKED: |
||
371 | // BN_CLICKED = Button clicked |
||
372 | // STN_CLICKED = Static controls with SS_NOTIFY clicked |
||
373 | // Both have the same ordinal number |
||
259 | daniel-mar | 374 | if(item==PREVIEWITEM && GetCursorPos(&origpos)){ |
375 | panning = true; |
||
376 | origscroll = preview_scroll; |
||
377 | SetCursor(hCurHandGrab); |
||
433 | daniel-mar | 378 | SetCapture(hDlg); |
259 | daniel-mar | 379 | break; |
380 | } |
||
419 | daniel-mar | 381 | /* ... falls through ... */ |
259 | daniel-mar | 382 | case EN_CHANGE: |
383 | if(doupdates && !maindlgitem(hDlg,item)) |
||
384 | EndDialog(hDlg,item); |
||
385 | } |
||
386 | break; |
||
387 | // case WM_LBUTTONDOWN: break; |
||
388 | case WM_MOUSEMOVE: |
||
389 | if(panning && GetCursorPos(&newpos)){ |
||
273 | daniel-mar | 390 | newscroll.h = (int16)(origscroll.h - zoomfactor*((double)newpos.x - (double)origpos.x)); |
391 | newscroll.v = (int16)(origscroll.v - zoomfactor*((double)newpos.y - (double)origpos.y)); |
||
259 | daniel-mar | 392 | if( newscroll.h != preview_scroll.h || newscroll.v != preview_scroll.v ){ |
393 | preview_scroll = newscroll; |
||
394 | recalc_preview(gpb,hDlg); |
||
395 | } |
||
396 | } |
||
397 | break; |
||
398 | case WM_LBUTTONUP: |
||
399 | ReleaseCapture(); |
||
400 | panning = false; |
||
401 | break; |
||
402 | case WM_HSCROLL: |
||
422 | daniel-mar | 403 | // Only for non-Plugin.dll-sliders |
259 | daniel-mar | 404 | item = GetDlgCtrlID((HWND)lParam); |
477 | daniel-mar | 405 | if(doupdates && !gdata->pluginDllSliderInfo.initialized && item>=FIRSTCTLITEM && item<=FIRSTCTLITEM+7) |
259 | daniel-mar | 406 | slidermoved(hDlg,item); |
407 | break; |
||
408 | default: |
||
409 | return false; |
||
410 | } |
||
411 | |||
412 | return true; |
||
413 | } |
||
414 | |||
431 | daniel-mar | 415 | Boolean maindialog(FilterRecordPtr pb){ |
416 | PlatformData *p; |
||
417 | INT_PTR res; |
||
418 | |||
419 | // First try to use the sliders from PLUGIN.DLL (only Photoshop) |
||
444 | daniel-mar | 420 | if (!Slider_Init_PluginDll(TEXT("FoundrySlider"))) { |
431 | daniel-mar | 421 | // If we couldn't get the sliders from PLUGIN.DLL (probably not running in Photoshop), |
422 | // then try the Microsoft Trackbar Control instead |
||
444 | daniel-mar | 423 | if (!Slider_Init_MsTrackbar(TEXT("FoundrySlider"))) { |
431 | daniel-mar | 424 | // This will happen if we neither have PLUGIN.DLL, nor the Microsoft Trackbar Control (msctls_trackbar32). |
425 | // "msctls_trackbar32" is not included in Windows NT 3.1, and since there is no OCX or RegSvr32. |
||
426 | // It is included in Windows NT 3.5x. |
||
427 | |||
444 | daniel-mar | 428 | //simplealert((TCHAR*)TEXT("This plugin requires Photoshop's PLUGIN.DLL or the Microsoft Trackbar Control (msctls_trackbar32) which was not found on your system.")); |
430 | daniel-mar | 429 | //return false; |
430 | |||
431 | // We simply hide the sliders and let the user enter the numeric values in the edit-box. |
||
492 | daniel-mar | 432 | simplewarning_id(MSG_SLIDER_UNAVAILABLE_ID); |
444 | daniel-mar | 433 | Slider_Init_None(TEXT("FoundrySlider")); |
419 | daniel-mar | 434 | } |
413 | daniel-mar | 435 | } |
436 | |||
431 | daniel-mar | 437 | // For the preview image and caution symbols, we register subclasses, so that we can assign a mouse cursor to this class. |
460 | daniel-mar | 438 | MakeSimpleSubclass(TEXT("Preview"), WC_STATIC); |
439 | MakeSimpleSubclass(TEXT("Caution"), WC_BUTTON); |
||
259 | daniel-mar | 440 | |
441 | // Now show the dialog |
||
442 | p = (PlatformData*)pb->platformData; |
||
419 | daniel-mar | 443 | |
444 | // Note: "Invalid Cursor Handle" is the error when an unrecognized control class is detected |
||
259 | daniel-mar | 445 | res = DialogBoxParam(hDllInstance,MAKEINTRESOURCE(gdata->standalone ? ID_PARAMDLG : ID_MAINDLG), |
412 | daniel-mar | 446 | (HWND)p->hwnd,maindlgproc,0); |
447 | if (res == 0) { |
||
492 | daniel-mar | 448 | simplealert((TCHAR*)TEXT("DialogBoxParam invalid parent window handle")); // TODO (Not so important): TRANSLATE |
412 | daniel-mar | 449 | } |
450 | if (res == -1) { |
||
444 | daniel-mar | 451 | TCHAR s[0x300]; |
492 | daniel-mar | 452 | xstrcpy(s, (TCHAR*)TEXT("DialogBoxParam failed: ")); // TODO (Not so important): TRANSLATE |
454 | daniel-mar | 453 | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, s + xstrlen(s), 0x300 - (DWORD)xstrlen(s), NULL); |
482 | daniel-mar | 454 | simplealert(&s[0]); |
412 | daniel-mar | 455 | } |
259 | daniel-mar | 456 | |
353 | daniel-mar | 457 | // Clean up after the dialog has been closed |
444 | daniel-mar | 458 | UnregisterClass(TEXT("Preview"), hDllInstance); |
459 | UnregisterClass(TEXT("Caution"), hDllInstance); |
||
460 | UnregisterClass(TEXT("FoundrySlider"), hDllInstance); |
||
431 | daniel-mar | 461 | Slider_Uninit_PluginDll(); |
476 | daniel-mar | 462 | Slider_Uninit_MsTrackbar(); |
463 | Slider_Uninit_None(); |
||
259 | daniel-mar | 464 | |
412 | daniel-mar | 465 | return res == IDOK; |
259 | daniel-mar | 466 | } |