FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour A Func., to calc. the exact Screen-Pos. of a CircleGradient
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
A Func., to calc. the exact Screen-Pos. of a CircleGradient
Posted: Sat Sep 26, 2009 10:05 AM
Hello,

because including the new Circle-Gradient-Function in my Tools,
here is the exact Calculation of the Circle-Position for any Dialog-Size.
I'm working on a Update, to include this Calculation in the SkinTools.

How it works :
I devided the Screen in 20 Horizontal- and 20 Vertical-parts ( 5 Parts are 1 Screen-Quarter ).
Using Values of 10, 10 centeres the Circle.
Direction Left = minus ( Values 1-9 ), Right = plus ( Values 11-20 )
Up = minus ( Values 1-9 ), Down = plus ( Values 11-20 ).



The Function :

Code (fw): Select all Collapse
//------------- DLG CIRCLE -----------

// How to use it :
// Step 1-9 for up and left, 11 - 20 for right and down. 10 = Centered
// ------------------------------------------------------------------------------------
// 1. Sample : Circle centered
// ------------------------------------
// ACTIVATE DIALOG oDlg CENTERED ;
// ON PAINT (  DLG_CIRCL( oDlg, COLOR1, COLOR2, 10, 10 )    
//
// 2. Sample : Circle on left  / upper
// -------------------------------------------
// ACTIVATE DIALOG oDlg CENTERED ;
// ON PAINT (  DLG_CIRCL( oDlg, COLOR1, COLOR2, 5, 5 )  
//
// -------------------------------------------------------------------------------
// 3. Sample : Circle on right / bottom 
// --------------------------------------------------
// ACTIVATE DIALOG oDlg CENTERED ;
// ON PAINT (  DLG_CIRCL( oDlg, COLOR1, COLOR2, 20, 20 )    
// -------------------------------------------------------------------------------
//
// hDC
// { nTop, nLeft, nBottom, nRight },
// startColor, endColor
// nOffserX, nOffserY
// lBrush --> hBitmap / hBrush ( GDI OBJECT )

FUNCTION DLG_CIRCL( oDlg, nVColor, nBColor, W_Hoffset, W_Voffset ) 
LOCAL oBrushBmp := TBrush():New()
LOCAL hDC := oDlg:GETDC()
LOCAL aRect := GETCLIENTRECT( oDlg:hWnd )
LOCAL nXa := aRect[3] / 20, nYa := aRect[4] / 20
LOCAL nX := 0, nY := 0 // Value 10

IF W_HOFFSET > 10
   // position : right from center dialog to middle Circle
   nX := W_HOFFSET * nXa
ENDIF
IF W_HOFFSET < 10
   // position : left from center dialog to middle Circle
   nX := - ( ( 10 - W_HOFFSET ) * nXa ) 
ENDIF
IF W_VOFFSET > 10
   // position : down from center Dialog to middle Circle
   nY := ( W_VOFFSET - 10 ) * nYa 
ENDIF
IF W_VOFFSET < 10
   // position : up from middle dialog to middle Circle
   nY := - ( ( 10 - W_VOFFSET ) * nYa )  
ENDIF

DeleteObject( oBrushBmp:hBrush )
oBrushBmp:hBrush = CircleGradient( 0, { 0, 0, aRect[3], aRect[4] } , ;
nVColor, nBColor, nX, nY, 3 )  

FillRect( hDC, aRect, oBrushBMP:hBrush )

oDlg:ReleaseDC()
RELEASE BRUSH oBrushBMP

RETURN NIL


The new Function will be included in the next SkinTool-Update :



Best Regards
Uwe :-)
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.

Continue the discussion