You've already forked lazarus-ccr
fpspreadsheet: Add properties TextRotation(s) to TsWorksheetGrid and use in fpsgrid demo.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3038 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -126,14 +126,13 @@
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="mainform"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="204"/>
|
||||
<CursorPos X="28" Y="223"/>
|
||||
<TopLine Value="356"/>
|
||||
<CursorPos X="40" Y="375"/>
|
||||
<UsageCount Value="200"/>
|
||||
<Bookmarks Count="1">
|
||||
<Item0 X="49" Y="470" ID="1"/>
|
||||
<Item0 X="49" Y="494" ID="1"/>
|
||||
</Bookmarks>
|
||||
<Loaded Value="True"/>
|
||||
<LoadedDesigner Value="True"/>
|
||||
@ -143,18 +142,19 @@
|
||||
<UnitName Value="fpspreadsheet"/>
|
||||
<EditorIndex Value="3"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="228"/>
|
||||
<CursorPos X="36" Y="241"/>
|
||||
<TopLine Value="146"/>
|
||||
<CursorPos X="3" Y="165"/>
|
||||
<UsageCount Value="98"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit2>
|
||||
<Unit3>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<UnitName Value="fpspreadsheetgrid"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<EditorIndex Value="2"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="65"/>
|
||||
<CursorPos X="60" Y="87"/>
|
||||
<TopLine Value="131"/>
|
||||
<CursorPos X="29" Y="155"/>
|
||||
<UsageCount Value="99"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit3>
|
||||
@ -558,95 +558,127 @@
|
||||
<UsageCount Value="14"/>
|
||||
</Unit54>
|
||||
</Units>
|
||||
<JumpHistory Count="22" HistoryIndex="21">
|
||||
<JumpHistory Count="30" HistoryIndex="29">
|
||||
<Position1>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="701" Column="22" TopLine="694"/>
|
||||
<Caret Line="1146" Column="56" TopLine="1127"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="701" Column="32" TopLine="681"/>
|
||||
<Caret Line="1149" Column="53" TopLine="1127"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="704" Column="1" TopLine="693"/>
|
||||
<Caret Line="1158" Column="61" TopLine="1140"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="710" Column="1" TopLine="686"/>
|
||||
<Caret Line="1727" Column="25" TopLine="1708"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="748" Column="1" TopLine="715"/>
|
||||
<Caret Line="1" Column="1" TopLine="1"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="1709" Column="38" TopLine="1709"/>
|
||||
<Caret Line="45" Column="37" TopLine="13"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="1" Column="1" TopLine="1"/>
|
||||
<Caret Line="1137" Column="55" TopLine="1135"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="45" Column="49" TopLine="13"/>
|
||||
<Caret Line="1727" Column="22" TopLine="1708"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="1161" Column="41" TopLine="1135"/>
|
||||
<Caret Line="1755" Column="19" TopLine="1737"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="1164" Column="21" TopLine="1129"/>
|
||||
<Caret Line="1154" Column="1" TopLine="1135"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="1146" Column="56" TopLine="1127"/>
|
||||
<Caret Line="1142" Column="19" TopLine="1133"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="1149" Column="53" TopLine="1127"/>
|
||||
<Caret Line="1929" Column="3" TopLine="1898"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="1158" Column="61" TopLine="1140"/>
|
||||
<Caret Line="1730" Column="1" TopLine="1713"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="1727" Column="25" TopLine="1708"/>
|
||||
<Caret Line="56" Column="61" TopLine="39"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="1" Column="1" TopLine="1"/>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<Caret Line="213" Column="17" TopLine="204"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="45" Column="37" TopLine="13"/>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<Caret Line="214" Column="17" TopLine="205"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="1137" Column="55" TopLine="1135"/>
|
||||
<Caret Line="1418" Column="79" TopLine="1416"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="1727" Column="22" TopLine="1708"/>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<Caret Line="239" Column="19" TopLine="206"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="1755" Column="19" TopLine="1737"/>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<Caret Line="240" Column="19" TopLine="207"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="1154" Column="1" TopLine="1135"/>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<Caret Line="139" Column="15" TopLine="121"/>
|
||||
</Position20>
|
||||
<Position21>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="1142" Column="19" TopLine="1133"/>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<Caret Line="592" Column="56" TopLine="558"/>
|
||||
</Position21>
|
||||
<Position22>
|
||||
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
|
||||
<Caret Line="1929" Column="3" TopLine="1898"/>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<Caret Line="593" Column="56" TopLine="559"/>
|
||||
</Position22>
|
||||
<Position23>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<Caret Line="594" Column="56" TopLine="560"/>
|
||||
</Position23>
|
||||
<Position24>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<Caret Line="595" Column="56" TopLine="561"/>
|
||||
</Position24>
|
||||
<Position25>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<Caret Line="596" Column="56" TopLine="562"/>
|
||||
</Position25>
|
||||
<Position26>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<Caret Line="597" Column="56" TopLine="563"/>
|
||||
</Position26>
|
||||
<Position27>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<Caret Line="371" Column="65" TopLine="352"/>
|
||||
</Position27>
|
||||
<Position28>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<Caret Line="187" Column="18" TopLine="166"/>
|
||||
</Position28>
|
||||
<Position29>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<Caret Line="374" Column="30" TopLine="356"/>
|
||||
</Position29>
|
||||
<Position30>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<Caret Line="375" Column="40" TopLine="356"/>
|
||||
</Position30>
|
||||
</JumpHistory>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
|
@ -512,6 +512,25 @@ object Form1: TForm1
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00
|
||||
}
|
||||
end
|
||||
object MnuTextRotation: TMenuItem
|
||||
Caption = 'Text rotation'
|
||||
object MenuItem29: TMenuItem
|
||||
Action = AcTextHoriz
|
||||
AutoCheck = True
|
||||
end
|
||||
object MenuItem30: TMenuItem
|
||||
Action = AcTextVertCW
|
||||
AutoCheck = True
|
||||
end
|
||||
object MenuItem31: TMenuItem
|
||||
Action = AcTextVertCCW
|
||||
AutoCheck = True
|
||||
end
|
||||
object MenuItem32: TMenuItem
|
||||
Action = AcTextStacked
|
||||
AutoCheck = True
|
||||
end
|
||||
end
|
||||
object MnuHorAlignment: TMenuItem
|
||||
Caption = 'Horizontal alignment'
|
||||
object MnuHorDefault: TMenuItem
|
||||
@ -1976,6 +1995,39 @@ object Form1: TForm1
|
||||
Hint = 'Wrap text'
|
||||
OnExecute = AcWordwrapExecute
|
||||
end
|
||||
object AcTextHoriz: TAction
|
||||
Tag = 130
|
||||
Category = 'Format'
|
||||
AutoCheck = True
|
||||
Caption = 'Horizontal'
|
||||
Checked = True
|
||||
Hint = 'Use horizontal text'
|
||||
OnExecute = AcTextRotationExecute
|
||||
end
|
||||
object AcTextVertCW: TAction
|
||||
Tag = 131
|
||||
Category = 'Format'
|
||||
AutoCheck = True
|
||||
Caption = '90° clockwise'
|
||||
Hint = 'Text rotated by 90° clockwise'
|
||||
OnExecute = AcTextRotationExecute
|
||||
end
|
||||
object AcTextVertCCW: TAction
|
||||
Tag = 132
|
||||
Category = 'Format'
|
||||
AutoCheck = True
|
||||
Caption = '90° counter-clockwise'
|
||||
Hint = 'Text rotated by 90° counter-clockwise'
|
||||
OnExecute = AcTextRotationExecute
|
||||
end
|
||||
object AcTextStacked: TAction
|
||||
Tag = 133
|
||||
Category = 'Format'
|
||||
AutoCheck = True
|
||||
Caption = 'Stacked characters'
|
||||
Hint = 'Text characters stacked'
|
||||
OnExecute = AcTextRotationExecute
|
||||
end
|
||||
end
|
||||
object FontDialog1: TFontDialog
|
||||
MinFontSize = 0
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -42,6 +42,10 @@ type
|
||||
AcBorderAll: TAction;
|
||||
AcBorderOuter: TAction;
|
||||
AcBorderOuterMedium: TAction;
|
||||
AcTextHoriz: TAction;
|
||||
AcTextVertCW: TAction;
|
||||
AcTextVertCCW: TAction;
|
||||
AcTextStacked: TAction;
|
||||
AcWordwrap: TAction;
|
||||
AcVAlignDefault: TAction;
|
||||
AcVAlignTop: TAction;
|
||||
@ -79,6 +83,11 @@ type
|
||||
MenuItem26: TMenuItem;
|
||||
MenuItem27: TMenuItem;
|
||||
MenuItem28: TMenuItem;
|
||||
MenuItem29: TMenuItem;
|
||||
MenuItem30: TMenuItem;
|
||||
MenuItem31: TMenuItem;
|
||||
MenuItem32: TMenuItem;
|
||||
MnuTextRotation: TMenuItem;
|
||||
MenuItem3: TMenuItem;
|
||||
MenuItem4: TMenuItem;
|
||||
MenuItem5: TMenuItem;
|
||||
@ -137,6 +146,7 @@ type
|
||||
procedure AcFontExecute(Sender: TObject);
|
||||
procedure AcFontStyleExecute(Sender: TObject);
|
||||
procedure AcHorAlignmentExecute(Sender: TObject);
|
||||
procedure AcTextRotationExecute(Sender: TObject);
|
||||
procedure AcVertAlignmentExecute(Sender: TObject);
|
||||
procedure AcWordwrapExecute(Sender: TObject);
|
||||
procedure CbShowHeadersClick(Sender: TObject);
|
||||
@ -156,6 +166,7 @@ type
|
||||
procedure LoadFile(const AFileName: String);
|
||||
procedure UpdateFontActions(AFont: TsFont);
|
||||
procedure UpdateHorAlignmentActions;
|
||||
procedure UpdateTextRotationActions;
|
||||
procedure UpdateVertAlignmentActions;
|
||||
procedure UpdateWordwraps;
|
||||
public
|
||||
@ -173,6 +184,7 @@ uses
|
||||
const
|
||||
HORALIGN_TAG = 100;
|
||||
VERTALIGN_TAG = 110;
|
||||
TEXTROT_TAG = 130;
|
||||
|
||||
LEFT_BORDER_THIN = $0001;
|
||||
LEFT_BORDER_THICK = $0002;
|
||||
@ -352,6 +364,18 @@ begin
|
||||
UpdateHorAlignmentActions;
|
||||
end;
|
||||
|
||||
procedure TForm1.AcTextRotationExecute(Sender: TObject);
|
||||
var
|
||||
text_rot: TsTextRotation;
|
||||
begin
|
||||
if TAction(Sender).Checked then
|
||||
text_rot := TsTextRotation(TAction(Sender).Tag - TEXTROT_TAG)
|
||||
else
|
||||
text_rot := trHorizontal;
|
||||
with sWorksheetGrid1 do TextRotations[Selection] := text_rot;
|
||||
UpdateTextRotationActions;
|
||||
end;
|
||||
|
||||
procedure TForm1.AcVertAlignmentExecute(Sender: TObject);
|
||||
var
|
||||
vert_align: TsVertAlignment;
|
||||
@ -561,6 +585,20 @@ begin
|
||||
AcFontStrikeout.Checked := fssStrikeOut in AFont.Style;
|
||||
end;
|
||||
|
||||
procedure TForm1.UpdateTextRotationActions;
|
||||
var
|
||||
i: Integer;
|
||||
ac: TAction;
|
||||
text_rot: TsTextRotation;
|
||||
begin
|
||||
with sWorksheetGrid1 do text_rot := TextRotations[Selection];
|
||||
for i:=0 to ActionList1.ActionCount-1 do begin
|
||||
ac := TAction(ActionList1.Actions[i]);
|
||||
if (ac.Tag >= TEXTROT_TAG) and (ac.Tag < TEXTROT_TAG+10) then
|
||||
ac.Checked := ((ac.Tag - TEXTROT_TAG) = ord(text_rot));
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.UpdateVertAlignmentActions;
|
||||
var
|
||||
i: Integer;
|
||||
|
@ -43,6 +43,8 @@ type
|
||||
procedure ChangedCellHandler(ASender: TObject; ARow, ACol: Cardinal);
|
||||
procedure ChangedFontHandler(ASender: TObject; ARow, ACol: Cardinal);
|
||||
procedure FixNeighborCellBorders(ACol, ARow: Integer);
|
||||
|
||||
// Setter/Getter
|
||||
function GetCellBorder(ACol, ARow: Integer): TsCellBorders;
|
||||
function GetCellBorders(ARect: TGridRect): TsCellBorders;
|
||||
function GetCellBorderStyle(ACol, ARow: Integer; ABorder: TsCellBorder): TsCellBorderStyle;
|
||||
@ -51,6 +53,8 @@ type
|
||||
function GetHorAlignments(ARect: TGridRect): TsHorAlignment;
|
||||
function GetShowGridLines: Boolean;
|
||||
function GetShowHeaders: Boolean;
|
||||
function GetTextRotation(ACol, ARow: Integer): TsTextRotation;
|
||||
function GetTextRotations(ARect: TGridRect): TsTextRotation;
|
||||
function GetVertAlignment(ACol, ARow: Integer): TsVertAlignment;
|
||||
function GetVertAlignments(ARect: TGridRect): TsVertAlignment;
|
||||
function GetWordwrap(ACol, ARow: Integer): Boolean;
|
||||
@ -65,6 +69,8 @@ type
|
||||
procedure SetHorAlignments(ARect: TGridRect; AValue: TsHorAlignment);
|
||||
procedure SetShowGridLines(AValue: Boolean);
|
||||
procedure SetShowHeaders(AValue: Boolean);
|
||||
procedure SetTextRotation(ACol, ARow: Integer; AValue: TsTextRotation);
|
||||
procedure SetTextRotations(ARect: TGridRect; AValue: TsTextRotation);
|
||||
procedure SetVertAlignment(ACol, ARow: Integer; AValue: TsVertAlignment);
|
||||
procedure SetVertAlignments(ARect: TGridRect; AValue: TsVertAlignment);
|
||||
procedure SetWordwrap(ACol, ARow: Integer; AValue: boolean);
|
||||
@ -143,6 +149,10 @@ type
|
||||
read GetHorAlignment write SetHorAlignment;
|
||||
property HorAlignments[ARect: TGridRect]: TsHorAlignment
|
||||
read GetHorAlignments write SetHorAlignments;
|
||||
property TextRotation[ACol, ARow: Integer]: TsTextRotation
|
||||
read GetTextRotation write SetTextRotation;
|
||||
property TextRotations[ARect: TGridRect]: TsTextRotation
|
||||
read GetTextRotations write SetTextRotations;
|
||||
property VertAlignment[ACol, ARow: Integer]: TsVertAlignment
|
||||
read GetVertAlignment write SetVertAlignment;
|
||||
property VertAlignments[ARect: TGridRect]: TsVertAlignment
|
||||
@ -1409,6 +1419,35 @@ begin
|
||||
Result := FHeaderCount <> 0;
|
||||
end;
|
||||
|
||||
function TsCustomWorksheetGrid.GetTextRotation(ACol, ARow: Integer): TsTextRotation;
|
||||
var
|
||||
cell: PCell;
|
||||
begin
|
||||
Result := trHorizontal;
|
||||
if Assigned(FWorksheet) then begin
|
||||
cell := FWorksheet.FindCell(GetWorksheetRow(ARow), GetWorksheetCol(ACol));
|
||||
if (cell <> nil) then
|
||||
Result := cell^.TextRotation;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TsCustomWorksheetGrid.GetTextRotations(ARect: TGridRect): TsTextRotation;
|
||||
var
|
||||
c, r: Integer;
|
||||
textrot: TsTextRotation;
|
||||
begin
|
||||
Result := GetTextRotation(ARect.Left, ARect.Top);
|
||||
textrot := Result;
|
||||
for c := ARect.Left to ARect.Right do
|
||||
for r := ARect.Top to ARect.Bottom do begin
|
||||
Result := GetTextRotation(c, r);
|
||||
if Result <> textrot then begin
|
||||
Result := trHorizontal;
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TsCustomWorksheetGrid.GetVertAlignment(ACol, ARow: Integer): TsVertAlignment;
|
||||
var
|
||||
cell: PCell;
|
||||
@ -1671,6 +1710,28 @@ begin
|
||||
Setup;
|
||||
end;
|
||||
|
||||
procedure TsCustomWorksheetGrid.SetTextRotation(ACol, ARow: Integer;
|
||||
AValue: TsTextRotation);
|
||||
begin
|
||||
if Assigned(FWorkbook) then
|
||||
FWorksheet.WriteTextRotation(GetWorksheetRow(ARow), GetWorksheetCol(ACol), AValue);
|
||||
end;
|
||||
|
||||
procedure TsCustomWorksheetGrid.SetTextRotations(ARect: TGridRect;
|
||||
AValue: TsTextRotation);
|
||||
var
|
||||
c,r: Integer;
|
||||
begin
|
||||
BeginUpdate;
|
||||
try
|
||||
for c := ARect.Left to ARect.Right do
|
||||
for r := ARect.Top to ARect.Bottom do
|
||||
SetTextRotation(c, r, AValue);
|
||||
finally
|
||||
EndUpdate;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TsCustomWorksheetGrid.Setup;
|
||||
var
|
||||
i: Integer;
|
||||
|
Reference in New Issue
Block a user