Module: _menusys      Library: Clipper 5.3


This module contains the following functions and procedures:



Note: Because this is raw decompiler output, the code is closer
to that seen in a .PPO file, rather than a .PRG file. In other
words, you must allow for the preprocessor conversions normally 
performed based on the contents of STD.CH and other .CH files
 
#include "common.ch"
#include "inkey.ch"

//-----------------------------------------------------------------
//  file-wide static variables
//
static Static1, Static2, Static3, Static4:= Nil, Static5:= 0

//---------------------------------------------------[top]-
//  EXECUTE
//
static function EXECUTE

   local Local1, Local2, Local3 := .T.
   Local1 := Static3:getitem(Static3:current())
   if ( ISNIL( Local1 ) )
   elseif ( !Local1:ispopup() )
      if ( Static3:classname() == "POPUPMENU" )
         Static3:close()
         eval(Local1:data(), Local1)
         Local3 := .F.
      elseif ( Static3:classname() == "TOPBARMENU" )
         eval(Local1:data(), Local1)
         Local3 := .F.
      endif
      popall()
      Local2 := Static3:current()
      Static3:select(0)
      Static3:display()
      Static3:select(Local2)
      if ( Local3 )
         Static3:close()
         eval(Local1:data(), Local1)
      endif
      Static3:select(0)
      return Local1:id()
   endif
   return 0

//---------------------------------------------------[top]-
//  HITTEST( Arg1, Arg2, Arg3 )
//
static function HITTEST( Arg1, Arg2, Arg3 )

   for Arg2 := Static2 to 1 step -1
      Arg1 := Static1[ Arg2 ]
      Arg3 := Arg1:hittest(mrow(), mcol())
      if ( Arg3 < 0 )
         return .F.
      elseif ( Arg3 > 0 )
         return .T.
      endif
   next
   return .F.

//---------------------------------------------------[top]-
//  ISSHORTCUT( Arg1, Arg2, Arg3 )
//
function ISSHORTCUT( Arg1, Arg2, Arg3 )

   local Local1, Local2, Local3, Local4, Local5
   if ( ( Local3 := Arg1:getshortct(Arg2) ) == 0 )
      Local2 := Arg1:itemcount()
      for Local1 := 1 to Local2
         if ( !Local4 := Arg1:getitem(Local1):ispopup() )
         elseif ( isshortcut(Local4:data(), Arg2, @Arg3) )
            return .T.
         endif
      next
   elseif ( !Local4 := Arg1:getitem(Local3):ispopup() )
      Arg1:select(Local3)
      eval(Local4:data(), Local4)
      Arg3 := Local4:id()
      return .T.
   endif
   return .F.

//---------------------------------------------------[top]-
//  MENUMODAL( Arg1, Arg2, Arg3, Arg4, Arg5, Arg6 )
//
function MENUMODAL( Arg1, Arg2, Arg3, Arg4, Arg5, Arg6 )

   local Local1, Local2, Local3, Local4, Local5, Local6, Local7, ;
      Local8, Local9, Local10, Local11, Local12, Local13, Local14, ;
      Local15 := 0, Local16:= Col(), Local17:= Row(), Local18, Local19
   Local4 := setcursor(0)
   if ( !( ISNUMBER( Arg3 ) ) )
      Local10 := .F.
   elseif ( !( ISNUMBER( Arg4 ) ) )
      Local10 := .F.
   elseif ( !( ISNUMBER( Arg5 ) ) )
      Local10 := .F.
   else
      Local10 := .T.
      Local11 := SaveScreen(Arg3, Arg4, Arg3, Arg5)
      Local12 := Arg5 - Arg4 + 1
   endif
   do while ( Arg2 == 0 )
      Local1 := InKey(0)
      if ( Local1 == 1002 )
         Arg2 := Arg1:hittest(mrow(), mcol())
      elseif ( ( Arg2 := Arg1:getaccel(Local1) ) != 0 )
      elseif ( isshortcut(Arg1, Local1, @Local15) )
         return Local15
      endif
   enddo
   if ( !Arg1:getitem(Arg2):enabled() )
      return 0
   endif
   Static3 := Arg1
   Static1 := array(16)
   Static2 := 1
   Static1[ 1 ] := Static3
   Local5 := mleftdown()
   Static3:select(Arg2)
   Static3:display()
   pushmenu(.T.)
   showmsg(Local10, Arg3, Arg4, Local12, Arg6, .T.)
   do while ( .T. )
      Local1 := InKey(0)
      if ( !( ISNIL( Local19 := SetKey(Local1) ) ) )
         eval(Local19, procname(1), procline(1), "")
         loop
      endif
      do case
      case Local1 == 1001
         if ( Local5 )
            if ( !hittest(@Local7, @Local9, @Local3) )
            elseif ( Static2 != Local9 )
               if ( Local3 == Local7:current() )
               elseif ( Local7:getitem(Local3):enabled() )
                  Static3 := Local7
                  popchild(Local9)
                  Static3:select(Local3)
                  Static3:display()
                  pushmenu()
                  showmsg(Local10, Arg3, Arg4, Local12, Arg6, .T.)
               endif
            elseif ( Local3 != Local7:current() )
               popchild(Static2)
               if ( Static3:getitem(Local3):enabled() )
                  Static3:select(Local3)
                  Static3:display()
                  pushmenu()
                  showmsg(Local10, Arg3, Arg4, Local12, Arg6, .T.)
               endif
            endif
         endif
      case Local1 == 24
         if ( Static2 > 1 )
            Local18 := Static3:getnext()
            if ( Local18 == 0 )
               Local18 := Static3:getfirst()
            endif
            Static3:select(Local18)
            Static3:display()
            showmsg(Local10, Arg3, Arg4, Local12, Arg6, .T.)
         endif
      case Local1 == 5
         if ( Static2 > 1 )
            Local18 := Static3:getprev()
            if ( Local18 == 0 )
               Local18 := Static3:getlast()
            endif
            Static3:select(Local18)
            Static3:display()
            showmsg(Local10, Arg3, Arg4, Local12, Arg6, .T.)
         endif
      case Local1 == 19
         if ( Static2 > 1 )
            popmenu()
         endif
         if ( Static2 == 1 )
            Local18 := Static3:getprev()
            if ( Local18 == 0 )
               Local18 := Static3:getlast()
            endif
            Static3:select(Local18)
            Static3:display()
            pushmenu(.T.)
         endif
         showmsg(Local10, Arg3, Arg4, Local12, Arg6, .T.)
      case Local1 == 4
         if ( !pushmenu(.T.) )
            popall()
            Local18 := Static3:getnext()
            if ( Local18 == 0 )
               Local18 := Static3:getfirst()
            endif
            Static3:select(Local18)
            Static3:display()
            pushmenu(.T.)
         endif
         showmsg(Local10, Arg3, Arg4, Local12, Arg6, .T.)
      case Local1 == 13
         if ( pushmenu(.T.) )
            showmsg(Local10, Arg3, Arg4, Local12, Arg6, .T.)
         else
            showmsg(Local10, Arg3, Arg4, Local12, Arg6, .F.)
            Local15 := execute()
            exit
         endif
      case Local1 == 27
         popmenu()
         Static3:display()
         showmsg(Local10, Arg3, Arg4, Local12, Arg6, .T.)
      case Local1 == 1002
         if ( !hittest(@Local7, @Local9, @Local3) )
         elseif ( Local9 == Static2 )
            Static3:select(Local3)
            Static3:display()
            if ( !pushmenu() )
               Static3:display()
            endif
            pushmenu()
            showmsg(Local10, Arg3, Arg4, Local12, Arg6, .T.)
         else
            Static2 := Local9
            Static3 := Static1[ Static2 ]
            Local14 := Static3:current()
            Local13 := Static3:getitem(Local14)
            if ( Local13 := ;
                  Static3:getitem(Static3:current()):ispopup() )
               Local13:data():close()
            endif
            if ( Local14 != Local3 )
               Local14 := Local3
               Static3:select(Local3)
               Static3:display()
               pushmenu()
            endif
            showmsg(Local10, Arg3, Arg4, Local12, Arg6, .T.)
         endif
         Local5 := .T.
      case Local1 == 1003
         Local5 := .F.
         if ( !hittest(@Local7, @Local9, @Local3) )
         elseif ( Local9 == Static2 )
            showmsg(Local10, Arg3, Arg4, Local12, Arg6, .F.)
            Local15 := execute()
            if ( Local15 != 0 )
               exit
            endif
         else
            Local3 := Static3:getfirst()
            if ( Local3 == 0 )
            else
               Static3:select(Local3)
               Static3:display()
               showmsg(Local10, Arg3, Arg4, Local12, Arg6, .T.)
            endif
         endif
      case ( Local3 := Static3:getaccel(Local1) ) != 0
         Static3:select(Local3)
         Static3:display()
         if ( !pushmenu(.T.) )
            showmsg(Local10, Arg3, Arg4, Local12, Arg6, .F.)
            Local15 := execute()
            exit
         endif
         showmsg(Local10, Arg3, Arg4, Local12, Arg6, .T.)
      case isshortcut(Arg1, Local1, @Local15)
         exit
      case ( Local3 := Arg1:getaccel(Local1) ) != 0
         popall()
         Static3:select(Local3)
         Static3:display()
         if ( Arg1:getitem(Local3):ispopup() )
            pushmenu(.T.)
         else
            showmsg(Local10, Arg3, Arg4, Local12, Arg6, .F.)
            Local15 := execute()
            exit
         endif
         showmsg(Local10, Arg3, Arg4, Local12, Arg6, .T.)
      endcase
   enddo
   if ( Local10 .AND. !_isgraphic() )
      RestScreen(Arg3, Arg4, Arg3, Arg5, Local11)
   endif
   popall()
   Static3:select(0)
   Arg1:display()
   SetPos(Local17, Local16)
   setcursor(Local4)
   return Local15

//---------------------------------------------------[top]-
//  POPALL
//
static function POPALL

   if ( Static2 > 1 )
      Static1[ 2 ]:close()
      Static2 := 1
      Static3 := Static1[ 1 ]
   endif
   return .T.

//---------------------------------------------------[top]-
//  POPCHILD( Arg1 )
//
static function POPCHILD( Arg1 )

   local Local1, Local2
   if ( ( Local1 := Static3:getitem(Local2), ( Local2:= ;
         Static3:current() ) != 0 .AND. Local1:ispopup() ) )
      Local1:data():close()
      Static2 := Arg1
      return .T.
   endif
   return .F.

//---------------------------------------------------[top]-
//  POPMENU
//
static function POPMENU

   if ( Static2 > 1 )
      Static3:close()
      Static3 := Static1[ --Static2 ]
      return .T.
   endif
   return .F.

//---------------------------------------------------[top]-
//  PUSHMENU( Arg1 )
//
static function PUSHMENU( Arg1 )

   local Local1 := Static3:getitem(Static3:current())
   if ( ISNIL( Local1 ) )
   elseif ( Local1:ispopup() )
      if ( !( ISLOGICAL( Arg1 ) ) )
         Arg1 := .F.
      endif
      Static3 := Local1:data()
      Static1[ ++Static2 ] := Static3
      if ( Arg1 )
         Static3:select(Static3:getfirst())
      else
         Static3:select(0)
      endif
      Static3:open()
      return .T.
   endif
   return .F.

//---------------------------------------------------[top]-
//  SHOWMSG( Arg1, Arg2, Arg3, Arg4, Arg5, Arg6 )
//
static function SHOWMSG( Arg1, Arg2, Arg3, Arg4, Arg5, Arg6 )

   local Local1, Local2, Local3, Local4, Local5, Local6 := Nil, ;
      Local7, Local8, Local9, Local10
   if ( Arg1 )
      if ( Local3 := ISCHARACTER( Arg5 ) )
         Local1 := SetColor(Arg5)
      endif
      if ( !_isgraphic() )
         SetPos(Arg2, Arg3)
         if ( ( Local2 := Static3:current() ) == 0 )
            DevOut(Space(Arg4))
         elseif ( Arg6 )
            DevOut(padc(Static3:getitem(Local2):message(), Arg4))
         else
            DevOut(Space(Arg4))
         endif
      else
         Local9 := msetcursor(.F.)
         Local4 := _getnumcol(Arg5)
         Local7 := At("/", Arg5)
         Local5 := _getnumcol(SubStr(Arg5, Local7 + 1, Len(Arg5) - ;
            Local7))
         Local2 := Static3:current()
         if ( Local2 == 0 )
            if ( ISNUMBER( Static4 ) )
               Local6 := Space(Len(Static4))
            else
               Local6 := Space(0)
            endif
         else
            Local6 := Static3:getitem(Local2):message()
         endif
         Local8 := Int(Arg4 / 2) - Int(Len(Local6) / 2) + 1
         Local10 := gmode()[ 5 ]
         if ( Static4 != Nil .AND. ( Static4 != Local6 .OR. ;
               Len(Local6) == 0 ) )
            gwriteat(Static5 * 8, Arg2 * Local10, Static4, Local5, -1)
            gframe(Arg3 * 8, Arg2 * Local10 - 1, ( Arg3 + Arg4 ) * ;
               8, ( Arg2 + 1 ) * Local10 + 1, Local5, 8, 15, 2, 2, ;
               2, 2, -4, .T.)
         endif
         if ( Static4 != Local6 .OR. Len(Local6) == 0 )
            gframe(Arg3 * 8, Arg2 * Local10 - 1, ( Arg3 + Arg4 ) * ;
               8, ( Arg2 + 1 ) * Local10 + 1, Local5, 8, 15, 2, 2, ;
               2, 2, -4, .T.)
            gwriteat(Local8 * 8, Arg2 * Local10, Local6, Local4, -1)
         endif
         Static4 := Local6
         Static5 := Local8
         msetcursor(Local9)
      endif
      if ( Local3 )
         set color to (Local1)
      endif
      return .T.
   endif
   return .F.

//---EOF


Use your Browser's BACK button to return to Function Listings