Rev 78 | Rev 94 | 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; |
||
92 | toby | 75 | char s[0x100]; |
2 | toby | 76 | |
77 | extern Boolean doupdates; |
||
78 | extern Handle preview_handle; |
||
79 | |||
80 | switch(wMsg){ |
||
81 | case WM_INITDIALOG: |
||
92 | toby | 82 | if(gdata->standalone){ |
83 | myp2cstrcpy(s,gdata->parm.title); |
||
84 | SetWindowText(hDlg,s); // window title bar |
||
85 | } |
||
2 | toby | 86 | centre_window(hDlg); |
87 | |||
88 | // see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/fontext_3pbo.asp |
||
89 | hfnt = GetStockObject(ANSI_FIXED_FONT); |
||
90 | |||
91 | preview_hwnd = GetDlgItem(hDlg, PREVIEWITEM); |
||
92 | GetClientRect(preview_hwnd, &preview_rect); |
||
93 | |||
78 | toby | 94 | for(i = 0; i < 8; ++i){ |
2 | toby | 95 | SendDlgItemMessage(hDlg,FIRSTCTLITEM+i, TBM_SETRANGE,TRUE,MAKELONG(0,255)); |
96 | SendDlgItemMessage(hDlg,FIRSTCTLITEM+i, TBM_SETTICFREQ,SLIDERPAGE,0); |
||
97 | SendDlgItemMessage(hDlg,FIRSTCTLITEM+i, TBM_SETPAGESIZE,0,SLIDERPAGE); |
||
98 | SendDlgItemMessage(hDlg,FIRSTCTLTEXTITEM+i, EM_SETLIMITTEXT,3,0); |
||
99 | } |
||
78 | toby | 100 | for(i = 0; i < 4; ++i){ |
2 | toby | 101 | SendDlgItemMessage(hDlg,FIRSTEXPRITEM+i, EM_SETLIMITTEXT,MAXEXPR,0); |
102 | SendDlgItemMessage(hDlg,FIRSTEXPRITEM+i, WM_SETFONT,(WPARAM)hfnt,false); |
||
103 | } |
||
104 | |||
105 | maindlginit(hDlg); |
||
106 | break; |
||
107 | case WM_DRAWITEM: |
||
108 | pdi = (DRAWITEMSTRUCT*)lParam; |
||
109 | if(pdi->itemAction == ODA_DRAWENTIRE){ |
||
110 | switch(pdi->CtlID){ |
||
111 | case PREVIEWITEM: |
||
78 | toby | 112 | drawpreview(hDlg,pdi->hDC,PILOCKHANDLE(preview_handle,false)); |
2 | toby | 113 | PIUNLOCKHANDLE(preview_handle); |
114 | break; |
||
78 | toby | 115 | default: |
116 | return false; |
||
2 | toby | 117 | } |
118 | }else |
||
119 | return false; // we couldn't handle the message |
||
120 | break; |
||
121 | case WM_COMMAND: |
||
122 | item = LOWORD(wParam); |
||
123 | switch(HIWORD(wParam)){ |
||
124 | case BN_CLICKED: //case STN_CLICKED: |
||
125 | if(item==PREVIEWITEM && GetCursorPos(&origpos)){ |
||
126 | panning = true; |
||
127 | origscroll = preview_scroll; |
||
128 | SetCapture(hDlg); |
||
129 | break; |
||
130 | } |
||
131 | case EN_CHANGE: |
||
132 | if(doupdates && !maindlgitem(hDlg,item)) |
||
133 | EndDialog(hDlg,item); |
||
134 | } |
||
135 | break; |
||
136 | // case WM_LBUTTONDOWN: break; |
||
137 | case WM_MOUSEMOVE: |
||
138 | if(panning && GetCursorPos(&newpos)){ |
||
139 | newscroll.h = origscroll.h - zoomfactor*(newpos.x - origpos.x); |
||
140 | newscroll.v = origscroll.v - zoomfactor*(newpos.y - origpos.y); |
||
141 | if( newscroll.h != preview_scroll.h || newscroll.v != preview_scroll.v ){ |
||
142 | preview_scroll = newscroll; |
||
143 | recalc_preview(gpb,hDlg); |
||
144 | } |
||
145 | } |
||
146 | break; |
||
147 | case WM_LBUTTONUP: |
||
148 | ReleaseCapture(); |
||
149 | panning = false; |
||
150 | break; |
||
151 | case WM_HSCROLL: |
||
152 | item = GetDlgCtrlID((HWND)lParam); |
||
153 | if(doupdates && item>=FIRSTCTLITEM && item<=FIRSTCTLITEM+7) |
||
154 | slidermoved(hDlg,item); |
||
155 | break; |
||
156 | default: |
||
157 | return false; |
||
158 | } |
||
159 | |||
160 | return true; |
||
161 | } |
||
162 | |||
163 | Boolean maindialog(FilterRecordPtr pb){ |
||
164 | PlatformData *p = pb->platformData; |
||
165 | return DialogBoxParam(hDllInstance,MAKEINTRESOURCE(gdata->standalone ? ID_PARAMDLG : ID_MAINDLG), |
||
166 | (HWND)p->hwnd,maindlgproc,0) == IDOK; |
||
167 | } |
||
168 |