Subversion Repositories filter_foundry

Rev

Rev 87 | Rev 130 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

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