Merged revision(s) 54872 #f9266d01ea,54874 #dbe072e701,54875 #b8d6c0d8dc,54877 #cd4add856f,54878 #5377b0e786,54881 #c5cf593797,54812 #e3f7770451,54813 #ede8a86d9d,54815 #118cfb3d98,54816 #43e271b439,54817 #76e4dccfaa,54840 #553d56948a,54841 #5fc40612bc,54842 #2abbee1637,54843 #dcdcafb794,54844 #92cf9781fa,54882 #3ba0ca06c3,54883 #bff91a4961 from trunk:

- r54872 #f9266d01ea lhelp: Fix lhelp to show popup hints. Issue #31732.
- r54874 #dbe072e701 Menu designer: Call GlobalDesignHook.Modified after adding an item. Issue #31791.
- r54875 #b8d6c0d8dc gridexamples: in title_image_demo show images at start, adapt height of header row to image layout) (http://forum.lazarus.freepascal.org/index.php/topic,36841.0.html)
- r54877 #cd4add856f Examples: Minor improvements of sample project motiongraphics (http://forum.lazarus.freepascal.org/index.php/topic,36858.msg245986.html)
- r54878 #5377b0e786 Examples: Improved usability of demo "openurltest".
- r54881 #c5cf593797 Examples: Fix crash of demo "propstorage" (http://forum.lazarus.freepascal.org/index.php/topic,36862.msg246019/topicseen.html).
- r54812 #e3f7770451 lcl: grids: disable VisualChange and UpdateSizes if AutoSize is disabled. Solves part of Issue #31715
- r54813 #ede8a86d9d lcl: support for DebugDisableAutoSizing compiler define
- r54815 #118cfb3d98 lcl: wincontrol: ignore FBoundsRealized in WM_SIZE. Solves part of Issue #31715
- r54816 #43e271b439 lcl: grids: Hi-DPI: row heights and column width. New default (system) value is -1. Solves part of Issue #31715
- r54817 #76e4dccfaa lcl: grids: ignore WMSIZE when updating scrollbars. Solves part of Issue #31715
- r54840 lcl: grids: fix scrolling after r54816 #43e271b439, Issue #31715
- r54841 #5fc40612bc lcl: grids: scroll to highest possible value if col/row are out of valid bounds. Related to Issue #31766
- r54842 lcl: dbgrids: adapt after r54816 #43e271b439. Issue #31765 and #31715
- r54843 ide: packager: adapt after r54816 #43e271b439. Issue #31762 and #31715
- r54844 #92cf9781fa lcl: grids: make GetDefaultRowHeight and *ColWidth public. Issue #31762 and #31715
- r54882 #3ba0ca06c3 lcl: grids: make default value for DefRowHeight and DefColWidth 0 and not -1 (due to LCL consistency). Issue #31715
- r54883 #bff91a4961 lcl: grids: rename GetRealDefaultColWidth and GetRealDefaultRowHeight to GetRealDef* (LCL consistency). Issue #31715

git-svn-id: branches/fixes_1_8@54884 -
This commit is contained in:
ondrej 2017-05-12 20:01:43 +00:00
parent 755f441541
commit aee454aa3c
25 changed files with 261 additions and 142 deletions

View File

@ -640,8 +640,32 @@ begin
end;
procedure TChmContentProvider.IpHtmlPanelHotClick(Sender: TObject);
var
HelpFile: String;
aPos: integer;
lcURL: String;
begin
OpenURL(fHtml.HotURL);
// chm-links look like: mk:@MSITStore:D:\LazPortable\docs\chm\iPro.chm::/html/lh3zs3.htm
lcURL := Lowercase(fHtml.HotURL);
if (Pos('javascript:helppopup(''', lcURL) = 1) or
(Pos('javascript:popuplink(''', lcURL) = 1)
then begin
HelpFile := Copy(fHtml.HotURL, 23, Length(fHtml.HotURL) - (23-1));
HelpFile := Copy(HelpFile, 1, Pos('''', HelpFile)-1);
if (Pos('/',HelpFile)=0) and (Pos('.chm:',HelpFile)=0) then begin //looks like?: 'xyz.htm'
aPos := LastDelimiter('/', fHtml.CurURL);
if aPos>0 then HelpFile := Copy(fHtml.CurURL,1,aPos) + HelpFile;
end
else if (Pos('.chm:',HelpFile)=0) then begin //looks like?: 'folder/xyz.htm' or '/folder/xyz.htm'
if HelpFile[1]<>'/' then HelpFile:='/'+HelpFile;
aPos := LastDelimiter(':', fHtml.CurURL);
if aPos>0 then HelpFile := Copy(fHtml.CurURL,1,aPos) + HelpFile;
end;
DoLoadUri(HelpFile); //open it in current iphtmlpanel.
end
else
OpenURL(fHtml.HotURL);
end;
procedure TChmContentProvider.PopupCopyClick(Sender: TObject);

View File

@ -154,21 +154,22 @@ end;
function TIpChmDataProvider.CanHandle(const URL: string): Boolean;
var
HelpFile: String;
Reader: TChmReader = nil;
begin
Result := True;
if Pos('Java', URL) =1 then Result := False;
if (fChm.ObjectExists(StripInPageLink(url), Reader)= 0)
and (fChm.ObjectExists(StripInPageLink(BuildUrl(fCurrentPath,Url)), Reader) = 0) then Result := False;
if Pos('Java', URL) = 1 then
Result := False;
if (fChm.ObjectExists(StripInPageLink(url), Reader)= 0) and
(fChm.ObjectExists(StripInPageLink(BuildUrl(fCurrentPath,Url)), Reader) = 0)
then
Result := False;
//DebugLn('CanHandle ',Url,' = ', Result);
//if not Result then if fChm.ObjectExists(BuildURL('', URL)) > 0 Then result := true;
if Pos('javascript:helppopup(''', LowerCase(URL)) = 1 then begin
HelpFile := Copy(URL, 23, Length(URL) - (23-1));
HelpFile := Copy(HelpFile, 1, Pos('''', HelpFile)-1);
//DebugLn('HelpFile = ', HelpFile);
end;
if (not Result) and (Pos('#', URL) = 1) then Result := True;
if (not Result) and (Pos('#', URL) = 1) then
Result := True;
end;
function TIpChmDataProvider.BuildURL(const OldURL, NewURL: string): string;

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<Version Value="10"/>
<PathDelim Value="\"/>
<General>
<Flags>

View File

@ -1966,13 +1966,14 @@ begin
newMI.Name:=FShadowMenu.FEditorDesigner.CreateUniqueComponentName(newMI.ClassName);
if isSeparator then
newMI.Caption:=cLineCaption
else newMI.Caption:=newMI.Name;
else
newMI.Caption:=newMI.Name;
existingSI.RealItem.Parent.Insert(idx, newMI);
TShadowItem.CreateWithBoxAndItem(FShadowMenu, existingSI.ParentBox, newMI);
FShadowMenu.UpdateBoxLocationsAndSizes;
FShadowMenu.FDesigner.FGui.AddingItem := True;
GlobalDesignHook.PersistentAdded(newMI, not isSeparator);
//GlobalDesignHook.Modified(newMI);
GlobalDesignHook.Modified(newMI);
FShadowMenu.FDesigner.FGui.AddingItem := False;
FShadowMenu.SetSelectedMenuItem(newMI, False, False);
if not isSeparator then

View File

@ -3,16 +3,18 @@ object Form1: TForm1
Height = 278
Top = 206
Width = 425
HorzScrollBar.Page = 235
HorzScrollBar.Page = 205
VertScrollBar.Page = 92
AutoScroll = True
Caption = 'Form1'
ClientHeight = 278
ClientWidth = 425
LCLVersion = '1.5'
ShowHint = True
LCLVersion = '1.9.0.0'
object StringGrid1: TStringGrid
Left = 0
Height = 236
Hint = 'Title images are used here as indicators for sorting direction.'#13#10'Click on a column header to toggle the sorting direction and its title image.'
Top = 42
Width = 425
Align = alClient
@ -20,19 +22,35 @@ object Form1: TForm1
Columns = <
item
Title.Alignment = taCenter
Title.ImageIndex = 0
Title.ImageLayout = blGlyphLeft
Title.Caption = 'Fruit'
Width = 100
end
item
Alignment = taRightJustify
Title.Alignment = taCenter
Title.ImageIndex = 0
Title.ImageLayout = blGlyphLeft
Title.Caption = 'Number'
Width = 102
end>
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goRowSizing, goColSizing, goSmoothScroll]
TabOrder = 0
TitleImageList = ImageList1
OnHeaderClick = StringGrid1HeaderClick
ColWidths = (
64
100
102
)
RowHeights = (
22
22
22
22
22
)
Cells = (
8
1
@ -77,7 +95,7 @@ object Form1: TForm1
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 4
ClientHeight = 21
ClientHeight = 22
ClientWidth = 421
Columns = 4
ItemIndex = 0

View File

@ -19,6 +19,7 @@ type
procedure StringGrid1HeaderClick(
Sender: TObject; IsColumn: Boolean;Index: Integer);
private
procedure AdjustTitleHeight;
procedure Refresh;
public
@ -36,6 +37,14 @@ uses
{ TForm1 }
procedure TForm1.AdjustTitleHeight;
begin
if RadioGroup1.ItemIndex < 2 then
StringGrid1.RowHeights[0] := StringGrid1.DefaultRowHeight
else
StringGrid1.RowHeights[0] := StringGrid1.RowHeights[1] + ImageList1.Height;
end;
procedure TForm1.RadioGroup1Click(Sender: TObject);
var
i: Integer;
@ -48,6 +57,7 @@ begin
StringGrid1.Columns[i].Title.ImageLayout :=
TButtonLayout(RadioGroup1.ItemIndex);
end;
AdjustTitleHeight;
end;
procedure TForm1.Refresh;
@ -82,6 +92,7 @@ begin
if ImageIndex > 0 then
StringGrid1.Columns[2 - Index].Title.ImageIndex := 0;
end;
AdjustTitleHeight;
Refresh;
end;

View File

@ -9,6 +9,7 @@
</Flags>
<MainUnit Value="0"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
<Icon Value="0"/>
<ActiveWindowIndexAtStart Value="0"/>
</General>
@ -227,8 +228,13 @@
</Parsing>
<Linking>
<Debugging>
<UseHeaptrc Value="True"/>
<UseExternalDbgSyms Value="True"/>
</Debugging>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>
<CompilerPath Value="$(CompPath)"/>

View File

@ -7,12 +7,12 @@ object Form1: TForm1
ClientHeight = 240
ClientWidth = 320
OnPaint = FormPaint
LCLVersion = '0.9.31'
LCLVersion = '1.9.0.0'
object Label1: TLabel
Left = 6
Height = 18
Height = 15
Top = 6
Width = 46
Width = 35
Caption = 'Speed:'
ParentColor = False
end

View File

@ -33,6 +33,9 @@ implementation
{$R *.lfm}
uses
Math;
{ TForm1 }
procedure TForm1.timerRedrawTimer(Sender: TObject);
@ -68,23 +71,25 @@ end;
function TForm1.RotatePoint(APoint, ACenter: TPoint; AAngle: Double): TPoint;
var
dx, dy: Double;
sinAngle, cosAngle: Double;
begin
dx := (ACenter.Y * Sin(AAngle)) - (ACenter.X * Cos(AAngle)) + ACenter.X;
dy := -(ACenter.X * Sin(AAngle)) - (ACenter.Y * Cos(AAngle)) + ACenter.Y;
Result.X := Round((APoint.X * Cos(AAngle)) - (APoint.Y * Sin(AAngle)) + dx);
Result.Y := Round((APoint.X * Sin(AAngle)) + (APoint.Y * Cos(AAngle)) + dy);
SinCos(AAngle, sinAngle, cosAngle);
dx := ACenter.Y * sinAngle - ACenter.X * cosAngle + ACenter.X + 10;
dy := -ACenter.X * sinAngle - ACenter.Y * cosAngle + ACenter.Y + Height div 4;
Result.X := Round(APoint.X * cosAngle - APoint.Y * sinAngle + dx);
Result.Y := Round(APoint.X * sinAngle + APoint.Y * cosAngle + dy);
end;
procedure TForm1.FormPaint(Sender: TObject);
var
lPoints: array[0..2] of TPoint;
begin
lPoints[0].X := 100;
lPoints[0].Y := 100;
lPoints[1].X := 200;
lPoints[0].X := Self.Width div 4;
lPoints[0].Y := Self.Height div 4;
lPoints[1].X := Self.Width div 2;
lPoints[1].Y := 0;
lPoints[2].X := 200;
lPoints[2].Y := 200;
lPoints[2].X := Self.Width div 2;
lPoints[2].Y := Self.Height div 2;
RotatePolygon(lPoints, CurStep);
Canvas.Polygon(lPoints);
end;

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<Version Value="10"/>
<General>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
@ -12,9 +12,6 @@
<i18n>
<EnableI18N LFM="False"/>
</i18n>
<VersionInfo>
<StringTable ProductVersion=""/>
</VersionInfo>
<BuildModes Count="1">
<Item1 Name="Default" Default="True"/>
</BuildModes>
@ -37,14 +34,13 @@
<Unit0>
<Filename Value="motiongraphics.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="motiongraphics"/>
</Unit0>
<Unit1>
<Filename Value="mainform.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="Form1"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="mainform"/>
</Unit1>
</Units>
</ProjectOptions>
@ -64,12 +60,6 @@
</Win32>
</Options>
</Linking>
<Other>
<CompilerMessages>
<UseMsgFile Value="True"/>
</CompilerMessages>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">

View File

@ -1,12 +1,12 @@
object Form1: TForm1
Left = 257
Height = 248
Height = 254
Top = 177
Width = 320
Caption = 'Form1'
ClientHeight = 248
ClientHeight = 254
ClientWidth = 320
LCLVersion = '1.1'
LCLVersion = '1.9.0.0'
object btnOpenURLHTTP: TButton
Left = 64
Height = 25
@ -18,21 +18,21 @@ object Form1: TForm1
end
object editFileName: TFileNameEdit
Left = 8
Height = 21
Height = 23
Top = 32
Width = 280
FilterIndex = 0
HideDirectories = False
ButtonWidth = 23
NumGlyphs = 0
NumGlyphs = 1
MaxLength = 0
TabOrder = 1
end
object Label1: TLabel
Left = 8
Height = 14
Height = 15
Top = 9
Width = 216
Width = 234
Caption = 'Please indicate a filename or URL for testing:'
ParentColor = False
end
@ -65,7 +65,7 @@ object Form1: TForm1
end
object Label2: TLabel
Left = 9
Height = 14
Height = 15
Top = 58
Width = 35
Caption = 'Result:'
@ -73,7 +73,7 @@ object Form1: TForm1
end
object editResult: TEdit
Left = 9
Height = 21
Height = 23
Top = 80
Width = 279
TabOrder = 5

View File

@ -39,16 +39,6 @@ implementation
{ TForm1 }
procedure TForm1.btnOpenURLHTTPClick(Sender: TObject);
begin
editResult.Text := BoolToStr(OpenURL('www.google.com'));
end;
procedure TForm1.btnOpenDocumentClick(Sender: TObject);
begin
editResult.Text := BoolToStr(OpenDocument(editFilename.Text));
end;
procedure TForm1.btnFindBrowserClick(Sender: TObject);
var
lStr, lParams: String;
@ -57,9 +47,25 @@ begin
editResult.Text := lStr + ' ' + lParams;
end;
procedure TForm1.btnOpenURLHTTPClick(Sender: TObject);
begin
if editFileName.Text = '' then
editFileName.Text := 'www.google.com';
editResult.Text := BoolToStr(OpenURL(editFileName.Text), true);
end;
procedure TForm1.btnOpenDocumentClick(Sender: TObject);
begin
if editFileName.Text = '' then
editFileName.Text := 'mainform.pas';
editResult.Text := BoolToStr(OpenDocument(editFilename.Text), true);
end;
procedure TForm1.btnOpenURLFILEClick(Sender: TObject);
begin
editResult.Text := BoolToStr(OpenURL('file://'+editFilename.Text));
if editFileName.Text = '' then
editFileName.Text := ExpandFileName('./mainform.pas');
editResult.Text := BoolToStr(OpenURL('file://'+editFilename.Text), true);
end;
end.

View File

@ -58,7 +58,7 @@
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Options>

View File

@ -61,7 +61,7 @@
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<CodeGeneration>
<Optimizations>

View File

@ -6,8 +6,9 @@ object Form1: TForm1
Caption = 'Form1'
ClientHeight = 359
ClientWidth = 531
SessionProperties = 'Memo1.Lines'
LCLVersion = '1.3'
OnCreate = FormCreate
SessionProperties = 'Memo1.Lines;Width;Height'
LCLVersion = '1.9.0.0'
object Memo1: TMemo
Left = 8
Height = 162
@ -16,17 +17,15 @@ object Form1: TForm1
TabOrder = 0
end
object XMLPropStorage1: TXMLPropStorage
StoredValues = <
item
end>
StoredValues = <>
FileName = 'config.xml'
left = 24
left = 64
top = 200
end
object IniPropStorage1: TIniPropStorage
StoredValues = <>
IniFileName = 'config.ini'
left = 137
left = 200
top = 200
end
end

View File

@ -5,7 +5,7 @@ unit Unit1;
interface
uses
Forms, StdCtrls, XMLPropStorage, IniPropStorage;
Forms, StdCtrls, XMLPropStorage, IniPropStorage, Classes;
type
@ -15,6 +15,7 @@ type
IniPropStorage1: TIniPropStorage;
Memo1: TMemo;
XMLPropStorage1: TXMLPropStorage;
procedure FormCreate(Sender: TObject);
private
public
@ -28,6 +29,15 @@ implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
Memo1.Lines.Add('Enter some text here.');
Memo1.Lines.Add('At exit, it will be stored by TIniPropStorage and TXmlPropStorage');
Memo1.Lines.Add('along with the form''s width and height.');
end;
initialization

View File

@ -1447,13 +1447,13 @@ end;
function TCustomDBGrid.DefaultFieldColWidth(F: TField): Integer;
begin
if not HandleAllocated or (F=nil) then
result:=DefaultColWidth
result:=GetRealDefColWidth
else begin
if F.DisplayWidth = 0 then
if Canvas.HandleAllocated then
result := Canvas.TextWidth( F.DisplayName ) + 3
else
Result := DefaultColWidth
Result := GetRealDefColWidth
else
result := F.DisplayWidth * CalcCanvasCharWidth(Canvas);
end;
@ -1610,7 +1610,7 @@ begin
{$ifdef dbgDBGrid}
DebugLn('%s.GetBufferCount', [ClassName]);
{$endif}
Result := ClientHeight div DefaultRowHeight;
Result := ClientHeight div GetRealDefRowHeight;
if dgTitles in Options then
Dec(Result, 1);
end;
@ -4249,7 +4249,7 @@ begin
FreeWorkingCanvas(tmpCanvas);
end else
result := DEFCOLWIDTH;
result := -1;
end;
function TColumn.CreateTitle: TGridColumnTitle;

View File

@ -72,7 +72,6 @@ const
const
DEFCOLWIDTH = 64;
DEFROWHEIGHT = 20;
DEFBUTTONWIDTH = 25;
DEFIMAGEPADDING = 2;
DEFAUTOADJPADDING = 8;
@ -154,9 +153,9 @@ type
TTitleStyle = (tsLazarus, tsStandard, tsNative);
TGridFlagsOption = (gfEditorUpdateLock, gfNeedsSelectActive, gfEditorTab,
gfRevEditorTab, gfVisualChange, gfDefRowHeightChanged, gfColumnsLocked,
gfRevEditorTab, gfVisualChange, gfColumnsLocked,
gfEditingDone, gfSizingStarted, gfPainting, gfUpdatingSize, gfClientRectChange,
gfAutoEditPending);
gfAutoEditPending, gfUpdatingScrollbar);
TGridFlags = set of TGridFlagsOption;
TSortOrder = (soAscending, soDescending);
@ -587,11 +586,11 @@ type
property MaxSize: Integer read GetMaxSize write SetMaxSize stored isMaxSizeStored;
property PickList: TStrings read GetPickList write SetPickList;
property ReadOnly: Boolean read GetReadOnly write SetReadOnly stored IsReadOnlyStored;
property SizePriority: Integer read GetSizePriority write SetSizePriority stored IsSizePriorityStored default 1;
property SizePriority: Integer read GetSizePriority write SetSizePriority stored IsSizePriorityStored;
property Tag: PtrInt read FTag write FTag default 0;
property Title: TGridColumnTitle read FTitle write SetTitle;
property Width: Integer read GetWidth write SetWidth stored IsWidthStored default DEFCOLWIDTH;
property Visible: Boolean read GetVisible write SetVisible stored IsVisibleStored default true;
property Width: Integer read GetWidth write SetWidth stored IsWidthStored;
property Visible: Boolean read GetVisible write SetVisible stored IsVisibleStored;
property ValueChecked: string read GetValueChecked write SetValueChecked
stored IsValueCheckedStored;
property ValueUnchecked: string read GetValueUnchecked write SetValueUnchecked
@ -726,6 +725,7 @@ type
FGridLineStyle: TPenStyle;
FGridLineWidth: Integer;
FDefColWidth, FDefRowHeight: Integer;
FRealizedDefColWidth, FRealizedDefRowHeight: Integer;
FCol,FRow, FFixedCols, FFixedRows: Integer;
FOnEditButtonClick: TNotifyEvent;
FOnButtonClick: TOnSelectEvent;
@ -795,7 +795,6 @@ type
procedure SetQuickColRow(AValue: TPoint);
function IsCellButtonColumn(ACell: TPoint): boolean;
function GetSelectedColumn: TGridColumn;
function IsDefRowHeightStored: boolean;
function IsTitleImageListStored: boolean;
procedure SetAlternateColor(const AValue: TColor);
procedure SetAutoFillColumns(const AValue: boolean);
@ -1121,6 +1120,7 @@ type
procedure UpdateBorderStyle;
function ValidateEntry(const ACol,ARow:Integer; const OldValue:string; var NewValue:string): boolean; virtual;
procedure VisualChange; virtual;
procedure WMSize(var Message: TLMSize); message LM_SIZE;
procedure WMHScroll(var message : TLMHScroll); message LM_HSCROLL;
procedure WMVScroll(var message : TLMVScroll); message LM_VSCROLL;
procedure WMKillFocus(var message: TLMKillFocus); message LM_KILLFOCUS;
@ -1141,8 +1141,8 @@ type
property ColumnClickSorts: boolean read FColumnClickSorts write SetColumnClickSorts default false;
property Columns: TGridColumns read GetColumns write SetColumns stored IsColumnsStored;
property ColWidths[aCol: Integer]: Integer read GetColWidths write SetColWidths;
property DefaultColWidth: Integer read FDefColWidth write SetDefColWidth default DEFCOLWIDTH;
property DefaultRowHeight: Integer read FDefRowHeight write SetDefRowHeight stored IsDefRowHeightStored;
property DefaultColWidth: Integer read FDefColWidth write SetDefColWidth default 0;
property DefaultRowHeight: Integer read FDefRowHeight write SetDefRowHeight default 0;
property DefaultDrawing: Boolean read FDefaultDrawing write SetDefaultDrawing default True;
property DefaultTextStyle: TTextStyle read FDefaultTextStyle write FDefaultTextStyle;
property DragDx: Integer read FDragDx write FDragDx;
@ -1245,6 +1245,8 @@ type
procedure EndUpdate(aRefresh: boolean = true);
procedure EraseBackground(DC: HDC); override;
function Focused: Boolean; override;
function GetRealDefColWidth: integer;
function GetRealDefRowHeight: integer;
function HasMultiSelection: Boolean;
procedure InvalidateCell(aCol, aRow: Integer); overload;
procedure InvalidateCol(ACol: Integer);
@ -2072,7 +2074,7 @@ begin
Result:=integer(PtrUInt(FRows[aRow]))
else
Result:=-1;
if Result<0 then Result:=fDefRowHeight;
if Result<0 then Result:=GetRealDefRowHeight;
end;
function TCustomGrid.GetTopRow: Longint;
@ -2268,14 +2270,14 @@ begin
NewSize := AValue;
if NewSize<0 then begin
AValue:=-1;
NewSize := FDefColWidth;
NewSize := GetRealDefColWidth;
end;
OldSize := integer(PtrUInt(FCols[ACol]));
if NewSize<>OldSize then begin
if OldSize<0 then
OldSize := fDefColWidth;
OldSize := GetRealDefColWidth;
Bigger := NewSize>OldSize;
SetRawColWidths(ACol, AValue);
@ -2478,20 +2480,22 @@ function TCustomGrid.GetColWidths(Acol: Integer): Integer;
var
C: TGridColumn;
begin
if not Columns.Enabled or (aCol<FixedCols) then begin
if not Columns.Enabled or (aCol<FixedCols) then
begin
if (aCol<ColCount) and (aCol>=0) then
Result:=integer(PtrUInt(FCols[aCol]))
else
Result:=-1;
if result<0 then
Result:=fDefColWidth;
end else begin
end else
begin
C := ColumnFromGridColumn(Acol);
if C<>nil then
Result := C.Width
Result:=C.Width
else
result := FDefColWidth;
Result:=-1;
end;
if Result<0 then
Result:=GetRealDefColWidth;
end;
procedure TCustomGrid.SetEditor(AValue: TWinControl);
@ -2748,14 +2752,14 @@ begin
NewSize := AValue;
if NewSize<0 then begin
AValue:=-1;
NewSize := FDefRowHeight;
NewSize := GetRealDefRowHeight;
end;
OldSize := integer(PtrUInt(FRows[ARow]));
if AValue<>OldSize then begin
if OldSize<0 then
OldSize := FDefRowHeight;
OldSize := GetRealDefRowHeight;
bigger := NewSize > OldSize;
@ -2916,8 +2920,6 @@ begin
Target.FixedCols := FixedCols;
Target.FixedRows := FixedRows;
Target.DefaultRowHeight := DefaultRowHeight;
if not IsDefRowHeightStored then
Target.GridFlags := Target.GridFlags - [gfDefRowHeightChanged];
Target.DefaultColWidth := DefaultColWidth;
if not Columns.Enabled then
Target.FCols.Assign(FCols);
@ -3010,8 +3012,8 @@ var
i: Integer;
OldTop,OldBottom,NewTop,NewBottom: Integer;
begin
if (AValue<>fDefRowHeight) or (csLoading in ComponentState) then begin
include(FGridFlags, gfDefRowHeightChanged);
if (AValue<>fDefRowHeight) or (csLoading in ComponentState) then
begin
FDefRowheight:=AValue;
if EditorMode then
@ -3021,12 +3023,12 @@ begin
FRows[i] := Pointer(-1);
VisualChange;
if EditorMode then begin
if EditorMode then
begin
ColRowToOffSet(False,True, FRow, NewTop, NewBottom);
if (NewTop<>OldTOp) or (NewBottom<>OldBottom) then
EditorPos;
end;
end;
end;
@ -3300,7 +3302,12 @@ begin
{$Ifdef DbgScroll}
DebugLn('ScrollbarShow: Which=',SbToStr(Which), ' Avalue=',dbgs(AValue));
{$endif}
ShowScrollBar(Handle,Which,aValue);
Include(FGridFlags, gfUpdatingScrollbar);
try
ShowScrollBar(Handle,Which,aValue);
finally
Exclude(FGridFlags, gfUpdatingScrollbar);
end;
if Which in [SB_BOTH, SB_VERT] then FVSbVisible := Ord(AValue);
if Which in [SB_BOTH, SB_HORZ] then FHSbVisible := Ord(AValue);
end;
@ -4536,8 +4543,8 @@ begin
end;
SB_PAGELEFT: TrySmoothScrollBy(-(ClientWidth-FGCache.FixedWidth)*RTLSign, 0);
SB_PAGERIGHT: TrySmoothScrollBy((ClientWidth-FGCache.FixedWidth)*RTLSign, 0);
SB_LINELEFT: TrySmoothScrollBy(-DefaultColWidth*RTLSign, 0);
SB_LINERIGHT: TrySmoothScrollBy(DefaultColWidth*RTLSign, 0);
SB_LINELEFT: TrySmoothScrollBy(-GetRealDefColWidth*RTLSign, 0);
SB_LINERIGHT: TrySmoothScrollBy(GetRealDefColWidth*RTLSign, 0);
end;
if EditorMode then
@ -4559,8 +4566,8 @@ begin
end;
SB_PAGEUP: TrySmoothScrollBy(0, -(ClientHeight-FGCache.FixedHeight));
SB_PAGEDOWN: TrySmoothScrollBy(0, ClientHeight-FGCache.FixedHeight);
SB_LINEUP: TrySmoothScrollBy(0, -DefaultRowHeight);
SB_LINEDOWN: TrySmoothScrollBy(0, DefaultRowHeight);
SB_LINEUP: TrySmoothScrollBy(0, -GetRealDefRowHeight);
SB_LINEDOWN: TrySmoothScrollBy(0, GetRealDefRowHeight);
end;
if EditorMode then
@ -4604,6 +4611,13 @@ begin
InvalidateFocused;
end;
procedure TCustomGrid.WMSize(var Message: TLMSize);
begin
if gfUpdatingScrollbar in FGridFlags then // ignore WMSize when updating scrollbars. issue #31715
Exit;
inherited WMSize(Message);
end;
class procedure TCustomGrid.WSRegisterClass;
begin
inherited WSRegisterClass;
@ -4669,6 +4683,7 @@ begin
TryTL:=ScrollGrid(False,aCol, aRow);
TLChange := not PointIgual(TryTL, FTopLeft);
if TLChange
or (not PointIgual(TryTL, Point(aCol, aRow)) and (goSmoothScroll in Options))
or (ClearColOff and (FGCache.TLColOff<>0))
or (ClearRowOff and (FGCache.TLRowOff<>0)) then
begin
@ -4679,6 +4694,10 @@ begin
FGCache.TLColOff := 0;
if ClearRowOff then
FGCache.TLRowOff := 0;
if (aCol>TryTL.X) and (goSmoothScroll in Options) then
FGCache.TLColOff := FGCache.MaxTLOffset.X;
if (aRow>TryTL.Y) and (goSmoothScroll in Options) then
FGCache.TLRowOff := FGCache.MaxTLOffset.Y;
{$ifdef dbgscroll}
DebugLn('TryScrollTo: TopLeft=%s NewCol=%d NewRow=%d',
[dbgs(FTopLeft), NewCol, NewRow]);
@ -4958,7 +4977,11 @@ end;
procedure TCustomGrid.UpdateSizes;
begin
if (FUpdateCount<>0) or (not HandleAllocated) then
exit;
Include(FGridFlags, gfVisualChange);
UpdateCachedSizes;
CacheVisibleGrid;
CalcScrollbarsRange;
@ -5139,16 +5162,33 @@ begin
end;
end;
function TCustomGrid.GetRealDefColWidth: integer;
begin
if FDefColWidth = 0 then
begin
if FRealizedDefColWidth = 0 then
FRealizedDefColWidth := MulDiv(DEFCOLWIDTH, Font.PixelsPerInch, 96);
Result := FRealizedDefColWidth;
end else
Result := FDefColWidth;
end;
function TCustomGrid.GetRealDefRowHeight: integer;
begin
if FDefRowHeight = 0 then
begin
if FRealizedDefRowHeight = 0 then
FRealizedDefRowHeight := GetDefaultRowHeight;
Result := FRealizedDefRowHeight;
end else
Result := FDefRowHeight;
end;
function TCustomGrid.GetSelectedColumn: TGridColumn;
begin
Result := ColumnFromGridColumn(Col);
end;
function TCustomGrid.IsDefRowHeightStored: boolean;
begin
result := (gfDefRowHeightChanged in GridFlags);
end;
function TCustomGrid.IsAltColorStored: boolean;
begin
result := FAlternateColor <> Color;
@ -6784,15 +6824,20 @@ begin
C := Columns.Items[i];
C.MaxSize := Round(C.MaxSize * AXProportion);
C.MinSize := Round(C.MinSize * AXProportion);
C.Width := Round(C.Width * AXProportion);
if C.IsWidthStored then
C.Width := Round(C.Width * AXProportion);
end;
for i := RowCount - 1 downto 0 do
RowHeights[i] := Round(RowHeights[i] * AYProportion);
for i := FRows.Count - 1 downto 0 do
FRows[i] := Pointer(Round(PtrInt(FRows[i]) * AYProportion));
for i := FCols.Count - 1 downto 0 do
FCols[i] := Pointer(Round(PtrInt(FCols[i]) * AXProportion));
FDefColWidth := Round(FDefColWidth * AXProportion);
FDefRowHeight := Round(FDefRowHeight * AYProportion);
Include(FGridFlags, gfDefRowHeightChanged);
FRealizedDefRowHeight := 0;
FRealizedDefColWidth := 0;
finally
EndUpdate;
end;
@ -7987,6 +8032,8 @@ end;
procedure TCustomGrid.FontChanged(Sender: TObject);
begin
FRealizedDefRowHeight := 0;
FRealizedDefColWidth := 0;
if csCustomPaint in ControlState then
Canvas.Font := Font
else begin
@ -8721,7 +8768,7 @@ end;
function TCustomGrid.GetDefaultColumnWidth(Column: Integer): Integer;
begin
result := FDefColWidth;
Result := FDefColWidth;
end;
function TCustomGrid.GetDefaultColumnLayout(Column: Integer): TTextLayout;
@ -8873,7 +8920,6 @@ begin
Cfg.SetValue('grid/design/fixedcols', FixedCols);
Cfg.SetValue('grid/design/fixedrows', Fixedrows);
Cfg.SetValue('grid/design/defaultcolwidth', DefaultColWidth);
Cfg.SetValue('grid/design/isdefaultrowheight', ord(IsDefRowHeightStored));
Cfg.SetValue('grid/design/defaultrowheight',DefaultRowHeight);
Cfg.Setvalue('grid/design/color',ColorToString(Color));
@ -9036,10 +9082,8 @@ begin
RowCount:=Cfg.GetValue('grid/design/rowcount', 5);
FixedCols:=Cfg.GetValue('grid/design/fixedcols', 1);
FixedRows:=Cfg.GetValue('grid/design/fixedrows', 1);
k := Cfg.GetValue('grid/design/isdefaultrowheight', -1);
if k<>0 then
DefaultRowheight:=Cfg.GetValue('grid/design/defaultrowheight', DEFROWHEIGHT);
DefaultColWidth:=Cfg.getValue('grid/design/defaultcolwidth', DEFCOLWIDTH);
DefaultRowheight:=Cfg.GetValue('grid/design/defaultrowheight', -1);
DefaultColWidth:=Cfg.getValue('grid/design/defaultcolwidth', -1);
try
Color := StringToColor(cfg.GetValue('grid/design/color', 'clWindow'));
except
@ -9175,8 +9219,8 @@ begin
goSmoothScroll ];
FScrollbars:=ssAutoBoth;
fGridState:=gsNormal;
FDefColWidth:=DEFCOLWIDTH;
FDefRowHeight:=GetDefaultRowHeight;
FDefColWidth:=0;
FDefRowHeight:=0;
FGridLineColor:=clSilver;
FFixedGridLineColor := cl3DDKShadow;
FGridLineStyle:=psSolid;
@ -10194,11 +10238,11 @@ begin
ScrollCols := (ssCtrl in shift);
if ScrollCols then
begin
if not TrySmoothScrollBy(Delta*DefaultColWidth, 0) then
if not TrySmoothScrollBy(Delta*GetRealDefColWidth, 0) then
TryScrollTo(FTopLeft.x+Delta, FTopLeft.y, True, False);
end else
begin
if not TrySmoothScrollBy(0, Delta*DefaultRowHeight*Mouse.WheelScrollLines) then
if not TrySmoothScrollBy(0, Delta*GetRealDefRowHeight*Mouse.WheelScrollLines) then
TryScrollTo(FTopLeft.x, FTopLeft.y+Delta, False, True); // scroll only 1 line if above scrolling failed (probably due to too high line)
end;
if EditorMode then
@ -10693,7 +10737,7 @@ begin
W := W + imgWidth;
if W=0 then
W := DefaultColWidth
W := GetRealDefColWidth
else
W := W + DEFAUTOADJPADDING;
@ -11631,6 +11675,8 @@ begin
end;
function TGridColumn.GetWidth: Integer;
var
tmpGrid: TCustomGrid;
begin
{$ifdef newcols}
if not Visible then
@ -11640,6 +11686,12 @@ begin
result := GetDefaultWidth
else
result := FWidth^;
if (result<0) then
begin
tmpGrid := Grid;
if tmpGrid<>nil then
result := tmpGrid.GetRealDefColWidth;
end;
end;
function TGridColumn.IsAlignmentStored: boolean;
@ -11912,7 +11964,7 @@ begin
if tmpGrid<>nil then
result := tmpGrid.DefaultColWidth
else
result := DEFCOLWIDTH;
result := -1;
end;
function TGridColumn.GetDefaultMaxSize: Integer;

View File

@ -3008,7 +3008,7 @@ begin
// Apply the changes
if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then
begin
DisableAutoSizing;
DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TControl.DoAutoAdjustLayout'){$ENDIF};
try
if not ParentFont or (Parent=nil) then
ScaleFontsPPI(AYProportion);
@ -3082,7 +3082,7 @@ begin
SetBounds(NewLeft, NewTop, NewWidth, NewHeight);
finally
EnableAutoSizing;
EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TControl.DoAutoAdjustLayout'){$ENDIF};
end;
end;
end;

View File

@ -1574,7 +1574,7 @@ begin
// Apply the changes
if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then
begin
DisableAutoSizing;
DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TCustomForm.DoAutoAdjustLayout'){$ENDIF};
try
if not ParentFont or (Parent=nil) then
ScaleFontsPPI(AYProportion);
@ -1587,7 +1587,7 @@ begin
SetBounds(Left, Top, NewWidth, NewHeight);
finally
EnableAutoSizing;
EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TCustomForm.DoAutoAdjustLayout'){$ENDIF};
end;
end;
end;

View File

@ -3300,14 +3300,14 @@ begin
if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then
begin
DisableAutoSizing;
DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TCustomTreeView.DoAutoAdjustLayout'){$ENDIF};
try
if not (tvoAutoItemHeight in Options) then
DefaultItemHeight := Round(DefaultItemHeight*AYProportion);
FIndent := Round(FIndent*AXProportion);
FExpandSignSize := Round(FExpandSignSize*AXProportion);
finally
EnableAutoSizing;
EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TCustomTreeView.DoAutoAdjustLayout'){$ENDIF};
end;
end;
end;

View File

@ -3844,14 +3844,14 @@ procedure TWinControl.AutoAdjustLayout(AMode: TLayoutAdjustmentPolicy;
var
i: Integer;
begin
DisableAutoSizing;
DisableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.AutoAdjustLayout'){$ENDIF};
try
for i:=0 to ControlCount-1 do
Controls[i].AutoAdjustLayout(AMode, AFromPPI, AToPPI, AOldFormWidth, ANewFormWidth);
inherited;
finally
EnableAutoSizing;
EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TWinControl.AutoAdjustLayout'){$ENDIF};
end;
end;
@ -6968,10 +6968,6 @@ begin
' wcfClientRectNeedsUpdate=',wcfClientRectNeedsUpdate in FWinControlFlags]);
{$ENDIF}
NewLeft := FBoundsRealized.Left;
NewTop := FBoundsRealized.Top;
if HandleAllocated then
GetWindowRelativePosition(Handle, NewLeft, NewTop);
//if CheckPosition(Self) then
//DebugLn(['TWinControl.WMSize GetWindowRelativePosition: ',DbgSName(Self),' ',NewLeft,',',NewTop,' ClientRectNeedsInterfaceUpdate=',ClientRectNeedsInterfaceUpdate]);
NewBoundsRealized := Bounds(NewLeft, NewTop, Message.Width, Message.Height);

View File

@ -79,7 +79,7 @@ begin
Cells[0, 0] := lisConfirmPackageNewPackageSet;
Cells[1, 0] := lisConfirmPackageAction;
Cells[2, 0] := lisConfirmPackageOldPackageSet;
d := RowCount * (DefaultRowHeight + GridLineWidth) - Height;
d := RowCount * (GetRealDefRowHeight + GridLineWidth) - Height;
end;
// Auto-grow dialog up to 3/4 of the screen height.
d := Min(d, Screen.Height * 3 div 4 - Height);