merged r50847 #9cd8314204,r50848,r50851,r50854: grids: fix editor position. Issue #29196

git-svn-id: branches/fixes_1_6@50855 -
This commit is contained in:
ondrej 2015-12-17 10:51:30 +00:00
parent ddbef587da
commit 1a2b04d1b2
7 changed files with 99 additions and 15 deletions

View File

@ -3567,7 +3567,10 @@ begin
Canvas.Pen.Mode := pmCopy;
GetSelectedState(aState, IsSelected);
if IsSelected then begin
Canvas.Brush.Color := SelectedColor;
if FEditorMode and (FEditor<>nil) then
Canvas.Brush.Color := FEditor.Color
else
Canvas.Brush.Color := SelectedColor;
SetCanvasFont(GetColumnFont(aCol, False));
if not IsCellButtonColumn(point(aCol,aRow)) then
Canvas.Font.Color := clHighlightText;
@ -7855,8 +7858,10 @@ begin
CellR := Bounds(-FEditor.Width-100, -FEditor.Height-100, CellR.Right-CellR.Left, CellR.Bottom-CellR.Top);
if FEditorOptions and EO_AUTOSIZE = EO_AUTOSIZE then begin
if EditorBorderStyle = bsNone then
InflateRect(CellR, -1, -1);
if (FEditor = FStringEditor) and (EditorBorderStyle = bsNone) then begin
CellR := TWSCustomGridClass(WidgetSetClass).
GetEditorBoundsFromCellRect(Canvas, CellR, GetColumnLayout(FCol, False));
end;
FEditor.BoundsRect := CellR;
end else begin
Msg.LclMsg.msg:=GM_SETBOUNDS;

View File

@ -570,8 +570,8 @@ end;
function RegisterCustomGrid: Boolean; alias : 'WSRegisterCustomGrid';
begin
RegisterWSComponent(TCustomGrid, TGtk2WSCustomGrid); { GTK1 }
// RegisterWSComponent(TCustomGrid, TGtk2WSCustomGrid);
//RegisterWSComponent(TCustomGrid, TGtkWSCustomGrid); { GTK1 }
RegisterWSComponent(TCustomGrid, TGtk2WSCustomGrid);
Result := True;
end;

View File

@ -27,7 +27,7 @@ uses
// To get as little as posible circles,
// uncomment only when needed for registration
////////////////////////////////////////////////////
// Grids,
Types, Grids, Graphics,
////////////////////////////////////////////////////
WSGrids, WSLCLClasses;
@ -36,11 +36,33 @@ type
{ TGtk2WSCustomGrid }
TGtk2WSCustomGrid = class(TWSCustomGrid)
private
protected
public
published
class function GetEditorBoundsFromCellRect(ACanvas: TCanvas;
const ACellRect: TRect; const AColumnLayout: TTextLayout): TRect; override;
end;
implementation
{ TGtk2WSCustomGrid }
class function TGtk2WSCustomGrid.GetEditorBoundsFromCellRect(ACanvas: TCanvas;
const ACellRect: TRect; const AColumnLayout: TTextLayout): TRect;
var
EditorTop: LongInt;
TextHeight: Integer;
begin
Result:=ACellRect;
Inc(Result.Left);
Dec(Result.Right);
Dec(Result.Bottom);
TextHeight := ACanvas.TextHeight(' ');
case AColumnLayout of
tlTop: EditorTop:=Result.Top+constCellPadding;
tlCenter: EditorTop:=Result.Top+(Result.Bottom-Result.Top-TextHeight+1) div 2;
tlBottom: EditorTop:=Result.Bottom-constCellPadding-TextHeight+1;
end;
if EditorTop>Result.Top then Result.Top:=EditorTop;
Result.Bottom:=Result.Top+TextHeight;
end;
end.

View File

@ -4,7 +4,7 @@ unit QtWSFactory;
interface
uses
Classes, Controls, ComCtrls, Calendar, StdCtrls, Spin,
Classes, Controls, ComCtrls, Calendar, StdCtrls, Spin, Grids,
Dialogs, ExtCtrls, Buttons, CheckLst, Forms, Menus, RubberBand, PairSplitter,
WSLCLClasses;
@ -111,6 +111,7 @@ uses
QtWSPairSplitter,
QtWSSpin,
QtWSStdCtrls,
QtWSGrids,
QtWSDesigner;
// imglist
@ -502,7 +503,8 @@ end;
function RegisterCustomGrid: Boolean; alias : 'WSRegisterCustomGrid';
begin
Result := False;
RegisterWSComponent(TCustomGrid, TQtWSCustomGrid);
Result := True;
end;
function RegisterMenuItem: Boolean; alias : 'WSRegisterMenuItem';

View File

@ -23,7 +23,7 @@ interface
{$I qtdefines.inc}
uses
Controls,
Controls, Types, Graphics, Grids,
// Widgetset
WSGrids, WSLCLClasses;
@ -33,9 +33,32 @@ type
TQtWSCustomGrid = class(TWSCustomGrid)
published
class function GetEditorBoundsFromCellRect(ACanvas: TCanvas;
const ACellRect: TRect; const AColumnLayout: TTextLayout): TRect; override;
end;
implementation
{ TQtWSCustomGrid }
class function TQtWSCustomGrid.GetEditorBoundsFromCellRect(ACanvas: TCanvas;
const ACellRect: TRect; const AColumnLayout: TTextLayout): TRect;
var
EditorTop: LongInt;
TextHeight: Integer;
begin
Result:=ACellRect;
Dec(Result.Right);
Dec(Result.Bottom);
TextHeight := ACanvas.TextHeight(' ');
case AColumnLayout of
tlTop: EditorTop:=Result.Top+constCellPadding;
tlCenter: EditorTop:=Result.Top+Round((Result.Bottom-Result.Top-TextHeight+1) div 2);
tlBottom: EditorTop:=Result.Bottom-constCellPadding-TextHeight+1;
end;
if EditorTop>Result.Top then Result.Top:=EditorTop;
Result.Bottom:=Result.Top+TextHeight;
end;
end.

View File

@ -29,7 +29,7 @@ uses
// To get as little as posible circles,
// uncomment only when needed for registration
////////////////////////////////////////////////////
Windows, LCLType, LazUTF8, Controls, Win32Proc,
Windows, LCLType, LazUTF8, Types, Controls, Grids, Win32Proc, Graphics,
////////////////////////////////////////////////////
WSGrids;
@ -39,12 +39,33 @@ type
TWin32WSCustomGrid = class(TWSCustomGrid)
published
class procedure SendCharToEditor(AEditor:TWinControl; Ch: TUTF8Char); override;
class function GetEditorBoundsFromCellRect(ACanvas: TCanvas;
const ACellRect: TRect; const AColumnLayout: TTextLayout): TRect; override;
end;
implementation
{ TWin32WSCustomGrid }
class function TWin32WSCustomGrid.GetEditorBoundsFromCellRect(ACanvas: TCanvas;
const ACellRect: TRect; const AColumnLayout: TTextLayout): TRect;
var
EditorTop: LongInt;
TextHeight: Integer;
begin
Result:=ACellRect;
Dec(Result.Right);
Dec(Result.Bottom);
TextHeight := ACanvas.TextHeight(' ');
case AColumnLayout of
tlTop: EditorTop:=Result.Top+constCellPadding;
tlCenter: EditorTop:=Result.Top+Round((Result.Bottom-Result.Top-TextHeight) / 2);
tlBottom: EditorTop:=Result.Bottom-constCellPadding-TextHeight+1;
end;
if EditorTop>Result.Top then Result.Top:=EditorTop;
Result.Bottom:=Result.Top+TextHeight;
end;
class procedure TWin32WSCustomGrid.SendCharToEditor(AEditor: TWinControl;
Ch: TUTF8Char);
var

View File

@ -39,7 +39,7 @@ uses
// To get as little as posible circles,
// uncomment only when needed for registration
////////////////////////////////////////////////////
LCLType, Controls, StdCtrls, Grids, LazUTF8,
LCLType, Types, Controls, StdCtrls, Grids, LazUTF8, Graphics,
////////////////////////////////////////////////////
WSLCLClasses, WSControls, WSFactory;
@ -50,6 +50,8 @@ type
published
class procedure SendCharToEditor(AEditor:TWinControl; Ch: TUTF8Char); virtual;
class function InvalidateStartY(const FixedHeight, RowOffset: Integer): integer; virtual;
class function GetEditorBoundsFromCellRect(ACanvas: TCanvas;
const ACellRect: TRect; const AColumnLayout: TTextLayout): TRect; virtual;
end;
TWSCustomGridClass = class of TWSCustomgrid;
@ -106,7 +108,16 @@ begin
EditorTextChanged(Col, Row, GMsg.Value);
end;
class function TWSCustomGrid.InvalidateStartY(const FixedHeight, RowOffset: Integer): Integer;
class function TWSCustomGrid.GetEditorBoundsFromCellRect(ACanvas: TCanvas;
const ACellRect: TRect; const AColumnLayout: TTextLayout): TRect;
begin
Result := ACellRect;
Dec(Result.Right);
Dec(Result.Bottom);
end;
class function TWSCustomGrid.InvalidateStartY(const FixedHeight,
RowOffset: Integer): integer;
begin
result := FixedHeight;
end;