// $Revision: 1.2 $ // Copyright (C) 1995 Taligent, Inc. All rights reserved. #ifndef Taligent_CURSORTOOLSELECTIONSTATE #include #endif #ifndef Taligent_STANDARDARROWTOOL #include #endif #ifndef Taligent_CANVASLINE #include #endif #ifndef Taligent_CANVASPOLYLINE #include #endif #ifndef Taligent_CANVASPOLYGON #include #endif #ifndef Taligent_CANVASCURVE #include #endif #ifndef Taligent_CANVASTEXT #include #endif #ifndef Taligent_BASICCANVASGRAPHIC #include #endif #ifndef Taligent_GRAPHICS #include #endif #ifndef Taligent_BUNDLES #include #endif #ifndef Taligent_GRAFATTRIBUTE #include #endif #ifndef Taligent_RGBCOLOR #include #endif #ifndef Taligent_VIEWROOT #include #endif #ifndef Taligent_REQUESTPROCESSOR #include #endif #ifndef Taligent_VIEWEVENTRECEIVER #include #endif #ifndef Taligent_MENUCONTROLS #include #endif #ifndef Taligent_TRANSFORMS #include #endif #ifndef Taligent_LABEL #include #endif #ifndef Taligent_GRAFPENS #include #endif #ifndef Taligent_MARSTESTPRESENTER #include "MarsTestPresenter.h" #endif #ifndef Taligent_STANDARDGRAFEDIT #include #endif #ifndef Taligent_SCROLLINGVIEW #include #endif #ifndef Taligent_CANVASTEXT #include #endif #ifndef Taligent_TEXTMENUS #include #endif #include "TestClasses.h" TTestOtherClassesState::TTestOtherClassesState(TGUIBundle * theBundle, TMarsTestPresenter *thePresenter) : fGUIBundle(theBundle), fPresenter(thePresenter) { } TGUIBundle* TTestOtherClassesState::GetGUIBundle() const { return fGUIBundle; } void TTestOtherClassesState::Select() { TGUIBundle *theGUIBundle = GetGUIBundle(); //qprintf("TTestOtherClassesState::Select\n"); TView *theView = fPresenter->GetView(); if (theView) { TStandardCanvasView *aCanvasView = (TStandardCanvasView *) theView; //qprintf("TStandardView != NIL\n"); TTestGrafEditClass aTestClass(fPresenter, fGUIBundle, aCanvasView); aTestClass.Test(); } else { qprintf("TStandardView == NIL\n"); } } TSubMenuItem *TMarsTestPresenter::gTestSubMenuItem = NIL; VersionDefinitionsMacro (TMarsTestPresenter, kOriginalVersion); DynamicCastDefinitionsMacroOne (TMarsTestPresenter,TGUIPresenter); const TMenuDomainID TMarsTestPresenter::kMarsAPITestDomainID = TMenuDomainID("TMarsTestPresenter"); const TMenuItemID TMarsTestPresenter::kTestAllClassesMenu = 1; TMarsTestPresenter::TMarsTestPresenter (const TGUIBundle& bundle) : TMarsPresenter(bundle), fCanvasViewHandle(NIL) { // qprintf("TMarsTestPresenter::TMarsTestPresenter\n"); } TMarsTestPresenter::~TMarsTestPresenter() { // qprintf("TMarsTestPresenter::~TMarsTestPresenter\n"); delete fCanvasViewHandle; } TView* TMarsTestPresenter::HandleCreateMainView (TGUIBundle* theBundleToAlias) const { // qprintf("TMarsTestPresenter::HandleCreateMainView\n"); // Create and return a TStandardCanvasView on top of a TScrollingView TCanvasView *contentView = new TStandardCanvasView (theBundleToAlias); contentView->SetAllocatedArea (TGArea(TGRect(0.,0.,500.,400.))); ::NonConst((TMarsTestPresenter*)this)->SetCanvasView(contentView); TCanvasView *nonConstContentView = NonConst(contentView); NonConst(this)->fCanvasViewHandle = new TViewHandle(*nonConstContentView); // put everything into a scrolling view TScrollingView* scrollingView = new TScrollingView(TScrollingView::kBothScrollbars); scrollingView->AdoptViewToScroll(contentView); scrollingView->SetAllocatedArea (TGArea(TGRect(0.,0.,350.,300.))); return scrollingView; } void TMarsTestPresenter::HandleMenuActivate (TMenu& theMainMenu) { // qprintf("TMarsTestPresenter::HandleMenuActivate \n"); TMarsPresenter::HandleMenuActivate(theMainMenu); TDeleterFor theArchive = TArchive::CopyArchiveForSharedLibrary(); if (!TMarsTestPresenter::gTestSubMenuItem) { // Test menu TMenu* aMenu = new TMenu; aMenu->SetControlLayout(MControl::kTopToBottom); aMenu->SetItemLayout(MControl::kTopToBottom); TMomentaryMenuItem *testMenu = new TMomentaryMenuItem (); testMenu->SetControlLayout(MControl::kTopToBottom); { TDeleterFor theText = CopyLocalizedText(theArchive, "Test Classes"); testMenu->AdoptLabel(new TTextLabel(theText)); testMenu->AdoptState(new TTestOtherClassesState(GetGUIBundle(), this) ); } aMenu->AdoptLast(testMenu); TSubMenuItem* theSubMenuItem = new TSubMenuItem( aMenu, new TTextLabel(CopyLocalizedText(theArchive, "Test"))); gTestSubMenuItem = theSubMenuItem; } theMainMenu.AdoptLast (TMarsTestPresenter::gTestSubMenuItem); } void TMarsTestPresenter::HandleMenuDeactivate(TMenu& theMainMenu) { // qprintf("TMarsTestPresenter::HandleMenuDeactivate\n"); TMarsTestPresenter::gTestSubMenuItem->GetOwner()->Orphan(*TMarsTestPresenter::gTestSubMenuItem); TMarsPresenter::HandleMenuDeactivate(theMainMenu); } TStandardText* TMarsTestPresenter::CopyLocalizedText(TArchive* theArchive, const TStandardText& theKey ) const { // qprintf("TMarsTestPresenter::CopyLocalizedText\n"); TStandardText *returnText; try { TArchiveEnvelope theEnvelope(theArchive, GetLocale()); returnText = theEnvelope.CopyObject( theKey ); } catch ( ... ) { returnText = new TStandardText(theKey); } return returnText; } TView* TMarsTestPresenter::GetView() { TView *theView = NIL; if (fCanvasViewHandle) theView = fCanvasViewHandle->GetView(); return theView; } // The Mars stationery static TGUIModelPresenterStationeryFor stationery;