Subversion Repositories filter_foundry

Rev

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