mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-28 21:00:43 +02:00
cocoa: adding theme update notification
git-svn-id: trunk@61235 -
This commit is contained in:
parent
ab3b8df7cc
commit
6dfa26faa8
@ -30,6 +30,7 @@ type
|
|||||||
TCocoaThemeServices = class(TThemeServices)
|
TCocoaThemeServices = class(TThemeServices)
|
||||||
private
|
private
|
||||||
protected
|
protected
|
||||||
|
callback : NSObject;
|
||||||
BtnCell : NSButtonCell;
|
BtnCell : NSButtonCell;
|
||||||
function SetButtonCellType(btn: NSButtonCell; Details: TThemedElementDetails): Boolean;
|
function SetButtonCellType(btn: NSButtonCell; Details: TThemedElementDetails): Boolean;
|
||||||
procedure SetButtonCellToDetails(btn: NSButtonCell; Details: TThemedElementDetails);
|
procedure SetButtonCellToDetails(btn: NSButtonCell; Details: TThemedElementDetails);
|
||||||
@ -58,6 +59,7 @@ type
|
|||||||
BezelToolBar : NSBezelStyle;
|
BezelToolBar : NSBezelStyle;
|
||||||
BezelButton : NSBezelStyle;
|
BezelButton : NSBezelStyle;
|
||||||
constructor Create;
|
constructor Create;
|
||||||
|
destructor Destroy; override;
|
||||||
procedure DrawElement(DC: HDC; Details: TThemedElementDetails; const R: TRect; ClipRect: PRect); override;
|
procedure DrawElement(DC: HDC; Details: TThemedElementDetails; const R: TRect; ClipRect: PRect); override;
|
||||||
(*
|
(*
|
||||||
procedure DrawEdge({%H-}DC: HDC; {%H-}Details: TThemedElementDetails; const {%H-}R: TRect; {%H-}Edge, {%H-}Flags: Cardinal; {%H-}AContentRect: PRect); override;
|
procedure DrawEdge({%H-}DC: HDC; {%H-}Details: TThemedElementDetails; const {%H-}R: TRect; {%H-}Edge, {%H-}Flags: Cardinal; {%H-}AContentRect: PRect); override;
|
||||||
@ -92,6 +94,11 @@ function NSAppearanceClass: pobjc_class;
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
type
|
||||||
|
TCocoaThemeCallback = objcclass(NSObject)
|
||||||
|
procedure notifySysColorsChanged(notification: NSNotification); message 'notifySysColorsChanged:';
|
||||||
|
end;
|
||||||
|
|
||||||
type
|
type
|
||||||
TCocoaContextAccess = class(TCocoaContext);
|
TCocoaContextAccess = class(TCocoaContext);
|
||||||
|
|
||||||
@ -624,6 +631,18 @@ begin
|
|||||||
BtnCell := NSButtonCell.alloc.initTextCell(NSSTR(''));
|
BtnCell := NSButtonCell.alloc.initTextCell(NSSTR(''));
|
||||||
BezelToolBar := NSSmallSquareBezelStyle; // can be resized at any size
|
BezelToolBar := NSSmallSquareBezelStyle; // can be resized at any size
|
||||||
BezelButton := NSSmallSquareBezelStyle;
|
BezelButton := NSSmallSquareBezelStyle;
|
||||||
|
|
||||||
|
callback := TCocoaThemeCallback.alloc.init;
|
||||||
|
NSNotificationCenter(NSNotificationCenter.defaultCenter).addObserver_selector_name_object(
|
||||||
|
callback, ObjCSelector('notifySysColorsChanged:'), NSSystemColorsDidChangeNotification, nil
|
||||||
|
);
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TCocoaThemeServices.Destroy;
|
||||||
|
begin
|
||||||
|
NSNotificationCenter(NSNotificationCenter.defaultCenter).removeObserver(callback);
|
||||||
|
callback.release;
|
||||||
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
(*function TCarbonThemeServices.DrawWindowElement(DC: TCarbonDeviceContext;
|
(*function TCarbonThemeServices.DrawWindowElement(DC: TCarbonDeviceContext;
|
||||||
@ -1027,6 +1046,14 @@ begin
|
|||||||
NSGraphicsContext.setCurrentContext( cur );
|
NSGraphicsContext.setCurrentContext( cur );
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TCocoaThemeCallback }
|
||||||
|
|
||||||
|
procedure TCocoaThemeCallback.notifySysColorsChanged(notification: NSNotification);
|
||||||
|
begin
|
||||||
|
ThemeServices.UpdateThemes;
|
||||||
|
Graphics.UpdateHandleObjects;
|
||||||
|
ThemeServices.IntfDoOnThemeChange;
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user