You've already forked lazarus-ccr
jvcllaz: Fix painting issues in JvComboListbox demo on Linux.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6878 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -10,8 +10,6 @@ object JvComboListBoxDemoFrm: TJvComboListBoxDemoFrm
|
|||||||
Constraints.MinHeight = 480
|
Constraints.MinHeight = 480
|
||||||
Constraints.MinWidth = 500
|
Constraints.MinWidth = 500
|
||||||
Font.Color = clWindowText
|
Font.Color = clWindowText
|
||||||
Font.Height = -11
|
|
||||||
Font.Name = 'MS Shell Dlg 2'
|
|
||||||
OnCreate = FormCreate
|
OnCreate = FormCreate
|
||||||
LCLVersion = '2.1.0.0'
|
LCLVersion = '2.1.0.0'
|
||||||
object Splitter1: TSplitter
|
object Splitter1: TSplitter
|
||||||
|
@ -102,6 +102,7 @@ type
|
|||||||
FOnGetText: TJvListBoxDataEvent;
|
FOnGetText: TJvListBoxDataEvent;
|
||||||
procedure SetDrawStyle(const Value: TJvComboListBoxDrawStyle);
|
procedure SetDrawStyle(const Value: TJvComboListBoxDrawStyle);
|
||||||
function DestRect(Picture: TPicture; ARect: TRect): TRect;
|
function DestRect(Picture: TPicture; ARect: TRect): TRect;
|
||||||
|
procedure FixItemRect(var ARect: TRect);
|
||||||
function GetOffset(OrigRect, ImageRect: TRect): TRect;
|
function GetOffset(OrigRect, ImageRect: TRect): TRect;
|
||||||
procedure SetButtonWidth(const Value: Integer);
|
procedure SetButtonWidth(const Value: Integer);
|
||||||
procedure SetDropdownMenu(const Value: TPopupMenu);
|
procedure SetDropdownMenu(const Value: TPopupMenu);
|
||||||
@ -203,7 +204,7 @@ type
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Math, Themes, JvJVCLUtils;
|
Types, Math, Themes, LCLPlatformDef, InterfaceBase, JvJVCLUtils;
|
||||||
|
|
||||||
constructor TJvComboListBox.Create(AOwner: TComponent);
|
constructor TJvComboListBox.Create(AOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
@ -362,9 +363,9 @@ var
|
|||||||
uState: Cardinal;
|
uState: Cardinal;
|
||||||
details: TThemedElementDetails;
|
details: TThemedElementDetails;
|
||||||
begin
|
begin
|
||||||
if ThemeServices.ThemesEnabled then begin
|
if ThemeServices.ThemesEnabled and (WidgetSet.LclPlatform <> lpQT) then begin
|
||||||
details := ThemeServices.GetElementDetails(DROPDOWN_DETAILS[Highlight, Pushed]);
|
details := ThemeServices.GetElementDetails(DROPDOWN_DETAILS[Highlight, Pushed]);
|
||||||
ThemeServices.DrawElement(ACanvas.Handle, details, R, nil)
|
ThemeServices.DrawElement(ACanvas.Handle, details, R, nil);
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
uState := DFCS_SCROLLDOWN;
|
uState := DFCS_SCROLLDOWN;
|
||||||
@ -389,6 +390,7 @@ var
|
|||||||
begin
|
begin
|
||||||
if (Index < 0) or (Index >= Items.Count) or Assigned(OnDrawItem) then
|
if (Index < 0) or (Index >= Items.Count) or Assigned(OnDrawItem) then
|
||||||
Exit;
|
Exit;
|
||||||
|
FixItemRect(ARect);
|
||||||
Canvas.Lock;
|
Canvas.Lock;
|
||||||
try
|
try
|
||||||
if State * [odSelected, odFocused] <> [] then
|
if State * [odSelected, odFocused] <> [] then
|
||||||
@ -486,6 +488,15 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TJvComboListBox.FixItemRect(var ARect: TRect);
|
||||||
|
var
|
||||||
|
w: Integer;
|
||||||
|
begin
|
||||||
|
if Columns = 0 then w := ClientWidth else w := ClientWidth div Columns;
|
||||||
|
if ARect.Right - ARect.Left > w then
|
||||||
|
ARect.Right := ARect.Left + w;
|
||||||
|
end;
|
||||||
|
|
||||||
function TJvComboListBox.GetOffset(OrigRect, ImageRect: TRect): TRect;
|
function TJvComboListBox.GetOffset(OrigRect, ImageRect: TRect): TRect;
|
||||||
var
|
var
|
||||||
W, H, W2, H2: Integer;
|
W, H, W2, H2: Integer;
|
||||||
@ -517,19 +528,20 @@ end;
|
|||||||
|
|
||||||
procedure TJvComboListBox.InvalidateItem(Index: Integer);
|
procedure TJvComboListBox.InvalidateItem(Index: Integer);
|
||||||
var
|
var
|
||||||
R, R2: TRect;
|
R: TRect;
|
||||||
begin
|
begin
|
||||||
if Index < 0 then
|
if Index < 0 then
|
||||||
Index := ItemIndex;
|
Index := ItemIndex;
|
||||||
R := ItemRect(Index);
|
R := ItemRect(Index);
|
||||||
R2 := R;
|
// R2 := R;
|
||||||
// we only want to redraw the combo button
|
// we only want to redraw the combo button
|
||||||
if not IsRectEmpty(R) then
|
if not IsRectEmpty(R) then
|
||||||
begin
|
begin
|
||||||
|
FixItemRect(R);
|
||||||
R.Right := R.Right - ButtonWidth;
|
R.Right := R.Right - ButtonWidth;
|
||||||
// don't redraw content, just button
|
// don't redraw content, just button
|
||||||
ExcludeClipRect(Canvas.Handle, R.Left, R.Top, R.Right, R.Bottom);
|
ExcludeClipRect(Canvas.Handle, R.Left, R.Top, R.Right, R.Bottom);
|
||||||
InvalidateRect(Handle, @R2, False);
|
InvalidateRect(Handle, @R, False);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -547,6 +559,7 @@ begin
|
|||||||
P := Point(X, Y);
|
P := Point(X, Y);
|
||||||
I := ItemAtPos(P, True);
|
I := ItemAtPos(P, True);
|
||||||
R := ItemRect(I);
|
R := ItemRect(I);
|
||||||
|
FixItemRect(R);
|
||||||
if (I = ItemIndex) and (X >= R.Right - ButtonWidth) and (X <= R.Right) then
|
if (I = ItemIndex) and (X >= R.Right - ButtonWidth) and (X <= R.Right) then
|
||||||
begin
|
begin
|
||||||
FMouseOver := True;
|
FMouseOver := True;
|
||||||
@ -588,6 +601,7 @@ begin
|
|||||||
P := Point(X, Y);
|
P := Point(X, Y);
|
||||||
I := ItemAtPos(P, True);
|
I := ItemAtPos(P, True);
|
||||||
R := ItemRect(I);
|
R := ItemRect(I);
|
||||||
|
FixItemRect(R);
|
||||||
if HotTrackCombo and (I <> FLastHotTrack) then
|
if HotTrackCombo and (I <> FLastHotTrack) then
|
||||||
begin
|
begin
|
||||||
if FLastHotTrack > -1 then
|
if FLastHotTrack > -1 then
|
||||||
|
Reference in New Issue
Block a user