Subversion Repositories filter_foundry

Rev

Rev 439 | Rev 445 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 439 Rev 444
Line 77... Line 77...
77
                               "suggestions or comments.\n"
77
                               "suggestions or comments.\n"
78
                               "If you use this program and like it, please consider\n"
78
                               "If you use this program and like it, please consider\n"
79
                               "making a donation.");
79
                               "making a donation.");
80
        }
80
        }
81
 
81
 
82
        MessageBox((HWND)p->hwnd, text, title, MB_TASKMODAL|MB_ICONINFORMATION|MB_OK);
82
        MessageBoxA((HWND)p->hwnd, text, title, MB_TASKMODAL|MB_ICONINFORMATION|MB_OK);
83
}
83
}
84
 
84
 
85
Boolean simplealert(char *s){
85
Boolean simplealert(TCHAR* s){
86
        HWND hwnd;
86
        HWND hwnd;
87
        char* title;
87
        TCHAR title[256];
88
        if (gdata && gdata->standalone) {
88
        if (gdata && gdata->standalone) {
-
 
89
                #ifdef UNICODE
-
 
90
                mbstowcs(&title[0], (const char*)gdata->parm.szTitle, 256);
-
 
91
                #else
89
                title = gdata->parm.szTitle;
92
                strcpy(&title[0], gdata->parm.szTitle);
-
 
93
                #endif
-
 
94
        }
90
        } else {
95
        else {
91
                title = _strdup("Filter Foundry");
96
                xstrcpy(&title[0], (TCHAR*)TEXT("Filter Foundry"));
92
        }
97
        }
93
        hwnd = gdata ? gdata->hWndMainDlg : NULL;
98
        hwnd = gdata ? gdata->hWndMainDlg : NULL;
94
        return MessageBox(hwnd, s, title, MB_TASKMODAL|MB_ICONERROR|MB_OK) == IDOK;
99
        return MessageBox(hwnd, s, title, MB_TASKMODAL|MB_ICONERROR|MB_OK) == IDOK;
95
}
100
}
96
 
101
 
97
Boolean simplewarning(char* s) {
102
Boolean simplewarning(TCHAR* s) {
98
        HWND hwnd;
103
        HWND hwnd;
99
        char* title;
104
        TCHAR title[256];
100
        if (gdata && gdata->standalone) {
105
        if (gdata && gdata->standalone) {
-
 
106
                #ifdef UNICODE
-
 
107
                mbstowcs(&title[0], (const char*)gdata->parm.szTitle, 256);
-
 
108
                #else
101
                title = gdata->parm.szTitle;
109
                strcpy(&title[0], gdata->parm.szTitle);
-
 
110
                #endif
102
        } else {
111
        } else {
103
                title = _strdup("Filter Foundry");
112
                xstrcpy(&title[0], (TCHAR*)TEXT("Filter Foundry"));
104
        }
113
        }
105
        hwnd = gdata ? gdata->hWndMainDlg : NULL;
114
        hwnd = gdata ? gdata->hWndMainDlg : NULL;
106
        return MessageBox(hwnd,s,title,MB_TASKMODAL|MB_ICONEXCLAMATION|MB_OK) == IDOK;
115
        return MessageBox(hwnd,s,title,MB_TASKMODAL|MB_ICONEXCLAMATION|MB_OK) == IDOK;
107
}
116
}
108
 
117
 
109
Boolean showmessage(char *s) {
118
Boolean showmessage(TCHAR *s) {
110
        HWND hwnd;
119
        HWND hwnd;
111
        char* title;
120
        TCHAR title[256];
112
        if (gdata && gdata->standalone) {
121
        if (gdata && gdata->standalone) {
-
 
122
                #ifdef UNICODE
-
 
123
                mbstowcs(&title[0], (const char*)gdata->parm.szTitle, 256);
-
 
124
                #else
113
                title = gdata->parm.szTitle;
125
                strcpy(&title[0], gdata->parm.szTitle);
-
 
126
                #endif
-
 
127
        }
114
        } else {
128
        else {
115
                title = _strdup("Filter Foundry");
129
                xstrcpy(&title[0], (TCHAR*)TEXT("Filter Foundry"));
116
        }
130
        }
117
        hwnd = gdata ? gdata->hWndMainDlg : NULL;
131
        hwnd = gdata ? gdata->hWndMainDlg : NULL;
118
        return MessageBox(hwnd,s,title,MB_TASKMODAL|MB_ICONINFORMATION|MB_OK) == IDOK;
132
        return MessageBox(hwnd,s,title,MB_TASKMODAL|MB_ICONINFORMATION|MB_OK) == IDOK;
119
}
133
}
120
 
134
 
Line 127... Line 141...
127
//   nDlg - window handle of the dialog box.
141
//   nDlg - window handle of the dialog box.
128
//   pszText - string to use as the tooltip text.
142
//   pszText - string to use as the tooltip text.
129
// Returns:
143
// Returns:
130
//   The handle to the tooltip.
144
//   The handle to the tooltip.
131
//
145
//
132
HWND CreateToolTip(int toolID, HWND hDlg, PTSTR pszText) {
146
HWND CreateToolTip(int toolID, HWND hDlg, LPTSTR pszText) {
133
        // Source: https://docs.microsoft.com/en-us/windows/win32/controls/create-a-tooltip-for-a-control (modified)
147
        // Source: https://docs.microsoft.com/en-us/windows/win32/controls/create-a-tooltip-for-a-control (modified)
134
 
148
 
135
        HWND hwndTool, hwndTip;
149
        HWND hwndTool, hwndTip;
136
        TOOLINFO toolInfo;
150
        TOOLINFO toolInfo;
137
 
151
 
Line 180... Line 194...
180
        extern Handle preview_handle;
194
        extern Handle preview_handle;
181
 
195
 
182
        if ((gdata->pluginDllSliderMessageId != 0) && (wMsg == gdata->pluginDllSliderMessageId)) {
196
        if ((gdata->pluginDllSliderMessageId != 0) && (wMsg == gdata->pluginDllSliderMessageId)) {
183
                // This is for the PLUGIN.DLL sliders only
197
                // This is for the PLUGIN.DLL sliders only
184
                if (doupdates) {
198
                if (doupdates) {
185
                        int sliderNum = wParam - FIRSTCTLITEM;
199
                        int sliderNum = (int)wParam - FIRSTCTLITEM;
186
                        uint8_t sliderVal = (uint8_t)(lParam & 0xFFFF);
200
                        uint8_t sliderVal = (uint8_t)(lParam & 0xFFFF);
187
                        slider[sliderNum] = sliderVal;
201
                        slider[sliderNum] = sliderVal;
188
 
202
 
189
                        SETCTLTEXTINT(hDlg, FIRSTCTLTEXTITEM + sliderNum, sliderVal, false);
203
                        SETCTLTEXTINT(hDlg, FIRSTCTLTEXTITEM + sliderNum, sliderVal, false);
190
                        REPAINTCTL(hDlg, FIRSTCTLTEXTITEM + sliderNum);
204
                        REPAINTCTL(hDlg, FIRSTCTLTEXTITEM + sliderNum);
Line 197... Line 211...
197
        switch (wMsg) {
211
        switch (wMsg) {
198
        case WM_INITDIALOG:
212
        case WM_INITDIALOG:
199
                gdata->hWndMainDlg = hDlg;
213
                gdata->hWndMainDlg = hDlg;
200
 
214
 
201
                if(gdata->standalone){
215
                if(gdata->standalone){
202
                        SetWindowText(hDlg,gdata->parm.szTitle); // window title bar
216
                        SetWindowTextA(hDlg,gdata->parm.szTitle); // window title bar
203
                }
217
                }
204
                centre_window(hDlg);
218
                centre_window(hDlg);
205
 
219
 
206
                hfnt = GetStockObject(ANSI_FIXED_FONT);
220
                hfnt = GetStockObject(ANSI_FIXED_FONT);
207
 
221
 
208
                hCurHandOpen = LoadCursor(hDllInstance, "HAND_OPEN");
222
                hCurHandOpen = LoadCursorA(hDllInstance, "HAND_OPEN");
209
                hCurHandGrab = LoadCursor(hDllInstance, "HAND_GRAB");
223
                hCurHandGrab = LoadCursorA(hDllInstance, "HAND_GRAB");
210
                hCurHandQuestion = LoadCursor(hDllInstance, "HAND_QUESTION");
224
                hCurHandQuestion = LoadCursorA(hDllInstance, "HAND_QUESTION");
211
 
225
 
212
                hIconCautionSign = LoadIcon(hDllInstance, "CAUTION_ICO");
226
                hIconCautionSign = LoadIconA(hDllInstance, "CAUTION_ICO");
213
 
227
 
214
                // Note: The whole class "Preview" gets the mouse cursor, not just the single item!
228
                // Note: The whole class "Preview" gets the mouse cursor, not just the single item!
215
                preview_hwnd = GetDlgItem(hDlg, PREVIEWITEM);
229
                preview_hwnd = GetDlgItem(hDlg, PREVIEWITEM);
216
                GetClientRect(preview_hwnd, &preview_rect);
230
                GetClientRect(preview_hwnd, &preview_rect);
217
                SetClassLongPtr(preview_hwnd, GCLP_HCURSOR, (LONG_PTR)hCurHandOpen);
231
                SetClassLongPtr(preview_hwnd, GCLP_HCURSOR, (LONG_PTR)hCurHandOpen);
218
 
232
 
219
                // Note: The whole class "Caution" gets the mouse cursor, not just the single item!
233
                // Note: The whole class "Caution" gets the mouse cursor, not just the single item!
220
                SetClassLongPtr(GetDlgItem(hDlg, FIRSTICONITEM), GCLP_HCURSOR, (LONG_PTR)hCurHandQuestion);
234
                SetClassLongPtr(GetDlgItem(hDlg, FIRSTICONITEM), GCLP_HCURSOR, (LONG_PTR)hCurHandQuestion);
221
 
235
 
222
                for(i = 0; i < 4; ++i){
236
                for(i = 0; i < 4; ++i){
223
                        CreateToolTip(FIRSTICONITEM + i, hDlg, _strdup("Error in expression! Click to see details."));
237
                        CreateToolTip(FIRSTICONITEM + i, hDlg, (TCHAR*)TEXT("Error in expression! Click to see details."));
224
                }
238
                }
225
 
239
 
226
                CreateToolTip(ZOOMINITEM, hDlg, _strdup("Zoom in"));
240
                CreateToolTip(ZOOMINITEM, hDlg, (TCHAR*)TEXT("Zoom in"));
227
                CreateToolTip(ZOOMOUTITEM, hDlg, _strdup("Zoom out"));
241
                CreateToolTip(ZOOMOUTITEM, hDlg, (TCHAR*)TEXT("Zoom out"));
228
                CreateToolTip(ZOOMLEVELITEM, hDlg, _strdup("Fully zoom in/out"));
242
                CreateToolTip(ZOOMLEVELITEM, hDlg, (TCHAR*)TEXT("Fully zoom in/out"));
229
 
243
 
230
                for(i = 0; i < 8; ++i){
244
                for(i = 0; i < 8; ++i){
231
                        if (gdata->pluginDllSliderMessageId == 0) {
245
                        if (gdata->pluginDllSliderMessageId == 0) {
232
                                // Non PLUGIN.DLL sliders
246
                                // Non PLUGIN.DLL sliders
233
                                SetWindowLongPtr(GetDlgItem(hDlg, FIRSTCTLITEM + i), GWL_STYLE, TBS_HORZ | TBS_AUTOTICKS | WS_CHILD | WS_VISIBLE);
247
                                SetWindowLongPtr(GetDlgItem(hDlg, FIRSTCTLITEM + i), GWL_STYLE, TBS_HORZ | TBS_AUTOTICKS | WS_CHILD | WS_VISIBLE);
Line 327... Line 341...
327
Boolean maindialog(FilterRecordPtr pb){
341
Boolean maindialog(FilterRecordPtr pb){
328
        PlatformData *p;
342
        PlatformData *p;
329
        INT_PTR res;
343
        INT_PTR res;
330
 
344
 
331
        // First try to use the sliders from PLUGIN.DLL (only Photoshop)
345
        // First try to use the sliders from PLUGIN.DLL (only Photoshop)
332
        if (!Slider_Init_PluginDll("FoundrySlider")) {
346
        if (!Slider_Init_PluginDll(TEXT("FoundrySlider"))) {
333
                // If we couldn't get the sliders from PLUGIN.DLL (probably not running in Photoshop),
347
                // If we couldn't get the sliders from PLUGIN.DLL (probably not running in Photoshop),
334
                // then try the Microsoft Trackbar Control instead
348
                // then try the Microsoft Trackbar Control instead
335
                if (!Slider_Init_MsTrackbar("FoundrySlider")) {
349
                if (!Slider_Init_MsTrackbar(TEXT("FoundrySlider"))) {
336
                        // This will happen if we neither have PLUGIN.DLL, nor the Microsoft Trackbar Control (msctls_trackbar32).
350
                        // This will happen if we neither have PLUGIN.DLL, nor the Microsoft Trackbar Control (msctls_trackbar32).
337
                        // "msctls_trackbar32" is not included in Windows NT 3.1, and since there is no OCX or RegSvr32.
351
                        // "msctls_trackbar32" is not included in Windows NT 3.1, and since there is no OCX or RegSvr32.
338
                        // It is included in Windows NT 3.5x.
352
                        // It is included in Windows NT 3.5x.
339
 
353
 
340
                        //simplealert(_strdup("This plugin requires Photoshop's PLUGIN.DLL or the Microsoft Trackbar Control (msctls_trackbar32) which was not found on your system."));
354
                        //simplealert((TCHAR*)TEXT("This plugin requires Photoshop's PLUGIN.DLL or the Microsoft Trackbar Control (msctls_trackbar32) which was not found on your system."));
341
                        //return false;
355
                        //return false;
342
 
356
 
343
                        // We simply hide the sliders and let the user enter the numeric values in the edit-box.
357
                        // We simply hide the sliders and let the user enter the numeric values in the edit-box.
344
                        simplewarning(_strdup("Visual sliders are not available because neither PLUGIN.DLL, nor the Microsoft Trackbar Control (msctls_trackbar32) was found on your system."));
358
                        simplewarning((TCHAR*)TEXT("Visual sliders are not available because neither PLUGIN.DLL, nor the Microsoft Trackbar Control (msctls_trackbar32) was found on your system."));
345
                        Slider_Init_None("FoundrySlider");
359
                        Slider_Init_None(TEXT("FoundrySlider"));
346
                }
360
                }
347
        }
361
        }
348
 
362
 
349
        // For the preview image and caution symbols, we register subclasses, so that we can assign a mouse cursor to this class.
363
        // For the preview image and caution symbols, we register subclasses, so that we can assign a mouse cursor to this class.
350
        MakeSimpleSubclass("Preview", "STATIC");
364
        MakeSimpleSubclass(TEXT("Preview"), TEXT("STATIC"));
351
        MakeSimpleSubclass("Caution", "Button");
365
        MakeSimpleSubclass(TEXT("Caution"), TEXT("Button"));
352
 
366
 
353
        // Now show the dialog
367
        // Now show the dialog
354
        p = (PlatformData*)pb->platformData;
368
        p = (PlatformData*)pb->platformData;
355
 
369
 
356
        // Note: "Invalid Cursor Handle" is the error when an unrecognized control class is detected
370
        // Note: "Invalid Cursor Handle" is the error when an unrecognized control class is detected
357
        res = DialogBoxParam(hDllInstance,MAKEINTRESOURCE(gdata->standalone ? ID_PARAMDLG : ID_MAINDLG),
371
        res = DialogBoxParam(hDllInstance,MAKEINTRESOURCE(gdata->standalone ? ID_PARAMDLG : ID_MAINDLG),
358
                             (HWND)p->hwnd,maindlgproc,0);
372
                             (HWND)p->hwnd,maindlgproc,0);
359
        if (res == 0) {
373
        if (res == 0) {
360
                simplealert(_strdup("DialogBoxParam in valid parent window handle"));
374
                simplealert((TCHAR*)TEXT("DialogBoxParam in valid parent window handle"));
361
        }
375
        }
362
        if (res == -1) {
376
        if (res == -1) {
363
                char s[100];
377
                TCHAR s[0x300];
364
                strcpy(s, "DialogBoxParam failed: ");
378
                xstrcpy(s, (TCHAR*)TEXT("DialogBoxParam failed: "));
365
                FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, s + strlen(s), 0x100, NULL);
379
                FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, s + xstrlen(s), 0x300 - xstrlen(s), NULL);
366
                dbg(s);
380
                dbg(&s[0]);
367
        }
381
        }
368
 
382
 
369
        // Clean up after the dialog has been closed
383
        // Clean up after the dialog has been closed
370
        UnregisterClass("Preview", hDllInstance);
384
        UnregisterClass(TEXT("Preview"), hDllInstance);
371
        UnregisterClass("Caution", hDllInstance);
385
        UnregisterClass(TEXT("Caution"), hDllInstance);
372
        UnregisterClass("FoundrySlider", hDllInstance);
386
        UnregisterClass(TEXT("FoundrySlider"), hDllInstance);
373
        Slider_Uninit_PluginDll();
387
        Slider_Uninit_PluginDll();
374
 
388
 
375
        return res == IDOK;
389
        return res == IDOK;
376
}
390
}