mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-23 22:59:21 +02:00
cocoa: code moving and cleaning up units use
git-svn-id: trunk@58919 -
This commit is contained in:
parent
c2f1d4283e
commit
cbb9c40974
@ -34,7 +34,7 @@ uses
|
|||||||
MacOSAll, CocoaAll, CocoaUtils, CocoaGDIObjects,
|
MacOSAll, CocoaAll, CocoaUtils, CocoaGDIObjects,
|
||||||
cocoa_extra,
|
cocoa_extra,
|
||||||
// LCL
|
// LCL
|
||||||
LCLType, StdCtrls;
|
LCLType;
|
||||||
|
|
||||||
const
|
const
|
||||||
SPINEDIT_DEFAULT_STEPPER_WIDTH = 15;
|
SPINEDIT_DEFAULT_STEPPER_WIDTH = 15;
|
||||||
|
@ -8,8 +8,8 @@ interface
|
|||||||
uses
|
uses
|
||||||
classes,
|
classes,
|
||||||
MacOSAll, CocoaAll,
|
MacOSAll, CocoaAll,
|
||||||
SysUtils, Types, LCLType, LCLClasses, LCLProc, menus,//LMessages,
|
SysUtils, Types, LCLType, LCLClasses, LCLProc,
|
||||||
Controls, Forms, Graphics, Math, GraphType;
|
Controls, Graphics, Math, GraphType;
|
||||||
|
|
||||||
const
|
const
|
||||||
LCLEventSubTypeMessage = MaxShort - 1;
|
LCLEventSubTypeMessage = MaxShort - 1;
|
||||||
@ -68,9 +68,6 @@ function NSColorToRGB(const Color: NSColor): TColorRef; inline;
|
|||||||
function NSColorToColorRef(const Color: NSColor): TColorRef;
|
function NSColorToColorRef(const Color: NSColor): TColorRef;
|
||||||
function ColorToNSColor(const Color: TColorRef): NSColor; inline;
|
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
|
const
|
||||||
DEFAULT_CFSTRING_ENCODING = kCFStringEncodingUTF8;
|
DEFAULT_CFSTRING_ENCODING = kCFStringEncodingUTF8;
|
||||||
|
|
||||||
@ -198,24 +195,6 @@ begin
|
|||||||
((Color shr 16) and $FF) / $FF, 1);
|
((Color shr 16) and $FF) / $FF, 1);
|
||||||
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;
|
|
||||||
|
|
||||||
function CFStringToString(AString: CFStringRef): String;
|
function CFStringToString(AString: CFStringRef): String;
|
||||||
begin
|
begin
|
||||||
result:=CFStringToStr(AString);
|
result:=CFStringToStr(AString);
|
||||||
@ -365,7 +344,7 @@ end;
|
|||||||
function LCLCoordsToCocoa(AControl: TControl; X, Y: Integer): NSPoint;
|
function LCLCoordsToCocoa(AControl: TControl; X, Y: Integer): NSPoint;
|
||||||
begin
|
begin
|
||||||
Result.x := X;
|
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;
|
if AControl <> nil then Result.y := Result.y - AControl.Height;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -149,6 +149,9 @@ type
|
|||||||
|
|
||||||
procedure NSMenuItemSetBitmap(mn: NSMenuItem; bmp: TBitmap);
|
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
|
implementation
|
||||||
|
|
||||||
{ TLCLMenuItemCallback }
|
{ TLCLMenuItemCallback }
|
||||||
@ -717,4 +720,23 @@ begin
|
|||||||
end;
|
end;
|
||||||
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.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user