fpspreadsheet: TsCellCombobox finished.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3799 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2014-11-27 20:59:14 +00:00
parent c75c611846
commit 1b7d496a56
4 changed files with 196 additions and 155 deletions

View File

@ -2,18 +2,18 @@ object Form1: TForm1
Left = 541 Left = 541
Height = 600 Height = 600
Top = 214 Top = 214
Width = 876 Width = 941
Caption = 'Form1' Caption = 'Form1'
ClientHeight = 575 ClientHeight = 580
ClientWidth = 876 ClientWidth = 941
Menu = MainMenu Menu = MainMenu
ShowHint = True ShowHint = True
LCLVersion = '1.3' LCLVersion = '1.3'
object WorkbookTabControl: TsWorkbookTabControl object WorkbookTabControl: TsWorkbookTabControl
Left = 0 Left = 0
Height = 486 Height = 497
Top = 89 Top = 83
Width = 623 Width = 688
TabIndex = 0 TabIndex = 0
Tabs.Strings = ( Tabs.Strings = (
'Sheet1' 'Sheet1'
@ -23,9 +23,9 @@ object Form1: TForm1
WorkbookSource = WorkbookSource WorkbookSource = WorkbookSource
object WorksheetGrid: TsWorksheetGrid object WorksheetGrid: TsWorksheetGrid
Left = 2 Left = 2
Height = 456 Height = 472
Top = 28 Top = 23
Width = 619 Width = 684
FrozenCols = 0 FrozenCols = 0
FrozenRows = 0 FrozenRows = 0
ReadFormulas = False ReadFormulas = False
@ -77,9 +77,9 @@ object Form1: TForm1
end end
end end
object InspectorTabControl: TTabControl object InspectorTabControl: TTabControl
Left = 628 Left = 693
Height = 486 Height = 497
Top = 89 Top = 83
Width = 248 Width = 248
OnChange = InspectorTabControlChange OnChange = InspectorTabControlChange
TabIndex = 0 TabIndex = 0
@ -94,8 +94,8 @@ object Form1: TForm1
Visible = False Visible = False
object Inspector: TsSpreadsheetInspector object Inspector: TsSpreadsheetInspector
Left = 2 Left = 2
Height = 456 Height = 472
Top = 28 Top = 23
Width = 244 Width = 244
Align = alClient Align = alClient
RowCount = 25 RowCount = 25
@ -108,7 +108,7 @@ object Form1: TForm1
'Options=boAutoCalc, boCalcBeforeSaving, boReadFormulas' 'Options=boAutoCalc, boCalcBeforeSaving, boReadFormulas'
'FormatSettings=' 'FormatSettings='
' ThousandSeparator=.' ' ThousandSeparator=.'
' DecimalSeparator=,' ' DecimalSeparator=.'
' ListSeparator=;' ' ListSeparator=;'
' DateSeparator=.' ' DateSeparator=.'
' TimeSeparator=:' ' TimeSeparator=:'
@ -134,24 +134,24 @@ object Form1: TForm1
WorkbookSource = WorkbookSource WorkbookSource = WorkbookSource
Mode = imWorkbook Mode = imWorkbook
ColWidths = ( ColWidths = (
109 111
110 112
) )
end end
end end
object Splitter1: TSplitter object Splitter1: TSplitter
Left = 623 Left = 688
Height = 486 Height = 497
Top = 89 Top = 83
Width = 5 Width = 5
Align = alRight Align = alRight
ResizeAnchor = akRight ResizeAnchor = akRight
end end
object ToolBar1: TToolBar object ToolBar1: TToolBar
Left = 0 Left = 0
Height = 28 Height = 26
Top = 28 Top = 24
Width = 876 Width = 941
AutoSize = True AutoSize = True
ButtonHeight = 26 ButtonHeight = 26
ButtonWidth = 24 ButtonWidth = 24
@ -160,7 +160,7 @@ object Form1: TForm1
Images = ImageList Images = ImageList
TabOrder = 3 TabOrder = 3
object ToolButton4: TToolButton object ToolButton4: TToolButton
Left = 265 Left = 232
Height = 26 Height = 26
Top = 0 Top = 0
Width = 3 Width = 3
@ -168,22 +168,22 @@ object Form1: TForm1
Style = tbsDivider Style = tbsDivider
end end
object ToolButton6: TToolButton object ToolButton6: TToolButton
Left = 268 Left = 283
Top = 0 Top = 0
Action = AcFontBold Action = AcFontBold
end end
object ToolButton7: TToolButton object ToolButton7: TToolButton
Left = 292 Left = 307
Top = 0 Top = 0
Action = AcFontItalic Action = AcFontItalic
end end
object ToolButton8: TToolButton object ToolButton8: TToolButton
Left = 316 Left = 331
Top = 0 Top = 0
Action = AcFontUnderline Action = AcFontUnderline
end end
object ToolButton10: TToolButton object ToolButton10: TToolButton
Left = 364 Left = 379
Height = 26 Height = 26
Top = 0 Top = 0
Width = 5 Width = 5
@ -191,27 +191,27 @@ object Form1: TForm1
Style = tbsDivider Style = tbsDivider
end end
object ToolButton11: TToolButton object ToolButton11: TToolButton
Left = 340 Left = 355
Top = 0 Top = 0
Action = AcFontStrikeout Action = AcFontStrikeout
end end
object ToolButton12: TToolButton object ToolButton12: TToolButton
Left = 369 Left = 384
Top = 0 Top = 0
Action = AcHorAlignLeft Action = AcHorAlignLeft
end end
object ToolButton13: TToolButton object ToolButton13: TToolButton
Left = 393 Left = 408
Top = 0 Top = 0
Action = AcHorAlignCenter Action = AcHorAlignCenter
end end
object ToolButton14: TToolButton object ToolButton14: TToolButton
Left = 417 Left = 432
Top = 0 Top = 0
Action = AcHorAlignRight Action = AcHorAlignRight
end end
object ToolButton15: TToolButton object ToolButton15: TToolButton
Left = 441 Left = 456
Height = 26 Height = 26
Top = 0 Top = 0
Width = 5 Width = 5
@ -219,22 +219,22 @@ object Form1: TForm1
Style = tbsDivider Style = tbsDivider
end end
object ToolButton16: TToolButton object ToolButton16: TToolButton
Left = 446 Left = 461
Top = 0 Top = 0
Action = AcVertAlignTop Action = AcVertAlignTop
end end
object ToolButton17: TToolButton object ToolButton17: TToolButton
Left = 470 Left = 485
Top = 0 Top = 0
Action = AcVertAlignCenter Action = AcVertAlignCenter
end end
object ToolButton18: TToolButton object ToolButton18: TToolButton
Left = 494 Left = 509
Top = 0 Top = 0
Action = AcVertAlignBottom Action = AcVertAlignBottom
end end
object ToolButton19: TToolButton object ToolButton19: TToolButton
Left = 518 Left = 533
Height = 26 Height = 26
Top = 0 Top = 0
Width = 5 Width = 5
@ -242,7 +242,7 @@ object Form1: TForm1
Style = tbsDivider Style = tbsDivider
end end
object ToolButton20: TToolButton object ToolButton20: TToolButton
Left = 523 Left = 567
Hint = 'Number format' Hint = 'Number format'
Top = 0 Top = 0
Caption = 'ToolButton20' Caption = 'ToolButton20'
@ -251,7 +251,7 @@ object Form1: TForm1
Style = tbsDropDown Style = tbsDropDown
end end
object ToolButton21: TToolButton object ToolButton21: TToolButton
Left = 583 Left = 627
Hint = 'Currency format' Hint = 'Currency format'
Top = 0 Top = 0
Caption = 'ToolButton21' Caption = 'ToolButton21'
@ -260,12 +260,12 @@ object Form1: TForm1
Style = tbsDropDown Style = tbsDropDown
end end
object ToolButton22: TToolButton object ToolButton22: TToolButton
Left = 559 Left = 603
Top = 0 Top = 0
Action = AcNumFormatPercentage Action = AcNumFormatPercentage
end end
object ToolButton23: TToolButton object ToolButton23: TToolButton
Left = 828 Left = 901
Height = 26 Height = 26
Top = 0 Top = 0
Width = 5 Width = 5
@ -273,7 +273,7 @@ object Form1: TForm1
Style = tbsDivider Style = tbsDivider
end end
object ToolButton24: TToolButton object ToolButton24: TToolButton
Left = 619 Left = 663
Hint = 'Date format' Hint = 'Date format'
Top = 0 Top = 0
Caption = 'ToolButton24' Caption = 'ToolButton24'
@ -282,7 +282,7 @@ object Form1: TForm1
Style = tbsDropDown Style = tbsDropDown
end end
object ToolButton25: TToolButton object ToolButton25: TToolButton
Left = 655 Left = 699
Hint = 'Time format' Hint = 'Time format'
Top = 0 Top = 0
Caption = 'ToolButton25' Caption = 'ToolButton25'
@ -291,27 +291,29 @@ object Form1: TForm1
Style = tbsDropDown Style = tbsDropDown
end end
object ToolButton26: TToolButton object ToolButton26: TToolButton
Left = 691 Left = 735
Top = 0 Top = 0
Action = AcDecDecimals Action = AcDecDecimals
end end
object ToolButton27: TToolButton object ToolButton27: TToolButton
Left = 715 Left = 759
Top = 0 Top = 0
Action = AcIncDecimals Action = AcIncDecimals
end end
object ToolButton29: TToolButton object ToolButton29: TToolButton
Left = 30 Left = 30
Hint = 'Cell font dialog'
Top = 0 Top = 0
Action = AcCellFontDialog Action = AcCellFontDialog
end end
object ToolButton30: TToolButton object ToolButton30: TToolButton
Left = 768 Left = 788
Hint = 'Background color dialog'
Top = 0 Top = 0
Action = AcBackgroundColorDialog Action = AcBackgroundColorDialog
end end
object ToolButton31: TToolButton object ToolButton31: TToolButton
Left = 857 Left = 860
Height = 26 Height = 26
Top = 0 Top = 0
Width = 5 Width = 5
@ -319,7 +321,7 @@ object Form1: TForm1
Style = tbsDivider Style = tbsDivider
end end
object TbBorders: TToolButton object TbBorders: TToolButton
Left = 792 Left = 865
Hint = 'Top border' Hint = 'Top border'
Top = 0 Top = 0
Caption = 'Top' Caption = 'Top'
@ -327,32 +329,8 @@ object Form1: TForm1
ImageIndex = 26 ImageIndex = 26
Style = tbsDropDown Style = tbsDropDown
end end
object FontnameCombo: TsFontNameCombobox
Left = 54
Height = 28
Top = 0
Width = 151
CellFormatItem = cfiFontName
WorkbookSource = WorkbookSource
ItemHeight = 20
ItemIndex = 41
TabOrder = 0
Text = 'Arial'
end
object sFontSizeCombobox1: TsFontSizeCombobox
Left = 205
Height = 28
Top = 0
Width = 60
CellFormatItem = cfiFontName
WorkbookSource = WorkbookSource
ItemHeight = 20
ItemIndex = 2
TabOrder = 1
Text = '10'
end
object ToolButton3: TToolButton object ToolButton3: TToolButton
Left = 739 Left = 783
Height = 26 Height = 26
Top = 0 Top = 0
Width = 5 Width = 5
@ -360,12 +338,12 @@ object Form1: TForm1
Style = tbsDivider Style = tbsDivider
end end
object ToolButton5: TToolButton object ToolButton5: TToolButton
Left = 833 Left = 906
Top = 0 Top = 0
Action = AcMergeCells Action = AcMergeCells
end end
object ToolButton36: TToolButton object ToolButton36: TToolButton
Left = 744 Left = 538
Top = 0 Top = 0
Action = AcWordWrap Action = AcWordWrap
end end
@ -382,12 +360,70 @@ object Form1: TForm1
Caption = 'ToolButton38' Caption = 'ToolButton38'
Style = tbsDivider Style = tbsDivider
end end
object FontnameCombo: TsCellCombobox
Left = 54
Height = 23
Hint = 'Cell font name'
Top = 0
Width = 130
CellFormatItem = cfiFontName
WorkbookSource = WorkbookSource
ItemIndex = 62
TabOrder = 0
Text = 'Arial'
end
object FontsizeCombo: TsCellCombobox
Left = 184
Height = 23
Hint = 'Cell font size'
Top = 0
Width = 48
CellFormatItem = cfiFontSize
WorkbookSource = WorkbookSource
ItemIndex = 2
TabOrder = 1
Text = '10'
end
object FontColorCombobox: TsCellCombobox
Left = 235
Height = 24
Hint = 'Font color'
Top = 0
Width = 48
CellFormatItem = cfiFontColor
ColorRectWidth = -1
WorkbookSource = WorkbookSource
ItemIndex = 0
TabOrder = 2
Text = 'black'
end
object BackgroundColorCombobox: TsCellCombobox
Left = 812
Height = 24
Hint = 'Background color'
Top = 0
Width = 48
CellFormatItem = cfiBackgroundColor
ColorRectWidth = -1
WorkbookSource = WorkbookSource
ItemIndex = 0
TabOrder = 3
Text = '(none)'
end
object ToolButton45: TToolButton
Left = 562
Height = 26
Top = 0
Width = 5
Caption = 'ToolButton45'
Style = tbsDivider
end
end end
object ToolBar2: TToolBar object ToolBar2: TToolBar
Left = 0 Left = 0
Height = 28 Height = 24
Top = 0 Top = 0
Width = 876 Width = 941
AutoSize = True AutoSize = True
ButtonHeight = 24 ButtonHeight = 24
ButtonWidth = 24 ButtonWidth = 24
@ -477,54 +513,12 @@ object Form1: TForm1
Caption = 'ToolButton44' Caption = 'ToolButton44'
Style = tbsDivider Style = tbsDivider
end end
object FontColorCombobox: TsCellCombobox
Left = 261
Height = 28
Top = 0
Width = 48
CellFormatItem = cfiFontColor
ColorRectWidth = -1
WorkbookSource = WorkbookSource
ItemHeight = 20
TabOrder = 0
end
object BackgroundColorCombobox: TsCellCombobox
Left = 309
Height = 28
Top = 0
Width = 48
CellFormatItem = cfiBackgroundColor
ColorRectWidth = -1
WorkbookSource = WorkbookSource
ItemHeight = 20
TabOrder = 1
end
object sCellCombobox3: TsCellCombobox
Left = 357
Height = 28
Top = 0
Width = 124
CellFormatItem = cfiFontName
WorkbookSource = WorkbookSource
ItemHeight = 20
TabOrder = 2
end
object sCellCombobox4: TsCellCombobox
Left = 481
Height = 28
Top = 0
Width = 50
CellFormatItem = cfiFontSize
WorkbookSource = WorkbookSource
ItemHeight = 20
TabOrder = 3
end
end end
object ToolBar3: TToolBar object ToolBar3: TToolBar
Left = 0 Left = 0
Height = 28 Height = 28
Top = 56 Top = 50
Width = 876 Width = 941
AutoSize = True AutoSize = True
Caption = 'ToolBar3' Caption = 'ToolBar3'
Constraints.MinHeight = 28 Constraints.MinHeight = 28
@ -542,7 +536,7 @@ object Form1: TForm1
TabOrder = 0 TabOrder = 0
object CellIndicator: TsCellIndicator object CellIndicator: TsCellIndicator
Left = 0 Left = 0
Height = 28 Height = 23
Top = 0 Top = 0
Width = 138 Width = 138
Align = alTop Align = alTop
@ -555,7 +549,7 @@ object Form1: TForm1
Left = 144 Left = 144
Height = 24 Height = 24
Top = 0 Top = 0
Width = 732 Width = 797
Align = alClient Align = alClient
BorderSpacing.Bottom = 2 BorderSpacing.Bottom = 2
TabOrder = 1 TabOrder = 1
@ -573,8 +567,8 @@ object Form1: TForm1
Cursor = crVSplit Cursor = crVSplit
Left = 0 Left = 0
Height = 5 Height = 5
Top = 84 Top = 78
Width = 876 Width = 941
Align = alTop Align = alTop
ResizeAnchor = akTop ResizeAnchor = akTop
end end

View File

@ -185,13 +185,11 @@ type
AcCellBorderTopBottomDbl: TsCellBorderAction; AcCellBorderTopBottomDbl: TsCellBorderAction;
AcCellBorderAll: TsCellBorderAction; AcCellBorderAll: TsCellBorderAction;
AcCellBorderAllVert: TsCellBorderAction; AcCellBorderAllVert: TsCellBorderAction;
FontnameCombo: TsFontnameCombobox;
AcCopyFormat: TsCopyFormatAction; AcCopyFormat: TsCopyFormatAction;
FontColorCombobox: TsCellCombobox; FontColorCombobox: TsCellCombobox;
BackgroundColorCombobox: TsCellCombobox; BackgroundColorCombobox: TsCellCombobox;
sCellCombobox3: TsCellCombobox; FontnameCombo: TsCellCombobox;
sCellCombobox4: TsCellCombobox; FontsizeCombo: TsCellCombobox;
sFontSizeCombobox1: TsFontSizeCombobox;
AcMergeCells: TsMergeAction; AcMergeCells: TsMergeAction;
Splitter2: TSplitter; Splitter2: TSplitter;
Splitter3: TSplitter; Splitter3: TSplitter;
@ -246,6 +244,7 @@ type
ToolButton42: TToolButton; ToolButton42: TToolButton;
ToolButton43: TToolButton; ToolButton43: TToolButton;
ToolButton44: TToolButton; ToolButton44: TToolButton;
ToolButton45: TToolButton;
ToolButton5: TToolButton; ToolButton5: TToolButton;
ToolButton6: TToolButton; ToolButton6: TToolButton;
ToolButton7: TToolButton; ToolButton7: TToolButton;

View File

@ -1616,6 +1616,9 @@ begin
FLastRowIndex := 0; FLastRowIndex := 0;
FLastColIndex := 0; FLastColIndex := 0;
FActiveCellRow := Cardinal(-1);
FActiveCellCol := Cardinal(-1);
FOptions := [soShowGridLines, soShowHeaders]; FOptions := [soShowGridLines, soShowHeaders];
end; end;
@ -3670,12 +3673,12 @@ end;
-------------------------------------------------------------------------------} -------------------------------------------------------------------------------}
procedure TsWorksheet.SelectCell(ARow, ACol: Cardinal); procedure TsWorksheet.SelectCell(ARow, ACol: Cardinal);
begin begin
if (ARow <> FActiveCellRow) or (ACol <> FActiveCellCol) then //if (ARow <> FActiveCellRow) or (ACol <> FActiveCellCol) then
begin //begin
FActiveCellRow := ARow; FActiveCellRow := ARow;
FActiveCellCol := ACol; FActiveCellCol := ACol;
if Assigned(FOnSelectCell) then FOnSelectCell(Self, ARow, ACol); if Assigned(FOnSelectCell) then FOnSelectCell(Self, ARow, ACol);
end; //end;
end; end;
{@@ ---------------------------------------------------------------------------- {@@ ----------------------------------------------------------------------------
@ -3684,7 +3687,7 @@ end;
-------------------------------------------------------------------------------} -------------------------------------------------------------------------------}
procedure TsWorksheet.ClearSelection; procedure TsWorksheet.ClearSelection;
begin begin
SetLength(FSelection, 0); SetLength(FSelection, 0);
end; end;
{@@ ---------------------------------------------------------------------------- {@@ ----------------------------------------------------------------------------

View File

@ -262,14 +262,15 @@ type
// procedure UpdateCombo; // procedure UpdateCombo;
protected protected
procedure ApplyFormatToCell(ACell: PCell); virtual; procedure ApplyFormatToCell(ACell: PCell); virtual;
procedure Change; override;
procedure DrawItem(AIndex: Integer; ARect: TRect; procedure DrawItem(AIndex: Integer; ARect: TRect;
AState: TOwnerDrawState); override; AState: TOwnerDrawState); override;
procedure ExtractFromCell(ACell: PCell); virtual; procedure ExtractFromCell(ACell: PCell); virtual;
function GetActiveCell: PCell; function GetActiveCell: PCell;
// function GetItemHeight: Integer; override;
procedure Loaded; override; procedure Loaded; override;
procedure Notification(AComponent: TComponent; Operation: TOperation); override; procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure Populate; virtual; procedure Populate; virtual;
procedure ProcessItem;
procedure Select; override; procedure Select; override;
property Items stored false; property Items stored false;
public public
@ -297,7 +298,7 @@ type
property AutoCompleteText; property AutoCompleteText;
property AutoDropDown; property AutoDropDown;
property AutoSelect; property AutoSelect;
property AutoSize;// Note: windows has a fixed height in some styles property AutoSize; // Note: windows has a fixed height in some styles
property BidiMode; property BidiMode;
property BorderSpacing; property BorderSpacing;
property BorderStyle; property BorderStyle;
@ -310,7 +311,7 @@ type
property DropDownCount; property DropDownCount;
property Enabled; property Enabled;
property Font; property Font;
property ItemHeight; // property ItemHeight;
property ItemIndex; property ItemIndex;
// property Items; // property Items;
property ItemWidth; property ItemWidth;
@ -350,7 +351,7 @@ type
property ParentFont; property ParentFont;
property ParentShowHint; property ParentShowHint;
property PopupMenu; property PopupMenu;
property ReadOnly; // property ReadOnly;
property ShowHint; property ShowHint;
property Sorted; property Sorted;
// property Style; // property Style;
@ -389,7 +390,7 @@ type
property DropDownCount; property DropDownCount;
property Enabled; property Enabled;
property Font; property Font;
property ItemHeight; // property ItemHeight;
property ItemIndex; property ItemIndex;
// property Items; // property Items;
property ItemWidth; property ItemWidth;
@ -429,7 +430,7 @@ type
property ParentFont; property ParentFont;
property ParentShowHint; property ParentShowHint;
property PopupMenu; property PopupMenu;
property ReadOnly; // property ReadOnly;
property ShowHint; property ShowHint;
property Sorted; property Sorted;
// property Style; // property Style;
@ -658,9 +659,6 @@ begin
InternalCreateNewWorkbook; InternalCreateNewWorkbook;
FWorksheet := FWorkbook.AddWorksheet('Sheet1'); FWorksheet := FWorkbook.AddWorksheet('Sheet1');
SelectWorksheet(FWorksheet); SelectWorksheet(FWorksheet);
// notify listeners
// NotifyListeners([lniWorkbook, lniWorksheet, lniSelection]);
end; end;
{@@ ---------------------------------------------------------------------------- {@@ ----------------------------------------------------------------------------
@ -815,7 +813,9 @@ procedure TsWorkbookSource.Loaded;
begin begin
inherited; inherited;
if (FFileName <> '') then if (FFileName <> '') then
SetFileName(FFilename); SetFileName(FFilename)
else
CreateNewWorkbook;
end; end;
{@@ ---------------------------------------------------------------------------- {@@ ----------------------------------------------------------------------------
@ -1149,6 +1149,8 @@ end;
-------------------------------------------------------------------------------} -------------------------------------------------------------------------------}
procedure TsWorkbookSource.WorksheetSelectedHandler(Sender: TObject; procedure TsWorkbookSource.WorksheetSelectedHandler(Sender: TObject;
AWorksheet: TsWorksheet); AWorksheet: TsWorksheet);
var
r, c: Cardinal;
begin begin
FWorksheet := AWorksheet; FWorksheet := AWorksheet;
if FWorksheet <> nil then if FWorksheet <> nil then
@ -1157,7 +1159,13 @@ begin
FWorksheet.OnChangeFont := @CellFontChangedHandler; FWorksheet.OnChangeFont := @CellFontChangedHandler;
FWorksheet.OnSelectCell := @CellSelectedHandler; FWorksheet.OnSelectCell := @CellSelectedHandler;
NotifyListeners([lniWorksheet]); NotifyListeners([lniWorksheet]);
SelectCell(FWorksheet.ActiveCellRow, FWorksheet.ActiveCellCol); if FWorksheet.ActiveCellRow = Cardinal(-1) then
r := FWorksheet.TopPaneHeight else
r := FWorksheet.ActiveCellRow;
if FWorksheet.ActiveCellCol = Cardinal(-1) then
c := FWorksheet.LeftPaneWidth else
c := FWorksheet.ActiveCellCol;
SelectCell(r, c);
end else end else
NotifyListeners([lniWorksheet]); NotifyListeners([lniWorksheet]);
end; end;
@ -1580,6 +1588,7 @@ constructor TsCellCombobox.Create(AOwner: TComponent);
begin begin
inherited Create(AOwner); inherited Create(AOwner);
FColorRectWidth := 10; FColorRectWidth := 10;
ItemHeight := -1;
end; end;
{@@ ---------------------------------------------------------------------------- {@@ ----------------------------------------------------------------------------
@ -1602,21 +1611,24 @@ var
clr: TColor; clr: TColor;
sclr: TsColor; sclr: TsColor;
begin begin
if (ItemIndex = -1) or (Worksheet = nil) then if (Worksheet = nil) then
exit; exit;
case FFormatItem of case FFormatItem of
cfiFontName: cfiFontName:
if Text <> '' then
begin begin
fnt := Worksheet.ReadCellFont(ACell); fnt := Worksheet.ReadCellFont(ACell);
Worksheet.WriteFont(ACell, Items[ItemIndex], fnt.Size, fnt.Style, fnt.Color); Worksheet.WriteFont(ACell, Text, fnt.Size, fnt.Style, fnt.Color);
end; end;
cfiFontSize: cfiFontSize:
if Text <> '' then
begin begin
fnt := Worksheet.ReadCellFont(ACell); fnt := Worksheet.ReadCellFont(ACell);
Worksheet.WriteFont(ACell, fnt.FontName, StrToFloat(Items[ItemIndex]), fnt.Style, fnt.Color); Worksheet.WriteFont(ACell, fnt.FontName, StrToFloat(Text), fnt.Style, fnt.Color);
end; end;
cfiFontColor: cfiFontColor:
if ItemIndex > -1 then
begin begin
fnt := Worksheet.ReadCellFont(ACell); fnt := Worksheet.ReadCellFont(ACell);
clr := PtrInt(Items.Objects[ItemIndex]); clr := PtrInt(Items.Objects[ItemIndex]);
@ -1637,6 +1649,17 @@ begin
end; end;
end; end;
{@@ ----------------------------------------------------------------------------
The text of the currently selected combobox item has been changed.
Calls "ProcessValue" to changes the selected cells according to the
Mode property by calling ApplyFormatToCell.
-------------------------------------------------------------------------------}
procedure TsCellCombobox.Change;
begin
inherited;
ProcessItem;
end;
{@@ ---------------------------------------------------------------------------- {@@ ----------------------------------------------------------------------------
Customdraws an item in the combobox. This is overridden to paint a color box Customdraws an item in the combobox. This is overridden to paint a color box
for the color-related format items. for the color-related format items.
@ -1868,22 +1891,29 @@ begin
end; end;
{@@ ---------------------------------------------------------------------------- {@@ ----------------------------------------------------------------------------
A new item in the combobox is selected. Changes the selected cells according Processes the selected combobox item after a new item has been selected or the
to the Mode property by calling ApplyFormatToCell. item text has been edited.
Changes the selected cells according to the Mode property by calling
ApplyFormatToCell.
-------------------------------------------------------------------------------} -------------------------------------------------------------------------------}
procedure TsCellCombobox.Select; procedure TsCellCombobox.ProcessItem;
var var
r, c: Cardinal; r, c: Cardinal;
range: Integer; range: Integer;
sel: TsCellRangeArray; sel: TsCellRangeArray;
cell: PCell; cell: PCell;
begin begin
inherited Select;
// UpdateCombo;
if Worksheet = nil then if Worksheet = nil then
exit; exit;
sel := Worksheet.GetSelection; sel := Worksheet.GetSelection;
if Length(sel) = 0 then
begin
SetLength(sel, 1);
sel[0].Col1 := Worksheet.ActiveCellCol;
sel[0].Row1 := Worksheet.ActiveCellRow;
sel[0].Col2 := sel[0].Col1;
sel[0].Row2 := sel[0].Row2;
end;
for range := 0 to High(sel) do for range := 0 to High(sel) do
for r := sel[range].Row1 to sel[range].Row2 do for r := sel[range].Row1 to sel[range].Row2 do
for c := sel[range].Col1 to sel[range].Col2 do for c := sel[range].Col1 to sel[range].Col2 do
@ -1893,6 +1923,16 @@ begin
end; end;
end; end;
{@@ ----------------------------------------------------------------------------
A new item in the combobox is selected. Calls "ProcessValue" to changes the
selected cells according to the Mode property by calling ApplyFormatToCell.
-------------------------------------------------------------------------------}
procedure TsCellCombobox.Select;
begin
inherited Select;
ProcessItem;
end;
{@@ ---------------------------------------------------------------------------- {@@ ----------------------------------------------------------------------------
Setter method for the ColorRectWidth property Setter method for the ColorRectWidth property
-------------------------------------------------------------------------------} -------------------------------------------------------------------------------}
@ -1911,9 +1951,14 @@ procedure TsCellCombobox.SetFormatItem(AValue: TsCellFormatItem);
begin begin
FFormatItem := AValue; FFormatItem := AValue;
if FFormatItem in [cfiFontColor, cfiBackgroundColor, cfiBorderColor] then if FFormatItem in [cfiFontColor, cfiBackgroundColor, cfiBorderColor] then
inherited Style := csOwnerDrawFixed begin
else inherited Style := csOwnerDrawFixed;
ReadOnly := true;
end else
begin
inherited Style := csDropdown; inherited Style := csDropdown;
ReadOnly := false;
end;
Populate; Populate;
if FWorkbookSource <> nil then if FWorkbookSource <> nil then