From 1291b44c5d0b5abaecba661f01d1034c3df2344a Mon Sep 17 00:00:00 2001 From: graemeg Date: Fri, 14 Dec 2007 20:17:45 +0000 Subject: * Implemented Cell Text Alignment. * Fixed CalendarCombo so dates are centered in grid cells. * Fixed memory leak in AbstractCombobox. * Modified the GridTest example to show the column text alignment in action. --- src/gui/gui_combobox.pas | 2 ++ src/gui/gui_grid.pas | 25 +++++++++++++++++++++++-- src/gui/gui_popupcalendar.pas | 14 +++++++------- 3 files changed, 32 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/gui/gui_combobox.pas b/src/gui/gui_combobox.pas index 930bd551..1ad527ea 100644 --- a/src/gui/gui_combobox.pas +++ b/src/gui/gui_combobox.pas @@ -483,6 +483,8 @@ end; destructor TfpgAbstractComboBox.Destroy; begin + if Assigned(FDropDown) then + FDropDown.Free; FItems.Free; FFont.Free; inherited Destroy; diff --git a/src/gui/gui_grid.pas b/src/gui/gui_grid.pas index d764d241..5be33147 100644 --- a/src/gui/gui_grid.pas +++ b/src/gui/gui_grid.pas @@ -782,13 +782,34 @@ begin end; procedure TfpgCustomStringGrid.DrawCell(ARow, ACol: integer; ARect: TfpgRect; - AFlags: integer); + AFlags: integer); +var + x: TfpgCoord; begin if Cells[ACol, ARow] <> '' then begin if not Enabled then Canvas.SetTextColor(clShadow1); - Canvas.DrawString(ARect.Left+1, ARect.Top+1, Cells[ACol, ARow]); + + case Columns[ACol].Alignment of + taLeftJustify: + begin + x := ARect.Left + 1; + end; + taCenter: + begin + x := (ARect.Width - Font.TextWidth(Cells[ACol, ARow])) div 2; + Inc(x, ARect.Left); + end; + taRightJustify: + begin + x := ARect.Right - Font.TextWidth(Cells[ACol, ARow]) - 1; + if x < (ARect.Left + 1) then + x := ARect.Left + 1; + end; + end; { case } + + Canvas.DrawString(x, ARect.Top+1, Cells[ACol, ARow]); end; end; diff --git a/src/gui/gui_popupcalendar.pas b/src/gui/gui_popupcalendar.pas index 53b9e215..4e90c4a5 100644 --- a/src/gui/gui_popupcalendar.pas +++ b/src/gui/gui_popupcalendar.pas @@ -569,13 +569,13 @@ begin begin Name := 'grdName1'; SetPosition(0, 23, 233, 119); - AddColumn('Mon', 33, taLeftJustify); - AddColumn('Tue', 32, taLeftJustify); - AddColumn('Wed', 33, taLeftJustify); - AddColumn('Thu', 32, taLeftJustify); - AddColumn('Fri', 33, taLeftJustify); - AddColumn('Sat', 32, taLeftJustify); - AddColumn('Sun', 33, taLeftJustify); + AddColumn('Mon', 33, taCenter); + AddColumn('Tue', 32, taCenter); + AddColumn('Wed', 33, taCenter); + AddColumn('Thu', 32, taCenter); + AddColumn('Fri', 33, taCenter); + AddColumn('Sat', 32, taCenter); + AddColumn('Sun', 33, taCenter); FontDesc := '#Grid'; HeaderFontDesc := '#GridHeader'; RowCount := 6; -- cgit v1.2.3-70-g09d2