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

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

Added XML.

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