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

📄 jvgreporteditorform.pas

📁 East make Tray Icon in delphi
💻 PAS
📖 第 1 页 / 共 3 页
字号:
    FSelectedControl := nil;
    RemakeComponentsList;
  end;
end;

procedure TJvgReportEditorForm.OnDrawScrollBox(Sender: TObject);
begin
  VRuler.Top := ShapeSize.Top;
  HRuler.Left := ShapeSize.Left + P_VRuler.Width;
end;

procedure TJvgReportEditorForm.FormDestroy(Sender: TObject);
begin
  //...
end;

procedure TJvgReportEditorForm.RemakeComponentsList;
var
  I: Integer;
begin
  cb_Components.Items.Clear;
  for I := 0 to FScrollBox.ControlCount - 1 do
    if FScrollBox.Controls[I] is TJvgReportItem then
      cb_Components.Items.Add(TJvgReportItem(FScrollBox.Controls[I]).CompName);
  cb_Components.Text := '';
  lb_Params.Items.Clear;
  for I := 0 to Component.ParamNames.Count - 1 do
    lb_Params.Items.Add(Component.ParamNames[I]);
end;

procedure TJvgReportEditorForm.UpdatePageSize;
const
  Sizes: array [Boolean, 1..2] of Integer =
    ((21, 29), (29, 21));
begin
  ShapeSize.Width := Round(Sizes[Printer.Orientation = poLandscape][1] *
    GetDeviceCaps(Canvas.Handle, LOGPIXELSX) * 1.541 * 2.54 / 10);
  ShapeSize.Height := Round(Sizes[Printer.Orientation = poLandscape][2] *
    GetDeviceCaps(Canvas.Handle, LOGPIXELSY) * 1.541 * 2.54 / 10);
  HRuler.Width := ShapeSize.Width + 10;
  VRuler.Height := ShapeSize.Height + 10;
end;

procedure TJvgReportEditorForm.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
var
  L, T, W, H: Integer;
begin
  W := 0;
  H := 0;
  if (Shift = [ssCtrl]) and (Chr(Key) = 'Z') and FCanUndo then
  begin
    FCanUndo := False;
    ResizeReportControls(FUndoPosShift.X, FUndoPosShift.Y, 0, 0, True);
  end;

  if Assigned(ActiveControl) then
    Exit;
  L := 0;
  T := 0;
  case Key of
    VK_UP:
      if Shift = [ssShift] then
        H := -1
      else
      if Shift = [ssCtrl] then
        T := -1;
    VK_DOWN:
      if Shift = [ssShift] then
        H := 1
      else
      if Shift = [ssCtrl] then
        T := 1;
    VK_LEFT:
      if Shift = [ssShift] then
        W := -1
      else
      if Shift = [ssCtrl] then
        L := -1;
    VK_RIGHT:
      if Shift = [ssShift] then
        W := 1
      else
      if Shift = [ssCtrl] then
        L := 1;
  else
    Exit;
  end;
  ResizeReportControls(L, T, W, H, True);

end;

procedure TJvgReportEditorForm.sb_FixMovingClick(Sender: TObject);
var
  I: Integer;
begin
  with FScrollBox do
    for I := 0 to ControlCount - 1 do
      if (Controls[I] is TJvgReportItem) and
        TJvgReportItem(Controls[I]).Selected then
        TJvgReportItem(Controls[I]).Fixed := Ord(sb_FixMoving.Down);
end;

procedure TJvgReportEditorForm.N_AutoSizeClick(Sender: TObject);
begin
  FSelectedControl.OLESizeMode := TMenuItem(Sender).Tag;
end;

procedure TJvgReportEditorForm.sb_SnapToGridClick(Sender: TObject);
begin
  if sb_SnapToGrid.Down then
  begin
    FStep.X := FGrid.X;
    FStep.Y := FGrid.Y;
  end
  else
  begin
    FStep.X := 1;
    FStep.Y := 1;
  end;
end;

procedure TJvgReportEditorForm.se_SizeChange(Sender: TObject);
begin
  if (not FMouseDown) and (not FSkipSizeUpdate) then
    ResizeReportControls(se_Left.Position, IGNORE_VALUE,
      IGNORE_VALUE, IGNORE_VALUE, False {fUseParamsAsShifts});
  ShowComponentPos(FSelectedControl);
  FSkipSizeUpdate := False;
end;

procedure TJvgReportEditorForm.se_TopChange(Sender: TObject);
begin
  if (not FMouseDown) and (not FSkipSizeUpdate) then
    ResizeReportControls(IGNORE_VALUE, se_Top.Position,
      IGNORE_VALUE, IGNORE_VALUE, False {fUseParamsAsShifts});
  ShowComponentPos(FSelectedControl);
  FSkipSizeUpdate := False;
end;

procedure TJvgReportEditorForm.se_WidthChange(Sender: TObject);
begin
  if (not FMouseDown) and (not FSkipSizeUpdate) then
    ResizeReportControls(IGNORE_VALUE, IGNORE_VALUE,
      se_Width.Position, IGNORE_VALUE, False {fUseParamsAsShifts});
  ShowComponentPos(FSelectedControl);
  FSkipSizeUpdate := False;
end;

procedure TJvgReportEditorForm.se_HeightChange(Sender: TObject);
begin
  if (not FMouseDown) and (not FSkipSizeUpdate) then
    ResizeReportControls(IGNORE_VALUE, IGNORE_VALUE,
      IGNORE_VALUE, se_Height.Position, False {fUseParamsAsShifts});
  ShowComponentPos(FSelectedControl);
  FSkipSizeUpdate := False;
end;

procedure TJvgReportEditorForm.ResizeReportControls(L, T, W, H: Integer;
  fUseParamsAsShifts: Boolean);
var
  I: Integer;
begin
  with FScrollBox do
    for I := 0 to ControlCount - 1 do
      if Controls[I] is TJvgReportItem then
        with TJvgReportItem(Controls[I]) do
          if Selected and (Fixed = 0) then
            if fUseParamsAsShifts then
            begin
              if L < IGNORE_VALUE then
                Left := Left + L;
              if T < IGNORE_VALUE then
                Top := Top + T;
              if W < IGNORE_VALUE then
                Width := Width + W;
              if H < IGNORE_VALUE then
                Height := Height + H;
            end
            else
            begin
              if L < IGNORE_VALUE then
                Left := L;
              if T < IGNORE_VALUE then
                Top := T;
              if W < IGNORE_VALUE then
                Width := W;
              if H < IGNORE_VALUE then
                Height := H;
            end;
end;

procedure TJvgReportEditorForm.cb_ComponentsChange(Sender: TObject);
var
  I: Integer;
begin
  if Assigned(FSelectedControl) then
    if FSelectedControl.CompName = cb_Components.Text then
      Exit;
  with FScrollBox do
    for I := 0 to ControlCount - 1 do
      if Controls[I] is TJvgReportItem then
        if TJvgReportItem(Controls[I]).CompName = cb_Components.Text then
        begin
          OnMouseDown_(Controls[I], mbLeft, [], 0, 0);
          OnMouseUp_(Controls[I], mbLeft, [], 0, 0);
          Exit;
        end;
end;

procedure TJvgReportEditorForm.ShowComponentPos(Control: TControl);
begin
  if Component <> nil then
  begin
    se_Left.Position := Control.Left;
    se_Top.Position := Control.Top;
    se_Width.Position := Control.Width;
    se_Height.Position := Control.Height;
  end;
end;

procedure TJvgReportEditorForm.AssignEventsToAllComponents;
var
  I: Integer;
begin
  with Component.ParentWnd do
    for I := 0 to ControlCount - 1 do
      if Controls[I] is TJvgReportItem then
        with TJvgReportItem(Controls[I]) do
        begin
          OnMouseDown := OnMouseDown_;
          OnMouseUp := OnMouseUp_;
          OnMouseMove := OnMouseMove_;
          OnResize := OnResize_;
        end;
end;

function CanAlignControl(Control: TControl): Boolean;
begin
  Result := (Control is TJvgReportItem) and
    TJvgReportItem(Control).Selected and
    (TJvgReportItem(Control).Fixed = 0);
end;

procedure TJvgReportEditorForm.N4Click(Sender: TObject);
begin
  with TAlignForm.Create(Self) do
    try
      if ShowModal = mrOk then
        AlignControlsInWindow(Component.ParentWnd, CanAlignControl,
          Horz, Vert);
    finally
      Free;
    end;
end;

procedure TJvgReportEditorForm.sb_BevelBoldClick(Sender: TObject);
var
  I: Integer;
begin
  with Component.ParentWnd do
    for I := 0 to ControlCount - 1 do
      if (Controls[I] is TJvgReportItem) and
        TJvgReportItem(Controls[I]).Selected then
        TJvgReportItem(Controls[I]).PenWidth := 1 + Ord(sb_BevelBold.Down);
end;

procedure TJvgReportEditorForm.UpdateToolBar(Control: TJvgReportItem);
begin
  with Control do
  begin
    {
      se_Left.Enabled := Assigned(Control);
      se_Top.Enabled := Assigned(Control);
      se_Width.Enabled := Assigned(Control);
      se_Height.Enabled := Assigned(Control);}
    P_Sides.Enabled := Assigned(Control);
    P_Font.Enabled := Assigned(Control);
    P_SBar.Enabled := Assigned(Control);
    if not Assigned(Control) then
      Exit;
    Edit1.Text := Text;
    Memo1.Text := Text;
    FontComboBox1.Text := FName;
    RxSpinEdit1.Position := FSize;
    ColorComboBox1.Color := FColor;

    SB_Left.Down := SideLeft = 1;
    SB_Top.Down := SideTop = 1;
    SB_Right.Down := SideRight = 1;
    SB_Bottom.Down := SideBottom = 1;
    case Alignment of
      1:
        sb_AlignL.Down := True;
      2:
        sb_AlignR.Down := True;
      3:
        sb_AlignC.Down := True;
      4:
        sb_AlignW.Down := True;
    end;
    sb_FixMoving.Down := Fixed <> 0;
    sb_FontBold.Down := (FStyle and 1) <> 0;
    sb_FontItalic.Down := (FStyle and 2) <> 0;
    sb_FontUnderline.Down := (FStyle and 4) <> 0;
    FE_OLE.Text := OLELinkToFile;
    FE_OLE.Enabled := ContainOLE;
    sb_BevelBold.Down := (PenWidth - 1) <> 0;
    FSkipSizeUpdate := True;
    ShowComponentPos(Control);

    cb_Components.Text := CompName;
  end;
end;

procedure TJvgReportEditorForm.FormClose(Sender: TObject; var Action:
  TCloseAction);
begin
  FReportParamEditor.Free;
  FScrollBox.HorzScrollBar.Position := 0;
  FScrollBox.VertScrollBar.Position := 0;
  Component.Save;
end;

procedure TJvgReportEditorForm.FE_OLEChange(Sender: TObject);
var
  S: string;
begin
  if (not Assigned(FSelectedControl)) or (not FileExists(FE_OLE.Text)) then
    Exit;
  S := FE_OLE.Text;
  if ExtractFilePath(Name) = ExtractFilePath(ParamStr(0)) then
    S := ExtractFileName(Name);
  if FSelectedControl.OLELinkToFile <> S then
    FSelectedControl.OLELinkToFile := S;
end;

procedure TJvgReportEditorForm.SpeedButton1Click(Sender: TObject);
begin
  if OpenOLEFile.Execute then
    FE_OLE.Text := OpenOLEFile.FileName;
end;

procedure TJvgReportEditorForm.sb_PrintClick(Sender: TObject);
begin
  if Assigned(Component) and (Component.ComponentList.Count > 0) then
    Component.Print;
  Component.OwnerWnd := Self;
  Component.ParentWnd := FScrollBox;
end;

procedure TJvgReportEditorForm.sb_PreviewClick(Sender: TObject);
var
  Form: TForm;
  Image: TImage;
  Bmp: TBitmap;
  R: TRect;
  I, W, H: Integer;
begin
  if not Assigned(Component) then
    Exit;
  Form := TForm.Create(nil);
  Form.Caption := RsPagePreview;
  Image := TImage.Create(Form);
  Bmp := TBitmap.Create;
  Image.Parent := Form;
  H := CentimetersToPixels(Form.Canvas.Handle, 29, True);
  W := CentimetersToPixels(Form.Canvas.Handle, 21, False);
  //  Image.Width := W+8;
  //  Image.Height := H+8;
  Image.Left := 0;
  Image.Top := 0;
  Bmp.Width := W + 7;
  Bmp.Height := H + 7;
  try
    //    Bmp.Canvas.Brush.Color := clWhite;
    //    R := Image.ClientRect; Bmp.Canvas.FillRect( R );

    with Component do
      for I := 0 to ComponentList.Count - 1 do
        with TJvgReportItem(ComponentList[I]) do
        begin
          PaintTo(Bmp.Canvas);
          if ContainOLE then
            OLEContainer.PaintTo(Bmp.Canvas.Handle, Left, Top);
        end;

    Bmp.Canvas.Brush.Color := clBtnFace;
    R := Bounds(Bmp.Width - 7, 0, 7, Bmp.Height - 7);
    Bmp.Canvas.FillRect(R);
    R := Bounds(0, Bmp.Height - 7, Bmp.Width - 7, 7);
    Bmp.Canvas.FillRect(R);
    Bmp.Canvas.Brush.Color := 0;
    R := Bounds(Bmp.Width - 7, 7, 7, Bmp.Height - 7);
    Bmp.Canvas.FillRect(R);
    R := Bounds(7, Bmp.Height - 7, Bmp.Width - 7, 7);
    Bmp.Canvas.FillRect(R);

    Image.Picture.Bitmap := Bmp;
    Image.Stretch := True;
    Image.Width := W div 2;
    Image.Height := H div 2;
    Form.ClientWidth := Image.Width;
    Form.ClientHeight := Image.Height;

    Bmp.Free;
    Bmp := nil;
    Form.ShowModal;
  finally
    Bmp.Free;
    Form.Free;
  end;
end;

procedure TJvgReportEditorForm.SpeedButton2Click(Sender: TObject);
begin
  if not Assigned(FReportParamEditor) then
    FReportParamEditor := TJvgReportParamEditor.Create(nil);
  FReportParamEditor.ShowModal;
end;

procedure TJvgReportEditorForm.cb_ComponentsKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  if Key = VK_RETURN then
  begin
    FSelectedControl.CompName := Trim(cb_Components.Text);
    RemakeComponentsList;
    cb_Components.Text := FSelectedControl.CompName;
  end;
  if Key = VK_ESCAPE then
    cb_Components.Text := FSelectedControl.CompName;
end;

procedure TJvgReportEditorForm.CheckBox1Click(Sender: TObject);
begin
  if Assigned(FSelectedControl) then
    FSelectedControl.Transparent := Ord(TCheckBox(Sender).Checked);
end;

procedure TJvgReportEditorForm.se_LeftClick(Sender: TObject;
  Button: TUDBtnType);
begin
  if Assigned(FSelectedControl) then
    FSelectedControl.FSize := TUpDown(Sender).Position;
end;

end.


⌨️ 快捷键说明

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