{**********************************************}
{  TCustomChart (or derived) Editor Dialog     }
{  Copyright (c) 1996-2020 by Steema Software  }
{**********************************************}
unit TeeEdiAxis;
{$I TeeDefs.inc}

interface

uses {$IFNDEF LINUX}
     Windows, Messages,
     {$ENDIF}
     SysUtils, Classes,

     Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls, ExtCtrls, Buttons,

     TeEngine, TeeEdiFont, TeCanvas, TeeProcs, TeePenDlg, TeeCustomShapeEditor,
     TeeMargins;

type
  TFormTeeAxis = class(TForm)
    PageAxis: TPageControl;
    TabScales: TTabSheet;
    TabTitle: TTabSheet;
    TabLabels: TTabSheet;
    TabTicks: TTabSheet;
    TabPositions: TTabSheet;
    Label41: TLabel;
    Label42: TLabel;
    Label43: TLabel;
    EPos: TEdit;
    EStart: TEdit;
    EEnd: TEdit;
    UDPos: TUpDown;
    UDStart: TUpDown;
    UDEnd: TUpDown;
    TabGrids: TTabSheet;
    CBOtherSide: TCheckBox;
    CBHorizAxis: TCheckBox;
    PageTitle: TPageControl;
    TabTitleStyle: TTabSheet;
    L14: TLabel;
    ETitle: TEdit;
    L3: TLabel;
    SETitleAngle: TEdit;
    UDTitleAngle: TUpDown;
    L9: TLabel;
    SETitleSize: TEdit;
    UDTitleSize: TUpDown;
    CBTitleVisible: TCheckBox;
    PageLabels: TPageControl;
    TabLabStyle: TTabSheet;
    CBLabels: TCheckBox;
    CBMultiline: TCheckBox;
    CBOnAxis: TCheckBox;
    CBRoundFirst: TCheckBox;
    SELabelsSize: TEdit;
    L26: TLabel;
    L23: TLabel;
    SELabelsAngle: TEdit;
    UDLabelsAngle: TUpDown;
    UDLabelsSize: TUpDown;
    L20: TLabel;
    SESepar: TEdit;
    UDSepar: TUpDown;
    TabLabelsFormat: TTabSheet;
    PanelAxes: TPanel;
    TabLabFormat: TTabSheet;
    LabelAxisFormat: TLabel;
    CBFormat: TComboFlat;
    CBExpo: TCheckBox;
    CBLabelAlign: TCheckBox;
    Splitter1: TSplitter;
    Panel2: TPanel;
    BAdd: TSpeedButton;
    BDelete: TSpeedButton;
    Panel4: TPanel;
    CBShow: TCheckBox;
    CBAxisBeh: TCheckBox;
    Label1: TLabel;
    LBAxes: TListBox;
    LabelZ: TLabel;
    Edit1: TEdit;
    UDZ: TUpDown;
    PageScales: TPageControl;
    TabMin: TTabSheet;
    TabMax: TTabSheet;
    CBAutoMax: TCheckBox;
    BAxisMax: TButton;
    CBAutoMin: TCheckBox;
    BAxisMin: TButton;
    Label4: TLabel;
    EMinOff: TEdit;
    UDMinOff: TUpDown;
    Label5: TLabel;
    EMaxOff: TEdit;
    UDMaxOff: TUpDown;
    Label7: TLabel;
    CBPosUnits: TComboFlat;
    Label3: TLabel;
    CBLabelStyle: TComboFlat;
    CBAlternate: TCheckBox;
    Button1: TButton;
    TabIncrement: TTabSheet;
    BIncre: TButton;
    L6: TLabel;
    TabOptions: TTabSheet;
    CBAutomatic: TCheckBox;
    CBLogarithmic: TCheckBox;
    CBVisible: TCheckBox;
    CBInverted: TCheckBox;
    Label2: TLabel;
    ELogBase: TEdit;
    LogE: TCheckBox;
    CBShowAll: TCheckBox;
    CBMinRound: TCheckBox;
    CBMaxRound: TCheckBox;
    TabTitleFormat: TTabSheet;
    PageTitleFormat: TPageControl;
    CBLabelsBehind: TCheckBox;
    TabItems: TTabSheet;
    ListItems: TListBox;
    PanelItems: TPanel;
    Panel3: TPanel;
    CBItemsAuto: TCheckBox;
    Splitter2: TSplitter;
    PageControl2: TPageControl;
    TabGridBorder: TTabSheet;
    TabGridMinor: TTabSheet;
    Panel5: TPanel;
    Label6: TLabel;
    Label8: TLabel;
    Edit2: TEdit;
    UDGridZ: TUpDown;
    CBGridCentered: TCheckBox;
    EMarksEvery: TEdit;
    UDEvery: TUpDown;
    Panel6: TPanel;
    L31: TLabel;
    SEMinorCount: TEdit;
    UDMinorCount: TUpDown;
    CBAutoInc: TCheckBox;
    TabAxisBorder: TTabSheet;
    PageTicks: TPageControl;
    TabOuter: TTabSheet;
    TabInner: TTabSheet;
    TabMinor: TTabSheet;
    Panel7: TPanel;
    L28: TLabel;
    SEAxisTickLength: TEdit;
    CBTickOnLabels: TCheckBox;
    UDAxisTickLength: TUpDown;
    Panel8: TPanel;
    Label12: TLabel;
    Edit4: TEdit;
    UDInnerTicksLength: TUpDown;
    Panel9: TPanel;
    L30: TLabel;
    Label9: TLabel;
    SEAxisMinorTickLen: TEdit;
    UDAxisMinorTickLen: TUpDown;
    Edit3: TEdit;
    UDMinorC: TUpDown;
    EIncrement: TEdit;
    EAxisMin: TEdit;
    EAxisMax: TEdit;
    Panel10: TPanel;
    Label10: TLabel;
    Label11: TLabel;
    EItemValue: TEdit;
    AxisItemText: TMemo;
    TabMargins: TTabSheet;
    TabBack: TTabSheet;
    Label13: TLabel;
    CBLabelsPos: TComboFlat;
    RGTitlePos: TRadioGroup;
    CBGridAlways: TCheckBox;
    Label14: TLabel;
    CBTitleFormat: TComboFlat;
    SBAddItem: TSpeedButton;
    SBDeleteItem: TSpeedButton;
    LInvalidValue: TLabel;
    LBSubAxis: TListBox;
    Splitter3: TSplitter;
    Panel1: TPanel;
    BAddSub: TSpeedButton;
    BDeleteSub: TSpeedButton;
    MainPanel: TPanel;
    Label15: TLabel;
    EMargin: TEdit;
    UDMargin: TUpDown;
    CBImages: TCheckBox;
    procedure FormShow(Sender: TObject);
    procedure CBVisibleClick(Sender: TObject);
    procedure SEAxisTickLengthChange(Sender: TObject);
    procedure CBAutomaticClick(Sender: TObject);
    procedure ETitleChange(Sender: TObject);
    procedure BAxisMaxClick(Sender: TObject);
    procedure BAxisMinClick(Sender: TObject);
    procedure BIncreClick(Sender: TObject);
    procedure CBLogarithmicClick(Sender: TObject);
    procedure SEAxisMinorTickLenChange(Sender: TObject);
    procedure SEMinorCountChange(Sender: TObject);
    procedure CBAutoMaxClick(Sender: TObject);
    procedure CBInvertedClick(Sender: TObject);
    procedure SETitleAngleChange(Sender: TObject);
    procedure SETitleSizeChange(Sender: TObject);
    procedure CBLabelsClick(Sender: TObject);
    procedure SELabelsAngleChange(Sender: TObject);
    procedure RGLabelStyleClick(Sender: TObject);
    procedure SELabelsSizeChange(Sender: TObject);
    procedure CBOnAxisClick(Sender: TObject);
    procedure SESeparChange(Sender: TObject);
    procedure CBRoundFirstClick(Sender: TObject);
    procedure CBTickOnLabelsClick(Sender: TObject);
    procedure CBGridCenteredClick(Sender: TObject);
    procedure CBMultilineClick(Sender: TObject);
    procedure PageAxisChange(Sender: TObject);
    procedure CBShowClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure PageAxisChanging(Sender: TObject; var AllowChange: Boolean);
    procedure EPosChange(Sender: TObject);
    procedure EStartChange(Sender: TObject);
    procedure EEndChange(Sender: TObject);
    procedure LBAxesClick(Sender: TObject);
    procedure BAddClick(Sender: TObject);
    procedure CBOtherSideClick(Sender: TObject);
    procedure BDeleteClick(Sender: TObject);
    procedure CBHorizAxisClick(Sender: TObject);
    procedure ELogBaseChange(Sender: TObject);
    procedure CBTitleVisibleClick(Sender: TObject);
    procedure CBFormatChange(Sender: TObject);
    procedure CBExpoClick(Sender: TObject);
    procedure CBAxisBehClick(Sender: TObject);
    procedure CBLabelAlignClick(Sender: TObject);
    procedure Edit1Change(Sender: TObject);
    procedure EMinOffChange(Sender: TObject);
    procedure EMaxOffChange(Sender: TObject);
    procedure LogEClick(Sender: TObject);
    procedure Edit2Change(Sender: TObject);
    procedure CBPosUnitsChange(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure CBAlternateClick(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure EMarksEveryChange(Sender: TObject);
    procedure CBShowAllClick(Sender: TObject);
    procedure CBMinRoundClick(Sender: TObject);
    procedure CBMaxRoundClick(Sender: TObject);
    procedure Edit3Change(Sender: TObject);
    procedure PageTitleFormatChange(Sender: TObject);
    procedure PageLabelsChange(Sender: TObject);
    procedure PageTitleChange(Sender: TObject);
    procedure CBLabelsBehindClick(Sender: TObject);
    procedure ListItemsClick(Sender: TObject);
    procedure EItemValueChange(Sender: TObject);
    procedure CBItemsAutoClick(Sender: TObject);
    procedure AxisItemTextChange(Sender: TObject);
    procedure CBAutoIncClick(Sender: TObject);
    procedure Edit4Change(Sender: TObject);
    procedure PageTicksChange(Sender: TObject);
    procedure EIncrementChange(Sender: TObject);
    procedure EAxisMinChange(Sender: TObject);
    procedure EAxisMaxChange(Sender: TObject);
    procedure CBLabelsPosChange(Sender: TObject);
    procedure RGTitlePosClick(Sender: TObject);
    procedure CBGridAlwaysClick(Sender: TObject);
    procedure CBTitleFormatChange(Sender: TObject);
    procedure SBAddItemClick(Sender: TObject);
    procedure SBDeleteItemClick(Sender: TObject);
    procedure BDeleteSubClick(Sender: TObject);
    procedure LBSubAxisClick(Sender: TObject);
    procedure BAddSubClick(Sender: TObject);
    procedure PageAxisGetImageIndex(Sender: TObject; TabIndex: Integer;
      var ImageIndex: Integer);
    procedure EMarginChange(Sender: TObject);
    procedure CBImagesClick(Sender: TObject);
  private
    { Private declarations }
    CreatingForm  : Boolean;

    IChangingItems,
    IChangingAuto : Boolean;

    ILabelsFormat : TFormTeeShape;
    ILabelsMargins: TMarginsEditor;
    IBack         : TFormTeeShape;
    ITitleEditor  : TFormTeeShape;
    IItemsFormat  : TFormTeeShape;

    IAxisEditor      : TPenDialog;
    IOuterEditor     : TPenDialog;
    IInnerEditor     : TPenDialog;
    IMinorEditor     : TPenDialog;
    IGridEditor      : TPenDialog;
    IMinorGridEditor : TPenDialog;

    procedure AddAxisItem(Index:Integer);
    procedure AddAxisItems;
    procedure AddSubAxes;
    procedure EditAxisMaxMin(Const ATitle:String; const ACheckBox:TCheckBox;
                             IsMax:Boolean);
    Procedure EnableLogBaseControls;
    function SelectedMainAxis:TChartAxis;
    Procedure SetAxisIndex;
    Procedure SetAxisScales;
    procedure SetScaleEdit(const Value:Double; const AEdit:TEdit);
  public
    { Public declarations }
    TheAxis : TChartAxis;
    NotifyCustom : TNotifyEvent;

    Constructor CreateAxis(const AOwner:TComponent; const AAxis:TChartAxis);
  end;

procedure TeeAddAxes(const AChart:TCustomAxisPanel; const AList:TStrings; AddDepth:Boolean); overload;
procedure TeeAddAxes(const AChart:TCustomAxisPanel; const AList:TStrings; AddDepth:Boolean; AddAll: Boolean); overload;

implementation

{$IFNDEF LCL}
{$R *.DFM}
{$ELSE}
{$R *.lfm}
{$ENDIF}

Uses
  TeeConst, TeeAxisIncr, TeeBrushDlg, TeeAxMaxMin, Chart, TeeFormatting,
  Math;

{$IFDEF D15}
{$DEFINE TEEFORMAT}
{$ENDIF}

{$IFDEF LCL}
{$DEFINE TEEFORMAT}
{$ENDIF}

procedure TeeAddAxes(const AChart:TCustomAxisPanel; const AList:TStrings; AddDepth:Boolean);
begin
  TeeAddAxes(AChart, AList, AddDepth, False);
end;

procedure TeeAddAxes(const AChart:TCustomAxisPanel; const AList:TStrings; AddDepth:Boolean; AddAll: Boolean);
var t : Integer;
begin
  With AList do
  begin
    Clear;

    if AddAll then
       Add(TeeMsg_All);

    Add(TeeMsg_LeftAxis);
    Add(TeeMsg_RightAxis);
    Add(TeeMsg_TopAxis);
    Add(TeeMsg_BottomAxis);

    if AddDepth then
    begin
      Add(TeeMsg_DepthAxis);
      Add(TeeMsg_DepthTopAxis);
    end;

    if Assigned(AChart) then
    for t:=TeeInitialCustomAxis to AChart.Axes.Count-1 do
        Add(TeeMsg_CustomAxesEditor+IntToStr(t-TeeInitialCustomAxis));
  end;
end;

Constructor TFormTeeAxis.CreateAxis(const AOwner:TComponent; const AAxis:TChartAxis);
begin
  CreatingForm:=True;
  inherited Create(AOwner);
  IChangingAuto:=False;
  TheAxis:=AAxis;
end;

Procedure TFormTeeAxis.SetAxisIndex;
begin
  With TheAxis.ParentChart,LBAxes do
  if TheAxis=LeftAxis   then ItemIndex:=0 else
  if TheAxis=RightAxis  then ItemIndex:=1 else
  if TheAxis=TopAxis    then ItemIndex:=2 else
  if TheAxis=BottomAxis then ItemIndex:=3 else
  if TheAxis=DepthAxis  then ItemIndex:=4 else
  if TheAxis=DepthTopAxis then ItemIndex:=5 else
     ItemIndex:=Axes.IndexOf(TheAxis);
end;

procedure TFormTeeAxis.FormShow(Sender: TObject);
begin
  if Assigned(TheAxis) then
  begin
    //TabItems.TabVisible:=not (csDesigning in TheAxis.ParentChart.ComponentState);

    TeeAddAxes(TheAxis.ParentChart,LBAxes.Items,True);
    SetAxisIndex;

    AddSubAxes;

    CBShow.Checked:=TheAxis.ParentChart.Axes.Visible;
    CBAxisBeh.Checked:=TheAxis.ParentChart.Axes.Behind;

    PageAxis.ActivePage:=TabScales;
    PageLabels.ActivePage:=TabLabStyle;
    PageTitle.ActivePage:=TabTitleStyle;
    PageAxisChange(Self);
  end;
end;

procedure TFormTeeAxis.CBVisibleClick(Sender: TObject);
begin
  if not CreatingForm then
     TheAxis.Visible:=CBVisible.Checked;
end;

procedure TFormTeeAxis.SEAxisTickLengthChange(Sender: TObject);
begin
  if not CreatingForm then
     TheAxis.TickLength:=UDAxisTickLength.Position;
end;

procedure TFormTeeAxis.CBAutomaticClick(Sender: TObject);
begin
  if not IChangingAuto then
  begin
    With TheAxis do
    begin
      Automatic:=CBAutomatic.Checked;

      if Automatic then
         AdjustMaxMin
      else
      begin
        AutomaticMaximum:=False;
        AutomaticMinimum:=False;
      end;
    end;

    SetAxisScales;
  end;
end;

procedure TFormTeeAxis.ETitleChange(Sender: TObject);
{$IFDEF AXUNICODE}
  function CheckChars : Boolean;
  var i : Integer;
  Begin
    result:=True;
    if Pos('@U#',ETitle.Text)=1 then
      for i:=4 to Length(ETitle.Text) do
      Begin
        if not (((ETitle.Text[i]>='0') and (ETitle.Text[i]<='9'))
           or ((UpperCase(ETitle.Text[i])>='A') and (UpperCase(ETitle.Text[i])<='F'))
           or (ETitle.Text[i]=' ')) then
           result:=False;
      end;
  end;
{$ENDIF}
begin
{$IFDEF AXUNICODE}
  if not CheckChars then
    ETitle.Text:=Copy(ETitle.Text,2,Length(ETitle.Text));
{$ENDIF}
  TheAxis.Title.Caption:=ETitle.Text;
end;

procedure TFormTeeAxis.EditAxisMaxMin(Const ATitle:String; const ACheckBox:TCheckBox;
                                      IsMax:Boolean);
var tmp : TAxisMaxMin;
begin
  tmp:=TAxisMaxMin.Create(Self);

  with tmp do
  try
    Caption:=ATitle+' '+(TheAxis.ParentChart as TCustomChart).AxisTitleOrName(TheAxis);

    IsDateTime:=TheAxis.IsDateTime;

    if IsMax then MaxMin:=TheAxis.Maximum
             else MaxMin:=TheAxis.Minimum;

    TeeTranslateControl(tmp);

    if ShowModal=mrOk then
    Begin
      if IsMax then TheAxis.Maximum:=MaxMin
               else TheAxis.Minimum:=MaxMin;

      ACheckBox.Checked:=False;
      SetAxisScales;
    end;
  finally
    Free;
  end;
end;

procedure TFormTeeAxis.BAxisMaxClick(Sender: TObject);
begin
  EditAxisMaxMin(TeeMsg_Maximum,CBAutoMax,True);
end;

procedure TFormTeeAxis.BAxisMinClick(Sender: TObject);
begin
  EditAxisMaxMin(TeeMsg_Minimum,CBAutoMin,False);
end;

procedure TFormTeeAxis.BIncreClick(Sender: TObject);
begin
  if TAxisIncrement.ChangeIncrement(Owner,TheAxis) then
     SetAxisScales;
end;

procedure TFormTeeAxis.CBLogarithmicClick(Sender: TObject);
begin
  try
    try
      TheAxis.Logarithmic:=CBLogarithmic.Checked;
    except
      on AxisException do
      Begin
        TheAxis.Logarithmic:=False;
        CBLogarithmic.Checked:=False;
        Raise;
      end;
    end;
  finally
    EnableLogBaseControls;
  end;
end;

Procedure TFormTeeAxis.EnableLogBaseControls;
begin
  ELogBase.Enabled:=CBLogarithmic.Checked and CBLogarithmic.Enabled;
  LogE.Enabled:=ELogBase.Enabled;
end;

procedure TFormTeeAxis.SEAxisMinorTickLenChange(Sender: TObject);
begin
  if not CreatingForm then TheAxis.MinorTickLength:=UDAxisMinorTickLen.Position;
end;

procedure TFormTeeAxis.SEMinorCountChange(Sender: TObject);
begin
  if not CreatingForm then
     TheAxis.MinorTickCount:=UDMinorCount.Position;
end;

procedure TFormTeeAxis.CBAutoMaxClick(Sender: TObject);
begin
  if not IChangingAuto then
  begin
    With TheAxis do
    if Sender=CBAutoMax then
    begin
      AutomaticMaximum:=CBAutoMax.Checked;
      CBMaxRound.Enabled:=CBAutoMax.Checked;
    end
    else
    begin
      AutomaticMinimum:=CBAutoMin.Checked;
      CBMinRound.Enabled:=CBAutoMin.Checked;
    end;

    TheAxis.AdjustMaxMin;
    SetAxisScales;
  end;
end;

procedure TFormTeeAxis.CBInvertedClick(Sender: TObject);
begin
  TheAxis.Inverted:=CBInverted.Checked;
end;

procedure TFormTeeAxis.SETitleAngleChange(Sender: TObject);
begin
  if not CreatingForm then TheAxis.Title.Angle:=UDTitleAngle.Position;
end;

procedure TFormTeeAxis.SETitleSizeChange(Sender: TObject);
begin
  if not CreatingForm then TheAxis.TitleSize:=UDTitleSize.Position;
end;

procedure TFormTeeAxis.CBLabelsClick(Sender: TObject);
begin
  TheAxis.Labels:=CBLabels.Checked;
end;

procedure TFormTeeAxis.SELabelsAngleChange(Sender: TObject);
begin
  if not CreatingForm then TheAxis.LabelsAngle:=UDLabelsAngle.Position;
end;

procedure TFormTeeAxis.RGLabelStyleClick(Sender: TObject);
begin
  TheAxis.LabelStyle:=TAxisLabelStyle(CBLabelStyle.ItemIndex);
end;

procedure TFormTeeAxis.SELabelsSizeChange(Sender: TObject);
begin
  if not CreatingForm then TheAxis.LabelsSize:=UDLabelsSize.Position;
end;

procedure TFormTeeAxis.CBOnAxisClick(Sender: TObject);
begin
  TheAxis.LabelsOnAxis:=CBOnAxis.Checked;
end;

procedure TFormTeeAxis.SESeparChange(Sender: TObject);
begin
  if not CreatingForm then
  begin
    TheAxis.LabelsSeparation:=UDSepar.Position;
    CBShowAll.Checked:=TheAxis.LabelsSeparation=0;
  end;
end;

procedure TFormTeeAxis.CBRoundFirstClick(Sender: TObject);
begin
  TheAxis.RoundFirstLabel:=CBRoundFirst.Checked;
end;

procedure TFormTeeAxis.CBTickOnLabelsClick(Sender: TObject);
begin
  TheAxis.TickOnLabelsOnly:=CBTickOnLabels.Checked;
end;

procedure TFormTeeAxis.CBGridCenteredClick(Sender: TObject);
begin
  TheAxis.Grid.Centered:=CBGridCentered.Checked;
end;

procedure TFormTeeAxis.CBMultilineClick(Sender: TObject);
begin
  TheAxis.LabelsMultiLine:=CBMultiline.Checked;
end;

procedure TFormTeeAxis.SetScaleEdit(const Value:Double; const AEdit:TEdit);
begin
  if TheAxis.IsDateTime then
  begin
    if ((Value > DTMinValue) and (Value < DTMaxValue)) then
         AEdit.Text:=DateTimeToStr(Value)
    else
         AEdit.Text:=TimeToStr(Value);
  end
  else
    AEdit.Text:=FloatToStr(Value); // No formatting to allow manual editing
end;

Procedure TFormTeeAxis.SetAxisScales;
Begin
  With TheAxis do
  Begin
    EIncrement.Text:=GetIncrementText(Self,Increment,IsDateTime,ExactDateTime,AxisValuesFormat);

    EIncrement.Enabled:=not IsDateTime;

    CBAutoInc.Checked:=(Increment=0);
    CBAutoInc.Enabled:=not CBAutoInc.Checked;

    IChangingAuto:=True;

    //TF02014321
    SetScaleEdit(Minimum,EAxisMin);
    SetScaleEdit(Maximum,EAxisMax);

    EAxisMin.Enabled:=not IsDateTime;
    EAxisMax.Enabled:=not IsDateTime;

    CBAutomatic.Checked:=Automatic;
    CBAutoMax.Checked:=AutomaticMaximum;
    CBAutoMin.Checked:=AutomaticMinimum;
    UDMaxOff.Position:=MaximumOffset;
    UDMinOff.Position:=MinimumOffset;
    CBMaxRound.Checked:=MaximumRound;
    CBMinRound.Checked:=MinimumRound;
    CBMaxRound.Enabled:=AutomaticMaximum;
    CBMinRound.Enabled:=AutomaticMinimum;

    IChangingAuto:=False;

    CBLogarithmic.Checked:=Logarithmic;
    CBLogarithmic.Enabled:=not IsDepthAxis;
    LogE.Checked:=LogarithmicBase=Exp(1);
    eLogBase.Text:=FloatToStr(LogarithmicBase);

    EnableLogBaseControls;

    CBInverted.Checked:=Inverted;
    CBVisible.Checked:=Visible;

    CBShowAll.Checked:=LabelsSeparation=0;
  end;
end;

procedure TFormTeeAxis.AddAxisItem(Index:Integer);
var S : String;
begin
  S:=Trim(TheAxis.Items[Index].Text);

  if S='' then
     S:=FloatToStr(TheAxis.Items[Index].Value);

  ListItems.Items.Add(S);
end;

procedure TFormTeeAxis.AddAxisItems;
var t : Integer;
begin
  ListItems.Items.Clear;

  for t:=0 to TheAxis.Items.Count-1 do
      AddAxisItem(t);

  if ListItems.Items.Count>0 then
  begin
    ListItems.ItemIndex:=0;
    ListItemsClick(Self);
  end
  else
  begin
    EItemValue.Text:='';
    AxisItemText.Clear;
    FreeAndNil(IItemsFormat);
  end;
end;

procedure TFormTeeAxis.PageAxisChange(Sender: TObject);

  Procedure SetAxisLabels;
  var tmp : String;
  begin
    { Axis Labels  }

    with TheAxis.Texts do
    begin
      CBLabels.Checked:=Visible;
      CBLabelStyle.ItemIndex:=Ord(Style);
      CBOnAxis.Checked:=OnAxis;
      CBRoundFirst.Checked:=RoundFirst;
      UDLabelsAngle.Position:=Angle;
      UDMargin.Position:=MarginToAxis;

      UDSepar.Position:=Separation;
      UDLabelsSize.Position:=Size;
      CBMultiline.Checked:=MultiLine;
      CBExpo.Checked:=Exponent;

      CBFormat.Items.Clear;

      CBAlternate.Checked:=Alternate;
      CBLabelsBehind.Checked:=Behind;

      CBLabelsPos.ItemIndex:=Ord(Position);

      if Assigned(ILabelsFormat) then
         ILabelsFormat.RefreshControls(Format);

      if Assigned(ILabelsMargins) then
         ILabelsMargins.RefreshControls(Format.Margins);
   end;

   if Assigned(IBack) then
      IBack.RefreshControls(TheAxis.Shape);

   with TheAxis do
    if IsDateTime then
    begin
      With CBFormat.Items do
      if Maximum-Minimum<=1 then
      begin
        Add({$IFDEF TEEFORMAT}FormatSettings.{$ENDIF}ShortTimeFormat);
        Add({$IFDEF TEEFORMAT}FormatSettings.{$ENDIF}LongTimeFormat);
        Add('hh:nn');
        Add('hh:nn:ss');
        Add('hh:nn:ss.zzz');
      end
      else
      begin
        Add({$IFDEF TEEFORMAT}FormatSettings.{$ENDIF}ShortDateFormat);
        Add({$IFDEF TEEFORMAT}FormatSettings.{$ENDIF}LongDateFormat);
        Add('yyyy-mm-dd');
        Add('mm-dd-yyyy');
        Add('dd-mm-yyyy');
        Add('ddd');
        Add('dddd');
        Add('mmm');
        Add('mmmm');
      end;

      LabelAxisFormat.Caption:=TeeMsg_DateTimeFormat;
      tmp:=DateTimeFormat;
      if tmp='' then tmp:=DateTimeDefaultFormat(Maximum-Minimum);
    end
    else
    begin
      TFormatEditor.AddDefaultFormats(CBFormat.Items);
      LabelAxisFormat.Caption:=TeeMsg_ValuesFormat;
      tmp:=AxisValuesFormat;

      if tmp='' then
         tmp:=TeeMsg_DefValueFormat;

      tmp:=DelphiToLocalFormat(tmp);
    end;

    with CBFormat.Items do
    if IndexOf(tmp)=-1 then
       Add(tmp);

    CBFormat.Text:=tmp;
  end;

  Procedure SetAxisTicks;
  begin
    with TheAxis do
    begin
      UDAxisTickLength.Position:=TickLength;
      UDInnerTicksLength.Position:=TickInnerLength;
      CBTickOnLabels.Checked:=TickOnLabelsOnly;
      UDAxisMinorTickLen.Position:=MinorTickLength;
      UDMinorC.Position:=MinorTickCount;
    end;

    PageTicksChange(Self);
  end;

  Procedure SetAxisGrids;
  begin
    if Assigned(IGridEditor) then
       IGridEditor.RefreshPen(TheAxis.Grid)
    else
       IGridEditor:=TPenDialog.InsertForm(TheAxis.Grid, TabGridBorder);

    if Assigned(IMinorGridEditor) then
       IMinorGridEditor.RefreshPen(TheAxis.MinorGrid)
    else
       IMinorGridEditor:=TPenDialog.InsertForm(TheAxis.MinorGrid, TabGridMinor);

    with TheAxis do
    begin
      CBGridCentered.Checked:=Grid.Centered;
      CBGridAlways.Checked:=Grid.DrawAlways;
      
      UDGridZ.Position:=Round(Grid.ZPosition);
      UDEvery.Position:=Grid.DrawEvery;
      UDMinorCount.Position:=MinorTickCount;
    end;
  end;

  Procedure SetAxisTitle;
  begin
    with TheAxis do
    begin
      ETitle.Text:=Title.Caption;
      UDTitleAngle.Position:=Title.Angle;
      UDTitleSize.Position:=TitleSize;
      CBTitleVisible.Checked:=Title.Visible;
      RGTitlePos.ItemIndex:=Ord(Title.Position);

      if Title.TextFormat=ttfNormal then
         CBTitleFormat.ItemIndex:=0
      else
         CBTitleFormat.ItemIndex:=1;

      if Assigned(ITitleEditor) then
         ITitleEditor.RefreshControls(Title);
    end;
  end;

  Procedure SetAxisPositions;
  begin
    with TheAxis do
    begin
      UDPos.Position:=Round(PositionPercent);
      UDStart.Position:=Round(StartPosition);
      UDEnd.Position:=Round(EndPosition);
      UDZ.Position:=Round(ZPosition);
      CBPosUnits.ItemIndex:=Ord(TheAxis.PositionUnits);

      CBOtherSide.Checked:=OtherSide;
      CBOtherSide.Enabled:=LBAxes.ItemIndex>=TeeInitialCustomAxis;
      CBHorizAxis.Checked:=Horizontal;
      CBHorizAxis.Enabled:=LBAxes.ItemIndex>=TeeInitialCustomAxis;
      UDZ.Enabled:=not IsDepthAxis;
      Edit1.Enabled:=not IsDepthAxis;
    end;
  end;

  procedure SetAxisItems;
  begin
    ListItems.Clear;

    CBItemsAuto.Checked:=TheAxis.Items.Automatic;
    CBItemsAutoClick(Self);

    if not TheAxis.Items.Automatic then
       AddAxisItems;
  end;

begin
  if not Assigned(TheAxis) then Exit;

  With PageAxis do
  if ActivePage=TabLabels then SetAxisLabels else
  if ActivePage=TabScales then SetAxisScales else
  if ActivePage=TabTitle then SetAxisTitle else
  if ActivePage=TabTicks then SetAxisTicks else
  if ActivePage=TabGrids then SetAxisGrids else
  if ActivePage=TabPositions then SetAxisPositions else
  if ActivePage=TabItems then SetAxisItems else
  if ActivePage=TabAxisBorder then
  begin
    if not Assigned(IAxisEditor) then
       IAxisEditor:=TPenDialog.InsertForm(TheAxis.Axis,TabAxisBorder)
    else
       IAxisEditor.RefreshPen(TheAxis.Axis);
  end;

  BDelete.Enabled:=LBAxes.ItemIndex>=TeeInitialCustomAxis;
  CBVisible.Checked:=TheAxis.Visible;

  CBLabelAlign.Checked:=TheAxis.Texts.Align=alDefault;
  CBLabelAlign.Enabled:=(not TheAxis.Horizontal) and (not TheAxis.IsDepthAxis);

  CBImages.Checked:=TheAxis.Texts.UseImages;

  CreatingForm:=False;
end;

procedure TFormTeeAxis.CBShowClick(Sender: TObject);
begin
  TheAxis.ParentChart.Axes.Visible:=CBShow.Checked;
end;

procedure TFormTeeAxis.FormCreate(Sender: TObject);
begin
  {$IFDEF TEELITE}
  BAdd.Visible:=False;
  BDelete.Visible:=False;
  {$ENDIF}

  PageAxis.ActivePageIndex:=0;
  PageScales.ActivePageIndex:=0;

  //TabItems.TabVisible:=not (csDesigning in ComponentState);

  CreatingForm:=True;
end;

procedure TFormTeeAxis.PageAxisChanging(Sender: TObject;
  var AllowChange: Boolean);
begin
  CreatingForm:=True;
end;

procedure TFormTeeAxis.EPosChange(Sender: TObject);
begin
  if not CreatingForm then TheAxis.PositionPercent:=UDPos.Position;
end;

procedure TFormTeeAxis.EStartChange(Sender: TObject);
begin
  if not CreatingForm then
    if UDStart.Position<TheAxis.EndPosition then
       TheAxis.StartPosition:=UDStart.Position
    else
       UDStart.Position:=Round(TheAxis.StartPosition);
end;

procedure TFormTeeAxis.EEndChange(Sender: TObject);
begin
  if not CreatingForm then
    if UDEnd.Position>TheAxis.StartPosition then
       TheAxis.EndPosition:=UDEnd.Position
    else
       UDEnd.Position:=Round(TheAxis.EndPosition);
end;

procedure TFormTeeAxis.AddSubAxes;
var t : Integer;
begin
  LBSubAxis.Items.Clear;

  for t:=0 to TheAxis.SubAxes.Count-1 do
      LBSubAxis.Items.AddObject(IntToStr(t),TheAxis.SubAxes[t]);

  BDeleteSub.Enabled:=False;
end;

function TFormTeeAxis.SelectedMainAxis:TChartAxis;
begin
  with TheAxis.ParentChart do
  Case LBAxes.ItemIndex of
    0: result:=LeftAxis;
    1: result:=RightAxis;
    2: result:=TopAxis;
    3: result:=BottomAxis;
    4: result:=DepthAxis;
    5: result:=DepthTopAxis;
  else
    result:=Axes[LBAxes.ItemIndex];
  end;
end;

procedure TFormTeeAxis.LBAxesClick(Sender: TObject);
begin
  TheAxis:=SelectedMainAxis;

  AddSubAxes;

  CreatingForm:=True;

  PageAxisChange(Self);
end;

procedure TFormTeeAxis.BAddClick(Sender: TObject);
begin
  TheAxis:=TChartAxis.Create(TheAxis.ParentChart.CustomAxes);
  TeeAddAxes(TheAxis.ParentChart,LBAxes.Items,True);
  SetAxisIndex;
  PageAxisChange(Self);
end;

procedure TFormTeeAxis.CBOtherSideClick(Sender: TObject);
begin
  TheAxis.OtherSide:=CBOtherSide.Checked;
end;

procedure TFormTeeAxis.BDeleteClick(Sender: TObject);
var tmp : Integer;
begin
  TheAxis.Free;

  with LBAxes do
  begin
    tmp:=ItemIndex;
    Items.Delete(tmp);
    ItemIndex:=tmp-1;
  end;

  LBAxesClick(Self);
end;

procedure TFormTeeAxis.CBHorizAxisClick(Sender: TObject);
begin
  if TheAxis.ParentChart.Axes.IndexOf(TheAxis)>=TeeInitialCustomAxis then
  begin
    TheAxis.Horizontal:=CBHorizAxis.Checked;

    if Assigned(NotifyCustom) then
       NotifyCustom(TheAxis);
  end;
end;

procedure TFormTeeAxis.ELogBaseChange(Sender: TObject);
var tmp : Double;
begin
  if not CreatingForm then
  begin
    tmp:=StrToFloatDef(ELogBase.Text,TheAxis.LogarithmicBase);

    if (tmp<>1) and (tmp<>0) then
    begin
      TheAxis.LogarithmicBase:=tmp;
      LogE.Checked:=TheAxis.LogarithmicBase=Exp(1);
      LogE.Enabled:=not LogE.Checked;
    end;
  end;
end;

procedure TFormTeeAxis.CBTitleVisibleClick(Sender: TObject);
begin
  TheAxis.Title.Visible:=CBTitleVisible.Checked
end;

procedure TFormTeeAxis.CBFormatChange(Sender: TObject);
begin
  With TheAxis do
  if IsDateTime then DateTimeFormat:=CBFormat.Text
                else AxisValuesFormat:=LocalToDelphiFormat(CBFormat.Text);
end;

procedure TFormTeeAxis.CBExpoClick(Sender: TObject);
begin
  TheAxis.Texts.Exponent:=CBExpo.Checked;
end;

procedure TFormTeeAxis.CBAxisBehClick(Sender: TObject);
begin
  TheAxis.ParentChart.Axes.Behind:=CBAxisBeh.Checked;
end;

procedure TFormTeeAxis.CBLabelAlignClick(Sender: TObject);
begin
  if CBLabelAlign.Checked then
     TheAxis.Texts.Align:=alDefault
  else
     TheAxis.Texts.Align:=alOpposite;
end;

procedure TFormTeeAxis.Edit1Change(Sender: TObject);
begin
  if not CreatingForm then TheAxis.ZPosition:=UDZ.Position;
end;

procedure TFormTeeAxis.EMinOffChange(Sender: TObject);
begin
  if not CreatingForm then TheAxis.MinimumOffset:=UDMinOff.Position;
end;

procedure TFormTeeAxis.EMaxOffChange(Sender: TObject);
begin
  if not CreatingForm then TheAxis.MaximumOffset:=UDMaxOff.Position;
end;

procedure TFormTeeAxis.LogEClick(Sender: TObject);
begin
  ELogBase.Text:=FloatToStr(Exp(1));
  LogE.Enabled:=False;
end;

procedure TFormTeeAxis.Edit2Change(Sender: TObject);
begin
  if not CreatingForm then
     TheAxis.Grid.ZPosition:=UDGridZ.Position;
end;

procedure TFormTeeAxis.CBPosUnitsChange(Sender: TObject);
begin
  if not CreatingForm then
     TheAxis.PositionUnits:=TTeeUnits(CBPosUnits.ItemIndex);
end;

procedure TFormTeeAxis.FormDestroy(Sender: TObject);
begin
  PageAxis.Parent:=Self;
end;

procedure TFormTeeAxis.CBAlternateClick(Sender: TObject);
begin
  TheAxis.LabelsAlternate:=CBAlternate.Checked;
end;

procedure TFormTeeAxis.Button1Click(Sender: TObject);
begin
  CBFormat.Text:=TFormatEditor.Change(Self,CBFormat.Text,TheAxis.IsDateTime);
  CBFormatChange(Self);
end;

procedure TFormTeeAxis.EMarksEveryChange(Sender: TObject);
begin
  if not CreatingForm then
     TheAxis.Grid.DrawEvery:=UDEvery.Position;
end;

procedure TFormTeeAxis.CBShowAllClick(Sender: TObject);
begin
  if CBShowAll.Checked then
     TheAxis.LabelsSeparation:=0
  else
     TheAxis.LabelsSeparation:=TeeDefaultLabelsSeparation;
end;

procedure TFormTeeAxis.CBMinRoundClick(Sender: TObject);
begin
  TheAxis.MinimumRound:=CBMinRound.Checked;
end;

procedure TFormTeeAxis.CBMaxRoundClick(Sender: TObject);
begin
  TheAxis.MaximumRound:=CBMaxRound.Checked;
end;

procedure TFormTeeAxis.Edit3Change(Sender: TObject);
begin
  if not CreatingForm then
     TheAxis.MinorTickCount:=UDMinorC.Position;
end;

procedure TFormTeeAxis.PageTitleFormatChange(Sender: TObject);
begin
  ITitleEditor.PC1Change(Sender);
end;

procedure TFormTeeAxis.PageLabelsChange(Sender: TObject);
begin
  if (PageLabels.ActivePage=TabLabelsFormat) and (TabLabelsFormat.ControlCount=0) then
     ILabelsFormat:=TFormTeeShape.CreateForm(Self,TheAxis.LabelsFormat,TabLabelsFormat)
  else
  if (PageLabels.ActivePage=TabMargins) and (TabMargins.ControlCount=0) then
  begin
    ILabelsMargins:=TMarginsEditor.Create(Self);
    ILabelsMargins.RefreshControls(TheAxis.LabelsFormat.Margins);
    AddFormTo(ILabelsMargins,TabMargins);
  end
  else
  if (PageLabels.ActivePage=TabBack) and (TabBack.ControlCount=0) then
  begin
    IBack:=TFormTeeShape.CreateForm(Self,TheAxis.Shape,TabBack);
    IBack.TabText.TabVisible:=False;
  end;
end;

procedure TFormTeeAxis.PageTitleChange(Sender: TObject);
begin
  if (PageTitle.ActivePage=TabTitleFormat) and (PageTitleFormat.PageCount=0) then
  begin
    ITitleEditor:=InsertTeeObjectForm(PageTitleFormat,TheAxis.Title);
    ITitleEditor.RefreshControls(TheAxis.Title);
  end;
end;

procedure TFormTeeAxis.CBLabelsBehindClick(Sender: TObject);
begin
  TheAxis.LabelsBehind:=CBLabelsBehind.Checked;
end;

procedure TFormTeeAxis.ListItemsClick(Sender: TObject);
var tmp : Boolean;
begin
  IChangingItems:=True;

  tmp:=ListItems.ItemIndex=-1;

  if tmp then
  begin
    FreeAndNil(IItemsFormat);

    EItemValue.Text:='';
    AxisItemText.Text:='';
  end
  else
  with TheAxis.Items[ListItems.ItemIndex] do
  begin
    EItemValue.Text:=FloatToStr(Value);
    AxisItemText.Text:=Text;

    if Assigned(IItemsFormat) then
       IItemsFormat.RefreshControls(Format)
    else
       IItemsFormat:=TFormTeeShape.CreateForm(Self,Format,PanelItems);
  end;

  EItemValue.Enabled:=not tmp;
  AxisItemText.Enabled:=not tmp;

  SBDeleteItem.Enabled:=SBAddItem.Enabled and (not tmp);

  IChangingItems:=False;
end;

procedure TFormTeeAxis.EItemValueChange(Sender: TObject);
var tmp : TAxisValue;
begin
  if not IChangingItems then
     if ListItems.ItemIndex<>-1 then
     begin
       LInvalidValue.Visible:=not TryStrToFloat(EItemValue.Text,tmp);

       if not LInvalidValue.Visible then
          TheAxis.Items[ListItems.ItemIndex].Value:=tmp;
     end;
end;

procedure TFormTeeAxis.CBItemsAutoClick(Sender: TObject);
begin
  TheAxis.Items.Automatic:=CBItemsAuto.Checked;

  PanelItems.Enabled:=not CBItemsAuto.Checked;
  ListItems.Enabled:=PanelItems.Enabled;

  SBAddItem.Enabled:=ListItems.Enabled;

  if not SBAddItem.Enabled then
     SBDeleteItem.Enabled:=False;

  if TheAxis.Items.Automatic then
  begin
    TheAxis.ParentChart.Draw;
    AddAxisItems;
  end
  else
     ListItemsClick(Self);
end;

procedure TFormTeeAxis.AxisItemTextChange(Sender: TObject);
begin
  if not IChangingItems then
     if ListItems.ItemIndex<>-1 then
        TheAxis.Items[ListItems.ItemIndex].Text:=AxisItemText.Text;
end;

procedure TFormTeeAxis.CBAutoIncClick(Sender: TObject);
begin
  if CBAutoInc.Checked and (TheAxis.Increment<>0) then
  begin
    TheAxis.Increment:=0;
    SetAxisScales;
  end;
end;

procedure TFormTeeAxis.Edit4Change(Sender: TObject);
begin
  if not CreatingForm then
     TheAxis.TickInnerLength:=UDInnerTicksLength.Position;
end;

procedure TFormTeeAxis.PageTicksChange(Sender: TObject);

  procedure Check(const APen:TTeePen; const ATab:TTabSheet; var AEditor:TPenDialog);
  begin
    if PageTicks.ActivePage=ATab then
       if Assigned(AEditor) then
          AEditor.RefreshPen(APen)
       else
          AEditor:=TPenDialog.InsertForm(APen,ATab)
  end;

begin
  Check(TheAxis.Ticks,TabOuter,IOuterEditor);
  Check(TheAxis.TicksInner,TabInner,IInnerEditor);
  Check(TheAxis.MinorTicks,TabMinor,IMinorEditor);
end;

procedure TFormTeeAxis.EIncrementChange(Sender: TObject);
begin
  TheAxis.Increment:=StrToFloatDef(EIncrement.Text,TheAxis.Increment);

  CBAutoInc.Checked:=TheAxis.Increment=0;
  CBAutoInc.Enabled:=not CBAutoInc.Checked;
end;

procedure TFormTeeAxis.EAxisMinChange(Sender: TObject);
var tmp : Double;
begin
  if not IChangingAuto then
  begin
    tmp:=StrToFloatDef(EAxisMin.Text,TheAxis.Minimum);

    if (tmp<>TheAxis.Minimum) or IsNan(TheAxis.Minimum) then
    begin
      IChangingAuto:=True;
      try
        CBAutoMin.Checked:=False;
        TheAxis.AutomaticMinimum:=False;

        TheAxis.Minimum:=tmp;
      finally
        IChangingAuto:=False;
      end;
    end;
  end;
end;

procedure TFormTeeAxis.EAxisMaxChange(Sender: TObject);
var tmp : Double;
begin
  if not IChangingAuto then
  begin
    tmp:=StrToFloatDef(EAxisMax.Text,TheAxis.Maximum);

    if (tmp<>TheAxis.Maximum) or IsNan(TheAxis.Maximum) then
    begin
      IChangingAuto:=True;
      try
        CBAutoMax.Checked:=False;
        TheAxis.AutomaticMaximum:=False;

        TheAxis.Maximum:=tmp;
      finally
        IChangingAuto:=False;
      end;
    end;
  end;
end;

procedure TFormTeeAxis.CBLabelsPosChange(Sender: TObject);
begin
  TheAxis.Texts.Position:=TAxisLabelsPosition(CBLabelsPos.ItemIndex);
end;

procedure TFormTeeAxis.RGTitlePosClick(Sender: TObject);
begin
  TheAxis.Title.Position:=TAxisTitlePosition(RGTitlePos.ItemIndex);
end;

procedure TFormTeeAxis.CBGridAlwaysClick(Sender: TObject);
begin
  TheAxis.Grid.DrawAlways:=CBGridAlways.Checked;
end;

procedure TFormTeeAxis.CBTitleFormatChange(Sender: TObject);
begin
  if CBTitleFormat.ItemIndex=0 then
     TheAxis.Title.TextFormat:=ttfNormal
  else
     TheAxis.Title.TextFormat:=ttfHtml;
end;

procedure TFormTeeAxis.SBAddItemClick(Sender: TObject);
begin
  CBItemsAuto.Checked:=False;

  TheAxis.Items.Add(0);
  AddAxisItem(TheAxis.Items.Count-1);

  ListItems.ItemIndex:=ListItems.Items.Count-1;
  ListItemsClick(Self);
end;

procedure TFormTeeAxis.SBDeleteItemClick(Sender: TObject);

  procedure DeleteItem(Index:Integer);
  begin
    TheAxis.Items.Delete(Index);
    ListItems.Items.Delete(Index);
  end;

var t,
    tmp : Integer;
begin
  tmp:=ListItems.ItemIndex;

  if ListItems.SelCount=1 then
     DeleteItem(tmp)
  else
  begin
    t:=0;

    while t<ListItems.Items.Count do
          if ListItems.Selected[t] then
             DeleteItem(t)
          else
             Inc(t);
  end;

  if tmp>=ListItems.Items.Count then
     tmp:=ListItems.Items.Count-1;

  ListItems.ItemIndex:=tmp;
  ListItemsClick(Self);
end;

procedure TFormTeeAxis.BDeleteSubClick(Sender: TObject);
var tmp : Integer;
begin
  TheAxis.Free;

  with LBSubAxis do
  begin
    tmp:=ItemIndex;
    Items.Delete(tmp);
    ItemIndex:=tmp-1;
  end;

  LBSubAxisClick(Self);
end;

procedure TFormTeeAxis.LBSubAxisClick(Sender: TObject);
var tmp : Integer;
begin
  tmp:=LBSubAxis.ItemIndex;

  BDeleteSub.Enabled:=tmp<>-1;

  if tmp=-1 then
     LBAxesClick(Self)
  else
  begin
    TheAxis:=TChartAxis(LBSubAxis.Items.Objects[tmp]);

    CreatingForm:=True;

    PageAxisChange(Self);
  end;
end;

procedure TFormTeeAxis.BAddSubClick(Sender: TObject);
var tmp : Integer;
    tmpAxis : TChartAxis;
begin
  tmpAxis:=SelectedMainAxis;
  tmp:=tmpAxis.SubAxes.Count;

  TheAxis:=tmpAxis.SubAxes.Add;

  LBSubAxis.Items.AddObject(IntToStr(tmp),TheAxis);
  LBSubAxis.ItemIndex:=tmp;
  LBSubAxisClick(Self);
end;

procedure TFormTeeAxis.PageAxisGetImageIndex(Sender: TObject;
  TabIndex: Integer; var ImageIndex: Integer);
begin
// Dummy
end;

procedure TFormTeeAxis.EMarginChange(Sender: TObject);
begin
  if not CreatingForm then
     TheAxis.Texts.MarginToAxis:=UDMargin.Position;
end;

procedure TFormTeeAxis.CBImagesClick(Sender: TObject);
begin
  TheAxis.Texts.UseImages:=CBImages.Checked;
end;

end.
