cocoa: support of BorderStyle property for the common rectangular controls

git-svn-id: trunk@59024 -
This commit is contained in:
dmitry 2018-09-16 01:17:16 +00:00
parent c38c08ac2d
commit 56d4ce821b
4 changed files with 68 additions and 4 deletions

View File

@ -138,6 +138,7 @@ type
out ANSColumn: NSTableColumn; const ALV: TCustomListView; const AIndex: Integer; ASecondIndex: Integer = -1): Boolean;
published
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
class procedure SetBorderStyle(const AWinControl: TWinControl; const ABorderStyle: TBorderStyle); override;
// Column
class procedure ColumnDelete(const ALV: TCustomListView; const AIndex: Integer); override;
class function ColumnGetWidth(const ALV: TCustomListView; const AIndex: Integer; const {%H-}AColumn: TListColumn): Integer; override;
@ -796,12 +797,22 @@ begin
lTableLV.setDelegate(lTableLV);
lTableLV.setAllowsColumnReordering(False);
lCocoaLV.callback := lclcb;
ScrollViewSetBorderStyle(lCocoaLV, TCustomListView(AWinControl).BorderStyle);
{$IFDEF COCOA_DEBUG_LISTVIEW}
WriteLn(Format('[TCocoaWSCustomListView.CreateHandle] headerView=%d', [PtrInt(lTableLV.headerView)]));
{$ENDIF}
end;
end;
class procedure TCocoaWSCustomListView.SetBorderStyle(
const AWinControl: TWinControl; const ABorderStyle: TBorderStyle);
begin
if not Assigned(AWinControl) or not AWinControl.HandleAllocated then Exit;
ScrollViewSetBorderStyle(NSScrollView(AWinControl.Handle), ABorderStyle);
end;
class procedure TCocoaWSCustomListView.ColumnDelete(const ALV: TCustomListView;
const AIndex: Integer);
var

View File

@ -148,6 +148,8 @@ function EmbedInManualScrollView(AView: NSView): TCocoaManualScrollView;
function HWNDToTargetObject(AFormHandle: HWND): TObject;
procedure ScrollViewSetBorderStyle(sv: NSScrollView; astyle: TBorderStyle);
implementation
uses
@ -158,6 +160,17 @@ var
{$I mackeycodes.inc}
procedure ScrollViewSetBorderStyle(sv: NSScrollView; astyle: TBorderStyle);
const
NSBorderStyle : array [TBorderStyle] of NSBorderType = (
NSNoBorder, // bsNone
NSBezelBorder // bsSingle (NSLineBorder is too thick)
);
begin
if not Assigned(sv) then Exit;
sv.setBorderType( NSBorderStyle[astyle] );
end;
function EmbedInScrollView(AView: NSView; AReleaseView: Boolean): TCocoaScrollView;
var
r: TRect;

View File

@ -68,7 +68,8 @@ type
private
protected
public
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
class procedure SetBorderStyle(const AWinControl: TWinControl; const ABorderStyle: TBorderStyle); override;
end;
{ TCocoaWSScrollBox }
@ -425,9 +426,17 @@ begin
docview.setAutoresizingMask(NSViewWidthSizable or NSViewHeightSizable);
scrollcon.callback := lcl;
scrollcon.setDocumentView(docview);
ScrollViewSetBorderStyle(scrollcon, TScrollingWinControl(AWincontrol).BorderStyle);
Result := TLCLIntfHandle(scrollcon);
end;
class procedure TCocoaWSScrollingWinControl.SetBorderStyle(
const AWinControl: TWinControl; const ABorderStyle: TBorderStyle);
begin
if not Assigned(AWinControl) or not AWincontrol.HandleAllocated then Exit;
ScrollViewSetBorderStyle( NSScrollView(AWinControl.Handle), ABorderStyle);
end;
{ TCocoaWSCustomForm }

View File

@ -109,7 +109,7 @@ type
class function GetTopIndex(const ACustomListBox: TCustomListBox): integer; override;
class procedure SelectItem(const ACustomListBox: TCustomListBox; AIndex: integer; ASelected: boolean); override;
//class procedure SetBorderStyle(const AWinControl: TWinControl; const ABorderStyle: TBorderStyle); override;
class procedure SetBorderStyle(const AWinControl: TWinControl; const ABorderStyle: TBorderStyle); override;
//class procedure SetBorder(const ACustomListBox: TCustomListBox); override;
class procedure SetItemIndex(const ACustomListBox: TCustomListBox; const AIndex: integer); override;
class procedure SetSelectionMode(const ACustomListBox: TCustomListBox; const AExtendedSelect, AMultiSelect: boolean); override;
@ -128,6 +128,7 @@ type
// WSControl functions
class procedure SetColor(const AWinControl: TWinControl); override;
class procedure SetBorderStyle(const AWinControl: TWinControl; const ABorderStyle: TBorderStyle); override;
// WSEdit functions
class function GetSelStart(const ACustomEdit: TCustomEdit): integer; override;
@ -311,6 +312,7 @@ procedure TextViewSetWordWrap(txt: NSTextView; lScroll: NSScrollView; NewWordWra
function AlignmentLCLToCocoa(al: TAlignment): NSTextAlignment;
procedure TextViewSetAllignment(txt: NSTextView; align: TAlignment);
procedure TextFieldSetAllignment(txt: NSTextField; align: TAlignment);
procedure TextFieldSetBorderStyle(txt: NSTextField; astyle: TBorderStyle);
procedure RadioButtonSwitchSiblings(checkedRadio: NSButton);
procedure ScrollViewSetScrollStyles(AScroll: TCocoaScrollView; AStyles: TScrollStyle);
@ -320,6 +322,7 @@ function ComboBoxIsReadOnly(cmb: TCustomComboBox): Boolean;
function ComboBoxIsOwnerDrawn(AStyle: TComboBoxStyle): Boolean;
function ComboBoxIsVariable(AStyle: TComboBoxStyle): Boolean;
implementation
const
@ -396,6 +399,15 @@ begin
end;
end;
procedure TextFieldSetBorderStyle(txt: NSTextField; astyle: TBorderStyle);
begin
if not Assigned(txt) then Exit;
if astyle = bsNone then
txt.setBezeled(false)
else
txt.setBezeled(true);
end;
procedure RadioButtonSwitchSiblings(checkedRadio: NSButton);
var
SubView : NSView;
@ -853,6 +865,7 @@ begin
NSCell(field.cell).setWraps(false);
NSCell(field.cell).setScrollable(true);
TextFieldSetAllignment(field, TCustomEdit(AWinControl).Alignment);
TextFieldSetBorderStyle(field, TCustomEdit(AWinControl).BorderStyle);
Result:=TLCLIntfHandle(field);
end;
@ -869,6 +882,12 @@ begin
field.setBackgroundColor( ColorToNSColor(ColorToRGB(AWinControl.Color)));
end;
class procedure TCocoaWSCustomEdit.SetBorderStyle(
const AWinControl: TWinControl; const ABorderStyle: TBorderStyle);
begin
inherited SetBorderStyle(AWinControl, ABorderStyle);
end;
class function TCocoaWSCustomEdit.GetSelStart(const ACustomEdit: TCustomEdit): integer;
var
field : TCocoaTextField;
@ -1257,8 +1276,7 @@ begin
scr.setAutohidesScrollers(ScrollerAutoHide[TMemo(AWinControl).ScrollBars]);
scr.setDrawsBackground(false);
if TCustomMemo(AWinControl).BorderStyle=bsSingle then
scr.setBorderType(NSBezelBorder);
ScrollViewSetBorderStyle(scr, TCustomMemo(AWinControl).BorderStyle);
nr:=scr.documentVisibleRect;
txt.setFrame(nr);
@ -1792,6 +1810,8 @@ begin
scroll.callback := list.callback;
scroll.setHasVerticalScroller(true);
scroll.setAutohidesScrollers(true);
ScrollViewSetBorderStyle(scroll, lclListBox.BorderStyle);
Result := TLCLIntfHandle(scroll);
end;
@ -1891,6 +1911,17 @@ begin
list.deselectRow(AIndex);
end;
class procedure TCocoaWSCustomListBox.SetBorderStyle(
const AWinControl: TWinControl; const ABorderStyle: TBorderStyle);
var
list: TCocoaTableListView;
begin
list := GetListBox(AWinControl);
if not Assigned(list) then Exit;
ScrollViewSetBorderStyle(list.enclosingScrollView, ABorderStyle);
end;
class procedure TCocoaWSCustomListBox.SetItemIndex(const ACustomListBox: TCustomListBox; const AIndex: integer);
var
list: TCocoaTableListView;