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

Last change on this file since 93 was 48, checked in by umoeller, 24 years ago

misc changes

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