Rev 23 | Rev 78 | 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 | |||
29 | toby | 25 | #include "PIAbout.h" |
2 | toby | 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 Point origscroll; |
||
69 | static Boolean panning = false; |
||
70 | |||
23 | toby | 71 | int item,i; |
2 | toby | 72 | POINT newpos; |
73 | DRAWITEMSTRUCT *pdi; |
||
74 | Point newscroll; |
||
75 | HFONT hfnt; |
||
76 | |||
77 | extern Boolean doupdates; |
||
78 | extern Handle preview_handle; |
||
79 | |||
80 | switch(wMsg){ |
||
81 | case WM_INITDIALOG: |
||
82 | DBG("dlgproc: WM_INITDIALOG"); |
||
83 | centre_window(hDlg); |
||
84 | // cicon = LoadImage(hDllInstance,"CAUTION_ICO",IMAGE_ICON,16,16,LR_DEFAULTCOLOR); |
||
85 | |||
86 | // see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/fontext_3pbo.asp |
||
87 | hfnt = GetStockObject(ANSI_FIXED_FONT); |
||
88 | |||
89 | preview_hwnd = GetDlgItem(hDlg, PREVIEWITEM); |
||
90 | GetClientRect(preview_hwnd, &preview_rect); |
||
91 | // MapWindowPoints(hcl,hDlg,(POINT*)&preview_rect,2); |
||
92 | //{char s[0x100]; sprintf(s,"preview_rect=(%d,%d,%d,%d)", |
||
93 | // preview_rect.left,preview_rect.top,preview_rect.right,preview_rect.bottom); dbg(s);} |
||
94 | |||
95 | for(i=0;i<8;++i){ |
||
96 | SendDlgItemMessage(hDlg,FIRSTCTLITEM+i, TBM_SETRANGE,TRUE,MAKELONG(0,255)); |
||
97 | SendDlgItemMessage(hDlg,FIRSTCTLITEM+i, TBM_SETTICFREQ,SLIDERPAGE,0); |
||
98 | SendDlgItemMessage(hDlg,FIRSTCTLITEM+i, TBM_SETPAGESIZE,0,SLIDERPAGE); |
||
99 | SendDlgItemMessage(hDlg,FIRSTCTLTEXTITEM+i, EM_SETLIMITTEXT,3,0); |
||
100 | } |
||
101 | for(i=0;i<4;++i){ |
||
102 | SendDlgItemMessage(hDlg,FIRSTEXPRITEM+i, EM_SETLIMITTEXT,MAXEXPR,0); |
||
103 | SendDlgItemMessage(hDlg,FIRSTEXPRITEM+i, WM_SETFONT,(WPARAM)hfnt,false); |
||
104 | } |
||
105 | |||
106 | maindlginit(hDlg); |
||
107 | break; |
||
108 | case WM_DRAWITEM: |
||
109 | pdi = (DRAWITEMSTRUCT*)lParam; |
||
110 | if(pdi->itemAction == ODA_DRAWENTIRE){ |
||
111 | switch(pdi->CtlID){ |
||
112 | /* |
||
113 | case FIRSTICONITEM: |
||
114 | case FIRSTICONITEM+1: |
||
115 | case FIRSTICONITEM+2: |
||
116 | case FIRSTICONITEM+3: |
||
117 | DrawIconEx( pdi->hDC, 0,0, cicon, 16,16, 0, NULL, DI_NORMAL ); |
||
118 | break; |
||
119 | */ |
||
120 | case PREVIEWITEM: |
||
121 | drawpreview(hDlg,pdi->hDC,PILOCKHANDLE(preview_handle,false));//paint_preview(hDlg,pdi->hwndItem,pdi->hDC,&pdi->rcItem); |
||
122 | PIUNLOCKHANDLE(preview_handle); |
||
123 | break; |
||
124 | default: return false; |
||
125 | } |
||
126 | }else |
||
127 | return false; // we couldn't handle the message |
||
128 | break; |
||
129 | case WM_COMMAND: |
||
130 | item = LOWORD(wParam); |
||
131 | switch(HIWORD(wParam)){ |
||
132 | case BN_CLICKED: //case STN_CLICKED: |
||
133 | if(item==PREVIEWITEM && GetCursorPos(&origpos)){ |
||
134 | // dbg("click preview"); |
||
135 | panning = true; |
||
136 | origscroll = preview_scroll; |
||
137 | SetCapture(hDlg); |
||
138 | break; |
||
139 | } |
||
140 | case EN_CHANGE: |
||
141 | if(doupdates && !maindlgitem(hDlg,item)) |
||
142 | EndDialog(hDlg,item); |
||
143 | } |
||
144 | break; |
||
145 | // case WM_LBUTTONDOWN: break; |
||
146 | case WM_MOUSEMOVE: |
||
147 | if(panning && GetCursorPos(&newpos)){ |
||
148 | newscroll.h = origscroll.h - zoomfactor*(newpos.x - origpos.x); |
||
149 | newscroll.v = origscroll.v - zoomfactor*(newpos.y - origpos.y); |
||
150 | if( newscroll.h != preview_scroll.h || newscroll.v != preview_scroll.v ){ |
||
151 | preview_scroll = newscroll; |
||
152 | recalc_preview(gpb,hDlg); |
||
153 | } |
||
154 | } |
||
155 | break; |
||
156 | case WM_LBUTTONUP: |
||
157 | // dbg("button up"); |
||
158 | ReleaseCapture(); |
||
159 | panning = false; |
||
160 | break; |
||
161 | case WM_HSCROLL: |
||
162 | item = GetDlgCtrlID((HWND)lParam); |
||
163 | if(doupdates && item>=FIRSTCTLITEM && item<=FIRSTCTLITEM+7) |
||
164 | slidermoved(hDlg,item); |
||
165 | //recalc_preview(gpb,hDlg); |
||
166 | break; |
||
167 | default: |
||
168 | return false; |
||
169 | } |
||
170 | |||
171 | return true; |
||
172 | } |
||
173 | |||
174 | Boolean maindialog(FilterRecordPtr pb){ |
||
175 | PlatformData *p = pb->platformData; |
||
176 | return DialogBoxParam(hDllInstance,MAKEINTRESOURCE(gdata->standalone ? ID_PARAMDLG : ID_MAINDLG), |
||
177 | (HWND)p->hwnd,maindlgproc,0) == IDOK; |
||
178 | } |
||
179 |