You've already forked lazarus-ccr
ExCtrls: New properties SelectedColor and SelectedTextColor of TColumnComboBoxEx.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7943 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -44,6 +44,8 @@ type
|
||||
FParser: TStringList;
|
||||
FColSeparatorColor: TColor;
|
||||
FShowColSeparators: Boolean;
|
||||
FSelectedColor: TColor;
|
||||
FSelectedTextColor: TColor;
|
||||
FTextHeight: Integer;
|
||||
function ColumnMarginStored: Boolean;
|
||||
function GetTextSize(const aText: String): TSize;
|
||||
@ -54,14 +56,16 @@ type
|
||||
procedure SetDelimiter(aValue: AnsiChar);
|
||||
procedure SetOffsets;
|
||||
procedure SetShowColSeparators(aValue: Boolean);
|
||||
procedure SetSelectedColor(AValue: TColor);
|
||||
procedure SetSelectedTextColor(AValue: TColor);
|
||||
protected
|
||||
procedure CreateHandle; override;
|
||||
procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
|
||||
const AXProportion, AYProportion: Double); override;
|
||||
procedure DrawItem(Index: Integer; ARect: TRect; State: TOwnerDrawState); override;
|
||||
class function GetControlClassDefaultSize: TSize; override;
|
||||
procedure GetItems; override;
|
||||
procedure InitializeWnd; override;
|
||||
procedure DrawItem(Index: Integer; ARect: TRect; State: TOwnerDrawState); override;
|
||||
procedure FontChanged(Sender: TObject); override;
|
||||
procedure SetItems(const Value: TStrings); override;
|
||||
procedure SetStyle(AValue: TComboBoxStyle); override;
|
||||
@ -74,6 +78,8 @@ type
|
||||
property ColumnMargin: Integer read FColumnMargin write SetColumnMargin stored ColumnMarginStored;
|
||||
property ColSeparatorColor: TColor read FColSeparatorColor write SetColSeparatorColor default clSilver;
|
||||
property Delimiter: AnsiChar read FDelimiter write SetDelimiter default ',';
|
||||
property SelectedColor: TColor read FSelectedColor write SetSelectedColor default clHighlight;
|
||||
property SelectedTextColor: TColor read FSelectedTextColor write SetSelectedTextColor default clHighlightText;
|
||||
property ShowColSeparators: Boolean read FShowColSeparators write SetShowColSeparators default False;
|
||||
// inherited comboBox properties
|
||||
property Align;
|
||||
@ -164,6 +170,8 @@ begin
|
||||
FColSeparatorColor := clSilver;
|
||||
FDelimiter := ',';
|
||||
FShowColSeparators := False;
|
||||
FSelectedColor := clHighlight;
|
||||
FSelectedTextColor := clHighlightText;
|
||||
SetStyle(csOwnerDrawFixed);
|
||||
FOffsets := nil;
|
||||
FColumnCount := 0;
|
||||
@ -204,6 +212,7 @@ procedure TColumnComboBoxEx.DrawItem(Index: Integer; ARect: TRect; State: TOwner
|
||||
var
|
||||
i, y, xl: Integer;
|
||||
txt: String;
|
||||
savedColor, savedFontColor: TColor;
|
||||
begin
|
||||
if Assigned(OnDrawItem) then
|
||||
begin
|
||||
@ -211,14 +220,22 @@ begin
|
||||
exit;
|
||||
end;
|
||||
|
||||
savedColor := Canvas.Brush.Color;
|
||||
savedFontColor := Canvas.Font.Color;
|
||||
|
||||
if DroppedDown then
|
||||
begin
|
||||
if (odSelected in State) then
|
||||
Canvas.Brush.Color := clHighlight
|
||||
else if (Canvas.Brush.Color <> Color) then
|
||||
begin
|
||||
Canvas.Brush.Color := FSelectedColor;
|
||||
Canvas.Font.Color := FSelectedTextColor;
|
||||
end else
|
||||
if (Canvas.Brush.Color <> Color) then
|
||||
Canvas.Brush.Color := Color;
|
||||
Canvas.Brush.Style := bsSolid;
|
||||
Canvas.FillRect(ARect);
|
||||
end;
|
||||
end else
|
||||
Canvas.Font.Color := clWindowText;
|
||||
|
||||
if Index < 0 then
|
||||
txt := ''
|
||||
@ -230,9 +247,7 @@ begin
|
||||
FParser.DelimitedText := txt;
|
||||
|
||||
y := ARect.Top + (ARect.Height - FTextHeight) shr 1;
|
||||
|
||||
Canvas.Brush.Style := bsClear; // transparent text background
|
||||
|
||||
if Assigned(FOffsets) then
|
||||
begin
|
||||
for i := 0 to FParser.Count-1 do
|
||||
@ -253,6 +268,9 @@ begin
|
||||
end
|
||||
else
|
||||
Canvas.TextOut(xl, y, txt);
|
||||
|
||||
Canvas.Brush.Color := savedColor;
|
||||
Canvas.Font.Color := savedFontColor;
|
||||
end;
|
||||
|
||||
|
||||
@ -418,6 +436,24 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TColumnComboBoxEx.SetSelectedColor(AValue: TColor);
|
||||
begin
|
||||
if FSelectedColor <> AValue then
|
||||
begin
|
||||
FSelectedColor := AValue;
|
||||
Invalidate;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TColumnComboBoxEx.SetSelectedTextColor(AValue: TColor);
|
||||
begin
|
||||
if FSelectedTextColor <> AValue then
|
||||
begin
|
||||
FSelectedTextColor := AValue;
|
||||
Invalidate;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TColumnComboBoxEx.SetShowColSeparators(aValue: Boolean);
|
||||
begin
|
||||
if FShowColSeparators <> aValue then
|
||||
|
Reference in New Issue
Block a user