EDIT_GET_BUTTON when xbrowsing an oTree

EDIT_GET_BUTTON when xbrowsing an oTree

Postby reinaldocrespo » Wed Nov 28, 2012 1:35 am

Hi everyone;

When browsing a tree, I find that :nEditType := EDIT_GET_BUTTON does not work. As in:

Code: Select all  Expand view

   REDEFINE XBROWSE oBrw ID 103 OF oDlg FOOTERS FASTEDIT

   oBrw:SetTree( ::oTree, { "FolderOpen16", "FolderClose16", "Clear16" } )
   ADD TO oBrw DATA oBrw:oTreeItem:Cargo[ 1 ] HEADER "Account"
   ADD TO oBrw DATA oBrw:oTreeItem:Cargo[ 2 ] HEADER "SrvDate"
   ADD TO oBrw DATA oBrw:oTreeItem:Cargo[ 3 ] HEADER "Expected"  PICTURE "999,999,9999.99"
   ADD TO oBrw DATA oBrw:oTreeItem:Cargo[ 4 ] HEADER "Paid"      PICTURE "999,999,999.99"

   WITH OBJECT oBrw

      WITH OBJECT :Paid
     
         :nEditType := EDIT_GET_BUTTON
         :nWidth       := 70
         :nBtnBmp      := 1
         :addResource( "copy16" )
         :bOnPostEdit := { |o,x| oBrw:oTreeItem:Cargo[ _PAID ]:= x , ::ReCalculate() }
         :bEditBlock := { || oBrw:oTreeItem:Cargo[ _PAID ] := ;
               oBrw:oTreeItem:Cargo[ _EXPECTED ],;
               ::ReCalculate() }

      END
...
 


Does not show the button on the cell. Here is screen shot of how it looks (notice it is missing the button on the ":Paid" cell):

Image

Help?


Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: EDIT_GET_BUTTON when xbrowsing an oTree

Postby reinaldocrespo » Wed Nov 28, 2012 2:58 pm

Anyone?

Has anyone been able to show the GET_BUTTON on a cell when xbrowsing a Tree?

Is the EDIT_GET_BUTTON incompatible with Trees on an xbrowse? If so, any ideas for a workaround?


Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: EDIT_GET_BUTTON when xbrowsing an oTree

Postby Rick Lipkin » Wed Nov 28, 2012 4:00 pm

Reinaldo

I know there has been work done on the Edit_Get_Button since FWH 1203 .. I do not use oTree but it appears the code is similar .. For what it is worth, here is an invoicing program that uses similar logic however, in FWH1203 I could not set the size of the button, but understand that has been fixed recently.

Note that the bitmap files are from Resource and not file.

Rick Lipkin

Code: Select all  Expand view

// serial number
ADD oCol to oLbxB AT 8 HEADER 'Serial Num' size 60
oLbxB:aCols[ 8 ]:nEditType  := EDIT_GET_BUTTON
oLbxB:aCols[ 8 ]:bEditBlock := {|row, col, oCol| oLbxB:GoLeftMost(),_SerBrow(;
                       nRepairNumber,;
                       oRsDetail:Fields("Inventory Id"):Value,;
                       oRsDetail:Fields("Qty"):Value,;
                       oRsDetail:Fields("Unique Line"):Value,;
                       oRsDetail,;
                       "","","","","","R","A" ) }  // repair

oLbxB:aCols[ 8 ]:addbmpfile( "zoom2.bmp" )
oLbxB:aCols[ 8 ]:addbmpfile( "adddbf.bmp" )
oLbxB:aCols[ 8 ]:bBmpData := { | lValue | If( oRsDetail:Fields("IsSerial"):Value = .t., 1, 2 ) }
oLbxB:aCols[ 8 ]:lBtnTransparent := .t.

 


Image
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: EDIT_GET_BUTTON when xbrowsing an oTree

Postby reinaldocrespo » Wed Nov 28, 2012 5:36 pm

Actually, I confirmed that nEditType as EDIT_GET_BUTTON does work when xbrowsing a tree. To test I just added this at line #23 to xbrwtree.prg in samples.
Code: Select all  Expand view

   oBrw:Last:nEditType := EDIT_GET_BUTTON
 


The button does show. So I conclude that I must be doing something wrong on my code. I just can't find it. Perhaps the fact that oTree is empty when the xbrowse is first define?

Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: EDIT_GET_BUTTON when xbrowsing an oTree

Postby Rick Lipkin » Wed Nov 28, 2012 5:49 pm

Reinaldo

In my example .. the button only seems to appear when the row is hi-lited .. I tested your code change to xbrwtree.prg and indeed got the button but the first row was hi-lited and in focus.

In your screen shot I could not tell if your browse was in focus ?? ( oLbx:SetFocus() )

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: EDIT_GET_BUTTON when xbrowsing an oTree

Postby reinaldocrespo » Wed Nov 28, 2012 6:03 pm

Rick;

Right. The line must have focus for the button to display. Once the line looses focus, the button is gone. That's ok and it makes sense to me. I'm using EDIT_GET_BUTTON as nEditType browsing arrays and it works as expected. My problem is when browsing this particular oTree. It doesn't matter if the line has focus or not, the button does not appear.

Here is another screenshot with the line having focus:
Image

Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: EDIT_GET_BUTTON when xbrowsing an oTree

Postby Rick Lipkin » Thu Nov 29, 2012 1:54 pm

Reinaldo

Thought about this problem some last night .. I notice that the button is always on the far right side of the field. For 'hoots and grins' try to shift the data in the cell to the left and see what happens ??

It seems that all the examples for a button are on character fields and not numeric ..

Rick Lipkin

Code: Select all  Expand view

oBrw:Paid:nDataStrAlign := AL_LEFT
oBrw:Paid:nHeadStrAlign := AL_LEFT
 
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: EDIT_GET_BUTTON when xbrowsing an oTree

Postby reinaldocrespo » Thu Nov 29, 2012 3:25 pm

HOLY SHIT!

Rick- your post forced to look into an older piece of code further down:
Code: Select all  Expand view

   AEVAL( oBrw:aCols, { |e| e:nDataStrAlign := AL_RIGHT,;
                           e:nEditType := EDIT_GET,;
                           e:cEditPicture := "999,999.99",;
                           e:nFooterType := AGGR_TOTAL,;
                           e:nFootStrAlign := AL_RIGHT,;
                           e:oFooterFont   := oApp():oFont12_bold }, 4, 5 )
 


I was just about to change to AL_RIGHT for AL_LEFT when I realized the next line is the culprit. Notice it is overriding my previous code where I assign EDIT_GET_BUTTON to :nEditType property. Amazing, you made me see it. I was blind but now I see. :-)

Thank you very much,


Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: EDIT_GET_BUTTON when xbrowsing an oTree

Postby Rick Lipkin » Thu Nov 29, 2012 3:35 pm

Reinaldo

You are MOST welcome !! "been there .. done that"

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: EDIT_GET_BUTTON when xbrowsing an oTree

Postby Rick Lipkin » Thu Nov 29, 2012 3:44 pm

Reinaldo

Just curious .. what happens if your customer 'resizes' the form ?? ( pulls a corner and makes the window larger ) I have not found an easy way to re-size the controls :( .

What I have done is re-size my controls one element at a time .. browse, buttons, etc which is impossible.. must be an easier way especially when you have a form embeded in a FOLDEREX or regular Folder.

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: EDIT_GET_BUTTON when xbrowsing an oTree

Postby reinaldocrespo » Thu Nov 29, 2012 4:28 pm

On this screen, as shown on the screen-shot, I actually have a non-modal Dialog from resources inside a mdichild window. On Init of the mdichild oWnd, the dialog is redefined. On window resize, I call a class ::resize() method. Method resize() resizes the dialog, the folders -shown on the right side, and the taskbar shown on the left. No need to resize the xbrowse as it is an oClient of the folder dialog. Here is parts of that the code, I will spare you the oTree details and the SQL code as it has nothing to do with the resizing:

Code: Select all  Expand view

//------------------------------------------------------------------------------
METHOD New( oOwner ) CLASS TBatchPayments
   LOCAL dToday := GetServerDate()
   LOCAL nDaysBack := VAL( GetValFromRepository( "REMITANCE_HISTORY", "DEFAULT_DAYS", "180" ) )

... (some code)
   
   DEFINE WINDOW ::oWnd MDICHILD FROM 0, 0 TO 400, 600 OF oOwner TITLE "Batch Payments detail browser"

RETURN SELF
//------------------------------------------------------------------------------------//
METHOD Show() CLASS TBatchPayments
   LOCAL oSelf := SELF

   ACTIVATE WINDOW ::oWnd MAXIMIZED ON INIT oSelf:DefineDlg() ;
      VALID( !GetKeyState( VK_ESCAPE ) .AND. Lastkey() != 27 .AND. oSelf:End() )

RETURN NIL

//------------------------------------------------------------------------------
METHOD DefineDlg() CLASS TBatchPayments
   LOCAL oSelf := SELF
   LOCAL oFont

   DEFINE FONT oFont NAME "Arial" SIZE 0, -10
   DEFINE DIALOG ::oDlg RESOURCE "GenericDlg_W_LeftPanel" TRANSPARENT OF ::oWnd ;
      COLOR CLR_BLUE, RGB( 240, 240, 240 ) TITLE "Full Remittance Payments" FONT oFont

   REDEFINE FOLDEREX ::oFld OF ::oDlg ID 103 PROMPTS "Detailed Check", "Remittances" DIALOGS "xbrowse", "xBrowse"

   ::CreateCheckBrw( ::oFld:aDialogs[ 1 ] )
   ::CreateRemitsBrw( ::oFld:aDialogs[ 2 ] )

   ::oDlg:bGotFocus := { || ::Resize() }
   ::oDlg:lHelpIcon := .F.

   ::oDlg:bLostFocus := { || ::oDlg:Hide() }

   ACTIVATE DIALOG ::oDlg NOWAIT;
             VALID ( oSelf:End() ) ;
           ON INIT ( oSelf:oTskBar := oSelf:VTaskBarMenu(), oSelf:Resize() )


RETURN NIL

//------------------------------------------------------------------------------
METHOD resize() CLASS TBatchPayments
   LOCAL aClient := GetClientRect ( ::oWnd:hWnd )
   LOCAL nWidth  := aClient[4] - 1
   LOCAL nHeight := aClient[3] //- WndMain():oBar:nHeight - WndMain():oMsgBar:nHeight - 2
   
   ::oDlg:Move( aClient[ 1 ] , 0 ) //+ WndMain():oBar:nHeight, 0 )
   ::oDlg:SetSize( nWidth, nHeight, .T. )

   ::oFld:Move( 0, nGrdleft )
   ::oFld:SetSize( ::oDlg:nWidth - nGrdleft, ::oDlg:nHeight )

   ::oTskBar:Move( 0, 0 )
   ::oTskBar:SetSize( nGrdleft -3, ::oDlg:nHeight, .T. )

RETURN NIL

//------------------------------------------------------------------------------------//
METHOD VTaskBarMenu() CLASS TBatchPayments
   LOCAL oTaskPanel, b, oTsk
   LOCAL oFont, aVals, lRet
   
   ::aGets := ARRAY( 8 )
   
   nGrdleft := 225   //nGrdleft is a static var.
   DEFINE TASKPANEL oTaskPanel SIZE nGrdleft, 1600 ANIMATE OF ::oDlg BUBBLE
   oTaskPanel:oFont := ::oDlg:oFont

   TASKGROUP oTsk PROMPT "Check Details" BITMAP "Remittance24" SPECIAL WATERMARK "WATERMARK"
      @ 10, 01 SAY "Chk Num" PIXEL SIZE 47, 15 RIGHT //FONT oFont
      @ 10, 50 GET ::aGets[ 1 ] VAR ::cCheckNum SIZE 140, 16 PIXEL UPDATE WHEN ::isNew //COLOR CLR_BLUE, RGB( 142, 208, 208 )
         
... (redefines of other controls on the left vertical taskbar)

   ENDTASKGROUP

   TASKGROUP "Actions" SPECIAL WATERMARK "WATERMARK"  BITMAP "RUN24"

      TASKITEM b PROMPT "Start New Remit" BITMAP "New16" TOOLTIP "Save data to remittance."
      b:bAction := { || ::InitNewRemit() }

      TASKITEM b PROMPT "Save Remit"    BITMAP "Save16" TOOLTIP "Save data to remittance. ^S"
      b:bAction := { || ::Save(), ::oBrw:SetFocus() }
     
      TASKITEM b PROMPT "Print Remittance" BITMAP "Printer16" TOOLTIP "Create Report from Remittance Records"
      b:bAction := { || IIF( ::isChanged, MsgStop( "Must save changes before printing report" ), ::Print() ) }

      TASKITEM b PROMPT "Post Remit"    BITMAP "Run16"  TOOLTIP "Commit remittance data to payments table"
      b:bAction := { || ::PostPayments() }

      TASKITEM b PROMPT "Reload Remits" BITMAP "Redo16"  TOOLTIP "Reload remitances list from file"
      b:bAction := { || CursorWait(), ;
                     ::oQ:Run(), ;
                     ( ::oQ:cAlias )->( OrdListRebuild() ), ;
                     CursorArrow(),;
                     ::oRemitsBrw:Refresh(), ;
                     ::oRemitsBrw:GoTop() } //empty tags

      TASKITEM b PROMPT "Search" BITMAP "Search16"  TOOLTIP "Search account or ClaimKey.  F8 to start new search or F3 to search Next"
      b:bAction := { || ::Search() }

      TASKITEM b PROMPT "Expand All"    BITMAP "FolderOpen16"  TOOLTIP "Exapand all claimkey detailed lines. F9"
      b:bAction := { || ::oBrw:oTree:Expand(), ::oBrw:Refresh(), ::oBrw:SetFocus() }

      TASKITEM b PROMPT "Collapse All"  BITMAP "FolderClose16"  TOOLTIP "Collapse all claimkey detailed lines. F10"
      b:bAction := { || ::oBrw:oTree:Collapse(), ::oBrw:Refresh(), ::oBrw:SetFocus() }

   ENDTASKGROUP

   TASKGROUP "Remittances Period" SPECIAL WATERMARK "WATERMARK"  BITMAP "Calendar24"

      @ 10, 01 SAY "From" PIXEL SIZE 47, 15 RIGHT FONT oFont

      @ 10, 50 GET ::dFrom SIZE 90, 16 PIXEL UPDATE ;
            VALID( ::oQ:aParameters := { DTOC( ::dFrom ), DTOC( ::dThru ) }, .t. )
           
      @ 25, 01 SAY "Thru" PIXEL SIZE 47, 15 RIGHT FONT oFont

      @ 25, 50 GET ::dThru SIZE 90, 16 PIXEL UPDATE ;
            VALID( ::oQ:aParameters := { DTOC( ::dFrom ), DTOC( ::dThru ) }, .t. )

   ENDTASKGROUP

   ENDTASKPANEL

RETURN oTaskPanel

 

Image

I will gladly send you the whole class for your review if you prefer that.




Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: EDIT_GET_BUTTON when xbrowsing an oTree

Postby Rick Lipkin » Thu Nov 29, 2012 4:59 pm

Reinaldo

Kinda 'ole skool' :roll: here .. Take a look at what I have done .. this code is similar without the Folders, but it is a MdiCHild with a non-modal dialog from resources. I made the decision to only resize the xBrowse control because re-sizing each was not practical ..

Review the code snipits and make some suggestions if you can... notice the Resize in the Activate Window clause... Sorry if the code seems 'brutal'

Thanks
Rick Lipkin

Code: Select all  Expand view

DEFINE WINDOW oWndChildB           ;
       FROM 0,0 to 39,120          ;
       MDICHILD                    ;
       OF oWnd                     ;
       ICON oIco                   ;
       TITLE xTITLE

       DEFINE DIALOG oWorkB RESOURCE "QUIKVIEW" of oWndChildB

       REDEFINE xBROWSE oLBXB        ;
         RECORDSET oRsInvDetail      ;
         COLUMNS "QTY",              ;
                 "INVENTORY ID",     ;
                 "INVENTORY TYPE",   ;
                 "ITEM DESCRIPTION", ;
                 "PRICE",            ;
                 "LOCATION",         ;
                 "COVERED BY WARRANTY" ;
         COLSIZES 45,120,70,328,65,80,50   ;
         HEADERS "Qty",              ;
                 "Part Number",      ;
                 "Type",             ;
                 "Description",      ;
                 "Price",            ;
                 "Location",         ;
                 "Warranty"          ;
         ID 172 of oWorkB            ;
       AUTOCOLS LINES CELL FASTEDIT


... code

 ACTIVATE DIALOG oWorkB NOMODAL ;
                ON INIT _ReCalcTotals(oRsInvDetail,oRsInv,@lTaxable,oTaxable,,oLbxB,;
                         oLabor,oParts,oMisc,oTax,oTotal,nTaxNumber,oOther,oSubtotal ) ;
                VALID(!GETKEYSTATE( 27 ))

ACTIVATE WINDOW oWndChildB ;
   ON INIT ( oWorkB:Move( 0,0, oWndchildB:nWidth, oWndchildB:nHeight, .T. ), oLbxB:SetFocus(), ;
           oWndChildB:bResized := {|| _ReSizeUm( oWorkB,oWndChildB,oLbxB) }, ;
           oWorkB:refresh(.t.));
   VALID ( IIF( !lOK, ExitPgm(.T.,oWndChildB,oRsInvDetail,oRsEmp,oWndChildA,oLbxb,@lOk,;
                                  oRsInv,cLoc,@lClosed ), .F. ))

//------------------------------
Static Func _ReSizeUm( oWorkB1,oWndChildB1,oLbxB1 )

oWorkB1:SetSize( oWndChildB1:nWidth, oWndChildB1:nHeight, .t. ) // frame and dialog link

// dialog controls
oWorkB1:bResized = { | nSizeType, nWidth, nHeight | ResizeControls( nSizeType, nWidth, nHeight, oWorkB1 )  }

oLbxB1:SetFocus()

Return(nil)

//-------------------------
Static Func ResizeControls( nSizeType, nWidth, nHeight, oWorkB1 )


if nSizeType = 0 //SIZE_MAXIMIZED

   oWorkB1:aControls[ 1 ]:SetSize( nWidth - 170, nHeight - 295 ) //txbrowse

endif

Return(nil)

 
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 113 guests