diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/fpg_basegrid.pas | 33 | ||||
-rw-r--r-- | src/gui/fpg_customgrid.pas | 2 | ||||
-rw-r--r-- | src/gui/fpg_grid.pas | 1 |
3 files changed, 33 insertions, 3 deletions
diff --git a/src/gui/fpg_basegrid.pas b/src/gui/fpg_basegrid.pas index 9ad2b59f..73d77e40 100644 --- a/src/gui/fpg_basegrid.pas +++ b/src/gui/fpg_basegrid.pas @@ -43,7 +43,7 @@ type TfpgDrawCellEvent = procedure(Sender: TObject; const ARow, ACol: Integer; const ARect: TfpgRect; const AFlags: TfpgGridDrawState; var ADefaultDrawing: boolean) of object; // widget options - TfpgGridOption = (go_HideFocusRect); + TfpgGridOption = (go_HideFocusRect, go_AlternativeColor); TfpgGridOptions = set of TfpgGridOption; // Column 2 is special just for testing purposes. Descendant classes will @@ -79,6 +79,7 @@ type FUpdateCount: integer; FOptions: TfpgGridOptions; FPopupMenu: TfpgPopupMenu; + FAlternativeBGColor: TfpgColor; function GetFontDesc: string; function GetHeaderFontDesc: string; procedure HScrollBarMove(Sender: TObject; position: integer); @@ -98,12 +99,14 @@ type function VisibleWidth: integer; function VisibleHeight: integer; procedure SetFirstRow(const AValue: Integer); + procedure SetAlternativeBGColor(const AValue: TfpgColor); protected property UpdateCount: integer read FUpdateCount; procedure UpdateScrollBars; virtual; function GetHeaderText(ACol: Integer): string; virtual; function GetColumnWidth(ACol: Integer): integer; virtual; procedure SetColumnWidth(ACol: Integer; const AValue: integer); virtual; + function GetBackgroundColor(ARow: integer; ACol: integer): TfpgColor; virtual; function GetColumnBackgroundColor(ACol: Integer): TfpgColor; virtual; procedure SetColumnBackgroundColor(ACol: Integer; const AValue: TfpgColor); virtual; function GetColumnTextColor(ACol: Integer): TfpgColor; virtual; @@ -126,6 +129,7 @@ type procedure HandleLMouseDown(x, y: integer; shiftstate: TShiftState); override; procedure HandleRMouseUp(x, y: integer; shiftstate: TShiftState); override; procedure FollowFocus; virtual; + property AlternateBGColor: TfpgColor read FAlternativeBGColor write SetAlternativeBGColor default clHilite1; property DefaultColWidth: integer read FDefaultColWidth write SetDefaultColWidth default 64; property DefaultRowHeight: integer read FDefaultRowHeight write SetDefaultRowHeight; property Font: TfpgFont read FFont; @@ -264,6 +268,24 @@ begin end; end; +function TfpgBaseGrid.GetBackgroundColor(ARow: integer; ACol: integer): TfpgColor; +begin + if (ARow >= 0) and (ACol >= 0) and (ARow < RowCount) and (ACol < ColumnCount) then + begin + if go_AlternativeColor in Options then + begin + if (ARow mod 2) <> 0 then + Result := AlternateBGColor + else + Result := ColumnBackgroundColor[ACol]; + end + else + Result := ColumnBackgroundColor[ACol]; + end + else + Result := BackgroundColor; +end; + function TfpgBaseGrid.GetColumnBackgroundColor(ACol: Integer): TfpgColor; begin // implemented in descendant @@ -481,6 +503,12 @@ begin RePaint; end; +procedure TfpgBaseGrid.SetAlternativeBGColor(const AValue: TfpgColor); +begin + if FAlternativeBGColor = AValue then exit; + FAlternativeBGColor := AValue; +end; + procedure TfpgBaseGrid.UpdateScrollBars; var HWidth: integer; @@ -627,7 +655,7 @@ begin end else begin - Canvas.SetColor(ColumnBackgroundColor[col]); + Canvas.SetColor(GetBackgroundColor(row, col)); Canvas.SetTextColor(ColumnTextColor[col]); end; Canvas.AddClipRect(r); @@ -1141,6 +1169,7 @@ begin FDefaultRowHeight := FFont.Height + 2; FHeaderHeight := FHeaderFont.Height + 2; FBackgroundColor := clBoxColor; + FAlternativeBGColor := clHilite1; FColResizing := False; MinHeight := HeaderHeight + DefaultRowHeight + FMargin; diff --git a/src/gui/fpg_customgrid.pas b/src/gui/fpg_customgrid.pas index a43c141e..fc7a58a1 100644 --- a/src/gui/fpg_customgrid.pas +++ b/src/gui/fpg_customgrid.pas @@ -259,7 +259,7 @@ begin if (ACol >= 0) and (ACol < ColumnCount) then Result := TfpgGridColumn(FColumns[ACol]).FBackgroundColor else - result := BackgroundColor; + Result := BackgroundColor; end; procedure TfpgCustomGrid.SetColumnBackgroundColor(ACol: Integer; const AValue: TfpgColor); diff --git a/src/gui/fpg_grid.pas b/src/gui/fpg_grid.pas index fdc83e9f..ad5dc6e3 100644 --- a/src/gui/fpg_grid.pas +++ b/src/gui/fpg_grid.pas @@ -125,6 +125,7 @@ type public property Font; published + property AlternateBGColor; property BackgroundColor; // property ColResizing; property ColumnCount; |