📄 xpmenu.pas
字号:
B := nil;
{Added By Sylvain ...}
HasHotBitmap := (Sender.HotImages <> nil) and
(Button.ImageIndex <> -1) and
(Button.ImageIndex <= Sender.HotImages.Count - 1);
HasDisBitmap := (Sender.DisabledImages <> nil) and
(Button.ImageIndex <> -1) and
(Button.ImageIndex <= Sender.DisabledImages.Count - 1);
{...Sylvain}
HasBitmap := (Sender.Images <> nil) and
(Button.ImageIndex <> -1) and
(Button.ImageIndex <= Sender.Images.Count - 1);
IsTransparent := Sender.Transparent;
ACanvas := Sender.Canvas;
//SetGlobalColor(ACanvas);
if(FColorsChanged) then SetGlobalColor(ACanvas); // +jt
if (Is16Bit) and (not UseSystemColors) then
FBSelectColor := NewColor(ACanvas, FSelectColor, 68)
else
FBSelectColor := FFSelectColor;
HoldRect := Button.BoundsRect;
ARect := HoldRect;
if Is16Bit then
ACanvas.brush.color := NewColor(ACanvas, Sender.Color, 16)
else
ACanvas.brush.color := Sender.Color;
if not IsTransparent then
ACanvas.FillRect(ARect);
HasBorder := false;
HasBkg := false;
if (cdsHot in State) then
begin
if (cdsChecked in State) or (Button.Down) or (cdsSelected in State) then
ACanvas.Brush.Color := FCheckedAreaSelectColor
else
ACanvas.brush.color := FBSelectColor;
HasBorder := true;
HasBkg := true;
end;
if ((cdsChecked in State) and not (cdsHot in State)) then
begin
ACanvas.Brush.Color := FCheckedAreaColor;
HasBorder := true;
HasBkg := true;
end;
if (cdsIndeterminate in State) and not (cdsHot in State) then
begin
ACanvas.Brush.Color := FBSelectColor;
HasBkg := true;
end;
if (Button.MenuItem <> nil) and (State = []) then
begin
ACanvas.brush.color := Sender.Color;
if not IsTransparent then
HasBkg := true;
end;
Inc(ARect.Top, 1);
if HasBkg then
ACanvas.FillRect(ARect);
if HasBorder then
DrawBorder;
if ((Button.MenuItem <> nil) or (Button.DropdownMenu <> nil))
and (cdsSelected in State) then
begin
DrawTopMenuItem(Button, ACanvas, ARect, Sender.Color ,false);
DefaultDraw := false;
end;
ARect := HoldRect;
DefaultDraw := false;
if Button.Style = tbsDropDown then
begin
ACanvas.Pen.Color := clBlack;
DrawArrow(ACanvas, (ARect.Right - 14) + ((14 - 5) div 2),
ARect.Top + ((ARect.Bottom - ARect.Top - 3) div 2) + 1);
end;
BitmapWidth := 0;
{ Rem by Sylvain ...
if HasBitmap then
begin
... Sylvain}
try
B := TBitmap.Create;
CanDraw := False;
ImglstHand:=0;
if (cdsHot in State) AND HasHotBitmap then
begin
B.Width := Sender.HotImages.Width;
B.Height := Sender.HotImages.Height;
ImglstHand := Sender.HotImages.Handle;
CanDraw := True;
end
else if (cdsDisabled in State) and HasDisBitmap then
begin
B.Width := Sender.DisabledImages.Width;
B.Height := Sender.DisabledImages.Height;
ImglstHand := Sender.DisabledImages.Handle;
CanDraw := True;
end
else if HasBitMap then
begin
B.Width := Sender.Images.Width;
B.Height := Sender.Images.Height;
ImglstHand := Sender.Images.Handle;
CanDraw := True;
end;
if CanDraw then
begin {CanDraw}
B.Canvas.Brush.Color := TransparentColor; // ACanvas.Brush.Color; // +jt
B.Canvas.FillRect(Rect(0, 0, B.Width, B.Height));
ImageList_DrawEx(ImglstHand, Button.ImageIndex,
B.Canvas.Handle, 0, 0, 0, 0, clNone, clNone, ILD_Transparent);
BitmapWidth := b.Width;
if Button.Style = tbsDropDown then
Dec(ARect.Right, 12);
if TToolBar(Button.Parent).List then
begin
if Button.BiDiMode = bdRightToLeft then
begin
Dec(ARect.Right, 3);
ARect.Left := ARect.Right - BitmapWidth;
end
else
begin
Inc(ARect.Left, 3);
ARect.Right := ARect.Left + BitmapWidth
end
end
else
ARect.Left := Round(ARect.Left + (ARect.Right - ARect.Left - B.Width)/2);
inc(ARect.Top, 2);
ARect.Bottom := ARect.Top + B.Height + 6;
DrawIcon(Button, ACanvas, B, ARect, (cdsHot in State),
(cdsSelected in State), Button.Enabled, (cdsChecked in State), false,
false);
end; {CanDraw}
finally
B.Free;
end;
ARect := HoldRect;
DefaultDraw := false;
{rem by sylvain ...
end;
...Sylvain}
//-----------
if Sender.ShowCaptions then
begin
if Button.Style = tbsDropDown then
Dec(ARect.Right, 12);
if not TToolBar(Button.Parent).List then
begin
TextFormat := DT_Center;
ARect.Top := ARect.Bottom - ACanvas.TextHeight(Button.Caption) - 6;
end
else
begin
TextFormat := DT_VCENTER;
if Button.BiDiMode = bdRightToLeft then
begin
TextFormat := TextFormat + DT_Right;
Dec(ARect.Right, BitmapWidth + 7);
end
else
begin
if BitmapWidth > 0 then //"Dan Downs" <dan@laserformsinc.com>
if Sender.List then //Micha雔 Moreno <michael@weatherderivs.com>
Inc(ARect.Left, BitmapWidth + 6)
else
Inc(ARect.Left, BitmapWidth);
end
end;
if (Button.MenuItem <> nil) then
begin
TextFormat := DT_Center;
//Inc(ARect.Left, 1);
end;
if Button.BiDiMode = bdRightToLeft then
TextFormat := TextFormat + DT_RTLREADING;
if Button.Down and not Button.Enabled then //"felix" <felix@unidreamtech.com> 23/5
InflateRect(ARect, -1, -1);
DrawTheText(Button, Button.Caption, '',
ACanvas, ARect,
(cdsSelected in State), Button.Enabled, false,
(Button.MenuItem <> nil),
(Button.BidiMode = bdRightToLeft), FFont, TextFormat);
ARect := HoldRect;
DefaultDraw := false;
end;
if Button.Index > 0 then
begin
XButton := {TToolBar(Button.Parent)}Sender.Buttons[Button.Index - 1];
if (XButton.Style = tbsDivider) or (XButton.Style = tbsSeparator) then
begin
ARect := XButton.BoundsRect;
if Is16Bit then
ACanvas.brush.color := NewColor(ACanvas, Sender.Color, 16)
else
ACanvas.brush.color := Sender.Color;
if not IsTransparent then
ACanvas.FillRect(ARect);
// if (XButton.Style = tbsDivider) then // Can't get it.
if XButton.Tag > 0 then
begin
Inc(ARect.Top, 2);
Dec(ARect.Bottom, 1);
ACanvas.Pen.color := GetShadeColor(ACanvas,Sender.Color,30);
ARect.Left := ARect.Left + (ARect.Right - ARect.Left) div 2;
ACanvas.MoveTo(ARect.Left, ARect.Top);
ACanvas.LineTo(ARect.Left, ARect.Bottom);
end;
ARect := Button.BoundsRect;
DefaultDraw := false;
end;
end;
{if Button.MenuItem <> nil then
if (xcMainMenu in XPControls) then
ActivateMenuItem(Button.MenuItem);}
end;
{$ENDIF}
// Controlbar Paint. Added by Michiel van Oudheusden (27 sep 2001)
// Paints the bands of a controlbar like the office XP style
procedure TXPMenu.ControlBarPaint(Sender: TObject; Control: TControl;
Canvas: TCanvas; var ARect: TRect; var Options: TBandPaintOptions);
var
i: Integer;
intInc: integer;
begin
if(FColorsChanged) then SetGlobalColor(Canvas); // +jt
// No frame and grabber drawing. We do it ourselfes
Options := [];
// First background
if Is16Bit then
Canvas.brush.color := NewColor(Canvas, TControlBar(Sender).Color , 6)
else
Canvas.brush.color := TControlBar(Sender).Color;
Canvas.FillRect(ARect);
intInc := 30;
for i := (ARect.Top + 5) to (ARect.Bottom - 5)do
begin
Canvas.Pen.Color := GetShadeColor(Canvas, TControlBar(Sender).Color, intInc);
if i mod 2 = 0 then
begin
Canvas.MoveTo(ARect.Left + 3, i);
Canvas.LineTo(ARect.Left + 6, i);
Inc(intInc, 7);
end;
end;
end;
procedure TXPMenu.SetGlobalColor(ACanvas: TCanvas);
begin
//-----
FColorsChanged:=false; // +jt
if GetDeviceCaps(ACanvas.Handle, BITSPIXEL) < 16 then
Is16Bit := false
else
Is16Bit := true;
FDimParentColor := 16;
FDimParentColorSelect := 40;
FFColor := FColor;
FFIconBackColor := FIconBackColor;
if Is16Bit then
begin
if FUseDimColor then
begin
FFSelectColor := NewColor(ACanvas, FSelectColor, 68);
FCheckedAreaColor := NewColor(ACanvas, FSelectColor, 80);
FCheckedAreaSelectColor := NewColor(ACanvas, FSelectColor, 50);
end
else
begin
FFSelectColor := FSelectColor;
FCheckedAreaColor := FSelectColor;
FCheckedAreaSelectColor := FSelectColor;
end;
FMenuBorderColor := GetShadeColor(ACanvas, clBtnFace, 90);
FMenuShadowColor := GetShadeColor(ACanvas, clBtnFace, 76);
end
else
begin
FFSelectColor := FSelectColor;
FCheckedAreaColor := clWhite;
FCheckedAreaSelectColor := clSilver;
FMenuBorderColor := clBtnShadow;
FMenuShadowColor := clBtnShadow;
end;
FFSelectBorderColor := FSelectBorderColor;
FFSelectFontColor := FSelectFontColor;
FFMenuBarColor := FMenuBarColor;
FFDisabledColor := FDisabledColor;
FFCheckedColor := FCheckedColor;
FFSeparatorColor := FSeparatorColor;
if FUseSystemColors then
begin
// GetSystemMenuFont(FFont);
FFSelectFontColor := FFont.Color;
if not Is16Bit then
begin
FFColor := clWhite;
FFIconBackColor := clBtnFace;
FFSelectColor := clWhite;
FFSelectBorderColor := clHighlight;
FFMenuBarColor := FFIconBackColor;
FFDisabledColor := clBtnShadow;
FFCheckedColor := clHighlight;
FFSeparatorColor := clBtnShadow;
FCheckedAreaColor := clWhite;
FCheckedAreaSelectColor := clWhite;
end
else
begin
FFColor := NewColor(ACanvas, clBtnFace, 86);
FFIconBackColor := NewColor(ACanvas, clBtnFace, 16);
FFSelectColor := NewColor(ACanvas, clHighlight, 68);
FFSelectBorderColor := clHighlight;
FFMenuBarColor := clBtnFace;
FFDisabledColor := NewColor(ACanvas, clBtnShadow, 10);
FFSeparatorColor := NewColor(ACanvas, clBtnShadow, 25);
FFCheckedColor := clHighlight;
FCheckedAreaColor := NewColor(ACanvas, clHighlight, 80);
FCheckedAreaSelectColor := NewColor(ACanvas, clHighlight, 50);
end;
end;
end;
procedure TXPMenu.DrawTopMenuItem(Sender: TObject; ACanvas: TCanvas;
ARect: TRect; BckColor:Tcolor; IsRightToLeft: boolean);
var
X1, X2: integer;
DefColor, HoldColor: TColor;
begin
X1 := ARect.Left;
X2 := ARect.Right;
ACanvas.brush.Style := bsSolid;
ACanvas.brush.color := FFSelectColor;
ACanvas.FillRect(ARect);
ACanvas.Pen.Color := FFSelectBorderColor;
if (not IsRightToLeft) and (Is16Bit) and (Sender is TMenuItem) then
begin
ACanvas.MoveTo(X1, ARect.Bottom - 1);
ACanvas.LineTo(X1, ARect.Top);
ACanvas.LineTo(X2 - 8, ARect.Top);
ACanvas.LineTo(X2 - 8, ARect.Bottom);
// ACanvas.LineTo(X1, ARect.Bottom);
DefColor := FFMenuBarColor;
HoldColor := GetShadeColor(ACanvas, DefColor, 10);
ACanvas.Brush.Style := bsSolid;
ACanvas.Brush.Color := HoldColor;
ACanvas.Pen.Color := HoldColor;
ACanvas.FillRect(Rect(X2 - 7, ARect.Top, X2, ARect.Bottom));
HoldColor := GetShadeColor(ACanvas, DefColor, 30);
ACanvas.Brush.Color := HoldColor;
ACanvas.Pen.Color := HoldColor;
ACanvas.FillRect(Rect(X2 - 7, ARect.Top + 3, X2 - 2, ARect.Bottom));
HoldColor := GetShadeColor(ACanvas, DefColor, 40 + 20);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -