1 | #define INCL_PM
|
---|
2 | #define INCL_DOS
|
---|
3 | #include <os2.h>
|
---|
4 | #include <stdio.h>
|
---|
5 | /* Include file with definition for WPShadow class */
|
---|
6 | #include "wpshadow.h"
|
---|
7 | #include "wpdisk.h"
|
---|
8 | #include "wpfsys.h" /* For _wpQueryDisk */
|
---|
9 |
|
---|
10 |
|
---|
11 | /*&************************************************/
|
---|
12 |
|
---|
13 |
|
---|
14 | /*&&***********************************************/
|
---|
15 |
|
---|
16 | #if 0
|
---|
17 | int iFirstCD;
|
---|
18 | int iNumCD;
|
---|
19 | BOOL bGotCD=FALSE;
|
---|
20 | static BOOL _queryCDOnce(void)
|
---|
21 | {
|
---|
22 | static BOOL bTriedCD=FALSE;
|
---|
23 |
|
---|
24 | /* Only search for CDs once to speed up things */
|
---|
25 | if(!bTriedCD) {
|
---|
26 | bTriedCD=TRUE; /* Don't search for CDs again */
|
---|
27 | /* Get CD drives */
|
---|
28 | if(cwQueryCDDrives(&iNumCD, &iFirstCD))
|
---|
29 | bGotCD=TRUE;
|
---|
30 | }
|
---|
31 | return TRUE;
|
---|
32 | }
|
---|
33 | BOOL somObjectIsOnCD(WPObject * somSelf)
|
---|
34 | {
|
---|
35 | /* Get the CD drives in the system */
|
---|
36 | _queryCDOnce();
|
---|
37 |
|
---|
38 | if(bGotCD) {
|
---|
39 | WPDisk *wpDisk;
|
---|
40 | int iDiskNum;
|
---|
41 |
|
---|
42 | if((wpDisk=_wpQueryDisk(somSelf))!=NULLHANDLE) {
|
---|
43 | if((iDiskNum=_wpQueryLogicalDrive(wpDisk))!=0) {
|
---|
44 | if((iDiskNum>=iFirstCD && iDiskNum<=iFirstCD+iNumCD)) {
|
---|
45 | return TRUE; /* The object is on a CD */
|
---|
46 | }
|
---|
47 | }
|
---|
48 | }
|
---|
49 | }
|
---|
50 | return FALSE; /* Object not on CD */
|
---|
51 | }
|
---|
52 | #endif
|
---|
53 |
|
---|
54 | /*!************************************************************/
|
---|
55 | /* */
|
---|
56 | /* @@DESC */
|
---|
57 | /* This function returns the pointer to a file system object */
|
---|
58 | /* or NULL. */
|
---|
59 | /* It follows shadow objects and returns the object handle */
|
---|
60 | /* of the linked object if it's a file system object */
|
---|
61 | /* */
|
---|
62 | /*!!***********************************************************/
|
---|
63 | WPObject* somGetFileSystemObject(WPObject* wpObject)
|
---|
64 | {
|
---|
65 | if(!somIsObj(wpObject))
|
---|
66 | return NULL;//No object given
|
---|
67 |
|
---|
68 | /* Check if it's a shadow */
|
---|
69 | //if(somResolveByName(wpObject,"wpQueryShadowedObject")){
|
---|
70 | if(_somIsA(wpObject,_WPShadow)){
|
---|
71 | /* Yes, it's a shadow. Query the linked object. */
|
---|
72 | wpObject=_wpQueryShadowedObject((WPShadow*)wpObject, FALSE);
|
---|
73 | if(!somIsObj(wpObject))
|
---|
74 | return NULL;//The link is broken
|
---|
75 | }
|
---|
76 |
|
---|
77 | #if 0
|
---|
78 | while(somResolveByName(wpObject,"wpQueryShadowedObject")) {
|
---|
79 | /* Yes, it's a shadow. Query the linked object. */
|
---|
80 | wpObject=_wpQueryShadowedObject((WPShadow*)wpObject, FALSE);
|
---|
81 | }
|
---|
82 | #endif
|
---|
83 |
|
---|
84 | /* Check if it's a file system object */
|
---|
85 | // if(somResolveByName(wpObject, "wpQueryRealName")){
|
---|
86 | if(_somIsA(wpObject, _WPFileSystem)){
|
---|
87 | return wpObject;/* Yes */
|
---|
88 | }
|
---|
89 | else
|
---|
90 | return NULL;
|
---|
91 | }
|
---|
92 |
|
---|
93 | /*!*******************************************************/
|
---|
94 | /* */
|
---|
95 | /* @@DESC */
|
---|
96 | /* Get the class object for the class <chrClassName>. */
|
---|
97 | /* */
|
---|
98 | /* */
|
---|
99 | /* @@REMARKS */
|
---|
100 | /* */
|
---|
101 | /* If the class isn't already loaded by SOM this function*/
|
---|
102 | /* will find it and load it into memory. */
|
---|
103 | /* */
|
---|
104 | /* @@PARAM */
|
---|
105 | /* */
|
---|
106 | /* char* chrClassName input */
|
---|
107 | /* */
|
---|
108 | /* Class for which the class object will be returned. */
|
---|
109 | /* */
|
---|
110 | /* */
|
---|
111 | /* @@RETURNS */
|
---|
112 | /* */
|
---|
113 | /* SOMClass somCls */
|
---|
114 | /* Pointer to the class object. */
|
---|
115 | /* In case of an error NULL is returned. */
|
---|
116 | /* */
|
---|
117 | /*!!******************************************************/
|
---|
118 | SOMClass* somGetSomClass(char* chrClassName)
|
---|
119 | {
|
---|
120 | somId mySomId;
|
---|
121 | SOMClass *somClass;
|
---|
122 |
|
---|
123 | if((mySomId=somIdFromString(chrClassName))==NULLHANDLE)
|
---|
124 | return NULLHANDLE;
|
---|
125 |
|
---|
126 | // somClass=_somClassFromId(SOMClassMgrObject, mySomId);
|
---|
127 | /* somFindClass() loads the class if not already done */
|
---|
128 | somClass=_somFindClass(SOMClassMgrObject, mySomId, 1, 1);
|
---|
129 | SOMFree(mySomId);
|
---|
130 |
|
---|
131 | return somClass;
|
---|
132 | }
|
---|
133 |
|
---|
134 | #if __cplusplus
|
---|
135 | extern "C" {
|
---|
136 |
|
---|
137 | #endif
|
---|
138 |
|
---|
139 | /*!*******************************************************/
|
---|
140 | /* */
|
---|
141 | /* @@DESC */
|
---|
142 | /* Check if the object wpObject is an instance of the */
|
---|
143 | /* class <chrClassName>. */
|
---|
144 | /* */
|
---|
145 | /* @@REMARKS */
|
---|
146 | /* */
|
---|
147 | /* The object may be an instance of the specified class */
|
---|
148 | /* or of one of the subclasses when this function returns*/
|
---|
149 | /* TRUE. For example if the object is an instance of */
|
---|
150 | /* MMMP3 and MMMP3 is a subclass of MMAudio a check */
|
---|
151 | /* for MMAudio would return TRUE. */
|
---|
152 | /* */
|
---|
153 | /* @@PARAM */
|
---|
154 | /* */
|
---|
155 | /* WPObject* wpObject input */
|
---|
156 | /* Object which should be tested. */
|
---|
157 | /* */
|
---|
158 | /* @@PARAM */
|
---|
159 | /* */
|
---|
160 | /* char* chrClassName input */
|
---|
161 | /* */
|
---|
162 | /* Name of the class e.g. MMAudio. */
|
---|
163 | /* */
|
---|
164 | /* @@RETURNS */
|
---|
165 | /* */
|
---|
166 | /* BOOL rc */
|
---|
167 | /* TRUE if the object is an instance of the class */
|
---|
168 | /* <chrClassName>, or one of its subclasses, */
|
---|
169 | /* FALSE otherwise. */
|
---|
170 | /* */
|
---|
171 | /* */
|
---|
172 | /*!!******************************************************/
|
---|
173 | BOOL somObjectIsA(WPObject* wpObject, char * chrClassName)
|
---|
174 | {
|
---|
175 | return _somIsA(wpObject, somGetSomClass(chrClassName));
|
---|
176 | }
|
---|
177 |
|
---|
178 | #if __cplusplus
|
---|
179 | }
|
---|
180 | #endif
|
---|
181 |
|
---|
182 |
|
---|
183 | WPObject* somResolveShadow(WPObject* wpObject)
|
---|
184 | {
|
---|
185 | if(!somIsObj(wpObject))
|
---|
186 | return NULLHANDLE;
|
---|
187 | if(somObjectIsA(wpObject, "WPShadow"))
|
---|
188 | return _wpQueryShadowedObject((WPShadow*)wpObject, FALSE);
|
---|
189 |
|
---|
190 | return wpObject;
|
---|
191 | }
|
---|
192 |
|
---|
193 | /*!*******************************************************/
|
---|
194 | /* */
|
---|
195 | /* @@DESC */
|
---|
196 | /* Realloc memory for a new string. If an error occurs */
|
---|
197 | /* the old string is returned. In pulError the error */
|
---|
198 | /* code of wpAllocMem() is returned. The memory of the */
|
---|
199 | /* old string is freed if the function succeeds. */
|
---|
200 | /* */
|
---|
201 | /* @@REMARKS */
|
---|
202 | /* The memory containing the old string must have been */
|
---|
203 | /* allocated using wpAllocMem(). Don't call this */
|
---|
204 | /* functions with strings located in memory allocated */
|
---|
205 | /* using DosAllocMem() or malloc(). pulError contains */
|
---|
206 | /* the error code as returned by wpAllocMem(). */
|
---|
207 | /* If the string is no longer needed free the memory */
|
---|
208 | /* using wpFreeMem(). */
|
---|
209 | /* */
|
---|
210 | /* @@PARAM */
|
---|
211 | /* */
|
---|
212 | /* WPObject* wpObject input */
|
---|
213 | /* Object for which the wpAllocMem() method is called. */
|
---|
214 | /* */
|
---|
215 | /* */
|
---|
216 | /* @@PARAM */
|
---|
217 | /* */
|
---|
218 | /* PBYTE oldString input */
|
---|
219 | /* */
|
---|
220 | /* Ponter to the already allocated string memory. If */
|
---|
221 | /* this function succeeds, this memory will be freed. */
|
---|
222 | /* */
|
---|
223 | /* @@PARAM */
|
---|
224 | /* */
|
---|
225 | /* char* newString input */
|
---|
226 | /* */
|
---|
227 | /* String which should be put into a new memory block */
|
---|
228 | /* */
|
---|
229 | /* @@PARAM */
|
---|
230 | /* */
|
---|
231 | /* PULONG pulError in/out */
|
---|
232 | /* */
|
---|
233 | /* Return code of wpAllocMem(). */
|
---|
234 | /* */
|
---|
235 | /* @@RETURNS */
|
---|
236 | /* */
|
---|
237 | /* PBYTE pByte */
|
---|
238 | /* Pointer to the memory containing the newString. */
|
---|
239 | /* If an error ocurred, the pointer to the old string */
|
---|
240 | /* is returned. The strings are always null terminated. */
|
---|
241 | /* */
|
---|
242 | /* */
|
---|
243 | /*!!******************************************************/
|
---|
244 | PBYTE somReallocString(WPObject* wpObject, PBYTE oldString, char* newString, PULONG pulError)
|
---|
245 | {
|
---|
246 | ULONG ulLen;
|
---|
247 | PBYTE pNewText;
|
---|
248 |
|
---|
249 | if(!newString)
|
---|
250 | return oldString;
|
---|
251 |
|
---|
252 | ulLen=strlen(newString);
|
---|
253 | /* Alloc mem for new string */
|
---|
254 | if( (pNewText=_wpAllocMem(wpObject, ulLen, pulError))!=NULLHANDLE) {
|
---|
255 | /* Copy string into memory */
|
---|
256 | strcpy(pNewText, newString);
|
---|
257 | if(oldString)
|
---|
258 | _wpFreeMem(wpObject, oldString);
|
---|
259 | return pNewText;
|
---|
260 | }
|
---|
261 |
|
---|
262 | return oldString;;
|
---|
263 | }
|
---|
264 |
|
---|
265 |
|
---|
266 | BOOL wpsObjectIsInsertedInContainer(WPObject * wpObject)
|
---|
267 | {
|
---|
268 |
|
---|
269 | if(_wpFindUseItem(wpObject, USAGE_RECORD, NULLHANDLE))
|
---|
270 | return TRUE;
|
---|
271 |
|
---|
272 | return FALSE;
|
---|
273 | }
|
---|
274 |
|
---|
275 | /*
|
---|
276 | This function draws the template (but not the icon) if the object is a template.
|
---|
277 | */
|
---|
278 | ULONG wpsDrawTemplate(WPObject* wpObject, RECTL* rcl, HPS hps, ULONG flCnr)
|
---|
279 | {
|
---|
280 | HPOINTER hptrTemplate;
|
---|
281 | HMODULE hmodTemplate;
|
---|
282 |
|
---|
283 | if(!DosQueryModuleHandle("PMWP",&hmodTemplate))
|
---|
284 | {
|
---|
285 | ULONG ulIconSize;
|
---|
286 |
|
---|
287 | hptrTemplate=WinLoadPointer(HWND_DESKTOP, hmodTemplate, 20);
|
---|
288 | WinDrawPointer(hps, rcl->xLeft, rcl->yBottom, hptrTemplate, (flCnr & CV_MINI ? DP_MINI:DP_NORMAL));
|
---|
289 | WinDestroyPointer(hptrTemplate);
|
---|
290 | if((ulIconSize=WinQuerySysValue(HWND_DESKTOP,SV_CXICON))!=0)
|
---|
291 | {
|
---|
292 | ulIconSize=(rcl->xRight-rcl->xLeft-ulIconSize/2)/2;
|
---|
293 | rcl->xLeft+=ulIconSize/2;
|
---|
294 | rcl->yBottom+=ulIconSize;
|
---|
295 | }
|
---|
296 | return DP_MINI;
|
---|
297 | }
|
---|
298 |
|
---|
299 | return DP_NORMAL;
|
---|
300 | }
|
---|
301 |
|
---|
302 |
|
---|
303 | //#include "sys_funcs.h"
|
---|
304 | /*
|
---|
305 | This function redraws an object in all containers it is inserted in.
|
---|
306 | */
|
---|
307 | void wpsRefreshObjectRecords(WPObject *somSelf)
|
---|
308 | {
|
---|
309 | PUSEITEM pUse;
|
---|
310 | // SysWriteToTrapLog("!!! %s: %s\n", __FUNCTION__, _wpQueryTitle(somSelf));
|
---|
311 | for(pUse=_wpFindUseItem(somSelf, USAGE_RECORD, NULL );pUse;
|
---|
312 | pUse=_wpFindUseItem(somSelf, USAGE_RECORD, pUse ))
|
---|
313 | {
|
---|
314 | PRECORDITEM pRecordItem=(PRECORDITEM)++pUse;
|
---|
315 | WinPostMsg(pRecordItem->hwndCnr, CM_INVALIDATERECORD,MPFROMP(&pRecordItem->pRecord),
|
---|
316 | MPFROM2SHORT(1,CMA_NOREPOSITION/* |CMA_ERASE*/));
|
---|
317 | // SysWriteToTrapLog("!!! %s: %s %x\n", __FUNCTION__, _wpQueryTitle(somSelf), pRecordItem->hwndCnr);
|
---|
318 | }/* for() */
|
---|
319 | }
|
---|
320 |
|
---|
321 |
|
---|
322 |
|
---|