Class: TMenuWindow

Declaration: MenuWindow.h

Taxonomy Categories:

Member Functions:


Interface Category:

API.

Inherits From:

TWindow

Inherited By:

None.

Purpose:

TMenuWindow is the window that is used to present a desktop menu. It provides special functions for hiding all torn off submenus and for disabling the command keys for all the submenus when the window is disabled or hidden, and for re-showing the torn off menus and re-enabling the command keys when the window is shown and enabled.

Instantiation:

Allocate on the heap or the stack.

Deriving Classes:

Derive classes from TMenuWindow if you want to add functionality. For example, the provided derived class TActionMenuWindow adds the MActionTarget mixin so that it can redirect actions that have moved up the menu hierarchy to some other target.

Concurrency:

Not multithread safe.

Resource Use:

No special requirements.

Other Considerations:

None.

Member Function: TMenuWindow::TMenuWindow

  1. TMenuWindow ()
  2. TMenuWindow (TMenu * adoptedMenu, const TText & title, bool hasCloseBox =false)
  3. TMenuWindow (TMenu * adoptedMenu, TLabel * adoptedTitle, bool hasCloseBox =false)
  4. TMenuWindow (const TMenuWindow &)

Interface Category:

API.

Purpose:

  1. Default constructor.
  2. Creates a menu window that adopts the specified menu and has the specified title.
  3. Creates a menu window that adopts the specified menu and label.
  4. Copy constructor.

Calling Context:

  1. Called by the stream-in operators.
  2. Called to create a menu window that adopts the specified menu and has the specified title.
  3. Called to create a menu window that adopts the specified menu and label.
  4. Called to copy an object.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TMenuWindow::~TMenuWindow

virtual ~ TMenuWindow ()

Interface Category:

API.

Purpose:

Destructor.

Calling Context:

Called to destroy an object.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TMenuWindow::operator=

TMenuWindow & operator =(const TMenuWindow &)

Interface Category:

API.

Purpose:

Assignment operator.

Calling Context:

Called when an object is assigned to another compatible object.

Parameters:

Return Value:

A non-const reference to the left-hand side object.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TMenuWindow::operator>>=

virtual TStream & operator >>=(TStream & towhere) const

Interface Category:

API.

Purpose:

Stream-out operator.

Calling Context:

Called to stream out data.

Parameters:

Return Value:

Returns a reference to the stream the object streams itself out to.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TMenuWindow::operator<<=

virtual TStream & operator <<= (TStream & fromwhere)

Interface Category:

API.

Purpose:

Stream-in operator.

Calling Context:

Called to stream in data.

Parameters:

Return Value:

Returns a reference to the stream the object streams itself in from.

Exceptions:

Throws TInvalidVersionError if the object has detected an unsupportable version during the stream-in process.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TMenuWindow::AdoptMenu

  1. virtual TMenu * AdoptMenu (TMenu * menu, const TText & title)
  2. virtual TMenu * AdoptMenu (TMenu * menu, TLabel * title)
  3. virtual TMenu * AdoptMenu (TMenu * menu)

Interface Category:

API.

Purpose:

  1. Installs the specified menu into the window, and returns the old menu, if any. Gives the menu the specified title. If the given menu already contains a title bar, the title bar label will be replaced with one containing the given text.
  2. Installs the specified menu into the window, and returns the old menu, if any. Gives the menu the specified label. If the given menu already contains a title bar, the title bar label will be replaced with the specified label.
  3. Installs the specified menu into the window, and returns the old menu, if any.

Calling Context:

  1. Called to install the specified menu and give it the specified title.
  2. Called to install the specified menu and give it the specified label.
  3. Called to install the specified menu. It you want to create your own title item, or re-adopt a previously orphaned menu, use this function.

Parameters:

Return Value:

A pointer to the old menu, if any.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TMenuWindow::GetMenu

virtual TMenu * GetMenu () const

Interface Category:

API.

Purpose:

Returns a pointer to the menu installed in this window. This menu is basically the same as the menu passed in to be adopted in either the constructor, or a call to AdoptMenu, except that those functions modify the menu to contain a new item at the beginning: a menu title bar. If you make changes to the menu returned from GetMenu, be sure to call SetWindowSize with the menu's new preferred size.

Calling Context:

Call this function directly.

Parameters:

Return Value:

A pointer to the menu installed in this window.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TMenuWindow::OrphanMenu

virtual TMenu * OrphanMenu ()

Interface Category:

API.

Purpose:

Orphans and returns a pointer to the menu installed in this window. This menu is basically the same as the menu passed in to be adopted in either the constructor, or a call to AdoptMenu, except that those functions modify the menu to contain a new item at the beginning: a menu title bar.

Calling Context:

Call this function directly.

Parameters:

Return Value:

A pointer to the orphaned menu.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TMenuWindow::SetColor

virtual void SetColor (const TColor & color)

Interface Category:

API.

Purpose:

Assigns the specified color to the menu bar.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TMenuWindow::GetColor

void GetColor (TColor & color) const

Interface Category:

API.

Purpose:

Returns the current menu bar color.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TMenuWindow::SetTitle

virtual void SetTitle (TText & title)

Interface Category:

API.

Purpose:

Gives the menu the specified title. Replaces the previous title, if any.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TMenuWindow::AdoptTitle

virtual void AdoptTitle (TLabel * title)

Interface Category:

API.

Purpose:

Adopts the specified title label, installing it in the menu bar. Replaces the old label, if any.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TMenuWindow::CopyTitle

virtual TLabel * CopyTitle () const

Interface Category:

API.

Purpose:

Returns a copy of the menu title label.

Calling Context:

Call this function directly.

Parameters:

Return Value:

A pointer to a copy of the menu title label.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TMenuWindow::SetWindowSize

virtual void SetWindowSize (const TGPoint &)

Interface Category:

API.

Purpose:

Sets the size of the window, and of the menu installed in it.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

Overrides inherited TWindow function.

Member Function: TMenuWindow::SetHasCloseBox

virtual void SetHasCloseBox (bool hasCloseBox)

Interface Category:

API.

Purpose:

Specifies whether or not the menu window has a close box, according to the specified input parameter.

Calling Context:

Clients can call to modify the indication as to whether or not the menu window has a close box, after the window has already been constructed.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TMenuWindow::HasCloseBox

virtual bool HasCloseBox () const

Interface Category:

API.

Purpose:

Determines if the window has a close box or not.

Calling Context:

Derived classes can call this function directly.

Parameters:

Return Value:

Returns true if the window has a close box, false otherwise.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TMenuWindow::NeedsClipping

virtual bool NeedsClipping ()

Interface Category:

API.

Purpose:

Tells whether or not the menu window needs to be clipped when drawing this view.

Calling Context:

Called by the View system to determine whether or not to clip when drawing this view.

Parameters:

Return Value:

Returns true if the menu window needs to be clipped, false otherwise.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

Overrides inherited TView function.

Member Function: TMenuWindow::DrawContents

virtual void DrawContents (TGrafPort & port) const

Interface Category:

API.

Purpose:

Draws a background fill for the menu.

Calling Context:

Called by the View system to draw the contents of this view.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

This protected function overrides the inherited TView function.

Member Function: TMenuWindow::HandleShow

virtual void HandleShow ()

Interface Category:

API.

Purpose:

Makes the menu window visible, and activates the menu.

Calling Context:

Called by TWindow::Show.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

This protected function overrides the inherited TWindow function.

Member Function: TMenuWindow::HandleHide

virtual void HandleHide ()

Interface Category:

API.

Purpose:

Makes the menu window invisible and deactivates the menu.

Calling Context:

Called by the TWindow Hide function.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

This protected function overrides the inherited TWindow function.

Member Function: TMenuWindow::HandleEnable

virtual void HandleEnable ()

Interface Category:

API.

Purpose:

Enables the menu window.

Calling Context:

Called by TWindow::Enable.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

This protected function overrides the inherited TWindow function.

Member Function: TMenuWindow::HandleDisable

virtual void HandleDisable ()

Interface Category:

API.

Purpose:

Disables the menu window.

Calling Context:

Called by TWindow::Disable.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

This protected function overrides the inherited TWindow function.

Member Function: TMenuWindow::HandleAllocatedAreaChanged

virtual void HandleAllocatedAreaChanged (const TGArea & newArea)

Interface Category:

API.

Purpose:

Handles a change to the allocated area for the menu, keeping the window bounds in sync with the menu bounds.

Calling Context:

Called when there is a change to the allocated area of the menu.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

This protected function overrides the inherited TView function.

Member Function: TMenuWindow::SetChildAllocatedArea

virtual void SetChildAllocatedArea (TView &, const TGArea &)

Interface Category:

API.

Purpose:

Sets the area that's allocated to the child menu to the specified area, to keep the menu bounds in sync with the window bounds. The area is in menu-relative coordinates.

Calling Context:

Called by the View system.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

This protected function overrides the inherited TWindow function.

Member Function: TMenuWindow::SetChildAllocatedAreaAndLocation

virtual void SetChildAllocatedAreaAndLocation (TView &, const TGArea &, const TGPoint &)

Interface Category:

API.

Purpose:

Sets the area that's allocated to the child menu to the specified area, to keep the menu bounds in sync with the window bounds. The area is in the menu's parent's (the window's) coordinate system. Also sets the menu's location.

Calling Context:

Called to keep the menu bounds in sync with the window bounds.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

This protected function overrides the inherited TWindow function.

Member Function: TMenuWindow::TransformBy

virtual void TransformBy (const TGrafMatrix &)

Interface Category:

API.

Purpose:

TView override that does nothing, as it doesn't make sense to transform a menu window.

Calling Context:

Called from MGraphic internally.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

This protected function overrides the inherited TView function.
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.