home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 6.1 KB | 200 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: PatFrame.cpp
- // Release Version: $ ODF 2 $
- //
- // Author: Henri Lamiraux
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "ODFDraw.hpp"
-
- #ifndef PATFRAME_H
- #include "PatFrame.h"
- #endif
-
- #ifndef DRAWPART_H
- #include "DrawPart.h"
- #endif
-
- #ifndef DEFINES_K
- #include "Defines.k"
- #endif
-
- // ----- Part Layer -----
-
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- #ifndef FWCONTXT_H
- #include "FWContxt.h"
- #endif
-
- // ----- OS Layer -----
-
- #ifndef FWWINDOW_H
- #include "FWWindow.h"
- #endif
-
- #ifndef FWMEMMGR_H
- #include "FWMemMgr.h"
- #endif
-
- #ifndef FWEVENT_H
- #include "FWEvent.h"
- #endif
-
- #ifndef FWCOLOR_H
- #include "FWColor.h"
- #endif
-
- #ifndef FWRECSHP_H
- #include "FWRecShp.h"
- #endif
-
- //========================================================================================
- // Runtime Informations
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment odfdrawframes
- #endif
-
- //========================================================================================
- // CLASS CPatternChangedInterest
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CPatternChangedInterest::CPatternChangedInterest
- //----------------------------------------------------------------------------------------
-
- CPatternChangedInterest::CPatternChangedInterest(FW_MNotifier* notifier) :
- FW_CInterest(notifier, kPatternChanged)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CPatternChangedInterest::~CPatternChangedInterest
- //----------------------------------------------------------------------------------------
-
- CPatternChangedInterest::~CPatternChangedInterest()
- {
- }
-
- //========================================================================================
- // CLASS CPatternChangedNotification
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CPatternChangedNotification::CPatternChangedNotification
- //----------------------------------------------------------------------------------------
-
- CPatternChangedNotification::CPatternChangedNotification(const FW_CInterest& interest,
- short patternIndex,
- FW_ERenderVerbs renderVerb) :
- FW_CNotification(interest),
- fPatternIndex(patternIndex),
- fRenderVerb(renderVerb)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CPatternChangedNotification::~CPatternChangedNotification
- //----------------------------------------------------------------------------------------
-
- CPatternChangedNotification::~CPatternChangedNotification()
- {
- }
-
- //========================================================================================
- // CLASS CPatternFrame
- //========================================================================================
-
- FW_DEFINE_AUTO(CPatternFrame)
-
- //----------------------------------------------------------------------------------------
- // CPatternFrame::CPatternFrame
- //----------------------------------------------------------------------------------------
-
- CPatternFrame::CPatternFrame(Environment* ev, ODFrame* odFrame, FW_CPresentation* presentation, CDrawPart* drawPart) :
- CFloatingWindowFrame(ev, odFrame, presentation, drawPart),
- FW_MNotifier(),
- fGrid(2, 6, FW_CPoint(FW_IntToFixed(2), FW_IntToFixed(2)), FW_CPoint(kPatternCellSize, kPatternCellSize), FW_kFixedPos1),
- fDrawPart(drawPart)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CPatternFrame::~CPatternFrame
- //----------------------------------------------------------------------------------------
-
- CPatternFrame::~CPatternFrame()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CPatternFrame::Draw
- //----------------------------------------------------------------------------------------
-
- void CPatternFrame::Draw(Environment* ev, ODFacet* odFacet, ODShape* invalidShape)
- {
- FW_CViewContext vc(ev, this, odFacet, invalidShape);
- vc.SetMapping(fMapping);
-
- EraseBackground(ev, vc);
-
- // ----- Draw the grid -----
- fGrid.DrawGridBorders(vc);
-
- // ----- Draw each color -----
- FW_CRect rect;
- FW_CRectShape rectShape(FW_kZeroRect, FW_kFill);
- for (unsigned long index = 0; index < 12; index++)
- {
- fGrid.GetCellInterior(index, rect);
- rectShape.SetRectangle(rect);
- rectShape.GetStyle().SetPattern(fDrawPart->GetPattern(index));
- rectShape.Render(vc);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CPatternFrame::DoMouseDown
- //----------------------------------------------------------------------------------------
-
- FW_Handled CPatternFrame::DoMouseDown(Environment* ev, const FW_CMouseEvent& theMouseEvent)
- {
- FW_CPoint where = theMouseEvent.GetLogicalMousePosition(ev, fMapping);
-
- unsigned long patIndex;
- if (fGrid.FindCell(where, patIndex))
- {
- CPatternChangedInterest interest(this);
- CPatternChangedNotification notification(interest, patIndex, theMouseEvent.IsCopyModifier(ev) ? FW_kFrame : FW_kFill);
- Notify(ev, notification);
- }
-
- return FW_kHandled;
- }
-
- //----------------------------------------------------------------------------------------
- // CPatternFrame::FacetAdded
- //----------------------------------------------------------------------------------------
-
- void CPatternFrame::FacetAdded(Environment* ev, ODFacet* facet, unsigned short facetCount)
- {
- // ----- Call inherited first -----
- CFloatingWindowFrame::FacetAdded(ev, facet, facetCount);
-
- // ----- Resize my Window -----
- FW_CRect gridRect;
- fGrid.GetExteriorGridRect(gridRect);
- gridRect.Inset(-FW_IntToFixed(2), -FW_IntToFixed(2));
- FW_CPoint windowSize(gridRect.Width(), gridRect.Height());
- GetWindow(ev)->SetWindowSize(ev, windowSize);
- }
-
-