📄 frxcrosseditor.pas
字号:
if (X > 118) and (X < 133) then
begin
if FCurList = RowsLB then
Memo := FCross.RowTotalMemos[FCurList.ItemIndex + 1] else
Memo := FCross.ColumnTotalMemos[FCurList.ItemIndex + 1];
Memo.Visible := not Memo.Visible;
end;
if (X > 183) and (X < 198) then
begin
if FCurList = RowsLB then
sort := FCross.RowSort[FCurList.ItemIndex] else
sort := FCross.ColumnSort[FCurList.ItemIndex];
for i := 0 to SortPopup.Items.Count - 1 do
if SortPopup.Items[i].Tag = Integer(sort) then
SortPopup.Items[i].Checked := True;
pt := FCurList.ClientToScreen(Point(X, Y));
SortPopup.Popup(pt.X, pt.Y);
end;
FCurList.Invalidate;
ReflectChanges;
end;
procedure TfrxCrossEditorForm.PaintBoxMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
FSelectedPoint := Point(X, Y);
FSelectedObject := nil;
DrawCross;
UpdateControls;
end;
procedure TfrxCrossEditorForm.UpdateControls;
var
DMPFontStyle: TfrxDMPFontStyles;
procedure SetEnabled(cAr: array of TControl; Enabled: Boolean);
var
i: Integer;
begin
for i := 0 to High(cAr) do
begin
cAr[i].Enabled := Enabled;
if (cAr[i] is TToolButton) and not Enabled then
TToolButton(cAr[i]).Down := False;
end;
end;
begin
SetEnabled([AlignLeftB, AlignCenterB, AlignRightB, RotationB, HighlightB,
FormatB], FSelectedObject <> nil);
if FSelectedObject <> nil then
begin
AlignLeftB.Down := FSelectedObject.HAlign = haLeft;
AlignCenterB.Down := FSelectedObject.HAlign = haCenter;
AlignRightB.Down := FSelectedObject.HAlign = haRight;
RotationB.Enabled := FSelectedObject.Tag >= 100;
end;
DMPFontStyle := [];
if FSelectedObject is TfrxDMPMemoView then
DMPFontStyle := TfrxDMPMemoView(FSelectedObject).FontStyle;
BoldMI.Checked := fsxBold in DMPFontStyle;
ItalicMI.Checked := fsxItalic in DMPFontStyle;
UnderlineMI.Checked := fsxUnderline in DMPFontStyle;
SuperScriptMI.Checked := fsxSuperScript in DMPFontStyle;
SubScriptMI.Checked := fsxSubScript in DMPFontStyle;
CondensedMI.Checked := fsxCondensed in DMPFontStyle;
WideMI.Checked := fsxWide in DMPFontStyle;
N12cpiMI.Checked := fsx12cpi in DMPFontStyle;
N15cpiMI.Checked := fsx15cpi in DMPFontStyle;
end;
procedure TfrxCrossEditorForm.ToolButtonClick(Sender: TObject);
var
i: Integer;
AllMemos: TList;
procedure EditFont;
var
i: Integer;
m: TfrxCustomMemoView;
begin
with TFontDialog.Create(Application) do
begin
if FSelectedObject <> nil then
Font := FSelectedObject.Font;
Options := Options + [fdForceFontExist];
if Execute then
if FSelectedObject <> nil then
FSelectedObject.Font := Font
else
for i := 0 to AllMemos.Count - 1 do
begin
m := AllMemos[i];
m.Font.Name := Font.Name;
m.Font.Size := Font.Size;
m.Font.Color := Font.Color;
m.Font.Charset := Font.Charset;
end;
Free;
end;
end;
procedure EditFormat;
begin
with TfrxFormatEditorForm.Create(Owner) do
begin
Format.Assign(FSelectedObject.DisplayFormat);
if ShowModal = mrOk then
FSelectedObject.DisplayFormat := Format;
Free;
end;
end;
procedure EditHighlight;
begin
with TfrxHighlightEditorForm.Create(Owner) do
begin
MemoView := FSelectedObject;
if ShowModal = mrOk then
FSelectedObject.Highlight := MemoView.Highlight;
Free;
end;
end;
procedure EditFrame;
var
i: Integer;
m: TfrxCustomMemoView;
begin
with TfrxFrameEditorForm.Create(Owner) do
begin
if FSelectedObject <> nil then
Frame.Assign(FSelectedObject.Frame);
if ShowModal = mrOk then
if FSelectedObject <> nil then
FSelectedObject.Frame := Frame
else
for i := 0 to AllMemos.Count - 1 do
begin
m := AllMemos[i];
m.Frame := Frame;
end;
Free;
end;
end;
procedure SetFillColor(c: TColor);
var
i: Integer;
m: TfrxCustomMemoView;
begin
if FSelectedObject <> nil then
FSelectedObject.Color := c
else
for i := 0 to AllMemos.Count - 1 do
begin
m := AllMemos[i];
m.Color := c;
end;
end;
procedure SetDMPFontStyle(fStyle: TfrxDMPFontStyle; Include: Boolean);
var
i: Integer;
m: TfrxCustomMemoView;
procedure DoSetStyle(m: TfrxCustomMemoView);
var
Style: TfrxDMPFontStyles;
begin
Style := TfrxDMPMemoView(m).FontStyle;
if not Include then
Style := Style + [fStyle] else
Style := Style - [fStyle];
TfrxDMPMemoView(m).FontStyle := Style;
end;
begin
if FSelectedObject <> nil then
DoSetStyle(FSelectedObject)
else
for i := 0 to AllMemos.Count - 1 do
begin
m := AllMemos[i];
DoSetStyle(m);
end;
end;
begin
AllMemos := TList.Create;
for i := 0 to CROSS_DIM_SIZE - 1 do
begin
AllMemos.Add(FCross.CellMemos[i]);
AllMemos.Add(FCross.ColumnMemos[i]);
AllMemos.Add(FCross.ColumnTotalMemos[i]);
AllMemos.Add(FCross.RowMemos[i]);
AllMemos.Add(FCross.RowTotalMemos[i]);
end;
case TComponent(Sender).Tag of
1: { Font }
EditFont;
2, 3, 4: { Align }
FSelectedObject.HAlign := TfrxHAlign(TControl(Sender).Tag - 2);
5: { Rotation }
FSelectedObject.Rotation := TMenuItem(Sender).HelpContext;
6: { Highlight }
EditHighlight;
7: { Format }
EditFormat;
8: { Frame }
EditFrame;
9: { Fill Color setup }
with TfrxColorSelector.Create(TComponent(Sender)) do
begin
OnColorChanged := ToolButtonClick;
Tag := 90;
end;
34: SetDMPFontStyle(fsxBold, BoldMI.Checked);
35: SetDMPFontStyle(fsxItalic, ItalicMI.Checked);
36: SetDMPFontStyle(fsxUnderline, UnderlineMI.Checked);
37: SetDMPFontStyle(fsxSuperScript, SuperScriptMI.Checked);
38: SetDMPFontStyle(fsxSubScript, SubScriptMI.Checked);
39: SetDMPFontStyle(fsxCondensed, CondensedMI.Checked);
40: SetDMPFontStyle(fsxWide, WideMI.Checked);
41: SetDMPFontStyle(fsx12cpi, N12cpiMI.Checked);
42: SetDMPFontStyle(fsx15cpi, N15cpiMI.Checked);
90: { Fill Color }
SetFillColor(TfrxColorSelector(Sender).Color);
end;
AllMemos.Free;
UpdateControls;
DrawCross;
end;
procedure TfrxCrossEditorForm.PaintBoxDblClick(Sender: TObject);
begin
{ edit only total memos }
if (FSelectedObject <> nil) and (FSelectedObject.Tag >= 300) then
with TfrxMemoEditorForm.Create(Owner) do
begin
MemoView := FSelectedObject;
if ShowModal = mrOk then
FSelectedObject.Text := Memo.Text;
Free;
end;
end;
procedure TfrxCrossEditorForm.CBClick(Sender: TObject);
begin
if FUpdating then Exit;
case TControl(Sender).Tag of
0: FCross.ShowRowHeader := RowHeaderCB.Checked;
1: FCross.ShowColumnHeader := ColumnHeaderCB.Checked;
2: FCross.ShowRowTotal := RowTotalCB.Checked;
3: FCross.ShowColumnTotal := ColumnTotalCB.Checked;
end;
ReflectChanges;
end;
procedure TfrxCrossEditorForm.DimesionsChange(Sender: TObject);
begin
if FUpdating then Exit;
case TControl(Sender).Tag of
0: FCross.RowLevels := StrToInt(RowsE.Text);
1: FCross.ColumnLevels := StrToInt(ColumnsE.Text);
2: FCross.CellLevels := StrToInt(CellsE.Text);
end;
RowsLB.Items := FCross.RowFields;
ColumnsLB.Items := FCross.ColumnFields;
CellsLB.Items := FCross.CellFields;
ReflectChanges;
end;
procedure TfrxCrossEditorForm.CellsLBDrawItem(Control: TWinControl;
Index: Integer; ARect: TRect; State: TOwnerDrawState);
begin
with TListBox(Control), TListBox(Control).Canvas do
begin
FillRect(ARect);
TextOut(ARect.Left + 2, ARect.Top + 1, Items[Index]);
TextOut(ARect.Left + 200, ARect.Top + 1, FFuncNames[FCross.CellFunctions[Index]]);
Pen.Color := clGray;
Brush.Color := clWindow;
Rectangle(ARect.Left + 185, ARect.Top + 3, ARect.Left + 196, ARect.Top + 14);
Pen.Color := clBlack;
with ARect do
begin
MoveTo(Left + 187, Top + 7); LineTo(Left + 194, Top + 7);
MoveTo(Left + 188, Top + 8); LineTo(Left + 193, Top + 8);
MoveTo(Left + 189, Top + 9); LineTo(Left + 192, Top + 9);
MoveTo(Left + 190, Top + 10); LineTo(Left + 191, Top + 10);
end;
end;
end;
procedure TfrxCrossEditorForm.FuncMIClick(Sender: TObject);
begin
if CellsLB.ItemIndex = -1 then Exit;
FCross.CellFunctions[CellsLB.ItemIndex] := TfrxCrossFunction(TControl(Sender).Tag);
CellsLB.Invalidate;
CellsLB.EndDrag(False);
end;
procedure TfrxCrossEditorForm.CellsLBMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
i: Integer;
f: TfrxCrossFunction;
pt: TPoint;
begin
if CellsLB.ItemIndex = -1 then Exit;
if (X > 183) and (X < 198) then
begin
f := FCross.CellFunctions[CellsLB.ItemIndex];
for i := 0 to FuncPopup.Items.Count - 1 do
if FuncPopup.Items[i].Tag = Integer(f) then
FuncPopup.Items[i].Checked := True;
pt := CellsLB.ClientToScreen(Point(X, Y));
FuncPopup.Popup(pt.X, pt.Y);
end;
end;
procedure TfrxCrossEditorForm.StyleCBClick(Sender: TObject);
var
i: Integer;
Style: TfrxStyles;
AllMemos: TList;
begin
Style := FStyleSheet.Find(StyleCB.Text);
if Style = nil then Exit;
AllMemos := TList.Create;
for i := 0 to CROSS_DIM_SIZE - 1 do
begin
AllMemos.Add(FCross.CellMemos[i]);
AllMemos.Add(FCross.ColumnMemos[i]);
AllMemos.Add(FCross.ColumnTotalMemos[i]);
AllMemos.Add(FCross.RowMemos[i]);
AllMemos.Add(FCross.RowTotalMemos[i]);
end;
for i := 0 to AllMemos.Count - 1 do
TfrxCustomMemoView(AllMemos[i]).ApplyStyle(
Style.Find(TfrxCustomMemoView(AllMemos[i]).Style));
AllMemos.Free;
ScrollBox1.SetFocus;
DrawCross;
end;
procedure TfrxCrossEditorForm.SortMIClick(Sender: TObject);
begin
if FCurList.ItemIndex = -1 then Exit;
if FCurList = ColumnsLB then
FCross.ColumnSort[FCurList.ItemIndex] := TfrxCrossSortOrder(TControl(Sender).Tag) else
FCross.RowSort[FCurList.ItemIndex] := TfrxCrossSortOrder(TControl(Sender).Tag);
FCurList.Invalidate;
FCurList.EndDrag(False);
end;
procedure TfrxCrossEditorForm.SwapBClick(Sender: TObject);
var
sl: TStrings;
begin
sl := TStringList.Create;
sl.Assign(RowsLB.Items);
RowsLB.Items := ColumnsLB.Items;
ColumnsLB.Items := sl;
sl.Free;
ReflectChanges;
end;
procedure TfrxCrossEditorForm.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = VK_F1 then
frxResources.Help(Self);
end;
initialization
frxComponentEditors.Register(TfrxCrossView, TfrxCrossEditor);
frxComponentEditors.Register(TfrxDBCrossView, TfrxCrossEditor);
end.
//<censored>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -