Subversion Repositories filter_foundry

Rev

Rev 145 | Rev 175 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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