source: trunk/include/helpers/cnrh.h@ 13

Last change on this file since 13 was 7, checked in by umoeller, 25 years ago

Initial checkin of helpers code, which used to be in WarpIN.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 21.5 KB
Line 
1/* $Id: cnrh.h 7 2000-10-27 21:27:02Z umoeller $ */
2
3
4/*
5 *@@sourcefile cnrh.h:
6 * header file for cnrh.c (container helper functions).
7 * See remarks there.
8 *
9 * Note: Version numbering in this file relates to XWorkplace version
10 * numbering.
11 *
12 *@@include #define INCL_WINSTDCNR
13 *@@include #define INCL_WINSTDDRAG
14 *@@include #include <os2.h>
15 *@@include #include "cnrh.h"
16 */
17
18/* Copyright (C) 1997-2000 Ulrich M”ller.
19 * This file is part of the XWorkplace source package.
20 * XWorkplace is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published
22 * by the Free Software Foundation, in version 2 as it comes in the
23 * "COPYING" file of the XWorkplace main distribution.
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
28 */
29
30#if __cplusplus
31extern "C" {
32#endif
33
34#ifndef CNRH_HEADER_INCLUDED
35 #define CNRH_HEADER_INCLUDED
36
37 #ifndef INCL_WINSTDCNR
38 #error cnrh.h requires INCL_WINSTDCNR to be defined.
39 #endif
40
41 /* ******************************************************************
42 * *
43 * Details view field infos *
44 * *
45 ********************************************************************/
46
47 // redefine the FIELDOFFSET macro; the one
48 // in the OS/2 header files doesn't work with C++
49 #undef FIELDOFFSET
50 #define FIELDOFFSET(type, field) ((ULONG)&(((type *)0)->field))
51
52 ULONG cnrhClearFieldInfos(HWND hwndCnr,
53 BOOL fInvalidate);
54
55 /*
56 *@@ cnrhAllocFieldInfos:
57 * this allocates sColumnCount field infos
58 * for Details view in hwndCnr.
59 * Returns the first PFIELDINFO, which is
60 * the root of a linked list. Follow
61 * FIELDINFO.pNextFieldInfo to get to the
62 * next field info, the last of which is
63 * NULL.
64 *
65 *@@added V0.9.0
66 */
67
68 #define cnrhAllocFieldInfos(hwndCnr, sColumnCount) \
69 (PFIELDINFO)WinSendMsg(hwndCnr, \
70 CM_ALLOCDETAILFIELDINFO, \
71 MPFROMSHORT(sColumnCount), \
72 NULL)
73
74 /*
75 *@@ XFIELDINFO:
76 * input structure for cnrhSetFieldInfos.
77 * See cnrhSetFieldInfo for a description
78 * of the fields.
79 *
80 *@@added V0.9.0
81 */
82
83 typedef struct _XFIELDINFO
84 {
85 ULONG ulFieldOffset;
86 PSZ pszColumnTitle;
87 ULONG ulDataType;
88 ULONG ulOrientation;
89 } XFIELDINFO, *PXFIELDINFO;
90
91 VOID cnrhSetFieldInfo(PFIELDINFO *ppFieldInfo2,
92 ULONG ulFieldOffset,
93 PSZ pszColumnTitle,
94 ULONG ulDataType,
95 ULONG ulOrientation,
96 BOOL fDrawLines);
97
98 ULONG cnrhInsertFieldInfos(HWND hwndCnr,
99 PFIELDINFO pFieldInfoFirst,
100
101 ULONG ulFieldCount);
102
103 PFIELDINFO cnrhSetFieldInfos(HWND hwndCnr,
104 PXFIELDINFO paxfi,
105 ULONG ulFieldCount,
106 BOOL fDrawLines,
107 ULONG ulFieldReturn);
108
109 /* ******************************************************************
110 * *
111 * Record core management *
112 * *
113 ********************************************************************/
114
115 /*
116 *@@ FNCNRSORT:
117 * container sort function as used in
118 * CM_SORTRECORD and CNRINFO.pSortRecord
119 */
120
121 typedef SHORT EXPENTRY FNCNRSORT(PVOID, // record core 1
122 PVOID, // record core 2
123 PVOID); // pStorage (== NULL)
124 typedef FNCNRSORT *PFNCNRSORT;
125
126 PRECORDCORE cnrhAllocRecords(HWND hwndCnr,
127 ULONG cbrecc,
128 ULONG ulCount);
129
130 ULONG cnrhInsertRecords(HWND hwndCnr,
131 PRECORDCORE preccParent,
132 PRECORDCORE precc,
133 BOOL fInvalidate,
134 PSZ pszText,
135 ULONG flRecordAttr,
136 ULONG ulCount);
137
138 ULONG cnrhInsertRecordAfter(HWND hwndCnr,
139 PRECORDCORE precc,
140 PSZ pszText,
141 ULONG flRecordAttr,
142 PRECORDCORE preccAfter,
143 BOOL fInvalidate);
144
145 BOOL cnrhMoveRecord(HWND hwndCnr,
146 PRECORDCORE preccMove,
147 PRECORDCORE preccInsertAfter);
148
149 BOOL cnrhMoveTree(HWND hwndCnr,
150 PRECORDCORE preccMove,
151 PRECORDCORE preccNewParent,
152 PFNCNRSORT pfnCnrSort);
153
154 /*
155 *@@ cnrhRemoveAll:
156 * this helper removes all records from the container
157 * and frees them (CM_REMOVERECORD with NULL
158 * and CMA_FREE | CMA_INVALIDATE specified).
159 *
160 *@@added V0.9.0 (99-10-22) [umoeller]
161 */
162
163 #define cnrhRemoveAll(hwndCnr) \
164 WinSendMsg(hwndCnr, CM_REMOVERECORD, NULL, MPFROM2SHORT(0, CMA_FREE | CMA_INVALIDATE))
165
166 /*
167 *@@ cnrhInvalidateAll:
168 * invalidates all records in the container.
169 *
170 *@@added V0.9.2 (2000-02-19) [umoeller]
171 */
172
173 #define cnrhInvalidateAll(hwndCnr) \
174 WinSendMsg(hwndCnr, CM_INVALIDATERECORD, NULL, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION | CMA_TEXTCHANGED))
175
176 /* ******************************************************************
177 * *
178 * CNRINFO management *
179 * *
180 ********************************************************************/
181
182 /*
183 *@@ cnrhQueryCnrInfo:
184 * this stores the CNRINFO for hwndCnr
185 * in the specified variable, which must
186 * be a PCNRINFO.
187 * Example:
188 + CNRINFO CnrInfo;
189 + cnrhQueryCnrInfo(&CnrInfo);
190 *
191 *@@changed V0.9.0
192 */
193
194 #define cnrhQueryCnrInfo(hwndCnr, pCnrInfo) \
195 WinSendMsg(hwndCnr, CM_QUERYCNRINFO, \
196 (MPARAM)(pCnrInfo), \
197 (MPARAM)(sizeof(*pCnrInfo)))
198
199 /*
200 *@@ BEGIN_CNRINFO:
201 * this func starts a "container info" block for the
202 * following functions.
203 * This must always be followed by END_CNRINFO(),
204 * or you'll get funny compilation errors.
205 *
206 *@@added V0.9.0
207 */
208
209 #define BEGIN_CNRINFO() \
210 { \
211 CNRINFO CnrInfo_ = {0}; \
212 ULONG ulSendFlags_ = 0; \
213 CnrInfo_.cb = sizeof(CnrInfo_);
214
215 /*
216 *@@ END_CNRINFO:
217 * this ends a "container info" block started by
218 * BEGIN_CNRINFO.
219 *
220 *@@added V0.9.0
221 */
222
223 #define END_CNRINFO(hwndCnr) \
224 WinSendMsg((hwndCnr), CM_SETCNRINFO, (MPARAM)&CnrInfo_, \
225 (MPARAM)ulSendFlags_); \
226 }
227
228 /*
229 *@@ cnrhSetTitle:
230 * this sets the container title to the specified
231 * text. You must specify CA_CONTAINERTITLE with
232 * cnrhSetView then.
233 *
234 *@@added V0.9.1 (99-12-18) [umoeller]
235 */
236
237 #define cnrhSetTitle(pszTitle) \
238 CnrInfo_.pszCnrTitle = (pszTitle); \
239 ulSendFlags_ |= CMA_CNRTITLE;
240
241 /*
242 *@@ cnrhSetSplitBarAfter:
243 * this macro sets the field info after which
244 * the split bar should be shown.
245 * If (pFieldInfo == NULL), the split bar is hidden.
246 *
247 * This can be used directly with the return value
248 * of cnrhSetFieldInfos. With that function, specify
249 * the field info to be returned with ulFieldReturn.
250 *
251 * This can only be used after BEGIN_CNRINFO().
252 *
253 *@@added V0.9.0
254 */
255
256 #define cnrhSetSplitBarAfter(pFieldInfo) \
257 CnrInfo_.pFieldInfoLast = (pFieldInfo); \
258 ulSendFlags_ |= CMA_PFIELDINFOLAST;
259
260 /*
261 *@@ cnrhSetSplitBarPos:
262 * this macro sets the vertical split bar
263 * position (in window coordinates).
264 *
265 * This can only be used after BEGIN_CNRINFO().
266 *
267 *@@added V0.9.0
268 */
269
270 #define cnrhSetSplitBarPos(xPos) \
271 CnrInfo_.xVertSplitbar = (xPos); \
272 ulSendFlags_ |= CMA_XVERTSPLITBAR;
273
274 /*
275 *@@ cnrhSetTreeBmpOrIconSize:
276 * this macro sets the size used for the bitmaps
277 * or icons used for the "+" and "-" signs in
278 * tree views.
279 * The default is the system icon size (32 or 40).
280 */
281
282 #define cnrhSetTreeBmpOrIconSize(cxNew, cyNew) \
283 CnrInfo_.slTreeBitmapOrIcon.cx = cxNew; \
284 CnrInfo_.slTreeBitmapOrIcon.cy = cyNew; \
285 ulSendFlags_ |= CMA_SLTREEBITMAPORICON;
286
287 /*
288 *@@ cnrhSetBmpOrIconSize:
289 * this macro sets the size used for bitmaps
290 * or icons (depending on whether CA_DRAWBITMAP
291 * or the default CA_DRAWICON is set in flWindowAttr).
292 * The default is the system icon size (32 or 40).
293 *
294 * This can only be used after BEGIN_CNRINFO().
295 *
296 *@@added V0.9.0
297 */
298
299 #define cnrhSetBmpOrIconSize(cxNew, cyNew) \
300 CnrInfo_.slBitmapOrIcon.cx = cxNew; \
301 CnrInfo_.slBitmapOrIcon.cy = cyNew; \
302 ulSendFlags_ |= CMA_SLBITMAPORICON;
303
304 /*
305 *@@ cnrhSetView:
306 * this sets the container view attributes (CNRINFO.flWindowAttr).
307 *
308 * This can only be used after BEGIN_CNRINFO().
309 *
310 * The following combinations are useful for flWindowAttr.
311 *
312 * <B>Icon view:</B>
313 * -- CV_ICON: icon view
314 * RECORDCORE.pszIcon is used for record titles;
315 * add CV_MINI for mini-icons view
316 *
317 * <B>Tree view:</B>
318 * -- CV_TREE | CV_ICON: tree icon view (icon plus name;
319 * RECORDCORE.pszIcon is used for record titles)
320 * -- CV_TREE | CV_NAME: tree name view (icon plus name;
321 * RECORDCORE.pszName is used for record titles,
322 * and this does _not_ use a separate icon/bitmap for
323 * "collapsed" and "expanded"
324 * -- CV_TREE | CV_TEXT: tree text view (no icons;
325 * RECORDCORE.pszText is used for record titles)
326 * Add CA_TREELINE to have lines drawn between tree items.
327 *
328 * <B>Name view:</B>
329 * -- CV_NAME: non-flowed name view (icon plus name;
330 * RECORDCORE.pszName is used for record titles;
331 * display a single column
332 * -- CV_NAME | CV_FLOW: flowed name view (icon plus name;
333 * RECORDCORE.pszName is used for record titles;
334 * display multiple columns
335 *
336 * <B>Text view:</B>
337 * -- CV_TEXT: non-flowed name view (name WITHOUT icons;
338 * RECORDCORE.pszText is used for record titles;
339 * display a single column
340 * -- CV_TEXT | CV_FLOW: flowed name view (name WITHOUT icons;
341 * RECORDCORE.pszText is used for record titles;
342 * display multiple columns
343 *
344 * <B>Details view:</B>
345 * -- CV_DETAIL: details view without column headers
346 * -- CV_DETAIL | CA_DETAILSVIEWTITLES: details view _with_ column headers
347 *
348 * <B>Target emphasis:</B>
349 * For Name, Text, and Details view, per default target emphasis
350 * during d'n'd is only displayed _around_ the record core.
351 * If you add CA_ORDEREDTARGETEMPH, target emphasis is only
352 * displayed _below_ the record core. If you add CA_MIXEDTARGETEMPH,
353 * both emphasis types are possible.
354 *
355 * Additional flags for _all_ views:
356 * -- CA_DRAWICON: RECORDCORE.hptrIcon and hptrMiniIcon
357 * are to be used to draw icons
358 * -- CA_DRAWBITMAP: RECORDCORE.hbmBitmap and hbmMiniBitmap
359 * are to be used to draw bitmaps
360 * (CA_DRAWICON takes precedence)
361 * -- CA_OWNERDRAW: all record cores are to be owner-drawn.
362 * -- CA_OWNERPAINTBACKGROUND: container sends CM_PAINTBACKGROUND
363 * to itself. By subclassing the container,
364 * this can be intercepted.
365 * -- CA_CONTAINERTITLE: add container title. If this is
366 * specified, you may also specify
367 * CA_TITLEREADONLY, CA_TITLESEPARATOR,
368 * and one out of (CA_TITLECENTER, CA_TITLELEFT,
369 * CA_TITLERIGHT).
370 *
371 * Note that CV_MINI is only supported for "pure" icon view.
372 *
373 *@@added V0.9.0
374 */
375
376 #define cnrhSetView(flNewAttr) \
377 CnrInfo_.flWindowAttr = (flNewAttr); \
378 ulSendFlags_ |= CMA_FLWINDOWATTR;
379
380 /*
381 *@@ cnrhSetTreeIndent:
382 * this sets the horizontal spacing between levels
383 * in Tree views.
384 *
385 *@@added V0.9.0
386 */
387
388 #define cnrhSetTreeIndent(ulNewIndent) \
389 CnrInfo_.cxTreeIndent = (ulNewIndent); \
390 ulSendFlags_ |= CMA_CXTREEINDENT;
391
392 /*
393 *@@ cnrhSetSortFunc:
394 * this sets the sort function for a container.
395 * This can only be used after BEGIN_CNRINFO().
396 *
397 *@@added V0.9.0
398 */
399
400 #define cnrhSetSortFunc(fnCompareName) \
401 CnrInfo_.pSortRecord = (PVOID)(fnCompareName); \
402 ulSendFlags_ |= CMA_PSORTRECORD;
403
404 /* ******************************************************************
405 * *
406 * View management *
407 * *
408 ********************************************************************/
409
410 /*
411 *@@ cnrhSelectRecord:
412 * this selects/deselects a container RECORDCORE
413 * (precc), depending on fSelect.
414 *
415 *@@changed V0.9.0
416 */
417
418 #define cnrhSelectRecord(hwndCnr, precc, fSelect) \
419 WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, \
420 (MPARAM)(precc), \
421 MPFROM2SHORT(fSelect, CRA_SELECTED))
422
423 /*
424 *@@ cnrhSetSourceEmphasis:
425 * this gives a container RECORDCORE (precc)
426 * source emphasis or removes it, depending
427 * on fSelect.
428 * precc may be NULL to give the whole container
429 * source emphasis.
430 */
431
432 #define cnrhSetSourceEmphasis(hwndCnr, precc, fSelect) \
433 WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, \
434 (MPARAM)(precc), \
435 MPFROM2SHORT(fSelect, CRA_SOURCE))
436
437 ULONG cnrhSelectAll(HWND hwndCnr,
438 BOOL fSelect);
439
440 #define FRFP_RIGHTSPLITWINDOW 0x0001
441 #define FRFP_SCREENCOORDS 0x0002
442
443 PRECORDCORE cnrhFindRecordFromPoint(HWND hwndCnr,
444 PPOINTL pptl,
445 PRECTL prclFoundRecord,
446 ULONG fsExtent,
447 ULONG fl);
448
449 ULONG cnrhScrollToRecord(HWND hwndCnr,
450 PRECORDCORE pRec,
451 ULONG fsExtent,
452 BOOL KeepParent);
453
454 BOOL cnrhShowContextMenu(HWND hwndCnr,
455 PRECORDCORE preccSource,
456 HWND hMenu,
457 HWND hwndMenuOwner);
458
459 // flags for cnrhQuerySourceRecord
460 #define SEL_WHITESPACE 1
461 #define SEL_SINGLESEL 2
462 #define SEL_MULTISEL 3
463 #define SEL_SINGLEOTHER 4
464 #define SEL_NONEATALL 5
465
466 PRECORDCORE cnrhQuerySourceRecord(HWND hwndCnr,
467 PRECORDCORE preccSource,
468 PULONG pulSelection);
469
470 PRECORDCORE cnrhQueryNextSelectedRecord(HWND hwndCnr,
471 PRECORDCORE preccCurrent);
472
473 /* ******************************************************************
474 * *
475 * Record relations/iteration *
476 * *
477 ********************************************************************/
478
479 LONG cnrhQueryRecordIndex(HWND hwndCnr,
480 PRECORDCORE precc);
481
482 typedef ULONG (EXPENTRY FNCBRECC)(HWND, PRECORDCORE, ULONG, ULONG);
483 typedef FNCBRECC *PFNCBRECC;
484
485 /*
486 *@@ cnrhQueryParentRecord:
487 * this returns the parent record of precc.
488 *
489 * This returns a PRECORDCORE or NULL if no
490 * parent record could be found or -1 if
491 * the container found an error.
492 *
493 *@@added V0.9.0
494 */
495
496 #define cnrhQueryParentRecord(hwndCnr, precc) \
497 (PRECORDCORE)WinSendMsg(hwndCnr, CM_QUERYRECORD, \
498 (MPARAM)precc, \
499 MPFROM2SHORT(CMA_PARENT, CMA_ITEMORDER))
500
501 /*
502 *@@ cnrhQueryFirstChildRecord:
503 * this returns the first child record of precc.
504 *
505 * This returns a PRECORDCORE or NULL if no
506 * parent record could be found or -1 if
507 * the container found an error.
508 *
509 *@@added V0.9.0
510 */
511
512 #define cnrhQueryFirstChildRecord(hwndCnr, precc) \
513 (PRECORDCORE)WinSendMsg(hwndCnr, CM_QUERYRECORD, \
514 (MPARAM)precc, \
515 MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER))
516
517 ULONG cnrhForAllRecords(HWND hwndCnr,
518 PRECORDCORE preccParent,
519 PFNCBRECC pfncbRecc,
520 ULONG ulUser1,
521 ULONG ulUser2);
522
523 /* VOID cnrhForAllChildRecords(HWND hwndCnr,
524 PRECORDCORE precc,
525 PFNCBRECC pfncbRecc,
526 ULONG ulp1,
527 ULONG ulp2);
528
529 VOID cnrhForAllRecords2(HWND hwndCnr,
530 PFNCBRECC pfncbRecc,
531 ULONG ulp1,
532 ULONG ulp2);
533
534 VOID cnrhForAllParentRecords(HWND hwndCnr,
535 PRECORDCORE precc,
536 PFNCBRECC pfncbRecc,
537 ULONG ulp1,
538 ULONG ulp2); */
539
540 /* ******************************************************************
541 * *
542 * Miscellaneous *
543 * *
544 ********************************************************************/
545
546 HWND cnrhQueryCnrFromFrame(HWND hwndFrame);
547
548 PDRAGINFO cnrhInitDrag(HWND hwndCnr,
549 PRECORDCORE preccDrag,
550 USHORT usNotifyCode,
551 PSZ pszRMF,
552 USHORT usSupportedOps);
553
554 MRESULT cnrhOwnerDrawRecord(MPARAM mp2);
555
556 BOOL cnrhDateTimeDos2Win(DATETIME* pdt,
557 CDATE* pcdate,
558 CTIME* pctime);
559
560 BOOL cnrhDateDos2Win(FDATE* pfd,
561 CDATE* pcd);
562
563 BOOL cnrhTimeDos2Win(FTIME* pft,
564 CTIME* pct);
565
566#endif
567
568#if __cplusplus
569}
570#endif
571
Note: See TracBrowser for help on using the repository browser.