Commit f1335e9e authored by Juha Manninen's avatar Juha Manninen
Browse files

LCL-GTK3: Fix Splitter and its related code. Issue #34106, patch from Anton Kavalenka.

git-svn-id: trunk@59339 -
parent 09050483
......@@ -283,8 +283,8 @@ type
TGtkOrientation = Integer;
const
{ GtkOrientation }
GTK_ORIENTATION_HORIZONTAL: TGtkOrientation = 0;
GTK_ORIENTATION_VERTICAL: TGtkOrientation = 1;
GTK_ORIENTATION_HORIZONTAL = TGtkOrientation(0);
GTK_ORIENTATION_VERTICAL = TGtkOrientation(1);
 
type
TGtkDestDefaults = Integer;
......@@ -29,45 +29,22 @@ begin
if dy < 0 then
dy := 0;
(*
// rubber band is just a window without a title
Result := {%H-}HWND(gtk_window_new(GTK_WINDOW_POPUP));
Result := {%H-}HWND(gtk_window_new(GTK_WINDOW_TOPLEVEL));
gtk_window_set_default_size({%H-}PGtkWindow(Result), dx, dy);
gtk_widget_set_uposition(Widget, ARect.Left, ARect.Top);
gtk_widget_set_app_paintable(Widget, True);
gtk_widget_realize(Widget);
gdk_window_set_decorations(Widget^.window, 0);
gdk_window_set_functions(Widget^.window, GDK_FUNC_RESIZE or GDK_FUNC_CLOSE);
gtk_window_set_opacity({%H-}PGtkWindow(Result), 0.25);
if ABrush = 0 then
SetWidgetColor(Widget, clNone, clGradientActiveCaption, [GTK_STATE_NORMAL])
else
if {%H-}PGDIObject(ABrush)^.GDIBrushFill = GDK_SOLID then
SetWidgetColor(Widget, clNone, {%H-}PGDIObject(ABrush)^.GDIBrushColor.ColorRef, [GTK_STATE_NORMAL])
else
begin
Pixmap := gdk_pixmap_new(Widget^.window, dx, dy, -1);
gc := gdk_gc_new(Pixmap);
AColor := AllocGDKColor(clWhite);
gdk_gc_set_foreground(gc, @AColor);
gdk_gc_set_fill(gc, {%H-}PGDIObject(ABrush)^.GDIBrushFill);
case {%H-}PGDIObject(ABrush)^.GDIBrushFill of
GDK_TILED: gdk_gc_set_tile(gc, {%H-}PGDIObject(ABrush)^.GDIBrushPixMap);
GDK_STIPPLED: gdk_gc_set_stipple(gc, {%H-}PGDIObject(ABrush)^.GDIBrushPixMap);
end;
gdk_draw_rectangle(Pixmap, gc, -1, 0, 0, dx, dy);
gdk_gc_unref(gc);
gdk_window_set_back_pixmap(Widget^.window, Pixmap, False);
g_object_unref(Pixmap);
end;
gtk_widget_set_opacity(Widget, 0.25);
gtk_widget_show(Widget);
*)
end;
procedure TGtk3WidgetSet.DestroyRubberBand(ARubberBand: HWND);
begin
// TODO: gtk_widget_destroy({%H-}PGtkWidget(ARubberBand));
gtk_widget_destroy({%H-}PGtkWidget(ARubberBand));
end;
procedure TGtk3WidgetSet.DrawDefaultDockImage(AOldRect, ANewRect: TRect;
......
......@@ -25,7 +25,7 @@ uses
Classes, SysUtils, types, math,
// LCL
Controls, StdCtrls, ExtCtrls, ComCtrls, Graphics, Dialogs, Forms, Menus, ExtDlgs,
Spin, CheckLst, LCLType, LCLProc, LMessages, LCLMessageGlue, LCLIntf,
Spin, CheckLst, PairSplitter, LCLType, LCLProc, LMessages, LCLMessageGlue, LCLIntf,
// GTK3
LazGtk3, LazGdk3, LazGObject2, LazGLib2, LazCairo1, LazPango1, LazGdkPixbuf2,
gtk3objects, gtk3procs, gtk3private, Gtk3CellRenderer;
......@@ -383,6 +383,22 @@ type
end;
{ TGtk3Paned }
TGtk3Paned = class(TGtk3Container)
protected
function CreateWidget(const Params: TCreateParams):PGtkWidget; override;
end;
{ TGtk3SplitterSide }
TGtk3SplitterSide = class(TGtk3Container)
protected
function CreateWidget(const Params: TCreateParams):PGtkWidget; override;
end;
{ TGtk3MenuShell }
TGtk3MenuShell = class(TGtk3Container)
......@@ -711,6 +727,13 @@ type
function CreateWidget(const Params: TCreateParams):PGtkWidget; override;
end;
{ TGtk3Splitter }
TGtk3Splitter = class(TGtk3Panel)
public
end;
{ TGtk3Window }
TGtk3Window = class(TGtk3ScrollableWin) {we are TGtk3Bin actually, but it won't hurt since we need scroll}
......@@ -1591,6 +1614,25 @@ begin
// DebugLn('Gtk3ScrollEvent for ', dbgsName(TGtk3Widget(AData).LCLObject),' Result ',dbgs(Result));
end;
{ TGtk3SplitterSide }
function TGtk3SplitterSide.CreateWidget(const Params: TCreateParams): PGtkWidget;
begin
Result:=TGtkScrolledWindow.new(nil, nil);
end;
{ TGtk3Paned }
function TGtk3Paned.CreateWidget(const Params: TCreateParams): PGtkWidget;
const
ornt:array[TPairSplitterType] of TGtkOrientation=(
GTK_ORIENTATION_HORIZONTAL,
GTK_ORIENTATION_VERTICAL
);
begin
Result:=TGtkPaned.new(ornt[TPairSplitter(Self.LCLObject).SplitterType]);
end;
{ TGtk3Widget }
function TGtk3Widget.GtkEventMouseEnterLeave(Sender: PGtkWidget; Event: PGdkEvent): Boolean;
......@@ -1598,23 +1640,22 @@ function TGtk3Widget.GtkEventMouseEnterLeave(Sender: PGtkWidget; Event: PGdkEven
var
Msg: TLMessage;
// MouseMsg: TLMMouseMove absolute Msg;
{$IFDEF GTK3DEBUGCORE}
MousePos: TPoint;
{$ENDIF}
begin
Result := False;
FillChar(Msg, SizeOf(Msg), #0);
if Event^.type_ = GDK_ENTER_NOTIFY then
begin
Msg.Msg := LM_MOUSEENTER;
end else
begin
Msg.Msg := LM_MOUSEENTER
else
Msg.Msg := LM_MOUSELEAVE;
end;
MousePos.X := Round(Event^.crossing.x);
MousePos.Y := Round(Event^.crossing.y);
NotifyApplicationUserInput(LCLObject, Msg.Msg);
Result := DeliverMessage(Msg, True) <> 0;
{$IFDEF GTK3DEBUGCORE}
MousePos.X := Round(Event^.crossing.x);
MousePos.Y := Round(Event^.crossing.y);
DebugLn('GtkEventMouseEnterLeave: mousePos ',dbgs(MousePos),' Object ',dbgsName(LCLObject),
' IsEnter ',dbgs(Event^.type_ = GDK_ENTER_NOTIFY),' Result=',dbgs(Result));
{$ENDIF}
......@@ -3881,10 +3922,7 @@ begin
AToolBar := TToolBar(LCLObject);
FHasPaint := False;
FWidgetType := [wtWidget, wtContainer];
Result := PGtkWidget(TGtkHBox.new(GTK_ORIENTATION_HORIZONTAL, 0));
FCentralWidget := PGtkWidget(TGtkFixed.new);
PGtkHBox(Result)^.add(FCentralWidget);
PGtkFixed(FCentralWidget)^.set_has_window(True);
Result:=PGtkWidget(TGtkToolbar.new);
end;
{ TGtk3Page }
......@@ -6453,7 +6491,7 @@ end;
function TGtk3Window.GetTitle: String;
begin
Result := '';
Result:=PGtkWindow(FWidget)^.get_title();
end;
procedure TGtk3Window.SetIcon(AValue: PGdkPixBuf);
......@@ -6557,9 +6595,15 @@ begin
FHasPaint := True;
AForm := TCustomForm(LCLObject);
FWidgetType := [wtWidget, wtLayout, wtScrollingWin, wtWindow];
Result := TGtkWindow.new(GTK_WINDOW_TOPLEVEL);
if not Assigned(LCLObject.Parent) then
begin
Result := TGtkWindow.new(GTK_WINDOW_TOPLEVEL);
FWidgetType := [wtWidget, wtLayout, wtScrollingWin, wtWindow];
end else
begin
Result := PGtkScrolledWindow(TGtkScrolledWindow.new(nil, nil));
FWidgetType := [wtWidget, wtLayout, wtScrollingWin, wtCustomControl]
end;
FBox := TGtkVBox.new(GTK_ORIENTATION_VERTICAL, 0);
......
......@@ -3677,10 +3677,8 @@ end;
function TGtk3WidgetSet.SetParent(hWndChild: HWND; hWndParent: HWND): HWND;
begin
{$IFDEF GTK3DEBUGNOTIMPLEMENTED}
DebugLn('WARNING: TGtk3WidgetSet.SetParent not implemented ...');
{$ENDIF}
Result:=inherited SetParent(hWndChild, hWndParent);
Result := HWND(TGtk3Widget(hWndChild).getParent);
TGtk3Widget(hWndChild).SetParent(TGtk3Widget(hWndParent),0,0)
end;
function TGtk3WidgetSet.SetProp(Handle: hwnd; Str: PChar; Data: Pointer
......
......@@ -50,6 +50,8 @@ type
TGtk3WSCustomSplitter = class(TWSCustomSplitter)
published
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): TLCLIntfHandle; override;
end;
{ TGtk3WSSplitter }
......@@ -146,6 +148,17 @@ implementation
uses
gtk3widgets;
{ TGtk3WSCustomSplitter }
class function TGtk3WSCustomSplitter.CreateHandle(
const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle;
var
ASplitter: TGtk3Splitter;
begin
ASplitter := TGtk3Splitter.Create(AWinControl, AParams);
Result := TLCLIntfHandle(ASplitter);
end;
{ TGtk3WSCustomPanel }
class function TGtk3WSCustomPanel.CreateHandle(const AWinControl: TWinControl;
......
......@@ -21,7 +21,7 @@ interface
uses
Classes, Controls, ComCtrls, Calendar, StdCtrls, Arrow, Spin,
Dialogs, ExtCtrls, ExtDlgs, Buttons, CheckLst, Forms, Grids, Menus,
PairSplitter, ImgList, WSLCLClasses;
ImgList, PairSplitter, WSLCLClasses;
// imglist
......@@ -137,7 +137,7 @@ uses
uses
Gtk3WSImgList, Gtk3WSControls, Gtk3WSForms, Gtk3WSButtons, Gtk3WSStdCtrls,
Gtk3WSComCtrls, Gtk3WSExtCtrls, Gtk3WSSpin, Gtk3WSMenus, Gtk3WSCalendar,
Gtk3WSDialogs, Gtk3WSCheckLst, Gtk3WSExtDlgs;
Gtk3WSDialogs, Gtk3WSCheckLst, Gtk3WSExtDlgs, gtk3wssplitter;
// imglist
function RegisterCustomImageListResolution: Boolean; alias : 'WSRegisterCustomImageListResolution';
......@@ -402,9 +402,8 @@ end;
function RegisterCustomSplitter: Boolean; alias : 'WSRegisterCustomSplitter';
begin
// RegisterWSComponent(TCustomSplitter, TGtk2WSCustomSplitter);
// RegisterWSComponent(TSplitter, TGtk2WSSplitter);
Result := False;
RegisterWSComponent(TCustomSplitter, TGtk3WSCustomSplitter);
Result := true;
end;
function RegisterPaintBox: Boolean; alias : 'WSRegisterPaintBox';
......@@ -597,16 +596,14 @@ end;
function RegisterPairSplitterSide: Boolean; alias : 'WSRegisterPairSplitterSide';
begin
// RegisterWSComponent(TPairSplitterSide, TGtk2WSPairSplitterSide); { GTK1 }
// RegisterWSComponent(TPairSplitterSide, TGtk2WSPairSplitterSide);
Result := False;
RegisterWSComponent(TPairSplitterSide, TGtk3WSPairSplitterSide);
Result := true;
end;
function RegisterCustomPairSplitter: Boolean; alias : 'WSRegisterCustomPairSplitter';
begin
// RegisterWSComponent(TCustomPairSplitter, TGtk2WSCustomPairSplitter, TGtkPrivatePaned); { GTK1 }
// RegisterWSComponent(TCustomPairSplitter, TGtk2WSCustomPairSplitter);
Result := False;
RegisterWSComponent(TCustomPairSplitter, TGtk3WSCustomPairSplitter);
Result := true;
end;
function RegisterCustomFloatSpinEdit: Boolean; alias : 'WSRegisterCustomFloatSpinEdit';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment