mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-09 19:35:57 +02:00
cocoa: fix for custom rect draw - only perform it, if custom drawing is requested via LCL control style. Fix for #32845
git-svn-id: trunk@56821 -
This commit is contained in:
parent
fdcf607d17
commit
8d9100d064
@ -599,6 +599,7 @@ type
|
|||||||
callback: IListBoxCallback;
|
callback: IListBoxCallback;
|
||||||
resultNS: NSString;
|
resultNS: NSString;
|
||||||
list: TCocoaStringList;
|
list: TCocoaStringList;
|
||||||
|
isCustomDraw: Boolean;
|
||||||
function acceptsFirstResponder: Boolean; override;
|
function acceptsFirstResponder: Boolean; override;
|
||||||
function becomeFirstResponder: Boolean; override;
|
function becomeFirstResponder: Boolean; override;
|
||||||
function resignFirstResponder: Boolean; override;
|
function resignFirstResponder: Boolean; override;
|
||||||
@ -2844,6 +2845,7 @@ var
|
|||||||
LCLObject: TCustomListBox;
|
LCLObject: TCustomListBox;
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
|
if not isCustomDraw then Exit;
|
||||||
ctx := TCocoaContext.Create(NSGraphicsContext.currentContext);
|
ctx := TCocoaContext.Create(NSGraphicsContext.currentContext);
|
||||||
DrawStruct.Area := NSRectToRect(rectOfRow(row));
|
DrawStruct.Area := NSRectToRect(rectOfRow(row));
|
||||||
DrawStruct.DC := HDC(ctx);
|
DrawStruct.DC := HDC(ctx);
|
||||||
|
@ -73,6 +73,7 @@ begin
|
|||||||
list.setDataSource(list);
|
list.setDataSource(list);
|
||||||
list.setDelegate(list);
|
list.setDelegate(list);
|
||||||
list.AllowMixedState := TCustomCheckListBox(AWinControl).AllowGrayed;
|
list.AllowMixedState := TCustomCheckListBox(AWinControl).AllowGrayed;
|
||||||
|
ListBoxSetStyle(list, TCustomCheckListBox(AWinControl).Style);
|
||||||
|
|
||||||
scroll := EmbedInScrollView(list);
|
scroll := EmbedInScrollView(list);
|
||||||
if not Assigned(scroll) then
|
if not Assigned(scroll) then
|
||||||
|
@ -109,8 +109,8 @@ type
|
|||||||
//class procedure SetBorder(const ACustomListBox: TCustomListBox); override;
|
//class procedure SetBorder(const ACustomListBox: TCustomListBox); override;
|
||||||
class procedure SetItemIndex(const ACustomListBox: TCustomListBox; const AIndex: integer); override;
|
class procedure SetItemIndex(const ACustomListBox: TCustomListBox; const AIndex: integer); override;
|
||||||
class procedure SetSelectionMode(const ACustomListBox: TCustomListBox; const AExtendedSelect, AMultiSelect: boolean); override;
|
class procedure SetSelectionMode(const ACustomListBox: TCustomListBox; const AExtendedSelect, AMultiSelect: boolean); override;
|
||||||
{class procedure SetStyle(const ACustomListBox: TCustomListBox); override;
|
class procedure SetStyle(const ACustomListBox: TCustomListBox); override;
|
||||||
class procedure SetSorted(const ACustomListBox: TCustomListBox; AList: TStrings; ASorted: boolean); override;}
|
{class procedure SetSorted(const ACustomListBox: TCustomListBox; AList: TStrings; ASorted: boolean); override;}
|
||||||
class procedure SetTopIndex(const ACustomListBox: TCustomListBox; const NewTopIndex: integer); override;
|
class procedure SetTopIndex(const ACustomListBox: TCustomListBox; const NewTopIndex: integer); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -268,6 +268,7 @@ function AllocTextField(ATarget: TWinControl; const AParams: TCreateParams): TCo
|
|||||||
function AllocSecureTextField(ATarget: TWinControl; const AParams: TCreateParams): TCocoaSecureTextField;
|
function AllocSecureTextField(ATarget: TWinControl; const AParams: TCreateParams): TCocoaSecureTextField;
|
||||||
|
|
||||||
function GetListBox(AWinControl: TWinControl): TCocoaListBox;
|
function GetListBox(AWinControl: TWinControl): TCocoaListBox;
|
||||||
|
procedure ListBoxSetStyle(list: TCocoaListBox; AStyle: TListBoxStyle);
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
@ -467,6 +468,7 @@ begin
|
|||||||
btn.adjustFontToControlSize:=true;
|
btn.adjustFontToControlSize:=true;
|
||||||
// these heights were received from Xcode builder, where the height cannot be changed for a button control
|
// these heights were received from Xcode builder, where the height cannot be changed for a button control
|
||||||
// the actual size of the button (the difference between top pixel and bottom pixel, is less than frame size
|
// the actual size of the button (the difference between top pixel and bottom pixel, is less than frame size
|
||||||
|
// also, the "mini" button seems to be wider, than
|
||||||
Result := TLCLIntfHandle(btn);
|
Result := TLCLIntfHandle(btn);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1344,6 +1346,12 @@ begin
|
|||||||
Result := TCocoaListBox(TCocoaScrollView(AWinControl.Handle).documentView);
|
Result := TCocoaListBox(TCocoaScrollView(AWinControl.Handle).documentView);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure ListBoxSetStyle(list: TCocoaListBox; AStyle: TListBoxStyle);
|
||||||
|
begin
|
||||||
|
if not Assigned(list) then Exit;
|
||||||
|
list.isCustomDraw := AStyle in [lbOwnerDrawFixed, lbOwnerDrawVariable];
|
||||||
|
end;
|
||||||
|
|
||||||
class function TCocoaWSCustomListBox.CreateHandle(const AWinControl:TWinControl;
|
class function TCocoaWSCustomListBox.CreateHandle(const AWinControl:TWinControl;
|
||||||
const AParams:TCreateParams):TLCLIntfHandle;
|
const AParams:TCreateParams):TLCLIntfHandle;
|
||||||
var
|
var
|
||||||
@ -1364,6 +1372,7 @@ begin
|
|||||||
list.setDataSource(list);
|
list.setDataSource(list);
|
||||||
list.setDelegate(list);
|
list.setDelegate(list);
|
||||||
list.setAllowsMultipleSelection(lclListBox.MultiSelect);
|
list.setAllowsMultipleSelection(lclListBox.MultiSelect);
|
||||||
|
ListBoxSetStyle(list, TCustomListBox(AWinControl).Style);
|
||||||
|
|
||||||
scroll := EmbedInScrollView(list);
|
scroll := EmbedInScrollView(list);
|
||||||
if not Assigned(scroll) then
|
if not Assigned(scroll) then
|
||||||
@ -1507,6 +1516,15 @@ begin
|
|||||||
list.setAllowsMultipleSelection(AMultiSelect);
|
list.setAllowsMultipleSelection(AMultiSelect);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
class procedure TCocoaWSCustomListBox.SetStyle(const ACustomListBox: TCustomListBox);
|
||||||
|
var
|
||||||
|
view: TCocoaListBox;
|
||||||
|
begin
|
||||||
|
view := GetListBox(ACustomListBox);
|
||||||
|
ListBoxSetStyle(view, TCustomListBox(ACustomListBox).Style);
|
||||||
|
view.setNeedsDisplay;
|
||||||
|
end;
|
||||||
|
|
||||||
class procedure TCocoaWSCustomListBox.SetTopIndex(const ACustomListBox: TCustomListBox; const NewTopIndex: integer);
|
class procedure TCocoaWSCustomListBox.SetTopIndex(const ACustomListBox: TCustomListBox; const NewTopIndex: integer);
|
||||||
var
|
var
|
||||||
view: TCocoaListBox;
|
view: TCocoaListBox;
|
||||||
|
Loading…
Reference in New Issue
Block a user