Subversion Repositories filter_foundry

Rev

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

Rev Author Line No. Line
18 toby 1
/*
2
    This file is part of "Filter Foundry", a filter plugin for Adobe Photoshop
78 toby 3
    Copyright (C) 2003-7 Toby Thain, toby@telegraphics.com.au
18 toby 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
 
78 toby 20
/* Win32 user interface routines */
2 toby 21
 
22
#include "world.h"
23
 
29 toby 24
#include "PIAbout.h"
2 toby 25
 
26
#include <windows.h>
27
#include <commctrl.h>
28
 
29
#include "ff.h"
30
#include "version.h"
31
 
32
extern UIRECT preview_rect;
33
extern double zoomfactor;
34
extern Point preview_scroll;
35
 
36
HWND preview_hwnd;
37
 
38
extern HANDLE hDllInstance;
39
 
40
void DoAbout(AboutRecordPtr pb){
41
        char s[0x200];
42
        int n;
43
        PlatformData *p = (PlatformData*)pb->platformData;
44
 
78 toby 45
        n = sprintf(s,"Filter Foundry %s\n(C) 2003-7 Toby Thain <toby@telegraphics.com.au>\n\n",VERSION_STR);
2 toby 46
        if(gdata->standalone){
47
                sprintf(s+n,"Standalone filter:\n%s by %s.\n%s",
48
                        INPLACEP2CSTR(gdata->parm.title),
49
                        INPLACEP2CSTR(gdata->parm.author),
50
                        INPLACEP2CSTR(gdata->parm.copyright));
51
        }else
52
                strcat(s,"Latest version available from http://www.telegraphics.com.au/sw/\n\
53
Please contact the author with any bug reports, suggestions or comments.\n\
54
If you use this program and like it, please consider making a donation\n\
55
through www.paypal.com (US$5 suggested) to the address above.");
56
        MessageBox((HWND)p->hwnd,s,"About Filter Foundry",MB_APPLMODAL|MB_ICONINFORMATION|MB_OK);
57
}
58
 
59
Boolean simplealert(char *s){
60
        return MessageBox(NULL,s,"Filter Foundry",MB_APPLMODAL|MB_ICONERROR|MB_OK) == IDOK;
61
}
62
 
63
BOOL CALLBACK maindlgproc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam);
64
 
65
BOOL CALLBACK maindlgproc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam){
66
        static POINT origpos;
67
        static Point origscroll;
68
        static Boolean panning = false;
69
 
23 toby 70
        int item,i;
2 toby 71
        POINT newpos;
72
        DRAWITEMSTRUCT *pdi;
73
        Point newscroll;
74
        HFONT hfnt;
75
 
76
        extern Boolean doupdates;
77
        extern Handle preview_handle;
78
 
79
        switch(wMsg){
80
        case WM_INITDIALOG:
81
                centre_window(hDlg);
82
 
83
                // see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/fontext_3pbo.asp
84
                hfnt = GetStockObject(ANSI_FIXED_FONT);
85
 
86
                preview_hwnd = GetDlgItem(hDlg, PREVIEWITEM);
87
                GetClientRect(preview_hwnd, &preview_rect);
88
 
78 toby 89
                for(i = 0; i < 8; ++i){
2 toby 90
                        SendDlgItemMessage(hDlg,FIRSTCTLITEM+i,         TBM_SETRANGE,TRUE,MAKELONG(0,255));
91
                        SendDlgItemMessage(hDlg,FIRSTCTLITEM+i,         TBM_SETTICFREQ,SLIDERPAGE,0);
92
                        SendDlgItemMessage(hDlg,FIRSTCTLITEM+i,         TBM_SETPAGESIZE,0,SLIDERPAGE);
93
                        SendDlgItemMessage(hDlg,FIRSTCTLTEXTITEM+i,     EM_SETLIMITTEXT,3,0);
94
                }
78 toby 95
                for(i = 0; i < 4; ++i){
2 toby 96
                        SendDlgItemMessage(hDlg,FIRSTEXPRITEM+i,        EM_SETLIMITTEXT,MAXEXPR,0);
97
                        SendDlgItemMessage(hDlg,FIRSTEXPRITEM+i,        WM_SETFONT,(WPARAM)hfnt,false);
98
                }
99
 
100
                maindlginit(hDlg);
101
                break;
102
        case WM_DRAWITEM:
103
                pdi = (DRAWITEMSTRUCT*)lParam;
104
                if(pdi->itemAction == ODA_DRAWENTIRE){
105
                        switch(pdi->CtlID){
106
                        case PREVIEWITEM:
78 toby 107
                                drawpreview(hDlg,pdi->hDC,PILOCKHANDLE(preview_handle,false));
2 toby 108
                                PIUNLOCKHANDLE(preview_handle);
109
                                break;
78 toby 110
                        default:
111
                                return false;
2 toby 112
                        }
113
                }else
114
                        return false; // we couldn't handle the message
115
                break;
116
        case WM_COMMAND:
117
                item = LOWORD(wParam);
118
                switch(HIWORD(wParam)){
119
                case BN_CLICKED: //case STN_CLICKED:
120
                        if(item==PREVIEWITEM && GetCursorPos(&origpos)){
121
                                panning = true;
122
                                origscroll = preview_scroll;
123
                                SetCapture(hDlg);
124
                                break;
125
                        }
126
                case EN_CHANGE:
127
                        if(doupdates && !maindlgitem(hDlg,item))
128
                                EndDialog(hDlg,item);
129
                }
130
                break;
131
//      case WM_LBUTTONDOWN: break;
132
        case WM_MOUSEMOVE:
133
                if(panning && GetCursorPos(&newpos)){
134
                        newscroll.h = origscroll.h - zoomfactor*(newpos.x - origpos.x);
135
                        newscroll.v = origscroll.v - zoomfactor*(newpos.y - origpos.y);
136
                        if( newscroll.h != preview_scroll.h || newscroll.v != preview_scroll.v ){
137
                                preview_scroll = newscroll;
138
                                recalc_preview(gpb,hDlg);
139
                        }
140
                }
141
                break;
142
        case WM_LBUTTONUP:
143
                ReleaseCapture();
144
                panning = false;
145
                break;
146
        case WM_HSCROLL:
147
                item = GetDlgCtrlID((HWND)lParam);
148
                if(doupdates && item>=FIRSTCTLITEM && item<=FIRSTCTLITEM+7)
149
                        slidermoved(hDlg,item);
150
                break;
151
        default:
152
                return false;
153
        }
154
 
155
        return true;
156
}
157
 
158
Boolean maindialog(FilterRecordPtr pb){
159
        PlatformData *p = pb->platformData;
160
        return DialogBoxParam(hDllInstance,MAKEINTRESOURCE(gdata->standalone ? ID_PARAMDLG : ID_MAINDLG),
161
                                                  (HWND)p->hwnd,maindlgproc,0) == IDOK;
162
}
163