{***********************************************************************}
{									}
{ __DispMnu   Display a menu						}
{									}
{ function  __DispMnu(MenuPtr : _MenuPtr) : boolean;			}
{									}
{	      MenuPtr	Pointer to the menu descriptor returned by	}
{			__MakeMnu when the menu is constructed. 	}
{									}
{ Description This function displays the menu (window) specified by the }
{	      menu pointer using the __DispWin function.  The menu	}
{	      must have been constructed by __MakeMnu or __BuildMnu be- }
{	      fore __DispMnu is called.  If the menu cannot be dis-	}
{	      played the function returns FALSE, otherwise the function }
{	      returns returns TRUE.					}
{									}
{	      Note that the menu will be displayed in the window	}
{	      pointed to in the _MWinPtr field of the _Menu descriptor. }
{	      You may use __AttchMnu to change this pointer so that	}
{	      the same menu may be displayed in another window. 	}
{	      See the prelude to __DispWin for a description of how	}
{	      windows are displayed.					}
{									}
{	      On error _MenuError may be set to:  _InvalidWindow	}
{						  _InvalidMenu		}
{						  _InvalidItem		}
{									}
{ Version     4.00 (C)Copyright Blaise Computing Inc. 1987		}
{_______________________________________________________________________}

  function __DispMnu(MenuPtr : _MenuPtr) : boolean;

  var
    TempPtr  : _ItemPtr;
    BufPtr   : pointer;
    MaxRow   : word;
    MaxCol   : word;
    CursorOn : boolean;

  begin {__DispMnu}

    __DispMnu := FALSE;

    if (not ValidSig(MenuPtr,MENUSIG_)) then
      Exit;			       { Invalid menu pointer		}

    CursorOn := __IsCurScn;
    __COffScn(TRUE);

    with MenuPtr^ do
      begin
	if (__DispWin(_MWinPtr)) then  { Display the window		}
	   begin
	     MaxCol := MenuPtr^._MWinPtr^._Dim._XLower -
		       MenuPtr^._MWinPtr^._Dim._XUpper + 1;
	     MaxRow := MenuPtr^._MwinPtr^._Dim._YLower -
		       MenuPtr^._MwinPtr^._Dim._YUpper + 1;
	     TempPtr := _MItemsPtr;
	     while (TempPtr <> NIL) do
	       with TempPtr^ do
		 begin
		   if (not ValidSig(TempPtr,ITEMSIG_)) then
		       begin
			 __COffScn(not CursorOn);
			 Exit
		       end;

		   { Determine whether item fits in window		}

		   if ((_Row > MaxRow) or
		      ((_Col + _Len - 1) > MaxCol)) then
		      _Active := FALSE
		   else
		      _Active := TRUE;

		   if (_Active) then
		      begin
			BufPtr := Ptr(_VectorAddr(_ItemStrPtr)._Seg,
				      _VectorAddr(_ItemStrPtr)._Ofs + 1);
			if (_Protect) then
			   __FastWin(_Col,_Row,BufPtr,_Len,
					_ProtFore,_ProtBack,_USEATTR_SCN)
			else
			  begin
			    __FastWin(_Col,_Row,BufPtr,_Len,0,0,
							    _CHONLY_SCN);
			   if (_HiChPos > 0) then
			      __WrAttWin(_Col + _HiChPos - 1,_Row,
						  1,_HiChFore,_HiChBack)
			  end
		      end;
		   TempPtr := _NextItem
		 end;
	     __DispMnu := TRUE
	   end
	else			       { Cannot display the menu window }
	   SetMenuError(_InvalidWindow)
      end;

    __COffScn(not CursorOn)

  end;	{__DispMnu}
