// $Revision: 1.4 $ // Copyright (c) 1995 Taligent, Inc. All rights reserved. #ifndef TaligentSamples_SAMPLETEXTPRESENTATION #include "SampleTextPresentation.h" #endif #ifndef Taligent_TEXTMODEL #include #endif VersionDefinitionsMacro(TSampleTextPresenter, 0); TSampleTextPresenter::TSampleTextPresenter(const TGUIBundle& bundle) : TTextPresenter(bundle) { } TSampleTextPresenter::~TSampleTextPresenter() { } // By overriding this and returning NIL, we indicate no clipping view will be used, // and so the view will be resized when the window is resized. Otherwise, the // view would be placed in a standard TScrollingView with horizontal and vertical // scrollbars, and the view would be clipped instead of resized. // // If we didn't want to do this, it wouldn't be necessary to subclass TTextPresenter // to create TSampleTextPresenter. If we didn't need to create TSampleTextPresenter, // it wouldn't be necessary to subclass TTextPresenterState to create // TSampleTextPresenterState, since the 'default' values provided by its constructor // could just as easily be set by the stationery. We need to derive from // TDocumentComponentStationery in any case, since EditableText provides no // stationery class for us, and CompoundDocument provides no stationery template // that takes both a model and a presenterState (we need to set both). TView* TSampleTextPresenter::HandleCreateContentClippingView(TDocumentTextView*) const { return NIL; } // ============== // The default constructor supplies defaults, but this is optional as the stationery // could set them instead. This class exists primarily to instantiate our custom // presenter. MCollectibleDefinitionsMacro(TSampleTextPresenterState, 0); TSampleTextPresenterState::TSampleTextPresenterState() : TTextPresenterState() { SetTextBackgroundColor(TRGBColor(1.0, 1.0, 0.75)); SetTextSelectionColor(TRGBColor(0.75, 1.0, 0.75)); SetTextViewSize(TGPoint(300, 300)); } TSampleTextPresenterState::TSampleTextPresenterState(const TSampleTextPresenterState& source) : TTextPresenterState(source) { } TSampleTextPresenterState::~TSampleTextPresenterState() { } TSampleTextPresenterState& TSampleTextPresenterState::operator=(const TSampleTextPresenterState& source) { if (&source != this) { TTextPresenterState::operator=(source); } return *this; } TGUIPresenter* TSampleTextPresenterState::HandleCreatePresenter(const TGUIBundle& bundle) const { return new TSampleTextPresenter(bundle); } // =========== // This class is required to create a TTextModel and TTextPresenterState. // Note that if we did not wish to override // TTextPresenter::HandleCreateContentClippingView, this is the only // class we'd need to write. MCollectibleDefinitionsMacro(TSampleTextStationery, 0); TSampleTextStationery::TSampleTextStationery() : TDocumentComponentStationery() { } TSampleTextStationery::~TSampleTextStationery() { } TModel* TSampleTextStationery::CreateModel() { return new TTextModel; } TModelPresenterState* TSampleTextStationery::CreateModelPresenterState() { return new TSampleTextPresenterState; }