...
// ------ Font - Preview ----------------------
// "Blanc" = any small BMP from Resources.
REDEFINE BITMAP oBMP ID 350 ADJUST RESOURCE "Blanc" OF oFld:aDialogs[1]
oBMP:bPainted := { |hDC| ;
DRAW_TITLE( oBMP, ; // BMP
hDC, ; // hDC
.T., ; // Horiz. or Vert.
B_COLOR, ; // 1. Grad-Color
B_COLOR, ; // 2. Grad-Color ( same like 1. Color for non Gradient )
0.50, ; // Gradient-Color-Pos.
0, ; // Text-Pos from left ( 0 = centered )
oTextfont, ; // defined Font
T_COLOR, ; // Font-Color
"Fonttest" ) } // can be a Var
...
...
//------------- Title ( the Function uses Gradient or Color ) -----------
//--- for Color : nVcolor and nBcolor are the same -------------------
FUNCTION DRAW_TITLE( oBitmap, hDC, lDirect,nVColor, ;
nBColor, nMove, nLeft, oFont, nTColor, cTitle )
LOCAL aGrad := { { nMove, nVColor, nBColor }, { nMove, nBColor, nVColor } }
LOCAL aRect := GETCLIENTRECT( oBitmap:hWnd )
LOCAL oNewBrush
DEFINE BRUSH oNewBrush ;
COLOR GradientFill( hDC, 0, 0, aRect[3], aRect[4], aGrad, lDirect )
hOldFont := SelectObject( hDC, oFont:hFont )
nTXTLG := GettextWidth( hDC, cTitle )
nBMPLONG := oBitmap:Super:nWidth()
nBMPHIGHT := oBitmap:Super:nHeight()
nFONTHIGHT := oFont:nInpHeight * -1
IF nLEFT = 0
nLEFT := (nBMPLONG - nTXTLG) / 2
ENDIF
nNEWHIGHT := nFONTHIGHT
nTOP := (nBMPHIGHT - nNEWHIGHT) / 2
SetTextColor( hDC,nTColor)
SetBkMode( oBitmap:hDC, 0 )
TextOut( hDC, nTOP, nLEFT, cTitle )
RELEASE BRUSH oNewbrush
RETURN NIL
...
...
REDEFINE BITMAP oBMP ID 350 ADJUST RESOURCE "Blanc" OF oFld:aDialogs[1]
oBMP:bPainted := { |hDC|DRAW_TILED( ;
oBMP, ; // Bitmap
hDC, ; // hDC
oTextfont, ; // Font
c_path + "\System\blustone.bmp", ; // BMP-file
"Fonttest", ; // Text
0, ; // Orientation from Left, 0 = Centered
128 ) } // Textcolor
...
...
// ---------- TILED --------------
FUNCTION DRAW_TILED( oBitmap, hDC, oTextfont, cBitmap, cTitle, nLeft, nTColor )
LOCAL oImage, nRow := 0, nCol := 0, n
IF FILE( cBitmap )
DEFINE BITMAP oImage FILENAME cBitmap
aRect := GETCLIENTRECT( oBitmap:hWnd )
nHeight := oImage:nHeight
nWidth := oImage:nWidth
IF aRect[3] > 0
DO WHILE nRow < aRect[3]
nCol = 0
DO WHILE nCol < aRect[4]
PalBmpDraw( hDC, nRow, nCol, oImage:hBitmap )
nCol += nHeight
ENDDO
nRow += nWidth
ENDDO
ELSE
MsgAlert( "Not possible to use Picture " + CRLF + ;
cBitmap + CRLF + ;
"for TILED-selection !", "ATTENTION" )
ENDIF
hOldFont := SelectObject( hDC, oTextFont:hFont )
nTXTLG := GettextWidth( hDC, cTitle )
nBMPLONG := oBitmap:Super:nWidth()
nBMPHIGHT := oBitmap:Super:nHeight()
nFONTHIGHT := oTextFont:nInpHeight * -1
IF nLEFT = 0
nLEFT := (nBMPLONG - nTXTLG) / 2
ENDIF
nNEWHIGHT := nFONTHIGHT
nTOP := (nBMPHIGHT - nNEWHIGHT) / 2
SetTextColor( hDC,nTColor)
SetBkMode( oBitmap:hDC, 0 )
TextOut( hDC, nTOP, nLEFT, cTitle )
oBitmap:ReleaseDC()
ELSE
IF !EMPTY(cBitmap)
MsgAlert( "File : " + cBitmap + CRLF + ;
"does not exist" + CRLF + ;
"to create Background !", "ATTENTION" )
ENDIF
ENDIF
RETURN( NIL )
...
...
REDEFINE BITMAP oBMP ID 350 ADJUST RESOURCE "Blanc" OF oFld:aDialogs[1]
oBMP:bPainted := { |hDC|DRAW_IMG( ;
oBMP, ; // Bitmap
hDC, ; // hDC
oTextfont, ; // Font
c_path + "\System\fantasy5.jpg", ; // BMP-file
"Fonttest", ; // Text
0, ; // Orientation from Left, 0 = Centered
16777215 ) } // Textcolor
...
...
// ---------------------
FUNCTION DRAW_IMG( oBitmap, hDC, oTextfont, cBitmap, cTitle, nLeft, nTColor )
LOCAL oImage
IF FILE( cBitmap )
DEFINE IMAGE oImage FILENAME cBitmap
aRect := GETCLIENTRECT( oBitmap:hWnd )
PalBmpDraw( hDC, 0, 0, oImage:hBitmap, , aRect[4], aRect[3] )
hOldFont := SelectObject( hDC, oTextFont:hFont )
nTXTLG := GettextWidth( hDC, cTitle )
nBMPLONG := oBitmap:Super:nWidth()
nBMPHIGHT := oBitmap:Super:nHeight()
nFONTHIGHT := oTextFont:nInpHeight * -1
IF nLEFT = 0
nLEFT := (nBMPLONG - nTXTLG) / 2
ENDIF
nNEWHIGHT := nFONTHIGHT
nTOP := (nBMPHIGHT - nNEWHIGHT) / 2
SetTextColor( hDC,nTColor)
SetBkMode( oBitmap:hDC, 0 )
TextOut( hDC, nTOP, nLEFT, cTitle )
oBitmap:ReleaseDC()
ELSE
IF !EMPTY(cBitmap)
MsgAlert( "File : " + cBitmap + CRLF + ;
"does not exist" + CRLF + ;
"to create Background !", "ATTENTION" )
ENDIF
ENDIF
RETURN( NIL )
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 76 guests