Antonio Linares wrote:Enrico,
Sorry about this. We have been introducing some changes and it seems as still it requires some fine tunning.
Antonio Linares wrote:Should the text go to the left or to the right if you use RIGHT without a bitmap ?
METHOD PaintCaption() CLASS TBtnBmp
local oRect
local nTextTop, nTextHeight
local nStyle := DT_CENTER + DT_WORDBREAK + DT_TOP // VCenter we do in the code
local nBmpWidth
local nBorderMargin := If( ::lBarBtn, 2, 4 )
local nBmpMargin := 5
local nClr, hOldFont // for painting
local lBmp := !( ::lAdjust .or. Empty( ::hBmp ) ) // Leave space for bmp or not
if ! Empty( ::cCaption )
oRect = ::GetCliRect()
nBmpWidth = If( lBmp, nBmpWidth( ::hBmp ) + nBmpMargin, 0 )
nBmpWidth = Min( oRect:nWidth / 2 - nBorderMargin, nBmpWidth )
WITH OBJECT oRect
// Leave space for nBorderMargin, Space for Bmp and Popup
:nTop += nBorderMargin
:nLeft += ( nBorderMargin + If( ::nLayOut == LAYOUT_LEFT, nBmpWidth, 0 ) ) // BMP LEEFT
:nBottom -= nBorderMargin
:nRight -= ( nBorderMargin + If( ::oPopup == nil, 0, 12 ) + ;
If( ::nLayOut == LAYOUT_RIGHT, nBmpWidth, 0 ) )
END
hOldFont = SelectObject( ::hDC, ::oFont:hFont )
nTextHeight = DrawText( ::hDC, ::cCaption, oRect:aRect, nOr( DT_TOP + DT_CENTER, DT_WORDBREAK, DT_CALCRECT ) )
if ( ! lBmp ) .or. ::nLayOut == LAYOUT_LEFT .or. ::nLayOut == LAYOUT_RIGHT .or. ::nLayOut == LAYOUT_CENTER
// Center vertically if layout is LEFT/RIGHT or NO bitmap
oRect:nTop += Int( ( oRect:nHeight - nTextHeight ) / 2 )
elseif ::nLayOut == LAYOUT_TOP
// When bitmap is on top, paint text at bottom
oRect:nTop = oRect:nBottom - nTextHeight - 1
else
endif
if !lBmp // EMG
oRect:nTop -= 1 // EMG
nStyle = DT_LEFT + DT_WORDBREAK + DT_TOP // EMG
endif // EMG
if ::lPressed
// Move entire rect by one pixel to right and down
oRect:MoveBy( 1, 1 )
endif
// Start painting now
nClr = If( ::IsEnabled(), ::nClrText, If( ::lDisColor, CLR_HGRAY, ::nClrTextDis ) )
SetTextColor( ::hDC, XEval( nClr, ::lMOver ) ) // XEval Evals if nClr is 'B' else returns nClr
SetBkMode( ::hDC, 1 )
DrawText( ::hDC, ::cCaption, oRect:aRect, nStyle )
SelectObject( ::hDC, hOldFont )
// Painting done
endif
return nil
METHOD PaintBitmap() CLASS TBtnBmp
local oBtnRect, oBmpRect, nTextHeight
local nBorderMargin := If( ::lBarBtn, 2, 0 )
local hBmp, nTop, nLeft, nBmpHeight, nBmpWidth, hOldFont
if Empty( ::hBmp )
return nil
endif
oBtnRect := ::GetCliRect()
WITH OBJECT oBtnRect
// Leave space for nBorderMargin, Space for Bmp and Popup
:nTop += nBorderMargin
:nLeft += nBorderMargin
:nBottom -= nBorderMargin
:nRight -= ( nBorderMargin + If( ::oPopup == nil, 0, 12 ) )
END
if ::lAdjust
hBmp = ResizeBitmap( ::hBmp, ::nWidth, ::nHeight )
elseif nBmpWidth( ::hBmp ) > oBtnRect:nWidth .or. nBmpHeight( ::hBmp ) > oBtnRect:nHeight
hBmp = ResizeBitmap( ::hBmp, oBtnRect:nWidth * 1.1, oBtnRect:nHeight * 1.1, 3 ) // shrink to fit
else
hBmp = ::hBmp
endif
nBmpWidth = nBmpWidth( hBmp )
nBmpHeight = nBmpHeight( hBmp )
// Center horizontally and vertically to start with
nTop = oBtnRect:nTop + ( oBtnRect:nHeight - nBmpHeight ) / 2
nLeft = oBtnRect:nLeft + ( oBtnRect:nWidth - nBmpWidth ) / 2
if ! Empty( ::cCaption ) // if there is no caption Bitmap is always centered
hOldFont = SelectObject( ::hDC, ::oFont:hFont )
nTextHeight = DrawText( ::hDC, ::cCaption, oBtnRect:aRect, nOr( DT_CENTER, DT_WORDBREAK, DT_CALCRECT ) )
SelectObject( ::hDC, hOldFont )
do case
case ::nLayOut == LAYOUT_TOP
nTop = oBtnRect:nTop + Max( ( oBtnRect:nHeight - nTextHeight - nBmpHeight ) / 2, 0 )
case ::nLayOut == LAYOUT_LEFT
nLeft = oBtnRect:nLeft + 3 // flush left
case ::nLayOut == LAYOUT_BOTTOM
nTop = oBtnRect:nBottom - ( oBtnRect:nHeight - nTextHeight - nBmpHeight ) / 2
nTop = Min( oBtnRect:nBottom - nBmpHeight, nTop )
case ::nLayOut == LAYOUT_RIGHT
nLeft = oBtnRect:nRight - nBmpWidth - 3 // flush right
endcase
endif
if ::oPopup = nil // EMG
nTop += 2 // EMG
endif // EMG
...
if ::lBarBtn .and. ::oPopup = nil // EMG
nTop += 2 // EMG
endif // EMG
Return to Bugs report & fixes / Informe de errores y arreglos
Users browsing this forum: No registered users and 5 guests