Subversion Repositories filter_foundry

Rev

Rev 256 | Rev 339 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 256 Rev 259
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-2009 Toby Thain, toby@telegraphics.com.au
3
    Copyright (C) 2003-2009 Toby Thain, toby@telegraphics.com.au
4
    Copyright (C) 2018-2021 Daniel Marschall, ViaThinkSoft
4
    Copyright (C) 2018-2021 Daniel Marschall, ViaThinkSoft
5
 
5
 
6
    This program is free software; you can redistribute it and/or modify
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
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
8
    the Free Software Foundation; either version 2 of the License, or
9
    (at your option) any later version.
9
    (at your option) any later version.
10
 
10
 
11
    This program is distributed in the hope that it will be useful,
11
    This program is distributed in the hope that it will be useful,
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
    GNU General Public License for more details.
14
    GNU General Public License for more details.
15
 
15
 
16
    You should have received a copy of the GNU General Public License
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
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
18
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
*/
19
*/
20
 
20
 
21
/* This is PLATFORM INDEPENDENT user interface code - mainly dialog logic */
21
/* This is PLATFORM INDEPENDENT user interface code - mainly dialog logic */
22
 
22
 
23
#include "ff.h"
23
#include "ff.h"
24
 
24
 
25
int ctls[8],maps[4];
25
int ctls[8],maps[4];
26
int checksliders_result;
26
int checksliders_result;
27
 
27
 
28
/* one-time initialisation of dialog box */
28
/* one-time initialisation of dialog box */
29
 
29
 
30
void builddlginit(DIALOGREF dp){
30
void builddlginit(DIALOGREF dp){
31
        int i;
31
        int i;
32
        char s[0x100];
32
        char s[0x100];
33
 
33
 
34
        if(gdata->parmloaded){
34
        if(gdata->parmloaded){
35
                SetDlgItemText(dp,CATEGORYITEM, INPLACEP2CSTR(gdata->parm.category));
35
                SetDlgItemText(dp,CATEGORYITEM, INPLACEP2CSTR(gdata->parm.category));
36
                SetDlgItemText(dp,TITLEITEM,    INPLACEP2CSTR(gdata->parm.title));
36
                SetDlgItemText(dp,TITLEITEM,    INPLACEP2CSTR(gdata->parm.title));
37
                SetDlgItemText(dp,COPYRIGHTITEM,INPLACEP2CSTR(gdata->parm.copyright));
37
                SetDlgItemText(dp,COPYRIGHTITEM,INPLACEP2CSTR(gdata->parm.copyright));
38
                SetDlgItemText(dp,AUTHORITEM,   INPLACEP2CSTR(gdata->parm.author));
38
                SetDlgItemText(dp,AUTHORITEM,   INPLACEP2CSTR(gdata->parm.author));
39
                for(i=0;i<4;++i){
39
                for(i=0;i<4;++i){
40
                        SetDlgItemText(dp,FIRSTMAPNAMEITEM+i,INPLACEP2CSTR(gdata->parm.map[i]));
40
                        SetDlgItemText(dp,FIRSTMAPNAMEITEM+i,INPLACEP2CSTR(gdata->parm.map[i]));
41
                }
41
                }
42
                for(i=0;i<8;++i){
42
                for(i=0;i<8;++i){
43
                        SetDlgItemText(dp,FIRSTCTLNAMEITEM+i,INPLACEP2CSTR(gdata->parm.ctl[i]));
43
                        SetDlgItemText(dp,FIRSTCTLNAMEITEM+i,INPLACEP2CSTR(gdata->parm.ctl[i]));
44
                }
44
                }
45
        }else{
45
        }else{
46
                /* strictly speaking this is not needed on the Mac,
46
                /* strictly speaking this is not needed on the Mac,
47
                   we can set initial values statically in the rez description */
47
                   we can set initial values statically in the rez description */
48
                SetDlgItemText(dp,CATEGORYITEM, "Filter Foundry");
48
                SetDlgItemText(dp,CATEGORYITEM, "Filter Foundry");
49
                SetDlgItemText(dp,TITLEITEM,    "Untitled");
49
                SetDlgItemText(dp,TITLEITEM,    "Untitled");
50
                SetDlgItemText(dp,COPYRIGHTITEM,""); //"Filter Foundry Copyright (C) 2003-2009 Toby Thain, 2018-" RELEASE_YEAR " Daniel Marschall"
50
                SetDlgItemText(dp,COPYRIGHTITEM,""); //"Filter Foundry Copyright (C) 2003-2009 Toby Thain, 2018-" RELEASE_YEAR " Daniel Marschall"
51
                SetDlgItemText(dp,AUTHORITEM,   "Anonymous");
51
                SetDlgItemText(dp,AUTHORITEM,   "Anonymous");
52
                strcpy(s,"Map X");
52
                strcpy(s,"Map X");
53
                for(i = 0; i < 4; ++i){
53
                for(i = 0; i < 4; ++i){
54
                        s[4] = '0'+i;
54
                        s[4] = '0'+i;
55
                        SetDlgItemText(dp,FIRSTMAPNAMEITEM+i,s);
55
                        SetDlgItemText(dp,FIRSTMAPNAMEITEM+i,s);
56
                }
56
                }
57
                strcpy(s,"ctl(X)");
57
                strcpy(s,"ctl(X)");
58
                for(i = 0; i < 8; ++i){
58
                for(i = 0; i < 8; ++i){
59
                        s[4] = '0'+i;
59
                        s[4] = '0'+i;
60
                        SetDlgItemText(dp,FIRSTCTLNAMEITEM+i,s);
60
                        SetDlgItemText(dp,FIRSTCTLNAMEITEM+i,s);
61
                }
61
                }
62
        }
62
        }
63
 
63
 
64
        checksliders_result = checksliders(4,ctls,maps);
64
        checksliders_result = checksliders(4,ctls,maps);
65
        for(i = 4; i--;){
65
        for(i = 4; i--;){
66
                DISABLEDLGITEM(dp,FIRSTMAPCHECKITEM+i);
66
                DISABLEDLGITEM(dp,FIRSTMAPCHECKITEM+i);
67
                if(maps[i] || (checksliders_result & CHECKSLIDERS_MAP_AMBIGUOUS))
67
                if(maps[i] || (checksliders_result & CHECKSLIDERS_MAP_AMBIGUOUS))
68
                        CHECKDLGBUTTON(dp,FIRSTMAPCHECKITEM+i,true);
68
                        CHECKDLGBUTTON(dp,FIRSTMAPCHECKITEM+i,true);
69
                else
69
                else
70
                        HideDialogItem(dp,FIRSTMAPNAMEITEM+i);
70
                        HideDialogItem(dp,FIRSTMAPNAMEITEM+i);
71
        }
71
        }
72
        for(i = 8; i--;){
72
        for(i = 8; i--;){
73
                DISABLEDLGITEM(dp,FIRSTCTLCHECKITEM+i);
73
                DISABLEDLGITEM(dp,FIRSTCTLCHECKITEM+i);
74
                if((ctls[i] || (checksliders_result & CHECKSLIDERS_CTL_AMBIGUOUS)) &&
74
                if((ctls[i] || (checksliders_result & CHECKSLIDERS_CTL_AMBIGUOUS)) &&
75
                   // When map() is activated, we don't need ctl labels,
75
                   // When map() is activated, we don't need ctl labels,
76
                   // since the standalone filter will only show map labels
76
                   // since the standalone filter will only show map labels
77
                   !maps[i/2] &&
77
                   !maps[i/2] &&
78
                   (!(checksliders_result & CHECKSLIDERS_MAP_AMBIGUOUS))
78
                   (!(checksliders_result & CHECKSLIDERS_MAP_AMBIGUOUS))
79
                   )
79
                   )
80
                        CHECKDLGBUTTON(dp,FIRSTCTLCHECKITEM+i,true);
80
                        CHECKDLGBUTTON(dp,FIRSTCTLCHECKITEM+i,true);
81
                else
81
                else
82
                        HideDialogItem(dp,FIRSTCTLNAMEITEM+i);
82
                        HideDialogItem(dp,FIRSTCTLNAMEITEM+i);
83
        }
83
        }
84
 
84
 
85
        SELECTDLGITEMTEXT(dp,TITLEITEM,0,-1);
85
        SELECTDLGITEMTEXT(dp,TITLEITEM,0,-1);
86
}
86
}
87
 
87
 
88
 
88
 
89
/* process an item hit. return false if the dialog is finished; otherwise return true. */
89
/* process an item hit. return false if the dialog is finished; otherwise return true. */
90
 
90
 
91
Boolean builddlgitem(DIALOGREF dp,int item){
91
Boolean builddlgitem(DIALOGREF dp,int item){
92
        enum{MAXFIELD=0x100};
92
        enum{MAXFIELD=0x100};
93
        char s[MAXFIELD+1];
93
        char s[MAXFIELD+1];
94
        int i,needui;
94
        int i,needui;
95
 
95
 
96
        switch(item){
96
        switch(item){
97
        case IDOK:
97
        case IDOK:
98
                // Do a few checks first
98
                // Do a few checks first
99
                GetDlgItemText(dp, CATEGORYITEM, s, MAXFIELD);
99
                GetDlgItemText(dp, CATEGORYITEM, s, MAXFIELD);
100
                if (strlen(s) == 0) {
100
                if (strlen(s) == 0) {
101
                        simplealert(_strdup("Category must not be empty!"));
101
                        simplealert(_strdup("Category must not be empty!"));
102
                        return false;
102
                        return false;
103
                }
103
                }
104
                GetDlgItemText(dp, TITLEITEM, s, MAXFIELD);
104
                GetDlgItemText(dp, TITLEITEM, s, MAXFIELD);
105
                if (strlen(s) == 0) {
105
                if (strlen(s) == 0) {
106
                        simplealert(_strdup("Title must not be empty!"));
106
                        simplealert(_strdup("Title must not be empty!"));
107
                        return false;
107
                        return false;
108
                }
108
                }
109
 
109
 
110
                // Now begin
110
                // Now begin
111
                memset(&gdata->parm,0,sizeof(PARM_T));
111
                memset(&gdata->parm,0,sizeof(PARM_T));
112
                GetDlgItemText(dp,CATEGORYITEM,s,MAXFIELD);             myc2pstrcpy(gdata->parm.category,s);
112
                GetDlgItemText(dp,CATEGORYITEM,s,MAXFIELD);             myc2pstrcpy(gdata->parm.category,s);
113
                GetDlgItemText(dp,TITLEITEM,s,MAXFIELD);                myc2pstrcpy(gdata->parm.title,s);
113
                GetDlgItemText(dp,TITLEITEM,s,MAXFIELD);                myc2pstrcpy(gdata->parm.title,s);
114
                GetDlgItemText(dp,COPYRIGHTITEM,s,MAXFIELD);    myc2pstrcpy(gdata->parm.copyright,s);
114
                GetDlgItemText(dp,COPYRIGHTITEM,s,MAXFIELD);    myc2pstrcpy(gdata->parm.copyright,s);
115
                GetDlgItemText(dp,AUTHORITEM,s,MAXFIELD);               myc2pstrcpy(gdata->parm.author,s);
115
                GetDlgItemText(dp,AUTHORITEM,s,MAXFIELD);               myc2pstrcpy(gdata->parm.author,s);
116
                gdata->parm.cbSize = PARM_SIZE;
116
                gdata->parm.cbSize = PARM_SIZE;
117
                gdata->parm.standalone = 1;  //0=original FF, 1=standalone filter
117
                gdata->parm.standalone = 1;  //0=original FF, 1=standalone filter
118
                needui = 0;
118
                needui = 0;
119
                for(i = 0; i < 8; ++i){
119
                for(i = 0; i < 8; ++i){
120
                        gdata->parm.val[i] = slider[i];
120
                        gdata->parm.val[i] = slider[i];
121
                        gdata->parm.ctl_used[i] = ctls[i] || (checksliders_result & CHECKSLIDERS_CTL_AMBIGUOUS);
121
                        gdata->parm.ctl_used[i] = ctls[i] || (checksliders_result & CHECKSLIDERS_CTL_AMBIGUOUS);
122
                        needui |= gdata->parm.ctl_used[i];
122
                        needui |= gdata->parm.ctl_used[i];
123
                        GetDlgItemText(dp,FIRSTCTLNAMEITEM+i,s,MAXFIELD); myc2pstrcpy(gdata->parm.ctl[i],s);
123
                        GetDlgItemText(dp,FIRSTCTLNAMEITEM+i,s,MAXFIELD); myc2pstrcpy(gdata->parm.ctl[i],s);
124
                }
124
                }
125
                for(i = 0; i < 4; ++i){
125
                for(i = 0; i < 4; ++i){
126
                        gdata->parm.map_used[i] = maps[i] || (checksliders_result & CHECKSLIDERS_MAP_AMBIGUOUS);
126
                        gdata->parm.map_used[i] = maps[i] || (checksliders_result & CHECKSLIDERS_MAP_AMBIGUOUS);
127
                        needui |= gdata->parm.map_used[i];
127
                        needui |= gdata->parm.map_used[i];
128
                        GetDlgItemText(dp,FIRSTMAPNAMEITEM+i,s,MAXFIELD); myc2pstrcpy(gdata->parm.map[i],s);
128
                        GetDlgItemText(dp,FIRSTMAPNAMEITEM+i,s,MAXFIELD); myc2pstrcpy(gdata->parm.map[i],s);
129
                        strcpy(gdata->parm.formula[i],expr[i] ? expr[i] : "bug! see builddlgitem");
129
                        strcpy(gdata->parm.formula[i],expr[i] ? expr[i] : "bug! see builddlgitem");
130
                }
130
                }
131
                gdata->parm.popDialog = needui; //true if need to pop a parameter dialog
131
                gdata->parm.popDialog = needui; //true if need to pop a parameter dialog
132
                gdata->parm.unknown1 = gdata->parm.unknown2 = gdata->parm.unknown3 = 0;
132
                gdata->parm.unknown1 = gdata->parm.unknown2 = gdata->parm.unknown3 = 0;
133
                gdata->parm.iProtected = ISDLGBUTTONCHECKED(dp,PROTECTITEM); // == 1 means protected
133
                gdata->parm.iProtected = ISDLGBUTTONCHECKED(dp,PROTECTITEM); // == 1 means protected
134
                gdata->obfusc = ISDLGBUTTONCHECKED(dp,PROTECTITEM);
134
                gdata->obfusc = ISDLGBUTTONCHECKED(dp,PROTECTITEM);
135
                /* ... falls through ... */
135
                /* ... falls through ... */
136
        case IDCANCEL:
136
        case IDCANCEL:
137
                return false; // end dialog
137
                return false; // end dialog
138
        case PROTECTITEM:
138
        case PROTECTITEM:
139
                CHECKDLGBUTTON(dp, item, ISDLGBUTTONCHECKED(dp,item) ^ 1);
139
                CHECKDLGBUTTON(dp, item, ISDLGBUTTONCHECKED(dp,item) ^ 1);
140
                break;
140
                break;
141
        }
141
        }
142
 
142
 
143
        return true; // keep going
143
        return true; // keep going
144
}
144
}
145
 
145