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

📄 teelisb.pas

📁 TeeChart 7.0 With Source在Delphi 7.0中的安装
💻 PAS
📖 第 1 页 / 共 3 页
字号:

{ Delete the current selected Series, if any. Returns True if deleted }
Function TChartListBox.DeleteSeries:Boolean;

  Procedure DoDelete;
  Var t : Integer;
  begin
    if MultiSelect then { 5.01 }
    begin
      t:=0;
      While t<Items.Count do
      if Selected[t] then Series[t].Free
                     else Inc(t);
    end
    else
    if ItemIndex<>-1 then Series[ItemIndex].Free;

    if Items.Count>0 then SelectSeries(0);

    DoRefresh;
    RefreshDesigner;
  end;

var tmpSt : String;
begin
  result:=False;

  if AnySelected then { 5.01 }
    if FAskDelete then
    begin
      if (not MultiSelect) or (SelCount=1) then  { 5.01 }
         tmpSt:=SeriesTitleOrName(SelectedSeries)
      else
         tmpSt:=TeeMsg_SelectedSeries;

      if TeeYesNoDelete(tmpSt,Self) then
      begin
        DoDelete;
        result:=True;
      end;
    end
    else
    begin
      DoDelete;
      result:=True;
    end;
end;

Procedure TChartListBox.CloneSeries;
begin { duplicate current selected series }
  if ItemIndex<>-1 then
  begin
    CloneChartSeries(SelectedSeries);
    RefreshDesigner;
  end;
end;

procedure TChartListBox.KeyUp(var Key: Word; Shift: TShiftState);
begin
  Case Key of
    {$IFDEF CLX}
    Key_Insert
    {$ELSE}
    VK_INSERT
    {$ENDIF}:  if FAllowAdd then AddSeriesGallery;

    {$IFDEF CLX}
    Key_Delete
    {$ELSE}
    VK_DELETE
    {$ENDIF}:  if FAllowDelete then DeleteSeries;

    {$IFDEF CLX}
    Key_F2
    {$ELSE}
    VK_F2
    {$ENDIF}:  if Assigned(SelectedSeries) then ShowEditor;
  end;
end;

procedure TChartListBox.EditorPress(Sender: TObject; var Key: Char);
begin
  if (Key=#13) or (Key=#27) then Key:=#0; // avoid "beep"
end;

procedure TChartListBox.EditorKey(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
  case Key of
    TeeKey_Escape,
    TeeKey_F2,
    TeeKey_Up,
    TeeKey_Down,
    TeeKey_Return: if Assigned(FEditor) and FEditor.Visible then
                   begin
                     if Key<>TeeKey_Escape then
                        TChartSeries(FEditor.Tag).Title:=FEditor.Text;
                     FEditor.Hide;
                     SetFocus;
                     Invalidate;
                   end;
  end;
end;

procedure TChartListBox.HideEditor;
var c : Word;
begin
  c:=TeeKey_Return;
  EditorKey(FEditor,c,[]);
end;

Procedure TChartListBox.ShowEditor;
var R : TRect;
begin
  if Assigned(SelectedSeries) and ShowSeriesTitle then
  begin
    if not Assigned(FEditor) then
       FEditor:=TEdit.Create(Self);

    with FEditor do
    begin
      Parent:=Self;
      Tag:={$IFDEF CLR}Variant{$ELSE}Integer{$ENDIF}(SelectedSeries);
      Text:=SeriesTitleOrName(SelectedSeries);
      Width:=Sections[3].Width;
      Left:=SectionLeft(3)-2;
      R:=ItemRect(ItemIndex);
      Top:=R.Top;
      Height:=R.Bottom-R.Top+1;
      OnKeyDown:=EditorKey;
      OnKeyPress:=EditorPress;

      Show;

      {$IFDEF TEEOCX}
      Windows.SetFocus(Handle); //MM ax V7.0.0.2 SetFocus;
      {$ELSE}
      SetFocus; 
      {$ENDIF}
    end;
  end;
end;

Function TChartListBox.RenameSeries:Boolean; { 5.02 }
var tmp       : Integer;
    tmpSeries : TChartSeries;
    tmpSt     : String;
    Old       : String;
begin
  result:=False;
  tmp:=ItemIndex;

  if tmp<>-1 then
  begin
    tmpSeries:=SelectedSeries;

    if FNames then tmpSt:=tmpSeries.Name  // 7.0
              else tmpSt:=SeriesTitleOrName(tmpSeries);
    Old:=tmpSt;

    if InputQuery(TeeMsg_ChangeSeriesTitle,
                  TeeMsg_NewSeriesTitle,tmpSt) then
    begin
      if tmpSt<>'' then
         if FNames then
         begin
           tmpSeries.Name:=tmpSt;
           Items[tmp]:=tmpSt;
           tmpSeries.Repaint;
         end
         else
         if tmpSt=tmpSeries.Name then tmpSeries.Title:=''
                                 else tmpSeries.Title:=tmpSt;

      // return True if the Series title has been changed

      if FNames then result:=Old<>tmpSeries.Name
                else result:=Old<>SeriesTitleOrName(tmpSeries);
    end;

    SelectSeries(tmp);
  end;
end;

Procedure TChartListBox.RefreshDesigner;
begin
  if Assigned(Chart) and Assigned(Chart.Designer) then Chart.Designer.Refresh;
end;

Function TChartListBox.AddSeriesGallery:TChartSeries;
var t : Integer;
begin
  if Assigned(TeeAddGalleryProc) then
  begin
    result:=TeeAddGalleryProc(Owner,Chart,SelectedSeries);

    if Assigned(result) then
    begin
      if MultiSelect then // 5.01
         for t:=0 to Items.Count-1 do Selected[t]:=False;

      SelectSeries(Items.IndexOfObject(result));

      DoRefresh;
      RefreshDesigner;
    end;
  end
  else result:=nil;
end;

procedure TChartListBox.Notification(AComponent: TComponent;
  Operation: TOperation);
begin
  inherited;
  if (Operation=opRemove) and Assigned(Chart) and (AComponent=Chart) then
     Chart:=nil;
end;

{$IFNDEF CLX}
{$IFNDEF LCL}
procedure TChartListBox.WMNCHitTest(var Msg: TWMNCHitTest);
begin
  inherited;
  FHitTest:=SmallPointToPoint(Msg.Pos);
end;

procedure TChartListBox.WMSetCursor(var Msg: TWMSetCursor);
var I: Integer;
begin
  if csDesigning in ComponentState then Exit;

  if (Items.Count>0) and (SeriesAtMousePos(FHitTest)<>-1) and
     (Msg.HitTest=HTCLIENT) then

     for I:=0 to 2 do  { don't count last section }
     begin
       if PointInSection(FHitTest,I) then
       begin
         if ((I=0) and FEnableChangeType) or
            ((I=2) and FEnableChangeColor) then
         begin
           SetCursor(Screen.Cursors[crHandPoint]);
           Exit;
         end
         else break;
       end;
     end;

  inherited;
end;

{$ELSE}

procedure TChartListBox.MouseMove(Shift: TShiftState; X, Y: Integer);
var I : Integer;
    P : TPoint;
begin
  if csDesigning in ComponentState then Exit;

  P:=TeePoint(X,Y);
  if (Items.Count>0) and (SeriesAtMousePos(P)<>-1) then

     for I:=0 to 2 do  { don't count last section }
     begin
       if PointInSection(P,I) then
       begin
         if ((I=0) and FEnableChangeType) or
            ((I=2) and FEnableChangeColor) then
         begin
           Cursor:=crHandPoint;
           Exit;
         end
         else break;
       end;
     end;
  Cursor:=crDefault;
end;
{$ENDIF}
{$ENDIF}

procedure TChartListBox.UpdateSeries;
begin
  FillSeries(SelectedSeries);
end;

Function TChartListBox.GetShowActive:Boolean;
begin
  result:=Sections[1].Visible;
end;

procedure TChartListBox.SetShowActive(Value:Boolean);
begin
  Sections[1].Visible:=Value; Repaint;
end;

Function TChartListBox.GetShowIcon:Boolean;
begin
  result:=Sections[0].Visible;
end;

procedure TChartListBox.SetShowIcon(Value:Boolean);
begin
  Sections[0].Visible:=Value; Repaint;
end;

Function TChartListBox.GetShowColor:Boolean;
begin
  result:=Sections[2].Visible;
end;

procedure TChartListBox.SetShowColor(Value:Boolean);
begin
  Sections[2].Visible:=Value; Repaint;
end;

Function TChartListBox.GetShowTitle:Boolean;
begin
  result:=Sections[3].Visible;
end;

procedure TChartListBox.SetShowTitle(Value:Boolean);
begin
  Sections[3].Visible:=Value; Repaint;
end;

procedure TChartListBox.SelectAll;
{$IFNDEF D6}
var t : Integer;
{$ENDIF}
begin
  if MultiSelect then { 5.01 }
  begin
    {$IFDEF D6}
    inherited;
    {$ELSE}
    for t:=0 to Items.Count-1 do Selected[t]:=True;
    {$ENDIF}
    RefreshDesigner;
  end;
end;

Function TChartListBox.GetSeries(Index:Integer):TChartSeries;
begin
  if (Index<>-1) and (Index<Items.Count) then
     result:=TChartSeries(Items.Objects[Index])
  else
     result:=nil;
end;

procedure TChartListBox.TeeEvent(Event:TTeeEvent);
var tmp : Integer;
begin
  if not (csDestroying in ComponentState) then
  if Event is TTeeSeriesEvent then
  With TTeeSeriesEvent(Event) do
  Case Event of
    seChangeColor,
    seChangeActive: Invalidate;
    seChangeTitle: begin
                     tmp:=Items.IndexOfObject(Series);
                     if tmp<>-1 then
                        Items[tmp]:=SeriesTitleOrName(Series);
                   end;
    seRemove: begin
                tmp:=Items.IndexOfObject(Series);
                if tmp<>-1 then
                begin
                  Items.Delete(tmp);
                  if Assigned(FOtherItems) then FOtherItems.Delete(tmp);
                  if Assigned(FOnRemovedSeries) then
                     FOnRemovedSeries(Self,Series); { 5.02 }
                end;
              end;
      seAdd,
      seSwap: UpdateSeries;
  end
  else
  if Event is TTeeView3DEvent then
     Invalidate; // 7.04 TV52010062

end;

{$IFNDEF D6}
Procedure TChartListBox.ClearSelection;
var t: Integer;
begin
  if MultiSelect then
     for t:=0 to Items.Count-1 do Selected[t]:=False
  else
     ItemIndex:=-1;
end;
{$ENDIF}

{$IFNDEF CLX}
Procedure TChartListBox.SetParent(Control:TWinControl);
begin
  inherited;

  if Assigned(Parent) and (Items.Count=0) and (ItemIndex<>-1) then
     ItemIndex:=-1;
end;
{$ENDIF}

end.

⌨️ 快捷键说明

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