Subversion Repositories filter_foundry

Rev

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

Rev 87 Rev 106
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
/* This is PLATFORM INDEPENDENT user interface code - mainly dialog logic */
20
/* This is PLATFORM INDEPENDENT user interface code - mainly dialog logic */
21
 
21
 
22
#include "ff.h"
22
#include "ff.h"
23
 
23
 
24
int ctls[8],maps[4];
24
int ctls[8],maps[4];
25
 
25
 
26
/* one-time initialisation of dialog box */
26
/* one-time initialisation of dialog box */
27
 
27
 
28
void builddlginit(DIALOGREF dp){
28
void builddlginit(DIALOGREF dp){
29
        int i;
29
        int i;
30
        char s[0x100];
30
        char s[0x100];
31
 
31
 
32
        if(gdata->parmloaded){
32
        if(gdata->parmloaded){
33
                SetDlgItemText(dp,CATEGORYITEM, INPLACEP2CSTR(gdata->parm.category));
33
                SetDlgItemText(dp,CATEGORYITEM, INPLACEP2CSTR(gdata->parm.category));
34
                SetDlgItemText(dp,TITLEITEM,    INPLACEP2CSTR(gdata->parm.title));
34
                SetDlgItemText(dp,TITLEITEM,    INPLACEP2CSTR(gdata->parm.title));
35
                SetDlgItemText(dp,COPYRIGHTITEM,INPLACEP2CSTR(gdata->parm.copyright));
35
                SetDlgItemText(dp,COPYRIGHTITEM,INPLACEP2CSTR(gdata->parm.copyright));
36
                SetDlgItemText(dp,AUTHORITEM,   INPLACEP2CSTR(gdata->parm.author));
36
                SetDlgItemText(dp,AUTHORITEM,   INPLACEP2CSTR(gdata->parm.author));
37
                for(i=0;i<4;++i){
37
                for(i=0;i<4;++i){
38
                        SetDlgItemText(dp,FIRSTMAPNAMEITEM+i,INPLACEP2CSTR(gdata->parm.map[i]));
38
                        SetDlgItemText(dp,FIRSTMAPNAMEITEM+i,INPLACEP2CSTR(gdata->parm.map[i]));
39
                }
39
                }
40
                for(i=0;i<8;++i){
40
                for(i=0;i<8;++i){
41
                        SetDlgItemText(dp,FIRSTCTLNAMEITEM+i,INPLACEP2CSTR(gdata->parm.ctl[i]));
41
                        SetDlgItemText(dp,FIRSTCTLNAMEITEM+i,INPLACEP2CSTR(gdata->parm.ctl[i]));
42
                }
42
                }
43
        }else{
43
        }else{
44
                /* strictly speaking this is not needed on the Mac,
44
                /* strictly speaking this is not needed on the Mac,
45
                   we can set initial values statically in the rez description */
45
                   we can set initial values statically in the rez description */
46
                SetDlgItemText(dp,CATEGORYITEM, "Filter Foundry");
46
                SetDlgItemText(dp,CATEGORYITEM, "Filter Foundry");
47
                SetDlgItemText(dp,TITLEITEM,    "Untitled");
47
                SetDlgItemText(dp,TITLEITEM,    "Untitled");
48
                SetDlgItemText(dp,COPYRIGHTITEM,""); //"Filter Foundry Copyright (C) 2003-5 Toby Thain, toby@telegraphics.com.au");
48
                SetDlgItemText(dp,COPYRIGHTITEM,""); //"Filter Foundry Copyright (C) 2003-5 Toby Thain, toby@telegraphics.com.au");
49
                SetDlgItemText(dp,AUTHORITEM,   "Anonymous");
49
                SetDlgItemText(dp,AUTHORITEM,   "Anonymous");
50
                strcpy(s,"Map X");
50
                strcpy(s,"Map X");
51
                for(i = 0; i < 4; ++i){
51
                for(i = 0; i < 4; ++i){
52
                        s[4] = '0'+i;
52
                        s[4] = '0'+i;
53
                        SetDlgItemText(dp,FIRSTMAPNAMEITEM+i,s);
53
                        SetDlgItemText(dp,FIRSTMAPNAMEITEM+i,s);
54
                }
54
                }
55
                strcpy(s,"ctl(X)");
55
                strcpy(s,"ctl(X)");
56
                for(i = 0; i < 8; ++i){
56
                for(i = 0; i < 8; ++i){
57
                        s[4] = '0'+i;
57
                        s[4] = '0'+i;
58
                        SetDlgItemText(dp,FIRSTCTLNAMEITEM+i,s);
58
                        SetDlgItemText(dp,FIRSTCTLNAMEITEM+i,s);
59
                }
59
                }
60
        }
60
        }
61
 
61
 
62
        if(!checksliders(4,ctls,maps)){
62
        if(!checksliders(4,ctls,maps)){
63
                for(i = 4; i--;){
63
                for(i = 4; i--;){
64
                        DISABLEDLGITEM(dp,FIRSTMAPCHECKITEM+i);
64
                        DISABLEDLGITEM(dp,FIRSTMAPCHECKITEM+i);
65
                        if(maps[i])
65
                        if(maps[i])
66
                                CHECKDLGBUTTON(dp,FIRSTMAPCHECKITEM+i,true);
66
                                CHECKDLGBUTTON(dp,FIRSTMAPCHECKITEM+i,true);
67
                        else
67
                        else
68
                                HideDialogItem(dp,FIRSTMAPNAMEITEM+i);
68
                                HideDialogItem(dp,FIRSTMAPNAMEITEM+i);
69
                }
69
                }
70
                for(i = 8; i--;){
70
                for(i = 8; i--;){
71
                        DISABLEDLGITEM(dp,FIRSTCTLCHECKITEM+i);
71
                        DISABLEDLGITEM(dp,FIRSTCTLCHECKITEM+i);
72
                        if(ctls[i])
72
                        if(ctls[i])
73
                                CHECKDLGBUTTON(dp,FIRSTCTLCHECKITEM+i,true);
73
                                CHECKDLGBUTTON(dp,FIRSTCTLCHECKITEM+i,true);
74
                        else
74
                        else
75
                                HideDialogItem(dp,FIRSTCTLNAMEITEM+i);
75
                                HideDialogItem(dp,FIRSTCTLNAMEITEM+i);
76
                }
76
                }
77
        }
77
        }
78
 
78
 
79
        SELECTDLGITEMTEXT(dp,TITLEITEM,0,-1);
79
        SELECTDLGITEMTEXT(dp,TITLEITEM,0,-1);
80
}
80
}
81
 
81
 
82
 
82
 
83
/* process an item hit. return false if the dialog is finished; otherwise return true. */
83
/* process an item hit. return false if the dialog is finished; otherwise return true. */
84
 
84
 
85
Boolean builddlgitem(DIALOGREF dp,int item){
85
Boolean builddlgitem(DIALOGREF dp,int item){
86
        enum{MAXFIELD=0x100};
86
        enum{MAXFIELD=0x100};
87
        char s[MAXFIELD+1];
87
        char s[MAXFIELD+1];
88
        int i,needui;
88
        int i,needui;
89
 
89
 
90
        switch(item){
90
        switch(item){
91
        case IDOK:
91
        case IDOK:
92
                memset(&gdata->parm,0,sizeof(PARM_T));
92
                memset(&gdata->parm,0,sizeof(PARM_T));
93
                GetDlgItemText(dp,CATEGORYITEM,s,MAXFIELD);             myc2pstrcpy(gdata->parm.category,s);
93
                GetDlgItemText(dp,CATEGORYITEM,s,MAXFIELD);             myc2pstrcpy(gdata->parm.category,s);
94
                GetDlgItemText(dp,TITLEITEM,s,MAXFIELD);                myc2pstrcpy(gdata->parm.title,s);
94
                GetDlgItemText(dp,TITLEITEM,s,MAXFIELD);                myc2pstrcpy(gdata->parm.title,s);
95
                GetDlgItemText(dp,COPYRIGHTITEM,s,MAXFIELD);    myc2pstrcpy(gdata->parm.copyright,s);
95
                GetDlgItemText(dp,COPYRIGHTITEM,s,MAXFIELD);    myc2pstrcpy(gdata->parm.copyright,s);
96
                GetDlgItemText(dp,AUTHORITEM,s,MAXFIELD);               myc2pstrcpy(gdata->parm.author,s);
96
                GetDlgItemText(dp,AUTHORITEM,s,MAXFIELD);               myc2pstrcpy(gdata->parm.author,s);
97
                gdata->parm.cbSize = PARM_SIG;
97
                gdata->parm.cbSize = PARM_SIZE;
98
                gdata->parm.nVersion = 1;  //0=original FF, 1=standalone filter
98
                gdata->parm.nVersion = 1;  //0=original FF, 1=standalone filter
99
                for(i = needui = 0; i < 8; ++i){
99
                for(i = needui = 0; i < 8; ++i){
100
                        gdata->parm.val[i] = slider[i];
100
                        gdata->parm.val[i] = slider[i];
101
                        needui |= (gdata->parm.ctl_used[i] = ctls[i]);
101
                        needui |= (gdata->parm.ctl_used[i] = ctls[i]);
102
                        GetDlgItemText(dp,FIRSTCTLNAMEITEM+i,s,MAXFIELD); myc2pstrcpy(gdata->parm.ctl[i],s);
102
                        GetDlgItemText(dp,FIRSTCTLNAMEITEM+i,s,MAXFIELD); myc2pstrcpy(gdata->parm.ctl[i],s);
103
                }
103
                }
104
                for(i = 0; i < 4; ++i){
104
                for(i = 0; i < 4; ++i){
105
                        gdata->parm.map_used[i] = maps[i];
105
                        gdata->parm.map_used[i] = maps[i];
106
                        GetDlgItemText(dp,FIRSTMAPNAMEITEM+i,s,MAXFIELD); myc2pstrcpy(gdata->parm.map[i],s);
106
                        GetDlgItemText(dp,FIRSTMAPNAMEITEM+i,s,MAXFIELD); myc2pstrcpy(gdata->parm.map[i],s);
107
                        strcpy(gdata->parm.formula[i],expr[i] ? expr[i] : "bug! see builddlgitem");
107
                        strcpy(gdata->parm.formula[i],expr[i] ? expr[i] : "bug! see builddlgitem");
108
                }
108
                }
109
                gdata->parm.popDialog = needui; //true if need to pop a parameter dialog
109
                gdata->parm.popDialog = needui; //true if need to pop a parameter dialog
110
                gdata->parm.unknown1 = gdata->parm.unknown2 = gdata->parm.unknown3 = 0;
110
                gdata->parm.unknown1 = gdata->parm.unknown2 = gdata->parm.unknown3 = 0;
111
                gdata->parm.iProtected = ISDLGBUTTONCHECKED(dp,PROTECTITEM); // == 1 means protected
111
                gdata->parm.iProtected = ISDLGBUTTONCHECKED(dp,PROTECTITEM); // == 1 means protected
112
                gdata->obfusc = ISDLGBUTTONCHECKED(dp,OBFUSCITEM);
112
                gdata->obfusc = ISDLGBUTTONCHECKED(dp,OBFUSCITEM);
113
               
113
 
114
        case IDCANCEL:
114
        case IDCANCEL:
115
                return false; // end dialog
115
                return false; // end dialog
116
        case PROTECTITEM:
116
        case PROTECTITEM:
117
        case OBFUSCITEM:
117
        case OBFUSCITEM:
118
                CHECKDLGBUTTON(dp, item, ISDLGBUTTONCHECKED(dp,item) ^ 1);
118
                CHECKDLGBUTTON(dp, item, ISDLGBUTTONCHECKED(dp,item) ^ 1);
119
                break;
119
                break;
120
        }
120
        }
121
 
121
 
122
        return true; // keep going
122
        return true; // keep going
123
}
123
}
124
 
124