// $Revision: 1.18 $ // ViewerPresenter.C // Copyright (C) 1994, 1995 Taligent, Inc. All rights reserved. #ifndef TaligentSamples_VIEWERPRESENTER #include "ViewerPresenter.h" #endif #ifndef TaligentSamples_VIEWERCONSTRUCTORS #include "ViewerConstructors.h" #endif #ifndef TaligentSamples_VIEWERPRESENTERSTATE #include "ViewerPresenterState.h" #endif #ifndef TaligentSamples_VIEWERVIEWS #include "ViewerViews.h" #endif #ifndef TaligentSamples_SETGRAPHCONSTRUCTORCOMMAND #include "SetGraphConstructorCommand.h" #endif #ifndef TaligentSamples_STANDARDGRAPH #include #endif #ifndef TaligentSamples_STOCKDATA #include #endif #ifndef TaligentSamples_ATOMICMODEL #include #endif #ifndef Taligent_MENUCONTROLS #include #endif #ifndef Taligent_GUICOMPOUNDDOCUMENTCOMMAND #include #endif #ifndef Taligent_LABEL #include #endif TSubMenuItem* TViewerPresenter::fgViewMenu = NIL; TaligentTypeExtensionMacro(TViewerPresenter); TViewerPresenter::TViewerPresenter() : TGUIPresenter() { } TViewerPresenter::TViewerPresenter(const TViewerPresenter& source) : TGUIPresenter(source) { } TViewerPresenter::TViewerPresenter(const TGUIBundle& guiBundle) : TGUIPresenter(guiBundle) { } TViewerPresenter::~TViewerPresenter() { } TView* TViewerPresenter::HandleCreateMainView(TGUIBundle* guiBundle) const { TViewerContentView* mainView = new TViewerContentView(guiBundle); TGraphView* graphView = new TGraphView(CreateStandardGraph()); mainView->AdoptGraphView(graphView); return mainView; } void TViewerPresenter::HandleMenuActivate(TMenu& theMainMenu) { TGUIPresenter::HandleMenuActivate(theMainMenu); if (fgViewMenu == NIL) { fgViewMenu = CreateViewSubMenuItem(); } theMainMenu.AdoptLast(fgViewMenu); } void TViewerPresenter::HandleMenuDeactivate(TMenu& theMainMenu) { fgViewMenu->GetOwner()->Orphan(*fgViewMenu); TGUIPresenter::HandleMenuDeactivate(theMainMenu); } TSubMenuItem* TViewerPresenter::CreateViewSubMenuItem() const { TDeleterFor > allGraphConstructors = CreateCollectionOfGraphConstructors(); TDeleterFor > iterator = allGraphConstructors->CreateIterator(); TMenu* viewMenu = new TMenu; for (TStockGraphConstructor* graphConstructor = iterator->First(); graphConstructor != NIL; graphConstructor = iterator->Next()) { TSetGraphConstructorCommand* command = new TSetGraphConstructorCommand(graphConstructor); MMomentaryControlState* controlState = new TCommandControlStateOn( GetGUIBundle(), new TTextLabel(graphConstructor->GetDescription()), command); viewMenu->AdoptLast(new TMomentaryMenuItem(controlState)); } return new TSubMenuItem(viewMenu, new TTextLabel(TStandardText("View"))); } TStandardGraph* TViewerPresenter::CreateStandardGraph() const { return new TStandardGraph; } TCollectionOf* TViewerPresenter::CreateCollectionOfGraphConstructors() const { TSortedSequenceOf* list = new TSortedSequenceOf; list->Add(new TAllDaysPriceGraphConstructor("All Days/Price", "Day", "Price")); list->Add(new TWeeklySummaryPriceGraphConstructor("Weekly Summary/Price", "Week", "Price")); list->Add(new TMonthlySummaryPriceGraphConstructor("Monthly Summary/Price", "Month", "Price")); list->Add(new TAllDaysVolumeGraphConstructor("All Days/Volume", "Day", "Volume")); list->Add(new TWeeklySummaryVolumeGraphConstructor("Weekly Summary/Volume", "Week", "Volume")); list->Add(new TMonthlySummaryVolumeGraphConstructor("Monthly Summary/Volume", "Month", "Volume")); return list; } TViewerPresenter& TViewerPresenter::operator=(const TViewerPresenter& source) { ::Assertion(false, "Can't assign TViewerPresenters."); return *this; }