|
From: Matthieu G. <mat...@ya...> - 2018-04-12 08:36:40
|
Hello !
My JVXPCheck checks.
Here it is :
procedure TJvXPCustomCheckControl.Paint;
var
Rect: TRect;
BoundColor: TColor;
Trans: integer;
begin
with Canvas do
begin
// clear background.
Rect := GetClientRect;
Brush.Color := Self.Color;
FillRect(Rect);
// draw designtime rect.
if csDesigning in ComponentState then
DrawFocusRect(Rect);
// draw boundlines.
if BoundLines <> [] then
begin
// if Style.GetTheme = WindowsXP then
// BoundColor := dxColor_Btn_Enb_Border_WXP
// else
BoundColor := dxColor_DotNetFrame;
JvXPDrawBoundLines(Self.Canvas, BoundLines, BoundColor, Rect);
end;
// draw focusrect.
if dsFocused in DrawState then
begin
Brush.Style := bsSolid;
DrawFocusRect(Rect);
end;
// draw check symbol.
DrawCheckSymbol(Rect);
// draw caption.
Trans := Transparent;
SetBkMode(Handle, Trans);
Font.Assign(Self.Font);
if BiDiMode = bdRightToLeft then
begin
Dec(Rect.Right, FCheckSize + 4 + Spacing);
JvXPPlaceText(Self, Canvas, Caption, Font, Enabled, True,
taRightJustify, True, Rect);
end
else
begin
Inc(Rect.Left, FCheckSize + 4 + Spacing);
JvXPPlaceText(Self, Canvas, Caption, Font, Enabled, True,
taLeftJustify, True, Rect);
end;
end;
end;
procedure TJvXPCheckbox.DrawCheckSymbol(const R: TRect);
var
ClipW: integer;
ap_Polygon : Array [0..5] of TPoint ;
// Theme: TJvXPTheme;
procedure DrawGradient(const Bitmap: TBitmap);
begin
{ if BiDiMode = bdRightToLeft then
BitBlt(Canvas.Handle, R.Right - 1 - FCheckSize, (ClientHeight -
FCheckSize) div 2 + 1,
FCheckSize - 2, FCheckSize - 2, Bitmap.Canvas.Handle, 0, 0,
SRCCOPY)
else}
BitBlt(Canvas.Handle, R.Left + 3, (ClientHeight - FCheckSize) div 2
+ 1,
FCheckSize - 2, FCheckSize - 2, Bitmap.Canvas.Handle, 0, 0, SRCCOPY);
end;
begin
// get current theme.
// Theme := Style.GetTheme;
with Canvas do
begin
// check for highlight.
ClipW := Ord(dsHighlight in DrawState);
// draw border.
{ if (Theme = WindowsXP) or ((Theme = OfficeXP) and (ClipW = 0)) then
Pen.Color := dxColor_Chk_Enb_Border_WXP
else}
Pen.Color := dxColor_BorderLineOXP;
if BiDiMode = bdRightToLeft then
Rectangle(Bounds(R.Right - 2 - FCheckSize, (ClientHeight -
FCheckSize) div
2, FCheckSize, FCheckSize))
else
Rectangle(Bounds(R.Left + 2, (ClientHeight - FCheckSize) div
2, FCheckSize, FCheckSize));
// draw background.
{ case Theme of
WindowsXP:
begin
if not ((ClipW <> 0) and (dsClicked in DrawState)) then
begin
if ClipW <> 0 then
DrawGradient(FHlGradient);
if BiDiMode = bdRightToLeft then
BitBlt(Handle, R.Right - 1 - FCheckSize + ClipW,
(ClientHeight - FCheckSize) div 2 + 1 +
ClipW, FCheckSize - 2 - ClipW * 2, FCheckSize - 2 -
ClipW * 2,
FBgGradient.Canvas.Handle, 0, 0, SRCCOPY)
else
BitBlt(Handle, R.Left + 3 + ClipW, (ClientHeight -
FCheckSize) div 2 + 1 +
ClipW, FCheckSize - 2 - ClipW * 2, FCheckSize - 2 -
ClipW * 2,
FBgGradient.Canvas.Handle, 0, 0, SRCCOPY);
end
else
DrawGradient(FCkGradient);
end;
OfficeXP:
begin}
if ClipW <> 0 then
begin
if not (dsClicked in DrawState) then
Brush.Color := dxColor_BgOXP
else
Brush.Color := dxColor_BgCkOXP;
if BiDiMode = bdRightToLeft then
FillRect(Bounds(R.Right - 1, (ClientHeight - FCheckSize) div 2 +
1, FCheckSize - 2, FCheckSize - 2))
else
FillRect(Bounds(R.Left + 3, (ClientHeight - FCheckSize) div
2 + 1, FCheckSize - 2, FCheckSize - 2));
end;
// end;
// end;
// draw checked or grayed symbols:
if FState in [cbChecked, cbGrayed] then
begin
if (dsClicked in DrawState) or (dsHighlight in DrawState) then
begin
Brush.Color := clWhite;
Pen .Color := clWhite;
end
else
if FState = cbChecked then
begin
Brush.Color := clWindowText;
Pen .Color := clWindowText;
end
else
begin
Brush.Color := clGray;
Pen .Color := clGray;
end;
if BiDiMode = bdRightToLeft then
Begin
CreateCheck ( R.Right - FCheckSize + 1, (ClientHeight -
FCheckSize) div 2 + 3, ap_Polygon );
Polygon(ap_Polygon);
end
else
Begin
CreateCheck ( FCheckSize div 2 - 1, (ClientHeight -
FCheckSize) div 2 + 3, ap_Polygon );
Polygon(ap_Polygon);
end
end;
end;
end;
--
LIBERLOG - Édition de livres de coaching et de logiciels
13 Rue François Tanguy PRIGENT A.15
35000 RENNES
Tél : 02 23 46 06 54 - Numéro vert : 06 44 733 008 - Fax : 09 72 53 47 55
http://editions.liberlog.fr
http://www.agoravox.tv/auteur/matthius
http://www.thebookedition.com/fr/12123_matthieu-giroux
http://www.ancestromania.net
--
LIBERLOG - Édition de livres de coaching et de logiciels
13 Rue François Tanguy PRIGENT A.15
35000 RENNES
Tél : 02 23 46 06 54 - Numéro vert : 06 44 733 008 - Fax : 09 72 53 47 55
http://editions.liberlog.fr
http://www.agoravox.tv/auteur/matthius
http://www.thebookedition.com/fr/12123_matthieu-giroux
http://www.ancestromania.net
|