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

« back to all changes in this revision

Viewing changes to lcl/interfaces/gtk2/gtk2wsforms.pp

  • 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
 
{ $Id: gtk2wsforms.pp 35769 2012-03-06 14:50:15Z vincents $}
 
1
{ $Id: gtk2wsforms.pp 36862 2012-04-17 07:55:52Z zeljko $}
2
2
{
3
3
 *****************************************************************************
4
4
 *                              Gtk2WSForms.pp                               * 
82
82
    class procedure SetFormBorderStyle(const AForm: TCustomForm;
83
83
                             const AFormBorderStyle: TFormBorderStyle); override;
84
84
    class procedure SetFormStyle(const AForm: TCustomform; const AFormStyle,
85
 
                       AOldFormStyle: TFormStyle); override;
86
 
{    class function GetDefaultClientRect(const AWinControl: TWinControl;
87
 
             const aLeft, aTop, aWidth, aHeight: integer; var aClientRect: TRect
88
 
             ): boolean; override;
89
 
    class procedure SetBorderIcons(const AForm: TCustomForm;
90
 
                                   const ABorderIcons: TBorderIcons); override;}
 
85
                       {%H-}AOldFormStyle: TFormStyle); override;
91
86
    class procedure SetAllowDropFiles(const AForm: TCustomForm; AValue: Boolean); override;
92
87
    class procedure SetShowInTaskbar(const AForm: TCustomForm; const AValue: TShowInTaskbar); override;
93
88
    class procedure ShowHide(const AWinControl: TWinControl); override;
94
 
    class procedure ShowModal(const AForm: TCustomForm); override;
 
89
    class procedure ShowModal(const {%H-}AForm: TCustomForm); override;
95
90
    class procedure SetBorderIcons(const AForm: TCustomForm;
96
91
                                   const ABorderIcons: TBorderIcons); override;
97
92
    class procedure SetColor(const AWinControl: TWinControl); override;
112
107
    class procedure SetCallbacks(const AWidget: PGtkWidget; const AWidgetInfo: PWidgetInfo); virtual;
113
108
  published
114
109
    class function  CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
 
110
    class procedure ShowHide(const AWinControl: TWinControl); override;
115
111
  end;
116
112
 
117
113
  { TGtk2WSScreen }
136
132
  AEvent: TGdkEventWindowState;
137
133
begin
138
134
  Result := False;
139
 
  AEvent := GetWidgetInfo(PGtkWidget(AnForm.Handle))^.FormWindowState;
140
 
  GTKWindowStateEventCB(PGtkWidget(AnForm.Handle), @AEvent, Data);
 
135
  AEvent := GetWidgetInfo({%H-}PGtkWidget(AnForm.Handle))^.FormWindowState;
 
136
  GTKWindowStateEventCB({%H-}PGtkWidget(AnForm.Handle), @AEvent, Data);
141
137
  // remove idle handler, because in fast switching hide/show there could
142
138
  // be dozen of added idle handlers, only one should be here.
143
139
  // also reset our internal flag on send_event.
144
 
  GetWidgetInfo(PGtkWidget(AnForm.Handle))^.FormWindowState.send_event := 0;
 
140
  GetWidgetInfo({%H-}PGtkWidget(AnForm.Handle))^.FormWindowState.send_event := 0;
145
141
  g_idle_remove_by_data(Data);
146
142
end;
147
143
 
148
 
{$IFDEF HASX}
149
 
function compositeManagerRunning: Boolean;
150
 
var
151
 
  XDisplay: PDisplay;
152
 
  WMAtom: TAtom;
153
 
begin
154
 
  Result := False;
155
 
  // who's running such old composition manager ?
156
 
  if (gtk_major_version = 2) and (gtk_minor_version < 10) then
157
 
    exit;
158
 
  XDisplay := gdk_display;
159
 
  WMAtom := XInternAtom(XDisplay,'_NET_WM_CM_S0', False);
160
 
  if WMAtom > 0 then
161
 
    Result := XGetSelectionOwner(XDisplay, WMAtom) <> 0;
162
 
end;
163
 
{$ENDIF}
164
 
 
165
144
function Gtk2FormEvent(widget: PGtkWidget; event: PGdkEvent; data: GPointer): gboolean; cdecl;
166
145
var
167
146
  ACtl: TWinControl;
182
161
        {fixes multiple resize events. See comments on
183
162
        http://bugs.freepascal.org/view.php?id=17015}
184
163
        ACtl := TWinControl(Data);
185
 
        GetWidgetRelativePosition(PGtkWidget(ACtl.Handle), X, Y);
 
164
        GetWidgetRelativePosition({%H-}PGtkWidget(ACtl.Handle), X, Y);
186
165
        Result := (event^.configure.send_event = 1) and
187
166
          not ((X <> ACtl.Left) or (Y <> ACtl.Top));
188
167
 
189
168
        {$IFDEF HASX}
190
169
        // fix for buggy compiz.
191
170
        // see http://bugs.freepascal.org/view.php?id=17523
192
 
        if compositeManagerRunning then
 
171
        if Gtk2WidgetSet.compositeManagerRunning then
193
172
        begin
194
173
          if (X <> ACtl.Left) or (Y <> ACtl.Top) then
195
174
            Result := gtkconfigureevent(widget, PGdkEventConfigure(event),
230
209
      end;
231
210
    GDK_ENTER_NOTIFY:
232
211
      begin
233
 
        FillChar(Mess, SizeOf(Mess), #0);
 
212
        FillChar(Mess{%H-}, SizeOf(Mess), #0);
234
213
        Mess.msg := LM_MOUSEENTER;
235
214
        DeliverMessage(Data, Mess);
236
215
      end;
255
234
          {$ENDIF}
256
235
          with Gtk2WidgetSet do
257
236
          begin
258
 
            LastFocusOut := PGtkWidget(ACtl.Handle);
 
237
            LastFocusOut := {%H-}PGtkWidget(ACtl.Handle);
259
238
            if LastFocusOut = LastFocusIn then
260
239
              StartFocusTimer;
261
240
          end;
263
242
        begin
264
243
          with Gtk2WidgetSet do
265
244
          begin
266
 
            LastFocusIn := PGtkWidget(ACtl.Handle);
 
245
            LastFocusIn := {%H-}PGtkWidget(ACtl.Handle);
267
246
            if not AppActive then
268
247
              AppActive := True;
269
248
          end;
270
249
        end;
 
250
        if GTK_IS_WINDOW(Widget) and
 
251
          (g_object_get_data({%H-}PGObject(ACtl.Handle),'lcl_nonmodal_over_modal') <> nil) then
 
252
        begin
 
253
          if PGdkEventFocus(event)^._in = 0 then
 
254
            gtk_window_set_modal({%H-}PGtkWindow(ACtl.Handle), False)
 
255
          else
 
256
            gtk_window_set_modal({%H-}PGtkWindow(ACtl.Handle), True);
 
257
        end;
271
258
      end;
272
259
  end;
273
260
end;
305
292
begin
306
293
  if AWinControl.HandleAllocated then
307
294
  begin
308
 
    Widget := PGtkWidget(AWinControl.Handle);
 
295
    Widget := {%H-}PGtkWidget(AWinControl.Handle);
309
296
    Result := GTK_WIDGET_VISIBLE(Widget) and GTK_WIDGET_SENSITIVE(Widget);
310
297
  end else
311
298
    Result := False;
366
353
    gtk_window_set_title(PGtkWindow(P), AParams.Caption);
367
354
 
368
355
    if (AParams.WndParent <> 0) then
369
 
      gtk_window_set_transient_for(PGtkWindow(P), PGtkWindow(AParams.WndParent))
 
356
      gtk_window_set_transient_for(PGtkWindow(P), {%H-}PGtkWindow(AParams.WndParent))
370
357
    else
371
358
    if not (csDesigning in ACustomForm.ComponentState) and
372
359
      (ACustomForm.FormStyle in fsAllStayOnTop) then
399
386
 
400
387
  // main menu
401
388
  if (ACustomForm.Menu <> nil) and (ACustomForm.Menu.HandleAllocated) then
402
 
    gtk_box_pack_start(Box, PGtkWidget(ACustomForm.Menu.Handle), False, False,0);
 
389
    gtk_box_pack_start(Box, {%H-}PGtkWidget(ACustomForm.Menu.Handle), False, False,0);
403
390
 
404
391
  // End of the old CreateForm method
405
392
 
414
401
  {$IFDEF DebugLCLComponents}
415
402
  DebugGtkWidgets.MarkCreated(P, dbgsName(AWinControl));
416
403
  {$ENDIF}
417
 
  Result := TLCLIntfHandle(PtrUInt(P));
 
404
  Result := TLCLIntfHandle({%H-}PtrUInt(P));
418
405
  Set_RC_Name(AWinControl, P);
419
406
  SetCallbacks(P, WidgetInfo);
420
407
end;
426
413
  g_idle_remove_by_data(Data);
427
414
end;
428
415
 
429
 
class procedure TGtk2WSCustomForm.ScrollBy(
430
 
  const AWinControl: TScrollingWinControl; const DeltaX, DeltaY: integer);
 
416
class procedure TGtk2WSCustomForm.ScrollBy(const AWinControl: TScrollingWinControl; const DeltaX, DeltaY: integer);
431
417
var
432
418
  Layout: PGtkLayout;
433
419
  WidgetInfo: PWidgetInfo;
436
422
  NewPos: Double;
437
423
begin
438
424
  if not AWinControl.HandleAllocated then exit;
439
 
  WidgetInfo := GetWidgetInfo(PGtkWidget(AWinControl.Handle));
 
425
  WidgetInfo := GetWidgetInfo({%H-}PGtkWidget(AWinControl.Handle));
440
426
  Layout := PGtkLayout(WidgetInfo^.ClientWidget);
441
427
  Adjustment := gtk_layout_get_hadjustment(Layout);
442
428
  if Adjustment <> nil then
443
429
  begin
444
430
    h := gtk_adjustment_get_value(Adjustment);
445
431
    NewPos := Adjustment^.upper - Adjustment^.page_size;
446
 
    if h + DeltaX <= NewPos then
447
 
      NewPos := h + DeltaX;
 
432
    if h - DeltaX <= NewPos then
 
433
      NewPos := h - DeltaX;
448
434
    if gtk_adjustment_get_value(Adjustment) <> NewPos then
449
435
    begin
450
436
      gtk_adjustment_set_value(Adjustment, NewPos);
459
445
  begin
460
446
    v := gtk_adjustment_get_value(Adjustment);
461
447
    NewPos := Adjustment^.upper - Adjustment^.page_size;
462
 
    if v + DeltaY <= NewPos then
463
 
      NewPos := v + DeltaY;
 
448
    if v - DeltaY <= NewPos then
 
449
      NewPos := v - DeltaY;
464
450
    if gtk_adjustment_get_value(Adjustment) <> NewPos then
465
451
    begin
466
452
      gtk_adjustment_set_value(Adjustment, NewPos);
484
470
 
485
471
  List := nil;
486
472
  if Small <> 0 then
487
 
    List := g_list_append(List, PGdkPixbuf(Small));
 
473
    List := g_list_append(List, {%H-}PGdkPixbuf(Small));
488
474
  if Big <> 0 then
489
 
    List := g_list_append(List, PGdkPixbuf(Big));
490
 
  gtk_window_set_icon_list(PGtkWindow(AForm.Handle), List);
 
475
    List := g_list_append(List, {%H-}PGdkPixbuf(Big));
 
476
  gtk_window_set_icon_list({%H-}PGtkWindow(AForm.Handle), List);
491
477
  if List <> nil
492
478
  then  g_list_free(List);
493
479
end;
497
483
begin
498
484
  if not WSCheckHandleAllocated(ACustomForm, 'SetAlphaBlend') then
499
485
    Exit;
500
 
  if Assigned(gtk_window_set_opacity) and GTK_IS_WINDOW(PGtkWidget(ACustomForm.Handle)) then
 
486
  if Assigned(gtk_window_set_opacity) and GTK_IS_WINDOW({%H-}PGtkWidget(ACustomForm.Handle)) then
501
487
    if AlphaBlend then
502
 
      gtk_window_set_opacity(PGtkWindow(ACustomForm.Handle), Alpha / 255)
 
488
      gtk_window_set_opacity({%H-}PGtkWindow(ACustomForm.Handle), Alpha / 255)
503
489
    else
504
 
      gtk_window_set_opacity(PGtkWindow(ACustomForm.Handle), 1);
 
490
      gtk_window_set_opacity({%H-}PGtkWindow(ACustomForm.Handle), 1);
505
491
end;
506
492
 
507
493
class procedure TGtk2WSCustomForm.SetFormBorderStyle(const AForm: TCustomForm;
517
503
  if (csDesigning in AForm.ComponentState) then
518
504
    exit;
519
505
 
520
 
  Widget := PGtkWidget(AForm.Handle);
 
506
  Widget := {%H-}PGtkWidget(AForm.Handle);
521
507
  WidgetInfo := GetWidgetInfo(Widget);
522
508
 
523
509
  if (WidgetInfo^.FormBorderStyle <> Ord(AFormBorderStyle)) then
549
535
    exit;
550
536
  if (csDesigning in AForm.ComponentState) then
551
537
    exit;
552
 
  if GTK_IS_WINDOW(PGtkWindow(AForm.Handle)) then
553
 
    gtk_window_set_keep_above(PGtkWindow(AForm.Handle),
 
538
  if GTK_IS_WINDOW({%H-}PGtkWindow(AForm.Handle)) then
 
539
    gtk_window_set_keep_above({%H-}PGtkWindow(AForm.Handle),
554
540
      GBoolean(AFormStyle in fsAllStayOnTop));
555
541
end;
556
542
 
557
 
{class function TGtk2WSCustomForm.GetDefaultClientRect(
558
 
  const AWinControl: TWinControl; const aLeft, aTop, aWidth, aHeight: integer;
559
 
  var aClientRect: TRect): boolean;
560
 
begin
561
 
  Result:=false;
562
 
  if AWinControl.HandleAllocated then begin
563
 
 
564
 
  end else begin
565
 
    FrameBorders:=GetStyleFormFrameBorders(TCustomForm(AWinControl).Menu<>nil);
566
 
    aClientRect:=Rect(0,0,
567
 
                 Max(0,aWidth-FrameBorders.Left-FrameBorders.Right),
568
 
                 Max(0,aHeight-FrameBorders.Top-FrameBorders.Bottom));
569
 
    Result:=true;
570
 
  end;
571
 
end;
572
 
 
573
 
class procedure TGtk2WSCustomForm.SetBorderIcons(const AForm: TCustomForm;
574
 
  const ABorderIcons: TBorderIcons);
575
 
begin
576
 
  gtk_window_get_modal();
577
 
end;}
578
 
 
579
543
class procedure TGtk2WSCustomForm.SetAllowDropFiles(const AForm: TCustomForm;
580
544
  AValue: Boolean);
581
545
begin
582
546
  if AValue then
583
 
    gtk_drag_dest_set(PGtkWidget(AForm.Handle), GTK_DEST_DEFAULT_ALL,
 
547
    gtk_drag_dest_set({%H-}PGtkWidget(AForm.Handle), GTK_DEST_DEFAULT_ALL,
584
548
      @FileDragTarget, 1, GDK_ACTION_COPY or GDK_ACTION_MOVE)
585
549
  else
586
 
    gtk_drag_dest_unset(PGtkWidget(AForm.Handle));
 
550
    gtk_drag_dest_unset({%H-}PGtkWidget(AForm.Handle));
587
551
end;
588
552
 
589
553
class procedure TGtk2WSCustomForm.SetShowInTaskbar(const AForm: TCustomForm;
599
563
var
600
564
  AForm: TCustomForm;
601
565
  GtkWindow: PGtkWindow;
 
566
  Geometry: TGdkGeometry;
 
567
 
 
568
  function ShowNonModalOverModal: Boolean;
 
569
  var
 
570
    AForm: TCustomForm;
 
571
    AWindow: PGtkWindow;
 
572
  begin
 
573
    Result := False;
 
574
    AForm := TCustomForm(AWinControl);
 
575
    if AWinControl.HandleObjectShouldBeVisible and
 
576
      not (csDesigning in AForm.ComponentState) and
 
577
      not (fsModal in AForm.FormState) and
 
578
      (AForm.Parent = nil) and
 
579
      (AForm.FormStyle <> fsMDIChild) and
 
580
      (ModalWindows <> nil) and (ModalWindows.Count > 0) and
 
581
      not (AForm.FormStyle in fsAllStayOnTop) and
 
582
      (AForm.BorderStyle in [bsDialog, bsSingle, bsSizeable]) and
 
583
      (AForm.PopupParent = nil) and (AForm.PopupMode = pmNone) then
 
584
    begin
 
585
      AWindow := {%H-}PGtkWindow(AForm.Handle);
 
586
      gtk_window_set_modal(AWindow, True);
 
587
      // lcl_nonmodal_over_modal is needed to track nonmodal form
 
588
      // created and shown when we have active modal forms
 
589
      g_object_set_data(PGObject(AWindow),'lcl_nonmodal_over_modal', AForm);
 
590
      Result := True;
 
591
    end;
 
592
  end;
602
593
begin
603
594
  AForm := TCustomForm(AWinControl);
604
595
  if not (csDesigning in AForm.ComponentState) then
605
596
  begin
606
597
    if AForm.HandleObjectShouldBeVisible and
607
 
      GTK_IS_WINDOW(PGtkWindow(AForm.Handle)) then
608
 
        gtk_window_set_keep_above(PGtkWindow(AForm.Handle),
 
598
      GTK_IS_WINDOW({%H-}PGtkWindow(AForm.Handle)) then
 
599
        gtk_window_set_keep_above({%H-}PGtkWindow(AForm.Handle),
609
600
          GBoolean(AForm.FormStyle in fsAllStayOnTop))
610
601
    else
611
602
    if (AForm.FormStyle in fsAllStayOnTop) and
612
603
      not (csDestroying in AWinControl.ComponentState) then
613
 
        gtk_window_set_keep_above(PGtkWindow(AForm.Handle), GBoolean(False));
 
604
        gtk_window_set_keep_above({%H-}PGtkWindow(AForm.Handle), GBoolean(False));
614
605
  end;
 
606
 
 
607
  GtkWindow := {%H-}PGtkWindow(AForm.Handle);
615
608
  if (fsModal in AForm.FormState) and AForm.HandleObjectShouldBeVisible then
616
609
  begin
617
 
    GtkWindow := PGtkWindow(AForm.Handle);
618
610
    gtk_window_set_default_size(GtkWindow, Max(1,AForm.Width), Max(1,AForm.Height));
619
611
    gtk_widget_set_uposition(PGtkWidget(GtkWindow), AForm.Left, AForm.Top);
620
612
    GtkWindowShowModal(AForm, GtkWindow);
621
 
  end
622
 
  else
 
613
  end else
 
614
  begin
 
615
    if ShowNonModalOverModal then
 
616
    // issue #21459
 
617
    else
 
618
    if (AForm.FormStyle <> fsMDIChild) and AForm.HandleObjectShouldBeVisible and
 
619
      (ModalWindows <> nil) and (ModalWindows.Count > 0) and
 
620
      (AForm.PopupParent = nil) and (AForm.BorderStyle = bsNone) then
 
621
    begin
 
622
      gtk_window_set_transient_for(GtkWindow, nil);
 
623
      gtk_window_set_modal(GtkWindow, True);
 
624
    end;
623
625
    Gtk2WidgetSet.SetVisible(AWinControl, AForm.HandleObjectShouldBeVisible);
 
626
  end;
 
627
 
 
628
  if not (csDesigning in AForm.ComponentState) and
 
629
    AForm.HandleObjectShouldBeVisible and
 
630
    (AForm.BorderStyle in [bsDialog, bsSingle]) then
 
631
  begin
 
632
    // we must set fixed size, gtk_window_set_resizable does not work
 
633
    // as expected for some reason.issue #20741
 
634
    with Geometry do
 
635
    begin
 
636
      min_width := AForm.Width;
 
637
      max_width := AForm.Width;
 
638
      min_height := AForm.Height;
 
639
      max_height := AForm.Height;
 
640
 
 
641
      base_width := AForm.Width;
 
642
      base_height := AForm.Height;
 
643
      width_inc := 1;
 
644
      height_inc := 1;
 
645
      min_aspect := 0;
 
646
      max_aspect := 1;
 
647
      win_gravity := gtk_window_get_gravity(GtkWindow);
 
648
    end;
 
649
    //debugln('TGtk2WSWinControl.ConstraintsChange A ',GetWidgetDebugReport(Widget),' max=',dbgs(Geometry.max_width),'x',dbgs(Geometry.max_height));
 
650
    gtk_window_set_geometry_hints(GtkWindow, nil, @Geometry,
 
651
      GDK_HINT_POS or GDK_HINT_MIN_SIZE or GDK_HINT_MAX_SIZE);
 
652
  end;
 
653
 
 
654
  if not (csDesigning in AForm.ComponentState) and
 
655
    AForm.HandleObjectShouldBeVisible and (AForm.WindowState = wsFullScreen) then
 
656
      gtk_window_fullscreen(GtkWindow);
 
657
 
 
658
 
624
659
  InvalidateLastWFPResult(AWinControl, AWinControl.BoundsRect);
625
660
end;
626
661
 
659
694
      PopupParent := APopupParent;
660
695
  end;
661
696
  if PopupParent <> nil then
662
 
    gtk_window_set_transient_for(PGtkWindow(ACustomForm.Handle), PGtkWindow(PopupParent.Handle))
 
697
    gtk_window_set_transient_for({%H-}PGtkWindow(ACustomForm.Handle), {%H-}PGtkWindow(PopupParent.Handle))
663
698
  else
664
 
    gtk_window_set_transient_for(PGtkWindow(ACustomForm.Handle), nil);
 
699
    gtk_window_set_transient_for({%H-}PGtkWindow(ACustomForm.Handle), nil);
665
700
end;
666
701
 
667
702
 
685
720
end;
686
721
 
687
722
class function TGtk2WSScrollingWinControl.CreateHandle(
688
 
  const AWinControl: TWinControl; const AParams: TCreateParams
689
 
  ): TLCLIntfHandle;
 
723
  const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle;
690
724
var
691
725
  Scrolled: PGtkScrolledWindow;
692
726
  Layout: PGtkWidget;
726
760
  SetFixedWidget(Scrolled, Layout);
727
761
  SetMainWidget(Scrolled, Layout);
728
762
 
729
 
 
730
 
  Result := TLCLIntfHandle(PtrUInt(Scrolled));
 
763
  Result := TLCLIntfHandle({%H-}PtrUInt(Scrolled));
731
764
 
732
765
  Set_RC_Name(AWinControl, PGtkWidget(Scrolled));
733
766
  SetCallBacks(PGtkWidget(Scrolled), WidgetInfo);
734
767
  if (gtk_major_version >= 2) and (gtk_minor_version > 8) then
735
768
  begin
736
769
    g_signal_connect(Scrolled^.hscrollbar, 'change-value',
737
 
      TGCallback(@Gtk2RangeScrollCB), WidgetInfo);
 
770
                     TGCallback(@Gtk2RangeScrollCB), WidgetInfo);
738
771
    g_signal_connect(Scrolled^.vscrollbar, 'change-value',
739
 
      TGCallback(@Gtk2RangeScrollCB), WidgetInfo);
 
772
                     TGCallback(@Gtk2RangeScrollCB), WidgetInfo);
 
773
    g_signal_connect(Scrolled^.hscrollbar, 'button-press-event',
 
774
                     TGCallback(@Gtk2RangeScrollPressCB), WidgetInfo);
 
775
    g_signal_connect(Scrolled^.hscrollbar, 'button-release-event',
 
776
                     TGCallback(@Gtk2RangeScrollReleaseCB), WidgetInfo);
 
777
    g_signal_connect(Scrolled^.vscrollbar, 'button-press-event',
 
778
                     TGCallback(@Gtk2RangeScrollPressCB), WidgetInfo);
 
779
    g_signal_connect(Scrolled^.vscrollbar, 'button-release-event',
 
780
                     TGCallback(@Gtk2RangeScrollReleaseCB), WidgetInfo);
 
781
    if (AWinControl is TScrollBox) then
 
782
      g_signal_connect(Scrolled, 'scroll-event',
 
783
                       TGCallback(@Gtk2ScrolledWindowScrollCB), WidgetInfo);
740
784
  end;
741
785
end;
742
786
 
746
790
  if not WSCheckHandleAllocated(AWinControl, 'SetColor')
747
791
  then Exit;
748
792
 
749
 
  Gtk2WidgetSet.SetWidgetColor(PGtkBin(AWinControl.Handle)^.child,
 
793
  Gtk2WidgetSet.SetWidgetColor({%H-}PGtkBin(AWinControl.Handle)^.child,
750
794
                               clNone, AWinControl.Color,
751
795
                               [GTK_STATE_NORMAL, GTK_STATE_ACTIVE,
752
796
                                GTK_STATE_PRELIGHT, GTK_STATE_SELECTED]);
761
805
  NewPos: Double;
762
806
begin
763
807
  if not AWinControl.HandleAllocated then exit;
764
 
  Scrolled := GTK_SCROLLED_WINDOW(Pointer(AWinControl.Handle));
 
808
  Scrolled := GTK_SCROLLED_WINDOW({%H-}Pointer(AWinControl.Handle));
765
809
  if not GTK_IS_SCROLLED_WINDOW(Scrolled) then
766
810
    exit;
767
811
  Adjustment := gtk_scrolled_window_get_hadjustment(Scrolled);
769
813
  begin
770
814
    h := gtk_adjustment_get_value(Adjustment);
771
815
    NewPos := Adjustment^.upper - Adjustment^.page_size;
772
 
    if h + DeltaX <= NewPos then
773
 
      NewPos := h + DeltaX;
 
816
    if h - DeltaX <= NewPos then
 
817
      NewPos := h - DeltaX;
774
818
    gtk_adjustment_set_value(Adjustment, NewPos);
775
819
  end;
776
820
  Adjustment := gtk_scrolled_window_get_vadjustment(Scrolled);
778
822
  begin
779
823
    v := gtk_adjustment_get_value(Adjustment);
780
824
    NewPos := Adjustment^.upper - Adjustment^.page_size;
781
 
    if v + DeltaY <= NewPos then
782
 
      NewPos := v + DeltaY;
 
825
    if v - DeltaY <= NewPos then
 
826
      NewPos := v - DeltaY;
783
827
    gtk_adjustment_set_value(Adjustment, NewPos);
784
828
  end;
785
829
end;
849
893
  {$IFDEF DebugLCLComponents}
850
894
  DebugGtkWidgets.MarkCreated(P,dbgsName(AWinControl));
851
895
  {$ENDIF}
852
 
  Result := TLCLIntfHandle(PtrUInt(P));
 
896
  Result := TLCLIntfHandle({%H-}PtrUInt(P));
853
897
  Set_RC_Name(AWinControl, P);
854
898
  SetCallbacks(P, WidgetInfo);
855
899
end;
 
900
 
 
901
class procedure TGtk2WSHintWindow.ShowHide(const AWinControl: TWinControl);
 
902
begin
 
903
  if not WSCheckHandleAllocated(AWinControl, 'SetColor') then
 
904
    exit;
 
905
  Gtk2WidgetSet.SetVisible(AWinControl, AWinControl.HandleObjectShouldBeVisible);
 
906
  InvalidateLastWFPResult(AWinControl, AWinControl.BoundsRect);
 
907
end;
 
908
 
856
909
end.