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

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

Coupla bugfixes.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 20.6 KB
Line 
1/* $Id: cnrh.h 15 2000-12-11 07:54:20Z 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 *
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 *
350 * For Name, Text, and Details view, per default target emphasis
351 * during d'n'd is only displayed _around_ the record core.
352 * This allows users to drop records onto each other.
353 * If you add CA_ORDEREDTARGETEMPH, target emphasis is only
354 * displayed _between_ records (to reorder records).
355 * If you add CA_MIXEDTARGETEMPH, both emphasis types are possible.
356 *
357 * Additional flags for _all_ views:
358 * -- CA_DRAWICON: RECORDCORE.hptrIcon and hptrMiniIcon
359 * are to be used to draw icons
360 * -- CA_DRAWBITMAP: RECORDCORE.hbmBitmap and hbmMiniBitmap
361 * are to be used to draw bitmaps
362 * (CA_DRAWICON takes precedence)
363 * -- CA_OWNERDRAW: all record cores are to be owner-drawn.
364 * -- CA_OWNERPAINTBACKGROUND: container sends CM_PAINTBACKGROUND
365 * to itself. By subclassing the container,
366 * this can be intercepted.
367 * -- CA_CONTAINERTITLE: add container title. If this is
368 * specified, you may also specify
369 * CA_TITLEREADONLY, CA_TITLESEPARATOR,
370 * and one out of (CA_TITLECENTER, CA_TITLELEFT,
371 * CA_TITLERIGHT).
372 *
373 * Note that CV_MINI is only supported for "pure" icon view.
374 *
375 *@@added V0.9.0
376 */
377
378 #define cnrhSetView(flNewAttr) \
379 CnrInfo_.flWindowAttr = (flNewAttr); \
380 ulSendFlags_ |= CMA_FLWINDOWATTR;
381
382 /*
383 *@@ cnrhSetTreeIndent:
384 * this sets the horizontal spacing between levels
385 * in Tree views.
386 *
387 *@@added V0.9.0
388 */
389
390 #define cnrhSetTreeIndent(ulNewIndent) \
391 CnrInfo_.cxTreeIndent = (ulNewIndent); \
392 ulSendFlags_ |= CMA_CXTREEINDENT;
393
394 /*
395 *@@ cnrhSetSortFunc:
396 * this sets the sort function for a container.
397 * This can only be used after BEGIN_CNRINFO().
398 *
399 *@@added V0.9.0
400 */
401
402 #define cnrhSetSortFunc(fnCompareName) \
403 CnrInfo_.pSortRecord = (PVOID)(fnCompareName); \
404 ulSendFlags_ |= CMA_PSORTRECORD;
405
406 /* ******************************************************************
407 *
408 * View management
409 *
410 ********************************************************************/
411
412 /*
413 *@@ cnrhSelectRecord:
414 * this selects/deselects a container RECORDCORE
415 * (precc), depending on fSelect.
416 *
417 *@@changed V0.9.0
418 */
419
420 #define cnrhSelectRecord(hwndCnr, precc, fSelect) \
421 WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, \
422 (MPARAM)(precc), \
423 MPFROM2SHORT(fSelect, CRA_SELECTED))
424
425 /*
426 *@@ cnrhSetSourceEmphasis:
427 * this gives a container RECORDCORE (precc)
428 * source emphasis or removes it, depending
429 * on fSelect.
430 * precc may be NULL to give the whole container
431 * source emphasis.
432 */
433
434 #define cnrhSetSourceEmphasis(hwndCnr, precc, fSelect) \
435 WinSendMsg(hwndCnr, CM_SETRECORDEMPHASIS, \
436 (MPARAM)(precc), \
437 MPFROM2SHORT(fSelect, CRA_SOURCE))
438
439 ULONG cnrhSelectAll(HWND hwndCnr,
440 BOOL fSelect);
441
442 #define FRFP_RIGHTSPLITWINDOW 0x0001
443 #define FRFP_SCREENCOORDS 0x0002
444
445 PRECORDCORE cnrhFindRecordFromPoint(HWND hwndCnr,
446 PPOINTL pptl,
447 PRECTL prclFoundRecord,
448 ULONG fsExtent,
449 ULONG fl);
450
451 ULONG cnrhScrollToRecord(HWND hwndCnr,
452 PRECORDCORE pRec,
453 ULONG fsExtent,
454 BOOL KeepParent);
455
456 BOOL cnrhShowContextMenu(HWND hwndCnr,
457 PRECORDCORE preccSource,
458 HWND hMenu,
459 HWND hwndMenuOwner);
460
461 // flags for cnrhQuerySourceRecord
462 #define SEL_WHITESPACE 1
463 #define SEL_SINGLESEL 2
464 #define SEL_MULTISEL 3
465 #define SEL_SINGLEOTHER 4
466 #define SEL_NONEATALL 5
467
468 PRECORDCORE cnrhQuerySourceRecord(HWND hwndCnr,
469 PRECORDCORE preccSource,
470 PULONG pulSelection);
471
472 PRECORDCORE cnrhQueryNextSelectedRecord(HWND hwndCnr,
473 PRECORDCORE preccCurrent);
474
475 /* ******************************************************************
476 *
477 * Record relations/iteration
478 *
479 ********************************************************************/
480
481 LONG cnrhQueryRecordIndex(HWND hwndCnr,
482 PRECORDCORE precc);
483
484 typedef ULONG EXPENTRY FNCBRECC(HWND, PRECORDCORE, ULONG, ULONG);
485 typedef FNCBRECC *PFNCBRECC;
486
487 /*
488 *@@ cnrhQueryParentRecord:
489 * this returns the parent record of precc.
490 *
491 * This returns a PRECORDCORE or NULL if no
492 * parent record could be found or -1 if
493 * the container found an error.
494 *
495 *@@added V0.9.0
496 */
497
498 #define cnrhQueryParentRecord(hwndCnr, precc) \
499 (PRECORDCORE)WinSendMsg(hwndCnr, CM_QUERYRECORD, \
500 (MPARAM)precc, \
501 MPFROM2SHORT(CMA_PARENT, CMA_ITEMORDER))
502
503 /*
504 *@@ cnrhQueryFirstChildRecord:
505 * this returns the first child record of precc.
506 *
507 * This returns a PRECORDCORE or NULL if no
508 * parent record could be found or -1 if
509 * the container found an error.
510 *
511 *@@added V0.9.0
512 */
513
514 #define cnrhQueryFirstChildRecord(hwndCnr, precc) \
515 (PRECORDCORE)WinSendMsg(hwndCnr, CM_QUERYRECORD, \
516 (MPARAM)precc, \
517 MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER))
518
519 ULONG cnrhForAllRecords(HWND hwndCnr,
520 PRECORDCORE preccParent,
521 PFNCBRECC pfncbRecc,
522 ULONG ulUser1,
523 ULONG ulUser2);
524
525 /* VOID cnrhForAllChildRecords(HWND hwndCnr,
526 PRECORDCORE precc,
527 PFNCBRECC pfncbRecc,
528 ULONG ulp1,
529 ULONG ulp2);
530
531 VOID cnrhForAllRecords2(HWND hwndCnr,
532 PFNCBRECC pfncbRecc,
533 ULONG ulp1,
534 ULONG ulp2);
535
536 VOID cnrhForAllParentRecords(HWND hwndCnr,
537 PRECORDCORE precc,
538 PFNCBRECC pfncbRecc,
539 ULONG ulp1,
540 ULONG ulp2); */
541
542 /* ******************************************************************
543 *
544 * Miscellaneous
545 *
546 ********************************************************************/
547
548 HWND cnrhQueryCnrFromFrame(HWND hwndFrame);
549
550 PDRAGINFO cnrhInitDrag(HWND hwndCnr,
551 PRECORDCORE preccDrag,
552 USHORT usNotifyCode,
553 PSZ pszRMF,
554 USHORT usSupportedOps);
555
556 MRESULT cnrhOwnerDrawRecord(MPARAM mp2);
557
558 BOOL cnrhDateTimeDos2Win(DATETIME* pdt,
559 CDATE* pcdate,
560 CTIME* pctime);
561
562 BOOL cnrhDateDos2Win(FDATE* pfd,
563 CDATE* pcd);
564
565 BOOL cnrhTimeDos2Win(FTIME* pft,
566 CTIME* pct);
567
568#endif
569
570#if __cplusplus
571}
572#endif
573
Note: See TracBrowser for help on using the repository browser.