Subversion Repositories filter_foundry

Rev

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

Rev 393 Rev 444
Line 31... Line 31...
31
void builddlginit(DIALOGREF dp){
31
void builddlginit(DIALOGREF dp){
32
        int i;
32
        int i;
33
        char s[0x100];
33
        char s[0x100];
34
 
34
 
35
        if(gdata->parmloaded){
35
        if(gdata->parmloaded){
36
                SetDlgItemText(dp,CATEGORYITEM, gdata->parm.szCategory);
36
                SetDlgItemTextA(dp,CATEGORYITEM, gdata->parm.szCategory);
37
                SetDlgItemText(dp,TITLEITEM,    gdata->parm.szTitle);
37
                SetDlgItemTextA(dp,TITLEITEM,    gdata->parm.szTitle);
38
                SetDlgItemText(dp,COPYRIGHTITEM,gdata->parm.szCopyright);
38
                SetDlgItemTextA(dp,COPYRIGHTITEM,gdata->parm.szCopyright);
39
                SetDlgItemText(dp,AUTHORITEM,   gdata->parm.szAuthor);
39
                SetDlgItemTextA(dp,AUTHORITEM,   gdata->parm.szAuthor);
40
                for(i=0;i<4;++i){
40
                for(i=0;i<4;++i){
41
                        SetDlgItemText(dp,FIRSTMAPNAMEITEM+i,gdata->parm.szMap[i]);
41
                        SetDlgItemTextA(dp,FIRSTMAPNAMEITEM+i,gdata->parm.szMap[i]);
42
                }
42
                }
43
                for(i=0;i<8;++i){
43
                for(i=0;i<8;++i){
44
                        SetDlgItemText(dp,FIRSTCTLNAMEITEM+i,gdata->parm.szCtl[i]);
44
                        SetDlgItemTextA(dp,FIRSTCTLNAMEITEM+i,gdata->parm.szCtl[i]);
45
                }
45
                }
46
        }else{
46
        }else{
47
                /* strictly speaking this is not needed on the Mac,
47
                /* strictly speaking this is not needed on the Mac,
48
                   we can set initial values statically in the rez description */
48
                   we can set initial values statically in the rez description */
49
                SetDlgItemText(dp,CATEGORYITEM, "Filter Foundry");
49
                SetDlgItemTextA(dp,CATEGORYITEM, "Filter Foundry");
50
                SetDlgItemText(dp,TITLEITEM,    "Untitled");
50
                SetDlgItemTextA(dp,TITLEITEM,    "Untitled");
51
                SetDlgItemText(dp,COPYRIGHTITEM,""); //"Filter Foundry Copyright (C) 2003-2009 Toby Thain, 2018-" RELEASE_YEAR " Daniel Marschall"
51
                SetDlgItemTextA(dp,COPYRIGHTITEM,""); //"Filter Foundry Copyright (C) 2003-2009 Toby Thain, 2018-" RELEASE_YEAR " Daniel Marschall"
52
                SetDlgItemText(dp,AUTHORITEM,   "Anonymous");
52
                SetDlgItemTextA(dp,AUTHORITEM,   "Anonymous");
53
                strcpy(s,"Map X");
53
                strcpy(s,"Map X");
54
                for(i = 0; i < 4; ++i){
54
                for(i = 0; i < 4; ++i){
55
                        s[4] = '0'+i;
55
                        s[4] = '0'+i;
56
                        SetDlgItemText(dp,FIRSTMAPNAMEITEM+i,s);
56
                        SetDlgItemTextA(dp,FIRSTMAPNAMEITEM+i,s);
57
                }
57
                }
58
                strcpy(s,"ctl(X)");
58
                strcpy(s,"ctl(X)");
59
                for(i = 0; i < 8; ++i){
59
                for(i = 0; i < 8; ++i){
60
                        s[4] = '0'+i;
60
                        s[4] = '0'+i;
61
                        SetDlgItemText(dp,FIRSTCTLNAMEITEM+i,s);
61
                        SetDlgItemTextA(dp,FIRSTCTLNAMEITEM+i,s);
62
                }
62
                }
63
        }
63
        }
64
 
64
 
65
        checksliders_result = checksliders(4,ctls,maps);
65
        checksliders_result = checksliders(4,ctls,maps);
66
        for(i = 4; i--;){
66
        for(i = 4; i--;){
Line 86... Line 86...
86
        CHECKDLGBUTTON(dp, PROTECTITEM, 0); // TODO: should we remember the last setting?
86
        CHECKDLGBUTTON(dp, PROTECTITEM, 0); // TODO: should we remember the last setting?
87
 
87
 
88
        SELECTDLGITEMTEXT(dp,TITLEITEM,0,-1);
88
        SELECTDLGITEMTEXT(dp,TITLEITEM,0,-1);
89
}
89
}
90
 
90
 
-
 
91
Boolean containsUnicodeInput(DIALOGREF dp, int item) {
-
 
92
        enum { MAXFIELD = 0x100 };
-
 
93
        char s[MAXFIELD + 1];
-
 
94
        wchar_t sw[MAXFIELD + 1];
-
 
95
        size_t i;
-
 
96
 
-
 
97
        GetDlgItemTextA(dp, item, s, MAXFIELD);
-
 
98
        GetDlgItemTextW(dp, item, sw, MAXFIELD);
-
 
99
        for (i = 0; i < strlen(s); i++) {
-
 
100
                if (((wchar_t)s[i] != sw[i]) && (s[i] == '?')) {
-
 
101
                        return true;
-
 
102
                }
-
 
103
        }
-
 
104
 
-
 
105
        return false;
-
 
106
}
-
 
107
 
-
 
108
Boolean containsExtCharset(DIALOGREF dp, int item) {
-
 
109
        enum { MAXFIELD = 0x100 };
-
 
110
        char s[MAXFIELD + 1];
-
 
111
        size_t i;
-
 
112
 
-
 
113
        GetDlgItemTextA(dp, item, s, MAXFIELD);
-
 
114
        for (i = 0; i < strlen(s); i++) {
-
 
115
                if ((unsigned char)s[i] > (unsigned char)0x7F) {
-
 
116
                        return true;
-
 
117
                }
-
 
118
        }
-
 
119
 
-
 
120
        return false;
-
 
121
}
91
 
122
 
92
/* process an item hit. return false if the dialog is finished; otherwise return true. */
123
/* process an item hit. return false if the dialog is finished; otherwise return true. */
93
 
124
 
94
Boolean builddlgitem(DIALOGREF dp,int item){
125
Boolean builddlgitem(DIALOGREF dp,int item){
95
        enum{MAXFIELD=0x100};
126
        enum{MAXFIELD=0x100};
96
        char s[MAXFIELD+1];
127
        char s[MAXFIELD+1];
97
        int i,needui;
128
        int i,needui;
98
        char fname[256];
129
        TCHAR fname[MAX_PATH + 1];
99
        StandardFileReply sfr;
130
        StandardFileReply sfr;
100
        NavReplyRecord reply;
131
        NavReplyRecord reply;
-
 
132
        #ifdef UNICODE
-
 
133
        Boolean unicode;
-
 
134
        #endif
-
 
135
        Boolean extCharset;
101
 
136
 
102
        switch(item){
137
        switch(item){
103
#ifdef MAC_ENV
138
#ifdef MAC_ENV
104
        case ok:
139
        case ok:
105
#else
140
#else
106
        case IDOK:
141
        case IDOK:
107
#endif
142
#endif
108
                // Do a few checks first
143
                // Do a few checks first
109
                GetDlgItemText(dp, CATEGORYITEM, s, MAXFIELD);
144
                GetDlgItemTextA(dp, CATEGORYITEM, s, MAXFIELD);
110
                if (strlen(s) == 0) {
145
                if (strlen(s) == 0) {
111
                        simplealert(_strdup("Category must not be empty!"));
146
                        simplealert((TCHAR*)TEXT("Category must not be empty!"));
112
                        return true; // don't continue (i.e. don't call EndDialog). Let the user correct the input
147
                        return true; // don't continue (i.e. don't call EndDialog). Let the user correct the input
113
                }
148
                }
114
                GetDlgItemText(dp, TITLEITEM, s, MAXFIELD);
149
                GetDlgItemTextA(dp, TITLEITEM, s, MAXFIELD);
115
                if (strlen(s) == 0) {
150
                if (strlen(s) == 0) {
116
                        simplealert(_strdup("Title must not be empty!"));
151
                        simplealert((TCHAR*)TEXT("Title must not be empty!"));
117
                        return true; // don't continue (i.e. don't call EndDialog). Let the user correct the input
152
                        return true; // don't continue (i.e. don't call EndDialog). Let the user correct the input
118
                }
153
                }
119
 
154
 
-
 
155
                // The PiPL and PARM structure does only define single byte charsets
-
 
156
                #ifdef UNICODE
-
 
157
                unicode =
-
 
158
                        containsUnicodeInput(dp, CATEGORYITEM) ||
-
 
159
                        containsUnicodeInput(dp, TITLEITEM) ||
-
 
160
                        containsUnicodeInput(dp, COPYRIGHTITEM) ||
-
 
161
                        containsUnicodeInput(dp, AUTHORITEM);
-
 
162
                #endif
-
 
163
                extCharset =
-
 
164
                        containsExtCharset(dp, CATEGORYITEM) ||
-
 
165
                        containsExtCharset(dp, TITLEITEM) ||
-
 
166
                        containsExtCharset(dp, COPYRIGHTITEM) ||
-
 
167
                        containsExtCharset(dp, AUTHORITEM);
-
 
168
 
-
 
169
                // The AETE structure does only define single byte charsets
-
 
170
                for (i = 0; i < 8; ++i) {
-
 
171
                        if (ctls[i] || (checksliders_result & CHECKSLIDERS_CTL_AMBIGUOUS)) {
-
 
172
                                #ifdef UNICODE
-
 
173
                                unicode |= containsUnicodeInput(dp, FIRSTCTLNAMEITEM + i);
-
 
174
                                #endif
-
 
175
                                extCharset |= containsExtCharset(dp, FIRSTCTLNAMEITEM + i);
-
 
176
                        }
-
 
177
                }
-
 
178
                for (i = 0; i < 4; ++i) {
-
 
179
                        if (maps[i] || (checksliders_result & CHECKSLIDERS_MAP_AMBIGUOUS)) {
-
 
180
                                #ifdef UNICODE
-
 
181
                                unicode |= containsUnicodeInput(dp, FIRSTMAPNAMEITEM + i);
-
 
182
                                #endif
-
 
183
                                extCharset |= containsExtCharset(dp, FIRSTMAPNAMEITEM + i);
-
 
184
                        }
-
 
185
                }
-
 
186
 
-
 
187
                #ifdef UNICODE
-
 
188
                if (unicode) {
-
 
189
                        simplewarning((TCHAR*)TEXT("The internal structures of Photoshop and Filter Factory are not compatible with Unicode characters. It is highly recommended that you only use characters of your current charset. Unicode characters will be converted into question mark symbols."));
-
 
190
                }
-
 
191
                else
-
 
192
                #endif
-
 
193
                if (extCharset) {
-
 
194
                        simplewarning((TCHAR*)TEXT("You were using characters of an extended charset. The characters might look correct on your machine, but on a machine in a different country, the characters might look wrong. Please consider using the ASCII character set only (i.e. Latin characters without accent marks)."));
-
 
195
                }
-
 
196
 
120
                // Now begin
197
                // Now begin
121
                memset(&gdata->parm,0,sizeof(PARM_T));
198
                memset(&gdata->parm,0,sizeof(PARM_T));
122
                GetDlgItemText(dp,CATEGORYITEM,gdata->parm.szCategory,MAXFIELD-4/*ProtectFlag*/);
199
                GetDlgItemTextA(dp,CATEGORYITEM,gdata->parm.szCategory,MAXFIELD-4/*ProtectFlag*/);
123
                GetDlgItemText(dp,TITLEITEM,gdata->parm.szTitle,MAXFIELD);
200
                GetDlgItemTextA(dp,TITLEITEM,gdata->parm.szTitle,MAXFIELD);
124
                GetDlgItemText(dp,COPYRIGHTITEM,gdata->parm.szCopyright,MAXFIELD);
201
                GetDlgItemTextA(dp,COPYRIGHTITEM,gdata->parm.szCopyright,MAXFIELD);
125
                GetDlgItemText(dp,AUTHORITEM,gdata->parm.szAuthor,MAXFIELD);
202
                GetDlgItemTextA(dp,AUTHORITEM,gdata->parm.szAuthor,MAXFIELD);
126
                gdata->parm.cbSize = PARM_SIZE;
203
                gdata->parm.cbSize = PARM_SIZE;
127
                gdata->parm.standalone = 1;  //0=original FF, 1=standalone filter
204
                gdata->parm.standalone = 1;  //0=original FF, 1=standalone filter
128
                needui = 0;
205
                needui = 0;
129
                // Sliders
206
                // Sliders
130
                for(i = 0; i < 8; ++i){
207
                for(i = 0; i < 8; ++i){
131
                        gdata->parm.val[i] = slider[i];
208
                        gdata->parm.val[i] = slider[i];
132
                        gdata->parm.ctl_used[i] = ctls[i] || (checksliders_result & CHECKSLIDERS_CTL_AMBIGUOUS);
209
                        gdata->parm.ctl_used[i] = ctls[i] || (checksliders_result & CHECKSLIDERS_CTL_AMBIGUOUS);
133
                        needui |= gdata->parm.ctl_used[i];
210
                        needui |= gdata->parm.ctl_used[i];
134
                        GetDlgItemText(dp,FIRSTCTLNAMEITEM+i, gdata->parm.szCtl[i],MAXFIELD);
211
                        GetDlgItemTextA(dp,FIRSTCTLNAMEITEM+i, gdata->parm.szCtl[i],MAXFIELD);
135
                }
212
                }
136
                // Maps
213
                // Maps
137
                for (i = 0; i < 4; ++i) {
214
                for (i = 0; i < 4; ++i) {
138
                        gdata->parm.map_used[i] = maps[i] || (checksliders_result & CHECKSLIDERS_MAP_AMBIGUOUS);
215
                        gdata->parm.map_used[i] = maps[i] || (checksliders_result & CHECKSLIDERS_MAP_AMBIGUOUS);
139
                        needui |= gdata->parm.map_used[i];
216
                        needui |= gdata->parm.map_used[i];
140
                        GetDlgItemText(dp, FIRSTMAPNAMEITEM + i, gdata->parm.szMap[i], MAXFIELD);
217
                        GetDlgItemTextA(dp, FIRSTMAPNAMEITEM + i, gdata->parm.szMap[i], MAXFIELD);
141
                }
218
                }
142
                // Expressions
219
                // Expressions
143
                for (i = 0; i < 4; ++i) {
220
                for (i = 0; i < 4; ++i) {
144
                        if (!expr[i]) {
221
                        if (!expr[i]) {
145
                                simplealert(_strdup("Bug! see builddlgitem"));
222
                                simplealert((TCHAR*)TEXT("Bug! see builddlgitem"));
146
                                return true; // keep going. Let the user try again
223
                                return true; // keep going. Let the user try again
147
                        }
224
                        }
148
                        if (strlen(expr[i]) >= sizeof(gdata->parm.szFormula[i])) {
225
                        if (strlen(expr[i]) >= sizeof(gdata->parm.szFormula[i])) {
149
                                if (i == 0) {
226
                                if (i == 0) {
150
                                        simplealert(_strdup("Attention! The formula for channel R was too long (longer than 1023 characters) and was truncated."));
227
                                        simplealert((TCHAR*)TEXT("Attention! The formula for channel R was too long (longer than 1023 characters) and was truncated."));
151
                                }
228
                                }
152
                                else if (i == 1) {
229
                                else if (i == 1) {
153
                                        simplealert(_strdup("Attention! The formula for channel G was too long (longer than 1023 characters) and was truncated."));
230
                                        simplealert((TCHAR*)TEXT("Attention! The formula for channel G was too long (longer than 1023 characters) and was truncated."));
154
                                }
231
                                }
155
                                else if (i == 2) {
232
                                else if (i == 2) {
156
                                        simplealert(_strdup("Attention! The formula for channel B was too long (longer than 1023 characters) and was truncated."));
233
                                        simplealert((TCHAR*)TEXT("Attention! The formula for channel B was too long (longer than 1023 characters) and was truncated."));
157
                                }
234
                                }
158
                                else if (i == 3) {
235
                                else if (i == 3) {
159
                                        simplealert(_strdup("Attention! The formula for channel A was too long (longer than 1023 characters) and was truncated."));
236
                                        simplealert((TCHAR*)TEXT("Attention! The formula for channel A was too long (longer than 1023 characters) and was truncated."));
160
                                }
237
                                }
161
                                expr[i][sizeof(gdata->parm.szFormula[i]) - 1] = '\0';
238
                                expr[i][sizeof(gdata->parm.szFormula[i]) - 1] = '\0';
162
                        }
239
                        }
163
                        strcpy(gdata->parm.szFormula[i], expr[i]);
240
                        strcpy(gdata->parm.szFormula[i], expr[i]);
164
                }
241
                }
165
                gdata->parm.popDialog = needui; //true if need to pop a parameter dialog
242
                gdata->parm.popDialog = needui; //true if need to pop a parameter dialog
166
                gdata->parm.unknown1 = gdata->parm.unknown2 = gdata->parm.unknown3 = 0;
243
                gdata->parm.unknown1 = gdata->parm.unknown2 = gdata->parm.unknown3 = 0;
167
                gdata->parm.iProtected = ISDLGBUTTONCHECKED(dp,PROTECTITEM); // == 1 means protected
244
                gdata->parm.iProtected = ISDLGBUTTONCHECKED(dp,PROTECTITEM); // == 1 means protected
168
                gdata->obfusc = ISDLGBUTTONCHECKED(dp,PROTECTITEM);
245
                gdata->obfusc = ISDLGBUTTONCHECKED(dp,PROTECTITEM);
169
 
246
 
-
 
247
                // TODO: Unicode!
170
                strcpy(fname, gdata->parm.szTitle);
248
                //xstrcpy(fname, gdata->parm.szTitle);
-
 
249
                /*
-
 
250
                for (i = 0; i < (int)strlen(gdata->parm.szTitle); i++) {
-
 
251
                        fname[i] = gdata->parm.szTitle[i];
-
 
252
                        fname[i + 1] = 0;
-
 
253
                }
-
 
254
                */
-
 
255
                GetDlgItemText(dp, TITLEITEM, fname, MAXFIELD);
-
 
256
 
171
                #ifdef MACMACHO
257
                #ifdef MACMACHO
172
                strcat(fname, ".plugin");
258
                strcat(fname, ".plugin");
173
                #endif
259
                #endif
174
                if (putfile(
260
                if (putfile(
175
                        #ifdef MAC_ENV
261
                        #ifdef MAC_ENV
176
                        (StringPtr)_strdup("\pMake standalone filter"), // "\p" means "Pascal string"
262
                        (StringPtr)_strdup("\pMake standalone filter"), // "\p" means "Pascal string"
177
                        #else
-
 
178
                        (StringPtr)_strdup("\026Make standalone filter"),
-
 
179
                        #endif
-
 
180
                        (StringPtr)myc2pstr(_strdup(fname)),
263
                        (StringPtr)myc2pstr(_strdup(fname)),
181
                        PS_FILTER_FILETYPE, kPhotoshopSignature, &reply, &sfr,
264
                        PS_FILTER_FILETYPE, kPhotoshopSignature, & reply, & sfr,
182
                        "8bf", "Filter plugin file (.8bf)\0*.8bf\0\0", 1
265
                        "8bf", "Filter plugin file (.8bf)\0*.8bf\0\0", 1
-
 
266
                        #else
-
 
267
                        TEXT("Make standalone filter"),
-
 
268
                        fname,
-
 
269
                        PS_FILTER_FILETYPE, kPhotoshopSignature, & reply, & sfr,
183
                        #ifdef _WIN32
270
                        TEXT("8bf"),
-
 
271
                        TEXT("Filter plugin file (.8bf)\0*.8bf\0\0"), 1
184
                        , (HWND)dp
272
                        , (HWND)dp
185
                        #endif /* _WIN32 */
273
                        #endif
186
                )) {
274
                )) {
187
                        make_standalone(&sfr);
275
                        make_standalone(&sfr);
188
                }
276
                }
189
                else {
277
                else {
190
                        return true; // keep going. Let the user correct their input
278
                        return true; // keep going. Let the user correct their input