cocoa: revising the structure of cocoa widgetset. for practice added cocoa progress bar to fullfill #22557

git-svn-id: trunk@43473 -
This commit is contained in:
dmitry 2013-11-23 05:24:29 +00:00
parent cc36b92b7b
commit c78384ddba
4 changed files with 135 additions and 3 deletions

1
.gitattributes vendored
View File

@ -6300,6 +6300,7 @@ lcl/interfaces/cocoa/cocoautils.pas svneol=native#text/plain
lcl/interfaces/cocoa/cocoawinapi.inc svneol=native#text/pascal
lcl/interfaces/cocoa/cocoawinapih.inc svneol=native#text/pascal
lcl/interfaces/cocoa/cocoawsbuttons.pp svneol=native#text/pascal
lcl/interfaces/cocoa/cocoawscomctrls.pas svneol=native#text/plain
lcl/interfaces/cocoa/cocoawscommon.pas svneol=native#text/plain
lcl/interfaces/cocoa/cocoawsextctrls.pas svneol=native#text/plain
lcl/interfaces/cocoa/cocoawsfactory.pas svneol=native#text/plain

View File

@ -12,6 +12,7 @@ uses
cocoagdiobjects,
cocoawsforms,
cocoaint,
cocoawscommon;
cocoawscommon,
cocoawscomctrls;
implementation
end.

View File

@ -0,0 +1,128 @@
unit CocoaWSComCtrls;
interface
{$mode delphi}
{$modeswitch objectivec1}
uses
CocoaAll
, LCLType
, WSComCtrls
, Controls, ComCtrls
, CocoaPrivate
, CocoaWSCommon;
type
{ TCocoaWSProgressBar }
TCocoaWSProgressBar = class(TWSProgressBar)
published
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
class procedure ApplyChanges(const AProgressBar: TCustomProgressBar); override;
class procedure SetPosition(const AProgressBar: TCustomProgressBar; const NewPosition: integer); override;
class procedure SetStyle(const AProgressBar: TCustomProgressBar; const NewStyle: TProgressBarStyle); override;
end;
implementation
type
{ TCocoaProgressIndicator }
TCocoaProgressIndicator = objcclass(NSProgressIndicator)
callback: ICommonCallback;
function acceptsFirstResponder: Boolean; override;
function becomeFirstResponder: Boolean; override;
function resignFirstResponder: Boolean; override;
function lclGetCallback: ICommonCallback; override;
procedure lclClearCallback; override;
procedure resetCursorRects; override;
end;
function AllocProgressIndicator(ATarget: TWinControl; const AParams: TCreateParams): TCocoaProgressIndicator;
begin
Result := TCocoaProgressIndicator.alloc.lclInitWithCreateParams(AParams);
if Assigned(Result) then
begin
Result.callback := TLCLCommonCallback.Create(Result, ATarget);
Result.startAnimation(nil);
//small constrol size looks like carbon
//Result.setControlSize(NSSmallControlSize);
end;
end;
{ TCocoaWSProgressBar }
class function TCocoaWSProgressBar.CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): TLCLIntfHandle;
begin
Result:=TLCLIntfHandle(AllocProgressIndicator(AWinControl, AParams));
end;
class procedure TCocoaWSProgressBar.ApplyChanges(
const AProgressBar: TCustomProgressBar);
var
ind : NSProgressIndicator;
begin
if not Assigned(AProgressBar) or not AProgressBar.HandleAllocated then Exit;
ind:=NSProgressIndicator(AProgressBAr.Handle);
ind.setMaxValue(AProgressBar.Max);
ind.setMinValue(AProgressBar.Min);
ind.setDoubleValue(AProgressBar.Position);
ind.setIndeterminate(AProgressBar.Style = pbstMarquee);
end;
class procedure TCocoaWSProgressBar.SetPosition(
const AProgressBar: TCustomProgressBar; const NewPosition: integer);
begin
if AProgressBar.HandleAllocated then
NSProgressIndicator(AProgressBar.Handle).setDoubleValue(NewPosition);
end;
class procedure TCocoaWSProgressBar.SetStyle(
const AProgressBar: TCustomProgressBar; const NewStyle: TProgressBarStyle);
begin
if AProgressBar.HandleAllocated then
NSProgressIndicator(AProgressBar.Handle).setIndeterminate(NewStyle = pbstMarquee);
end;
{ TCocoaProgressIndicator }
function TCocoaProgressIndicator.acceptsFirstResponder: Boolean;
begin
Result:=True;
end;
function TCocoaProgressIndicator.becomeFirstResponder: Boolean;
begin
Result := inherited becomeFirstResponder;
callback.BecomeFirstResponder;
end;
function TCocoaProgressIndicator.resignFirstResponder: Boolean;
begin
Result := inherited resignFirstResponder;
callback.ResignFirstResponder;
end;
function TCocoaProgressIndicator.lclGetCallback: ICommonCallback;
begin
Result:=callback;
end;
procedure TCocoaProgressIndicator.lclClearCallback;
begin
callback:=nil;
end;
procedure TCocoaProgressIndicator.resetCursorRects;
begin
if not callback.resetCursorRects then
inherited resetCursorRects;
end;
end.

View File

@ -13,7 +13,8 @@ uses
CocoaWSExtCtrls,
CocoaWSForms,
CocoaWSMenus,
CocoaWSStdCtrls;
CocoaWSStdCtrls,
CocoaWSComCtrls;
// imglist
function RegisterCustomImageList: Boolean;
@ -172,7 +173,8 @@ end;
function RegisterCustomProgressBar: Boolean; alias : 'WSRegisterCustomProgressBar';
begin
Result := False;
RegisterWSComponent(TCustomProgressBar, TCocoaWSProgressBar);
Result := True;
end;
function RegisterCustomUpDown: Boolean; alias : 'WSRegisterCustomUpDown';