customdrawn: Finishes the scrollbar arrows and starts supporting for scrolling controls

git-svn-id: trunk@33454 -
This commit is contained in:
sekelsenmat 2011-11-10 07:15:11 +00:00
parent 82e093ff6d
commit ca6dbdb336
3 changed files with 164 additions and 10 deletions

View File

@ -40,6 +40,7 @@ type
procedure DrawShallowSunkenFrame(ADest: TCanvas; ADestPos: TPoint; ASize: TSize); override;
procedure DrawTickmark(ADest: TCanvas; ADestPos: TPoint); override;
procedure DrawSlider(ADest: TCanvas; ADestPos: TPoint; ASize: TSize; AState: TCDControlState); override;
procedure DrawCompactArrow(ADest: TCanvas; ADestPos: TPoint; ADirection: TCDControlState); override;
// ===================================
// Standard Tab
// ===================================
@ -398,6 +399,47 @@ begin
end;
end;
procedure TCDDrawerCommon.DrawCompactArrow(ADest: TCanvas; ADestPos: TPoint;
ADirection: TCDControlState);
var
lPoints: array[0..2] of TPoint;
lPos: TPoint;
begin
lPos := ADestPos;
// Move the arrow a little bit when a sunken state is passed
if csfSunken in ADirection then lPos := Point(lPos.X+1, lPos.Y+1);
if csfLeftArrow in ADirection then
begin
lPoints[0] := Point(lPos.X, lPos.Y+3);// left point
lPoints[1] := Point(lPos.X+3, lPos.Y+6);// lower point
lPoints[2] := Point(lPos.X+3, lPos.Y); // upper point
end
else if csfRightArrow in ADirection then
begin
lPoints[0] := Point(lPos.X+1, lPos.Y); // upper point
lPoints[1] := Point(lPos.X+1, lPos.Y+6);// lower point
lPoints[2] := Point(lPos.X+4, lPos.Y+3);// right point
end
else if csfUpArrow in ADirection then
begin
lPoints[0] := Point(lPos.X+3, lPos.Y); // upper point
lPoints[1] := Point(lPos.X, lPos.Y+3);// left point
lPoints[2] := Point(lPos.X+6, lPos.Y+3);// right point
end
else // downArrow
begin
lPoints[0] := Point(lPos.X, lPos.Y+1);// left point
lPoints[1] := Point(lPos.X+6, lPos.Y+1);// right point
lPoints[2] := Point(lPos.X+3, lPos.Y+4);// lower point
end;
ADest.Brush.Style := bsSolid;
ADest.Brush.Color := clBlack;
ADest.Pen.Style := psSolid;
ADest.Pen.Color := clBlack;
ADest.Polygon(lPoints);
end;
procedure TCDDrawerCommon.DrawButton(ADest: TCanvas; ADestPos: TPoint;
ASize: TSize; AState: TCDControlState; AStateEx: TCDControlStateEx);
var
@ -779,6 +821,7 @@ procedure TCDDrawerCommon.DrawScrollBar(ADest: TCanvas; ADestPos: TPoint;
var
lPos: TPoint;
lSize: TSize;
lArrowState: TCDControlState;
begin
// Background
ADest.Brush.Color := WIN2000_SCROLLBAR_BACKGROUND;
@ -797,8 +840,20 @@ begin
ADest.Brush.Color := Palette.BtnFace;
ADest.Brush.Style := bsSolid;
ADest.Rectangle(Bounds(lPos.X, lPos.Y, lSize.cx, lSize.cy));
if csfLeftArrow in AState then DrawSunkenFrame(ADest, lPos, lSize)
else DrawRaisedFrame(ADest, lPos, lSize);
if csfLeftArrow in AState then
begin
DrawSunkenFrame(ADest, lPos, lSize);
lArrowState := [csfSunken];
end
else
begin
DrawRaisedFrame(ADest, lPos, lSize);
lArrowState := [];
end;
if csfHorizontal in AState then
DrawCompactArrow(ADest, Point(lPos.X+5, lPos.Y+5), [csfLeftArrow]+lArrowState)
else DrawCompactArrow(ADest, Point(lPos.X+5, lPos.Y+5), [csfUpArrow]+lArrowState);
// Right/Bottom button
if csfHorizontal in AState then
@ -808,8 +863,20 @@ begin
ADest.Brush.Color := Palette.BtnFace;
ADest.Brush.Style := bsSolid;
ADest.Rectangle(Bounds(lPos.X, lPos.Y, lSize.cx, lSize.cy));
if csfRightArrow in AState then DrawSunkenFrame(ADest, lPos, lSize)
else DrawRaisedFrame(ADest, lPos, lSize);
if csfRightArrow in AState then
begin
DrawSunkenFrame(ADest, lPos, lSize);
lArrowState := [csfSunken];
end
else
begin
DrawRaisedFrame(ADest, lPos, lSize);
lArrowState := [];
end;
if csfHorizontal in AState then
DrawCompactArrow(ADest, Point(lPos.X+5, lPos.Y+5), [csfRightArrow] + lArrowState)
else DrawCompactArrow(ADest, Point(lPos.X+5, lPos.Y+5), [csfDownArrow] + lArrowState);
// The slider
lPos := Point(0, 0);

View File

@ -63,6 +63,23 @@ type
end;
TCDControlClass = class of TCDControl;
TCDScrollBar = class;
{ TCDScrollableControl }
TCDScrollableControl = class(TCDControl)
private
FRightScrollBar, FBottomScrollBar: TCDScrollBar;
FSpacer: TCDControl;
FScrollBars: TScrollStyle;
procedure SetScrollBars(AValue: TScrollStyle);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property ScrollBars: TScrollStyle read FScrollBars write SetScrollBars default ssBoth;
end;
// ===================================
// Standard Tab
// ===================================
@ -400,7 +417,7 @@ type
{ TCDListView }
TCDListView = class(TCDControl)
TCDListView = class(TCDScrollableControl)
private
DragDropStarted: boolean;
// fields
@ -566,6 +583,76 @@ implementation
resourcestring
sTABSHEET_DEFAULT_NAME = 'CTabSheet';
{ TCDScrollableControl }
procedure TCDScrollableControl.SetScrollBars(AValue: TScrollStyle);
begin
if FScrollBars=AValue then Exit;
FScrollBars:=AValue;
{ if AValue = ssNone then
begin
FSpacer.Visible := False;
FRightScrollBar.Visible := False;
FBottomScrollBar.Visible := False;
end
else if AValue in [ssHorizontal, ssAutoHorizontal] then
begin
FSpacer.Visible := False;
FRightScrollBar.Visible := False;
FBottomScrollBar.BorderSpacing.Bottom := 0;
FBottomScrollBar.Align := alRight;
FBottomScrollBar.Visible := True;
end
else if AValue in [ssVertical, ssAutoVertical] then
begin
FSpacer.Visible := False;
FRightScrollBar.BorderSpacing.Bottom := 0;
FRightScrollBar.Align := alRight;
FRightScrollBar.Visible := True;
FBottomScrollBar.Visible := False;
end
else // ssBoth, ssAutoBoth
begin
FSpacer.Visible := True;
FBottomScrollBar.BorderSpacing.Bottom := 0;
FBottomScrollBar.Align := alRight;
FBottomScrollBar.Visible := True;
FBottomScrollBar := TCDScrollBar.Create(nil);
FBottomScrollBar.Kind := bsHorizontal;
FBottomScrollBar.Parent := Self;
FBottomScrollBar.Align := alBottom;
FBottomScrollBar.Visible := True;
end;}
end;
constructor TCDScrollableControl.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
{FSpacer := TCDControl.Create(nil);
FSpacer.Parent := Self;
FRightScrollBar := TCDScrollBar.Create(nil);
FBottomScrollBar.Kind := bsVertical;
FRightScrollBar.Parent := Self;
FRightScrollBar.Visible := True;
FBottomScrollBar := TCDScrollBar.Create(nil);
FBottomScrollBar.Kind := bsHorizontal;
FBottomScrollBar.Parent := Self;
FBottomScrollBar.Visible := True;
SetScrollBars(ssBoth);}
end;
destructor TCDScrollableControl.Destroy;
begin
inherited Destroy;
end;
{ TCDControl }
procedure TCDControl.CalculatePreferredSize(var PreferredWidth,

View File

@ -94,13 +94,12 @@ type
csfVertical,
csfRightToLeft,
csfTopDown,
// for TCDProgressBar
// for TCDProgressBar, TCDScrollBar, TCDComboBox
csfLeftArrow,
csfRightArrow,
// for TCDComboBox
csfDownArrow
{ csfUpArrow
// for tool button
csfDownArrow,
csfUpArrow
{ // for tool button
csfAutoRaise,
csfTop,
csfBottom,
@ -262,6 +261,7 @@ type
procedure DrawShallowSunkenFrame(ADest: TCanvas; ADestPos: TPoint; ASize: TSize); virtual; abstract;
procedure DrawTickmark(ADest: TCanvas; ADestPos: TPoint); virtual; abstract;
procedure DrawSlider(ADest: TCanvas; ADestPos: TPoint; ASize: TSize; AState: TCDControlState); virtual; abstract;
procedure DrawCompactArrow(ADest: TCanvas; ADestPos: TPoint; ADirection: TCDControlState); virtual; abstract;
// TCDButton
procedure DrawButton(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
AState: TCDControlState; AStateEx: TCDControlStateEx); virtual; abstract;