// $Revision: 1.4 $ // Copyright (C)1995 Taligent,Inc. All rights reserved. #ifndef Taligent_GUICOMPOUNDDOCUMENT #include #endif #ifndef Taligent_COMPOUNDDOCUMENTCOMMAND #include #endif #ifndef TaligentSamples_ATOMICMODEL #include #endif #ifndef Taligent_FONTSUBSTITUTION #include #endif #ifndef TaligentSamples_WEBLINK #include "WebLink.h" #endif #ifndef TaligentSamples_WEBLINKVIEW #include "WebLinkView.h" #endif #ifndef TaligentSamples_WEBMODEL #include "WebModel.h" #endif #ifndef TaligentSamples_FOLLOWURLCOMMAND #include "FollowURLCommand.h" #endif MCollectibleDefinitionsMacro(TWebLink, kOriginalVersion); TDocumentComponent* TWebLink::CreateWebLinkComponent(const TURL& destinationURL, const TStandardText& text, const TModelReference& parent) { TWebLink* link = new TWebLink(destinationURL, text, parent); TDocumentComponent* component = new TDocumentComponent(new TAtomicModelOn(link), new TGUIPresenterStateFor >); return component; } TWebLink::TWebLink() : fDisplayedText(), fDestinationURL(), fParentViewerReference() { } TWebLink::TWebLink(const TWebLink& source) : fDisplayedText(source.fDisplayedText), fDestinationURL(source.fDestinationURL), fParentViewerReference() // intentionally not copying { } TWebLink::TWebLink(const TURL& destination, const TStandardText& text, const TModelReference& parent) : fDisplayedText(text), fDestinationURL(destination), fParentViewerReference(parent) { } TWebLink::~TWebLink() { } TWebLink& TWebLink::operator=(const TWebLink& source) { if (&source != this) { fDisplayedText = source.fDisplayedText; fDestinationURL = source.fDestinationURL; } return *this; } TStream& TWebLink::operator>>=(TStream& toStream) const { ::WriteVersion(toStream); fDisplayedText >>= toStream; fDestinationURL >>= toStream; return toStream; } TStream& TWebLink::operator<<=(TStream& fromStream) { ::ReadVersion(fromStream, kOriginalVersion, kOriginalVersion); fDisplayedText <<= fromStream; fDestinationURL <<= fromStream; return fromStream; } TStandardText TWebLink::GetDisplayedText() const { TStandardText glyphText(" "); if (fParentViewerReference.IsDefined()) { glyphText += TStandardText(0xf8d2); } else { glyphText += TStandardText(0xf8cf); // A third glyph, 0xf8d0, will be used in future versions to indicate // a link that has been opened into an external document. } glyphText.AddStyles(TFontFamilyStyle("Link")); return fDisplayedText + glyphText; } TStandardText TWebLink::GetRawText() const { return fDisplayedText; } void TWebLink::OpenWebDocument() { TWebModel::OpenWebDocument(fDestinationURL); } TModelReference TWebLink::GetViewerModelReference() const { return fParentViewerReference; } TURL TWebLink::GetDestination() const { return fDestinationURL; }