mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 05:09:10 +02:00
*(Qt)At least fixed all geometry problems with various TWinControl descendants, now IDE config dialogs look nice.
*(Qt)Various cleanups. git-svn-id: trunk@11649 -
This commit is contained in:
parent
dd7bab87f9
commit
465f37f903
@ -52,8 +52,6 @@ type
|
||||
class procedure PanelUpdate(const AStatusBar: TStatusBar; PanelIndex: integer); override;
|
||||
class procedure SetPanelText(const AStatusBar: TStatusBar; PanelIndex: integer); override;
|
||||
class procedure Update(const AStatusBar: TStatusBar); override;
|
||||
class procedure GetPreferredSize(const AWinControl: TWinControl;
|
||||
var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean); override;
|
||||
end;
|
||||
|
||||
{ TQtWSTabSheet }
|
||||
@ -692,20 +690,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
class procedure TQtWSStatusBar.GetPreferredSize(const AWinControl: TWinControl;
|
||||
var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean);
|
||||
var
|
||||
PrefSize: TSize;
|
||||
begin
|
||||
QWidget_sizeHint(TQtStatusBar(AWinControl.Handle).Widget, @PrefSize);
|
||||
if (PrefSize.cx >= 0)
|
||||
and (PrefSize.cy >=0) then
|
||||
begin
|
||||
PreferredWidth := PrefSize.cx;
|
||||
PreferredHeight := PrefSize.cy;
|
||||
end;
|
||||
end;
|
||||
|
||||
{ TQtWSCustomListView }
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
|
@ -22,7 +22,7 @@
|
||||
}
|
||||
unit QtWSControls;
|
||||
|
||||
{$mode delphi}{$H+}
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
@ -35,7 +35,7 @@ uses
|
||||
{$endif}
|
||||
qtwidgets, qtobjects,
|
||||
// LCL
|
||||
SysUtils, Classes, Controls, LCLType, LCLProc, Forms, Graphics,
|
||||
SysUtils, Classes, Types, Controls, LCLType, LCLProc, Forms, Graphics,
|
||||
StdCtrls,
|
||||
// Widgetset
|
||||
InterfaceBase, WSControls, WSLCLClasses;
|
||||
@ -82,6 +82,9 @@ type
|
||||
class procedure SetCursor(const AWinControl: TWinControl; const ACursor: HCursor); override;
|
||||
class procedure SetFont(const AWinControl: TWinControl; const AFont: TFont); override;
|
||||
|
||||
class procedure GetPreferredSize(const AWinControl: TWinControl;
|
||||
var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean); override;
|
||||
|
||||
// class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override;
|
||||
// class procedure SetText(const AWinControl: TWinControl; const AText: string); override;
|
||||
|
||||
@ -314,6 +317,23 @@ begin
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
class procedure TQtWSWinControl.GetPreferredSize(const AWinControl: TWinControl;
|
||||
var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean);
|
||||
var
|
||||
PrefSize: TSize;
|
||||
begin
|
||||
{$ifdef VerboseQt}
|
||||
WriteLn('> TQtWSWinControl.GetPreferredSSize for ',dbgsname(AWinControl));
|
||||
{$endif}
|
||||
QWidget_sizeHint(TQtCheckBox(AWinControl.Handle).Widget, @PrefSize);
|
||||
if (PrefSize.cx >= 0)
|
||||
and (PrefSize.cy >=0) then
|
||||
begin
|
||||
PreferredWidth := PrefSize.cx;
|
||||
PreferredHeight := PrefSize.cy;
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TQtWSWinControl.SetBounds
|
||||
Params: AWinControl - the calling object
|
||||
@ -419,7 +439,7 @@ begin
|
||||
Color := ColorToRGB(AWinControl.Color);
|
||||
|
||||
// Fill QColor
|
||||
QColor_setRgb(@QColor,Red(Color),Green(Color),Blue(Color));
|
||||
QColor_setRgb(QColorH(@QColor),Red(Color),Green(Color),Blue(Color));
|
||||
|
||||
// Set color of the widget to QColor
|
||||
TQtWidget(AWinControl.Handle).SetColor(@QColor);
|
||||
@ -457,7 +477,7 @@ begin
|
||||
if AFont.Color = CLR_INVALID then exit;
|
||||
|
||||
Color := ColorToRGB(AFont.Color);
|
||||
QColor_setRgb(@QColor,Red(Color),Green(Color),Blue(Color));
|
||||
QColor_setRgb(QColorH(@QColor),Red(Color),Green(Color),Blue(Color));
|
||||
TQtWidget(AWinControl.Handle).SetTextColor(@QColor);
|
||||
end;
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
}
|
||||
unit QtWSExtCtrls;
|
||||
|
||||
{$mode delphi}{$H+}
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
@ -159,7 +159,6 @@ type
|
||||
public
|
||||
class function CreateHandle(const AWinControl: TWinControl;
|
||||
const AParams: TCreateParams): TLCLIntfHandle; override;
|
||||
class procedure ShowHide(const AWinControl: TWinControl); override;
|
||||
end;
|
||||
|
||||
{ TQtWSRadioGroup }
|
||||
@ -178,7 +177,6 @@ type
|
||||
public
|
||||
class function CreateHandle(const AWinControl: TWinControl;
|
||||
const AParams: TCreateParams): TLCLIntfHandle; override;
|
||||
class procedure ShowHide(const AWinControl: TWinControl); override;
|
||||
end;
|
||||
|
||||
{ TQtWSCheckGroup }
|
||||
@ -407,40 +405,6 @@ begin
|
||||
Result := THandle(QtGroupBox);
|
||||
end;
|
||||
|
||||
class procedure TQtWSCustomRadioGroup.ShowHide(const AWinControl: TWinControl);
|
||||
var
|
||||
i: Integer;
|
||||
ATextWidth: Integer;
|
||||
ATextHeight: Integer;
|
||||
FM: QFontMetricsH;
|
||||
Str: WideString;
|
||||
begin
|
||||
inherited ShowHide(AWinControl);
|
||||
{without this we have invisible radio buttons}
|
||||
{only this guarantee that our items are visible anytime ....}
|
||||
for i := 0 to TRadioGroup(AWinControl).ComponentCount - 1 do
|
||||
begin
|
||||
if TRadioButton(AWinControl.Components[i]).Height = 0 then
|
||||
begin
|
||||
FM := QFontMetrics_create(QWidget_font(TQtRadioButton(TRadioButton(AWinControl.Components[i]).Handle).Widget));
|
||||
try
|
||||
Str := UTF8Encode(TRadioButton(AWinControl.Components[i]).Caption);
|
||||
ATextWidth := QFontMetrics_width(FM, @Str, Length(Str));
|
||||
ATextHeight := QFontMetrics_height(FM);
|
||||
finally
|
||||
QFontMetrics_destroy(FM);
|
||||
end;
|
||||
|
||||
{ now, textwidth + default width of checkbox, default height
|
||||
qt doesn't align well control with text size < 100}
|
||||
if ATextWidth < 100 then
|
||||
ATextWidth := 100;
|
||||
|
||||
TRadioButton(AWinControl.Components[i]).SetBounds(0, 0, ATextWidth + ATextHeight + 1, ATextHeight);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
{ TQtWSCustomCheckGroup }
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -466,41 +430,6 @@ begin
|
||||
Result := THandle(QtGroupBox);
|
||||
end;
|
||||
|
||||
class procedure TQtWSCustomCheckGroup.ShowHide(const AWinControl: TWinControl);
|
||||
var
|
||||
i: Integer;
|
||||
ATextWidth: Integer;
|
||||
ATextHeight: Integer;
|
||||
FM: QFontMetricsH;
|
||||
Str: WideString;
|
||||
begin
|
||||
{without this checkboxes are invisible}
|
||||
inherited ShowHide(AWinControl);
|
||||
|
||||
{only this guarantee that our items are visible anytime ....}
|
||||
for i := 0 to TCheckGroup(AWinControl).ComponentCount - 1 do
|
||||
begin
|
||||
if TCheckBox(AWinControl.Components[i]).Height = 0 then
|
||||
begin
|
||||
FM := QFontMetrics_create(QWidget_font(TQtCheckBox(TCheckBox(AWinControl.Components[i]).Handle).Widget));
|
||||
try
|
||||
Str := UTF8Encode(TCheckBox(AWinControl.Components[i]).Caption);
|
||||
ATextWidth := QFontMetrics_width(FM, @Str, Length(Str));
|
||||
ATextHeight := QFontMetrics_height(FM);
|
||||
finally
|
||||
QFontMetrics_destroy(FM);
|
||||
end;
|
||||
|
||||
{ now, textwidth + default width of checkbox, default height
|
||||
qt doesn't align well control with text size < 100}
|
||||
if ATextWidth < 100 then
|
||||
ATextWidth := 100;
|
||||
|
||||
TCheckBox(AWinControl.Components[i]).SetBounds(0, 0, ATextWidth + ATextHeight + 1, ATextHeight);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
|
@ -37,7 +37,7 @@ uses
|
||||
// RTL
|
||||
math,
|
||||
// LCL
|
||||
Classes, StdCtrls, Controls, Graphics, Forms, SysUtils, InterfaceBase, LCLType, LCLIntf, LCLProc,
|
||||
Classes, Types, StdCtrls, Controls, Graphics, Forms, SysUtils, InterfaceBase, LCLType, LCLIntf, LCLProc,
|
||||
// Widgetset
|
||||
WSProc, WSStdCtrls, WSLCLClasses;
|
||||
|
||||
@ -1116,27 +1116,6 @@ begin
|
||||
|
||||
// Focus
|
||||
// QWidget_setFocusPolicy(QtCheckBox.Widget, QtStrongFocus);
|
||||
{we have a bug in LCL when parent is TCustomCheckGroup, it doesn't set sizes for items ?!? Width = 0 , Height = 0}
|
||||
// writeln('WW=',QWidget_width(QtCheckBox.Widget),' WH=',QWidget_height(QtCheckBox.Widget),' WCW=',AWinControl.Width,' WCH=',AWinControl.Height,' CAPTION=',TCustomCheckBox(AWinControl).Caption);
|
||||
|
||||
{we must cheat TCustomCheckGroup here with some reasonable CheckBox size...}
|
||||
if AWinControl.Height = 0 then
|
||||
begin
|
||||
{ we must calculate text size to get real checkbox size in TCustomCheckGroup }
|
||||
FM := QFontMetrics_create(QWidget_font(QtCheckBox.Widget));
|
||||
try
|
||||
Str := UTF8Encode(AWinControl.Caption);
|
||||
ATextWidth := QFontMetrics_width(FM, @Str, Length(Str));
|
||||
finally
|
||||
QFontMetrics_destroy(FM);
|
||||
end;
|
||||
{ now, textwidth + default width of checkbox, default height
|
||||
qt doesn't align well control with text size < 100}
|
||||
if ATextWidth < 100 then
|
||||
ATextWidth := 100;
|
||||
|
||||
AWinControl.SetInitialBounds(0, 0, ATextWidth + 22, 22);
|
||||
end;
|
||||
|
||||
Result := THandle(QtCheckBox);
|
||||
end;
|
||||
@ -1232,24 +1211,6 @@ begin
|
||||
QtRadioButton := TQtRadioButton.Create(AWinControl, AParams);
|
||||
QtRadioButton.AttachEvents;
|
||||
|
||||
{we must cheat TCustomRadioGroup here with some reasonable RadioButton size...}
|
||||
if AWinControl.Height = 0 then
|
||||
begin
|
||||
{ we must calculate text size to get real radiobutton size in TCustomRadioGroup }
|
||||
FM := QFontMetrics_create(QWidget_font(QtRadioButton.Widget));
|
||||
try
|
||||
Str := UTF8Encode(AWinControl.Caption);
|
||||
ATextWidth := QFontMetrics_width(FM, @Str, Length(Str));
|
||||
finally
|
||||
QFontMetrics_destroy(FM);
|
||||
end;
|
||||
{ now, textwidth + default width of radiobutton (including space), default height
|
||||
qt doesn't well align control with textsize < 100 }
|
||||
if ATextWidth < 100 then
|
||||
ATextWidth := 100;
|
||||
AWinControl.SetInitialBounds(0, 0, ATextWidth + 22, 22);
|
||||
end;
|
||||
|
||||
// Focus
|
||||
|
||||
//QWidget_setFocusPolicy(QtRadioButton.Widget, QtStrongFocus);
|
||||
|
Loading…
Reference in New Issue
Block a user