Subversion Repositories filter_foundry

Rev

Rev 95 | 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. #include "preview.h"
  21. #include "ui.h"
  22.  
  23. extern CursHandle handcursor; // provided and initialised by ui_mac.c
  24.  
  25. pascal void preview_item(DialogRef dp,DialogItemIndex item);
  26. pascal Boolean previewfilter(DialogRef dialog,EventRecord *event,short *item);
  27.  
  28. pascal void preview_item(DialogRef dp,DialogItemIndex item){
  29.         GrafPtr port;
  30.        
  31.         ENTERCALLBACK();
  32.  
  33.         GetPort(&port);
  34.         SetPortDialogPort(dp);
  35.  
  36.         drawpreview(dp,0,PILOCKHANDLE(preview_handle,false));
  37.         PIUNLOCKHANDLE(preview_handle);
  38.  
  39.         FrameRect(&preview_rect);
  40.        
  41.         SetPort(port);
  42.  
  43.         EXITCALLBACK();
  44. }
  45.  
  46. // The following code is not actually used in Filter Foundry;
  47. // it implements a preview-only event filter, for plugins that need
  48. // only preview functionality (without sliders).
  49.  
  50. pascal Boolean previewfilter(DialogRef dialog,EventRecord *event,short *item){ 
  51.         int i;
  52.         Point pt,origscroll,newscroll;
  53.         Boolean result = false,f;
  54.         EventRecord ev;
  55.         GrafPtr oldport;
  56.  
  57.         ENTERCALLBACK();
  58.  
  59.         GetPort(&oldport);
  60.         SetPortDialogPort(dialog);
  61.  
  62.         if(!event->what)
  63.                 gpb->processEvent(event); // pass null events to Photoshop
  64.        
  65.         if(event->what == updateEvt && (WindowRef)event->message != GetDialogWindow(dialog)){
  66.                 // pass Photoshop update events for its windows
  67.                 gpb->processEvent(event);
  68.                 result = false;
  69.         }else if(event->what == mouseDown){
  70.  
  71.                 pt = event->where;
  72.                 GlobalToLocal(&pt);
  73.        
  74.                 i = FindDialogItem(dialog,pt)+1;
  75.                 if(i == PREVIEWITEM){
  76.                         SetCursor(*handcursor);
  77.                         origscroll = preview_scroll;
  78.                         do{
  79.                                 f = WaitNextEvent(mUpMask,&ev,5,NULL);
  80.                                 newscroll.h = origscroll.h - zoomfactor*(ev.where.h - event->where.h);
  81.                                 newscroll.v = origscroll.v - zoomfactor*(ev.where.v - event->where.v);
  82.                                 if(!EqualPt(newscroll,preview_scroll)){
  83.                                         preview_scroll = newscroll;
  84.                                         recalc_preview(gpb,dialog);
  85.                                 }
  86.                         }while(!f);
  87.  
  88.                         *item = i;
  89.                         result = true;
  90.                 }
  91.                
  92.         }else{
  93.                 //GetKeyboardFocus(GetDialogWindow(dialog),&focus);
  94.                 result = StdFilterProc(dialog,event,item);
  95.         }
  96.                
  97.         SetPort(oldport);
  98.  
  99.         EXITCALLBACK();
  100.  
  101.         return result;
  102. }
  103.