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