The control state classes derive from TSimpleMomentaryControlStateOn, which, in GrafEdit, is a template that takes MCanvasSelection (the current selection) as a parameter. The control state classes used in the Mars program are the following:
TStandardCanvasFillColorState
TStandardCanvasFrameColorState
The control command classes derive from TCommandOn, which is a template that in GrafEdit takes MCanvasSelection (the current selection) as a parameter. The corresponding commands used in the Mars program are created as follows:
// Copyright (C) 1995 Taligent, Inc. All rights reserved. TMenu *colorsMenu = new TMenu (); colorsMenu->SetControlLayout(MControl::kTopToBottom);
Red frame
popup = new TMomentaryMenuItem (new TStandardCanvasFrameColorSelectionState(TRGBColor(1.,0.,0.), GetSharedBundleConnection()));
popup->AdoptLabel (new TTextLabel (*TDeleterFor<TStandardText>(CopyLocalizedText(theArchive, "Red Frame"))));
colorsMenu->AdoptLast (popup);
Green frame
popup = new TMomentaryMenuItem (new TStandardCanvasFrameColorSelectionState(TRGBColor(0.,1.,0.), GetSharedBundleConnection()));
popup->AdoptLabel (new TTextLabel (*TDeleterFor<TStandardText>(CopyLocalizedText(theArchive, "Green Frame"))));
colorsMenu->AdoptLast (popup);
Blue frame with separator line below
popup = new TMomentaryMenuItem (new TStandardCanvasFrameColorSelectionState(TRGBColor(0.,0.,1.), GetSharedBundleConnection()));
popup->AdoptLabel (new TTextLabel (*TDeleterFor<TStandardText>(CopyLocalizedText(theArchive, "Blue Frame"))));
popup->SetSeparator (MMenuItem::kAfter);
colorsMenu->AdoptLast (popup);
Red fill
popup = new TMomentaryMenuItem (new TStandardCanvasFillColorSelectionState(TRGBColor(1.,0.,0.), GetSharedBundleConnection()));
popup->AdoptLabel (new TTextLabel (*TDeleterFor<TStandardText>(CopyLocalizedText(theArchive, "Red Fill"))));
colorsMenu->AdoptLast (popup);
Green fill
popup = new TMomentaryMenuItem (new TStandardCanvasFillColorSelectionState(TRGBColor(0.,1.,0.), GetSharedBundleConnection()));
popup->AdoptLabel (new TTextLabel (*TDeleterFor<TStandardText>(CopyLocalizedText(theArchive, "Green Fill"))));
colorsMenu->AdoptLast (popup);
Blue fill
popup = new TMomentaryMenuItem (new TStandardCanvasFillColorSelectionState(TRGBColor(0.,0.,1.), GetSharedBundleConnection()));
popup->AdoptLabel (new TTextLabel (*TDeleterFor<TStandardText>(CopyLocalizedText(theArchive, "Blue Fill"))));
colorsMenu->AdoptLast (popup);
Labelling the menu
TMarsPresenter::gColorSubMenuItem = new TSubMenuItem (colorsMenu,
new TTextLabel(*TDeleterFor<TStandardText>(CopyLocalizedText(theArchive, "Color"))));
Pen menu
The Pen menu appears to the right of the Tool menu. The following code creates the Pen menu and specifies kTopBottom which means the items will be listed from top to bottom on the menu. Each menu item is added with AdoptLast to put it after the last item on the menu.
The menu is created by specifying the menu item text, and the standard line width control state. The Document framework supplies the appropriate command and interactor. // Copyright (C) 1995 Taligent, Inc. All rights reserved.
if (!TMarsPresenter::gPenSubMenuItem) {
// Lines menu
TMenu *linesMenu = new TMenu ();
linesMenu->SetControlLayout(MControl::kTopToBottom);
1world-coordinate unit
popup = new TMomentaryMenuItem (new TStandardCanvasLineWidthSelectionState(1., GetSharedBundleConnection()));
popup->AdoptLabel (new TTextLabel (*TDeleterFor<TStandardText>(CopyLocalizedText(theArchive, "1 point"))));
linesMenu->AdoptLast (popup);
2 world-coordinate units
popup = new TMomentaryMenuItem (new TStandardCanvasLineWidthSelectionState(2., GetSharedBundleConnection()));
popup->AdoptLabel (new TTextLabel (*TDeleterFor<TStandardText>(CopyLocalizedText(theArchive, "2 point"))));
linesMenu->AdoptLast (popup);
4 world-coordinate units
popup = new TMomentaryMenuItem (new TStandardCanvasLineWidthSelectionState(4., GetSharedBundleConnection()));
popup->AdoptLabel (new TTextLabel (*TDeleterFor<TStandardText>(CopyLocalizedText(theArchive, "4 point"))));
linesMenu->AdoptLast (popup);
6 world-coordinate units
popup = new TMomentaryMenuItem (new TStandardCanvasLineWidthSelectionState(6., GetSharedBundleConnection()));
popup->AdoptLabel (new TTextLabel (*TDeleterFor<TStandardText>(CopyLocalizedText(theArchive, "6 point"))));
linesMenu->AdoptLast (popup);
8 world-coordinate units
popup = new TMomentaryMenuItem (new TStandardCanvasLineWidthSelectionState(8., GetSharedBundleConnection()));
popup->AdoptLabel (new TTextLabel (*TDeleterFor<TStandardText>(CopyLocalizedText(theArchive, "8 point"))));
linesMenu->AdoptLast (popup);
10 world-coordinate units
popup = new TMomentaryMenuItem (new TStandardCanvasLineWidthSelectionState(10., GetSharedBundleConnection()));
popup->AdoptLabel (new TTextLabel (*TDeleterFor<TStandardText>(CopyLocalizedText(theArchive, "10 point"))));
linesMenu->AdoptLast (popup);
Labelling the menu
TMarsPresenter::gPenSubMenuItem = new TSubMenuItem (linesMenu,
new TTextLabel(*TDeleterFor<TStandardText>(CopyLocalizedText(theArchive, "Pen"))));
[Contents]
[Previous]
[Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Generated with WebMaker