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

Last change on this file since 233 was 233, checked in by umoeller, 23 years ago

Minor changes.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 22.2 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 "helpers\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 PCSZ 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 * -- CA_DETAILSVIEWTITLES: details view _with_ column headers
392 * -- CV_MINI: mini icons (but set the CCS_MINICONS _window_
393 * style in addition, see below)
394 *
395 * <B>Mini icons:</B>
396 *
397 * This is especially sick. The CV_MINI style in CNRINFO is only
398 * supported for "pure" icon view. For details and tree views,
399 * _in addition_, you must set the (half-documented) CCS_MINICONS style
400 * as a _window_ style on the container. Whoever came up with this.
401 *
402 * <B>Target emphasis:</B>
403 *
404 * For Name, Text, and Details view, per default target emphasis
405 * during d'n'd is only displayed _around_ the record core.
406 * This allows users to drop records onto each other.
407 * If you add CA_ORDEREDTARGETEMPH, target emphasis is only
408 * displayed _between_ records (to reorder records).
409 * If you add CA_MIXEDTARGETEMPH, both emphasis types are possible.
410 *
411 * Additional flags for _all_ views:
412 * -- CA_DRAWICON: RECORDCORE.hptrIcon and hptrMiniIcon
413 * are to be used to draw icons
414 * -- CA_DRAWBITMAP: RECORDCORE.hbmBitmap and hbmMiniBitmap
415 * are to be used to draw bitmaps
416 * (CA_DRAWICON takes precedence)
417 * -- CA_OWNERDRAW: all record cores are to be owner-drawn.
418 * -- CA_OWNERPAINTBACKGROUND: container sends CM_PAINTBACKGROUND
419 * to itself. By subclassing the container,
420 * this can be intercepted.
421 * -- CA_CONTAINERTITLE: add container title. If this is
422 * specified, you may also specify
423 * CA_TITLEREADONLY, CA_TITLESEPARATOR,
424 * and one out of (CA_TITLECENTER, CA_TITLELEFT,
425 * CA_TITLERIGHT).
426 *
427 *@@added V0.9.0
428 */
429
430 #define cnrhSetView(flNewAttr) \
431 CnrInfo_.flWindowAttr = (flNewAttr); \
432 ulSendFlags_ |= CMA_FLWINDOWATTR;
433
434 /*
435 *@@ cnrhSetTreeIndent:
436 * this macro sets the horizontal spacing between levels
437 * in Tree views.
438 *
439 * This can only be used after BEGIN_CNRINFO().
440 *
441 *@@added V0.9.0
442 */
443
444 #define cnrhSetTreeIndent(ulNewIndent) \
445 CnrInfo_.cxTreeIndent = (ulNewIndent); \
446 ulSendFlags_ |= CMA_CXTREEINDENT;
447
448 /*
449 *@@ cnrhSetSortFunc:
450 * this macro sets the sort function for a container.
451 *
452 * This can only be used after BEGIN_CNRINFO().
453 *
454 * Container sort funcs must have this prototype:
455 +
456 + SHORT EXPENTRY fnCompare(PRECORDCORE p1, PRECORDCORE p2, PVOID pStorage)
457 *
458 *@@added V0.9.0
459 */
460
461 #define cnrhSetSortFunc(fnCompareName) \
462 CnrInfo_.pSortRecord = (PVOID)(fnCompareName); \
463 ulSendFlags_ |= CMA_PSORTRECORD;
464
465 /* ******************************************************************
466 *
467 * View management
468 *
469 ********************************************************************/
470
471 /*
472 *@@ cnrhSelectRecord:
473 * this selects/deselects a container RECORDCORE
474 * (precc), depending on fSelect.
475 *
476 *@@changed V0.9.0
477 */
478
479 #define cnrhSelectRecord(hwndCnr, precc, fSelect) \
480 WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, \
481 (MPARAM)(precc), \
482 MPFROM2SHORT(fSelect, CRA_SELECTED))
483
484 /*
485 *@@ cnrhSetSourceEmphasis:
486 * this gives a container RECORDCORE (precc)
487 * source emphasis or removes it, depending
488 * on fSelect.
489 * precc may be NULL to give the whole container
490 * source emphasis.
491 */
492
493 #define cnrhSetSourceEmphasis(hwndCnr, precc, fSelect) \
494 WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, \
495 (MPARAM)(precc), \
496 MPFROM2SHORT(fSelect, CRA_SOURCE))
497
498 ULONG cnrhSelectAll(HWND hwndCnr,
499 BOOL fSelect);
500
501 #define FRFP_RIGHTSPLITWINDOW 0x0001
502 #define FRFP_SCREENCOORDS 0x0002
503
504 PRECORDCORE cnrhFindRecordFromPoint(HWND hwndCnr,
505 PPOINTL pptl,
506 PRECTL prclFoundRecord,
507 ULONG fsExtent,
508 ULONG fl);
509
510 ULONG cnrhExpandFromRoot(HWND hwndCnr,
511 PRECORDCORE prec);
512
513 ULONG cnrhScrollToRecord(HWND hwndCnr,
514 PRECORDCORE pRec,
515 ULONG fsExtent,
516 BOOL KeepParent);
517
518 BOOL cnrhShowContextMenu(HWND hwndCnr,
519 PRECORDCORE preccSource,
520 HWND hMenu,
521 HWND hwndMenuOwner);
522
523 // flags for cnrhQuerySourceRecord
524 #define SEL_WHITESPACE 1
525 #define SEL_SINGLESEL 2
526 #define SEL_MULTISEL 3
527 #define SEL_SINGLEOTHER 4
528 #define SEL_NONEATALL 5
529
530 PRECORDCORE cnrhQuerySourceRecord(HWND hwndCnr,
531 PRECORDCORE preccSource,
532 PULONG pulSelection);
533
534 PRECORDCORE cnrhQueryNextSelectedRecord(HWND hwndCnr,
535 PRECORDCORE preccCurrent);
536
537 /*
538 *@@category: Helpers\PM helpers\Container helpers\Record relations/iteration
539 */
540
541 /* ******************************************************************
542 *
543 * Record relations/iteration
544 *
545 ********************************************************************/
546
547 LONG cnrhQueryRecordIndex(HWND hwndCnr,
548 PRECORDCORE precc);
549
550 BOOL cnrhIsChildOf(HWND hwndCnr,
551 PRECORDCORE precTest,
552 PRECORDCORE precParent);
553
554 /*
555 *@@ cnrhQueryParentRecord:
556 * this returns the parent record of precc.
557 *
558 * This returns a PRECORDCORE or NULL if no
559 * parent record could be found or -1 if
560 * the container found an error.
561 *
562 *@@added V0.9.0
563 */
564
565 #define cnrhQueryParentRecord(hwndCnr, precc) \
566 (PRECORDCORE)WinSendMsg(hwndCnr, CM_QUERYRECORD, \
567 (MPARAM)precc, \
568 MPFROM2SHORT(CMA_PARENT, CMA_ITEMORDER))
569
570 /*
571 *@@ cnrhQueryFirstChildRecord:
572 * this returns the first child record of precc.
573 *
574 * This returns a PRECORDCORE or NULL if no
575 * parent record could be found or -1 if
576 * the container found an error.
577 *
578 *@@added V0.9.0
579 */
580
581 #define cnrhQueryFirstChildRecord(hwndCnr, precc) \
582 (PRECORDCORE)WinSendMsg(hwndCnr, CM_QUERYRECORD, \
583 (MPARAM)precc, \
584 MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER))
585
586 typedef ULONG XWPENTRY FNCBRECC(HWND, PRECORDCORE, ULONG);
587 typedef FNCBRECC *PFNCBRECC;
588
589 ULONG cnrhForAllRecords(HWND hwndCnr,
590 PRECORDCORE preccParent,
591 PFNCBRECC pfncbRecc,
592 ULONG ulUser);
593
594 /* ******************************************************************
595 *
596 * Miscellaneous
597 *
598 ********************************************************************/
599
600 HWND cnrhQueryCnrFromFrame(HWND hwndFrame);
601
602 BOOL cnrhOpenEdit(HWND hwndCnr);
603
604 PDRAGINFO cnrhInitDrag(HWND hwndCnr,
605 PRECORDCORE preccDrag,
606 USHORT usNotifyCode,
607 PSZ pszRMF,
608 USHORT usSupportedOps);
609
610 #define CODFL_DISABLEDTEXT 0x0001
611 #define CODFL_MINIICON 0x0002
612
613 MRESULT cnrhOwnerDrawRecord(MPARAM mp2,
614 ULONG flFlags);
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.