New Control

New Control

Postby Marcelo Via Giglio » Sat May 17, 2014 8:16 pm

Hello,

I don't know the name for this control, it is in pre-alpha state

Code: Select all  Expand view

#Include "FiveWin.Ch"
#include "xbrowse.ch"

Function Main()
   Local oDlg
   Local oGet, oGet1, oCb
   local cVar := space( 20 )
   local a := {}

   USE customer NEW
   customer -> ( DBEVAL( {|| AADD( a, field -> street ) } ) )

   DEFINE DIALOG oDlg from 0,0 to 400,400 pixel
   
   oGet := tListGet():new(15,15,{ | u | If( PCount()==0, cVar, cVar:= u ) },oDlg,120,12,"@!",,,,,,,.T.)
     
   @ 29,15 get oGet1 var cVar picture "@!" size 120,12 of oDlg pixel

   @ 43,15 COMBOBOX oCb ITEMS a OF oDlg pixel SIZE 120,100

   oGet:aSource  := a
   oGet:bSearch  := {|i,e| AT( i, UPPER(e) ) > 0 }
   oGet:cSource  := 'ARRAY'
   oGet:lenDisplay := 15
   
   ACTIVATE DIALOG oDlg
 
   USE

return nil

//---------------------------------------------------------------

CLASS tListGet FROM tGet

   DATA   oBrw, oWin, aData, lenBuffer, bSearch, aSource, cSource, cField, cAlias, lenDisplay

   METHOD new() CONSTRUCTOR
   METHOD redefine() CONSTRUCTOR
   METHOD FillList()
   METHOD Initiate()
   METHOD keyDown()
   METHOD keychar()

ENDCLASS

//---------------------------------------------------------------
METHOD New( nRow, nCol, bSetGet, oWnd, nWidth, nHeight, cPict, bValid,;
            nClrFore, nClrBack, oFont, lDesign, oCursor, lPixel, cMsg,;
            lUpdate, bWhen, lCenter, lRight, bChanged, lReadOnly,;
            lPassword, lNoBorder, nHelpId, lSpinner,;
            bUp, bDown, bMin, bMax, bAction, cBmpName, cVarName, cCueText ) CLASS tListGet 
//---------------------------------------------------------------

RETURN ::super:new( nRow, nCol, bSetGet, oWnd, nWidth, nHeight, cPict, bValid,;
            nClrFore, nClrBack, oFont, lDesign, oCursor, lPixel, cMsg,;
            lUpdate, bWhen, lCenter, lRight, bChanged, lReadOnly,;
            lPassword, lNoBorder, nHelpId, lSpinner,;
            bUp, bDown, bMin, bMax, bAction, cBmpName, cVarName, cCueText )
//---------------------------------------------------------------

METHOD ReDefine( nId, bSetGet, oWnd, nHelpId, cPict, bValid, nClrFore,;
                 nClrBack, oFont, oCursor, cMsg, lUpdate, bWhen, bChanged,;
                 lReadOnly, lSpinner, bUp, bDown, bMin, bMax, bAction, cBmpName,;
                 cVarName, cCueText ) CLASS tListGet
//---------------------------------------------------------------

RETURN ::super:ReDefine( nId, bSetGet, oWnd, nHelpId, cPict, bValid, nClrFore,;
                 nClrBack, oFont, oCursor, cMsg, lUpdate, bWhen, bChanged,;
                 lReadOnly, lSpinner, bUp, bDown, bMin, bMax, bAction, cBmpName,;
                 cVarName, cCueText )
   
//---------------------------------------------------------------
METHOD Initiate( hDlg ) CLASS TListGet
//---------------------------------------------------------------
LOCAL oSelf := SELF, aRect

   ::super:Initiate( hDlg )

   ::lenBuffer          := LEN( cValToChar( Eval( ::bSetGet ) ) )
   ::aData              := ARRAY(1)
   DEFAULT ::lenDisplay := 5

   DEFINE DIALOG ::oWin OF oSelf:oWnd FROM 100, 100 TO 100, 100 + ::nWidth PIXEL STYLE nOR( WS_CHILD, WS_POPUP, WS_VISIBLE )

   @ 0, 0 XBROWSE ::oBrw OF oSelf:oWin ARRAY oSelf:aData COLUMNS 1 SIZEs ::nWidth

   ::oBrw:lHeader         := .F.
   ::oBrw:lRecordSelector := .F.
   ::oBrw:lFlatStyle      := .T.
   ::oBrw:nStyle    -= WS_BORDER
   ::oWin:oClient   := ::oBrw
   ::oBrw:bChange   := {|| ::cText( PADR( ::aData[ ::oBrw:nArrayAt ], ::lenBuffer, ' ' ) ), ::refresh(), ::SetPos( LEN( ALLTRIM( ::aData[ ::oBrw:nArrayAt ] ) ) + 1 ), ::setFocus() }
   ::oBrw:bLClicked := {|| ::oWin:hide() }
   ::oBrw:lHScroll  := .F.
   ::oBrw:lVScroll  := .F.
   ::oBrw:createFromCode()
 
   ::bPostKey     := {|oGet, cBuffer| ;
              IF( EMPTY( cBuffer ), ::oWin:hide(), NIL  ),;
                      oGet:aData[1] := cBuffer, ;
              oGet:Assign(), ;
              ::FillList() }
               
  ACTIVATE DIALOG oSelf:oWin NOWAIT ON INIT oSelf:oWin:hide()

  ::oWnd:bMoved := {|| ::oWin:hide() }

return nil

//---------------------------------------------------------------
METHOD FillList() CLASS TListGet
//---------------------------------------------------------------
LOCAL i := 1, aRect

       ASIZE( ::aData, 1 )
       DO CASE
          CASE ::cSource = 'ARRAY'
               DO WHILE  LEN( ::aData ) < ::lenDisplay .AND. i <= LEN( ::aSource )
                  IF EVAL( ::bSearch, ALLTRIM(::aData[1]), ::aSource[i] )
                 AADD( ::aData, ::aSource[i] )
              ENDIF
                  i++
               ENDDO
           ::oWin:SetSize( ::oWin:nWidth, ( LEN( ::aData ) ) * GetTextHeight( ::hWnd ) + LEN( ::aData ) )
               aRect := getWndRect( ::hWnd )
           ::oWin:move( aRect[1] + ::nHeight + 3, aRect[2] )
           ::oWin:show()
          CASE ::cSource = 'DBF'
               (::cAlias) -> ( DBGOTOP() )
               DO WHILE  LEN( ::aData ) < ::lenDisplay .AND. ! (::cAlias)-> ( EOF() )
                  IF EVAL( ::bSearch, ALLTRIM(::aData[1]), (::cAlias)-> ( fieldGet( fieldPos( ::cField ) ) ) )
                 AADD( ::aData, (::cAlias)-> ( fieldGet( fieldPos( ::cField ) ) ) )
              ENDIF
                  i++
               ENDDO
       ENDCASE

       ::oBrw:refresh()

RETURN NIL

//---------------------------------------------------------------
METHOD KeyDown( nKey, nFlags ) CLASS TListGet
//---------------------------------------------------------------

   IF ::oWin:lVisible
      DO CASE
         CASE nKey == VK_UP
          ::oBrw:GoUp()
          RETURN 0

         CASE nKey == VK_DOWN
          ::oBrw:GoDown()
          RETURN 0
      ENDCASE
   ENDIF

   IF nKey == VK_DELETE .or. nKey == VK_BACK
      Super:KeyDown( nKey, nFlags )
      ::aData[1] := ::cText()
      IF( EMPTY( ::aData[1] ), ::oWin:hide(), ::FillList() )
      RETURN 0
   ENDIF  

RETURN Super:KeyDown( nKey, nFlags )

//---------------------------------------------------------------
METHOD keychar( nKey, nFlags ) CLASS TListGet
//---------------------------------------------------------------

           IF nKey == VK_RETURN .AND. ::oWin:lVisible
          ::oWin:hide()
       ENDIF
       
RETURN super:keychar( nkey, nFlags )
 
Marcelo Via Giglio
 
Posts: 1064
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: New Control

Postby Marcelo Via Giglio » Sun May 18, 2014 3:42 am

Marcelo Via Giglio
 
Posts: 1064
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: New Control

Postby emotta_no » Mon May 19, 2014 5:18 pm

Gracias !!!
emotta_no
 
Posts: 33
Joined: Thu Jul 04, 2013 9:28 pm

Re: New Control

Postby elvira » Tue May 20, 2014 1:53 pm

Great!!!.

Please, also check:
viewtopic.php?f=3&t=21772&hilit=autoget
elvira
 
Posts: 516
Joined: Fri Jun 29, 2012 12:49 pm

Re: New Control

Postby elvira » Sat Jun 28, 2014 10:01 pm

Marcelo,

Do you have a recent version?.

When defining ACTION (bAction) in the get does not show the button.

Thanks :D :D
elvira
 
Posts: 516
Joined: Fri Jun 29, 2012 12:49 pm

Re: New Control

Postby Maurizio » Fri Jul 11, 2014 9:23 am

Thank Marcelo

do you have tlistget.ch ?

Maurizio
User avatar
Maurizio
 
Posts: 824
Joined: Mon Oct 10, 2005 1:29 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 61 guests