Board index » cppbuilder » GUI stuff

GUI stuff


2005-06-25 12:39:37 AM
cppbuilder11
Does anyone know of any "free without nag" components mainly
(TPanel, and TButton, but others would be nice) that allow a
person to use a gradient or image? I'm trying to "unborify" my
project's GUI.
I'd rather download the package if there is one.
Thanks.
 
 

Re:GUI stuff

"metal.c" < XXXX@XXXXX.COM >wrote in message
Quote

Does anyone know of any "free without nag" components mainly
(TPanel, and TButton, but others would be nice) that allow a
person to use a gradient or image? I'm trying to "unborify" my
project's GUI.

I'd rather download the package if there is one.
Have you looked here ?
www.torry.net/pages.php
Jonathan
 

Re:GUI stuff

"metal.c" < XXXX@XXXXX.COM >wrote:
Quote

Does anyone know of any "free without nag" components mainly
(TPanel, and TButton, but others would be nice) that allow a
person to use a gradient or image? I'm trying to "unborify" my
project's GUI.
Why not do it yourself? It's quite simple adding a background image to most objects and then there is a win32 API for a very
nice and smooth gradient fill:
//-------------------------------------------------------------
void __fastcall GradientFillObject( HDC hDC, TColor StartColor, TColor EndColor, int Width, int Height, unsigned long Mode, int Factor )
{
void *pMesh;
int NumberOfVertices, FFactor;
TRIVERTEX Vertices[3];
GRADIENT_RECT GradientRect;
GRADIENT_TRIANGLE GradientTriangle;
memset( &Vertices, 0, sizeof(TRIVERTEX) * 3 );
AssignRGBToV( StartColor, &Vertices[0] );
AssignRGBToV( EndColor, &Vertices[1] );
if( Mode == GRADIENT_FILL_TRIANGLE )
{
Vertices[ 2 ] = Vertices[ 1 ];
Vertices[ 1 ].y = (Height - 1) * Factor * 2;
Vertices[ 2 ].x = (Width - 1) * Factor * 2;
GradientTriangle.Vertex1 = 0;
GradientTriangle.Vertex2 = 1;
GradientTriangle.Vertex3 = 2;
pMesh = &GradientTriangle;
NumberOfVertices = 3;
}
else
{
Vertices[ 1 ].x = (Width - 1) * Factor;
Vertices[ 1 ].y = (Height - 1) * Factor;
GradientRect.UpperLeft = 0;
GradientRect.LowerRight = 1;
pMesh = &GradientRect;
NumberOfVertices = 2;
}
GradientFill( hDC, (TRIVERTEX*)&Vertices, NumberOfVertices, pMesh, 1, Mode );
}
//-------------------------------------------------------------
void __fastcall AssignRGBToV( TColor Color, TRIVERTEX *V )
{
int C = ColorToRGB( Color );
V->Red = ( GetRValue(C) << 8 );
V->Green = ( GetGValue(C) << 8 );
V->Blue = ( GetBValue(C) << 8 );
}
//-------------------------------------------------------------
Try passing in a different Factor to the above and see what happens.
~ JD
 

{smallsort}

Re:GUI stuff

metal.c wrote:
Quote
Does anyone know of any "free without nag" components mainly
(TPanel, and TButton, but others would be nice) that allow a
person to use a gradient or image? I'm trying to "unborify" my
project's GUI.
Do it yourself. It's really easy. You may want to look at this:
www.leunen.com/cbuilder/gradient.html
Michel
--
----------------------------------------
Michel Leunen
mailto: see my homepage.
C++Builder, BCC5.5.1 Web site:
www.leunen.com/
----------------------------------------
 

Re:GUI stuff

V->Red = ( GetRValue(C) << 8 );
V->Green = ( GetGValue(C) << 8 );
V->Blue = ( GetBValue(C) << 8 );
Ok, I've been playing with the digits, but I can't seem to get
it set to the gradient I prefer.
I'm trying to get a WINXP silver to grayish gradient.
 

Re:GUI stuff

"metal.c" < XXXX@XXXXX.COM >wrote:
Quote

V->Red = ( GetRValue(C) << 8 );
V->Green = ( GetGValue(C) << 8 );
V->Blue = ( GetBValue(C) << 8 );


Ok, I've been playing with the digits, but I can't seem to get
it set to the gradient I prefer.
You don't mess with the above. Just pass in the the starting
and ending colors and Windows does the rest.
Quote
I'm trying to get a WINXP silver to grayish gradient.
Be aware that clColors are mapped into what ever the user has
set them to. Go to any Color property of any control and
double click the property value to bring up the color dialog
and select the actual color that you want.
The result will be that a clColor is no longer in the property
and you can get the hex value of the desired color that you
can cast to a TColor.
~ JD
 

Re:GUI stuff

"JD" < XXXX@XXXXX.COM >wrote:
Quote

I also didn't mention that if you increase the Factor, windows
will clip the range so you can specify something that well
exceeds the boundries of the object which results in a much
smoother gradient.
~ JD
 

Re:GUI stuff

Thanks JD, but I'm not seeing how to associate the gradient
with a component or how to get the color I need.
 

Re:GUI stuff

"metal.c" < XXXX@XXXXX.COM >wrote:
Quote

Thanks JD, but I'm not seeing how to associate the gradient
with a component or how to get the color I need.
GradientFillObject is a function that I defined to encapsulate
the win32 API GradientFill. To use my fuction, you pass into
it an HDC to the target object, a starting color, the ending
color, the width of the object, the height of the object, the
mode and the factor:
GradientFillObject( HDC hDC,
TColor StartColor,
TColor EndColor,
int Width,
int Height,
unsigned long Mode,
int Factor
);
The only parameters that need explaination are the hDC, the
Mode and the Factor.
For the hDC, you need to pass in an HDC to the object. Some
times this is the same as the Handle property and sonme times
not. It depends on what the Handle represents. For example,
for a TForm the Handle is a HWND and for a TCanvas, the Handle
is a HDC. It's up to you to know the difference and pass the
correct value so have a look at the win32 API's GetDC and
GetWindowDC.
The Mode is defined by M$:
GRADIENT_FILL_RECT_H
In this mode, two endpoints describe a rectangle. The rectangle
is defined to have a constant color (specified by the TRIVERTEX
structure) for the left and right edges. GDI interpolates the
color from the left to right edge and fills the interior.
GRADIENT_FILL_RECT_V
In this mode, two endpoints describe a rectangle. The rectangle
is defined to have a constant color (specified by the TRIVERTEX
structure) for the top and bottom edges. GDI interpolates the
color from the top to bottom edge and fills the interior.
GRADIENT_FILL_TRIANGLE
In this mode, an array of TRIVERTEX structures is passed to
GDI along with a list of array indexes that describe separate
triangles. GDI performs linear interpolation between triangle
vertices and fills the interior. Drawing is done directly in
24- and 32-bpp modes. Dithering is performed in 16-, 8-, 4-,
and 1-bpp mode.
The Factor parameter affects how the gradient looks. It
accomplishes this by changing the logical size of the object
in terms of how the gradient is applied. For example, if the
object is 10x10 and the Factor is one, the pixel at (0,0) will
be the starting color and the pixel at (9,9) will be the
ending color and the pixels between will be an even gradient
between the two colors.
If you change the Factor to 2, (0,0) will still be the starting
color but the gradient will be as if the object were 20x20
with window's clipping the over flow so that the ending color
is never seen but the gradient will still be gradually moving
toward the ending color.
~ JD
 

Re:GUI stuff

Like so.
::GradientFill(hDC, (TRIVERTEX*)&Vertices, NumberOfVertices, pMesh, 1, Mode );
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
GradientFillObject(Image1->Canvas->Handle,clBtnFace,clHighlight,Image1->Width,
Image1->Width,GRADIENT_FILL_RECT_H, 3);
}
Thanks.