Subversion Repositories filter_foundry

Rev

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

Rev Author Line No. Line
94 toby 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
 
95 toby 46
// The following code is not actually used by Filter Foundry;
47
// it implements an event filter for plugins that need
94 toby 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
 
95 toby 62
        if( !event->what || (event->what == updateEvt
63
                                                 && (WindowRef)event->message != GetDialogWindow(dialog)) )
64
        {       // pass null events and update events to Photoshop
94 toby 65
                gpb->processEvent(event);
95 toby 66
        }
67
        else if(event->what == mouseDown){
94 toby 68
                pt = event->where;
69
                GlobalToLocal(&pt);
70
 
71
                i = FindDialogItem(dialog,pt)+1;
72
                if(i == PREVIEWITEM){
73
                        SetCursor(*handcursor);
74
                        origscroll = preview_scroll;
75
                        do{
76
                                f = WaitNextEvent(mUpMask,&ev,5,NULL);
77
                                newscroll.h = origscroll.h - zoomfactor*(ev.where.h - event->where.h);
78
                                newscroll.v = origscroll.v - zoomfactor*(ev.where.v - event->where.v);
79
                                if(!EqualPt(newscroll,preview_scroll)){
80
                                        preview_scroll = newscroll;
81
                                        recalc_preview(gpb,dialog);
82
                                }
83
                        }while(!f);
84
 
85
                        *item = i;
86
                        result = true;
87
                }
95 toby 88
        }
89
        else
94 toby 90
                result = StdFilterProc(dialog,event,item);
91
 
92
        SetPort(oldport);
93
 
94
        EXITCALLBACK();
95
 
96
        return result;
97
}