mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-09 06:08:12 +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,
|
||||
// LCL
|
||||
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,
|
||||
LazGdkPixbuf2, gtk3widgets, gtk3objects, gtk3procs, gtk3boxes;
|
||||
|
||||
|
@ -1035,7 +1035,6 @@ end;
|
||||
Updates the constraints object (e.g. TSizeConstraints) with interface specific
|
||||
bounds.
|
||||
------------------------------------------------------------------------------}
|
||||
(*
|
||||
function TGtk3WidgetSet.GetControlConstraints(Constraints: TObject): boolean;
|
||||
var
|
||||
SizeConstraints: TSizeConstraints absolute Constraints;
|
||||
@ -1044,70 +1043,46 @@ var
|
||||
MinHeight: Integer;
|
||||
MaxWidth: Integer;
|
||||
MaxHeight: Integer;
|
||||
aPageControl: TPageControl;
|
||||
begin
|
||||
Result := True;
|
||||
|
||||
if Constraints is TSizeConstraints then
|
||||
begin
|
||||
if (SizeConstraints.Control=nil) then exit;
|
||||
MinWidth := 1;
|
||||
MinHeight := 1;
|
||||
MaxWidth := 0;
|
||||
MaxHeight := 0;
|
||||
|
||||
if (SizeConstraints.Control=nil) then exit;
|
||||
|
||||
if SizeConstraints.Control is TScrollBar then begin
|
||||
// TScrollBar
|
||||
if TScrollBar(SizeConstraints.Control).Kind=sbHorizontal then begin
|
||||
Widget:=GetStyleWidget(lgsHorizontalScrollbar);
|
||||
MinHeight:=Widget^.requisition.Height;
|
||||
MinHeight:=Widget^.get_allocated_height();
|
||||
MaxHeight:=MinHeight;
|
||||
end else begin
|
||||
Widget:=GetStyleWidget(lgsVerticalScrollbar);
|
||||
MinWidth:=Widget^.requisition.Width;
|
||||
MinWidth:=Widget^.get_allocated_width();
|
||||
MaxWidth:=MinWidth;
|
||||
end;
|
||||
//DebugLn('TGtk3WidgetSet.GetControlConstraints A '+dbgs(MinWidth)+','+dbgs(MinHeight),' ',dbgs(TScrollBar(SizeConstraints.Control).Kind=sbHorizontal),' ',TScrollBar(SizeConstraints.Control).Name);
|
||||
end
|
||||
else if SizeConstraints.Control is TCustomSplitter then begin
|
||||
// TCustomSplitter
|
||||
if TCustomSplitter(SizeConstraints.Control).ResizeAnchor in [akTop,akBottom] then
|
||||
begin
|
||||
Widget:=GetStyleWidget(lgsHorizontalPaned);
|
||||
MinHeight:=Widget^.requisition.Height;
|
||||
MaxHeight:=MinHeight;
|
||||
end else if SizeConstraints.Control is TPageControl then begin
|
||||
aPageControl:=TPageControl(SizeConstraints.Control);
|
||||
if aPageControl.TabPosition in [tpTop, tpBottom] then begin
|
||||
MinHeight:=20;
|
||||
end else begin
|
||||
Widget:=GetStyleWidget(lgsVerticalPaned);
|
||||
MinWidth:=Widget^.requisition.Width;
|
||||
MaxWidth:=MinWidth;
|
||||
MinWidth:=20;
|
||||
end;
|
||||
end
|
||||
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]);
|
||||
//DebugLn('TGtk3WidgetSet.GetControlConstraints A '+DbgSName(SizeConstraints.Control),' ',dbgs(MinWidth)+','+dbgs(MinHeight));
|
||||
end;
|
||||
|
||||
//DebugLn('TGtk3WidgetSet.GetControlConstraints A '+DbgSName(SizeConstraints.Control),' ',dbgs(MinWidth)+','+dbgs(MinHeight));
|
||||
|
||||
SizeConstraints.SetInterfaceConstraints(MinWidth,MinHeight,
|
||||
MaxWidth,MaxHeight);
|
||||
end;
|
||||
end;
|
||||
*)
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
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 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 PromptUser(const DialogCaption : string;
|
||||
|
@ -89,7 +89,7 @@ type
|
||||
|
||||
TGtkScrollStyle = record
|
||||
Horizontal,
|
||||
Vertical: TGtkPolicyType;
|
||||
Vertical: TGtkPolicyType;
|
||||
end;
|
||||
|
||||
const
|
||||
@ -1046,7 +1046,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function GetStyleWithName(const WName: String): PGtkWidget;
|
||||
function GetStyleWithName(const WName: String): PStyleObject;
|
||||
var
|
||||
StyleObject : PStyleObject;
|
||||
AIndex: Integer;
|
||||
@ -1058,11 +1058,11 @@ begin
|
||||
AIndex := IndexOfStyleWithName(WName);
|
||||
if AIndex >= 0 then
|
||||
begin
|
||||
StyleObject := PStyleObject(Styles.Objects[AIndex]);
|
||||
Result := StyleObject^.Widget;
|
||||
Result := PStyleObject(Styles.Objects[AIndex]);
|
||||
end else
|
||||
begin
|
||||
StyleObject := NewStyleObject;
|
||||
Result:=StyleObject;
|
||||
lgs := lgsUserDefined;
|
||||
DebugLn('GetStyleWithName creating style widget ',WName);
|
||||
WidgetName := 'LazStyle' + WName;
|
||||
@ -1135,7 +1135,6 @@ begin
|
||||
|
||||
//TODO: copy stuff from gtk2proc
|
||||
UpdateSysColorMap(StyleObject^.Widget, lgs);
|
||||
Result := StyleObject^.Widget;
|
||||
end else
|
||||
begin
|
||||
// DebugLn('BUG: GetStyleWithName() created style is not GtkWidget ',WName);
|
||||
@ -1145,15 +1144,13 @@ end;
|
||||
|
||||
function GetStyleWidgetWithName(const WName : String) : PGtkWidget;
|
||||
var
|
||||
l : Longint;
|
||||
aStyle: PStyleObject;
|
||||
begin
|
||||
Result := nil;
|
||||
// init style
|
||||
GetStyleWithName(WName);
|
||||
// return widget
|
||||
l := IndexOfStyleWithName(WName);
|
||||
if l>=0 then
|
||||
Result := PStyleObject(Styles.Objects[l])^.Widget;
|
||||
aStyle := GetStyleWithName(WName);
|
||||
if aStyle<>nil then
|
||||
Result:=aStyle^.Widget
|
||||
else
|
||||
Result:=nil;
|
||||
end;
|
||||
|
||||
function GetStyleWidget(aStyle: TLazGtkStyle) : PGtkWidget;
|
||||
|
@ -2972,31 +2972,31 @@ begin
|
||||
if (Widget=nil) then
|
||||
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
|
||||
begin
|
||||
dec(AWidth,4);
|
||||
dec(AHeight,4);
|
||||
AWidth:=Max(1,AWidth-4);
|
||||
AHeight:=Max(1,AHeight-4);
|
||||
end;
|
||||
|
||||
BeginUpdate;
|
||||
try
|
||||
{fixes gtk3 assertion}
|
||||
Widget^.get_preferred_width(@AMinSize, @ANaturalSize);
|
||||
AWidth:=Max(AWidth,AMinSize);
|
||||
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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user