home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 16 / CD_ASCQ_16_0994.iso / news / 4611 / fw16d.ins / IDE / SOURCE / OBJECT.PRG < prev    next >
Text File  |  1994-06-04  |  6KB  |  201 lines

  1. // FiveWin IDE - Object Inspector MDIChild Window
  2.  
  3. #include "FiveWin.ch"
  4.  
  5. static aObjBmps
  6.  
  7. //----------------------------------------------------------------------------//
  8.  
  9. function ObjInspect( oObject, cTitle )
  10.  
  11.    local oWndObj, oIco, oBar, oBrw
  12.    local aObjInfo
  13.    local nItem := 1
  14.  
  15.    DEFAULT aObjBmps := GetObjBmps()
  16.  
  17.    if ValType( oObject ) == "O"
  18.       aObjInfo = aOData( oObject )
  19.       // Let's give the Data Names the 'hungarian notation' look
  20.       AEval( aObjInfo, { | cData, n | aObjInfo[ n ] := cChr2Data( cData ) } )
  21.    endif
  22.  
  23.    DEFAULT cTitle := If( ValType( oObject ) == "O",;
  24.                          "Object Inspector",;
  25.                          "Array Inspector" )
  26.  
  27.    DEFINE ICON oIco RESOURCE "Objects"
  28.  
  29.    DEFINE WINDOW oWndObj FROM 1, 1 TO 23, 33 ;
  30.       TITLE If( ValType( oObject ) == "O", "Object Inspector: ",;
  31.                 "Array Inspector: " ) + cTitle ;
  32.       MDICHILD OF GetWndMain() ;
  33.       ICON oIco
  34.  
  35.    DEFINE BUTTONBAR oBar OF oWndObj
  36.  
  37.    DEFINE BUTTON OF oBar RESOURCE "Inspect" ;
  38.       MESSAGE "Review this contained Object" ;
  39.       ACTION DataInspect( oObject, nItem, aObjInfo, cTitle )
  40.  
  41.    DEFINE BUTTON GROUP OF oBar RESOURCE "ClassName" ;
  42.       MESSAGE "Review ClassName Object" ;
  43.       ACTION MsgInfo( "ClassName: " + oObject:ClassName() )
  44.  
  45.    DEFINE BUTTON OF oBar RESOURCE "Hierarchy" ;
  46.       MESSAGE "Review this Class Hierarchy" ;
  47.       ACTION  MsgInfo( cGetHierarchy( oObject ) )
  48.  
  49.    @ 0, 0 LISTBOX oBrw FIELDS "" ;
  50.       HEADERS "  ", "Data", "Value" ;
  51.       FIELDSIZES 16, 90, 300 ;
  52.       OF oWndObj ;
  53.       SIZE 400, 400 ;
  54.       ON DBLCLICK DataInspect( oObject, nItem, aObjInfo, cTitle )
  55.  
  56.    oBrw:bLine = { || aGetData( oObject, nItem, aObjInfo, cTitle ) }
  57.  
  58.    // Browsing an Array using FiveWin a TWBrowse Object !
  59.  
  60.    oBrw:bGoTop    = { || nItem := 1 }
  61.    oBrw:bGoBottom = { || nItem := Eval( oBrw:bLogicLen ) }
  62.  
  63.    oBrw:bSkip     = { | nWant, nOld | nOld := nItem, nItem += nWant,;
  64.                         nItem := Max( 1, Min( nItem, Eval( oBrw:bLogicLen ) ) ),;
  65.                         nItem - nOld }
  66.  
  67.    oBrw:bLogicLen = { || If( ValType( oObject ) == "O", Len( aObjInfo ),;
  68.                              Len( oObject ) ) }
  69.    oBrw:cAlias    = "Array"  // We need a non empty cAlias !
  70.  
  71.    oWndObj:SetControl( oBrw )
  72.  
  73.    ACTIVATE WINDOW oWndObj
  74.  
  75. return nil
  76.  
  77. //----------------------------------------------------------------------------//
  78.  
  79. static function cGetData( uData, cType )
  80.  
  81.    local cResult := ""
  82.  
  83.    do case
  84.       case cType == "B"
  85.            cResult = "{ || ... }"
  86.  
  87.       case cType == "A"
  88.            cResult = "[ ... ]"
  89.  
  90.       case cType == "O"
  91.            cResult = "Object"
  92.  
  93.       case cType == "U"
  94.            cResult = "Undefined"
  95.  
  96.       otherwise
  97.            cResult = cValToChar( uData )
  98.    endcase
  99.  
  100. return cResult
  101.  
  102. //----------------------------------------------------------------------------//
  103.  
  104. static function DataInspect( oObject, nItem, aObjInfo, cTitle )
  105.  
  106.    local cType := ValType( oObject )
  107.    local cData, uData
  108.  
  109.    do case
  110.       case cType == "A"
  111.            cData = "[ " + AllTrim( Str( nItem ) ) + " ]"
  112.            if Len( oObject[ nItem ] ) > 0
  113.               ObjInspect( oObject[ nItem ], cTitle + cData )
  114.            else
  115.               MsgInfo( "Array is empty!" )
  116.            endif
  117.  
  118.       case cType == "O"
  119.            cData = aObjInfo[ nItem ]
  120.            uData = OSend( oObject, cData )
  121.            if ValType( uData ) $ "AO"
  122.               ObjInspect( OSend( oObject, cData ), cTitle + ":" + cData )
  123.            else
  124.               MsgInfo( "I don't find an Object or an Array there!" )
  125.            endif
  126.    endcase
  127.  
  128. return nil
  129.  
  130. //----------------------------------------------------------------------------//
  131.  
  132. static function aGetData( oObject, nItem, aObjInfo )
  133.  
  134.    local uData, cData, cType
  135.  
  136.    do case
  137.       case ValType( oObject ) == "A"
  138.            uData = oObject[ nItem ]
  139.            cData = "[ " + AllTrim( Str( nItem ) ) + " ]"
  140.  
  141.       case ValType( oObject ) == "O"
  142.            uData = OSend( oObject, aObjInfo[ nItem ] )
  143.            cData = aObjInfo[ nItem ]
  144.    endcase
  145.  
  146.    cType = ValType( uData )
  147.  
  148. return { aObjBmps[ At( cType, "ABCDLNMOU" ) ], cData, cGetData( uData, cType ) }
  149.  
  150. //----------------------------------------------------------------------------//
  151.  
  152. static function cGetHierarchy( oObject )
  153.  
  154.    local nClass   := oObject:ClassH
  155.    local cClasses := "Class Hierarchy:" + CRLF
  156.    local n := 1
  157.  
  158.    while n < nClass
  159.       if oObject:ChildLevel( __ClassIns( n ) ) != 0
  160.          cClasses += __ClassNam( n ) + CRLF
  161.       endif
  162.       n++
  163.    end
  164.  
  165.    cClasses += oObject:ClassName()
  166.  
  167. return cClasses
  168.  
  169. //----------------------------------------------------------------------------//
  170.  
  171. function ThisInspect( oObject )
  172.  
  173.    local oMenu
  174.  
  175.    oObject:CoorsUpdate()
  176.  
  177.    MENU oMenu POPUP
  178.       MENUITEM "&Color..." ;
  179.          MESSAGE "Select a new color" ACTION oObject:SelColor()
  180.  
  181.       MENUITEM "&Font..." ;
  182.          MESSAGE "Select a new font" ACTION oObject:SelFont()
  183.  
  184.       MENUITEM "&Caption..." ;
  185.          MESSAGE "Edit the current Object text"
  186.  
  187.       SEPARATOR
  188.  
  189.       MENUITEM "&Object Inspector..." ;
  190.          MESSAGE "Review the Object data..." ACTION ObjInspect( oObject )
  191.  
  192.       MENUITEM "&Stack Inspector..." ;
  193.          MESSAGE "Review the application Stack..." ACTION StackInspect()
  194.    ENDMENU
  195.  
  196.    ACTIVATE POPUP oMenu AT oObject:nBottom, oObject:nLeft OF oObject
  197.  
  198. return nil
  199.  
  200. //----------------------------------------------------------------------------//
  201.