Rev 259 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
193 | daniel-mar | 1 | /* |
2 | This file is part of a common library for Adobe(R) plugins |
||
3 | Copyright (C) 2002-2010 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 | |||
20 | /* Cross-platform user interface defines */ |
||
21 | |||
22 | #ifndef UI_COMPAT_H_ |
||
23 | #define UI_COMPAT_H_ |
||
24 | |||
25 | #if macintosh |
||
26 | #include <qdoffscreen.h> |
||
27 | #include <sound.h> |
||
28 | #include <dialogs.h> |
||
29 | #include <controls.h> |
||
30 | |||
31 | #include "dlg.h" |
||
32 | #include "menu.h" |
||
33 | |||
34 | typedef DialogRef DIALOGREF; |
||
35 | typedef ControlRef CTLREF; |
||
36 | typedef struct MACBITMAP { |
||
37 | GWorldPtr gw; |
||
38 | PixMapHandle pm; |
||
39 | } *BITMAPREF; |
||
40 | typedef Rect UIRECT; |
||
41 | |||
42 | #define LOCKBITMAP(pb) LockPixels(pb->pm) |
||
43 | #define UNLOCKBITMAP(pb) UnlockPixels(pb->pm) |
||
44 | #define ROWBYTES(pb) GetPixRowBytes(pb->pm) |
||
45 | #define BASEADDR(pb) GetPixBaseAddr(pb->pm) |
||
46 | |||
47 | #define ENABLECONTROL(c) HiliteControl(c,0) |
||
48 | #define DISABLECONTROL(c) HiliteControl(c,255) |
||
49 | #define ENABLEDLGITEM EnableDlgControl |
||
50 | #define DISABLEDLGITEM DisableDlgControl |
||
51 | |||
52 | #define SELECTDLGITEMTEXT SelectDialogItemText |
||
53 | #define CHECKDLGBUTTON SetDlgControlValue |
||
54 | #define SETBUTTONVALUE SetControlValue |
||
55 | // ( GetDialogItem(d,i,&itemType,&itemHdl,&itemRect), |
||
56 | // SetControlValue((ControlHandle)itemHdl,v) ) |
||
57 | #define ISDLGBUTTONCHECKED GetDlgControlValue |
||
58 | // ( GetDialogItem(d,i,&itemType,&itemHdl,&itemRect), |
||
59 | // GetControlValue((ControlHandle)itemHdl) ) |
||
60 | |||
61 | #define GETSLIDERVALUE GetDlgControlValue |
||
62 | #define SETSLIDERVALUE SetDlgControlValue |
||
63 | #define GETCTLTEXT getctltext |
||
64 | #define SETCTLTEXT setctltext |
||
65 | #define GETCTLTEXTINT getctltextint |
||
66 | #define SETCTLTEXTINT setctltextint |
||
67 | #define SELECTCTLTEXT selectctltext |
||
68 | |||
69 | /* |
||
70 | #define ENABLECONTROL(d,i) \ |
||
71 | ( GetDialogItem(d,i,&itemType,&itemHdl,&itemRect),\ |
||
72 | HiliteControl((ControlHandle)itemHdl,0) ) |
||
73 | #define DISABLECONTROL(d,i) \ |
||
74 | ( GetDialogItem(d,i,&itemType,&itemHdl,&itemRect),\ |
||
75 | HiliteControl((ControlHandle)itemHdl,255) ) |
||
76 | #define SETDLGITEMINT(d,i,v,bsigned) \ |
||
77 | ( GetDialogItem(d,i,&itemType,&itemHdl,&itemRect),\ |
||
78 | NumToString(v,itemStr),\ |
||
79 | SetDialogItemText(itemHdl,itemStr) ) |
||
80 | #define GETDLGITEMINT(d,i,bpresult,bsigned) \ |
||
81 | ( GetDialogItem(d,i,&itemType,&itemHdl,&itemRect),\ |
||
82 | GetDialogItemText(itemHdl,itemStr),\ |
||
83 | StringToNum(itemStr,&itemNum),\ |
||
84 | itemNum ) |
||
85 | */ |
||
86 | |||
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) |
||
89 | #define GETMENUCURSEL(c) (GetControlValue(c)-1) |
||
90 | #define MENUADDCSTR menuaddcstr |
||
91 | //(c,s) myc2pstr(s),AppendMenu(GetControlPopupMenuHandle(c),(StringPtr)s),myp2cstr((StringPtr)s) |
||
92 | #define GETDLGCTLREF (ControlRef)get_item_handle |
||
93 | |||
94 | #define INITCURSOR InitCursor |
||
95 | |||
96 | #define INVALWINDOWRECT(dp,rp) InvalWindowRect(GetDialogWindow(dp),rp) |
||
97 | #define SYSBEEP SysBeep |
||
98 | |||
99 | #define ERASERECT EraseRect |
||
100 | |||
101 | #if TARGET_CPU_68K |
||
102 | // for Universal Interfaces 3.3 (CW 68K build) |
||
103 | #define SetPortDialogPort SetGrafPortOfDialog |
||
104 | #define GetDialogPort |
||
105 | #endif |
||
106 | |||
107 | // #define GetPixRowBytes(pm) ((*(pm))->rowBytes & 0x3fff) // "The high 2 bits of rowBytes are used as flags." |
||
108 | |||
109 | #if !TARGET_CARBON |
||
110 | #define InvalWindowRect my_InvalWindowRect |
||
111 | #endif |
||
112 | |||
113 | long GetDlgItemText(DIALOGREF d,int i,char *s,long n); // see dialog.c |
||
114 | long SetDlgItemText(DIALOGREF d,int i,char *s); |
||
115 | void SetDlgControlValue(DIALOGREF d,int i,int v); |
||
116 | int GetDlgControlValue(DIALOGREF d,int i); |
||
117 | |||
118 | void EnableDlgControl(DIALOGREF d,int i); |
||
119 | void DisableDlgControl(DIALOGREF d,int i); |
||
120 | Boolean SetDlgItemInt(DIALOGREF d,int i,long v,Boolean bsigned); |
||
121 | long GetDlgItemInt(DIALOGREF d,int i,Boolean *presult,Boolean bsigned); |
||
122 | |||
123 | OSStatus my_InvalWindowRect(WindowRef window,const Rect *bounds); |
||
124 | pascal Boolean standardfilter(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); |
||
127 | long getctltext(DIALOGREF d,int i,char *s,long n); |
||
128 | long setctltext(DIALOGREF d,int i,char *s); |
||
129 | Boolean setctltextint(DIALOGREF d,int i,long v,Boolean bsigned); |
||
130 | long getctltextint(DIALOGREF d,int i,Boolean *presult,Boolean bsigned); |
||
131 | long selectctltext(DIALOGREF d,int i,int start,int end); |
||
132 | |||
133 | void menuaddcstr(CTLREF m,char *s); |
||
134 | |||
135 | enum{IDOK = ok,IDCANCEL = cancel}; |
||
136 | |||
137 | #else |
||
138 | #include <windows.h> |
||
139 | #include <windowsx.h> |
||
140 | #include <commctrl.h> // for TBM_SETPOS, etc |
||
141 | |||
142 | #include "compat_win.h" |
||
143 | |||
144 | typedef HWND DIALOGREF,CTLREF; |
||
145 | typedef struct{ |
||
146 | HBITMAP hbmp; |
||
147 | BITMAPINFO bmi; |
||
148 | unsigned char *pbits; |
||
149 | long rowbytes; |
||
150 | } *BITMAPREF; |
||
151 | typedef RECT UIRECT; |
||
152 | |||
153 | #define LOCKBITMAP(pb) true |
||
154 | #define UNLOCKBITMAP(pb) |
||
155 | #define ROWBYTES(pb) (pb)->rowbytes |
||
156 | #define BASEADDR(pb) (pb)->pbits |
||
157 | |||
158 | #define ENABLEDLGITEM(d,i) EnableWindow(GetDlgItem(d,i),TRUE) |
||
159 | #define DISABLEDLGITEM(d,i) EnableWindow(GetDlgItem(d,i),FALSE) |
||
160 | #define ENABLECONTROL(c) EnableWindow(c,TRUE) |
||
161 | #define DISABLECONTROL(c) EnableWindow(c,FALSE) |
||
162 | #define SETDLGITEMINT SetDlgItemInt |
||
163 | #define GETDLGITEMINT GetDlgItemInt |
||
164 | #define SELECTDLGITEMTEXT(d,i,start,end) \ |
||
165 | ( SendDlgItemMessage(d,i,EM_SETSEL,start,end), \ |
||
166 | SendDlgItemMessage(d,i,EM_SCROLLCARET,0,0), \ |
||
167 | SetFocus(GetDlgItem(d,i)) ) |
||
168 | #define ISDLGBUTTONCHECKED IsDlgButtonChecked |
||
169 | #define CHECKDLGBUTTON CheckDlgButton |
||
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) |
||
172 | // #define ShowDialogItem SendDlgItemMessage(d,i,SW_SHOW,0,0) |
||
173 | #define HideDialogItem(d,i) ShowWindow(GetDlgItem(d,i),SW_HIDE) |
||
174 | #define ShowDialogItem(d,i) ShowWindow(GetDlgItem(d,i),SW_SHOW) |
||
175 | |||
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) |
||
178 | #define GETCTLTEXT GetDlgItemText |
||
179 | #define SETCTLTEXT SetDlgItemText |
||
180 | #define SELECTCTLTEXT SELECTDLGITEMTEXT |
||
181 | #define GETCTLTEXTINT GetDlgItemInt |
||
182 | #define SETCTLTEXTINT SetDlgItemInt |
||
183 | |||
184 | #define SETMENUCURSEL ComboBox_SetCurSel |
||
185 | #define GETMENUCURSEL ComboBox_GetCurSel |
||
186 | #define MENUADDCSTR ComboBox_AddString |
||
187 | #define GETDLGCTLREF GetDlgItem |
||
188 | |||
189 | #define INITCURSOR() |
||
190 | #define DLGVARS |
||
191 | #define INVALWINDOWRECT(dp,rp) RedrawWindow(dp,rp,NULL,RDW_ERASE|RDW_INVALIDATE) |
||
192 | #define SYSBEEP(x) MessageBeep(MB_ICONEXCLAMATION) |
||
193 | |||
194 | void centre_window(HWND hwnd); |
||
195 | void DebugStr(StringPtr s); |
||
196 | #endif |
||
197 | |||
198 | |||
199 | // implemented as functions on both platforms |
||
200 | #define GETDLGITEMCSTR GetDlgItemText |
||
201 | #define SETDLGITEMCSTR SetDlgItemText |
||
202 | Boolean newbitmap(BITMAPREF *pb,int depth,UIRECT *bounds); |
||
203 | void disposebitmap(BITMAPREF pb); |
||
204 | #define NEWBITMAP newbitmap |
||
205 | #define DISPOSEBITMAP disposebitmap |
||
206 | |||
207 | #endif |