Subversion Repositories filter_foundry

Rev

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