mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-06 04:58:14 +02:00
lcl: gtk3: fixed getting style constraints
This commit is contained in:
parent
7eb893ea23
commit
aa8213a2b4
@ -29,7 +29,7 @@ uses
|
|||||||
LazLoggerBase, LazTracer, LazUTF8, IntegerList, GraphType, LazUtilities,
|
LazLoggerBase, LazTracer, LazUTF8, IntegerList, GraphType, LazUtilities,
|
||||||
// LCL
|
// LCL
|
||||||
LCLPlatformDef, InterfaceBase, LCLProc, LCLType, LMessages, LCLMessageGlue,
|
LCLPlatformDef, InterfaceBase, LCLProc, LCLType, LMessages, LCLMessageGlue,
|
||||||
Controls, Forms, Graphics, GraphUtil, IntfGraphics,
|
Controls, Forms, Graphics, GraphUtil, IntfGraphics, StdCtrls, ComCtrls,
|
||||||
LazGtk3, LazGdk3, LazGlib2, LazGObject2, LazCairo1, LazPango1, LazGio2,
|
LazGtk3, LazGdk3, LazGlib2, LazGObject2, LazCairo1, LazPango1, LazGio2,
|
||||||
LazGdkPixbuf2, gtk3widgets, gtk3objects, gtk3procs, gtk3boxes;
|
LazGdkPixbuf2, gtk3widgets, gtk3objects, gtk3procs, gtk3boxes;
|
||||||
|
|
||||||
|
@ -1035,7 +1035,6 @@ end;
|
|||||||
Updates the constraints object (e.g. TSizeConstraints) with interface specific
|
Updates the constraints object (e.g. TSizeConstraints) with interface specific
|
||||||
bounds.
|
bounds.
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
(*
|
|
||||||
function TGtk3WidgetSet.GetControlConstraints(Constraints: TObject): boolean;
|
function TGtk3WidgetSet.GetControlConstraints(Constraints: TObject): boolean;
|
||||||
var
|
var
|
||||||
SizeConstraints: TSizeConstraints absolute Constraints;
|
SizeConstraints: TSizeConstraints absolute Constraints;
|
||||||
@ -1044,70 +1043,46 @@ var
|
|||||||
MinHeight: Integer;
|
MinHeight: Integer;
|
||||||
MaxWidth: Integer;
|
MaxWidth: Integer;
|
||||||
MaxHeight: Integer;
|
MaxHeight: Integer;
|
||||||
|
aPageControl: TPageControl;
|
||||||
begin
|
begin
|
||||||
Result := True;
|
Result := True;
|
||||||
|
|
||||||
if Constraints is TSizeConstraints then
|
if Constraints is TSizeConstraints then
|
||||||
begin
|
begin
|
||||||
|
if (SizeConstraints.Control=nil) then exit;
|
||||||
MinWidth := 1;
|
MinWidth := 1;
|
||||||
MinHeight := 1;
|
MinHeight := 1;
|
||||||
MaxWidth := 0;
|
MaxWidth := 0;
|
||||||
MaxHeight := 0;
|
MaxHeight := 0;
|
||||||
|
|
||||||
if (SizeConstraints.Control=nil) then exit;
|
|
||||||
|
|
||||||
if SizeConstraints.Control is TScrollBar then begin
|
if SizeConstraints.Control is TScrollBar then begin
|
||||||
// TScrollBar
|
// TScrollBar
|
||||||
if TScrollBar(SizeConstraints.Control).Kind=sbHorizontal then begin
|
if TScrollBar(SizeConstraints.Control).Kind=sbHorizontal then begin
|
||||||
Widget:=GetStyleWidget(lgsHorizontalScrollbar);
|
Widget:=GetStyleWidget(lgsHorizontalScrollbar);
|
||||||
MinHeight:=Widget^.requisition.Height;
|
MinHeight:=Widget^.get_allocated_height();
|
||||||
MaxHeight:=MinHeight;
|
MaxHeight:=MinHeight;
|
||||||
end else begin
|
end else begin
|
||||||
Widget:=GetStyleWidget(lgsVerticalScrollbar);
|
Widget:=GetStyleWidget(lgsVerticalScrollbar);
|
||||||
MinWidth:=Widget^.requisition.Width;
|
MinWidth:=Widget^.get_allocated_width();
|
||||||
MaxWidth:=MinWidth;
|
MaxWidth:=MinWidth;
|
||||||
end;
|
end;
|
||||||
//DebugLn('TGtk3WidgetSet.GetControlConstraints A '+dbgs(MinWidth)+','+dbgs(MinHeight),' ',dbgs(TScrollBar(SizeConstraints.Control).Kind=sbHorizontal),' ',TScrollBar(SizeConstraints.Control).Name);
|
//DebugLn('TGtk3WidgetSet.GetControlConstraints A '+dbgs(MinWidth)+','+dbgs(MinHeight),' ',dbgs(TScrollBar(SizeConstraints.Control).Kind=sbHorizontal),' ',TScrollBar(SizeConstraints.Control).Name);
|
||||||
end
|
end else if SizeConstraints.Control is TPageControl then begin
|
||||||
else if SizeConstraints.Control is TCustomSplitter then begin
|
aPageControl:=TPageControl(SizeConstraints.Control);
|
||||||
// TCustomSplitter
|
if aPageControl.TabPosition in [tpTop, tpBottom] then begin
|
||||||
if TCustomSplitter(SizeConstraints.Control).ResizeAnchor in [akTop,akBottom] then
|
MinHeight:=20;
|
||||||
begin
|
|
||||||
Widget:=GetStyleWidget(lgsHorizontalPaned);
|
|
||||||
MinHeight:=Widget^.requisition.Height;
|
|
||||||
MaxHeight:=MinHeight;
|
|
||||||
end else begin
|
end else begin
|
||||||
Widget:=GetStyleWidget(lgsVerticalPaned);
|
MinWidth:=20;
|
||||||
MinWidth:=Widget^.requisition.Width;
|
|
||||||
MaxWidth:=MinWidth;
|
|
||||||
end;
|
end;
|
||||||
end
|
//DebugLn('TGtk3WidgetSet.GetControlConstraints A '+DbgSName(SizeConstraints.Control),' ',dbgs(MinWidth)+','+dbgs(MinHeight));
|
||||||
else if SizeConstraints.Control is TCustomMemo then begin
|
|
||||||
// TCustomMemo
|
|
||||||
Widget:=GetStyleWidget(lgsHorizontalScrollbar);
|
|
||||||
MinHeight:=Widget^.requisition.Height+20;
|
|
||||||
Widget:=GetStyleWidget(lgsVerticalScrollbar);
|
|
||||||
MinWidth:=Widget^.requisition.Width+20;
|
|
||||||
end
|
|
||||||
else if SizeConstraints.Control is TCustomTrackBar then begin
|
|
||||||
// TCustomTrackBar
|
|
||||||
if TCustomTrackBar(SizeConstraints.Control).Orientation=trHorizontal then
|
|
||||||
begin
|
|
||||||
Widget:=GetStyleWidget(lgsHScale);
|
|
||||||
MinHeight:=Widget^.requisition.height;
|
|
||||||
end else begin
|
|
||||||
Widget:=GetStyleWidget(lgsVScale);
|
|
||||||
MinWidth:=Widget^.requisition.width;
|
|
||||||
end;
|
|
||||||
//DebugLn(['TGtk3WidgetSet.GetControlConstraints ',DbgSName(SizeConstraints.Control),
|
|
||||||
// ' ',MinWidth,',',MinHeight]);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
//DebugLn('TGtk3WidgetSet.GetControlConstraints A '+DbgSName(SizeConstraints.Control),' ',dbgs(MinWidth)+','+dbgs(MinHeight));
|
||||||
|
|
||||||
SizeConstraints.SetInterfaceConstraints(MinWidth,MinHeight,
|
SizeConstraints.SetInterfaceConstraints(MinWidth,MinHeight,
|
||||||
MaxWidth,MaxHeight);
|
MaxWidth,MaxHeight);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
*)
|
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
function TGtk3WidgetSet.GetLCLOwnerObject(Handle: HWnd): TObject;
|
function TGtk3WidgetSet.GetLCLOwnerObject(Handle: HWnd): TObject;
|
||||||
|
@ -38,7 +38,7 @@ function ExtUTF8Out(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect;
|
|||||||
function FontIsMonoSpace(Font: HFont): boolean; override;
|
function FontIsMonoSpace(Font: HFont): boolean; override;
|
||||||
|
|
||||||
function GetAcceleratorString(const AVKey: Byte; const AShiftState: TShiftState): String; override;
|
function GetAcceleratorString(const AVKey: Byte; const AShiftState: TShiftState): String; override;
|
||||||
// function GetControlConstraints(Constraints: TObject): boolean; override;
|
function GetControlConstraints(Constraints: TObject): boolean; override;
|
||||||
function GetLCLOwnerObject(Handle: HWnd): TObject; override;
|
function GetLCLOwnerObject(Handle: HWnd): TObject; override;
|
||||||
|
|
||||||
function PromptUser(const DialogCaption : string;
|
function PromptUser(const DialogCaption : string;
|
||||||
|
@ -89,7 +89,7 @@ type
|
|||||||
|
|
||||||
TGtkScrollStyle = record
|
TGtkScrollStyle = record
|
||||||
Horizontal,
|
Horizontal,
|
||||||
Vertical: TGtkPolicyType;
|
Vertical: TGtkPolicyType;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
const
|
const
|
||||||
@ -1046,7 +1046,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GetStyleWithName(const WName: String): PGtkWidget;
|
function GetStyleWithName(const WName: String): PStyleObject;
|
||||||
var
|
var
|
||||||
StyleObject : PStyleObject;
|
StyleObject : PStyleObject;
|
||||||
AIndex: Integer;
|
AIndex: Integer;
|
||||||
@ -1058,11 +1058,11 @@ begin
|
|||||||
AIndex := IndexOfStyleWithName(WName);
|
AIndex := IndexOfStyleWithName(WName);
|
||||||
if AIndex >= 0 then
|
if AIndex >= 0 then
|
||||||
begin
|
begin
|
||||||
StyleObject := PStyleObject(Styles.Objects[AIndex]);
|
Result := PStyleObject(Styles.Objects[AIndex]);
|
||||||
Result := StyleObject^.Widget;
|
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
StyleObject := NewStyleObject;
|
StyleObject := NewStyleObject;
|
||||||
|
Result:=StyleObject;
|
||||||
lgs := lgsUserDefined;
|
lgs := lgsUserDefined;
|
||||||
DebugLn('GetStyleWithName creating style widget ',WName);
|
DebugLn('GetStyleWithName creating style widget ',WName);
|
||||||
WidgetName := 'LazStyle' + WName;
|
WidgetName := 'LazStyle' + WName;
|
||||||
@ -1135,7 +1135,6 @@ begin
|
|||||||
|
|
||||||
//TODO: copy stuff from gtk2proc
|
//TODO: copy stuff from gtk2proc
|
||||||
UpdateSysColorMap(StyleObject^.Widget, lgs);
|
UpdateSysColorMap(StyleObject^.Widget, lgs);
|
||||||
Result := StyleObject^.Widget;
|
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
// DebugLn('BUG: GetStyleWithName() created style is not GtkWidget ',WName);
|
// DebugLn('BUG: GetStyleWithName() created style is not GtkWidget ',WName);
|
||||||
@ -1145,15 +1144,13 @@ end;
|
|||||||
|
|
||||||
function GetStyleWidgetWithName(const WName : String) : PGtkWidget;
|
function GetStyleWidgetWithName(const WName : String) : PGtkWidget;
|
||||||
var
|
var
|
||||||
l : Longint;
|
aStyle: PStyleObject;
|
||||||
begin
|
begin
|
||||||
Result := nil;
|
aStyle := GetStyleWithName(WName);
|
||||||
// init style
|
if aStyle<>nil then
|
||||||
GetStyleWithName(WName);
|
Result:=aStyle^.Widget
|
||||||
// return widget
|
else
|
||||||
l := IndexOfStyleWithName(WName);
|
Result:=nil;
|
||||||
if l>=0 then
|
|
||||||
Result := PStyleObject(Styles.Objects[l])^.Widget;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GetStyleWidget(aStyle: TLazGtkStyle) : PGtkWidget;
|
function GetStyleWidget(aStyle: TLazGtkStyle) : PGtkWidget;
|
||||||
|
@ -2972,31 +2972,31 @@ begin
|
|||||||
if (Widget=nil) then
|
if (Widget=nil) then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
|
//debugln(['TGtk3Widget.SetBounds ',DbgSName(LCLObject),' ',ALeft,',',ATop,',',AWidth,'x',AHeight]);
|
||||||
|
|
||||||
|
ARect.x := ALeft;
|
||||||
|
ARect.y := ATop;
|
||||||
|
ARect.width := AWidth;
|
||||||
|
ARect.Height := AHeight;
|
||||||
|
with Alloc do
|
||||||
|
begin
|
||||||
|
x := ALeft;
|
||||||
|
y := ATop;
|
||||||
|
width := AWidth;
|
||||||
|
height := AHeight;
|
||||||
|
end;
|
||||||
|
|
||||||
if Self is TGtk3Button then
|
if Self is TGtk3Button then
|
||||||
begin
|
begin
|
||||||
dec(AWidth,4);
|
AWidth:=Max(1,AWidth-4);
|
||||||
dec(AHeight,4);
|
AHeight:=Max(1,AHeight-4);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
BeginUpdate;
|
BeginUpdate;
|
||||||
try
|
try
|
||||||
{fixes gtk3 assertion}
|
{fixes gtk3 assertion}
|
||||||
Widget^.get_preferred_width(@AMinSize, @ANaturalSize);
|
Widget^.get_preferred_width(@AMinSize, @ANaturalSize);
|
||||||
AWidth:=Max(AWidth,AMinSize);
|
|
||||||
Widget^.get_preferred_height(@AMinSize, @ANaturalSize);
|
Widget^.get_preferred_height(@AMinSize, @ANaturalSize);
|
||||||
AHeight:=Max(AHeight,AMinSize);
|
|
||||||
|
|
||||||
ARect.x := ALeft;
|
|
||||||
ARect.y := ATop;
|
|
||||||
ARect.width := AWidth;
|
|
||||||
ARect.Height := AHeight;
|
|
||||||
with Alloc do
|
|
||||||
begin
|
|
||||||
x := ALeft;
|
|
||||||
y := ATop;
|
|
||||||
width := AWidth;
|
|
||||||
height := AHeight;
|
|
||||||
end;
|
|
||||||
|
|
||||||
Widget^.set_size_request(AWidth,AHeight);
|
Widget^.set_size_request(AWidth,AHeight);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user