// Copyright (C) 1995 Taligent, Inc. All rights reserved.
TSubMenuItem *TDeimosPresenter::gToolSubMenuItem = NIL;
VersionDefinitionsMacro (TDeimosPresenter, kOriginalVersion);
DynamicCastDefinitionsMacroOne (TDeimosPresenter,TGUIPresenter);
TDeimosPresenter::TDeimosPresenter (const TGUIBundle& bundle)
: TGUIPresenter(bundle)
{
}
TDeimosPresenter::~TDeimosPresenter()
{
}
TView* TDeimosPresenter::HandleCreateMainView (TGUIBundle* theBundleToAlias) const
{
// Create and return a TStandardCanvasView on top of a TScrollingView
TCanvasView *contentView = new TStandardCanvasView (theBundleToAlias);
contentView->SetAllocatedArea (TGArea(TGRect(0.,0.,500.,400.)));
// 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 TDeimosPresenter::HandleMenuActivate (TMenu& theMainMenu)
{
TGUIPresenter::HandleMenuActivate(theMainMenu);
TMomentaryMenuItem* popup;
if (!TDeimosPresenter::gToolSubMenuItem) {
// Tools menu
TMenu *toolsMenu = new TMenu ();
toolsMenu->SetControlLayout(MControl::kTopToBottom);
popup = new TMomentaryMenuItem (new TCursorToolSelectionState(new TStandardArrowTool()));
popup->AdoptLabel (new TTextLabel (TStandardText("Arrow")));
popup->SetSeparator (MMenuItem::kAfter);
toolsMenu->AdoptLast (popup);
popup = new TMomentaryMenuItem (new TCursorToolSelectionState(new TCanvasCurveCreationTool()));
popup->AdoptLabel (new TTextLabel (TStandardText("Curve")));
toolsMenu->AdoptLast (popup);
TDeimosPresenter::gToolSubMenuItem = new TSubMenuItem (toolsMenu,
new TTextLabel(TStandardText("Tools")));
}
theMainMenu.AdoptLast (TDeimosPresenter::gToolSubMenuItem);
}
void TDeimosPresenter::HandleMenuDeactivate(TMenu& theMainMenu)
{
TDeimosPresenter::gToolSubMenuItem->GetOwner()->Orphan(*TDeimosPresenter::gToolSubMenuItem);
TGUIPresenter::HandleMenuDeactivate(theMainMenu);
}