Hi,
By default, buttons in a TBar control are rendered from left to right.
Is it possible to output buttons from right to left?
Hi,
By default, buttons in a TBar control are rendered from left to right.
Is it possible to output buttons from right to left?
METHOD BtnAdjust( lRefresh ) CLASS TBar
聽 聽local n, nGroups := 0, nPopups := 0
聽 聽local l3D := ::l3D .and. ! ( ::l2007 .or. ::l2010 .or. ::l2013 .or. ::l2015)
聽 聽local nRow := If( l3D, 2, -1 )
聽 聽// Inicializamos nCol con el ancho total disponible
聽 聽local nCol := If( l3D, ::oWnd:nWidth - ::nBtnWidth - 2, ::oWnd:nWidth - ::nBtnWidth + 1 )
聽 聽DEFAULT lRefresh := .T.
聽 聽do case
聽 聽 聽 case ::nMode == BAR_TOP .or. ::nMode == BAR_DOWN
聽 聽 聽 聽 聽 聽for n = 1 to Len( ::aControls )
聽 聽 聽 聽 聽 聽 聽 TRY
聽 聽 聽 聽 聽 聽 聽 聽 聽nGroups += If( ::aControls[ n ]:lGroup, 1, 0 )
聽 聽 聽 聽 聽 聽 聽 CATCH
聽 聽 聽 聽 聽 聽 聽 聽 聽// not a btnbmp
聽 聽 聽 聽 聽 聽 聽 END
聽 聽 聽 聽 聽 聽 聽 ::aControls[ n ]:Move( If( l3D, 4, 0 ) - 1,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 nCol + ( nGroups * ::nGroupSep ) + ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 If( ::l2007 .or. ::l2010 .or. ::l2013 .or. ::l2015, 1, 9 ) + ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 ( nPopups * 13 ) )
聽 聽 聽 聽 聽 聽 聽 nPopups += If( ::aControls[ n ]:oPopup != nil, 1, 0 )
聽 聽 聽 聽 聽 聽 聽 ::aControls[ n ]:Refresh()
聽 聽 聽 聽 聽 聽 聽 // Restamos el ancho del bot贸n en vez de sumarlo
聽 聽 聽 聽 聽 聽 聽 nCol 聽 聽-= ::nBtnWidth
聽 聽 聽 聽 聽 聽next
聽 聽 聽 case ::nMode == BAR_LEFT .or. ::nMode == BAR_RIGHT
聽 聽 聽 聽 聽 聽// Para las barras verticales, iniciamos desde arriba pero desde el extremo derecho
聽 聽 聽 聽 聽 聽local nInitialCol := If( l3D, ::oWnd:nWidth - ::nBtnWidth - 3, ::oWnd:nWidth - ::nBtnWidth )
聽 聽 聽 聽 聽 聽for n = 1 to Len( ::aControls )
聽 聽 聽 聽 聽 聽 聽 TRY
聽 聽 聽 聽 聽 聽 聽 聽 聽nGroups += If( ::aControls[ n ]:lGroup, 1, 0 )
聽 聽 聽 聽 聽 聽 聽 CATCH
聽 聽 聽 聽 聽 聽 聽 END
聽 聽 聽 聽 聽 聽 聽 ::aControls[ n ]:Move( nRow + ( nGroups * ::nGroupSep ) + 8,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽nInitialCol )
聽 聽 聽 聽 聽 聽 聽 ::aControls[ n ]:Refresh()
聽 聽 聽 聽 聽 聽 聽 nRow += ::nBtnHeight - If( l3D, 3, -1 )
聽 聽 聽 聽 聽 聽next
聽 聽 聽 case ::nMode == BAR_FLOAT
聽 聽 聽 聽 聽 聽nRow = 0
聽 聽 聽 聽 聽 聽// Iniciamos nCol desde el extremo derecho
聽 聽 聽 聽 聽 聽nCol = ::oWnd:nWidth - ::nBtnWidth
聽 聽 聽 聽 聽 聽for n = 1 to Len( ::aControls )
聽 聽 聽 聽 聽 聽 聽 ::aControls[ n ]:Move( nRow, nCol )
聽 聽 聽 聽 聽 聽 聽 nRow = If( nCol <= 0, nRow + ::nBtnHeight - If( l3D, 5, -1 ), nRow )
聽 聽 聽 聽 聽 聽 聽 // Movemos hacia la izquierda
聽 聽 聽 聽 聽 聽 聽 nCol = If( nCol == ::oWnd:nWidth - ::nBtnWidth, 0, ::oWnd:nWidth - ::nBtnWidth )
聽 聽 聽 聽 聽 聽 聽 if nCol != ::oWnd:nWidth - ::nBtnWidth
聽 聽 聽 聽 聽 聽 聽 聽 聽nCol -= If( ::aControls[ n ]:oPopup != nil, 13, 0 )
聽 聽 聽 聽 聽 聽 聽 endif
聽 聽 聽 聽 聽 聽next
聽 聽endcase
聽 聽::oWnd:Refresh( lRefresh )
return nilMETHOD GetBtnLeft( lNewGroup, nInd ) CLASS TBar
聽 聽local l3D := ::l3D .and. ! ( ::l2007 .or. ::l2010 .or. ::l2013 .or. ::l2015)
聽 聽// Iniciamos desde el extremo derecho de la barra
聽 聽local nPos := ::nWidth - If( l3D, 9, 0 ) - ::nBtnWidth
聽 聽local n
聽 聽do case
聽 聽 聽 case ::nMode == BAR_TOP .or. ::nMode == BAR_DOWN
聽 聽 聽 聽 聽 聽if Len( ::aControls ) > 0
聽 聽 聽 聽 聽 聽 聽 if nInd == nil
聽 聽 聽 聽 聽 聽 聽 聽 聽// Para el 煤ltimo bot贸n, calculamos desde el borde derecho
聽 聽 聽 聽 聽 聽 聽 聽 聽nPos := ::nWidth - ATail( ::aControls ):nWidth - If( l3D, 9, 0 )
聽 聽 聽 聽 聽 聽 聽 else
聽 聽 聽 聽 聽 聽 聽 聽 聽if nInd > 1
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 // Calculamos la posici贸n basada en el bot贸n anterior
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 nPos := ::aControls[ nInd - 1 ]:nLeft - ::nBtnWidth
聽 聽 聽 聽 聽 聽 聽 聽 聽endif
聽 聽 聽 聽 聽 聽 聽 聽 聽// Ajustamos las posiciones de los botones siguientes
聽 聽 聽 聽 聽 聽 聽 聽 聽for n = nInd to Len( ::aControls )
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 ::aControls[ n ]:nRight -= ::nBtnWidth
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 ::aControls[ n ]:nLeft 聽-= ::nBtnWidth
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 if ::aControls[ n ]:lGroup
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽::aControls[ n ]:nRight -= ::nGroupSep
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽::aControls[ n ]:nLeft 聽-= ::nGroupSep
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 endif
聽 聽 聽 聽 聽 聽 聽 聽 聽next
聽 聽 聽 聽 聽 聽 聽 endif
聽 聽 聽 聽 聽 聽endif
聽 聽 聽 聽 聽 聽if lNewGroup != nil .and. lNewGroup
聽 聽 聽 聽 聽 聽 聽 // Ajustamos para nuevo grupo
聽 聽 聽 聽 聽 聽 聽 ++::nGroups
聽 聽 聽 聽 聽 聽 聽 nPos -= ::nGroupSep
聽 聽 聽 聽 聽 聽endif
聽 聽 聽 聽 聽 聽if l3D
聽 聽 聽 聽 聽 聽 聽 // Ajustamos para efecto 3D
聽 聽 聽 聽 聽 聽 聽 nPos -= 2
聽 聽 聽 聽 聽 聽endif
聽 聽 聽 case ::nMode == BAR_LEFT .or. ::nMode == BAR_RIGHT
聽 聽 聽 聽 聽 聽// Para barras verticales, mantenemos el mismo comportamiento pero desde el extremo derecho
聽 聽 聽 聽 聽 聽nPos := ::nWidth - ::nBtnWidth - If( l3D, 2, 0 )
聽 聽 聽 case ::nMode == BAR_FLOAT
聽 聽 聽 聽 聽 聽// Para barras flotantes, calculamos desde el extremo derecho
聽 聽 聽 聽 聽 聽nPos := If( Len( ::aControls ) > 0,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 If( ATail( ::aControls ):nLeft - ::nBtnWidth < 0,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 ::nWidth - ::nBtnWidth, ::nWidth - ( ( Len( ::aControls ) + 1 ) * ::nBtnWidth ) ), ::nWidth - ::nBtnWidth )
聽 聽endcase
return nPosMETHOD GetBtnTop( lNewGroup ) CLASS TBar
聽 聽local l3D 聽 聽 聽:= ::l3D .and. ! ( ::l2007 .or. ::l2010 .or. ::l2013 .or. ::l2015)
聽 聽local nPos 聽 聽 := 0
聽 聽local nButtons := Len( ::aControls )
聽 聽do case
聽 聽 聽 case ::nMode == BAR_TOP .or. ::nMode == BAR_DOWN
聽 聽 聽 聽 聽 聽// Para barras horizontales, mantenemos la misma posici贸n vertical
聽 聽 聽 聽 聽 聽nPos = If( l3D, 3, -1 ) 聽 // 3 --> 2
聽 聽 聽 case ::nMode == BAR_LEFT .or. ::nMode == BAR_RIGHT
聽 聽 聽 聽 聽 聽// Para barras verticales, calculamos desde arriba
聽 聽 聽 聽 聽 聽nPos = If( l3D, 2, 0 ) + ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 ( nButtons * ( ::nBtnHeight - If( l3D, 3, 0 ) ) ) + ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 ( If( lNewGroup, ++::nGroups, ::nGroups ) * ::nGroupSep )
聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽// No es necesario modificar la l贸gica vertical ya que los botones
聽 聽 聽 聽 聽 聽// seguir谩n apil谩ndose de arriba hacia abajo, solo cambiar谩 su
聽 聽 聽 聽 聽 聽// posici贸n horizontal (que se maneja en GetBtnLeft)
聽 聽endcase
return nPosThanks Antonio, everything works !