Rev 193 | Rev 268 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 193 | Rev 259 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /* |
1 | /* |
2 | This file is part of a common library for Adobe(R) plugins |
2 | This file is part of a common library for Adobe(R) plugins |
3 | Copyright (C) 2002-2010 Toby Thain, toby@telegraphics.com.au |
3 | Copyright (C) 2002-2010 Toby Thain, toby@telegraphics.com.au |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify |
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 |
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 |
7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. |
8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, |
10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. |
13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License |
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 |
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 |
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | */ |
18 | */ |
19 | 19 | ||
20 | /* Cross-platform user interface defines */ |
20 | /* Cross-platform user interface defines */ |
21 | 21 | ||
22 | #ifndef UI_COMPAT_H_ |
22 | #ifndef UI_COMPAT_H_ |
23 | #define UI_COMPAT_H_ |
23 | #define UI_COMPAT_H_ |
24 | 24 | ||
25 | #if macintosh |
25 | #if macintosh |
26 | #include <qdoffscreen.h> |
26 | #include <qdoffscreen.h> |
27 | #include <sound.h> |
27 | #include <sound.h> |
28 | #include <dialogs.h> |
28 | #include <dialogs.h> |
29 | #include <controls.h> |
29 | #include <controls.h> |
30 | 30 | ||
31 | #include "dlg.h" |
31 | #include "dlg.h" |
32 | #include "menu.h" |
32 | #include "menu.h" |
33 | 33 | ||
34 | typedef DialogRef DIALOGREF; |
34 | typedef DialogRef DIALOGREF; |
35 | typedef ControlRef CTLREF; |
35 | typedef ControlRef CTLREF; |
36 | typedef struct MACBITMAP { |
36 | typedef struct MACBITMAP { |
37 | GWorldPtr gw; |
37 | GWorldPtr gw; |
38 | PixMapHandle pm; |
38 | PixMapHandle pm; |
39 | } *BITMAPREF; |
39 | } *BITMAPREF; |
40 | typedef Rect UIRECT; |
40 | typedef Rect UIRECT; |
41 | 41 | ||
42 | #define LOCKBITMAP(pb) LockPixels(pb->pm) |
42 | #define LOCKBITMAP(pb) LockPixels(pb->pm) |
43 | #define UNLOCKBITMAP(pb) UnlockPixels(pb->pm) |
43 | #define UNLOCKBITMAP(pb) UnlockPixels(pb->pm) |
44 | #define ROWBYTES(pb) GetPixRowBytes(pb->pm) |
44 | #define ROWBYTES(pb) GetPixRowBytes(pb->pm) |
45 | #define BASEADDR(pb) GetPixBaseAddr(pb->pm) |
45 | #define BASEADDR(pb) GetPixBaseAddr(pb->pm) |
46 | 46 | ||
47 | #define ENABLECONTROL(c) HiliteControl(c,0) |
47 | #define ENABLECONTROL(c) HiliteControl(c,0) |
48 | #define DISABLECONTROL(c) HiliteControl(c,255) |
48 | #define DISABLECONTROL(c) HiliteControl(c,255) |
49 | #define ENABLEDLGITEM EnableDlgControl |
49 | #define ENABLEDLGITEM EnableDlgControl |
50 | #define DISABLEDLGITEM DisableDlgControl |
50 | #define DISABLEDLGITEM DisableDlgControl |
51 | 51 | ||
52 | #define SELECTDLGITEMTEXT SelectDialogItemText |
52 | #define SELECTDLGITEMTEXT SelectDialogItemText |
53 | #define CHECKDLGBUTTON SetDlgControlValue |
53 | #define CHECKDLGBUTTON SetDlgControlValue |
54 | #define SETBUTTONVALUE SetControlValue |
54 | #define SETBUTTONVALUE SetControlValue |
55 | // ( GetDialogItem(d,i,&itemType,&itemHdl,&itemRect), |
55 | // ( GetDialogItem(d,i,&itemType,&itemHdl,&itemRect), |
56 | // SetControlValue((ControlHandle)itemHdl,v) ) |
56 | // SetControlValue((ControlHandle)itemHdl,v) ) |
57 | #define ISDLGBUTTONCHECKED GetDlgControlValue |
57 | #define ISDLGBUTTONCHECKED GetDlgControlValue |
58 | // ( GetDialogItem(d,i,&itemType,&itemHdl,&itemRect), |
58 | // ( GetDialogItem(d,i,&itemType,&itemHdl,&itemRect), |
59 | // GetControlValue((ControlHandle)itemHdl) ) |
59 | // GetControlValue((ControlHandle)itemHdl) ) |
60 | 60 | ||
61 | #define GETSLIDERVALUE GetDlgControlValue |
61 | #define GETSLIDERVALUE GetDlgControlValue |
62 | #define SETSLIDERVALUE SetDlgControlValue |
62 | #define SETSLIDERVALUE SetDlgControlValue |
63 | #define GETCTLTEXT getctltext |
63 | #define GETCTLTEXT getctltext |
64 | #define SETCTLTEXT setctltext |
64 | #define SETCTLTEXT setctltext |
65 | #define GETCTLTEXTINT getctltextint |
65 | #define GETCTLTEXTINT getctltextint |
66 | #define SETCTLTEXTINT setctltextint |
66 | #define SETCTLTEXTINT setctltextint |
67 | #define SELECTCTLTEXT selectctltext |
67 | #define SELECTCTLTEXT selectctltext |
68 | 68 | ||
69 | /* |
69 | /* |
70 | #define ENABLECONTROL(d,i) \ |
70 | #define ENABLECONTROL(d,i) \ |
71 | ( GetDialogItem(d,i,&itemType,&itemHdl,&itemRect),\ |
71 | ( GetDialogItem(d,i,&itemType,&itemHdl,&itemRect),\ |
72 | HiliteControl((ControlHandle)itemHdl,0) ) |
72 | HiliteControl((ControlHandle)itemHdl,0) ) |
73 | #define DISABLECONTROL(d,i) \ |
73 | #define DISABLECONTROL(d,i) \ |
74 | ( GetDialogItem(d,i,&itemType,&itemHdl,&itemRect),\ |
74 | ( GetDialogItem(d,i,&itemType,&itemHdl,&itemRect),\ |
75 | HiliteControl((ControlHandle)itemHdl,255) ) |
75 | HiliteControl((ControlHandle)itemHdl,255) ) |
76 | #define SETDLGITEMINT(d,i,v,bsigned) \ |
76 | #define SETDLGITEMINT(d,i,v,bsigned) \ |
77 | ( GetDialogItem(d,i,&itemType,&itemHdl,&itemRect),\ |
77 | ( GetDialogItem(d,i,&itemType,&itemHdl,&itemRect),\ |
78 | NumToString(v,itemStr),\ |
78 | NumToString(v,itemStr),\ |
79 | SetDialogItemText(itemHdl,itemStr) ) |
79 | SetDialogItemText(itemHdl,itemStr) ) |
80 | #define GETDLGITEMINT(d,i,bpresult,bsigned) \ |
80 | #define GETDLGITEMINT(d,i,bpresult,bsigned) \ |
81 | ( GetDialogItem(d,i,&itemType,&itemHdl,&itemRect),\ |
81 | ( GetDialogItem(d,i,&itemType,&itemHdl,&itemRect),\ |
82 | GetDialogItemText(itemHdl,itemStr),\ |
82 | GetDialogItemText(itemHdl,itemStr),\ |
83 | StringToNum(itemStr,&itemNum),\ |
83 | StringToNum(itemStr,&itemNum),\ |
84 | itemNum ) |
84 | itemNum ) |
85 | */ |
85 | */ |
86 | 86 | ||
87 | /* note menu item indices are ZERO based in the following two calls (like Win32 Combo Box) */ |
87 | /* note menu item indices are ZERO based in the following two calls (like Win32 Combo Box) */ |
88 | #define SETMENUCURSEL(c,v) SetControlValue(c,(v)+1) |
88 | #define SETMENUCURSEL(c,v) SetControlValue(c,(v)+1) |
89 | #define GETMENUCURSEL(c) (GetControlValue(c)-1) |
89 | #define GETMENUCURSEL(c) (GetControlValue(c)-1) |
90 | #define MENUADDCSTR menuaddcstr |
90 | #define MENUADDCSTR menuaddcstr |
91 | //(c,s) myc2pstr(s),AppendMenu(GetControlPopupMenuHandle(c),(StringPtr)s),myp2cstr((StringPtr)s) |
91 | //(c,s) myc2pstr(s),AppendMenu(GetControlPopupMenuHandle(c),(StringPtr)s),myp2cstr((StringPtr)s) |
92 | #define GETDLGCTLREF (ControlRef)get_item_handle |
92 | #define GETDLGCTLREF (ControlRef)get_item_handle |
93 | 93 | ||
94 | #define INITCURSOR InitCursor |
94 | #define INITCURSOR InitCursor |
95 | 95 | ||
96 | #define INVALWINDOWRECT(dp,rp) InvalWindowRect(GetDialogWindow(dp),rp) |
96 | #define INVALWINDOWRECT(dp,rp) InvalWindowRect(GetDialogWindow(dp),rp) |
97 | #define SYSBEEP SysBeep |
97 | #define SYSBEEP SysBeep |
98 | 98 | ||
99 | #define ERASERECT EraseRect |
99 | #define ERASERECT EraseRect |
100 | 100 | ||
101 | #if TARGET_CPU_68K |
101 | #if TARGET_CPU_68K |
102 | // for Universal Interfaces 3.3 (CW 68K build) |
102 | // for Universal Interfaces 3.3 (CW 68K build) |
103 | #define SetPortDialogPort SetGrafPortOfDialog |
103 | #define SetPortDialogPort SetGrafPortOfDialog |
104 | #define GetDialogPort |
104 | #define GetDialogPort |
105 | #endif |
105 | #endif |
106 | 106 | ||
107 | // #define GetPixRowBytes(pm) ((*(pm))->rowBytes & 0x3fff) // "The high 2 bits of rowBytes are used as flags." |
107 | // #define GetPixRowBytes(pm) ((*(pm))->rowBytes & 0x3fff) // "The high 2 bits of rowBytes are used as flags." |
108 | 108 | ||
109 | #if !TARGET_CARBON |
109 | #if !TARGET_CARBON |
110 | #define InvalWindowRect my_InvalWindowRect |
110 | #define InvalWindowRect my_InvalWindowRect |
111 | #endif |
111 | #endif |
112 | 112 | ||
113 | long GetDlgItemText(DIALOGREF d,int i,char *s,long n); // see dialog.c |
113 | long GetDlgItemText(DIALOGREF d,int i,char *s,long n); // see dialog.c |
114 | long SetDlgItemText(DIALOGREF d,int i,char *s); |
114 | long SetDlgItemText(DIALOGREF d,int i,char *s); |
115 | void SetDlgControlValue(DIALOGREF d,int i,int v); |
115 | void SetDlgControlValue(DIALOGREF d,int i,int v); |
116 | int GetDlgControlValue(DIALOGREF d,int i); |
116 | int GetDlgControlValue(DIALOGREF d,int i); |
117 | 117 | ||
118 | void EnableDlgControl(DIALOGREF d,int i); |
118 | void EnableDlgControl(DIALOGREF d,int i); |
119 | void DisableDlgControl(DIALOGREF d,int i); |
119 | void DisableDlgControl(DIALOGREF d,int i); |
120 | Boolean SetDlgItemInt(DIALOGREF d,int i,long v,Boolean bsigned); |
120 | Boolean SetDlgItemInt(DIALOGREF d,int i,long v,Boolean bsigned); |
121 | long GetDlgItemInt(DIALOGREF d,int i,Boolean *presult,Boolean bsigned); |
121 | long GetDlgItemInt(DIALOGREF d,int i,Boolean *presult,Boolean bsigned); |
122 | 122 | ||
123 | OSStatus my_InvalWindowRect(WindowRef window,const Rect *bounds); |
123 | OSStatus my_InvalWindowRect(WindowRef window,const Rect *bounds); |
124 | pascal Boolean standardfilter(DialogRef dialog,EventRecord *event,short *item); |
124 | pascal Boolean standardfilter(DialogRef dialog,EventRecord *event,short *item); |
125 | pascal Boolean aboutfilter(DialogRef dialog,EventRecord *event,short *item); |
125 | pascal Boolean aboutfilter(DialogRef dialog,EventRecord *event,short *item); |
126 | Handle get_item_handle(DIALOGREF d,int i); |
126 | Handle get_item_handle(DIALOGREF d,int i); |
127 | long getctltext(DIALOGREF d,int i,char *s,long n); |
127 | long getctltext(DIALOGREF d,int i,char *s,long n); |
128 | long setctltext(DIALOGREF d,int i,char *s); |
128 | long setctltext(DIALOGREF d,int i,char *s); |
129 | Boolean setctltextint(DIALOGREF d,int i,long v,Boolean bsigned); |
129 | Boolean setctltextint(DIALOGREF d,int i,long v,Boolean bsigned); |
130 | long getctltextint(DIALOGREF d,int i,Boolean *presult,Boolean bsigned); |
130 | long getctltextint(DIALOGREF d,int i,Boolean *presult,Boolean bsigned); |
131 | long selectctltext(DIALOGREF d,int i,int start,int end); |
131 | long selectctltext(DIALOGREF d,int i,int start,int end); |
132 | 132 | ||
133 | void menuaddcstr(CTLREF m,char *s); |
133 | void menuaddcstr(CTLREF m,char *s); |
134 | 134 | ||
135 | enum{IDOK = ok,IDCANCEL = cancel}; |
135 | enum{IDOK = ok,IDCANCEL = cancel}; |
136 | 136 | ||
137 | #else |
137 | #else |
138 | #include <windows.h> |
138 | #include <windows.h> |
139 | #include <windowsx.h> |
139 | #include <windowsx.h> |
140 | #include <commctrl.h> // for TBM_SETPOS, etc |
140 | #include <commctrl.h> // for TBM_SETPOS, etc |
141 | 141 | ||
142 | #include "compat_win.h" |
142 | #include "compat_win.h" |
143 | 143 | ||
144 | typedef HWND DIALOGREF,CTLREF; |
144 | typedef HWND DIALOGREF,CTLREF; |
145 | typedef struct{ |
145 | typedef struct{ |
146 | HBITMAP hbmp; |
146 | HBITMAP hbmp; |
147 | BITMAPINFO bmi; |
147 | BITMAPINFO bmi; |
148 | unsigned char *pbits; |
148 | unsigned char *pbits; |
149 | long rowbytes; |
149 | long rowbytes; |
150 | } *BITMAPREF; |
150 | } *BITMAPREF; |
151 | typedef RECT UIRECT; |
151 | typedef RECT UIRECT; |
152 | 152 | ||
153 | #define LOCKBITMAP(pb) true |
153 | #define LOCKBITMAP(pb) true |
154 | #define UNLOCKBITMAP(pb) |
154 | #define UNLOCKBITMAP(pb) |
155 | #define ROWBYTES(pb) (pb)->rowbytes |
155 | #define ROWBYTES(pb) (pb)->rowbytes |
156 | #define BASEADDR(pb) (pb)->pbits |
156 | #define BASEADDR(pb) (pb)->pbits |
157 | 157 | ||
158 | #define ENABLEDLGITEM(d,i) EnableWindow(GetDlgItem(d,i),TRUE) |
158 | #define ENABLEDLGITEM(d,i) EnableWindow(GetDlgItem(d,i),TRUE) |
159 | #define DISABLEDLGITEM(d,i) EnableWindow(GetDlgItem(d,i),FALSE) |
159 | #define DISABLEDLGITEM(d,i) EnableWindow(GetDlgItem(d,i),FALSE) |
160 | #define ENABLECONTROL(c) EnableWindow(c,TRUE) |
160 | #define ENABLECONTROL(c) EnableWindow(c,TRUE) |
161 | #define DISABLECONTROL(c) EnableWindow(c,FALSE) |
161 | #define DISABLECONTROL(c) EnableWindow(c,FALSE) |
162 | #define SETDLGITEMINT SetDlgItemInt |
162 | #define SETDLGITEMINT SetDlgItemInt |
163 | #define GETDLGITEMINT GetDlgItemInt |
163 | #define GETDLGITEMINT GetDlgItemInt |
164 | #define SELECTDLGITEMTEXT(d,i,start,end) \ |
164 | #define SELECTDLGITEMTEXT(d,i,start,end) \ |
165 | ( SendDlgItemMessage(d,i,EM_SETSEL,start,end), \ |
165 | ( SendDlgItemMessage(d,i,EM_SETSEL,start,end), \ |
166 | SendDlgItemMessage(d,i,EM_SCROLLCARET,0,0), \ |
166 | SendDlgItemMessage(d,i,EM_SCROLLCARET,0,0), \ |
167 | SetFocus(GetDlgItem(d,i)) ) |
167 | SetFocus(GetDlgItem(d,i)) ) |
168 | #define ISDLGBUTTONCHECKED IsDlgButtonChecked |
168 | #define ISDLGBUTTONCHECKED IsDlgButtonChecked |
169 | #define CHECKDLGBUTTON CheckDlgButton |
169 | #define CHECKDLGBUTTON CheckDlgButton |
170 | #define SETBUTTONVALUE(c,v) SendMessage(c,BM_SETCHECK,v,0) |
170 | #define SETBUTTONVALUE(c,v) SendMessage(c,BM_SETCHECK,v,0) |
171 | // #define HideDialogItem SendDlgItemMessage(d,i,SW_HIDE,0,0) //ShowWindow(GetDlgItem(d,i),SW_HIDE) |
171 | // #define HideDialogItem SendDlgItemMessage(d,i,SW_HIDE,0,0) //ShowWindow(GetDlgItem(d,i),SW_HIDE) |
172 | // #define ShowDialogItem SendDlgItemMessage(d,i,SW_SHOW,0,0) |
172 | // #define ShowDialogItem SendDlgItemMessage(d,i,SW_SHOW,0,0) |
173 | #define HideDialogItem(d,i) ShowWindow(GetDlgItem(d,i),SW_HIDE) |
173 | #define HideDialogItem(d,i) ShowWindow(GetDlgItem(d,i),SW_HIDE) |
174 | #define ShowDialogItem(d,i) ShowWindow(GetDlgItem(d,i),SW_SHOW) |
174 | #define ShowDialogItem(d,i) ShowWindow(GetDlgItem(d,i),SW_SHOW) |
175 | 175 | ||
176 | #define GETSLIDERVALUE(d,i) (int)SendDlgItemMessage(d,i,TBM_GETPOS,0,0) |
176 | #define GETSLIDERVALUE(d,i) (int)SendDlgItemMessage(d,i,TBM_GETPOS,0,0) |
177 | #define SETSLIDERVALUE(d,i,v) SendDlgItemMessage(d,i,TBM_SETPOS,TRUE,v) |
177 | #define SETSLIDERVALUE(d,i,v) SendDlgItemMessage(d,i,TBM_SETPOS,TRUE,v) |
178 | #define GETCTLTEXT GetDlgItemText |
178 | #define GETCTLTEXT GetDlgItemText |
179 | #define SETCTLTEXT SetDlgItemText |
179 | #define SETCTLTEXT SetDlgItemText |
180 | #define SELECTCTLTEXT SELECTDLGITEMTEXT |
180 | #define SELECTCTLTEXT SELECTDLGITEMTEXT |
181 | #define GETCTLTEXTINT GetDlgItemInt |
181 | #define GETCTLTEXTINT GetDlgItemInt |
182 | #define SETCTLTEXTINT SetDlgItemInt |
182 | #define SETCTLTEXTINT SetDlgItemInt |
183 | 183 | ||
184 | #define SETMENUCURSEL ComboBox_SetCurSel |
184 | #define SETMENUCURSEL ComboBox_SetCurSel |
185 | #define GETMENUCURSEL ComboBox_GetCurSel |
185 | #define GETMENUCURSEL ComboBox_GetCurSel |
186 | #define MENUADDCSTR ComboBox_AddString |
186 | #define MENUADDCSTR ComboBox_AddString |
187 | #define GETDLGCTLREF GetDlgItem |
187 | #define GETDLGCTLREF GetDlgItem |
188 | 188 | ||
189 | #define INITCURSOR() |
189 | #define INITCURSOR() |
190 | #define DLGVARS |
190 | #define DLGVARS |
191 | #define INVALWINDOWRECT(dp,rp) RedrawWindow(dp,rp,NULL,RDW_ERASE|RDW_INVALIDATE) |
191 | #define INVALWINDOWRECT(dp,rp) RedrawWindow(dp,rp,NULL,RDW_ERASE|RDW_INVALIDATE) |
192 | #define SYSBEEP(x) MessageBeep(MB_ICONEXCLAMATION) |
192 | #define SYSBEEP(x) MessageBeep(MB_ICONEXCLAMATION) |
193 | 193 | ||
194 | void centre_window(HWND hwnd); |
194 | void centre_window(HWND hwnd); |
195 | void DebugStr(StringPtr s); |
195 | void DebugStr(StringPtr s); |
196 | #endif |
196 | #endif |
197 | 197 | ||
198 | 198 | ||
199 | // implemented as functions on both platforms |
199 | // implemented as functions on both platforms |
200 | #define GETDLGITEMCSTR GetDlgItemText |
200 | #define GETDLGITEMCSTR GetDlgItemText |
201 | #define SETDLGITEMCSTR SetDlgItemText |
201 | #define SETDLGITEMCSTR SetDlgItemText |
202 | Boolean newbitmap(BITMAPREF *pb,int depth,UIRECT *bounds); |
202 | Boolean newbitmap(BITMAPREF *pb,int depth,UIRECT *bounds); |
203 | void disposebitmap(BITMAPREF pb); |
203 | void disposebitmap(BITMAPREF pb); |
204 | #define NEWBITMAP newbitmap |
204 | #define NEWBITMAP newbitmap |
205 | #define DISPOSEBITMAP disposebitmap |
205 | #define DISPOSEBITMAP disposebitmap |
206 | 206 | ||
207 | #endif |
207 | #endif |