mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-29 22:51:02 +02:00
customdrawn: Starts the drawing of TCDListView
git-svn-id: trunk@33439 -
This commit is contained in:
parent
ad54b6620d
commit
8990e8afbb
@ -83,6 +83,10 @@ type
|
|||||||
// TCDListView
|
// TCDListView
|
||||||
procedure DrawListView(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
procedure DrawListView(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||||
AState: TCDControlState; AStateEx: TCDListViewStateEx); override;
|
AState: TCDControlState; AStateEx: TCDListViewStateEx); override;
|
||||||
|
procedure DrawReportListView(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||||
|
AState: TCDControlState; AStateEx: TCDListViewStateEx); override;
|
||||||
|
procedure DrawReportListViewItem(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||||
|
ACurItem: TCDListItems; AState: TCDControlState; AStateEx: TCDListViewStateEx); override;
|
||||||
// TCDCustomTabControl
|
// TCDCustomTabControl
|
||||||
procedure DrawCTabControl(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
procedure DrawCTabControl(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||||
AState: TCDControlState; AStateEx: TCDCTabControlStateEx); override;
|
AState: TCDControlState; AStateEx: TCDCTabControlStateEx); override;
|
||||||
@ -136,6 +140,12 @@ begin
|
|||||||
TCDTRACKBAR_RIGHT_SPACING: Result := 9;
|
TCDTRACKBAR_RIGHT_SPACING: Result := 9;
|
||||||
TCDTRACKBAR_TOP_SPACING: Result := 5;
|
TCDTRACKBAR_TOP_SPACING: Result := 5;
|
||||||
TCDTRACKBAR_FRAME_HEIGHT: Result := 17;
|
TCDTRACKBAR_FRAME_HEIGHT: Result := 17;
|
||||||
|
//
|
||||||
|
TCDLISTVIEW_COLUMN_LEFT_SPACING: Result := 10;
|
||||||
|
TCDLISTVIEW_COLUMN_RIGHT_SPACING: Result := 10;
|
||||||
|
TCDLISTVIEW_COLUMN_TEXT_LEFT_SPACING: Result := 5;
|
||||||
|
TCDLISTVIEW_LINE_TOP_SPACING: Result := 3;
|
||||||
|
TCDLISTVIEW_LINE_BOTTOM_SPACING: Result := 3;
|
||||||
else
|
else
|
||||||
Result := 0;
|
Result := 0;
|
||||||
end;
|
end;
|
||||||
@ -153,8 +163,8 @@ begin
|
|||||||
|
|
||||||
case AMeasureID of
|
case AMeasureID of
|
||||||
TCDCONTROL_CAPTION_WIDTH: Result := ADest.TextWidth(AStateEx.Caption);
|
TCDCONTROL_CAPTION_WIDTH: Result := ADest.TextWidth(AStateEx.Caption);
|
||||||
TCDCONTROL_CAPTION_HEIGHT: Result := ADest.TextHeight('ŹÇ')+3;
|
TCDCONTROL_CAPTION_HEIGHT: Result := ADest.TextHeight(cddTestStr)+3;
|
||||||
TCDCTABCONTROL_TAB_HEIGHT: Result := ADest.TextHeight('ŹÇ')+10;
|
TCDCTABCONTROL_TAB_HEIGHT: Result := ADest.TextHeight(cddTestStr)+10;
|
||||||
TCDCTABCONTROL_TAB_WIDTH:
|
TCDCTABCONTROL_TAB_WIDTH:
|
||||||
begin
|
begin
|
||||||
lCaption := ATabsStateEx.Tabs.Strings[ATabsStateEx.CurTabIndex];
|
lCaption := ATabsStateEx.Tabs.Strings[ATabsStateEx.CurTabIndex];
|
||||||
@ -627,6 +637,8 @@ begin
|
|||||||
Size(ASize.cx-lSquareHeight-4, ASize.cy));
|
Size(ASize.cx-lSquareHeight-4, ASize.cy));
|
||||||
|
|
||||||
// Now the text
|
// Now the text
|
||||||
|
ADest.Brush.Style := bsClear;
|
||||||
|
ADest.Pen.Style := psClear;
|
||||||
ADest.Font.Assign(AStateEx.Font);
|
ADest.Font.Assign(AStateEx.Font);
|
||||||
ADest.TextOut(lSquareHeight+5, 0, AStateEx.Caption);
|
ADest.TextOut(lSquareHeight+5, 0, AStateEx.Caption);
|
||||||
end;
|
end;
|
||||||
@ -758,7 +770,7 @@ var
|
|||||||
lTextSize: TSize;
|
lTextSize: TSize;
|
||||||
lCaption: String;
|
lCaption: String;
|
||||||
begin
|
begin
|
||||||
FCaptionMiddle := ADest.TextHeight('ŹÇ') div 2;
|
FCaptionMiddle := ADest.TextHeight(cddTestStr) div 2;
|
||||||
if FCaptionMiddle = 0 then FCaptionMiddle := AStateEx.Font.Size div 2;
|
if FCaptionMiddle = 0 then FCaptionMiddle := AStateEx.Font.Size div 2;
|
||||||
if FCaptionMiddle = 0 then FCaptionMiddle := 5;
|
if FCaptionMiddle = 0 then FCaptionMiddle := 5;
|
||||||
|
|
||||||
@ -956,6 +968,101 @@ begin
|
|||||||
DrawSunkenFrame(ADest, ADestPos, ASize);
|
DrawSunkenFrame(ADest, ADestPos, ASize);
|
||||||
|
|
||||||
// The contents depend on the view style
|
// The contents depend on the view style
|
||||||
|
case AStateEx.ViewStyle of
|
||||||
|
vsReport: DrawReportListView(ADest, ADestPos, ASize, AState, AStateEx);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCDDrawerCommon.DrawReportListView(ADest: TCanvas; ADestPos: TPoint;
|
||||||
|
ASize: TSize; AState: TCDControlState; AStateEx: TCDListViewStateEx);
|
||||||
|
var
|
||||||
|
lColumn: TListColumn;
|
||||||
|
lWidth: TWidth;
|
||||||
|
i, j: Integer;
|
||||||
|
lCurPos: TPoint;
|
||||||
|
lItemSize: TSize;
|
||||||
|
lItemCount: Integer;
|
||||||
|
lCurItem: TCDListItems;
|
||||||
|
begin
|
||||||
|
lCurPos := Point(2, 2);
|
||||||
|
lItemCount := AStateEx.Items.GetItemCount();
|
||||||
|
|
||||||
|
// i is an column zero-based index
|
||||||
|
for i := AStateEx.FirstVisibleColumn to AStateEx.Columns.Count-1 do
|
||||||
|
begin
|
||||||
|
lColumn := AStateEx.Columns[i];
|
||||||
|
lCurPos.Y := 2;
|
||||||
|
|
||||||
|
// get the column width
|
||||||
|
if lColumn.AutoSize then
|
||||||
|
begin
|
||||||
|
lItemSize.cx := ADest.GetTextWidth(lColumn.Caption)
|
||||||
|
+ GetMeasures(TCDLISTVIEW_COLUMN_LEFT_SPACING)
|
||||||
|
+ GetMeasures(TCDLISTVIEW_COLUMN_RIGHT_SPACING);
|
||||||
|
if (lColumn.MinWidth > 0) and (lItemSize.cx < lColumn.MinWidth) then lItemSize.cx := lColumn.MinWidth
|
||||||
|
else if (lColumn.MaxWidth > 0) and (lItemSize.cx > lColumn.MaxWidth) then lItemSize.cx := lColumn.MaxWidth;
|
||||||
|
end
|
||||||
|
else lItemSize.cx := lColumn.Width;
|
||||||
|
|
||||||
|
// line height measure
|
||||||
|
lItemSize.cy := ADest.TextHeight(cddTestStr)
|
||||||
|
+ GetMeasures(TCDLISTVIEW_LINE_TOP_SPACING)
|
||||||
|
+ GetMeasures(TCDLISTVIEW_LINE_BOTTOM_SPACING);
|
||||||
|
|
||||||
|
// Draw the column header
|
||||||
|
if AStateEx.ShowColumnHeader then
|
||||||
|
begin
|
||||||
|
// Foreground
|
||||||
|
ADest.Brush.Style := bsSolid;
|
||||||
|
ADest.Brush.Color := Palette.BtnFace; // WIN2000_BTNFACE
|
||||||
|
ADest.Pen.Style := psClear;
|
||||||
|
ADest.FillRect(Bounds(lCurPos.X, lCurPos.Y, lItemSize.cx, lItemSize.cy));
|
||||||
|
|
||||||
|
// Frame
|
||||||
|
DrawRaisedFrame(ADest, lCurPos, lItemSize);
|
||||||
|
|
||||||
|
// The caption
|
||||||
|
ADest.Brush.Style := bsClear;
|
||||||
|
ADest.Pen.Style := psClear;
|
||||||
|
ADest.TextOut(
|
||||||
|
lCurPos.X+GetMeasures(TCDLISTVIEW_COLUMN_TEXT_LEFT_SPACING),
|
||||||
|
lCurPos.Y+GetMeasures(TCDLISTVIEW_LINE_TOP_SPACING),
|
||||||
|
lColumn.Caption);
|
||||||
|
|
||||||
|
Inc(lCurPos.Y, lItemSize.cy);
|
||||||
|
end;
|
||||||
|
|
||||||
|
// j is a zero-based index for lines, ignoring the header
|
||||||
|
// Draw all items until we get out of the visible area
|
||||||
|
for j := 0 to lItemCount-1 do
|
||||||
|
begin
|
||||||
|
lCurItem := nil;
|
||||||
|
if i = 0 then lCurItem := AStateEx.Items.GetItem(j)
|
||||||
|
else if AStateEx.Items.GetItem(j).GetItemCount >= i then
|
||||||
|
lCurItem := AStateEx.Items.GetItem(j).GetItem(i-1);
|
||||||
|
|
||||||
|
if lCurItem = nil then Continue;
|
||||||
|
|
||||||
|
// Draw the item
|
||||||
|
DrawReportListViewItem(ADest, lCurPos, lItemSize, lCurItem, AState, AStateEx);
|
||||||
|
|
||||||
|
Inc(lCurPos.Y, lItemSize.CY);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Inc(lCurPos.X, lItemSize.CX);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCDDrawerCommon.DrawReportListViewItem(ADest: TCanvas;
|
||||||
|
ADestPos: TPoint; ASize: TSize; ACurItem: TCDListItems; AState: TCDControlState;
|
||||||
|
AStateEx: TCDListViewStateEx);
|
||||||
|
begin
|
||||||
|
ADest.Brush.Style := bsClear;
|
||||||
|
ADest.Pen.Style := psClear;
|
||||||
|
ADest.TextOut(
|
||||||
|
ADestPos.X+GetMeasures(TCDLISTVIEW_COLUMN_TEXT_LEFT_SPACING),
|
||||||
|
ADestPos.Y+GetMeasures(TCDLISTVIEW_LINE_TOP_SPACING),
|
||||||
|
ACurItem.Caption);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCDDrawerCommon.DrawCTabControl(ADest: TCanvas; ADestPos: TPoint;
|
procedure TCDDrawerCommon.DrawCTabControl(ADest: TCanvas; ADestPos: TPoint;
|
||||||
|
@ -369,10 +369,12 @@ type
|
|||||||
FIconOptions: TIconOptions;
|
FIconOptions: TIconOptions;
|
||||||
FListItems: TCDListItems;
|
FListItems: TCDListItems;
|
||||||
FProperties: TListViewProperties;
|
FProperties: TListViewProperties;
|
||||||
|
FShowColumnHeader: Boolean;
|
||||||
FViewStyle: TViewStyle;
|
FViewStyle: TViewStyle;
|
||||||
function GetProperty(AIndex: Integer): Boolean;
|
function GetProperty(AIndex: Integer): Boolean;
|
||||||
procedure SetColumns(AValue: TListColumns);
|
procedure SetColumns(AValue: TListColumns);
|
||||||
procedure SetProperty(AIndex: Integer; AValue: Boolean);
|
procedure SetProperty(AIndex: Integer; AValue: Boolean);
|
||||||
|
procedure SetShowColumnHeader(AValue: Boolean);
|
||||||
procedure SetViewStyle(AValue: TViewStyle);
|
procedure SetViewStyle(AValue: TViewStyle);
|
||||||
protected
|
protected
|
||||||
{ // keyboard
|
{ // keyboard
|
||||||
@ -401,10 +403,11 @@ type
|
|||||||
property Columns: TListColumns read FColumns write SetColumns;
|
property Columns: TListColumns read FColumns write SetColumns;
|
||||||
//property GridLines: Boolean index Ord(lvpGridLines) read GetProperty write SetProperty default False;
|
//property GridLines: Boolean index Ord(lvpGridLines) read GetProperty write SetProperty default False;
|
||||||
property Items: TCDListItems read FListItems;
|
property Items: TCDListItems read FListItems;
|
||||||
property ViewStyle: TViewStyle read FViewStyle default vsList;
|
property ShowColumnHeader: Boolean read FShowColumnHeader write SetShowColumnHeader default True;
|
||||||
|
property ViewStyle: TViewStyle read FViewStyle write SetViewStyle default vsList;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{TCDTabControl}
|
{ TCDTabControl }
|
||||||
|
|
||||||
{ TCDCustomTabControl }
|
{ TCDCustomTabControl }
|
||||||
|
|
||||||
@ -524,187 +527,6 @@ implementation
|
|||||||
resourcestring
|
resourcestring
|
||||||
sTABSHEET_DEFAULT_NAME = 'CTabSheet';
|
sTABSHEET_DEFAULT_NAME = 'CTabSheet';
|
||||||
|
|
||||||
{ TCDListView }
|
|
||||||
|
|
||||||
function TCDListView.GetProperty(AIndex: Integer): Boolean;
|
|
||||||
begin
|
|
||||||
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TCDListView.SetColumns(AValue: TListColumns);
|
|
||||||
begin
|
|
||||||
if FColumns=AValue then Exit;
|
|
||||||
FColumns:=AValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TCDListView.SetProperty(AIndex: Integer; AValue: Boolean);
|
|
||||||
begin
|
|
||||||
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TCDListView.SetViewStyle(AValue: TViewStyle);
|
|
||||||
begin
|
|
||||||
if FViewStyle=AValue then Exit;
|
|
||||||
FViewStyle:=AValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TCDListView.GetControlId: TCDControlID;
|
|
||||||
begin
|
|
||||||
Result := cidListView;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TCDListView.CreateControlStateEx;
|
|
||||||
begin
|
|
||||||
FLVState := TCDListViewStateEx.Create;
|
|
||||||
FStateEx := FLVState;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TCDListView.PrepareControlStateEx;
|
|
||||||
begin
|
|
||||||
inherited PrepareControlStateEx;
|
|
||||||
FLVState.Items := FListItems;
|
|
||||||
FLVState.Columns := FColumns;
|
|
||||||
FLVState.ViewStyle := FViewStyle;
|
|
||||||
end;
|
|
||||||
|
|
||||||
constructor TCDListView.Create(AOwner: TComponent);
|
|
||||||
begin
|
|
||||||
inherited Create(AOwner);
|
|
||||||
Width := 250;
|
|
||||||
Height := 150;
|
|
||||||
FColumns := TListColumns.Create(nil);
|
|
||||||
FListItems := TCDListItems.Create();
|
|
||||||
TabStop := True;
|
|
||||||
// FProperties: TListViewProperties;
|
|
||||||
// FViewStyle: TViewStyle;
|
|
||||||
|
|
||||||
PrepareCurrentDrawer();
|
|
||||||
end;
|
|
||||||
|
|
||||||
destructor TCDListView.Destroy;
|
|
||||||
begin
|
|
||||||
FColumns.Free;
|
|
||||||
FListItems.Free;
|
|
||||||
inherited Destroy;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TCDProgressBar }
|
|
||||||
|
|
||||||
procedure TCDProgressBar.SetMax(AValue: integer);
|
|
||||||
begin
|
|
||||||
if FMax=AValue then Exit;
|
|
||||||
FMax:=AValue;
|
|
||||||
Invalidate;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TCDProgressBar.SetBarShowText(AValue: Boolean);
|
|
||||||
begin
|
|
||||||
if FBarShowText=AValue then Exit;
|
|
||||||
FBarShowText:=AValue;
|
|
||||||
Invalidate;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TCDProgressBar.SetMin(AValue: integer);
|
|
||||||
begin
|
|
||||||
if FMin=AValue then Exit;
|
|
||||||
FMin:=AValue;
|
|
||||||
Invalidate;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TCDProgressBar.SetOrientation(AValue: TProgressBarOrientation);
|
|
||||||
var
|
|
||||||
lOldWidth: Integer;
|
|
||||||
begin
|
|
||||||
if FOrientation=AValue then Exit;
|
|
||||||
FOrientation:=AValue;
|
|
||||||
Invalidate;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TCDProgressBar.SetPosition(AValue: integer);
|
|
||||||
begin
|
|
||||||
if FPosition=AValue then Exit;
|
|
||||||
FPosition:=AValue;
|
|
||||||
Invalidate;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TCDProgressBar.SetSmooth(AValue: Boolean);
|
|
||||||
begin
|
|
||||||
if FSmooth=AValue then Exit;
|
|
||||||
FSmooth:=AValue;
|
|
||||||
Invalidate;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TCDProgressBar.SetStyle(AValue: TProgressBarStyle);
|
|
||||||
begin
|
|
||||||
if FStyle=AValue then Exit;
|
|
||||||
FStyle:=AValue;
|
|
||||||
Invalidate;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TCDProgressBar.GetControlId: TCDControlID;
|
|
||||||
begin
|
|
||||||
Result := cidProgressBar;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TCDProgressBar.CreateControlStateEx;
|
|
||||||
begin
|
|
||||||
FPBState := TCDProgressBarStateEx.Create;
|
|
||||||
FStateEx := FPBState;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TCDProgressBar.PrepareControlStateEx;
|
|
||||||
begin
|
|
||||||
inherited PrepareControlStateEx;
|
|
||||||
if FMax <> FMin then FPBState.PercentPosition := (FPosition-FMin)/(FMax-FMin)
|
|
||||||
else FPBState.PercentPosition := 1.0;
|
|
||||||
FPBState.BarShowText := FBarShowText;
|
|
||||||
FPBState.Style := FStyle;
|
|
||||||
FPBState.Orientation := FOrientation;
|
|
||||||
FPBState.Smooth := FSmooth;
|
|
||||||
end;
|
|
||||||
|
|
||||||
constructor TCDProgressBar.Create(AOwner: TComponent);
|
|
||||||
begin
|
|
||||||
inherited Create(AOwner);
|
|
||||||
Width := 100;
|
|
||||||
Height := 20;
|
|
||||||
FMax := 100;
|
|
||||||
TabStop := False;
|
|
||||||
PrepareCurrentDrawer();
|
|
||||||
end;
|
|
||||||
|
|
||||||
destructor TCDProgressBar.Destroy;
|
|
||||||
begin
|
|
||||||
inherited Destroy;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TCDStaticText }
|
|
||||||
|
|
||||||
function TCDStaticText.GetControlId: TCDControlID;
|
|
||||||
begin
|
|
||||||
Result:=cidStaticText;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TCDStaticText.RealSetText(const Value: TCaption);
|
|
||||||
begin
|
|
||||||
inherited RealSetText(Value);
|
|
||||||
Invalidate;
|
|
||||||
end;
|
|
||||||
|
|
||||||
constructor TCDStaticText.Create(AOwner: TComponent);
|
|
||||||
begin
|
|
||||||
inherited Create(AOwner);
|
|
||||||
Width := 70;
|
|
||||||
Height := 20;
|
|
||||||
TabStop := False;
|
|
||||||
ControlStyle := ControlStyle - [csAcceptsControls];
|
|
||||||
end;
|
|
||||||
|
|
||||||
destructor TCDStaticText.Destroy;
|
|
||||||
begin
|
|
||||||
inherited Destroy;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TCDControl }
|
{ TCDControl }
|
||||||
|
|
||||||
procedure TCDControl.CalculatePreferredSize(var PreferredWidth,
|
procedure TCDControl.CalculatePreferredSize(var PreferredWidth,
|
||||||
@ -1392,6 +1214,33 @@ begin
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TCDStaticText }
|
||||||
|
|
||||||
|
function TCDStaticText.GetControlId: TCDControlID;
|
||||||
|
begin
|
||||||
|
Result:=cidStaticText;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCDStaticText.RealSetText(const Value: TCaption);
|
||||||
|
begin
|
||||||
|
inherited RealSetText(Value);
|
||||||
|
Invalidate;
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TCDStaticText.Create(AOwner: TComponent);
|
||||||
|
begin
|
||||||
|
inherited Create(AOwner);
|
||||||
|
Width := 70;
|
||||||
|
Height := 20;
|
||||||
|
TabStop := False;
|
||||||
|
ControlStyle := ControlStyle - [csAcceptsControls];
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TCDStaticText.Destroy;
|
||||||
|
begin
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TCDTrackBar }
|
{ TCDTrackBar }
|
||||||
|
|
||||||
procedure TCDTrackBar.SetMax(Value: integer);
|
procedure TCDTrackBar.SetMax(Value: integer);
|
||||||
@ -1596,30 +1445,171 @@ begin
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{procedure TCDTrackBar.Paint;
|
{ TCDProgressBar }
|
||||||
var
|
|
||||||
AImage: TLazIntfImage = nil;
|
procedure TCDProgressBar.SetMax(AValue: integer);
|
||||||
ABmp: TBitmap = nil;
|
|
||||||
lCanvas: TFPImageCanvas = nil;
|
|
||||||
begin
|
begin
|
||||||
ABmp := TBitmap.Create;
|
if FMax=AValue then Exit;
|
||||||
try
|
FMax:=AValue;
|
||||||
ABmp.Width := Width;
|
if not (csLoading in ComponentState) then Invalidate;
|
||||||
ABmp.Height := Height;
|
end;
|
||||||
AImage := ABmp.CreateIntfImage;
|
|
||||||
lCanvas := TFPImageCanvas.Create(AImage);
|
procedure TCDProgressBar.SetBarShowText(AValue: Boolean);
|
||||||
// First step of the drawing: FCL TFPCustomCanvas for fast pixel access
|
begin
|
||||||
FCurrentDrawer.DrawToIntfImage(lCanvas, AImage, Self);
|
if FBarShowText=AValue then Exit;
|
||||||
ABmp.LoadFromIntfImage(AImage);
|
FBarShowText:=AValue;
|
||||||
Canvas.Draw(0, 0, ABmp);
|
if not (csLoading in ComponentState) then Invalidate;
|
||||||
finally
|
end;
|
||||||
if lCanvas <> nil then
|
|
||||||
lCanvas.Free;
|
procedure TCDProgressBar.SetMin(AValue: integer);
|
||||||
if AImage <> nil then
|
begin
|
||||||
AImage.Free;
|
if FMin=AValue then Exit;
|
||||||
ABmp.Free;
|
FMin:=AValue;
|
||||||
end;
|
if not (csLoading in ComponentState) then Invalidate;
|
||||||
end;}
|
end;
|
||||||
|
|
||||||
|
procedure TCDProgressBar.SetOrientation(AValue: TProgressBarOrientation);
|
||||||
|
var
|
||||||
|
lOldWidth: Integer;
|
||||||
|
begin
|
||||||
|
if FOrientation=AValue then Exit;
|
||||||
|
FOrientation:=AValue;
|
||||||
|
if not (csLoading in ComponentState) then Invalidate;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCDProgressBar.SetPosition(AValue: integer);
|
||||||
|
begin
|
||||||
|
if FPosition=AValue then Exit;
|
||||||
|
FPosition:=AValue;
|
||||||
|
if not (csLoading in ComponentState) then Invalidate;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCDProgressBar.SetSmooth(AValue: Boolean);
|
||||||
|
begin
|
||||||
|
if FSmooth=AValue then Exit;
|
||||||
|
FSmooth:=AValue;
|
||||||
|
if not (csLoading in ComponentState) then
|
||||||
|
Invalidate;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCDProgressBar.SetStyle(AValue: TProgressBarStyle);
|
||||||
|
begin
|
||||||
|
if FStyle=AValue then Exit;
|
||||||
|
FStyle:=AValue;
|
||||||
|
if not (csLoading in ComponentState) then Invalidate;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCDProgressBar.GetControlId: TCDControlID;
|
||||||
|
begin
|
||||||
|
Result := cidProgressBar;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCDProgressBar.CreateControlStateEx;
|
||||||
|
begin
|
||||||
|
FPBState := TCDProgressBarStateEx.Create;
|
||||||
|
FStateEx := FPBState;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCDProgressBar.PrepareControlStateEx;
|
||||||
|
begin
|
||||||
|
inherited PrepareControlStateEx;
|
||||||
|
if FMax <> FMin then FPBState.PercentPosition := (FPosition-FMin)/(FMax-FMin)
|
||||||
|
else FPBState.PercentPosition := 1.0;
|
||||||
|
FPBState.BarShowText := FBarShowText;
|
||||||
|
FPBState.Style := FStyle;
|
||||||
|
FPBState.Orientation := FOrientation;
|
||||||
|
FPBState.Smooth := FSmooth;
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TCDProgressBar.Create(AOwner: TComponent);
|
||||||
|
begin
|
||||||
|
inherited Create(AOwner);
|
||||||
|
Width := 100;
|
||||||
|
Height := 20;
|
||||||
|
FMax := 100;
|
||||||
|
TabStop := False;
|
||||||
|
PrepareCurrentDrawer();
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TCDProgressBar.Destroy;
|
||||||
|
begin
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TCDListView }
|
||||||
|
|
||||||
|
function TCDListView.GetProperty(AIndex: Integer): Boolean;
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCDListView.SetColumns(AValue: TListColumns);
|
||||||
|
begin
|
||||||
|
if FColumns=AValue then Exit;
|
||||||
|
FColumns:=AValue;
|
||||||
|
if not (csLoading in ComponentState) then Invalidate;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCDListView.SetProperty(AIndex: Integer; AValue: Boolean);
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCDListView.SetShowColumnHeader(AValue: Boolean);
|
||||||
|
begin
|
||||||
|
if FShowColumnHeader=AValue then Exit;
|
||||||
|
FShowColumnHeader:=AValue;
|
||||||
|
if not (csLoading in ComponentState) then Invalidate;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCDListView.SetViewStyle(AValue: TViewStyle);
|
||||||
|
begin
|
||||||
|
if FViewStyle=AValue then Exit;
|
||||||
|
FViewStyle:=AValue;
|
||||||
|
if not (csLoading in ComponentState) then Invalidate;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCDListView.GetControlId: TCDControlID;
|
||||||
|
begin
|
||||||
|
Result := cidListView;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCDListView.CreateControlStateEx;
|
||||||
|
begin
|
||||||
|
FLVState := TCDListViewStateEx.Create;
|
||||||
|
FStateEx := FLVState;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCDListView.PrepareControlStateEx;
|
||||||
|
begin
|
||||||
|
inherited PrepareControlStateEx;
|
||||||
|
FLVState.Items := FListItems;
|
||||||
|
FLVState.Columns := FColumns;
|
||||||
|
FLVState.ViewStyle := FViewStyle;
|
||||||
|
FLVState.ShowColumnHeader := FShowColumnHeader;
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TCDListView.Create(AOwner: TComponent);
|
||||||
|
begin
|
||||||
|
inherited Create(AOwner);
|
||||||
|
Width := 250;
|
||||||
|
Height := 150;
|
||||||
|
FColumns := TListColumns.Create(nil);
|
||||||
|
FListItems := TCDListItems.Create();
|
||||||
|
TabStop := True;
|
||||||
|
FShowColumnHeader := True;
|
||||||
|
// FProperties: TListViewProperties;
|
||||||
|
// FViewStyle: TViewStyle;
|
||||||
|
|
||||||
|
PrepareCurrentDrawer();
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TCDListView.Destroy;
|
||||||
|
begin
|
||||||
|
FColumns.Free;
|
||||||
|
FListItems.Free;
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TCDTabSheet }
|
{ TCDTabSheet }
|
||||||
|
|
||||||
|
@ -12,6 +12,8 @@ uses
|
|||||||
const
|
const
|
||||||
CDDRAWSTYLE_COUNT = 19;
|
CDDRAWSTYLE_COUNT = 19;
|
||||||
|
|
||||||
|
cddTestStr = 'ŹÇ'; // Used for testing text height
|
||||||
|
|
||||||
// Measures
|
// Measures
|
||||||
TCDEDIT_LEFT_TEXT_SPACING = $400; // The space between the start of the text and the left end of the control
|
TCDEDIT_LEFT_TEXT_SPACING = $400; // The space between the start of the text and the left end of the control
|
||||||
TCDEDIT_RIGHT_TEXT_SPACING = $401; // The space between the end of the text and the right end of the control
|
TCDEDIT_RIGHT_TEXT_SPACING = $401; // The space between the end of the text and the right end of the control
|
||||||
@ -28,6 +30,12 @@ const
|
|||||||
TCDTRACKBAR_TOP_SPACING = $1002;
|
TCDTRACKBAR_TOP_SPACING = $1002;
|
||||||
TCDTRACKBAR_FRAME_HEIGHT = $1003;
|
TCDTRACKBAR_FRAME_HEIGHT = $1003;
|
||||||
|
|
||||||
|
TCDLISTVIEW_COLUMN_LEFT_SPACING = $1200;
|
||||||
|
TCDLISTVIEW_COLUMN_RIGHT_SPACING = $1201;
|
||||||
|
TCDLISTVIEW_COLUMN_TEXT_LEFT_SPACING = $1202;
|
||||||
|
TCDLISTVIEW_LINE_TOP_SPACING = $1203;
|
||||||
|
TCDLISTVIEW_LINE_BOTTOM_SPACING = $1204;
|
||||||
|
|
||||||
// Measures Ex
|
// Measures Ex
|
||||||
TCDCONTROL_CAPTION_WIDTH = $100;
|
TCDCONTROL_CAPTION_WIDTH = $100;
|
||||||
TCDCONTROL_CAPTION_HEIGHT = $101;
|
TCDCONTROL_CAPTION_HEIGHT = $101;
|
||||||
@ -75,7 +83,7 @@ type
|
|||||||
csfOn,
|
csfOn,
|
||||||
csfOff,
|
csfOff,
|
||||||
csfPartiallyOn
|
csfPartiallyOn
|
||||||
{ // for TCDPageControl
|
{ // for TCDComboBox
|
||||||
csfDownArrow,
|
csfDownArrow,
|
||||||
// for tool button
|
// for tool button
|
||||||
csfAutoRaise,
|
csfAutoRaise,
|
||||||
@ -149,6 +157,8 @@ type
|
|||||||
constructor Create;
|
constructor Create;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
function Add(ACaption: string; AImageIndex, AStateIndex: Integer): TCDListItems;
|
function Add(ACaption: string; AImageIndex, AStateIndex: Integer): TCDListItems;
|
||||||
|
function GetItem(AIndex: Integer): TCDListItems;
|
||||||
|
function GetItemCount: Integer;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TCDListViewStateEx = class(TCDControlStateEx)
|
TCDListViewStateEx = class(TCDControlStateEx)
|
||||||
@ -156,6 +166,9 @@ type
|
|||||||
Columns: TListColumns; // just a reference, never free
|
Columns: TListColumns; // just a reference, never free
|
||||||
Items: TCDListItems; // just a reference, never free
|
Items: TCDListItems; // just a reference, never free
|
||||||
ViewStyle: TViewStyle;
|
ViewStyle: TViewStyle;
|
||||||
|
FirstVisibleColumn: Integer; // 0-based index
|
||||||
|
FirstVisibleLine: Integer; // 0-based index, remember that the header is always visible or always invisible
|
||||||
|
ShowColumnHeader: Boolean;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TCDCTabControlStateEx = class(TCDControlStateEx)
|
TCDCTabControlStateEx = class(TCDControlStateEx)
|
||||||
@ -278,6 +291,10 @@ type
|
|||||||
// TCDListView
|
// TCDListView
|
||||||
procedure DrawListView(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
procedure DrawListView(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||||
AState: TCDControlState; AStateEx: TCDListViewStateEx); virtual; abstract;
|
AState: TCDControlState; AStateEx: TCDListViewStateEx); virtual; abstract;
|
||||||
|
procedure DrawReportListView(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||||
|
AState: TCDControlState; AStateEx: TCDListViewStateEx); virtual; abstract;
|
||||||
|
procedure DrawReportListViewItem(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||||
|
ACurItem: TCDListItems; AState: TCDControlState; AStateEx: TCDListViewStateEx); virtual; abstract;
|
||||||
// TCDCustomTabControl
|
// TCDCustomTabControl
|
||||||
procedure DrawCTabControl(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
procedure DrawCTabControl(ADest: TCanvas; ADestPos: TPoint; ASize: TSize;
|
||||||
AState: TCDControlState; AStateEx: TCDCTabControlStateEx); virtual; abstract;
|
AState: TCDControlState; AStateEx: TCDCTabControlStateEx); virtual; abstract;
|
||||||
@ -357,6 +374,16 @@ begin
|
|||||||
Childs.Add(Pointer(Result));
|
Childs.Add(Pointer(Result));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCDListItems.GetItem(AIndex: Integer): TCDListItems;
|
||||||
|
begin
|
||||||
|
Result := TCDListItems(Childs.Items[AIndex]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCDListItems.GetItemCount: Integer;
|
||||||
|
begin
|
||||||
|
Result := Childs.Count;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TCDDrawer }
|
{ TCDDrawer }
|
||||||
|
|
||||||
constructor TCDDrawer.Create;
|
constructor TCDDrawer.Create;
|
||||||
|
Loading…
Reference in New Issue
Block a user