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

📄 visual.~pas

📁 A diagram edit component for delphi/c++ builder with full source included
💻 ~PAS
字号:
unit Visual;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Buttons, JvExStdCtrls, JvCombobox, JvColorCombo,Flow, ExtCtrls,
  Mask, JvExMask, JvMaskEdit, JvSpin;

type
  TVisualForm = class(TForm)
    GroupBox1: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    ComboBox1: TComboBox;
    JvColorComboBox1: TJvColorComboBox;
    Label3: TLabel;
    Label4: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    RadioGroup1: TRadioGroup;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    ComboBox2: TComboBox;
    GroupBox2: TGroupBox;
    GroupBox3: TGroupBox;
    Label8: TLabel;
    JvColorComboBox2: TJvColorComboBox;
    Label9: TLabel;
    JvColorComboBox3: TJvColorComboBox;
    Label10: TLabel;
    JvColorComboBox4: TJvColorComboBox;
    Label11: TLabel;
    JvColorComboBox5: TJvColorComboBox;
    Label13: TLabel;
    JvSpinEdit1: TJvSpinEdit;
    Label12: TLabel;
    procedure ComboBox1Change(Sender: TObject);
  public
    constructor Create(AOwner:TComponent;paperAttr:TPaperAttr;nodeAttr:TNodeAttr;edgeAttr:TEdgeAttr);

    function PaperAttr:TPaperAttr;
    function NodeAttr:TNodeAttr;
    function EdgeAttr:TEdgeAttr;
  end;

var
  VisualForm: TVisualForm;

implementation

{$R *.DFM}

constructor TVisualForm.Create(AOwner:TComponent;paperAttr:TPaperAttr;nodeAttr:TNodeAttr;edgeAttr:TEdgeAttr);
begin
  inherited Create(AOwner);

  with ComboBox1.Items do begin
    Add('Letter');
    Add('A3');
    Add('A4');
    Add('A5');
    Add('B4');
    Add('B5');
    Add('Custom');
  end;

  ComboBox1.ItemIndex:=Ord(paperAttr.m_paper);
  if(paperAttr.m_paper<>Custom) then begin
    Edit1.Enabled:=false;
    Edit2.Enabled:=false;
  end
  else begin
    Edit1.Enabled:=True;
    Edit2.Enabled:=True;
  end;
  Edit1.text:=IntToStr(paperAttr.m_width);
  Edit2.text:=IntToStr(paperAttr.m_height);

  RadioGroup1.ItemIndex:=paperAttr.m_direction;

  JvColorComboBox1.ColorValue:=paperAttr.m_color;

  ComboBox2.ItemIndex:=paperAttr.m_style;

  JvColorComboBox2.ColorValue:=NodeAttr.m_backColor;
  JvColorComboBox3.ColorValue:=NodeAttr.m_frameColor;
  JvColorComboBox4.ColorValue:=NodeAttr.m_textColor;

  JvColorComboBox5.ColorValue:=EdgeAttr.m_color;
  JvSpinEdit1.Value:=EdgeAttr.m_width;
end;

procedure TVisualForm.ComboBox1Change(Sender: TObject);
var
  size:TSize;
begin
  size:=PaperSize(TPaper(ComboBox1.ItemIndex));
  edit1.text:=IntToStr(size.m_width);
  edit2.text:=IntToStr(size.m_height);

  if(TPaper(ComboBox1.ItemIndex)<>Custom) then begin
    Edit1.Enabled:=false;
    Edit2.Enabled:=false;
  end
  else begin
    Edit1.Enabled:=True;
    Edit2.Enabled:=True;
  end;
end;

function TVisualForm.PaperAttr:TPaperAttr;
begin
  result.m_paper:=TPaper(ComboBox1.ItemIndex);
  result.m_width:=StrToInt(Edit1.text);
  result.m_height:=StrToInt(Edit2.text);
  result.m_direction:=RadioGroup1.ItemIndex;
  result.m_color:=JvColorComboBox1.ColorValue;
  result.m_style:=ComboBox2.ItemIndex;
end;

function TVisualForm.NodeAttr:TNodeAttr;
begin
  result.m_backColor:=JvColorComboBox2.ColorValue;
  result.m_frameColor:=JvColorComboBox3.ColorValue;
  result.m_textColor:=JvColorComboBox4.ColorValue;
end;

function TVisualForm.EdgeAttr:TEdgeAttr;
begin
  result.m_color:=JvColorComboBox5.ColorValue;
  result.m_width:=Round(JvSpinEdit1.Value);
end;

end.

⌨️ 快捷键说明

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