1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206:
|
unit PanelPlus;
interface
uses Types, SysUtils, Classes, ExtCtrls, Windows, Graphics, Controls;
type TPanelPlus = class(TPanel) private FCaptionTop: Integer; FFrameColor: TColor; FFrame, FDrawScrew: Boolean; protected procedure Paint; override; procedure SetCaptionTop(Value: Integer); procedure SetFrameColor(Value: TColor); procedure SetFrame(Value: Boolean); procedure SetDrawScrew(Value: Boolean); public constructor Create(AOwner: TComponent); override; destructor Destroy; override; published property CaptionTop: Integer read FCaptionTop write SetCaptionTop; property Frame: Boolean read FFrame write SetFrame; property FrameColor: TColor read FFrameColor write SetFrameColor; property DrawScrew: Boolean read FDrawScrew write SetDrawScrew; end;
procedure Register;
implementation
procedure TPanelPlus.Paint; const Alignments: array[TAlignment] of Longint = (DT_LEFT, DT_RIGHT, DT_CENTER); var Rect: TRect; TopColor, BottomColor: TColor; FontHeight: Integer; Flags: Longint;
procedure AdjustColors(Bevel: TPanelBevel); begin TopColor := clBtnHighlight; if Bevel = bvLowered then TopColor := clBtnShadow; BottomColor := clBtnShadow; if Bevel = bvLowered then BottomColor := clBtnHighlight; end;
begin Rect := GetClientRect; if BevelOuter <> bvNone then begin AdjustColors(BevelOuter); Frame3D(Canvas, Rect, TopColor, BottomColor, BevelWidth); end;
Frame3D(Canvas, Rect, Color, Color, BorderWidth); if BevelInner <> bvNone then begin AdjustColors(BevelInner); Frame3D(Canvas, Rect, TopColor, BottomColor, BevelWidth); end;
with Canvas do begin Brush.Color := Color; FillRect(Rect); Brush.Style := bsClear; Font := Self.Font; FontHeight := TextHeight('W'); with Rect do begin Top := ((Bottom + Top) - FontHeight) div 2; Bottom := Top + FontHeight; end;
Rect.Top := Rect.Top+FCaptionTop; Rect.Bottom := Rect.Bottom+Rect.Top;
Flags := DT_EXPANDTABS or DT_VCENTER or Alignments[Alignment]; Flags := DrawTextBiDiModeFlags(Flags);
if FFrame then begin Pen.Color := FFrameColor; Pen.Width := BevelWidth+BorderWidth+2; Rectangle(BevelWidth+BorderWidth+1,BevelWidth+BorderWidth+1,ClientWidth- BevelWidth-BorderWidth-1,ClientHeight-BevelWidth-BorderWidth-1); end;
DrawText(Handle, PChar(Caption), -1, Rect, Flags); end;
if FDrawScrew then begin if Height <= 80 then begin Canvas.Pen.Color := $00A58F92; Canvas.Pen.Width := 1; Canvas.Brush.Color := $00D9CCCA; Canvas.FillRect(Types.Rect(6,Height div 2-3,12,Height div 2-2+5)); Canvas.Ellipse(5, Height div 2-4, 13, Height div 2+4); Canvas.MoveTo(7,Height div 2-2); Canvas.LineTo(11,Height div 2+2); Canvas.FillRect(Types.Rect(Width-6,Height div 2-3,Width-12,Height div 2-2+6)); Canvas.Ellipse(Width-5, Height div 2-4, Width-13, Height div 2+4); Canvas.MoveTo(Width-8,Height div 2-2); Canvas.LineTo(Width-12,Height div 2+2); end else begin Canvas.Pen.Color := $00A58F92; Canvas.Pen.Width := 1; Canvas.Brush.Color := $00D9CCCA; Canvas.FillRect(Types.Rect(6,6,12,12)); Canvas.Ellipse(5, 5, 13,13); Canvas.FillRect(Types.Rect(Width-6,Height-6,Width-12,Height-12)); Canvas.Ellipse(Width-5, Height-5, Width-13,Height-13); Canvas.FillRect(Types.Rect(Width-6,6,Width-12,12)); Canvas.Ellipse(Width-5, 5, Width-13,13); Canvas.FillRect(Types.Rect(6,Height-6,12,Height-12)); Canvas.Ellipse(5, Height-5, 13,Height-13); Canvas.MoveTo(7,7); Canvas.LineTo(11,11); Canvas.MoveTo(Width-8,Height-8); Canvas.LineTo(Width-12,Height-12); Canvas.MoveTo(Width-8,7); Canvas.LineTo(Width-12,11); Canvas.MoveTo(7,Height-8); Canvas.LineTo(11,Height-12); end; end; end;
procedure TPanelPlus.SetCaptionTop(Value: Integer); begin FCaptionTop := Value; Paint; end;
procedure TPanelPlus.SetFrameColor(Value: TColor); begin FFrameColor := Value; Paint; end;
procedure TPanelPlus.SetFrame(Value: Boolean); begin FFrame := Value; Paint; end;
procedure TPanelPlus.SetDrawScrew(Value: Boolean); begin FDrawScrew := Value; Paint; end;
constructor TPanelPlus.Create(AOwner: TComponent); begin inherited Create(AOwner); FFrameColor := Color; end;
destructor TPanelPlus.Destroy; begin inherited Destroy; end;
procedure Register; begin RegisterComponents('Samples', [TPanelPlus]); end;
end. |