Page 1 of 1

Possible a text-adjust of BTNBMP NO image ?

PostPosted: Fri Feb 20, 2015 1:03 pm
by ukoenig
Hello,

is it possible to adjust the prompt of BTNBMP without using a image ( to the left ) ?
I noticed the text is always centered without using a image.
TOP, LEFT, BOTTOM and RIGHT belongs to a button-image.
I need the Prompt-text adjusted to the LEFT ( NO IMAGE used ),
near to a painted image ( right border ).
Maybe as well right adjusted using a left Image-border.
It means buttons ( visible text ) be painted closed to a defined area

A sample

Image

best regards
Uwe :?:

Re: Possible a text-adjust of BTNBMP without a image ?

PostPosted: Fri Feb 20, 2015 1:33 pm
by karinha
Maybe:

Code: Select all  Expand view

   oBtn:BtnAdjust()
   oBtn:Refresh()
 


Regards


Re: Possible a text-adjust of BTNBMP NO image ?

PostPosted: Fri Feb 20, 2015 5:00 pm
by nageswaragunupudi
Please do not specify any prompt or bitmap and use oBtn:bPainted to draw the prompt as you want.

Re: Possible a text-adjust of BTNBMP NO image ?

PostPosted: Sat Feb 21, 2015 12:15 am
by ukoenig
searching in class TBTNBMP I found this part :

defined caption
NO image
nLayout := 2
result => nTxtLeft := 4


if ! Empty( ::cCaption )
--- case ::nLayOut == 2 // left
------if ::lAdjust
---------nTxtLeft := 4
------else
---------if !empty( hBmp )
------------nTxtLeft := nBmpLeft + nBmpWidth + 4
------------nLayOut := 4
-------- else
----------- nTxtLeft := 4
--------endif

tested, but no result

Code: Select all  Expand view

if ! Empty( ::cCaption )
         DEFAULT ::nLayOut := 1
         do case
              ...
              ...
               case ::nLayOut == 2 // left
               nTxtTop := ::nHeight / 2 - ( ::nGetChrHeight() * nLine ) / 2
               if ::lAdjust
                  nTxtLeft := 4
               else
                  if !empty( hBmp )
                     nTxtLeft := nBmpLeft + nBmpWidth + 4
                     nLayOut := 4
                  else
                     nTxtLeft :=  4
                  endif
            endif
            ...
            ...
 


best regards
Uwe :?:

Re: Possible a text-adjust of BTNBMP NO image ?

PostPosted: Sat Feb 21, 2015 12:54 am
by nageswaragunupudi
Code: Select all  Expand view
function TryThis()

   local oDlg, oFont, oBtn, oBrush

   DEFINE BRUSH oBrush FILE "penguins.jpg" RESIZE // use any jpg
   DEFINE FONT oFont NAME "VERDANA" SIZE 0,-20 BOLD
   DEFINE DIALOG oDlg SIZE 500,400 PIXEL BRUSH oBrush

   @ 60,30 BTNBMP oBtn SIZE 200,20 PIXEL OF oDlg TRANSPARENT
   oBtn:bPainted := { || oBtn:Say( 4,10,"Button Prompt", CLR_YELLOW, nil, oFont, .t., .t. ) }

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont
   RELEASE BRUSH oBrush

return nil
 

Re: Possible a text-adjust of BTNBMP NO image ?

PostPosted: Sat Feb 21, 2015 1:12 am
by ukoenig
Thank You very much,

I still found another solution never tested before.
Only these two lines needed ?

@ 220, 218 BTNBMP oBtn[9] OF oDlg ;
SIZE 55, 25 PIXEL 2007 ;
NOBORDER ;
PROMPT "&Exit" ;
ACTION oDlg:End() ;
FONT oFont1 ;
LEFT
oBtn[9]:nLayOut := 4
oBtn[9]:lAdjust := .T.

oBtn[9]:lTransparent := .t.
oBtn[9]:cToolTip = { "Exit" + CRLF + "Color","Color-Selection", 1, CLR_BLACK, 14089979 }
oBtn[9]:nClrText := { | lMouseOver | If( lMouseOver, 0, 0 ) }

Image

best regards
Uwe :?:

Re: Possible a text-adjust of BTNBMP NO image ?

PostPosted: Sat Feb 21, 2015 1:16 am
by nageswaragunupudi
May I know which version are you using?
I request you not to depend on internals.
When there is no bitmap, prompt is centered in all cases.( v 15.01 )
Please follow my suggested solution.

Re: Possible a text-adjust of BTNBMP NO image ?

PostPosted: Sat Feb 21, 2015 1:23 am
by ukoenig
I only included BTNBMP.prg from FWH /Source-directory
in my MAKE-file without any changes after viewing the file.

I'm using the latest FWH-release.

best regards
Uwe :)

Re: Possible a text-adjust of BTNBMP NO image ?

PostPosted: Sat Feb 21, 2015 1:35 am
by ukoenig
Funny !

I deleted BTNBMP from my MAKE-file, to test the original release.
It doesn't work anymore !!!

Is BTNBMP.prg from directory /source different to the compiled release ( libs ) ?

FiveH.lib => 22.12.14
FiveHC.lib =>16.12.14
Five.Hx.lib => 22.12.14
BtnBmp.prg => 16.12.14

Best regards
Uwe :?:

Re: Possible a text-adjust of BTNBMP NO image ?

PostPosted: Sat Feb 21, 2015 5:16 am
by nageswaragunupudi
Is BTNBMP.prg from directory /source different to the compiled release ( libs ) ?

No.

Re: Possible a text-adjust of BTNBMP NO image ?

PostPosted: Sat Feb 21, 2015 1:31 pm
by ukoenig
Mr. Rao,

I tested Your sample, but there is NO prompt displayed
Using it inside my tools, it will be a problem in case it works only with January 2015
I'm trying to get everything working also using older FWH-versions.

Image

Code: Select all  Expand view

#include "fivewin.ch"
 
STATIC c_path, c_path1
 
FUNCTION MAIN()
local oDlg, oFont, oBtn, oBrush
 
SETBALLOON( .T. )
 
c_path := cFilePath(GetModuleFileName( GetInstance() ) )
c_path1 := c_Path + "BITMAPS\"

DEFINE BRUSH oBrush FILE c_path1 + "
Picture3.jpg" RESIZE // use any jpg
DEFINE FONT oFont NAME "
VERDANA" SIZE 0,-20 BOLD
DEFINE DIALOG oDlg SIZE 500,400 PIXEL BRUSH oBrush TITLE "
  FiveWin  Version: " + FWVERSION

@ 60,30 BTNBMP oBtn SIZE 200,20 PIXEL OF oDlg TRANSPARENT
oBtn:bPainted := { || oBtn:Say( 4,10,"
Button Prompt", CLR_YELLOW, nil, oFont, .t., .t. ) }

ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
RELEASE BRUSH oBrush

RETURN NIL


Maybe a release-problem ?

January 2015
============


* Enhancements to TBtnBmp class:
(a) FILE or RESOURCE clauses can be used to load bmpfiles or resources.
(b) Uses ReadPalBmpEx() to read/load image files/resources, so any bitmap
source can be used.
(c) Where the image is too large, it is resized to fit the size of the button
(d) When ButtonBar is created with 2013 style, BtnBmp class is recoginzing it as
pre-2007 style. Now fixed.
(e) Improved painting of Grayed bitmaps
(f) Improved quality of painting non-transparent images where lBmpTransparent is .f.
(g) There was some deteoration ofquality of painting of bitmaps on pre-2007 style
buttons. Now fixed
(h) BtnBmp now supports :bPainted.

best regards
Uwe :?:

Re: Possible a text-adjust of BTNBMP NO image ?

PostPosted: Sat Feb 21, 2015 1:41 pm
by Enrico Maria Giordano
Uwe,

Your sample works fine here.

EMG

Re: Possible a text-adjust of BTNBMP NO image ?

PostPosted: Sat Feb 21, 2015 1:45 pm
by ukoenig
Enrico,

I just updated to 15.1 and It is working now
Very often I don't want to show any images.
Thanks to Mr. Rao for the info.

added :

@ 90,30 BTNBMP oBtn2 SIZE 200,20 PIXEL OF oDlg TRANSPARENT
oBtn2:bPainted := { || ( nColor := If( oBtn2:lMOver, 255, CLR_YELLOW ), ;
oBtn2:Say( 4,10,"Mouse over", nColor, nil, oFont, .t., .t. ) ) }


Image

best regards
Uwe :)

Re: Possible a text-adjust of BTNBMP NO image ?

PostPosted: Sun Feb 22, 2015 12:24 pm
by ukoenig
Mr. Rao,

is it possible, to add a ACCELERATOR like on a normal button ?

oBtn:bPainted := { || ( nColor := If( oBtn:lMOver, 255, 0 ), ;
oBtn:Say( 5, 5, "Test", nColor, NIL, oFont, .T., .T. ) ) }


instead of a normal text, I added a second button-column
getting a image- AND text-change on focus.
A accelerator would make it perfect

Image

best regards
Uwe :?:

Re: Possible a text-adjust of BTNBMP NO image ?

PostPosted: Sun Feb 22, 2015 3:01 pm
by ukoenig
I added some lines in class BTNBMP ( NO other changes !!! )
for a missing prompt-adjustment with NO images.
Maybe possible, to include them ?
After many tests, I coudn't detect any problems.
The change keeps everything like accelerators and style 2007 as well the other paintings.

only one line to be added for buttons without images :

oBtn:nLayOut := 2 or 4 // left or right
or
oBtn:nLayOut := 0 // centered text
TOP and BOTTOM not needed.

DOWNLOD samples 1.1 MB ( EXE and PRG )
http://www.pflegeplus.com/DOWNLOADS/Btnprompt.zip

Please copy BtnBmp.prg from the /Source -directory to the install-dir and add these lines !!!
( release 15.1 tested )

Code: Select all  Expand view

METHOD PaintCaption() CLASS TBtnBmp
..
..
  if ! Empty( ::cCaption )

    If ::nLayOut == LAYOUT_LEFT
              nStyle   := DT_LEFT + DT_WORDBREAK + DT_TOP  
    elseif ::nLayOut == LAYOUT_RIGHT
              nStyle   := DT_RIGHT + DT_WORDBREAK + DT_TOP  
    endif
 


Tested ALL possible combinations after adding the new lines
I noticed maybe BOTTOM needs a little adjustment.


Image

best regards
Uwe :?: