Bug in TBtnBmp [Solved]

Re: Bug in TBtnBmp

Postby Antonio Linares » Sun Jun 29, 2014 9:50 pm

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  Expand view
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: 41205
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in TBtnBmp

Postby Antonio Linares » Sun Jun 29, 2014 9:54 pm

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  Expand view
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
Antonio Linares
Site Admin
 
Posts: 41205
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in TBtnBmp

Postby Enrico Maria Giordano » Sun Jun 29, 2014 9:58 pm

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
Enrico Maria Giordano
 
Posts: 8243
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in TBtnBmp

Postby Antonio Linares » Sun Jun 29, 2014 9:59 pm

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: 41205
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in TBtnBmp

Postby Antonio Linares » Sun Jun 29, 2014 10:01 pm

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: 41205
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in TBtnBmp

Postby Antonio Linares » Sun Jun 29, 2014 10:12 pm

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: 41205
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in TBtnBmp

Postby Antonio Linares » Wed Jul 02, 2014 5:18 am

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  Expand view
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
Antonio Linares
Site Admin
 
Posts: 41205
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in TBtnBmp

Postby Enrico Maria Giordano » Wed Jul 02, 2014 7:48 am

Antonio,

yes it getting better but:

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

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8243
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in TBtnBmp

Postby Antonio Linares » Thu Jul 10, 2014 4:22 am

Enrico,

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

Code: Select all  Expand view
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
Antonio Linares
Site Admin
 
Posts: 41205
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in TBtnBmp

Postby Enrico Maria Giordano » Thu Jul 10, 2014 7:55 am

Antonio,

it looks better but:

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

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8243
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in TBtnBmp

Postby Antonio Linares » Thu Jul 10, 2014 1:45 pm

Enrico,

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

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

Re: Bug in TBtnBmp

Postby Enrico Maria Giordano » Thu Jul 10, 2014 2:19 pm

Antonio,

yes, Sir, exactly! :-)

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8243
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in TBtnBmp

Postby Antonio Linares » Thu Jul 10, 2014 11:11 pm

Enrico,

They look like "inset", right ?

Like this one, right ?
viewtopic.php?p=161582#p161582
regards, saludos

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

Re: Bug in TBtnBmp

Postby Enrico Maria Giordano » Fri Jul 11, 2014 8:09 am

Antonio,

no, the other way around. :-)

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

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8243
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in TBtnBmp

Postby Antonio Linares » Sat Jul 12, 2014 9:44 am

Enrico,

Yes, please post a screenshot, thanks
regards, saludos

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

PreviousNext

Return to Bugs report & fixes / Informe de errores y arreglos

Who is online

Users browsing this forum: No registered users and 3 guests