Sample ==> Vertical-Button-Text ( => Rochinha )

Sample ==> Vertical-Button-Text ( => Rochinha )

Postby ukoenig » Fri Sep 12, 2008 1:16 pm

Hello,

A working-sample, to create Buttons ( BMP ) with vertical-text.

Image

Code: Select all  Expand view

oProgFont   := TFont():New("Arial", ,-14,.F.,.F., , , ,.F.)
oBfont1   := TFont():New("MS Sans Serif", ,-16, .F. ,.T., , , ,.F.)

DEFINE DIALOG oDlg RESOURCE "Tools" OF oWnd ;
TITLE  "BMP-Buttons" FONT oProgFont

// Test.BMP ( Brush not used )

REDEFINE BITMAP oBmp4  ID 210 ADJUST RESOURCE "Blanc"  OF oDlg
oBmp4:bLClicked := {|| MsgAlert( "Your Function 1" ) }
oBmp4:bMMoved := { || cursorhand() }

oBMP4:bPainted := { |hDC|OnPaintV( hDC,oBMP4, ;
13003573,15779475,0, ;
"Vertical  Button", oBfont1, 0 ,"TEST.BMP" ,4 ) }

REDEFINE BITMAP oBmp5  ID 220 ADJUST RESOURCE "Blanc"  OF oDlg
oBmp5:bLClicked := {|| MsgAlert( "Your Function 2" ) }
oBmp5:bMMoved := { || cursorhand() }

oBMP5:bPainted := { |hDC|OnPaintV( hDC,oBMP5, ;
13003573,15779475,0, ;
"Vertical  Button", oBfont1, 0 ,"TEST.BMP" ,4 ) }

REDEFINE BITMAP oBmp6  ID 230 ADJUST RESOURCE "Blanc"  OF oDlg
oBmp6:bLClicked := {|| MsgAlert( "Your Function 3" ) }
oBmp6:bMMoved := { || cursorhand() }

oBMP6:bPainted := { |hDC|OnPaintV( hDC,oBMP6, ;
13003573,15779475,0, ;
"Vertical  Button", oBfont1, 0 ,"TEST.BMP" ,4 ) }

ACTIVATE DIALOG oDlg CENTERED NOWAIT ;
ON INIT ( oDlg:Move( 70 , 50, oDlg:nWidth, oDlg:nHeight, .f.,) )

RETURN NIL   

//-------------------  VERTICAL ---------------------------------------------// 

FUNCTION ONPAINTV(hDC,oBmp,nVColor, nBColor,nColor,cText, ;
                     oBfont1,nLEFT, cBRUSH, nPEN)
LOCAL hOldFont, oNewbrush

xDFONT :=  e_oBfont1
hOldFont := SelectObject( hDC, oBfont1:hFont )
nTOP := 5
nTXTLG :=  GettextWidth( hDC, cText )

nBMPWIDTH  := oBmp:Super:nWidth()
nBMPLONG   := oBmp:Super:nHeight()

nFONTHIGHT := oBfont1:nInpHeight * -1
nFONTWIDTH := INT( e_oBfont1:nSize() )

nLEFT := (nBMPWIDTH - nTXTLG) / 2
aRect := GETCLIENTRECT( oBmp:hWnd )
// .T.  Horizontal
nGRADIENT := Gradient( hDC, aRect, nVColor, nBColor, .T. )
oBmp:oBrush := TBrush():New( , nGRADIENT ) 
FillRect( hDC, aRect, oBmp:oBrush:hBrush )
SetBkMode( hDC, 0 )   // 1 = Transparent
SetTextColor( hDC,nColor)
nTOP := nFONTHIGHT / 2
i := 1
nBMPWIDTH1 := nBMPWIDTH / 2
FOR i := 1 to len(cTEXT)
     cCHAR := SUBSTR(cTEXT,i,1)
     nCharWidth := GettextWidth( hDC, cCHAR )
     TextOut( hDC, nTOP, nBMPWIDTH1 - ( nCharWidth / 2 ),  cCHAR )
     IF !empty(cCHAR)
            nTOP := nTOP + nFONTHIGHT
     ELSE
            nTOP := nTOP + ( nFONTHIGHT / 2 )
     ENDIF
NEXT
SelectObject( hDC, hOldFont )

nColor1 := 128  // Border-Color
IF nPEN > 0
   DRAWBOX( aRect, hDC, nColor1, ;
   nBMPLONG, nBMPWIDTH, nPEN )
ENDIF

RETURN NIL

// ----------------------------------------

STATIC FUNCTION DRAWBOX( aRect, hDC, nColor1, ;
nBMPLONG, nBMPWIDHT, nPEN )
LOCAL hPen := CREATEPEN( PS_SOLID, nPEN, nColor1 )
LOCAL hOldPen := SELECTOBJECT( hDC, hPen )

MOVETO( hDC, 0, 0 )

LINETO( hDC, nBMPLONG, 0 )
LINETO( hDC, nBMPWIDHT, nBMPLONG )
LINETO( hDC, 0, nBMPLONG )
LINETO( hDC, 0, 0 )

DELETEOBJECT( hPen )

RETURN NIL



Regards
Uwe :lol:
Last edited by ukoenig on Fri Sep 12, 2008 1:47 pm, edited 3 times in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Postby James Bott » Fri Sep 12, 2008 1:21 pm

Uwe,

Well done!

However, I must say it seems much harder to read vertical text than horizontal text. Personally, I would avoid using vertical buttons.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Vertical Text

Postby ukoenig » Fri Sep 12, 2008 1:24 pm

Hello James,

It was just a special question from Rochinha to do this.
Maybe it helps.

I would be nice, to have a < Button-effect > for Bitmaps.
oBmp:bLClicked := {|| MsgAlert( "Your Function" ) }
maybe it is possible, to add something in method < bLClicked >
changing bitmap-position a few pixel on mouse-click ?

Regards
Uwe :lol:
Last edited by ukoenig on Fri Sep 12, 2008 2:17 pm, edited 1 time in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Postby James Bott » Fri Sep 12, 2008 1:44 pm

Uwe,

>It was just a special question from Rochinha to do this.

Yes, I saw the other message. It is just that when you actually see an example of the virtical button, it is apparent that it is hard to read.

>I would be nice, to have a < Button-effect > for Bitmaps.
>oBmp:bLClicked := {|| MsgAlert( "Your Function" ) }
>maybe it is possible, to add something in method < bLClicked >

See my answer to your question in another message thread.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Hand-cursor

Postby ukoenig » Fri Sep 12, 2008 1:49 pm

James,

Thank you very much

< oBmp:bMMoved := { || cursorhand() } >

is included in the sample-source.

Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Postby Rochinha » Sat Sep 13, 2008 6:46 am

ukoenig,

Very nice and thanks!
Rochinha
 
Posts: 310
Joined: Sun Jan 08, 2006 10:09 pm
Location: Brasil - Sao Paulo


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 40 guests