fpspreadsheet: Add ColorRectOffset to TsCellCombobox. Fix color rect of TsCellCombobox being truncated in qt.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4321 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2015-09-09 20:58:15 +00:00
parent 51ae4d34e1
commit 106c5a90f6
2 changed files with 33 additions and 13 deletions

View File

@@ -240,7 +240,7 @@ object MainForm: TMainForm
Action = AcNumFormatPercentage Action = AcNumFormatPercentage
end end
object ToolButton23: TToolButton object ToolButton23: TToolButton
Left = 898 Left = 896
Height = 26 Height = 26
Top = 0 Top = 0
Width = 5 Width = 5
@@ -286,7 +286,7 @@ object MainForm: TMainForm
Action = AcBackgroundColorDialog Action = AcBackgroundColorDialog
end end
object ToolButton31: TToolButton object ToolButton31: TToolButton
Left = 857 Left = 855
Height = 26 Height = 26
Top = 0 Top = 0
Width = 5 Width = 5
@@ -294,7 +294,7 @@ object MainForm: TMainForm
Style = tbsDivider Style = tbsDivider
end end
object TbBorders: TToolButton object TbBorders: TToolButton
Left = 862 Left = 860
Hint = 'Top border' Hint = 'Top border'
Top = 0 Top = 0
Caption = 'Top' Caption = 'Top'
@@ -311,7 +311,7 @@ object MainForm: TMainForm
Style = tbsDivider Style = tbsDivider
end end
object ToolButton5: TToolButton object ToolButton5: TToolButton
Left = 903 Left = 901
Top = 0 Top = 0
Action = AcMergeCells Action = AcMergeCells
end end
@@ -366,6 +366,7 @@ object MainForm: TMainForm
Top = 0 Top = 0
Width = 48 Width = 48
CellFormatItem = cfiFontColor CellFormatItem = cfiFontColor
ColorRectOffset = 3
ColorRectWidth = -1 ColorRectWidth = -1
WorkbookSource = WorkbookSource WorkbookSource = WorkbookSource
DropDownCount = 24 DropDownCount = 24
@@ -378,8 +379,9 @@ object MainForm: TMainForm
Height = 24 Height = 24
Hint = 'Background color' Hint = 'Background color'
Top = 0 Top = 0
Width = 48 Width = 46
CellFormatItem = cfiBackgroundColor CellFormatItem = cfiBackgroundColor
ColorRectOffset = 3
ColorRectWidth = -1 ColorRectWidth = -1
WorkbookSource = WorkbookSource WorkbookSource = WorkbookSource
DropDownCount = 24 DropDownCount = 24

View File

@@ -286,9 +286,11 @@ type
private private
FWorkbookSource: TsWorkbookSource; FWorkbookSource: TsWorkbookSource;
FFormatItem: TsCellFormatItem; FFormatItem: TsCellFormatItem;
FColorRectOffset: Integer;
FColorRectWidth: Integer; FColorRectWidth: Integer;
function GetWorkbook: TsWorkbook; function GetWorkbook: TsWorkbook;
function GetWorksheet: TsWorksheet; function GetWorksheet: TsWorksheet;
procedure SetColorRectOffset(AValue: Integer);
procedure SetColorRectWidth(AValue: Integer); procedure SetColorRectWidth(AValue: Integer);
procedure SetFormatItem(AValue: TsCellFormatItem); procedure SetFormatItem(AValue: TsCellFormatItem);
procedure SetWorkbookSource(AValue: TsWorkbookSource); procedure SetWorkbookSource(AValue: TsWorkbookSource);
@@ -318,6 +320,8 @@ type
published published
{@@ Identifies the cell format property to be used in the combobox } {@@ Identifies the cell format property to be used in the combobox }
property CellFormatItem: TsCellFormatItem read FFormatItem write SetFormatItem; property CellFormatItem: TsCellFormatItem read FFormatItem write SetFormatItem;
{@@ Margin around the color box }
property ColorRectOffset: Integer read FColorRectOffset write SetColorRectOffset default 2;
{@@ Width of the color box shown for the color-related format items } {@@ Width of the color box shown for the color-related format items }
property ColorRectWidth: Integer read FColorRectWidth write SetColorRectWidth default 10; property ColorRectWidth: Integer read FColorRectWidth write SetColorRectWidth default 10;
{@@ Link to the WorkbookSource which provides the workbook and worksheet. } {@@ Link to the WorkbookSource which provides the workbook and worksheet. }
@@ -463,7 +467,7 @@ procedure Register;
implementation implementation
uses uses
Types, Math, TypInfo, LCLType, LCLProc, Dialogs, Forms, Types, Math, StrUtils, TypInfo, LCLType, LCLProc, Dialogs, Forms,
fpsStrings, fpsUtils, fpsNumFormat, fpsHTMLUtils; fpsStrings, fpsUtils, fpsNumFormat, fpsHTMLUtils;
{@@ ---------------------------------------------------------------------------- {@@ ----------------------------------------------------------------------------
@@ -1911,6 +1915,7 @@ constructor TsCellCombobox.Create(AOwner: TComponent);
begin begin
inherited Create(AOwner); inherited Create(AOwner);
FColorRectWidth := 10; FColorRectWidth := 10;
FColorRectOffset := 2;
ItemHeight := -1; ItemHeight := -1;
end; end;
@@ -2001,11 +2006,11 @@ begin
if FFormatItem in [cfiFontColor, cfiBackgroundColor, cfiBorderColor] then if FFormatItem in [cfiFontColor, cfiBackgroundColor, cfiBorderColor] then
begin begin
r.Top := ARect.Top + 2; r.Top := ARect.Top + FColorRectOffset;
r.Bottom := ARect.Bottom - 2; r.Bottom := ARect.Bottom - FColorRectOffset;
r.Left := ARect.Left + 2; r.Left := ARect.Left + FColorRectOffset;
if FColorRectWidth = -1 then if FColorRectWidth = -1 then
r.Right := ARect.Right - 2 r.Right := ARect.Right - FColorRectOffset
else else
r.Right := r.Left + FColorRectWidth; r.Right := r.Left + FColorRectWidth;
Exclude(AState, odPainted); Exclude(AState, odPainted);
@@ -2049,7 +2054,7 @@ begin
if FColorRectWidth > -1 then if FColorRectWidth > -1 then
begin begin
r := ARect; r := ARect;
inc(r.Left, FColorRectWidth + 4); inc(r.Left, FColorRectWidth + 2*FColorRectOffset);
inherited DrawItem(AIndex, BidiFlipRect(r, ARect, UseRightToLeftAlignment), AState); inherited DrawItem(AIndex, BidiFlipRect(r, ARect, UseRightToLeftAlignment), AState);
end; end;
end else end else
@@ -2192,6 +2197,7 @@ procedure TsCellCombobox.Populate;
var var
i: Integer; i: Integer;
clr: TsColor; clr: TsColor;
noText: Boolean;
begin begin
if Workbook = nil then if Workbook = nil then
exit; exit;
@@ -2205,13 +2211,14 @@ begin
cfiFontColor, cfiFontColor,
cfiBorderColor: cfiBorderColor:
begin begin
noText := (FColorRectWidth = -1);
Items.Clear; Items.Clear;
if FFormatItem = cfiBackgroundColor then if FFormatItem = cfiBackgroundColor then
Items.AddObject('(none)', TObject(scTransparent)); Items.AddObject(IfThen(noText, '', '(none)'), TObject(scTransparent));
for i:=0 to ComboColors.Count-1 do for i:=0 to ComboColors.Count-1 do
begin begin
clr := ComboColors[i]; clr := ComboColors[i];
Items.AddObject(GetColorName(clr), TObject(PtrInt(clr))); Items.AddObject(IfThen(noText, '', GetColorName(clr)), TObject(PtrInt(clr)));
end; end;
end; end;
else else
@@ -2271,6 +2278,17 @@ begin
ProcessItem; ProcessItem;
end; end;
{@@ ----------------------------------------------------------------------------
Setter method for the ColorRectOffset property
-------------------------------------------------------------------------------}
procedure TsCellCombobox.SetColorRectOffset(AValue: Integer);
begin
if FColorRectOffset = AValue then
exit;
FColorRectOffset := AValue;
Invalidate;
end;
{@@ ---------------------------------------------------------------------------- {@@ ----------------------------------------------------------------------------
Setter method for the ColorRectWidth property Setter method for the ColorRectWidth property
-------------------------------------------------------------------------------} -------------------------------------------------------------------------------}