diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 6befca2472..7c61a18ee9 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -7,6 +7,14 @@ For example: 2002-12-01 23:12 UTC+0100 Foo Bar */ +2002-10-01 22:10 GMT-3 Luiz Rafael Culik +2002-01-14 10:40 UTC-0500 Paul Tucker + * source\common\hbffind.c + * source\rtl\direct.c + * modified for correct operation under NT + * including addition of extended file attributes + +2002-01-12 19:00 UTC+0500 Phil Barnett * tagged cvs with build38 and lifted cvs freeze 2002-01-12 14:20 UTC+0300 Alexander Kresin diff --git a/harbour/source/common/hbffind.c b/harbour/source/common/hbffind.c index d9fa335756..a9ab4597cd 100644 --- a/harbour/source/common/hbffind.c +++ b/harbour/source/common/hbffind.c @@ -118,6 +118,9 @@ HB_FILE_VER( "$Id$" ) { DIR * dir; struct dirent * entry; + char pfname[ _POSIX_PATH_MAX + 1 ]; + char pfext[ _POSIX_PATH_MAX + 1 ]; + } HB_FFIND_INFO, * PHB_FFIND_INFO; #else @@ -514,7 +517,7 @@ PHB_FFIND hb_fsFindFirst( const char * pszFileName, USHORT uiAttr ) /* Make sure we have this cleared */ ffind->info = NULL; - + /* Do platform dependant first search */ #if defined(HB_OS_DOS) @@ -590,21 +593,89 @@ PHB_FFIND hb_fsFindFirst( const char * pszFileName, USHORT uiAttr ) { PHB_FFIND_INFO info; + char string[ _POSIX_PATH_MAX + 1 ]; + char pattern[ _POSIX_PATH_MAX + 1 ]; + char dirname[ _POSIX_PATH_MAX + 1 ]; + char fname[ _POSIX_PATH_MAX + 1 ]; + char fext[ _POSIX_PATH_MAX + 1 ]; + + char * pos; ffind->info = ( void * ) hb_xgrab( sizeof( HB_FFIND_INFO ) ); info = ( PHB_FFIND_INFO ) ffind->info; + dirname[ 0 ] = '\0'; + pattern[ 0 ] = '\0'; + if( pszFileName ) + { + strcpy( string, pszFileName ); + pos = strrchr( string, OS_PATH_DELIMITER ); + if( pos ) + { + strcpy( pattern, pos + 1 ); + *( pos + 1 ) = '\0'; + strcpy( dirname, string ); + } + else + { + strcpy( pattern, string ); + strcpy( dirname, ".X" ); + dirname[ 1 ] = OS_PATH_DELIMITER; + } + } + if( !*pattern ) + strcpy( pattern, "*.*" ); + + if( strlen( pattern ) > 0 ) + { + strcpy( string, pattern ); + pos = strrchr( string, '.' ); + if( pos ) + { + strcpy( info->pfext, pos + 1 ); + *pos = '\0'; + strcpy( info->pfname, string ); + } + else + { + strcpy( info->pfname, string ); + info->pfext[ 0 ] = '\0'; + } + } + + if( strlen( info->pfname ) < 1 ) + strcpy( info->pfname, "*" ); tzset(); - info->dir = opendir( pszFileName ); + info->dir = opendir( dirname ); - if( info->dir ) - { - info->entry = readdir( info->dir ); + if( info->dir != NULL) + + while( ( info->entry = readdir( info->dir ) ) != NULL ){ + strcpy( string, info->entry->d_name ); + pos = strrchr( string, OS_PATH_DELIMITER ); + pos = strrchr( pos ? ( pos + 1 ) : string, '.' ); + if( pos && ! ( pos == &string[ 0 ] ) ) + { + strcpy( fext, pos + 1 ); + *pos = '\0'; + } + else + fext[ 0 ] = '\0'; + + pos = strrchr( string, OS_PATH_DELIMITER ); + strcpy( fname, pos ? ( pos + 1 ) : string ); + + if( !*fname ) + strcpy( fname, "*" ); + /* TOFIX: uiAttr check */ - - bFound = ( info->entry != NULL ); + if( hb_strMatchRegExp( fname, info->pfname ) && hb_strMatchRegExp( fext, info->pfext ) ) { + bFound=TRUE; + break; + } + } else bFound = FALSE; @@ -680,7 +751,46 @@ BOOL hb_fsFindNext( PHB_FFIND ffind ) #elif defined(HB_OS_UNIX) { - bFound = ( ( info->entry = readdir( info->dir ) ) != NULL ); + char string[ _POSIX_PATH_MAX + 1 ]; + char * pos; + char fname[ _POSIX_PATH_MAX + 1 ]; + char fext[ _POSIX_PATH_MAX + 1 ]; + BOOL bTest; + + bFound=FALSE; + + while( ( info->entry = readdir( info->dir ) ) != NULL ) + { + + strcpy( string, info->entry->d_name ); + pos = strrchr( string, OS_PATH_DELIMITER ); + pos = strrchr( pos ? ( pos + 1 ) : string, '.' ); + + if( pos && ! ( pos == &string[ 0 ] ) ) + { + strcpy( fext, pos + 1 ); + *pos = '\0'; + } + else + fext[ 0 ] = '\0'; + + pos = strrchr( string, OS_PATH_DELIMITER ); + strcpy( fname, pos ? ( pos + 1 ) : string ); + if( !*fname ) + strcpy( fname, "*" ); + + /* TOFIX: uiAttr check */ + bTest=hb_strMatchRegExp( fname, info->pfname ) && hb_strMatchRegExp( fext, info->pfext ) ; + + if (bTest) + { + bFound=TRUE; + break; + } + + + } + } #elif defined(HB_OS_MAC) diff --git a/harbour/source/rtl/listbox.prg b/harbour/source/rtl/listbox.prg index 5a11cb95d5..35e0ff6390 100644 --- a/harbour/source/rtl/listbox.prg +++ b/harbour/source/rtl/listbox.prg @@ -52,931 +52,986 @@ #include 'hbclass.ch' #include 'common.ch' - +#include "box.ch" #ifdef HB_COMPAT_C53 -CLASS HBListBox +Class HBListBox -Method New(nTop,nLeft,nBottom,nRigth,lDrop) + Method New( nTop, nLeft, nBottom, nRigth, lDrop ) + MESSAGE Select( nPos ) Method SELECTS( nPos ) + Method AddItem( cText, xValue ) + Method Close() + Method DelItem( nPos ) + Method Display() + Method FindText( cText, nPos, lCaseSensitive, lExact ) + Method FindData( cText, nPos, lCaseSensitive, lExact ) + Method GetData( xItem ) + Method GetItem( nPos ) + Method GetText( nPos ) + Method HitTest( n, p ) + Method InsItem( nPos, cText, xVal ) + Method KillFocus() + Method NextItem() + Method Open() + Method PrevItem() + MESSAGE Scroll( n ) Method _Scroll( n ) -MESSAGE Select(nPos) MeTHOD SELECTS(nPos) -METHOD AddItem(cText,xValue) -METHOD Close() -METHOD DelItem(nPos) -METHOD Display() -METHOD FindText( cText, nPos, lCaseSensitive, lExact ) -Method FindData( cText, nPos, lCaseSensitive, lExact ) -METHOD GetData(xItem) -METHOD GetItem(nPos) -METHOD GetText(nPos) -METHOD HitTest(n,p) -METHOD InsItem(nPos,cText,xVal) -METHOD KillFocus() -METHOD NextItem() -METHOD Open() -METHOD PrevItem() -MESSAGE Scroll(n) METHOD _Scroll(n) + Method SetData( nPos, xValue ) + Method SetFocus() + Method SetItem( nPos, aitem ) + Method SetText( nPos, xValue ) + DATA ClassName Init "LISTBOX" + DATA Buffer + DATA CapCol + DATA CapRow + DATA Cargo Init NIL + DATA HasFocus Init .T. + DATA ItemCount Init 0 + DATA Left Init 0 + DATA Message Init '' + DATA TextValue Init '' + DATA Style Init "" + DATA sBlock Init NIL + DAta fBlock Init Nil + DATA Hotbox Init "" + Data ColorSpec Init "" + DATA ColdBox + Data ISOPEN Init .f. + Data aItems Init {} + Data vScrolls -METHOD SetData(nPos,xValue) -METHOD SetFocus() -METHOD SetItem(nPos,aitem) -METHOD SetText(nPos,xValue) -DATA ClassName init "LISTBOX" -DATA Buffer -DATA CapCol -DATA CapRow -DATA Cargo init NIL -DATA HasFocus init .T. -DATA ItemCount init 0 -DATA Left init 0 -DATA Message init '' -DATA TextValue init '' -DATA Style init "" -DATA sBlock init NIL -DAta fBlock init Nil -DATA Hotbox init "" -Data ColorSpec init "" -DATA ColdBox -Data ISOPEN init .f. -Data aItems init {} -Data vScrolls + DATA Value Init 0 + Data Top Init 0 + Data right Init 0 + data Bottom Init 0 + Data TopItem Init 1 + Data dropdown Init .f. + ACCESS nTop inline ::SetTop() + ASSIGN nTop( xData ) inline ::SetTop( xData ) + ACCESS vScroll inline ::vScrolls + ASSIGN vScroll( xData ) inline ::SetScroll( xData ) + ACCESS NRight inline ::SetRight() + ASSIGN nRight( xData ) inline ::SetRight( xData ) + ACCESS lDropDown inline ::SetDropDown() + ASSIGN lDropDown( xData ) inline ::SetDropDown( xData ) + ACCESS caption inline ::SetCaption() + ASSIGN Caption( xData ) inline ::SetCaption( xData ) + ACCESS nBottom inline ::SetBottom() + ASSIGN nBottom( xData ) inline ::SetBottom( xData ) + ACCESS nTopItem inline ::SetTopItem() + ASSIGN nTopItem( xTop ) inline ::SetTopItem( xTop ) + ACCESS TypeOut inline ::itemCount == 0 + ASSIGN TypeOut( x ) inline If( x != nil, x, ::itemCount == 0 ) -DATA Value init 0 -Data top init 0 -Data right init 0 -data bottom init 0 -Data TopItem init 1 -Data dropdown init .f. -ACCESS nTop inline ::SetTop() -ASSIGN nTop(xData) inline ::SetTop(xData) -ACCESS vScroll inline ::vScrolls -ASSIGN vScroll(xData) inline ::SetScroll(xData) -ACCESS NRight inline ::SetRight() -ASSIGN nRight(xData) inline ::SetRight(xData) -ACCESS lDropDown inline ::SetDropDown() -ASSIGN lDropDown(xData) inline ::SetDropDown(xData) -ACCESS caption inline ::SetCaption() -ASSIGN Caption(xData) inline ::SetCaption(xData) -ACCESS nBottom inline ::SetBottom() -ASSIGN nBottom(xData) inline ::SetBottom(xData) -ACCESS nTopItem inline ::SetTopItem() -ASSIGN nTopItem(xTop) inline ::SetTopItem(xTop) -ACCESS TypeOut inline ::itemCount == 0 -ASSIGN TypeOut(x) inline if(x!=nil,x,::itemCount == 0) + Hidden: -Hidden: - -METHOD SetScroll(xData) -Data xTop init 0 -Method SetTop(xData) -Data xRight init 0 -METHOD SetRight(xData) -DATA xDropDown init .f. -Method SetDropDown(xData) -Data cCaption init '' -Method SetCaption(xData) -Data xBottom init 0 -METHOD SetBottom(xData) -Data aScreen init NIL -DATA nCursor init 0 -DATA xtopItem init 0 -METHOD SetTopItem(xTop) + Method SetScroll( xData ) + Data xTop Init 0 + Method SetTop( xData ) + Data xRight Init 0 + Method SetRight( xData ) + DATA xDropDown Init .f. + Method SetDropDown( xData ) + Data cCaption Init '' + Method SetCaption( xData ) + Data xBottom Init 0 + Method SetBottom( xData ) + Data aScreen Init NIL + DATA nCursor Init 0 + DATA xtopItem Init 0 + Method SetTopItem( xTop ) Endclass -Method New(nTop,nLeft,nBottom,nRigth,lDrop) - Local ccolor +Method New( nTop, nLeft, nBottom, nRigth, lDrop ) - ::ClassName:='LISTBOX' - ::Bottom := nBottom - ::nBottom := nBottom - ::right := nRigth - ::nright := nRigth - ::Top := nTop - ::ntop :=nTop - ::left := nleft - ::Buffer := Nil - ::Caption := "" - ::CapCol := nleft - ::CapRow := nTop - ::Cargo := Nil - ::ColdBox := "ÚÄ¿³ÙÄÀ³" - if ( isdefcolor() ) - ::Colorspec := "W/N,W+/N,W+/N,N/W,W/N,W/N,W+/N,W/N" - else - cColor := SetColor() - ::Colorspec := __guicolor(cColor, 5) + "," + ; - __guicolor(cColor, 5) + "," + __guicolor(cColor, 5) + ; - "," + __guicolor(cColor, 2) + "," + __guicolor(cColor, ; - 3) + "," + __guicolor(cColor, 1) + "," + ; - __guicolor(cColor, 4) - endif - ::aItems := {} - ::dropdown := lDrop - ::ldropdown := lDrop - ::fBlock := Nil - ::hasfocus := .F. + Local ccolor - ::hotbox := "ÉÍ»º¼ÍȺ" - ::itemCount := 0 + ::ClassName := 'LISTBOX' + ::Bottom := nBottom + ::nBottom := nBottom + ::right := nRigth + ::nright := nRigth + ::Top := nTop + ::ntop := nTop + ::left := nleft + ::Buffer := Nil + ::Caption := "" + ::CapCol := nleft + ::CapRow := nTop + ::Cargo := Nil + ::ColdBox := B_SINGLE + If ( Isdefcolor() ) + ::Colorspec := "W/N,W+/N,W+/N,N/W,W/N,W/N,W+/N,W/N" + Else + cColor := Setcolor() + ::Colorspec := __guicolor( cColor, 5 ) + "," + ; + __guicolor( cColor, 5 ) + "," + __guicolor( cColor, 5 ) + ; + "," + __guicolor( cColor, 2 ) + "," + __guicolor( cColor, ; + 3 ) + "," + __guicolor( cColor, 1 ) + "," + ; + __guicolor( cColor, 4 ) + Endif + ::aItems := {} + ::dropdown := lDrop + ::ldropdown := lDrop + ::fBlock := Nil + ::hasfocus := .F. - ::message := "" + ::hotbox := B_DOUBLE + ::itemCount := 0 - ::ascreen := Str(nTop + 1, 2) + Str(nleft, 2) + Str(nBottom, ; - 2) + Str(nRigth, 2) + SaveScreen(nTop + 1, nleft, nBottom, nRigth) - ::isopen := !lDrop + ::message := "" - ::sBlock := Nil - ::nCursor := Nil - ::Style := "" - ::TextValue := "" + ::ascreen := Str( nTop + 1, 2 ) + Str( nleft, 2 ) + Str( nBottom, ; + 2 ) + Str( nRigth, 2 ) + Savescreen( nTop + 1, nleft, nBottom, nRigth ) + ::isopen := !lDrop - ::Topitem := 0 - ::nTopItem:=0 - ::vScroll := Nil - ::Value := 0 + ::sBlock := Nil + ::nCursor := Nil + ::Style := chr(31) + ::TextValue := "" -return Self + ::Topitem := 0 + ::nTopItem := 0 + ::vScroll := Nil + ::Value := 0 + +Return Self /**** Get/Set Datas ****/ -METHOD SetScroll(xData) CLASS HBListBox - if (ISOBJECT(xData) )/*.and. xData:Classname=="SCROLLBAR" .and. xData:orient==1)*/ - ::vScrolls := xData - xData:total:=::iTemCount - endif - return ::vScrolls +Method SetScroll( xData ) Class HBListBox -METHOD SetTop(xData) CLASS HBListBox - Local nTop + If ( ISOBJECT( xData ) ) /*.and. xData:Classname=="SCROLLBAR" .and. xData:orient==1)*/ + ::vScrolls := xData + xData:total := ::iTemCount + Endif +Return ::vScrolls - if ( !( ISNIL( xData ) .and. ISNUMBER(xData) ) .and. ISNUMBER((::xTop := xData)) .and. ISOBJECT(::vScroll) ) - ::vScroll:start:=xData + 1 - endif - return ::xTop -METHOD SetRight(xData) CLASS HBListBox +Method SetTop( xData ) Class HBListBox - if ( ! (ISNIL( xData ) ) .and. ISOBJECT( ( ::xRight:=xData,::vScroll))) - ::vScroll:offset:=xData - endif - return ::xRight -METHOD SetDropDown( xData ) CLASS HBListBox + Local nTop - if ( !( ISNIL( xData ) ) ) .and. ISLOGICAL(xData) - ::xDropDown := xData - if xData - elseif ( !::isOpen ) - ::isOpen := .T. - endif + If ( !( ISNIL( xData ) .and. Isnumber( xData ) ) .and. Isnumber( ( ::xTop := xData ) ) .and. ISOBJECT( ::vScroll ) ) + ::vScroll:start := xData + 1 + Endif +Return ::xTop +Method SetRight( xData ) Class HBListBox - endif - return ::xDropDown + If ( !( ISNIL( xData ) ) .and. ISOBJECT( ( ::xRight := xData, ::vScroll ) ) ) + ::vScroll:offset := xData + Endif +Return ::xRight +Method SetDropDown( xData ) Class HBListBox -METHOD SetCaption(xData) CLASS HBListBox - if ( ISCHARACTER(xData) .AND. ISNIL( ::Capcol) ) - ::cCaption := xData - ::Caprow := ::top - ::Capcol := ::left - Len(xData) - endif - return ::cCaption + If ( !( ISNIL( xData ) ) ) .and. ISLOGICAL( xData ) + ::xDropDown := xData + If xData + Elseif ( !::isOpen ) + ::isOpen := .T. + Endif -METHOD SetBottom(xData) CLASS HBListBox - local nBottom - if ( ! (ISNIL( xData ) .and. ISNUMBER(xData)) .and. ISNUMBER((::xBottom := xData)) .and. ISOBJECT( (::vScroll))) - nBottom:=::xBottom - ::vScroll:end:=xData-1 - endif - return ::xBottom - /*** Class Methods ***/ + Endif +Return ::xDropDown -METHOD ADDITEM( cText, xValue ) CLASS HBListBox - if ( !( ISCHARACTER( cText ) ) ) - elseif ( ValType(xValue) $ "CUN" ) - AAdd(::aItems, {cText, xValue}) - ::iTemCount++ - if ( ::iTemCount == 1 .and. ISOBJECT(( ::Topitem := 1,::nTopItem:=1,::vScroll ) )) - ::vScroll:total:=(::iTemCount - ( ::bottom - ; - ::top - 2 )) - endif - endif - return Self +Method SetCaption( xData ) Class HBListBox + If ( Ischaracter( xData ) .and. ISNIL( ::Capcol ) ) + ::cCaption := xData + ::Caprow := ::top + ::Capcol := ::left - Len( xData ) + Endif +Return ::cCaption +Method SetBottom( xData ) Class HBListBox -METHOD CLOSE() CLASS HBListBox + Local nBottom + If ( !( ISNIL( xData ) .and. Isnumber( xData ) ) .and. Isnumber( ( ::xBottom := xData ) ) .and. ISOBJECT( ( ::vScroll ) ) ) + nBottom := ::xBottom + ::vScroll:end := xData - 1 + Endif +Return ::xBottom +/*** Class Methods ***/ - local Local1, Local2, Local3, cColor, Local5 - if ( ::isOpen ) - RestScreen(Val(SubStr(::aScreen, 1, 2)), ; - Val(SubStr(::aScreen, 3, 2)), ; - Val(SubStr(::aScreen, 5, 2)), ; - Val(SubStr(::aScreen, 7, 2)), SubStr(::aScreen, ; - 9)) - ::isOpen := .F. - ::aScreen := Nil - endif - return self +Method ADDITEM( cText, xValue ) Class HBListBox -METHOD DELITEM( xitem) + If ( !( Ischaracter( cText ) ) ) + Elseif ( Valtype( xValue ) $ "CUN" ) + Aadd( ::aItems, { cText, xValue } ) + ::iTemCount ++ + If ( ::iTemCount == 1 .and. ISOBJECT( ( ::Topitem := 1, ::nTopItem := 1, ::vScroll ) ) ) + ::vScroll:total := ( ::iTemCount - ( ::bottom - ; + ::top - 2 ) ) + Endif + Endif +Return Self - if ( xitem< 1 ) - elseif ( xitem<= ::iTemCount ) - adel(::aItems[ xitem]) - asize(::aItems, --::iTemCount) - if ( ::Value > ::iTemCount ) - ::Value := ::iTemCount - if ( ::Value == 0 ) - ::TextValue := "" - else - ::TextValue := _Getdata(::aItems[ ::iTemCount ]) - endif - if ( ISNIL( ::Buffer ) ) - elseif ( ISNUMBER( ::Buffer ) ) - ::Buffer := ::iTemCount - elseif ( ::Value > 0 ) - ::Buffer := ::TextValue - endif - endif - if ( ::Topitem > ::iTemCount ) - ::Topitem := ::iTemCount - ::nTopitem:= ::iTemCount - endif - if ( ISOBJECT( ::vScroll ) ) - ::vScroll:total:=::iTemCount - ( ::Bottom - ; - ::top - 2 ) - endif - endif - return self +Method Close() Class HBListBox -METHOD Getdata( xData ) CLASS HBListBox + Local Local1 + Local Local2 + Local Local3 + Local cColor + Local Local5 + If ( ::isOpen ) + Restscreen( Val( Substr( ::aScreen, 1, 2 ) ), ; + Val( Substr( ::aScreen, 3, 2 ) ), ; + Val( Substr( ::aScreen, 5, 2 ) ), ; + Val( Substr( ::aScreen, 7, 2 ) ), Substr( ::aScreen, ; + 9 ) ) + ::isOpen := .F. + ::aScreen := Nil + Endif +Return self - local xRet := Nil - if ( xData < 1 ) - elseif ( xData <= ::itemCount ) - xRet := ::aitems[ xData ][ 2 ] - endif - return xRet +Method DELITEM( xitem ) -Method FindData( cText, nPos, lCaseSensitive, lExact ) CLASS HBListBox + If ( xitem < 1 ) + Elseif ( xitem <= ::iTemCount ) + Adel( ::aItems[ xitem ] ) + Asize( ::aItems, -- ::iTemCount ) + If ( ::Value > ::iTemCount ) + ::Value := ::iTemCount + If ( ::Value == 0 ) + ::TextValue := "" + Else + ::TextValue := _Getdata( ::aItems[ ::iTemCount ] ) + Endif + If ( ISNIL( ::Buffer ) ) + Elseif ( Isnumber( ::Buffer ) ) + ::Buffer := ::iTemCount + Elseif ( ::Value > 0 ) + ::Buffer := ::TextValue + Endif + Endif + If ( ::Topitem > ::iTemCount ) + ::Topitem := ::iTemCount + ::nTopitem := ::iTemCount + Endif + If ( ISOBJECT( ::vScroll ) ) + ::vScroll:total := ::iTemCount - ( ::Bottom - ; + ::top - 2 ) + Endif + Endif +Return self - local nPosFound, lOldExact, nStart, nEnd, nSize - if ( ISLOGICAL( lExact ) ) - lOldExact := Set(_SET_EXACT, lExact) - endif - nEnd := 1 - if ( ISNUMBER( nPos ) ) - nEnd++ - else - nPos := 1 - endif - nSize := Len(::aitems) - nPos + 1 - if ( !( ISLOGICAL( lCaseSensitive ) ) ) - lCaseSensitive := .T. - endif - for nStart := 1 to nEnd - if ( lCaseSensitive ) - if ( Set(_SET_EXACT) ) - nPosFound := ascan(::aitems, { |_1| _Getdata(_1) == cText ; - }, nPos, nSize) - else - nPosFound := ascan(::aitems, { |_1| _Getdata(_1) = cText ; - }, nPos, nSize) - endif - elseif ( Set(_SET_EXACT) ) - nPosFound := ascan(::aitems, { |_1| Lower(_Getdata(_1)) == ; - Lower(cText) }, nPos, nSize) - else - nPosFound := ascan(::aitems, { |_1| Lower(_Getdata(_1)) = ; - Lower(cText) }, nPos, nSize) - endif - if ( nPosFound > 0 ) - exit - endif - nSize := nPos - 1 - nPos := 1 - next - if ( !( ISNIL( lOldExact ) ) ) - set exact (lOldExact) - endif - return nPosFound +Method Getdata( xData ) Class HBListBox -Method FindText( cText, nPos, lCaseSensitive, lExact ) CLASS HBListBox + Local xRet := Nil + If ( xData < 1 ) + Elseif ( xData <= ::itemCount ) + xRet := ::aitems[ xData, 2 ] + Endif +Return xRet - local nPosFound, lOldExact, nStart, nEnd, nSize - if ( ISLOGICAL( lExact ) ) - lOldExact := Set(_SET_EXACT, lExact) - endif - nEnd := 1 - if ( ISNUMBER( nPos ) ) - nEnd++ - else - nPos := 1 - endif - nSize := Len(::aitems) - nPos + 1 - if ( !( ISLOGICAL( lCaseSensitive ) ) ) - lCaseSensitive := .T. - endif - for nStart := 1 to nEnd - if ( lCaseSensitive ) - if ( Set(_SET_EXACT) ) - nPosFound := ascan(::aitems, { |_1| _1[ 1 ] == cText ; - }, nPos, nSize) +Method FindData( cText, nPos, lCaseSensitive, lExact ) Class HBListBox - else - nPosFound := ascan(::aitems, { |_1| _1[ 1 ] == cText ; - }, nPos, nSize) - endif - elseif ( Set(_SET_EXACT) ) - nPosFound := ascan(::aitems, { |_1| Lower(_1[ 1 ]) == ; - Lower(cText) }, nPos, nSize) - else - nPosFound := ascan(::aitems, { |_1| Lower(_1[ 1 ]) = ; - Lower(cText) }, nPos, nSize) - endif - if ( nPosFound > 0 ) - exit - endif - nSize := nPos - 1 - nPos := 1 - next - if ( !( ISNIL( lOldExact ) ) ) - set exact (lOldExact) - endif - return nPosFound + Local nPosFound + Local lOldExact + Local nStart + Local nEnd + Local nSize + If ( ISLOGICAL( lExact ) ) + lOldExact := Set( _SET_EXACT, lExact ) + Endif + nEnd := 1 + If ( Isnumber( nPos ) ) + nEnd ++ + Else + nPos := 1 + Endif + nSize := Len( ::aitems ) - nPos + 1 + If ( !( ISLOGICAL( lCaseSensitive ) ) ) + lCaseSensitive := .T. + Endif + For nStart := 1 To nEnd + If ( lCaseSensitive ) + If ( Set( _SET_EXACT ) ) + nPosFound := Ascan( ::aitems, { | _1 | _Getdata( _1 ) == cText ; + }, nPos, nSize ) + Else + nPosFound := Ascan( ::aitems, { | _1 | _Getdata( _1 ) = cText ; + }, nPos, nSize ) + Endif + Elseif ( Set( _SET_EXACT ) ) + nPosFound := Ascan( ::aitems, { | _1 | Lower( _Getdata( _1 ) ) == ; + Lower( cText ) }, nPos, nSize ) + Else + nPosFound := Ascan( ::aitems, { | _1 | Lower( _Getdata( _1 ) ) = ; + Lower( cText ) }, nPos, nSize ) + Endif + If ( nPosFound > 0 ) + Exit + Endif + nSize := nPos - 1 + nPos := 1 + Next + If ( !( ISNIL( lOldExact ) ) ) + Set Exact ( lOldExact ) + Endif +Return nPosFound +Method FindText( cText, nPos, lCaseSensitive, lExact ) Class HBListBox -METHOD NEXTITEM() CLASS HBListBox + Local nPosFound + Local lOldExact + Local nStart + Local nEnd + Local nSize + If ( ISLOGICAL( lExact ) ) + lOldExact := Set( _SET_EXACT, lExact ) + Endif + nEnd := 1 + If ( Isnumber( nPos ) ) + nEnd ++ + Else + nPos := 1 + Endif + nSize := Len( ::aitems ) - nPos + 1 + If ( !( ISLOGICAL( lCaseSensitive ) ) ) + lCaseSensitive := .T. + Endif + For nStart := 1 To nEnd + If ( lCaseSensitive ) + If ( Set( _SET_EXACT ) ) + nPosFound := Ascan( ::aitems, { | _1 | _1[ 1 ] == cText ; + }, nPos, nSize ) - local nCurValue, nValue - if ( !::hasfocus ) - elseif ( ::itemCount > 0 ) - if ( ( nCurValue := ::value ) == ::itemCount ) - nValue := nCurValue - else - nValue := nCurValue + 1 - endif - changeitem(self, nCurValue, nValue) - endif - return self -METHOD PREVITEM() CLASS HBListBox + Else + nPosFound := Ascan( ::aitems, { | _1 | _1[ 1 ] == cText ; + }, nPos, nSize ) + Endif + Elseif ( Set( _SET_EXACT ) ) + nPosFound := Ascan( ::aitems, { | _1 | Lower( _1[ 1 ] ) == ; + Lower( cText ) }, nPos, nSize ) + Else + nPosFound := Ascan( ::aitems, { | _1 | Lower( _1[ 1 ] ) = ; + Lower( cText ) }, nPos, nSize ) + Endif + If ( nPosFound > 0 ) + Exit + Endif + nSize := nPos - 1 + nPos := 1 + Next + If ( !( ISNIL( lOldExact ) ) ) + Set Exact ( lOldExact ) + Endif +Return nPosFound - local nCurValue, nValue - if ( !::hasfocus ) - elseif ( ::itemCount > 0 ) - if ( ( nCurValue := ::value ) == 0 ) - nValue := 1 - elseif ( nCurValue == 1 ) - nValue := nCurValue - else - nValue := nCurValue - 1 - endif - changeitem(self, nCurValue, nValue) - endif - return self +Method NEXTITEM() Class HBListBox -METHOD _SCROLL( nMethod ) CLASS HBListBox + Local nCurValue + Local nValue + If ( !::hasfocus ) + Elseif ( ::itemCount > 0 ) + If ( ( nCurValue := ::value ) == ::itemCount ) + nValue := nCurValue + Else + nValue := nCurValue + 1 + Endif + changeitem( self, nCurValue, nValue ) + Endif +Return self +Method PREVITEM() Class HBListBox - LOCAl nPos, nTopItem, nCount, nThumbPos, nCurrent, nBarLength, nTotal, ; - nSize, nMouRow, nMouseRow, nKey, nStart - do case - case nMethod == -3074 - if ( ::topitem > 1 ) - ::topitem-- - ::vScroll:current:=lbadjustcu(Self) - Self:display() - endif - case nMethod == -3075 - if (( ::topitem + ::bottom - ::top) <= ::itemCount + 1 ) - ::topitem++ - ::vScroll:current(lbadjustcu(Self)) - Self:display() - endif - case nMethod == -3077 - nPos := ::bottom - ::top - 1 - nCount := ::itemCount - nTopItem := ::topitem + nPos - if ( ::topitem < nCount - nPos + 1 ) - if ( nTopItem + nPos - 1 > nCount ) - nTopItem := nCount - nPos + 1 - endif - ::topitem := nTopItem - ::ntopitem := nTopItem - ::vScroll:current(lbadjustcu(Self)) - Self:display() - endif - case nMethod == -3076 - nPos := ::bottom - ::top - iif( ::bitmap, 2, ; - 1 ) - nCount := ::itemCount - nTopItem := ::topitem - nPos - if ( ::topitem > 1 ) - if ( nTopItem < 1 ) - nTopItem := 1 - endif - ::topitem := nTopItem - ::ntopitem := nTopItem - ::vScroll:current(lbadjustcu(Self)) - Self:display() - endif - case nMethod == -3073 - nMouseRow := mrow() - do while ( ( nKey := InKey(0) ) != 1003 ) - if ( nKey == 1001 ) - nMouRow := mrow() - if ( nMouRow <= ::vScroll:start() ) - nMouRow := ::vScroll:start() + 1 - endif - if ( nMouRow >= ::vScroll:end() ) - nMouRow := ::vScroll:end() - 1 - endif - if ( nMouRow != nMouseRow ) - nThumbPos := ::vScroll:thumbpos() + ( nMouRow - ; - nMouseRow ) - nBarLength := ::vScroll:barlength() - nTotal := ::vScroll:total() - nSize := ( nThumbPos * ( nTotal - nBarLength - 2 ) + 2 * ; - nBarLength + 1 - nTotal ) / ( nBarLength - 1 ) - if ( nSize < 1 ) - nSize := 1 - endif - if ( nSize > nTotal ) - nSize := nTotal - endif - nCurrent := ::vScroll:current() - if ( nSize - nCurrent > 0 ) - for nStart := 1 to nSize - nCurrent - Self:scroll(-3075) - next - else - for nStart := 1 to nCurrent - nSize - Self:scroll(-3074) - next - endif - nMouseRow := nMouRow - endif - endif - enddo - endcase - return Self + Local nCurValue + Local nValue + If ( !::hasfocus ) + Elseif ( ::itemCount > 0 ) + If ( ( nCurValue := ::value ) == 0 ) + nValue := 1 + Elseif ( nCurValue == 1 ) + nValue := nCurValue + Else + nValue := nCurValue - 1 + Endif + changeitem( self, nCurValue, nValue ) + Endif +Return self -METHOD SELECTS( nPosition ) CLASS HBListBox +Method _SCROLL( nMethod ) Class HBListBox - local nValue, nPos, xType - do case - case ( xType := ValType(nPosition) ) == "C" - nPos := Self:finddata(nPosition) - if ( !( ValType(::buffer) $ "CU" ) ) - ::buffer := nPos - elseif ( ::value == 0 ) - ::buffer := nPosition - else - ::buffer := _Getdata(::aitems[ nPos ]) - endif - case !( xType == "N" ) - return ::value - case nPosition < 1 - return ::value - case nPosition > ::itemCount - return ::value - case nPosition == ::value - return ::value - otherwise - nPos := nPosition - if ( ValType(::buffer) $ "NU" ) - ::buffer := nPos - elseif ( nPos == 0 ) - ::buffer := "" - else - ::buffer := _Getdata(::aitems[ nPos ]) - endif - endcase - ::value := nPos - if ( nPos == 0 ) - ::textvalue := "" - else - ::textvalue := _Getdata(::aitems[ nPos ]) - endif - if ( Empty(::hotbox + ::coldbox) ) - nPos := 0 - else - nPos := 2 - endif - nValue := ::value - ( ::bottom - ::top - nPos ) - if ( ::topitem <= nValue ) - ::topitem := nValue - ::ntopitem := nValue - if ( ISOBJECT( ::vScroll ) ) - ::vScroll:current:=lbadjustcu(Self) - endif - elseif ( ::value == 0 ) - elseif ( ::topitem > ::value .AND. ISOBJECT( ( ; - ::topitem := ::value,::ntopitem := ::value, ::vScroll ) ) ) - ::vScroll:current:=lbadjustcu(Self) - endif - Self:display() - if ( ISBLOCK( ::sBlock ) ) - eval(::sBlock) - endif - return ::value -Method SetTOPITEM( xData ) CLASS HBListBox + Local nPos + Local nTopItem + Local nCount + Local nThumbPos + Local nCurrent + Local nBarLength + Local nTotal + Local nSize + Local nMouRow + Local nMouseRow + Local nKey + Local nStart + Do Case + Case nMethod == - 3074 + If ( ::topitem > 1 ) + ::topitem -- + ::vScroll:current := lbadjustcu( Self ) + Self:display() + Endif + Case nMethod == - 3075 + If ( ( ::topitem + ::bottom - ::top ) <= ::itemCount + 1 ) + ::topitem ++ + ::vScroll:current( lbadjustcu( Self ) ) + Self:display() + Endif + Case nMethod == - 3077 + nPos := ::bottom - ::top - 1 + nCount := ::itemCount + nTopItem := ::topitem + nPos + If ( ::topitem < nCount - nPos + 1 ) + If ( nTopItem + nPos - 1 > nCount ) + nTopItem := nCount - nPos + 1 + Endif + ::topitem := nTopItem + ::ntopitem := nTopItem + ::vScroll:current( lbadjustcu( Self ) ) + Self:display() + Endif + Case nMethod == - 3076 + nPos := ::bottom - ::top - Iif( ::bitmap, 2, ; + 1 ) + nCount := ::itemCount + nTopItem := ::topitem - nPos + If ( ::topitem > 1 ) + If ( nTopItem < 1 ) + nTopItem := 1 + Endif + ::topitem := nTopItem + ::ntopitem := nTopItem + ::vScroll:current( lbadjustcu( Self ) ) + Self:display() + Endif + Case nMethod == - 3073 + nMouseRow := Mrow() + Do While ( ( nKey := Inkey( 0 ) ) != 1003 ) + If ( nKey == 1001 ) + nMouRow := Mrow() + If ( nMouRow <=::vScroll:start() ) + nMouRow :=::vScroll:start() + 1 + Endif + If ( nMouRow >=::vScroll:end() ) + nMouRow :=::vScroll:end() - 1 + Endif + If ( nMouRow != nMouseRow ) + nThumbPos :=::vScroll:thumbpos() + ( nMouRow - ; + nMouseRow ) + nBarLength :=::vScroll:barlength() + nTotal :=::vScroll:total() + nSize := ( nThumbPos * ( nTotal - nBarLength - 2 ) + 2 * ; + nBarLength + 1 - nTotal ) / ( nBarLength - 1 ) + If ( nSize < 1 ) + nSize := 1 + Endif + If ( nSize > nTotal ) + nSize := nTotal + Endif + nCurrent :=::vScroll:current() + If ( nSize - nCurrent > 0 ) + For nStart := 1 To nSize - nCurrent + Self:scroll( - 3075 ) + Next + Else + For nStart := 1 To nCurrent - nSize + Self:scroll( - 3074 ) + Next + Endif + nMouseRow := nMouRow + Endif + Endif + Enddo + Endcase +Return Self - local nSize, nPos - if ( !( ISNIL( xData ) )) .and. xData>0 .and. xData <= ::itemCount +Method SELECTS( nPosition ) Class HBListBox - if ( Empty(::hotbox + ::coldbox) ) - nPos := 0 - else - nPos := 2 - endif - nSize := ::itemCount - ( ::bottom - ::top - ; - nPos ) - if ( xData > nSize ) - xData := nSize - endif - if ( ::topitem != xData ) - ::xtopitem := xData - if ( ISOBJECT( ::vScroll ) ) - ::vScroll:current:=lbadjustcu(Self) - endif - Self:display() - endif - endif - return ::xtopitem + Local nValue + Local nPos + Local xType + Do Case + Case ( xType := Valtype( nPosition ) ) == "C" + nPos := Self:finddata( nPosition ) + If ( !( Valtype( ::buffer ) $ "CU" ) ) + ::buffer := nPos + Elseif ( ::value == 0 ) + ::buffer := nPosition + Else + ::buffer := _Getdata( ::aitems[ nPos ] ) + Endif + Case !( xType == "N" ) + Return ::value + Case nPosition < 1 + Return ::value + Case nPosition > ::itemCount + Return ::value + Case nPosition == ::value + Return ::value + Otherwise + nPos := nPosition + If ( Valtype( ::buffer ) $ "NU" ) + ::buffer := nPos + Elseif ( nPos == 0 ) + ::buffer := "" + Else + ::buffer := _Getdata( ::aitems[ nPos ] ) + Endif + Endcase + ::value := nPos + If ( nPos == 0 ) + ::textvalue := "" + Else + ::textvalue := _Getdata( ::aitems[ nPos ] ) + Endif + If ( Empty( ::hotbox + ::coldbox ) ) + nPos := 0 + Else + nPos := 2 + Endif + nValue := ::value - ( ::bottom - ::top - nPos ) + If ( ::topitem <= nValue ) + ::topitem := nValue + ::ntopitem := nValue + If ( ISOBJECT( ::vScroll ) ) + ::vScroll:current := lbadjustcu( Self ) + Endif + Elseif ( ::value == 0 ) + Elseif ( ::topitem > ::value .and. ISOBJECT( ( ; + ::topitem := ::value, ::ntopitem := ::value, ::vScroll ) ) ) + ::vScroll:current := lbadjustcu( Self ) + Endif + Self:display() + If ( ISBLOCK( ::sBlock ) ) + Eval( ::sBlock ) + Endif +Return ::value +Method SetTOPITEM( xData ) Class HBListBox -METHOD DISPLAY() CLASS HBListBox + Local nSize + Local nPos + If ( !( ISNIL( xData ) ) ) .and. xData > 0 .and. xData <= ::itemCount - local nCurRow := Row(), nCurCol:= Col(), cCurrentColor:= SetColor(), ; - nStart, nEnd, cColor4, cColor3, nTop := ::top, ; - nLeft := ::left, nSize, cHotBox, cCaption, nAmpPos, ; - cColorAny - nSize := ::right - nLeft + 1 - if ( ::hasfocus ) - cHotBox := ::hotbox - cColor3 := __guicolor(::colorspec, 3) - cColor4 := __guicolor(::colorspec, 4) - if ( ::isopen ) - cColorAny := __guicolor(::colorspec, 2) - else - cColorAny := __guicolor(::colorspec, 4) - endif - else - cHotBox := ::coldbox - cColor3 := __guicolor(::colorspec, 1) - cColor4 := __guicolor(::colorspec, 2) - cColorAny := __guicolor(::colorspec, 2) - endif + If ( Empty( ::hotbox + ::coldbox ) ) + nPos := 0 + Else + nPos := 2 + Endif + nSize := ::itemCount - ( ::bottom - ::top - ; + nPos ) + If ( xData > nSize ) + xData := nSize + Endif + If ( ::topitem != xData ) + ::xtopitem := xData + If ( ISOBJECT( ::vScroll ) ) + ::vScroll:current := lbadjustcu( Self ) + Endif + Self:display() + Endif + Endif +Return ::xtopitem - dispbegin() - nEnd := ::topitem + ::bottom - ::top - if ( ::dropdown ) - set color to (cColorAny) - SetPos(nTop++, nLeft) - if ( ::value == 0 ) - ?? Space(nSize - 1) - else - ?? padr(::aitems[ ::value ][ 1 ], nSize - 1) - endif - set color to (__guicolor(::colorspec, 8)) - ?? Left(::style, 1) - nEnd-- - endif - if ( ::isopen ) - if ( !Empty(cHotBox) ) - set color to (__guicolor(::colorspec, 5)) - @ nTop, nLeft clear to ::bottom, ::right - @ nTop, nLeft, ::bottom, ::right box cHotBox - if ( ISOBJECT( ::vScroll ) ) - ::vScroll:display() - endif - nTop++ - nLeft++ - nSize := nSize - 2 - nEnd := nEnd - 2 - endif - if ( nEnd > ::itemCount ) - nEnd := ::itemCount - endif - for nStart := ::topitem to nEnd - if ( nStart == ::value ) - set color to (cColor4) - else - set color to (cColor3) - endif - SetPos(nTop++, nLeft) - ?? padr(::aitems[ nStart ][ 1 ], nSize) - next - endif - if ( !Empty(cCaption := ::caption) ) - if ( ( nAmpPos := At("&", cCaption) ) == 0 ) - elseif ( nAmpPos == Len(cCaption) ) - nAmpPos := 0 - else - cCaption := stuff(cCaption, nAmpPos, 1, "") - endif - set color to (__guicolor(::colorspec, 6)) - SetPos(::caprow, ::capcol - 1) - ?? cCaption - if ( nAmpPos != 0 ) - set color to (__guicolor(::colorspec, 7)) - SetPos(::caprow, ::capcol + nAmpPos - 2) - ?? SubStr(cCaption, nAmpPos, 1) - endif - endif - dispend() +Method Display() Class HBListBox - set color to (cCurrentColor) - SetPos(nCurRow, nCurCol) - return Self + Local nCurRow := Row() + Local nCurCol := Col() + Local cCurrentColor := Setcolor() + Local nStart + Local nEnd + Local cColor4 + Local cColor3 + Local nTop := ::top + Local nLeft := ::left + Local nSize + Local cHotBox + Local cCaption + Local nAmpPos + Local cColorAny + nSize := ::right - nLeft + 1 + If ( ::hasfocus ) + cHotBox := ::hotbox + cColor3 := __guicolor( ::colorspec, 3 ) + cColor4 := __guicolor( ::colorspec, 4 ) + If ( ::isopen ) + cColorAny := __guicolor( ::colorspec, 2 ) + Else + cColorAny := __guicolor( ::colorspec, 4 ) + Endif + Else + cHotBox := ::coldbox + cColor3 := __guicolor( ::colorspec, 1 ) + cColor4 := __guicolor( ::colorspec, 2 ) + cColorAny := __guicolor( ::colorspec, 2 ) + Endif -METHOD GETITEM( xItem ) CLASS HBListBox + Dispbegin() + nEnd := ::topitem + ::bottom - ::top + If ( ::dropdown ) + Set Color To (cColorAny) + Setpos( nTop ++, nLeft ) + If ( ::value == 0 ) + ?? Space( nSize - 1 ) + Else + ?? Padr( ::aitems[ ::value, 1 ], nSize - 1 ) + Endif + Set Color To (__guicolor(::colorspec, 8)) + ?? Left( ::style, 1 ) + nEnd -- + Endif + If ( ::isopen ) + If ( !Empty( cHotBox ) ) + Set Color To (__guicolor(::colorspec, 5)) + @ nTop, nLeft clear To ::bottom, ::right + @ nTop, nLeft, ::bottom, ::right Box cHotBox + If ( ISOBJECT( ::vScroll ) ) + ::vScroll:display() + Endif + nTop ++ + nLeft ++ + nSize -= 2 + nEnd -= 2 + Endif + If ( nEnd > ::itemCount ) + nEnd := ::itemCount + Endif + For nStart := ::topitem To nEnd + If ( nStart == ::value ) + Set Color To (cColor4) + Else + Set Color To (cColor3) + Endif + Setpos( nTop ++, nLeft ) + ?? Padr( ::aitems[ nStart, 1 ], nSize ) + Next + Endif + If ( !Empty( cCaption := ::caption ) ) + If ( ( nAmpPos := At( "&", cCaption ) ) == 0 ) + Elseif ( nAmpPos == Len( cCaption ) ) + nAmpPos := 0 + Else + cCaption := Stuff( cCaption, nAmpPos, 1, "" ) + Endif + Set Color To (__guicolor(::colorspec, 6)) + Setpos( ::caprow, ::capcol - 1 ) + ?? cCaption + If ( nAmpPos != 0 ) + Set Color To (__guicolor(::colorspec, 7)) + Setpos( ::caprow, ::capcol + nAmpPos - 2 ) + ?? Substr( cCaption, nAmpPos, 1 ) + Endif + Endif + Dispend() - local xRet := Nil - if ( xItem < 1 ) - elseif ( xItem <= ::itemCount ) - xRet := ::aitems[ xItem ] - endif - return xRet -METHOD GETTEXT( xItem ) CLASS HBListBox + Set Color To (cCurrentColor) + Setpos( nCurRow, nCurCol ) +Return Self - local xRet := Nil - if ( xItem < 1 ) - elseif ( xItem <= ::itemCount ) - xRet := ::aitems[ xItem ][ 1 ] - endif - return xRet -METHOD INSITEM( nPosition, cText, xExp ) +Method GETITEM( xItem ) Class HBListBox - if ( !( ISCHARACTER( cText ) ) ) - elseif ( !( ISNUMBER( nPosition ) ) ) - elseif ( nPosition < ::itemCount ) - asize(::aitems, ++::itemCount) - ains(::aitems, nPosition) - ::aitems[ nPosition ] := {cText, xExp} - if ( ::itemCount == 1 ) - ::topitem := 1 - ::ntopitem := 1 - endif - if ( ISOBJECT( ::vScroll ) ) - ::vScroll:total:=::itemCount - ( ::bottom - ; - ::top - 2 ) - endif - endif - return self + Local xRet := Nil + If ( xItem < 1 ) + Elseif ( xItem <= ::itemCount ) + xRet := ::aitems[ xItem ] + Endif +Return xRet +Method GETTEXT( xItem ) Class HBListBox -METHOD HITTEST( nMouseRow, nMouseCol ) CLASS HBListBox + Local xRet := Nil + If ( xItem < 1 ) + Elseif ( xItem <= ::itemCount ) + xRet := ::aitems[ xItem, 1 ] + Endif +Return xRet +Method INSITEM( nPosition, cText, xExp ) - local Local1, Local2 := 0, Local3, cColor - if ( !::isopen ) - elseif ( !( ISOBJECT( ::vScroll ) ) ) - elseif ( ( Local2 := ::vScroll:hittest(nMouseRow, nMouseCol) ) != 0 ) - return Local2 - endif - if ( !::isopen .OR. Empty(::hotbox + ::coldbox) ) - Local1 := 0 - else - cColor := ::top - if ( ::DropDown ) - cColor++ - endif - do case - case nMouseRow == cColor - if ( nMouseCol == ::left ) - return -1 - elseif ( nMouseCol == ::right ) - return -3 - elseif ( nMouseCol >= ::left .AND. nMouseCol <= ::right ) - return -2 - endif - case nMouseRow == ::bottom - if ( nMouseCol == ::left ) - return -7 - elseif ( nMouseCol == ::right ) - return -5 - elseif ( nMouseCol >= ::left .AND. nMouseCol <= ::right ) - return -6 - endif - case nMouseCol == ::left - if ( nMouseRow >= ::top .AND. nMouseRow <= ::bottom ) - return -8 - else - return 0 - endif - case nMouseCol == ::right - if ( nMouseRow >= ::top .AND. nMouseRow <= ::bottom ) - return -4 - else - return 0 - endif - endcase - Local1 := 1 - endif - do case - case !::isopen - case nMouseRow < cColor + Local1 - case nMouseRow > ::bottom - Local1 - case nMouseCol < ::left + Local1 - case nMouseCol <= ::right - Local1 - return ::topitem + nMouseRow - ( cColor + Local1 ) - endcase - do case - case !::dropdown - case nMouseRow != ::top - case nMouseCol < ::left - case nMouseCol < ::right - return -2049 - case nMouseCol == ::right - return -4097 - endcase - do case - case Empty(::caption) - case nMouseRow != ::caprow - case nMouseCol < ::capcol - case nMouseCol < ::capcol + __caplengt(::caption) - return -1025 - endcase - return 0 -method KillFocus() CLASS HBListBox - local Local1 - if ( ::hasfocus ) - ::hasfocus := .F. - if ( ISBLOCK( ::fblock ) ) - eval(::fblock) - endif + If ( !( Ischaracter( cText ) ) ) + Elseif ( !( Isnumber( nPosition ) ) ) + Elseif ( nPosition < ::itemCount ) + Asize( ::aitems, ++ ::itemCount ) + Ains( ::aitems, nPosition ) + ::aitems[ nPosition ] := { cText, xExp } + If ( ::itemCount == 1 ) + ::topitem := 1 + ::ntopitem := 1 + Endif + If ( ISOBJECT( ::vScroll ) ) + ::vScroll:total := ::itemCount - ( ::bottom - ; + ::top - 2 ) + Endif + Endif +Return self - dispbegin() - if ( ::dropdown .AND. ::isopen ) - ::close() - endif - ::display() - dispend() +Method HITTEST( nMouseRow, nMouseCol ) Class HBListBox - setcursor(::nCursor) - endif - return self + Local Local1 + Local Local2 := 0 + Local Local3 + Local cColor + If ( !::isopen ) + Elseif ( !( ISOBJECT( ::vScroll ) ) ) + Elseif ( ( Local2 :=::vScroll:hittest( nMouseRow, nMouseCol ) ) != 0 ) + Return Local2 + Endif + If ( !::isopen .or. Empty( ::hotbox + ::coldbox ) ) + Local1 := 0 + Else + cColor := ::top + If ( ::DropDown ) + cColor ++ + Endif + Do Case + Case nMouseRow == cColor + If ( nMouseCol == ::left ) + Return - 1 + Elseif ( nMouseCol == ::right ) + Return - 3 + Elseif ( nMouseCol >= ::left .and. nMouseCol <= ::right ) + Return - 2 + Endif + Case nMouseRow == ::bottom + If ( nMouseCol == ::left ) + Return - 7 + Elseif ( nMouseCol == ::right ) + Return - 5 + Elseif ( nMouseCol >= ::left .and. nMouseCol <= ::right ) + Return - 6 + Endif + Case nMouseCol == ::left + If ( nMouseRow >= ::top .and. nMouseRow <= ::bottom ) + Return - 8 + Else + Return 0 + Endif + Case nMouseCol == ::right + If ( nMouseRow >= ::top .and. nMouseRow <= ::bottom ) + Return - 4 + Else + Return 0 + Endif + Endcase + Local1 := 1 + Endif + Do Case + Case !::isopen + Case nMouseRow < cColor + Local1 + Case nMouseRow > ::bottom - Local1 + Case nMouseCol < ::left + Local1 + Case nMouseCol <= ::right - Local1 + Return ::topitem + nMouseRow - ( cColor + Local1 ) + Endcase + Do Case + Case !::dropdown + Case nMouseRow != ::top + Case nMouseCol < ::left + Case nMouseCol < ::right + Return - 2049 + Case nMouseCol == ::right + Return - 4097 + Endcase + Do Case + Case Empty( ::caption ) + Case nMouseRow != ::caprow + Case nMouseCol < ::capcol + Case nMouseCol < ::capcol + __caplengt( ::caption ) + Return - 1025 + Endcase +Return 0 +Method KillFocus() Class HBListBox - METHOD Open() CLASS HBListBox - if ( !::isopen ) + Local Local1 + If ( ::hasfocus ) + ::hasfocus := .F. + If ( ISBLOCK( ::fblock ) ) + Eval( ::fblock ) + Endif - ::ascreen := Str(::top + 1, 2) + ; - Str(::left, 2) + Str(::bottom, 2) + ; - Str(::right, 2) + SaveScreen(::top + 1, ; - ::left, ::bottom, ::right) - ::isopen := .T. - Self:display() - endif - return self + Dispbegin() + If ( ::dropdown .and. ::isopen ) + ::close() + Endif + ::display() + Dispend() + Setcursor( ::nCursor ) + Endif +Return self -METHOD SetText(nPos,cText) CLASS HBListBox - if ( nPos < 1 ) - elseif ( nPos <= ::itemCount ) - ::aitems[ nPos ][ 1 ] := cText - endif - return self +Method Open() Class HBListBox + If ( !::isopen ) -Method SetItem( nPos, cText ) CLASS HBListBox + ::ascreen := Str( ::top + 1, 2 ) + ; + Str( ::left, 2 ) + Str( ::bottom, 2 ) + ; + Str( ::right, 2 ) + Savescreen( ::top + 1, ; + ::left, ::bottom, ::right ) + ::isopen := .T. + Self:display() + Endif +Return self - do case - case nPos < 1 - case nPos > ::itemCount - case Len(cText) != 2 - case ISCHARACTER( cText[ 1 ] ) - ::aitems[ nPos ] := cText - endcase - return self -method SETFOCUS() CLASS HBListBox +Method SetText( nPos, cText ) Class HBListBox - if ( !::hasfocus ) - ::nCursor := setcursor(0) - ::hasfocus := .T. - dispbegin() - Self:display() - dispend() + If ( nPos < 1 ) + Elseif ( nPos <= ::itemCount ) + ::aitems[ nPos, 1 ] := cText + Endif +Return self - if ( ISBLOCK( ::fblock ) ) - eval(::fblock) - endif - endif - return self +Method SetItem( nPos, cText ) Class HBListBox -METHOD SetDAta(nPos,xData) CLASS HBListBox - if ( !( nPos < 1 ) ) - elseif ( nPos <= ::itemCount ) - ::aitems[ nPos ][ 2 ] := xData - endif - return Self + Do Case + Case nPos < 1 + Case nPos > ::itemCount + Case Len( cText ) != 2 + Case Ischaracter( cText[ 1 ] ) + ::aitems[ nPos ] := cText + Endcase +Return self +Method SETFOCUS() Class HBListBox -static function CHANGEITEM( oList, nPos, nItem ) + If ( !::hasfocus ) + ::nCursor := Setcursor( 0 ) + ::hasfocus := .T. + Dispbegin() + Self:display() + Dispend() - local Local1, Local2 - if ( nPos != nItem ) - oList:value := nItem - if ( oList:value == 0 ) - oList:Textvalue := "" - else - oList:Textvalue := _Getdata(oList:aItems[ oList:value ]) - endif - if ( ISNIL( oList:Buffer ) ) - elseif ( ISNUMBER( oList:Buffer ) ) - oList:Buffer := oList:value - elseif ( oList:value > 0 ) - oList:Buffer := oList:Textvalue - endif - if ( Empty(oList:hotbox + oList:coldbox) ) - Local2 := 0 - else - Local2 := 2 - endif - if ( oList:Dropdown ) - Local2++ - endif - Local1 := oList:value - ( oList:Bottom - oList:top - Local2 ) - if ( oList:Topitem > oList:value ) - oList:topitem := oList:value - if ( ISOBJECT( oList:vScroll ) ) - oList:vScroll:current:=lbadjustcu(oList) - endif - - elseif ( oList:topitem <= Local1 .AND. ISOBJECT( (oList:topitem :=Local1, ; - oList:vScroll ) )) - oList:vScroll:current:=lbadjustcu(oList) - endif - oList:display() - if ( ISBLOCK( oList:sBlock ) ) - eval(oList:sBlock) - endif - endif - return oList -static function LBADJUSTCU( oList ) + If ( ISBLOCK( ::fblock ) ) + Eval( ::fblock ) + Endif + Endif +Return self - local nSize, nCount, nLength, nTopItem, nNewSize - nSize := oList:Bottom - oList:top - iif( oList:dropdown, 2, 1 ) - nCount := oList:itemCount - nLength := oList:vScroll:barlength - nTopItem := oList:Topitem - nNewSize := ( ( nCount - nLength ) * nTopItem + nLength - nSize ) / ( ; - nCount - nSize ) - return nNewSize +Method SetDAta( nPos, xData ) Class HBListBox -function LISTBOX( nTop,nLeft,nBottom,nRigth,lDrop) + If ( !( nPos < 1 ) ) + Elseif ( nPos <= ::itemCount ) + ::aitems[ nPos, 2 ] := xData + Endif +Return Self - if !( ISNUMBER( nTop ) ) .or. !( ISNUMBER( nleft ) ) .or. !( ISNUMBER( nBottom ) ) .or. !( ISNUMBER( nRigth ) ) - return nil - endif - return HBListBox():New(nTop,nLeft,nBottom,nRigth,lDrop) +Static Function CHANGEITEM( oList, nPos, nItem ) -static function _Getdata( xItem ) + Local Local1 + Local Local2 + If ( nPos != nItem ) + oList:value := nItem + If ( oList:value == 0 ) + oList:Textvalue := "" + Else + oList:Textvalue := _Getdata( oList:aItems[ oList:value ] ) + Endif + If ( ISNIL( oList:Buffer ) ) + Elseif ( Isnumber( oList:Buffer ) ) + oList:Buffer := oList:value + Elseif ( oList:value > 0 ) + oList:Buffer := oList:Textvalue + Endif + If ( Empty( oList:hotbox + oList:coldbox ) ) + Local2 := 0 + Else + Local2 := 2 + Endif + If ( oList:Dropdown ) + Local2 ++ + Endif + Local1 := oList:value - ( oList:Bottom - oList:top - Local2 ) + If ( oList:Topitem > oList:value ) + oList:topitem := oList:value + If ( ISOBJECT( oList:vScroll ) ) + oList:vScroll:current := lbadjustcu( oList ) + Endif - if ( ISNIL( xItem[ 2 ] ) ) - return xItem[ 1 ] - endif - return xItem[ 2 ] -function _LISTBOX_( Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, ; - Arg9, Arg10, Arg11, Arg12, Arg13) + Elseif ( oList:topitem <= Local1 .and. ISOBJECT( ( oList:topitem := Local1, ; + oList:vScroll ) ) ) + oList:vScroll:current := lbadjustcu( oList ) + Endif + oList:display() + If ( ISBLOCK( oList:sBlock ) ) + Eval( oList:sBlock ) + Endif + Endif +Return oList +Static Function LBADJUSTCU( oList ) - local oScroll, nPos, nLen, nCurPos - default arg5 to 1 - default arg12 to .f. - default arg13 to .f. - oScroll := listbox(Arg1, Arg2, Arg3, Arg4, Arg12) - if ( !( ISNIL( oScroll ) ) ) - if ( ISCHARACTER( Arg7 ) ) - oScroll:caption:=Arg7 - oScroll:capcol:=Arg2 - __caplengt(Arg7) - endif - if arg9!=nil - oScroll:colorspec:=Arg9 - endif - oScroll:message:=Arg8 - oScroll:fblock:=Arg10 - oScroll:sblock:=Arg11 - oScroll:isopen:=arg13 - nLen := Len(Arg6) - for nPos := 1 to nLen - nCurPos := Arg6[ nPos ] - if ( !( ISARRAY( nCurPos ) ) ) - oScroll:additem(nCurPos) - elseif ( Len(nCurPos) == 1 ) - oScroll:additem(nCurPos[ 1 ]) - else - oScroll:additem(nCurPos[ 1 ], nCurPos[ 2 ]) - endif - next - if ( !( ISNIL( Arg13 ) ) .AND. Arg13 ) - if ( !( ISLOGICAL( Arg12 ) ) ) - elseif ( Arg12 ) - Arg1++ - endif - oScroll:vscroll:=scrollbar(Arg1 + 1, Arg3 - 1, Arg4,,1) - endif + Local nSize + Local nCount + Local nLength + Local nTopItem + Local nNewSize + nSize := oList:Bottom - oList:top - Iif( oList:dropdown, 2, 1 ) + nCount := oList:itemCount + nLength := oList:vScroll:barlength + nTopItem := oList:Topitem + nNewSize := ( ( nCount - nLength ) * nTopItem + nLength - nSize ) / ( ; + nCount - nSize ) +Return nNewSize - oScroll:select(Arg5) - endif - return oScroll -function __CAPLENGT( Arg1 ) +Function Listbox( nTop, nLeft, nBottom, nRigth, lDrop ) - local Local1 := Len(Arg1), Local2 - if ( ( Local2 := At("&", Arg1) ) == 0 ) - elseif ( Local2 < Local1 ) - Local1-- - endif - return Local1 + If !( Isnumber( nTop ) ) .or. !( Isnumber( nleft ) ) .or. !( Isnumber( nBottom ) ) .or. !( Isnumber( nRigth ) ) + Return nil + Endif +Return HBListBox():New( nTop, nLeft, nBottom, nRigth, lDrop ) + +Static Function _Getdata( xItem ) + + If ( ISNIL( xItem[ 2 ] ) ) + Return xItem[ 1 ] + Endif +Return xItem[ 2 ] +Function _LISTBOX_( Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, ; + Arg9, Arg10, Arg11, Arg12, Arg13 ) + + Local oScroll + Local nPos + Local nLen + Local nCurPos + Default arg5 To 1 + Default arg12 To .f. + Default arg13 To .f. + oScroll := Listbox( Arg1, Arg2, Arg3, Arg4, Arg12 ) + If ( !( ISNIL( oScroll ) ) ) + If ( Ischaracter( Arg7 ) ) + oScroll:caption := Arg7 + oScroll:capcol := Arg2 - __caplengt( Arg7 ) + Endif + If arg9 != nil + oScroll:colorspec := Arg9 + Endif + oScroll:message := Arg8 + oScroll:fblock := Arg10 + oScroll:sblock := Arg11 + oScroll:isopen := arg13 + nLen := Len( Arg6 ) + For nPos := 1 To nLen + nCurPos := Arg6[ nPos ] + If ( !( Isarray( nCurPos ) ) ) + oScroll:additem( nCurPos ) + Elseif ( Len( nCurPos ) == 1 ) + oScroll:additem( nCurPos[ 1 ] ) + Else + oScroll:additem( nCurPos[ 1 ], nCurPos[ 2 ] ) + Endif + Next + If ( !( ISNIL( Arg13 ) ) .and. Arg13 ) + If ( !( ISLOGICAL( Arg12 ) ) ) + Elseif ( Arg12 ) + Arg1 ++ + Endif + oScroll:vscroll := Scrollbar( Arg1 + 1, Arg3 - 1, Arg4,, 1 ) + Endif + + oScroll:select( Arg5 ) + Endif +Return oScroll +Function __CAPLENGT( Arg1 ) + + Local Local1 := Len( Arg1 ) + Local Local2 + If ( ( Local2 := At( "&", Arg1 ) ) == 0 ) + Elseif ( Local2 < Local1 ) + Local1 -- + Endif +Return Local1 #endif + +*+ EOF: LISTBOX.PRG diff --git a/harbour/utils/hbmake/hbmutils.prg b/harbour/utils/hbmake/hbmutils.prg index b8531e47f4..d3ee1077e0 100644 --- a/harbour/utils/hbmake/hbmutils.prg +++ b/harbour/utils/hbmake/hbmutils.prg @@ -17,7 +17,7 @@ Function GetSourceFiles( lSubdir ) Local adirs AS ARRAY Local aRet AS ARRAY := {} - Local lLinux := At( 'linux', Os() ) > 0 + Local lLinux := At( 'linux', lower(Os() )) > 0 Local cdir as String := If( !llinux, '\' + Curdir() + '\', '/' + Curdir() + '/' ) Local aStru := { cDir } Local aData AS ARRAY @@ -32,6 +32,7 @@ Function GetSourceFiles( lSubdir ) Local nPos Local xItem Default lSubdir To .t. + While ++ nCounter <= Len( aStru ) If !Empty( adirs := GetDirs( astru[ nCounter ] ) ) // There are elements! @@ -65,6 +66,7 @@ Function GetSourceFiles( lSubdir ) Next Endif Next + For nCounter := 1 To Len( aret ) xItem := Substr( aret[ nCounter ], Rat( If( llinux, "/", '\' ), aret[ nCounter ] ) + 1 ) @@ -114,7 +116,7 @@ Return ctemp Static Function GetDirs( cPattern ) Local aDir := {} - Local lLinux := At( 'linux', Os() ) > 0 + Local lLinux := At( 'linux', lower(Os()) ) > 0 Aeval( Directory( cPattern + "*.", "D" ), ; { | xItem | If( xItem[ 5 ] = "D" .and. ; ( xItem[ 1 ] != "." .and. xItem[ 1 ] != ".." ), ; @@ -201,7 +203,7 @@ Return cPath Function GetSourceDirMacros() Local adirs AS ARRAY - Local lLinux := At( 'linux', Os() ) > 0 + Local lLinux := At( 'linux', lower(Os()) ) > 0 Local cdir as String := If( llinux, '/' + Curdir() + '/', '\' + Curdir() + '\' ) Local aStru := { cDir }