Bug in TBtnBmp [Solved]

User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Bug in TBtnBmp

Post by Antonio Linares »

Enrico,

Quite curious, now I tested here again and its fine :-)

Please test this Class TBtnBmp Method Paint() (warning to other users: this is for testing only, don't use this code yet)

Code: Select all

METHOD Paint() CLASS TBtnBmp

   local aInfo := ::DispBegin()

   local hBmp := If( ::lPressed, If( Empty( ::hBitmap2 ), If( ::lMOver .and. ;
                     ! Empty( ::hBitmap4 ), ::hBitmap4, ::hBitmap1 ),;
                     ::hBitmap2 ), If( ! IsWindowEnabled( ::hWnd ) .and. ;
                     ! Empty( ::hBitmap3 ), ::hBitmap3, If( ::lMOver .and. ;
                     ! Empty( ::hBitmap4 ), ::hBitmap4, ::hBitmap1 ) ) )

   local nBtn := If( ::lPressed, If( Empty( ::hBitmap2 ), If( ::lMOver .and. ;
                     ! Empty( ::hBitmap4 ), 4, 1 ), 2 ),;
                     If( ! IsWindowEnabled( ::hWnd ) .and. ! Empty( ::hBitmap3 ),;
                     3, If( ::lMOver .and. ! Empty( ::hBitmap4 ), 4, 1 ) ) )

   if ::lTransparent
      SetBrushOrgEx( ::hDC, nBmpWidth( ::oWnd:oBrush:hBitmap ) - ::nLeft,;
                     nBmpHeight( ::oWnd:oBrush:hBitmap ) - ::nTop )
      FillRect( ::hDC, GetClientRect( ::hWnd ), ::oWnd:oBrush:hBrush )
   else
      if Empty( ::bClrGrad )
         FillRect( ::hDC, GetClientRect( ::hWnd ), ::oBrush:hBrush )
      else
         if ::aGrad != nil
            GradientFill( ::hDC, 0, 0, ::nHeight, ::nWidth, ::aGrad() )
         endif
      endif   
   endif

   if ! Empty( hBmp )
      if ::lBmpTransparent
         if SetAlpha() .and. ::aAlpha[ nBtn ]
            ABPaint( ::hDC, If( ::lPressed, 1, 0 ), If( ::lPressed, 1, 0 ),;
                     hBmp, ::nAlphaLevel() )
         else
            DrawTransBmp( ::hDC, hBmp, If( ::lPressed, 1, 0 ),;
                          If( ::lPressed, 1, 0 ), ::nWidth, ::nHeight )
         endif
      else
         DrawTransBmp( ::hDC, hBmp, If( ::lPressed, 1, 0 ),;
                       If( ::lPressed, 1, 0 ), ::nWidth, ::nHeight )
      endif
   endif

   ::DispEnd( aInfo )

return nil
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Bug in TBtnBmp

Post by Antonio Linares »

Enrico,

The same one modified as there is no need to call DrawTransBmp() when the bitmap is not going to be used in transparent mode:

Code: Select all

METHOD Paint() CLASS TBtnBmp

   local aInfo := ::DispBegin()

   local hBmp := If( ::lPressed, If( Empty( ::hBitmap2 ), If( ::lMOver .and. ;
                     ! Empty( ::hBitmap4 ), ::hBitmap4, ::hBitmap1 ),;
                     ::hBitmap2 ), If( ! IsWindowEnabled( ::hWnd ) .and. ;
                     ! Empty( ::hBitmap3 ), ::hBitmap3, If( ::lMOver .and. ;
                     ! Empty( ::hBitmap4 ), ::hBitmap4, ::hBitmap1 ) ) )

   local nBtn := If( ::lPressed, If( Empty( ::hBitmap2 ), If( ::lMOver .and. ;
                     ! Empty( ::hBitmap4 ), 4, 1 ), 2 ),;
                     If( ! IsWindowEnabled( ::hWnd ) .and. ! Empty( ::hBitmap3 ),;
                     3, If( ::lMOver .and. ! Empty( ::hBitmap4 ), 4, 1 ) ) )

   if ::lTransparent
      SetBrushOrgEx( ::hDC, nBmpWidth( ::oWnd:oBrush:hBitmap ) - ::nLeft,;
                     nBmpHeight( ::oWnd:oBrush:hBitmap ) - ::nTop )
      FillRect( ::hDC, GetClientRect( ::hWnd ), ::oWnd:oBrush:hBrush )
   else
      if Empty( ::bClrGrad )
         FillRect( ::hDC, GetClientRect( ::hWnd ), ::oBrush:hBrush )
      else
         if ::aGrad != nil
            GradientFill( ::hDC, 0, 0, ::nHeight, ::nWidth, ::aGrad() )
         endif
      endif   
   endif

   if ! Empty( hBmp )
      if ::lBmpTransparent
         if SetAlpha() .and. ::aAlpha[ nBtn ]
            ABPaint( ::hDC, If( ::lPressed, 1, 0 ), If( ::lPressed, 1, 0 ),;
                     hBmp, ::nAlphaLevel() )
         else
            DrawTransBmp( ::hDC, hBmp, If( ::lPressed, 1, 0 ),;
                          If( ::lPressed, 1, 0 ), ::nWidth, ::nHeight )
         endif
      else
         DrawBitmap( ::hDC, hBmp, If( ::lPressed, 1, 0 ),;
                     If( ::lPressed, 1, 0 ), ::nWidth, ::nHeight )
      endif
   endif

   ::DispEnd( aInfo )

return nil
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Bug in TBtnBmp

Post by Enrico Maria Giordano »

Antonio,

no, it doesn't work fine, sorry:

- the bitmap is expanded to fill all the button
- there is no 3d effect
- the bitmap is not centered

EMG
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Bug in TBtnBmp

Post by Antonio Linares »

Enrico,

The above method Paint() works fine here on a window:

Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Bug in TBtnBmp

Post by Antonio Linares »

Enrico,

Yes I know it, its only a test. Its not completed yet. Now I am going to use it from a dialog and there the differences start (and that is what I don't want).

thanks for your testings :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Bug in TBtnBmp

Post by Antonio Linares »

Now, on a dialog the differences begin:

Now searching why that inset border appears

Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Bug in TBtnBmp

Post by Antonio Linares »

Enrico,

Could you please test this Class TBtnBmp Method Paint() (warning: it is not finished yet) and let me know if the results are getting better for you ? :-)

thanks

Code: Select all

METHOD Paint() CLASS TBtnBmp

   local aInfo := ::DispBegin()
   local nTop, nLeft

   local hBmp := If( ::lPressed, If( Empty( ::hBitmap2 ), If( ::lMOver .and. ;
                     ! Empty( ::hBitmap4 ), ::hBitmap4, ::hBitmap1 ),;
                     ::hBitmap2 ), If( ! IsWindowEnabled( ::hWnd ) .and. ;
                     ! Empty( ::hBitmap3 ), ::hBitmap3, If( ::lMOver .and. ;
                     ! Empty( ::hBitmap4 ), ::hBitmap4, ::hBitmap1 ) ) )

   local nBtn := If( ::lPressed, If( Empty( ::hBitmap2 ), If( ::lMOver .and. ;
                     ! Empty( ::hBitmap4 ), 4, 1 ), 2 ),;
                     If( ! IsWindowEnabled( ::hWnd ) .and. ! Empty( ::hBitmap3 ),;
                     3, If( ::lMOver .and. ! Empty( ::hBitmap4 ), 4, 1 ) ) )

   if ::lTransparent
      SetBrushOrgEx( ::hDC, nBmpWidth( ::oWnd:oBrush:hBitmap ) - ::nLeft,;
                     nBmpHeight( ::oWnd:oBrush:hBitmap ) - ::nTop )
      FillRect( ::hDC, GetClientRect( ::hWnd ), ::oWnd:oBrush:hBrush )
   else
      if Empty( ::bClrGrad )
         FillRect( ::hDC, GetClientRect( ::hWnd ), ::oBrush:hBrush )
      else
         if ::aGrad != nil
            GradientFill( ::hDC, 0, 0, ::nHeight, ::nWidth, ::aGrad() )
         endif
      endif   
   endif

   nTop  = ( ::nHeight / 2 ) - ( nBmpHeight( hBmp ) / 2 )
   nLeft = ( ::nWidth / 2 ) - ( nBmpWidth( hBmp ) / 2 )

   if ! Empty( hBmp )
      if ::lBmpTransparent
         if SetAlpha() .and. ::aAlpha[ nBtn ]
            ABPaint( ::hDC, nTop + If( ::lPressed, 1, 0 ),;
                     nLeft + If( ::lPressed, 1, 0 ), hBmp, ::nAlphaLevel() )
         else
            DrawTransBmp( ::hDC, hBmp, nTop + If( ::lPressed, 1, 0 ),;
                          nLeft + If( ::lPressed, 1, 0 ), nBmpWidth( hBmp ),;
                          nBmpHeight( hBmp ) )
         endif
      else
         DrawBitmap( ::hDC, hBmp, nTop + If( ::lPressed, 1, 0 ),;
                     nLeft + If( ::lPressed, 1, 0 ), nBmpWidth( hBmp ),;
                     nBmpHeight( hBmp ) )
      endif
   endif

   ::DispEnd( aInfo )

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Bug in TBtnBmp

Post by Enrico Maria Giordano »

Antonio,

yes it getting better but:

- bitmaps are not painted transparently
- 3D effect is missing
- bitmaps (on dialogs) are not centered

EMG
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Bug in TBtnBmp

Post by Antonio Linares »

Enrico,

I have finally reorganized Class TBtnBmp Method Paint() and now see how it looks :-)

Code: Select all

METHOD Paint() CLASS TBtnBmp

   local aInfo := ::DispBegin()

   ::GetBmp()  

   if ::l2007 .or. ::l2010
      ::PaintBackGroundAs20072010()
   else   
      ::PaintBackGroundStandard()
   endif   

   ::PaintBitmap()

   ::PaintCaption()
   
   ::PaintBorder()
   
   if ::oPopup != nil
      ::PaintPopupSection()
   endif   

   ::DispEnd( aInfo )

return nil
I am sending it to you by email, in case you want to try it. Still it may miss some changes, thus I appreciate your feedback, thanks!
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Bug in TBtnBmp

Post by Enrico Maria Giordano »

Antonio,

it looks better but:

- 3D effect is missing
- bitmaps (on dialogs) are not centered

EMG
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Bug in TBtnBmp

Post by Antonio Linares »

Enrico,

Do you mean 3D effect for buttons on dialogs ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Bug in TBtnBmp

Post by Antonio Linares »

Enrico,

They look like "inset", right ?

Like this one, right ?
http://forums.fivetechsupport.com/viewt ... 82#p161582
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Bug in TBtnBmp

Post by Enrico Maria Giordano »

Antonio,

no, the other way around. :-)

I can send you an image, if you need it.

EMG
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Bug in TBtnBmp

Post by Antonio Linares »

Enrico,

Yes, please post a screenshot, thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply