29
28
if GetMenuItemProperty(AMenu, MenuIdx, LAZARUS_FOURCC,
30
WIDGETINFO_FOURCC, SizeOf(TCarbonMenu), S, @CarbonMenu) = noErr then
29
WIDGETINFO_FOURCC, SizeOf(TCarbonMenu), S{%H-}, @CarbonMenu) = noErr then
32
FillChar(Msg, SizeOf(Msg), 0);
31
FillChar(Msg{%H-}, SizeOf(Msg), 0);
33
32
Msg.msg := LM_ACTIVATE;
34
33
CarbonMenu.LCLMenuItem.Dispatch(Msg);
52
51
// Do canclose query, if false then exit
54
FillChar(Msg, SizeOf(Msg),0);
53
FillChar(Msg{%H-}, SizeOf(Msg),0);
55
54
Msg.msg := LM_CLOSEQUERY;
57
56
// Message results : 0 - do nothing, 1 - destroy window
98
97
SizeOf(ClickCount), nil, @ClickCount),
99
98
SName, SGetEvent, 'kEventParamClickCount') then Exit;
101
Result := ClickCount;
100
Result := Integer(ClickCount);
102
101
{debugln('GetClickCount ClickCount=',dbgs(ClickCount));}
127
128
// Carbon's WheelDelta is the number of lines to be scrolled
128
129
// LCL expects the delta to be 120 for each wheel step, which should scroll
129
130
// Mouse.WheelScrollLines lines (defaults to three)
131
// Update: 20111212 by zeljko: All widgetsets sends WheelDelta +-120
132
// mac sends 1 or -1 so we just recalc that to wheel delta. see issue #20888
130
133
Result := (120 * WheelDelta) div Mouse.WheelScrollLines;
134
if Widget.ClassType = TCarbonCustomControl then
136
CCtl := TCarbonCustomControl(Widget);
137
if CCtl.GetScrollbarVisible(SB_VERT) then
139
FillChar(ScrollInfo{%H-}, SizeOf(ScrollInfo), #0);
140
ScrollInfo.fMask := SIF_TRACKPOS;
141
ScrollInfo.cbSize := SizeOf(ScrollInfo);
142
CCtl.GetScrollInfo(SB_VERT, ScrollInfo);
143
if (WheelDelta > 0) and (ScrollInfo.nTrackPos = 0) then
131
147
{$IFDEF VerboseMouse}
132
148
DebugLn('GetMouseWheelDelta WheelDelta=', DbgS(WheelDelta), ' ', HexStr(WheelDelta, 8));
218
234
MousePoint := GetMousePoint;
220
236
Msg^.Msg := LM_MOUSEMOVE;
221
Msg^.XPos := MousePoint.X;
222
Msg^.YPos := MousePoint.Y;
237
Msg^.XPos := SmallInt(MousePoint.X);
238
Msg^.YPos := SmallInt(MousePoint.Y);
223
239
Msg^.Keys := GetCarbonMsgKeyState;
226
procedure HandleMouseDraggedEvent(var AMsg);
242
procedure HandleMouseDraggedEvent(var {%H-}AMsg);
228
244
{$IFDEF VerboseMouse}
229
245
DebugLn('-- mouse dragged --');
264
280
P, ClientPt, ControlPt: TPoint;
265
281
DesignPt: HIPoint;
266
282
ViewPart: HIViewPartCode;
283
lTmpWidget: TCarbonWidget;
268
285
Result := EventNotHandledErr;
269
286
Postpone := False;
287
304
Widget := GetCarbonWidget(Control);
288
305
while Assigned(Widget) and not Widget.IsEnabled do
289
Widget := TCarbonWidget(CarbonWidgetset.GetParent(HWND(Widget)));
307
// Here we need to avoid an endless loop which might occur in case
308
// GetParent returns the same widget that we passed
309
lTmpWidget := TCarbonWidget(CarbonWidgetset.GetParent(HWND(Widget)));
310
if lTmpWidget = Widget then Break;
311
Widget := lTmpWidget;
290
313
if Widget = nil then Exit;
292
FillChar(Msg, SizeOf(Msg), 0);
315
FillChar(Msg{%H-}, SizeOf(Msg), 0);
294
317
EventKind := GetEventKind(AEvent);
295
318
case EventKind of
320
343
if Widget.NeedDeliverMouseEvent(Msg.Message.Msg, Msg) then begin
321
344
// Msg is set in the Appropriate HandleMousexxx procedure
322
NotifyApplicationUserInput(Msg.Message.Msg);
345
NotifyApplicationUserInput(Widget.LCLObject, Msg.Message.Msg);
323
346
if DeliverMessage(Widget.LCLObject, Msg) = 0 then
325
348
Result := EventNotHandledErr;
520
544
// get untranslated key (key without modifiers)
521
OSError(KLGetCurrentKeyboardLayout(KeyboardLayout), SName, 'KLGetCurrentKeyboardLayout');
522
OSError(KLGetKeyboardLayoutProperty(KeyboardLayout, kKLuchrData, Layout), SName, 'KLGetKeyboardLayoutProperty');
545
OSError(KLGetCurrentKeyboardLayout(KeyboardLayout{%H-}), SName, 'KLGetCurrentKeyboardLayout');
546
OSError(KLGetKeyboardLayoutProperty(KeyboardLayout, kKLuchrData, Layout{%H-}), SName, 'KLGetKeyboardLayoutProperty');
523
547
{$IFDEF VerboseKeyboard}
524
548
DebugLn('[Keyboard layout] UCHR layout = ', DbgS(Layout));
688
712
if AUTF8Char='' then Exit;
689
713
// only one character should be used
690
WideBuf:=UTF8Encode(UTF8Copy(AUTF8Char, 1,1));
714
WideBuf:={%H-}UTF8Encode(UTF8Copy(AUTF8Char, 1,1));
691
715
Result:=(length(WideBuf)>0) and
692
716
(not OSError(SetEventParameter(AEvent, kEventParamKeyUnicodes, typeUnicodeText,
693
717
length(WideBuf)*2, @WideBuf[1]), SName, ASetEvent, 'kEventParamKeyUnicodes'));
711
735
// create the CN_KEYDOWN message
712
FillChar(KeyMsg, SizeOf(KeyMsg), 0);
736
FillChar(KeyMsg{%H-}, SizeOf(KeyMsg), 0);
713
737
if IsSysKey then KeyMsg.Msg := CN_SYSKEYDOWN
714
738
else KeyMsg.Msg := CN_KEYDOWN;
715
739
KeyMsg.KeyData := KeyData;
779
803
LCLCharToMacEvent(UTF8Character);
781
805
// create the CN_CHAR / CN_SYSCHAR message
782
FillChar(CharMsg, SizeOf(CharMsg), 0);
806
FillChar(CharMsg{%H-}, SizeOf(CharMsg), 0);
783
807
if IsSysKey then CharMsg.Msg := CN_SYSCHAR
784
808
else CharMsg.Msg := CN_CHAR;
785
809
CharMsg.KeyData := KeyData;
795
819
if Result=EventNotHandledErr then
798
NotifyApplicationUserInput(CharMsg.Msg);
822
NotifyApplicationUserInput(Widget.LCLObject, CharMsg.Msg);
801
825
if CharMsg.CharCode<>ord(KeyChar) then
847
871
// create the CN_KEYUP message
848
FillChar(KeyMsg, SizeOf(KeyMsg), 0);
872
FillChar(KeyMsg{%H-}, SizeOf(KeyMsg), 0);
849
873
if IsSysKey then KeyMsg.Msg := CN_SYSKEYUP
850
874
else KeyMsg.Msg := CN_KEYUP;
851
875
KeyMsg.KeyData := KeyData;
977
then LCLSendActivateMsg(AWidget.LCLObject, true, false)
978
else LCLSendDeactivateStartMsg(AWidget.LCLObject);
1001
then LCLSendActivateMsg(AWidget.LCLObject, WA_ACTIVE, false)
1002
else LCLSendActivateMsg(AWidget.LCLObject, WA_INACTIVE, false);
980
1004
// force set and kill focus of focused control
1019
1043
case EventKind of
1020
kEventWindowCollapsed: Kind := SIZEICONIC;
1044
kEventWindowCollapsed: Kind := SIZE_MINIMIZED;
1021
1045
kEventWindowExpanded, kEventWindowZoomed:
1023
1047
if IsWindowInStandardState(TCarbonWindow(AWidget).fWindowRef, nil, nil) then
1024
Kind := SIZEFULLSCREEN
1048
Kind := SIZE_MAXIMIZED
1050
Kind := SIZE_RESTORED;
1029
1053
DebugLn('CarbonWindow_ShowWindow invalid event kind: ' + DbgS(EventKind));
1038
1062
if Kind >= 0 then
1040
AWidget.GetBounds(WidgetBounds);
1064
AWidget.GetBounds(WidgetBounds{%H-});
1041
1065
LCLSendSizeMsg(AWidget.LCLObject, WidgetBounds.Right - WidgetBounds.Left,
1042
1066
WidgetBounds.Bottom - WidgetBounds.Top, Size_SourceIsInterface or Kind);
1148
1172
1, @TmpSpec, Pointer(Self), nil);
1150
1174
// paint content message
1151
if (HIViewFindByID( HIViewGetRoot(fWindowRef), kHIViewWindowContentID, WinContent) = noErr) then
1175
if (HIViewFindByID( HIViewGetRoot(fWindowRef), kHIViewWindowContentID, WinContent{%H-}) = noErr) then
1153
1177
TmpSpec := MakeEventSpec(kEventClassControl, kEventControlDraw);
1154
1178
InstallControlEventHandler(WinContent,
1194
1218
kFloatingWindowClass:
1195
1219
Attributes := Attributes and (not (kWindowInWindowMenuAttribute or kWindowCollapseBoxAttribute));
1221
if CREATESHEETWINDOW = PtrUInt(LCLObject) then
1223
CREATESHEETWINDOW := 0;
1224
GroupClass := kSheetWindowClass;
1199
1228
//DebugLn('TCarbonWindow.CreateWidget ' + DbgS(ParamsToCarbonRect(AParams)));
1201
NewWindowClass:=kDocumentWindowClass;
1230
if GroupClass = kSheetWindowClass then
1232
NewWindowClass := GroupClass;
1233
Attributes := kWindowCompositingAttribute or kWindowStandardHandlerAttribute;
1236
NewWindowClass:=kDocumentWindowClass;
1237
Attributes := Attributes or kWindowCompositingAttribute or kWindowStandardHandlerAttribute
1238
or kWindowLiveResizeAttribute;
1203
1242
CreateNewWindow(NewWindowClass,
1204
Attributes or kWindowCompositingAttribute or kWindowStandardHandlerAttribute
1205
or kWindowLiveResizeAttribute, GetCarbonRect(0, 0, 0, 0), AWindow),
1243
Attributes, GetCarbonRect(0, 0, 0, 0), AWindow{%H-}),
1206
1244
Self, SCreateWidget, 'CreateNewWindow') then
1208
1246
DebugLn('Unable to create a window with selected class '+IntToStr(NewWindowClass)+ ', and attributes,'+IntToStr(Attributes)+', fallback to kDocumentWindowClass');
1209
1247
if OSError(CreateNewWindow(kDocumentWindowClass,
1210
Attributes or kWindowCompositingAttribute or kWindowStandardHandlerAttribute
1211
or kWindowLiveResizeAttribute, GetCarbonRect(0, 0, 0, 0), AWindow),
1248
Attributes, GetCarbonRect(0, 0, 0, 0), AWindow),
1212
1249
Self, SCreateWidget, 'CreateNewWindow') then RaiseCreateWidgetError(LCLObject);
1369
1406
if Assigned(fWindowRef) then
1371
OSError(GetWindowBounds(fWindowRef, kWindowStructureRgn, G),
1408
OSError(GetWindowBounds(fWindowRef, kWindowStructureRgn, G{%H-}),
1372
1409
Self, 'GetMousePos', SGetWindowBounds);
1373
OSError(GetWindowBounds(fWindowRef, kWindowContentRgn, R),
1410
OSError(GetWindowBounds(fWindowRef, kWindowContentRgn, R{%H-}),
1374
1411
Self, 'GetMousePos', SGetWindowBounds);
1375
1412
Result.X := winX - (R.left-G.Left);
1376
1413
Result.Y := winY - (R.Top-G.Top);
1407
1444
if Assigned(fWindowRef) then begin
1408
1445
Result := False;
1410
GetWindowBounds(fWindowRef, kWindowStructureRgn, AWndRect), Self,
1447
GetWindowBounds(fWindowRef, kWindowStructureRgn, AWndRect{%H-}), Self,
1411
1448
SName, SGetWindowBounds, 'kWindowStructureRgn') then Exit;
1413
GetWindowBounds(fWindowRef, kWindowContentRgn, AClientRect), Self,
1450
GetWindowBounds(fWindowRef, kWindowContentRgn, AClientRect{%H-}), Self,
1414
1451
SName, SGetWindowBounds, 'kWindowContentRgn') then Exit;
1416
1453
ARect.Left := AClientRect.Left - AWndRect.Left;
1520
1557
Result := False;
1523
MacOSAll.GetWindowBounds(fWindowRef, kWindowStructureRgn, AWndRect),
1560
MacOSAll.GetWindowBounds(fWindowRef, kWindowStructureRgn, AWndRect{%H-}),
1524
1561
Self, SName, SGetWindowBounds, 'kWindowStructureRgn') then Exit;
1526
MacOSAll.GetWindowBounds(fWindowRef, kWindowContentRgn, AClientRect),
1563
MacOSAll.GetWindowBounds(fWindowRef, kWindowContentRgn, AClientRect{%H-}),
1527
1564
Self, SName, SGetWindowBounds, 'kWindowContentRgn') then Exit;
1529
1566
ARect.Left := AWndRect.Left;
1850
1890
//DebugLn('TCarbonWindow.Show ' + DbgS(AShow));
1853
SW_SHOWNORMAL, SW_SHOWMAXIMIZED:
1895
ShowHide(AShow = SW_SHOW);
1899
SW_SHOWNORMAL, SW_SHOWMAXIMIZED, SW_SHOWFULLSCREEN:
1855
1901
if IsWindowCollapsed(fWindowRef) then
1856
1902
if OSError(CollapseWindow(fWindowRef, False),
1859
1905
// for checking if any change is necessary
1860
1906
Maximized := IsWindowInStandardState(fWindowRef, nil, nil);
1862
if AShow = SW_SHOWNORMAL then
1907
GetSystemUIMode(@UIMode, @UIOptions);
1908
FullScreen := (UIMode = kuiModeAllHidden) and (UIOptions = kUIOptionAutoShowMenuBar);
1912
SetSystemUIMode(kuiModeNormal, 0);
1913
if OSError(ZoomWindowIdeal(fWindowRef, inZoomIn, P{%H-}),
1914
Self, SName, SZoomIdeal, 'inZoomIn') then Exit;
1918
if (AShow = SW_SHOWNORMAL) then
1864
1920
if Maximized then
1865
1921
if OSError(ZoomWindowIdeal(fWindowRef, inZoomIn, P),
1866
1922
Self, SName, SZoomIdeal, 'inZoomIn') then Exit;
1869
if not Maximized then
1926
if AShow = SW_SHOWFULLSCREEN then
1927
SetSystemUIMode(kuiModeAllHidden, kUIOptionAutoShowMenuBar);
1929
if not Maximized or (AShow = SW_SHOWFULLSCREEN) then
1873
1933
if OSError(ZoomWindowIdeal(fWindowRef, inZoomOut, P),
1874
1934
Self, SName, SZoomIdeal, 'inZoomOut') then Exit;