mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-19 22:09:27 +02:00
cocoa: Fixes drawing of labels inside groupbox
git-svn-id: trunk@49700 -
This commit is contained in:
parent
57795c6d42
commit
6f9a817ae1
@ -57,6 +57,7 @@ type
|
||||
procedure boundsDidChange;
|
||||
// misc events
|
||||
procedure Draw(ctx: NSGraphicsContext; const bounds, dirty: NSRect);
|
||||
procedure DrawBackground(ctx: NSGraphicsContext; const bounds, dirty: NSRect);
|
||||
function ResetCursorRects: Boolean;
|
||||
procedure BecomeFirstResponder;
|
||||
procedure ResignFirstResponder;
|
||||
@ -1991,20 +1992,12 @@ begin
|
||||
end;
|
||||
|
||||
procedure TCocoaCustomControl.drawRect(dirtyRect: NSRect);
|
||||
var
|
||||
lTarget: TWinControl;
|
||||
begin
|
||||
inherited drawRect(dirtyRect);
|
||||
|
||||
// Implement Color property
|
||||
if Assigned(callback) then
|
||||
begin
|
||||
lTarget := TWinControl(callback.GetTarget());
|
||||
if (lTarget.Color <> clDefault) and (lTarget.Color <> clBtnFace) then
|
||||
begin
|
||||
ColorToNSColor(ColorToRGB(lTarget.Color)).set_();
|
||||
NSRectFill(dirtyRect);
|
||||
end;
|
||||
end;
|
||||
callback.DrawBackground(NSGraphicsContext.currentContext, bounds, dirtyRect);
|
||||
|
||||
if CheckMainThread and Assigned(callback) then
|
||||
callback.Draw(NSGraphicsContext.currentContext, bounds, dirtyRect);
|
||||
|
@ -67,6 +67,7 @@ type
|
||||
function DeliverMessage(var Msg): LRESULT; virtual; overload;
|
||||
function DeliverMessage(Msg: Cardinal; WParam: WParam; LParam: LParam): LResult; virtual; overload;
|
||||
procedure Draw(ControlContext: NSGraphicsContext; const bounds, dirty: NSRect); virtual;
|
||||
procedure DrawBackground(ctx: NSGraphicsContext; const bounds, dirtyRect: NSRect); virtual;
|
||||
function ResetCursorRects: Boolean; virtual;
|
||||
|
||||
property HasCaret: Boolean read GetHasCaret write SetHasCaret;
|
||||
@ -1058,6 +1059,19 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TLCLCommonCallback.DrawBackground(ctx: NSGraphicsContext; const bounds, dirtyRect: NSRect);
|
||||
var
|
||||
lTarget: TWinControl;
|
||||
begin
|
||||
// Implement Color property
|
||||
lTarget := TWinControl(GetTarget());
|
||||
if (lTarget.Color <> clDefault) and (lTarget.Color <> clBtnFace) then
|
||||
begin
|
||||
ColorToNSColor(ColorToRGB(lTarget.Color)).set_();
|
||||
NSRectFill(dirtyRect);
|
||||
end;
|
||||
end;
|
||||
|
||||
function TLCLCommonCallback.ResetCursorRects: Boolean;
|
||||
var
|
||||
ACursor: TCursor;
|
||||
|
@ -1068,6 +1068,8 @@ class function TCocoaWSCustomGroupBox.CreateHandle(const AWinControl: TWinContro
|
||||
var
|
||||
box: TCocoaGroupBox;
|
||||
cap: NSString;
|
||||
lGroupBoxContents: TCocoaCustomControl;
|
||||
ns: NSRect;
|
||||
begin
|
||||
box := NSView(TCocoaGroupBox.alloc).lclInitWithCreateParams(AParams);
|
||||
if Assigned(box) then
|
||||
@ -1076,6 +1078,13 @@ begin
|
||||
cap := NSStringUTF8(AParams.Caption);
|
||||
box.setTitle(cap);
|
||||
cap.release;
|
||||
|
||||
// set a content view in order to be able to customize drawing for labels/color
|
||||
ns := GetNSRect(AParams.X, AParams.Y, AParams.Width, AParams.Height);
|
||||
lGroupBoxContents := TCocoaCustomControl(TCocoaCustomControl.alloc.initWithFrame(ns));
|
||||
lGroupBoxContents.callback := TLCLCustomControlCallback.Create(lGroupBoxContents, AWinControl);
|
||||
lGroupBoxContents.autorelease;
|
||||
box.setContentView(lGroupBoxContents);
|
||||
end;
|
||||
Result := TLCLIntfHandle(box);
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user