home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!spool.mu.edu!umn.edu!csus.edu!netcom.com!jimlynch
- From: jimlynch@netcom.com (Jim Lynch)
- Subject: Re: TCL, CPanes of variant shapes?
- Message-ID: <1993Jan4.230114.18527@netcom.com>
- Organization: Netcom Online Communications Services (408-241-9760 login: guest)
- References: <1993Jan3.213713.11222@fsl.noaa.gov>
- Date: Mon, 4 Jan 1993 23:01:14 GMT
- Lines: 117
-
- Yes, you can. Here's mine. Feel free to have it as a toy, but if you
- distribute it, it must include this message. Don't use it in
- commercially available software without talking to me well in advance.
-
- --------------- *** file CRegion.c *** ------------------
- #include "CRegion.h"
-
- void CRegion::IRegion
- (
- CView *anEnclosure,
- CBureaucrat *aSupervisor,
- short aWidth,
- short aHeight,
- short aHEncl,
- short aVEncl,
- SizingOption aHSizing,
- SizingOption aVSizing
- )
- {
- inherited::IPane
- (
- anEnclosure, aSupervisor,
- aWidth, aHeight,
- aHEncl, aVEncl,
- aHSizing, aVSizing
- ) ;
-
- itsRegionH = NewRgn() ;
- }
-
- void CRegion::Dispose(void)
- }
- return(result) ;
- }
- result = PtInRgn(thePoint, itsRegionH) ;
- thePoint.v = theLPoint.v ;
- thePoint.h = theLPoint.h ;
- WindToFrame(thePoint, &theLPoint) ;
- {
- aWidth, aHeight,
- aHEncl, aVEncl,
- aHSizing, aVSizing
- ) ;
-
- itsRegionH = NewRgn() ;
- }
-
- void CRegion::Dispose(void)
- {
- DisposeRgn(itsRegionH) ;
-
- inherited::Dispose() ;
- }
-
- Boolean CRegion::Contains(Point thePoint)
- {
- LongPt theLPoint ;
- Boolean result ;
-
- result = FALSE ;
-
- if(ReallyVisible())
- {
- WindToFrame(thePoint, &theLPoint) ;
- thePoint.h = theLPoint.h ;
- thePoint.v = theLPoint.v ;
- result = PtInRgn(thePoint, itsRegionH) ;
- }
-
- return(result) ;
- }
-
- -------------- *** end of CRegion.c *** ------------------
-
- Here's the .h file:
-
- --------------- *** CRegion.h *** --------------------
- #pragma once
-
- #include <CPane.h>
-
- class CRegion : public CPane
- {
- protected:
- RgnHandle itsRegionH ;
-
- public:
- void IRegion
- (
- CView *anEnclosure,
- CBureaucrat *aSupervisor,
- short aWidth,
- short aHeight,
- short aHEncl,
- short aVEncl,
- SizingOption aHSizing,
- SizingOption aVSizing
- ) ;
- void Dispose(void) ;
-
- Boolean Contains(Point thePoint);
- } ;
-
- ---------------- *** end of CRegion.h *** ------------
-
- Notice I don't do anything to itsRegionH after allocating; that's up to your
- code. Also note that I override CPane::Contains() so CRegion's version checks
- to see if the point lies in the region referred to by itsRegionH.
-
- I use this as an abstract class. I was doing something with piano keys which
- are irregular shapes. Made buttons out of them, as I recall... In any case,
- my CKey::IKey method called its superclass' IRegion method then did something
- to the region (like make a shape).
-
- So you could make a CHex which is a subclass of CRegion and draw a hex polygon
- in itsRegionH...
-
-