📄 teeedigene.pas
字号:
{**********************************************}
{ TCustomChart (or derived) Editor Dialog }
{ Copyright (c) 1996-2007 by David Berneda }
{**********************************************}
unit TeeEdiGene;
{$I TeeDefs.inc}
interface
uses {$IFNDEF LINUX}
Windows, Messages,
{$ENDIF}
SysUtils, Classes,
{$IFDEF CLX}
Qt, QGraphics, QControls, QForms, QDialogs, QStdCtrls, QExtCtrls, QComCtrls,
{$ELSE}
Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, ComCtrls, Buttons,
{$ENDIF}
Chart, TeCanvas, TeePenDlg, TeeProcs, TeeNavigator, TeeEdiFont;
type
TFormTeeGeneral = class(TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
LSteps: TLabel;
Label1: TLabel;
CBAllowZoom: TCheckBox;
CBAnimatedZoom: TCheckBox;
SEAniZoomSteps: TEdit;
UDAniZoomSteps: TUpDown;
BZoomPen: TButtonPen;
BZoomColor: TButton;
EMinPix: TEdit;
UDMinPix: TUpDown;
TabSheet2: TTabSheet;
RGPanning: TRadioGroup;
Label2: TLabel;
CBDir: TComboFlat;
Label3: TLabel;
CBZoomMouse: TComboFlat;
Label4: TLabel;
CBScrollMouse: TComboFlat;
CBUpLeft: TCheckBox;
TabCursor: TTabSheet;
Label6: TLabel;
CBCursor: TComboFlat;
GroupBox1: TGroupBox;
ImageCursor: TImage;
TabFont: TTabSheet;
LBFonts: TListBox;
Panel1: TPanel;
PanelFont: TPanel;
Splitter1: TSplitter;
BLoad: TButton;
OpenDialog1: TOpenDialog;
procedure CBAllowZoomClick(Sender: TObject);
procedure CBAnimatedZoomClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure RGPanningClick(Sender: TObject);
procedure SEAniZoomStepsChange(Sender: TObject);
procedure BZoomColorClick(Sender: TObject);
procedure EMinPixChange(Sender: TObject);
procedure CBDirChange(Sender: TObject);
procedure CBZoomMouseChange(Sender: TObject);
procedure CBScrollMouseChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure CBCursorChange(Sender: TObject);
procedure CBUpLeftClick(Sender: TObject);
procedure LBFontsClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormDeactivate(Sender: TObject);
procedure LBFontsKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure PageControl1Change(Sender: TObject);
procedure BLoadClick(Sender: TObject);
private
{ Private declarations }
IBackup : TTeeFont;
IFont : TTeeFont;
IFontEditor : TTeeFontEditor;
OldChange : TNotifyEvent;
procedure ChangeCursor(ACursor:TCursor);
procedure ChangedFont(Sender: TObject);
Procedure EnableZoomControls;
{$IFDEF D6}
procedure FillFonts;
{$ENDIF}
procedure ResetIFont;
function SelectedFont(Index:Integer):TTeeFont;
public
{ Public declarations }
TheChart : TCustomChart;
Constructor CreateChart(Owner:TComponent; AChart:TCustomChart);
end;
// 5.03 Moved here from TeeNavigator.pas unit.
// Now TeeNavigator is an abstract class.
TChartPageNavigator=class(TCustomTeeNavigator)
private
function GetChart: TCustomChart;
procedure SetChart(const Value: TCustomChart);
protected
procedure BtnClick(Index: TTeeNavigateBtn); override;
procedure DoTeeEvent(Event: TTeeEvent); override;
procedure SetPanel(const Value: TCustomTeePanel); override;
public
procedure EnableButtons; override;
Function PageCount:Integer; override;
procedure Print; override;
published
property Chart:TCustomChart read GetChart write SetChart;
property OnButtonClicked;
end;
Procedure ChartPreview(AOwner:TComponent; TeePanel:TCustomTeePanel);
implementation
{$IFNDEF CLX}
{$IFNDEF LCL}
{$R *.DFM}
{$ENDIF}
{$ELSE}
{$R *.xfm}
{$ENDIF}
uses
{$IFDEF D6}
TypInfo,
{$ENDIF}
{$IFDEF CLX}
TeePreviewPanel,
{$ENDIF}
TeeConst, TeEngine, TeeStore, TeeBrushDlg, TeePrevi;
Procedure ChartPreview(AOwner:TComponent; TeePanel:TCustomTeePanel);
Begin
with TChartPreview.Create(AOwner) do
try
PageNavigatorClass:=TChartPageNavigator;
TeePreviewPanel1.Panel:=TeePanel;
ShowModal;
finally
Free;
TeePanel.Repaint;
end;
end;
{ Chart General Editor }
Constructor TFormTeeGeneral.CreateChart(Owner:TComponent; AChart:TCustomChart);
begin
inherited Create(Owner);
TheChart:=AChart;
end;
Procedure TFormTeeGeneral.EnableZoomControls;
begin
EnableControls(TheChart.Zoom.Allow,[ CBAnimatedZoom, UDAniZoomSteps,
SEAniZoomSteps,EMinPix,UDMinPix,
BZoomPen,BZoomColor,CBDir,CBZoomMouse,
CBUpLeft]);
end;
procedure TFormTeeGeneral.CBAllowZoomClick(Sender: TObject);
begin
TheChart.Zoom.Allow:=CBAllowZoom.Checked;
EnableZoomControls;
end;
procedure TFormTeeGeneral.CBAnimatedZoomClick(Sender: TObject);
begin
TheChart.Zoom.Animated:=CBAnimatedZoom.Checked;
end;
procedure TFormTeeGeneral.FormShow(Sender: TObject);
begin
if Assigned(TheChart) then
With TheChart do
begin
RGPanning.ItemIndex :=Ord(AllowPanning);
With Zoom do
begin
CBAllowZoom.Checked :=Allow;
CBAnimatedZoom.Checked :=Animated;
UDAniZoomSteps.Position:=AnimatedSteps;
EnableZoomControls;
UDMinPix.Position :=MinimumPixels;
CBDir.ItemIndex :=Ord(Direction);
CBZoomMouse.ItemIndex :=Ord(MouseButton);
CBUpLeft.Checked :=UpLeftZooms;
BZoomPen.LinkPen(Pen);
end;
CBScrollMouse.ItemIndex :=Ord(ScrollMouseButton);
CBScrollMouse.Enabled :=AllowPanning<>pmNone;
TeeFillCursors(CBCursor,Cursor);
TeePreviewCursor(Cursor,ImageCursor.Picture);
{$IFNDEF CLX}
BLoad.Visible:=not (csDesigning in ComponentState);
{$ENDIF}
{$IFDEF D6}
FillFonts;
{$ENDIF}
end;
end;
{$IFDEF D6}
function FontOfPersistent(Instance:TPersistent; FilterOut:TPersistent=nil):TTeeFont;
var t : Integer;
n : Integer;
tmpProps : {$IFDEF CLR}TPropList{$ELSE}PPropList{$ENDIF};
tmpProp : TObject;
begin
result:=nil;
{$IFDEF CLR}
tmpProps:=GetPropList(Instance);
n:=Length(tmpProps);
{$ELSE}
n:=GetPropList(Instance,tmpProps);
{$ENDIF}
if n>0 then
try
for t:=0 to n-1 do
with tmpProps[t]{$IFNDEF CLR}^{$ENDIF} do
if ({$IFDEF CLR}TypeInfo.TypeKind{$ELSE}PropType^.Kind{$ENDIF}=tkClass) {$IFNDEF CLR}and Assigned(GetProc){$ENDIF} then
begin
tmpProp:=GetObjectProp(Instance,tmpProps[t]);
if tmpProp is TTeeFont then
begin
if tmpProp<>FilterOut then
begin
result:=TTeeFont(tmpProp);
break;
end;
end
else
if tmpProp is TPersistent then
if not (tmpProp is TComponent) then
begin
result:=FontOfPersistent(TPersistent(tmpProp),FilterOut);
if Assigned(result) then
break;
end;
end;
finally
{$IFDEF CLR}
tmpProps:=nil;
{$ELSE}
FreeMemory(tmpProps);
{$ENDIF}
end;
end;
procedure TFormTeeGeneral.FillFonts;
procedure AddAxis(const Description:String; Axis:TChartAxis);
begin
with LBFonts.Items do
begin
AddObject(Description,Axis.LabelsFont);
AddObject(Description+' ('+TeeMsg_AxisTitle+')',Axis.Title.Font);
end;
end;
var t : Integer;
tmp : TPersistent;
begin
with LBFonts.Items do
begin
Clear;
AddObject('Legend',TheChart.Legend.Font);
AddObject('Legend title',TheChart.Legend.Title.Font);
AddObject('Title',TheChart.Title.Font);
AddObject('Footer',TheChart.Foot.Font);
AddObject('SubTitle',TheChart.SubTitle.Font);
AddObject('SubFooter',TheChart.SubFoot.Font);
for t:=0 to TheChart.SeriesCount-1 do
begin
tmp:=FontOfPersistent(TheChart[t],TheChart[t].Marks.Font);
if Assigned(tmp) then
AddObject(SeriesTitleOrName(TheChart[t]),tmp);
AddObject(SeriesTitleOrName(TheChart[t])+' (marks)',TheChart[t].Marks.Font);
end;
for t:=0 to TheChart.Tools.Count-1 do
begin
tmp:=FontOfPersistent(TheChart.Tools[t]);
if Assigned(tmp) then
AddObject(TheChart.Tools[t].Name,tmp);
end;
end;
// Do not translate string constants
AddAxis('Left axis',TheChart.Axes.Left);
AddAxis('Right axis',TheChart.Axes.Right);
AddAxis('Top axis',TheChart.Axes.Top);
AddAxis('Bottom axis',TheChart.Axes.Bottom);
AddAxis('Depth Top axis',TheChart.Axes.DepthTop);
AddAxis('Depth axis',TheChart.Axes.Depth);
for t:=0 to TheChart.CustomAxes.Count-1 do
AddAxis('Custom axis '+IntToStr(t),TheChart.CustomAxes[t]);
LBFonts.ItemIndex:=LBFonts.Items.IndexOfObject(TheChart.Title.Font);
LBFonts.Selected[LBFonts.ItemIndex]:=True;
LBFontsClick(LBFonts);
end;
{$ENDIF}
procedure TFormTeeGeneral.RGPanningClick(Sender: TObject);
begin
TheChart.AllowPanning:=TPanningMode(RGPanning.ItemIndex);
CBScrollMouse.Enabled:=TheChart.AllowPanning<>pmNone;
end;
procedure TFormTeeGeneral.SEAniZoomStepsChange(Sender: TObject);
begin
if Showing then
TheChart.Zoom.AnimatedSteps:=UDAniZoomSteps.Position;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -