home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 6.0 KB | 183 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWLink.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWFrameW.hpp"
-
- #ifndef FWLINK_H
- #include "FWLink.h"
- #endif
-
- // ----- Framework Includes -----
-
- #ifndef FWPART_H
- #include "FWPart.h"
- #endif
-
- #ifndef FWPRESEN_H
- #include "FWPresen.h"
- #endif
-
- #ifndef FWFRAME_H
- #include "FWFrame.h"
- #endif
-
- #ifndef FWEVENT_H
- #include "FWEvent.h"
- #endif
-
- #ifndef FWCONTXT_H
- #include "FWContxt.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdTypes_defined
- #include <StdTypes.xh>
- #endif
-
- //========================================================================================
- // Runtime information
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment odflinking
- #endif
-
- //=======================================================================================
- // Constants
- //=======================================================================================
-
- // Bit patterns for link borders
- const FW_BitPattern FW_kHLinkPat = {0x00, 0x66, 0xCC, 0x00, 0x00, 0x00, 0x00, 0x00};
- const FW_BitPattern FW_kVLinkPat = {0x20, 0x60, 0x40, 0x00, 0x20, 0x60, 0x40, 0x00};
- const FW_BitPattern FW_kSelectedHLinkPat = {0x00, 0x77, 0xEE, 0x00, 0x00, 0x00, 0x00, 0x00};
- const FW_BitPattern FW_kSelectedVLinkPat = {0x20, 0x60, 0x60, 0x40, 0x20, 0x60, 0x60, 0x40};
-
- //========================================================================================
- // class FW_CLink
- //========================================================================================
-
- //---------------------------------------------------------------------------------------
- // FW_CLink constructor
- //---------------------------------------------------------------------------------------
- FW_CLink::FW_CLink(Environment* ev, FW_CPresentation* presentation)
- : fPresentation(presentation),
- fSelected(false),
- fShowBorder(false)
- {
- FW_UNUSED(ev);
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CLink destructor
- //---------------------------------------------------------------------------------------
- FW_CLink::~FW_CLink()
- {
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CLink::DoCreateLinkBorderShape
- //---------------------------------------------------------------------------------------
- ODShape* FW_CLink::DoCreateLinkBorderShape(Environment* ev)
- {
- FW_UNUSED(ev);
- // Override to create a shape for the linked data's border
- return NULL;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CLink::DoDrawLinkBorder
- //---------------------------------------------------------------------------------------
- void FW_CLink::DoDrawLinkBorder(Environment* ev, ODShape* outline, FW_CGraphicContext& gc)
- {
- // Override to draw border around this link
- FW_UNUSED(ev);
- FW_UNUSED(outline);
- FW_UNUSED(gc);
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CLink::InvalidateBorder
- //---------------------------------------------------------------------------------------
- void FW_CLink::InvalidateBorder(Environment* ev)
- {
- FW_CAcquiredODShape aqBorderShape = DoCreateLinkBorderShape(ev);
- fPresentation->Invalidate(ev, aqBorderShape);
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CLink::IsMouseInBorder
- //---------------------------------------------------------------------------------------
- FW_Boolean FW_CLink::IsMouseInBorder(Environment* ev, FW_CFrame* frame, const FW_CMouseEvent& theMouseEvent)
- {
- if (!fShowBorder)
- return false;
-
- FW_CAcquiredODShape aqLinkShape = DoCreateLinkBorderShape(ev);
- if (((ODShape*)aqLinkShape) == NULL)
- return false;
-
- FW_CPoint where = theMouseEvent.GetMousePosition(ev, FW_CMouseEvent::kFrame);
- frame->GetContentView(ev)->FrameToViewContent(ev, where);
-
- ODPoint odWhere = where;
- return aqLinkShape->ContainsPoint(ev, &odWhere);
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CLink::ShowHideLinkBorder
- //---------------------------------------------------------------------------------------
- void FW_CLink::ShowHideLinkBorder(Environment* ev, FW_Boolean turnOn, ODFacet* facet)
- {
- // "Show Links" setting changed; draw borders as appropriate
- this->SetSelectState(ev, false); // de-select
- this->SetShowBorder(ev, turnOn);
-
- if (turnOn)
- this->DrawLinkBorder(ev, facet);
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CLink::DrawLinkBorder
- //---------------------------------------------------------------------------------------
- void FW_CLink::DrawLinkBorder(Environment* ev, ODFacet* facet)
- {
- // Redraw border using the current setting (fSelected)
- FW_CAcquiredODShape aqOutline = DoCreateLinkBorderShape(ev);
- if (((ODShape*)aqOutline) != NULL)
- if (!aqOutline->IsEmpty(ev))
- {
- FW_CViewContext fc(ev, NULL, facet); // the content view will be used
- this->DoDrawLinkBorder(ev, aqOutline, fc);
- }
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CLink::Select
- //---------------------------------------------------------------------------------------
- void FW_CLink::Select(Environment* ev, FW_Boolean newState)
- {
- this->SetSelectState(ev, newState);
- this->SelectionChanged(ev, newState);
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CLink::SelectionChanged
- //---------------------------------------------------------------------------------------
- void FW_CLink::SelectionChanged(Environment* ev, FW_Boolean newState)
- {
- FW_UNUSED(ev);
- FW_UNUSED(newState);
- // Override to do part-specific stuff when a link has been selected or de-selected
- }
-