Subversion Repositories filter_foundry

Rev

Rev 102 | Rev 107 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 102 Rev 106
Line 1... Line 1...
1
/*
1
/*
2
    This file is part of "Filter Foundry", a filter plugin for Adobe Photoshop
2
    This file is part of "Filter Foundry", a filter plugin for Adobe Photoshop
3
    Copyright (C) 2003-7 Toby Thain, toby@telegraphics.com.au
3
    Copyright (C) 2003-7 Toby Thain, toby@telegraphics.com.au
4
 
4
 
5
    This program is free software; you can redistribute it and/or modify
5
    This program is free software; you can redistribute it and/or modify
6
    it under the terms of the GNU General Public License as published by  
6
    it under the terms of the GNU General Public License as published by
7
    the Free Software Foundation; either version 2 of the License, or
7
    the Free Software Foundation; either version 2 of the License, or
8
    (at your option) any later version.
8
    (at your option) any later version.
9
 
9
 
10
    This program is distributed in the hope that it will be useful,
10
    This program is distributed in the hope that it will be useful,
11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
    GNU General Public License for more details.
13
    GNU General Public License for more details.
14
 
14
 
15
    You should have received a copy of the GNU General Public License  
15
    You should have received a copy of the GNU General Public License
16
    along with this program; if not, write to the Free Software
16
    along with this program; if not, write to the Free Software
17
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
*/
18
*/
19
 
19
 
20
/* Win32 user interface routines */
20
/* Win32 user interface routines */
Line 29... Line 29...
29
#include "ff.h"
29
#include "ff.h"
30
 
30
 
31
#include "version.h"
31
#include "version.h"
32
 
32
 
33
HWND preview_hwnd;
33
HWND preview_hwnd;
-
 
34
HCURSOR hCurHandOpen;
-
 
35
HCURSOR hCurHandGrab;
34
 
36
 
35
extern HANDLE hDllInstance;
37
extern HANDLE hDllInstance;
36
 
38
 
37
void DoAbout(AboutRecordPtr pb){
39
void DoAbout(AboutRecordPtr pb){
38
        char s[0x200];
40
        char s[0x200];
Line 44... Line 46...
44
        if(gdata && gdata->standalone)
46
        if(gdata && gdata->standalone)
45
                sprintf(s+n, "Standalone filter:\n%s by %s.\n%s",
47
                sprintf(s+n, "Standalone filter:\n%s by %s.\n%s",
46
                        INPLACEP2CSTR(gdata->parm.title),
48
                        INPLACEP2CSTR(gdata->parm.title),
47
                        INPLACEP2CSTR(gdata->parm.author),
49
                        INPLACEP2CSTR(gdata->parm.author),
48
                        INPLACEP2CSTR(gdata->parm.copyright));
50
                        INPLACEP2CSTR(gdata->parm.copyright));
49
        else
51
        else
50
                strcat(s,
52
                strcat(s,
51
"Latest version available from http://www.telegraphics.com.au/sw/\n\
53
"Latest version available from http://www.telegraphics.com.au/sw/\n\
52
Please contact the author with any bug reports, suggestions or comments.\n\
54
Please contact the author with any bug reports, suggestions or comments.\n\
53
If you use this program and like it, please consider making a donation\n\
55
If you use this program and like it, please consider making a donation\n\
54
through www.paypal.com (US$5 suggested) to the address above.");
56
through www.paypal.com (US$5 suggested) to the address above.");
Line 70... Line 72...
70
        POINT newpos;
72
        POINT newpos;
71
        DRAWITEMSTRUCT *pdi;
73
        DRAWITEMSTRUCT *pdi;
72
        Point newscroll;
74
        Point newscroll;
73
        HFONT hfnt;
75
        HFONT hfnt;
74
        char s[0x100];
76
        char s[0x100];
75
       
77
 
76
        extern Boolean doupdates;
78
        extern Boolean doupdates;
77
        extern Handle preview_handle;
79
        extern Handle preview_handle;
78
 
80
 
79
        switch(wMsg){
81
        switch(wMsg){
80
        case WM_INITDIALOG:
82
        case WM_INITDIALOG:
-
 
83
                gdata->hWndMainDlg = hDlg;
-
 
84
 
81
                if(gdata->standalone){
85
                if(gdata->standalone){
82
                        myp2cstrcpy(s,gdata->parm.title);
86
                        myp2cstrcpy(s,gdata->parm.title);
83
                        SetWindowText(hDlg,s); // window title bar
87
                        SetWindowText(hDlg,s); // window title bar
84
                }
88
                }
85
                centre_window(hDlg);
89
                centre_window(hDlg);
86
 
90
 
87
                // see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/fontext_3pbo.asp
91
                // see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/fontext_3pbo.asp
88
                hfnt = GetStockObject(ANSI_FIXED_FONT);
92
                hfnt = GetStockObject(ANSI_FIXED_FONT);
89
       
93
 
-
 
94
                hCurHandOpen = LoadCursor(hDllInstance, MAKEINTRESOURCE(IDC_FF_HAND_OPEN));
-
 
95
                hCurHandGrab = LoadCursor(hDllInstance, MAKEINTRESOURCE(IDC_FF_HAND_GRAB));
-
 
96
 
90
                preview_hwnd = GetDlgItem(hDlg, PREVIEWITEM);
97
                preview_hwnd = GetDlgItem(hDlg, PREVIEWITEM);
91
                GetClientRect(preview_hwnd, &preview_rect);
98
                GetClientRect(preview_hwnd, &preview_rect);
-
 
99
                SetClassLongPtr(preview_hwnd, GCL_HCURSOR, (LONG_PTR)hCurHandOpen);
92
 
100
 
93
                for(i = 0; i < 8; ++i){
101
                for(i = 0; i < 8; ++i){
94
                        SendDlgItemMessage(hDlg,FIRSTCTLITEM+i,         TBM_SETRANGE,TRUE,MAKELONG(0,255));
102
                        SendDlgItemMessage(hDlg,FIRSTCTLITEM+i,         TBM_SETRANGE,TRUE,MAKELONG(0,255));
95
                        SendDlgItemMessage(hDlg,FIRSTCTLITEM+i,         TBM_SETTICFREQ,SLIDERPAGE,0);
103
                        SendDlgItemMessage(hDlg,FIRSTCTLITEM+i,         TBM_SETTICFREQ,SLIDERPAGE,0);
96
                        SendDlgItemMessage(hDlg,FIRSTCTLITEM+i,         TBM_SETPAGESIZE,0,SLIDERPAGE);
104
                        SendDlgItemMessage(hDlg,FIRSTCTLITEM+i,         TBM_SETPAGESIZE,0,SLIDERPAGE);
97
                        SendDlgItemMessage(hDlg,FIRSTCTLTEXTITEM+i,     EM_SETLIMITTEXT,3,0);
105
                        SendDlgItemMessage(hDlg,FIRSTCTLTEXTITEM+i,     EM_SETLIMITTEXT,3,0);
98
                }
106
                }
99
                for(i = 0; i < 4; ++i){
107
                for(i = 0; i < 4; ++i){
100
                        SendDlgItemMessage(hDlg,FIRSTEXPRITEM+i,        EM_SETLIMITTEXT,MAXEXPR,0);
108
                        SendDlgItemMessage(hDlg,FIRSTEXPRITEM+i,        EM_SETLIMITTEXT,MAXEXPR-1,0); // we need 1 byte as NUL terminator, so our formula can be max 1023
101
                        SendDlgItemMessage(hDlg,FIRSTEXPRITEM+i,        WM_SETFONT,(WPARAM)hfnt,false);
109
                        SendDlgItemMessage(hDlg,FIRSTEXPRITEM+i,        WM_SETFONT,(WPARAM)hfnt,false);
102
                }
110
                }
103
 
111
 
104
                maindlginit(hDlg);
112
                maindlginit(hDlg);
105
                break;
113
                break;
-
 
114
        case WM_DESTROY:
-
 
115
                gdata->hWndMainDlg = 0;
-
 
116
                break;
106
        case WM_DRAWITEM:
117
        case WM_DRAWITEM:
107
                pdi = (DRAWITEMSTRUCT*)lParam;
118
                pdi = (DRAWITEMSTRUCT*)lParam;
108
                if(pdi->itemAction == ODA_DRAWENTIRE){
119
                if(pdi->itemAction == ODA_DRAWENTIRE){
109
                        switch(pdi->CtlID){
120
                        switch(pdi->CtlID){
110
                        case PREVIEWITEM:
121
                        case PREVIEWITEM:
Line 122... Line 133...
122
                switch(HIWORD(wParam)){
133
                switch(HIWORD(wParam)){
123
                case BN_CLICKED: //case STN_CLICKED:
134
                case BN_CLICKED: //case STN_CLICKED:
124
                        if(item==PREVIEWITEM && GetCursorPos(&origpos)){
135
                        if(item==PREVIEWITEM && GetCursorPos(&origpos)){
125
                                panning = true;
136
                                panning = true;
126
                                origscroll = preview_scroll;
137
                                origscroll = preview_scroll;
-
 
138
                                SetCursor(hCurHandGrab);
127
                                SetCapture(hDlg);
139
                                SetCapture(hDlg);
128
                                break;
140
                                break;
129
                        }
141
                        }
130
                case EN_CHANGE:
142
                case EN_CHANGE:
131
                        if(doupdates && !maindlgitem(hDlg,item))
143
                        if(doupdates && !maindlgitem(hDlg,item))
Line 158... Line 170...
158
 
170
 
159
        return true;
171
        return true;
160
}
172
}
161
 
173
 
162
Boolean maindialog(FilterRecordPtr pb){
174
Boolean maindialog(FilterRecordPtr pb){
-
 
175
 
-
 
176
        // For the preview image, we register a class, so that we can assign a mouse cursor to this class.
-
 
177
        WNDCLASSEX clx;
-
 
178
        clx.cbSize = sizeof(WNDCLASSEX);
-
 
179
        GetClassInfoEx(hDllInstance, "Static", &clx);
-
 
180
        clx.lpszClassName = "Preview";
-
 
181
        RegisterClassEx(&clx);
-
 
182
 
-
 
183
        // Now show the dialog
163
        PlatformData *p = pb->platformData;
184
        PlatformData *p = pb->platformData;
164
        return DialogBoxParam(hDllInstance,MAKEINTRESOURCE(gdata->standalone ? ID_PARAMDLG : ID_MAINDLG),
185
        return DialogBoxParam(hDllInstance,MAKEINTRESOURCE(gdata->standalone ? ID_PARAMDLG : ID_MAINDLG),
165
                                                  (HWND)p->hwnd,maindlgproc,0) == IDOK;
186
                                                  (HWND)p->hwnd,maindlgproc,0) == IDOK;
166
}
187
}
167
 
188