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

Last change on this file since 44 was 41, checked in by umoeller, 24 years ago

Updated timers.

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