⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 teeediaxis.pas

📁 第三方控件:PaintGrid.pas 网格型仪表控件源文件 Mymeter.pas 圆型仪表控件源文件 Project1是这两个控件的使用范例。 该
💻 PAS
📖 第 1 页 / 共 2 页
字号:
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 TheAxis.LabelsSeparation:=UDSepar.Position;
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.SetAxisScales;
Begin
  With TheAxis do
  Begin
    LAxisIncre.Caption:=GetIncrementText(Self,Increment,IsDateTime,ExactDateTime,AxisValuesFormat);

    if IsDateTime then
    begin
      if Minimum>=1 then LAxisMin.Caption:=DateTimeToStr(Minimum)
                    else LAxisMin.Caption:=TimeToStr(Minimum);
      if Maximum>=1 then LAxisMax.Caption:=DateTimeToStr(Maximum)
                    else LAxisMax.Caption:=TimeToStr(Maximum);
    end
    else
    begin
      LAxisMin.Caption:=FormatFloat(AxisValuesFormat,Minimum);
      LAxisMax.Caption:=FormatFloat(AxisValuesFormat,Maximum);
    end;

    IChangingAuto:=True; { 5.01 }

    CBAutomatic.Checked:=Automatic;
    CBAutoMax.Checked:=AutomaticMaximum;
    CBAutoMin.Checked:=AutomaticMinimum;
    UDMaxOff.Position:=MaximumOffset;  // 6.0
    UDMinOff.Position:=MinimumOffset;  // 6.0

    IChangingAuto:=False; { 5.01 }

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

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

procedure TFormTeeAxis.PageAxisChange(Sender: TObject);

  Procedure SetAxisLabels;
  var tmp : String;
  begin  { Axis Labels  }
    with TheAxis do
    begin
      CBLabels.Checked:=Labels;
      CBLabelStyle.ItemIndex:=Ord(LabelStyle);
      CBOnAxis.Checked:=LabelsOnAxis;
      CBRoundFirst.Checked:=RoundFirstLabel;
      UDLabelsAngle.Position:=LabelsAngle;
      UDSepar.Position:=LabelsSeparation;
      UDLabelsSize.Position:=LabelsSize;
      CBMultiline.Checked:=LabelsMultiLine;
      CBExpo.Checked:=LabelsExponent;
      CBFormat.Items.Clear;
      CBAlternate.Checked:=LabelsAlternate;

      if IsDateTime then
      begin
        With CBFormat.Items do
        if Maximum-Minimum<=1 then
        begin
          Add(ShortTimeFormat);
          Add(LongTimeFormat);
          Add('hh:nn');
          Add('hh:nn:ss');
          Add('hh:nn:ss.zzz');
        end
        else
        begin
          Add(ShortDateFormat);
          Add(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
        AddDefaultValueFormats(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;
      ILabelsFont.RefreshControls(LabelsFont);
    end;
  end;

  Procedure SetAxisTicks;
  begin
    with TheAxis do
    begin
      UDAxisTickLength.Position:=TickLength;
      UDInnerTicksLength.Position:=TickInnerLength;
      CBTickOnLabels.Checked:=TickOnLabelsOnly;
      CBGridCentered.Checked:=Grid.Centered;
      UDGridZ.Position:=Round(Grid.ZPosition);
    end;
  end;

  Procedure SetAxisMinorTicks;
  begin
    with TheAxis do
    begin
      UDAxisMinorTickLen.Position:=MinorTickLength;
      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;
      ITitleFont.RefreshControls(Title.Font);
    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;
    end;
  end;

begin
  {$IFDEF CLX}
  if not Showing then Exit;
  {$ENDIF}

  if not Assigned(TheAxis) then Exit;
  
  With TheAxis do
  begin
    BAxisGrid.LinkPen(Grid);
    BTickMinor.LinkPen(MinorTicks);
    BTickInner.LinkPen(TicksInner);
    BTickPen.LinkPen(Ticks);
    BAxisPen.LinkPen(Axis);
    BMinorGrid.LinkPen(MinorGrid);
  end;

  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=TabMinorTicks then SetAxisMinorTicks else
  if ActivePage=TabPositions then SetAxisPositions;

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

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

  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}

  CreatingForm:=True;
  ILabelsFont:=InsertTeeFontEditor(TabLabelsFont);
  ITitleFont:=InsertTeeFontEditor(TabTitleFont);
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.LBAxesClick(Sender: TObject);
begin
  With TheAxis.ParentChart do
  Case LBAxes.ItemIndex of
    0: TheAxis:=LeftAxis;
    1: TheAxis:=RightAxis;
    2: TheAxis:=TopAxis;
    3: TheAxis:=BottomAxis;
    4: TheAxis:=DepthAxis;
    5: TheAxis:=DepthTopAxis;
  else TheAxis:=Axes[LBAxes.ItemIndex];
  end;

  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
  TheAxis.Horizontal:=CBHorizAxis.Checked;
  if Assigned(NotifyCustom) then NotifyCustom(TheAxis);
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.LabelsExponent:=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.LabelsAlign:=alDefault
  else
     TheAxis.LabelsAlign:=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;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -