cocoa: code moving and cleaning up units use

git-svn-id: trunk@58919 -
This commit is contained in:
dmitry 2018-09-09 04:41:25 +00:00
parent c2f1d4283e
commit cbb9c40974
3 changed files with 26 additions and 25 deletions

View File

@ -34,7 +34,7 @@ uses
MacOSAll, CocoaAll, CocoaUtils, CocoaGDIObjects,
cocoa_extra,
// LCL
LCLType, StdCtrls;
LCLType;
const
SPINEDIT_DEFAULT_STEPPER_WIDTH = 15;

View File

@ -8,8 +8,8 @@ interface
uses
classes,
MacOSAll, CocoaAll,
SysUtils, Types, LCLType, LCLClasses, LCLProc, menus,//LMessages,
Controls, Forms, Graphics, Math, GraphType;
SysUtils, Types, LCLType, LCLClasses, LCLProc,
Controls, Graphics, Math, GraphType;
const
LCLEventSubTypeMessage = MaxShort - 1;
@ -68,9 +68,6 @@ function NSColorToRGB(const Color: NSColor): TColorRef; inline;
function NSColorToColorRef(const Color: NSColor): TColorRef;
function ColorToNSColor(const Color: TColorRef): NSColor; inline;
// the returned "Key" should not be released, as it's not memory owned
procedure ShortcutToKeyEquivalent(const AShortCut: TShortcut; out Key: NSString; out shiftKeyMask: NSUInteger);
const
DEFAULT_CFSTRING_ENCODING = kCFStringEncodingUTF8;
@ -198,24 +195,6 @@ begin
((Color shr 16) and $FF) / $FF, 1);
end;
procedure ShortcutToKeyEquivalent(const AShortCut: TShortcut; out Key: NSString; out shiftKeyMask: NSUInteger);
var
w: word;
s: TShiftState;
begin
ShortCutToKey(AShortCut, w, s);
key := VirtualKeyCodeToMacString(w);
shiftKeyMask := 0;
if ssShift in s then
ShiftKeyMask := ShiftKeyMask + NSShiftKeyMask;
if ssAlt in s then
ShiftKeyMask := ShiftKeyMask + NSAlternateKeyMask;
if ssCtrl in s then
ShiftKeyMask := ShiftKeyMask + NSControlKeyMask;
if ssMeta in s then
ShiftKeyMask := ShiftKeyMask + NSCommandKeyMask;
end;
function CFStringToString(AString: CFStringRef): String;
begin
result:=CFStringToStr(AString);
@ -365,7 +344,7 @@ end;
function LCLCoordsToCocoa(AControl: TControl; X, Y: Integer): NSPoint;
begin
Result.x := X;
Result.y := Screen.Height - Y;
Result.y := NSScreen.mainScreen.frame.size.height - Y;
if AControl <> nil then Result.y := Result.y - AControl.Height;
end;

View File

@ -149,6 +149,9 @@ type
procedure NSMenuItemSetBitmap(mn: NSMenuItem; bmp: TBitmap);
// the returned "Key" should not be released, as it's not memory owned
procedure ShortcutToKeyEquivalent(const AShortCut: TShortcut; out Key: NSString; out shiftKeyMask: NSUInteger);
implementation
{ TLCLMenuItemCallback }
@ -717,4 +720,23 @@ begin
end;
end;
procedure ShortcutToKeyEquivalent(const AShortCut: TShortcut; out Key: NSString; out shiftKeyMask: NSUInteger);
var
w: word;
s: TShiftState;
begin
ShortCutToKey(AShortCut, w, s);
key := VirtualKeyCodeToMacString(w);
shiftKeyMask := 0;
if ssShift in s then
ShiftKeyMask := ShiftKeyMask + NSShiftKeyMask;
if ssAlt in s then
ShiftKeyMask := ShiftKeyMask + NSAlternateKeyMask;
if ssCtrl in s then
ShiftKeyMask := ShiftKeyMask + NSControlKeyMask;
if ssMeta in s then
ShiftKeyMask := ShiftKeyMask + NSCommandKeyMask;
end;
end.