1{ $Id$} 2{ 3 ***************************************************************************** 4 * Gtk2WSGrids.pp * 5 * -------------- * 6 * * 7 * * 8 ***************************************************************************** 9 10 ***************************************************************************** 11 This file is part of the Lazarus Component Library (LCL) 12 13 See the file COPYING.modifiedLGPL.txt, included in this distribution, 14 for details about the license. 15 ***************************************************************************** 16} 17unit Gtk2WSGrids; 18 19{$mode objfpc}{$H+} 20 21interface 22 23uses 24//////////////////////////////////////////////////// 25// I M P O R T A N T 26//////////////////////////////////////////////////// 27// To get as little as posible circles, 28// uncomment only when needed for registration 29//////////////////////////////////////////////////// 30 Types, Grids, Graphics, 31//////////////////////////////////////////////////// 32 WSGrids, WSLCLClasses; 33 34type 35 36 { TGtk2WSCustomGrid } 37 38 TGtk2WSCustomGrid = class(TWSCustomGrid) 39 published 40 class function GetEditorBoundsFromCellRect(ACanvas: TCanvas; 41 const ACellRect: TRect; const AColumnLayout: TTextLayout): TRect; override; 42 class procedure Invalidate(sender: TCustomGrid); override; 43 end; 44 45implementation 46 47{ TGtk2WSCustomGrid } 48 49class function TGtk2WSCustomGrid.GetEditorBoundsFromCellRect(ACanvas: TCanvas; 50 const ACellRect: TRect; const AColumnLayout: TTextLayout): TRect; 51var 52 EditorTop: LongInt; 53 TextHeight: Integer; 54begin 55 Result:=ACellRect; 56 Inc(Result.Left); 57 Dec(Result.Right, 2); 58 Dec(Result.Bottom); 59 TextHeight := ACanvas.TextHeight(' '); 60 case AColumnLayout of 61 tlTop: EditorTop:=Result.Top+constCellPadding; 62 tlCenter: EditorTop:=Result.Top+(Result.Bottom-Result.Top-TextHeight+1) div 2; 63 tlBottom: EditorTop:=Result.Bottom-constCellPadding-TextHeight+1; 64 end; 65 if EditorTop>Result.Top then Result.Top:=EditorTop; 66 Result.Bottom:=Result.Top+TextHeight; 67end; 68 69class procedure TGtk2WSCustomGrid.Invalidate(sender: TCustomGrid); 70begin 71 Sender.Invalidate; 72end; 73 74end. 75