~ubuntu-branches/ubuntu/saucy/lazarus/saucy

« back to all changes in this revision

Viewing changes to lcl/interfaces/carbon/carbonprivatewindow.inc

  • Committer: Package Import Robot
  • Author(s): Paul Gevers, Abou Al Montacir, Bart Martens, Paul Gevers
  • Date: 2013-06-08 14:12:17 UTC
  • mfrom: (1.1.9)
  • Revision ID: package-import@ubuntu.com-20130608141217-7k0cy9id8ifcnutc
Tags: 1.0.8+dfsg-1
[ Abou Al Montacir ]
* New upstream major release and multiple maintenace release offering many
  fixes and new features marking a new milestone for the Lazarus development
  and its stability level.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_release_notes
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_fixes_branch
* LCL changes:
  - LCL is now a normal package.
      + Platform independent parts of the LCL are now in the package LCLBase
      + LCL is automatically recompiled when switching the target platform,
        unless pre-compiled binaries for this target are already installed.
      + No impact on existing projects.
      + Linker options needed by LCL are no more added to projects that do
        not use the LCL package.
  - Minor changes in LCL basic classes behaviour
      + TCustomForm.Create raises an exception if a form resource is not
        found.
      + TNotebook and TPage: a new implementation of these classes was added.
      + TDBNavigator: It is now possible to have focusable buttons by setting
        Options = [navFocusableButtons] and TabStop = True, useful for
        accessibility and for devices with neither mouse nor touch screen.
      + Names of TControlBorderSpacing.GetSideSpace and GetSpace were swapped
        and are now consistent. GetSideSpace = Around + GetSpace.
      + TForm.WindowState=wsFullscreen was added
      + TCanvas.TextFitInfo was added to calculate how many characters will
        fit into a specified Width. Useful for word-wrapping calculations.
      + TControl.GetColorResolvingParent and
        TControl.GetRGBColorResolvingParent were added, simplifying the work
        to obtain the final color of the control while resolving clDefault
        and the ParentColor.
      + LCLIntf.GetTextExtentExPoint now has a good default implementation
        which works in any platform not providing a specific implementation.
        However, Widgetset specific implementation is better, when available.
      + TTabControl was reorganized. Now it has the correct class hierarchy
        and inherits from TCustomTabControl as it should.
  - New unit in the LCL:
      + lazdialogs.pas: adds non-native versions of various native dialogs,
        for example TLazOpenDialog, TLazSaveDialog, TLazSelectDirectoryDialog.
        It is used by widgetsets which either do not have a native dialog, or
        do not wish to use it because it is limited. These dialogs can also be
        used by user applications directly.
      + lazdeviceapis.pas: offers an interface to more hardware devices such
        as the accelerometer, GPS, etc. See LazDeviceAPIs
      + lazcanvas.pas: provides a TFPImageCanvas descendent implementing
        drawing in a LCL-compatible way, but 100% in Pascal.
      + lazregions.pas. LazRegions is a wholly Pascal implementation of
        regions for canvas clipping, event clipping, finding in which control
        of a region tree one an event should reach, for drawing polygons, etc.
      + customdrawncontrols.pas, customdrawndrawers.pas,
        customdrawn_common.pas, customdrawn_android.pas and
        customdrawn_winxp.pas: are the Lazarus Custom Drawn Controls -controls
        which imitate the standard LCL ones, but with the difference that they
        are non-native and support skinning.
  - New APIs added to the LCL to improve support of accessibility software
    such as screen readers.
* IDE changes:
  - Many improvments.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/New_IDE_features_since#v1.0_.282012-08-29.29
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_release_notes#IDE_Changes
* Debugger / Editor changes:
  - Added pascal sources and breakpoints to the disassembler
  - Added threads dialog.
* Components changes:
  - TAChart: many fixes and new features
  - CodeTool: support Delphi style generics and new syntax extensions.
  - AggPas: removed to honor free licencing. (Closes: Bug#708695)
[Bart Martens]
* New debian/watch file fixing issues with upstream RC release.
[Abou Al Montacir]
* Avoid changing files in .pc hidden directory, these are used by quilt for
  internal purpose and could lead to surprises during build.
[Paul Gevers]
* Updated get-orig-source target and it compinion script orig-tar.sh so that they
  repack the source file, allowing bug 708695 to be fixed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
{%MainUnit carbonprivate.pp}
2
 
{ $Id: $}
3
2
{
4
3
 *****************************************************************************
5
4
 *                                                                           *
27
26
  S : ByteCount;
28
27
begin
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
31
30
  begin
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);
35
34
  end;
51
50
  {$ENDIF}
52
51
  // Do canclose query, if false then exit
53
52
 
54
 
  FillChar(Msg, SizeOf(Msg),0);
 
53
  FillChar(Msg{%H-}, SizeOf(Msg),0);
55
54
  Msg.msg := LM_CLOSEQUERY;
56
55
 
57
56
  // Message results : 0 - do nothing, 1 - destroy window
98
97
        SizeOf(ClickCount), nil, @ClickCount),
99
98
      SName, SGetEvent, 'kEventParamClickCount') then Exit;
100
99
 
101
 
    Result := ClickCount;
 
100
    Result := Integer(ClickCount);
102
101
    {debugln('GetClickCount ClickCount=',dbgs(ClickCount));}
103
102
  end;
104
103
 
116
115
  function GetMouseWheelDelta: Integer;
117
116
  var
118
117
    WheelDelta: SInt32;
 
118
    CCtl: TCarbonCustomControl;
 
119
    ScrollInfo: TScrollInfo;
119
120
  begin
120
121
    Result := 0;
121
122
    
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
 
135
    begin
 
136
      CCtl := TCarbonCustomControl(Widget);
 
137
      if CCtl.GetScrollbarVisible(SB_VERT) then
 
138
      begin
 
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
 
144
          Result := 120;
 
145
      end;
 
146
    end;
131
147
    {$IFDEF VerboseMouse}
132
148
      DebugLn('GetMouseWheelDelta WheelDelta=', DbgS(WheelDelta), ' ', HexStr(WheelDelta, 8));
133
149
    {$ENDIF}
218
234
    MousePoint := GetMousePoint;
219
235
    
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;
224
240
  end;
225
241
 
226
 
  procedure HandleMouseDraggedEvent(var AMsg);
 
242
  procedure HandleMouseDraggedEvent(var {%H-}AMsg);
227
243
  begin
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;
267
284
begin
268
285
  Result := EventNotHandledErr;
269
286
  Postpone := False;
286
303
  
287
304
  Widget := GetCarbonWidget(Control);
288
305
  while Assigned(Widget) and not Widget.IsEnabled do
289
 
    Widget := TCarbonWidget(CarbonWidgetset.GetParent(HWND(Widget)));
 
306
  begin
 
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;
 
312
  end;
290
313
  if Widget = nil then Exit;
291
314
 
292
 
  FillChar(Msg, SizeOf(Msg), 0);
 
315
  FillChar(Msg{%H-}, SizeOf(Msg), 0);
293
316
  
294
317
  EventKind := GetEventKind(AEvent);
295
318
  case EventKind of
319
342
  begin
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
324
347
      begin
325
348
        Result := EventNotHandledErr;
333
356
 
334
357
  // interactive design
335
358
  if (EventKind = kEventMouseDown)
 
359
  and Assigned(Widget.LCLObject)
336
360
  and ((csDesigning in Widget.LCLObject.ComponentState) or (Widget is TCarbonDesignWindow))
337
361
  and (GetCarbonMouseButton(AEvent) = 1) then
338
362
  begin
518
542
    end;
519
543
 
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));
525
549
    {$ENDIF}
687
711
  begin
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'));
709
733
    {$ENDIF}
710
734
 
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;
735
759
          DebugLn('[HandleRawKeyDownEvent] LCL handled CN_KEYDOWN, exiting');
736
760
        {$ENDIF}
737
761
        
738
 
        NotifyApplicationUserInput(KeyMsg.Msg);
 
762
        NotifyApplicationUserInput(Widget.LCLObject, KeyMsg.Msg);
739
763
        Result := noErr;
740
764
        Exit;
741
765
      end;
755
779
        {$ENDIF}
756
780
        //Result already set by CallNextEventHandler
757
781
        
758
 
        NotifyApplicationUserInput(KeyMsg.Msg);
 
782
        NotifyApplicationUserInput(Widget.LCLObject, KeyMsg.Msg);
759
783
        Exit;
760
784
      end;
761
785
    end;
779
803
        LCLCharToMacEvent(UTF8Character);
780
804
 
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
796
820
          Result := noErr;
797
821
          
798
 
        NotifyApplicationUserInput(CharMsg.Msg);
 
822
        NotifyApplicationUserInput(Widget.LCLObject, CharMsg.Msg);
799
823
        Exit;
800
824
      end;
801
825
      if CharMsg.CharCode<>ord(KeyChar) then
829
853
        if Result=EventNotHandledErr then
830
854
          Result := noErr;
831
855
          
832
 
        NotifyApplicationUserInput(CharMsg.Msg);
 
856
        NotifyApplicationUserInput(Widget.LCLObject, CharMsg.Msg);
833
857
        Exit;
834
858
      end;
835
859
    end;
845
869
    {$ENDIF}
846
870
 
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;
862
886
        {$ENDIF}
863
887
        Result := noErr;
864
888
        
865
 
        NotifyApplicationUserInput(KeyMsg.Msg);
 
889
        NotifyApplicationUserInput(Widget.LCLObject, KeyMsg.Msg);
866
890
        Exit;
867
891
      end;
868
892
      
883
907
        if Result=EventNotHandledErr then
884
908
          Result := noErr;
885
909
          
886
 
        NotifyApplicationUserInput(KeyMsg.Msg);
 
910
        NotifyApplicationUserInput(Widget.LCLObject, KeyMsg.Msg);
887
911
        Exit;
888
912
      end;
889
913
    end;
974
998
  end;
975
999
 
976
1000
  if DoActivate
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);
979
1003
 
980
1004
  // force set and kill focus of focused control
981
1005
  Control := nil;
1017
1041
  
1018
1042
  Kind := -1;
1019
1043
  case EventKind of
1020
 
  kEventWindowCollapsed: Kind := SIZEICONIC;
 
1044
  kEventWindowCollapsed: Kind := SIZE_MINIMIZED;
1021
1045
  kEventWindowExpanded, kEventWindowZoomed:
1022
1046
    begin
1023
1047
      if IsWindowInStandardState(TCarbonWindow(AWidget).fWindowRef, nil, nil) then
1024
 
        Kind := SIZEFULLSCREEN
 
1048
        Kind := SIZE_MAXIMIZED
1025
1049
      else
1026
 
        Kind := SIZENORMAL;
 
1050
        Kind := SIZE_RESTORED;
1027
1051
    end;
1028
1052
  else
1029
1053
    DebugLn('CarbonWindow_ShowWindow invalid event kind: ' + DbgS(EventKind));
1037
1061
  
1038
1062
  if Kind >= 0 then
1039
1063
  begin
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);
1043
1067
  end;
1148
1172
    1, @TmpSpec, Pointer(Self), nil);
1149
1173
 
1150
1174
  // paint content message
1151
 
  if (HIViewFindByID( HIViewGetRoot(fWindowRef), kHIViewWindowContentID, WinContent) = noErr) then
 
1175
  if (HIViewFindByID( HIViewGetRoot(fWindowRef), kHIViewWindowContentID, WinContent{%H-}) = noErr) then
1152
1176
  begin
1153
1177
    TmpSpec := MakeEventSpec(kEventClassControl, kEventControlDraw);
1154
1178
    InstallControlEventHandler(WinContent,
1166
1190
  Attributes: WindowAttributes;
1167
1191
begin
1168
1192
  // apply appropriate form style and form border style
1169
 
 
 
1193
  FSheetWin := nil;
1170
1194
  if csDesigning in LCLObject.ComponentState then
1171
1195
  begin
1172
1196
    GroupClass := kDocumentWindowClass;
1194
1218
      kFloatingWindowClass:
1195
1219
        Attributes := Attributes and (not (kWindowInWindowMenuAttribute or kWindowCollapseBoxAttribute));
1196
1220
    end;}
 
1221
    if CREATESHEETWINDOW = PtrUInt(LCLObject) then
 
1222
    begin
 
1223
      CREATESHEETWINDOW := 0;
 
1224
      GroupClass := kSheetWindowClass;
 
1225
    end;
1197
1226
  end;
1198
1227
 
1199
1228
  //DebugLn('TCarbonWindow.CreateWidget ' + DbgS(ParamsToCarbonRect(AParams)));
1200
1229
 
1201
 
  NewWindowClass:=kDocumentWindowClass;
 
1230
  if GroupClass = kSheetWindowClass then
 
1231
  begin
 
1232
    NewWindowClass := GroupClass;
 
1233
    Attributes := kWindowCompositingAttribute or kWindowStandardHandlerAttribute;
 
1234
  end else
 
1235
  begin
 
1236
    NewWindowClass:=kDocumentWindowClass;
 
1237
    Attributes := Attributes or kWindowCompositingAttribute or kWindowStandardHandlerAttribute
 
1238
      or kWindowLiveResizeAttribute;
 
1239
  end;
 
1240
 
1202
1241
  if OSError(
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
1207
1245
  begin
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);
1213
1250
  end;
1214
1251
 
1260
1297
var
1261
1298
  Layout: HILayoutInfo;
1262
1299
begin
1263
 
  HIViewGetLayoutInfo(Child, Layout);
 
1300
  HIViewGetLayoutInfo(Child, Layout{%H-});
1264
1301
  if FullAlign then
1265
1302
  begin
1266
1303
    Layout.binding.left.kind  := kHILayoutBindLeft;
1368
1405
begin
1369
1406
  if Assigned(fWindowRef) then
1370
1407
  begin
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;
1409
1446
    if OSError(
1410
 
      GetWindowBounds(fWindowRef, kWindowStructureRgn, AWndRect), Self,
 
1447
      GetWindowBounds(fWindowRef, kWindowStructureRgn, AWndRect{%H-}), Self,
1411
1448
      SName, SGetWindowBounds, 'kWindowStructureRgn') then Exit;
1412
1449
    if OSError(
1413
 
      GetWindowBounds(fWindowRef, kWindowContentRgn, AClientRect), Self,
 
1450
      GetWindowBounds(fWindowRef, kWindowContentRgn, AClientRect{%H-}), Self,
1414
1451
      SName, SGetWindowBounds, 'kWindowContentRgn') then Exit;
1415
1452
 
1416
1453
    ARect.Left := AClientRect.Left - AWndRect.Left;
1520
1557
    Result := False;
1521
1558
 
1522
1559
    if OSError(
1523
 
      MacOSAll.GetWindowBounds(fWindowRef, kWindowStructureRgn, AWndRect),
 
1560
      MacOSAll.GetWindowBounds(fWindowRef, kWindowStructureRgn, AWndRect{%H-}),
1524
1561
      Self, SName, SGetWindowBounds, 'kWindowStructureRgn') then Exit;
1525
1562
    if OSError(
1526
 
      MacOSAll.GetWindowBounds(fWindowRef, kWindowContentRgn, AClientRect),
 
1563
      MacOSAll.GetWindowBounds(fWindowRef, kWindowContentRgn, AClientRect{%H-}),
1527
1564
      Self, SName, SGetWindowBounds, 'kWindowContentRgn') then Exit;
1528
1565
 
1529
1566
    ARect.Left := AWndRect.Left;
1839
1876
var
1840
1877
  P: MacOSAll.Point;
1841
1878
  Maximized: Boolean;
 
1879
  FullScreen: Boolean;
 
1880
  UIMode: SystemUIMode;
 
1881
  UIOptions: SystemUIOptions;
1842
1882
const
1843
1883
  SName = 'Show';
1844
1884
  SCollapse = 'CollapseWindow';
1850
1890
  //DebugLn('TCarbonWindow.Show ' + DbgS(AShow));
1851
1891
 
1852
1892
  case AShow of
1853
 
  SW_SHOWNORMAL, SW_SHOWMAXIMIZED:
 
1893
  SW_SHOW, SW_HIDE:
 
1894
  begin
 
1895
    ShowHide(AShow = SW_SHOW);
 
1896
    Result := True;
 
1897
  end;
 
1898
 
 
1899
  SW_SHOWNORMAL, SW_SHOWMAXIMIZED, SW_SHOWFULLSCREEN:
1854
1900
  begin
1855
1901
    if IsWindowCollapsed(fWindowRef) then
1856
1902
      if OSError(CollapseWindow(fWindowRef, False),
1858
1904
 
1859
1905
    // for checking if any change is necessary
1860
1906
    Maximized := IsWindowInStandardState(fWindowRef, nil, nil);
1861
 
 
1862
 
    if AShow = SW_SHOWNORMAL then
 
1907
    GetSystemUIMode(@UIMode, @UIOptions);
 
1908
    FullScreen := (UIMode = kuiModeAllHidden) and (UIOptions = kUIOptionAutoShowMenuBar);
 
1909
 
 
1910
    if FullScreen then
 
1911
    begin
 
1912
      SetSystemUIMode(kuiModeNormal, 0);
 
1913
      if OSError(ZoomWindowIdeal(fWindowRef, inZoomIn, P{%H-}),
 
1914
        Self, SName, SZoomIdeal, 'inZoomIn') then Exit;
 
1915
      exit(True);
 
1916
    end;
 
1917
 
 
1918
    if (AShow = SW_SHOWNORMAL) then
1863
1919
    begin
1864
1920
      if Maximized then
1865
1921
        if OSError(ZoomWindowIdeal(fWindowRef, inZoomIn, P),
1866
1922
          Self, SName, SZoomIdeal, 'inZoomIn') then Exit;
1867
1923
    end
1868
1924
    else
1869
 
      if not Maximized then
 
1925
    begin
 
1926
      if AShow = SW_SHOWFULLSCREEN then
 
1927
        SetSystemUIMode(kuiModeAllHidden, kUIOptionAutoShowMenuBar);
 
1928
 
 
1929
      if not Maximized or (AShow = SW_SHOWFULLSCREEN) then
1870
1930
      begin
1871
1931
        P.v := $3FFF;
1872
1932
        P.h := $3FFF;
1873
1933
        if OSError(ZoomWindowIdeal(fWindowRef, inZoomOut, P),
1874
1934
         Self, SName, SZoomIdeal, 'inZoomOut') then Exit;
1875
1935
      end;
1876
 
 
 
1936
    end;
1877
1937
    SetForeground;
1878
1938
  end;
1879
1939
  SW_MINIMIZE: