home *** CD-ROM | disk | FTP | other *** search
- /*
- ** Apple Macintosh Developer Technical Support
- **
- ** File: TGroupObj.c
- ** Written by: Eric Soldan
- **
- ** Copyright © 1992 Apple Computer, Inc.
- ** All rights reserved.
- */
-
- /* You may incorporate this sample code into your applications without
- ** restriction, though the sample code has been provided "AS IS" and the
- ** responsibility for its operation is 100% yours. However, what you are
- ** not permitted to do is to redistribute the source as "DSC Sample Code"
- ** after having made changes. If you're going to re-distribute the source,
- ** we require that you make it clear in the source that the code was
- ** descended from Apple Sample Code, but that you've made changes. */
-
- /* See the files "=How to write your app" and "=Using TreeObj.c" for information
- ** on this function. */
-
- /* The group object is used as a parent of objects that are to be grouped.
- ** By having a group parent object, the children are understood to be grouped.
- ** This allows a hierarchy of groups.
- **
- ** Group objects can't be clicked on. Their members can, however. This means
- ** that hit-testing for a group always returns false. When an actual object is
- ** hit, it actually returns itself only if the parent isn't a group. A hit on
- ** an actual object causes the object to look at the parent. If the parent is
- ** a group, then it wants to return the parent as the object hit. If in turn that
- ** parent is a group, it continues up the chain until a non-group object is hit.
- ** For this sample application the first non-group parent will always be the root
- ** object.
- **
- ** The above parent check for hit-testing means that the highest order object
- ** in the group will always be returned, thus indicating that all members of the
- ** group should be considered selected. That is the exact implementation we use.
- **
- ** This also means that only objects directly off the root can be selected. The
- ** object will either be the highest order group object, or it will be an actual
- ** object directly off the root.
- **
- ** It seems kind of odd that a group object can be selected, but it can't be hit.
- ** This does actually make sense, since if any one of the members of the group is
- ** hit, the entire group should be considered a single entity, and the highest
- ** order group object would then naturally be the object to select. */
-
-
-
- /*****************************************************************************/
-
-
-
- #include "App.h" /* Get the application includes/typedefs, etc. */
- #include "App.protos.h" /* Get the prototypes for the application. */
-
- #ifndef __OSEVENTS__
- #include <OSEvents.h>
- #endif
-
- #ifndef __OSUTILS__
- #include <OSUtils.h>
- #endif
-
- #ifndef __QUICKDRAW__
- #include <Quickdraw.h>
- #endif
-
- #ifndef __STRING__
- #include <String.h>
- #endif
-
- #ifndef __TREEOBJ2__
- #include "TreeObj2.h"
- #endif
-
- #ifndef __UTILITIES__
- #include "Utilities.h"
- #endif
-
-
-
-
- #pragma segment DrawObjects
- long TGroupObj(TreeObjHndl hndl, short message, long data)
- {
- #if VH_VERSION
- char *cptr;
- Rect rct;
- #endif
-
- switch (message) {
- case FREEMESSAGE: /* For these messages, the TRect behavior is what we want. */
- case COPYMESSAGE:
- case UNDOMESSAGE:
- case CONVERTMESSAGE:
- case FREADMESSAGE:
- case FWRITEMESSAGE:
- case HREADMESSAGE:
- case HWRITEMESSAGE:
- case GETOBJRECTMESSAGE:
- case SETOBJRECTMESSAGE:
- case SECTOBJRECTMESSAGE:
- case GETBBOXMESSAGE:
- case CLICKMESSAGE:
- case SETSELECTMESSAGE:
- case GETSELECTMESSAGE:
- case COMPAREMESSAGE:
- return(TRectObj(hndl, message, data));
- break;
-
- case INITMESSAGE:
- break;
-
- case HITTESTMESSAGE:
- return(0L); /* Groups can not directly be hit. */
- break;
-
- case GETRGNMESSAGE:
- return((long)NewRgn()); /* The region is used for hit-testing, so return an empty rgn. */
- break;
-
- case DRAWMESSAGE:
- if (data == DRAWSELECT)
- TRectObj(hndl, message, data);
- /* Draw the selection indicators, bu the group has no body. */
- break;
-
- #if VH_VERSION
- case VHMESSAGE:
- cptr = ((VHFormatDataPtr)data)->data;
- ccatchr(cptr, 13, 2);
- ccat (cptr, "$10: TGroupObj:");
- ccatchr(cptr, 13, 1);
- ccat (cptr, " $00: selected = ");
- ccatdec(cptr, mDerefGroup(hndl)->selected);
- ccatchr(cptr, 13, 1);
-
- rct = mDerefGroup(hndl)->group;
- ccat (cptr, " $02: group = ($");
- ccatpadhex(cptr, 0, 4, 4, rct.top);
- ccat (cptr, ",$");
- ccatpadhex(cptr, 0, 4, 4, rct.left);
- ccat (cptr, ",$");
- ccatpadhex(cptr, 0, 4, 4, rct.bottom);
- ccat (cptr, ",$");
- ccatpadhex(cptr, 0, 4, 4, rct.right);
- ccat (cptr, ")");
- return(true);
- break;
- #endif
-
- default:
- break;
- }
-
- return(noErr);
- }
-
-
-
-