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

📄 frxdesgneditors.pas

📁 报表控件。FastReport 是非常强大的报表控件
💻 PAS
📖 第 1 页 / 共 3 页
字号:
procedure TfrxDataFieldProperty.GetValues;
var
  ds: TfrxDataSet;
begin
  inherited;
  ds := TfrxView(Component).DataSet;
  if ds <> nil then
    ds.GetFieldList(Values);
end;


{ TfrxLocSizeXProperty }

constructor TfrxLocSizeXProperty.Create(Designer: TfrxCustomDesigner);
begin
  inherited;
  FRatio := fr1CharX;
end;

function TfrxLocSizeXProperty.GetValue: String;
var
  e: Extended;
begin
  e := GetFloatValue;
  case TfrxDesignerForm(Designer).Units of
    duCM: e := e / 96 * 2.54;
    duInches: e := e / 96;
    duChars: e := e / FRatio;
  end;

  if e = Int(e) then
    Result := FloatToStr(e) else
    Result := Format('%f', [e]);
end;

procedure TfrxLocSizeXProperty.SetValue(const Value: String);
var
  e: Extended;
begin
  e := frxStrToFloat(Value);
  case TfrxDesignerForm(Designer).Units of
    duCM: e := e * 96 / 2.54;
    duInches: e := e * 96;
    duChars: e := e * FRatio;
  end;

  SetFloatValue(e);
end;


{ TfrxLocSizeYProperty }

constructor TfrxLocSizeYProperty.Create(Designer: TfrxCustomDesigner);
begin
  inherited;
  FRatio := fr1CharY;
end;


{ TfrxPaperXProperty }

constructor TfrxPaperXProperty.Create(Designer: TfrxCustomDesigner);
begin
  inherited;
  FRatio := fr1CharX;
end;

function TfrxPaperXProperty.GetValue: String;
var
  e: Extended;
begin
  e := GetFloatValue;
  case TfrxDesignerForm(Designer).Units of
    duCM: e := e / 10;
    duInches: e := e / 25.4;
    duPixels: e := e * 96 / 25.4;
    duChars: e := e * 96 / 25.4 / FRatio;
  end;

  if e = Int(e) then
    Result := FloatToStr(e) else
    Result := Format('%f', [e]);
end;

procedure TfrxPaperXProperty.SetValue(const Value: String);
var
  e: Extended;
begin
  e := frxStrToFloat(Value);
  case TfrxDesignerForm(Designer).Units of
    duCM: e := e * 10;
    duInches: e := e * 25.4;
    duPixels: e := e * 25.4 / 96;
    duChars: e := e * 25.4 / 96 * FRatio;
  end;

  SetFloatValue(e);
end;


{ TfrxPaperYProperty }

constructor TfrxPaperYProperty.Create(Designer: TfrxCustomDesigner);
begin
  inherited;
  FRatio := fr1CharY;
end;


{ TfrxEventProperty }

function TfrxEventProperty.Edit: Boolean;
var
  i: Integer;
begin
  if Value = '' then
  begin
    Value := frComponent.Name + GetName;
    i := frxLocateEventHandler(Designer.Code, Designer.Report.ScriptLanguage,
      Value);
    if i = -1 then
      i := frxAddEvent(Designer.Code, Designer.Report.ScriptLanguage,
        PropInfo.PropType^, Value) else
      Inc(i, 3);

    TfrxDesignerForm(Designer).SwitchToCodeWindow;
    TfrxDesignerForm(Designer).CodeWindow.UpdateView;
    TfrxDesignerForm(Designer).CodeWindow.SetPos(3, i);
    Result := True;
  end
  else
  begin
    i := frxLocateEventHandler(Designer.Code, Designer.Report.ScriptLanguage,
      Value);

    TfrxDesignerForm(Designer).SwitchToCodeWindow;
    TfrxDesignerForm(Designer).CodeWindow.SetPos(1, i + 3);
    Result := False;
  end;
end;

function TfrxEventProperty.GetAttributes: TfrxPropertyAttributes;
begin
  Result := [paMultiSelect, paValueList];
end;

procedure TfrxEventProperty.GetValues;
begin
  inherited;
  frxGetEventHandlersList(Designer.Code, Designer.Report.ScriptLanguage,
    PropInfo.PropType^, Values);
end;


{ TfrxStringsProperty }

function TfrxStringsProperty.Edit: Boolean;
var
  l: TStrings;
begin
  with TfrxStringsEditorForm.Create(Designer) do
  begin
    l := TStrings(GetOrdValue);
    Memo.Lines.Assign(l);
    Result := ShowModal = mrOk;
    if Result then
      l.Assign(Memo.Lines);
    Free;
  end;
end;

function TfrxStringsProperty.GetAttributes: TfrxPropertyAttributes;
begin
  Result := [paDialog, paReadOnly];
end;


{ TfrxBrushProperty }

function TfrxBrushProperty.GetAttributes: TfrxPropertyAttributes;
begin
  Result := [paMultiSelect, paValueList, paOwnerDraw];
end;

procedure TfrxBrushProperty.OnDrawLBItem(Control: TWinControl; Index: Integer;
  ARect: TRect; State: TOwnerDrawState);
begin
  inherited;
  with TListBox(Control), TListBox(Control).Canvas do
  begin
    Brush.Style := TBrushStyle(Index);
    Brush.Color := clBlack;
    Rectangle(ARect.Left + 2, ARect.Top + 2, ARect.Left + (ARect.Bottom - ARect.Top - 2), ARect.Bottom - 2);
  end;
end;

procedure TfrxBrushProperty.OnDrawItem(Canvas: TCanvas; ARect: TRect);
begin
  inherited;
  with Canvas do
  begin
    Brush.Style := TBrushStyle(GetOrdValue);
    Brush.Color := clBlack;
    Rectangle(ARect.Left, ARect.Top + 1, ARect.Left + (ARect.Bottom - ARect.Top - 5), ARect.Bottom - 4);
  end;
end;


{ TfrxFrameStyleProperty }

function TfrxFrameStyleProperty.GetAttributes: TfrxPropertyAttributes;
begin
  Result := [paMultiSelect, paValueList, paOwnerDraw];
end;

procedure HLine(Canvas: TCanvas; X, Y, DX: Integer);
var
  i: Integer;
begin
  with Canvas do
  begin
    Pen.Color := clBlack;
    if Pen.Style = psClear then
    begin
      Pen.Style := psSolid;
      for i := 0 to 1 do
      begin
        MoveTo(X, Y - 2 + i * 2);
        LineTo(X + DX, Y - 2 + i * 2);
      end
    end
    else
      for i := 0 to 1 do
      begin
        MoveTo(X, Y - 1 + i);
        LineTo(X + DX, Y - 1 + i);
      end;
  end;
end;

procedure TfrxFrameStyleProperty.OnDrawLBItem(Control: TWinControl; Index: Integer;
  ARect: TRect; State: TOwnerDrawState);
begin
  with TListBox(Control), TListBox(Control).Canvas do
  begin
    FillRect(ARect);
    TextOut(ARect.Left + 40, ARect.Top + 1, TListBox(Control).Items[Index]);

    Pen.Color := clGray;
    Brush.Color := clWhite;
    Rectangle(ARect.Left + 2, ARect.Top + 2, ARect.Left + 36, ARect.Bottom - 2);

    Pen.Style := TPenStyle(Index);
    HLine(TListBox(Control).Canvas, ARect.Left + 3, ARect.Top + (ARect.Bottom - ARect.Top) div 2, 32);
    Pen.Style := psSolid;
  end;
end;

procedure TfrxFrameStyleProperty.OnDrawItem(Canvas: TCanvas; ARect: TRect);
begin
  with Canvas do
  begin
    TextOut(ARect.Left + 38, ARect.Top, Value);

    Pen.Color := clGray;
    Brush.Color := clWhite;
    Rectangle(ARect.Left, ARect.Top + 1, ARect.Left + 34, ARect.Bottom - 4);

    Pen.Color := clBlack;
    Pen.Style := TPenStyle(GetOrdValue);
    HLine(Canvas, ARect.Left + 1, ARect.Top + (ARect.Bottom - ARect.Top) div 2 - 1, 32);
    Pen.Style := psSolid;
  end;
end;

function TfrxFrameStyleProperty.GetExtraLBSize: Integer;
begin
  Result := 36;
end;


{ TfrxDisplayFormatProperty }

function TfrxDisplayFormatProperty.Edit: Boolean;
var
  i: Integer;
  c: TfrxComponent;
begin
  with TfrxFormatEditorForm.Create(Designer) do
  begin
    Format.Assign(TfrxCustomMemoView(Component).DisplayFormat);
    Result := ShowModal = mrOk;
    if Result then
      for i := 0 to Self.Designer.SelectedObjects.Count - 1 do
      begin
        c := Self.Designer.SelectedObjects[i];
        if (c is TfrxCustomMemoView) and not (rfDontModify in c.Restrictions) then
          TfrxCustomMemoView(c).DisplayFormat := Format;
      end;
    Free;
  end;
end;

function TfrxDisplayFormatProperty.GetAttributes: TfrxPropertyAttributes;
begin
  Result := [paDialog, paMultiSelect, paReadOnly];
end;


{ TfrxBooleanProperty }

function TfrxBooleanProperty.GetAttributes: TfrxPropertyAttributes;
begin
  Result := [paMultiSelect, paValueList, paOwnerDraw];
end;

procedure TfrxBooleanProperty.OnDrawItem(Canvas: TCanvas; ARect: TRect);
begin
  inherited;
  with Canvas do
  begin
    Rectangle(ARect.Left, ARect.Top + 1, ARect.Left + (ARect.Bottom - ARect.Top - 5), ARect.Bottom - 4);
    Pen.Color := clBlack;
    if Boolean(GetOrdValue) = True then
      with ARect do
      begin
        PolyLine([Point(Left + 2, Top + 5), Point(Left + 4, Top + 7), Point(Left + 9, Top + 2)]);
        PolyLine([Point(Left + 2, Top + 6), Point(Left + 4, Top + 8), Point(Left + 9, Top + 3)]);
        PolyLine([Point(Left + 2, Top + 7), Point(Left + 4, Top + 9), Point(Left + 9, Top + 4)]);
      end;
  end;
end;

procedure TfrxBooleanProperty.OnDrawLBItem(Control: TWinControl;
  Index: Integer; ARect: TRect; State: TOwnerDrawState);
begin
  inherited;
  with TListBox(Control), TListBox(Control).Canvas do
  begin
    Rectangle(ARect.Left + 2, ARect.Top + 2, ARect.Left + (ARect.Bottom - ARect.Top - 2), ARect.Bottom - 2);
    Pen.Color := clBlack;
    if Index = 1 then
      with ARect do
      begin
        PolyLine([Point(Left + 5, Top + 6), Point(Left + 7, Top + 8), Point(Left + 12, Top + 3)]);
        PolyLine([Point(Left + 5, Top + 7), Point(Left + 7, Top + 9), Point(Left + 12, Top + 4)]);
        PolyLine([Point(Left + 5, Top + 8), Point(Left + 7, Top + 10), Point(Left + 12, Top + 5)]);
      end;
  end;
end;


{ TfrxPrinterProperty }

function TfrxPrinterProperty.GetAttributes: TfrxPropertyAttributes;
begin
  Result := [paValueList];
end;

procedure TfrxPrinterProperty.GetValues;
begin
  inherited;
  Values.Assign(frxPrinters.Printers);
  Values.Insert(0, frxResources.Get('prDefault'));
end;


initialization
  frxObjects.RegisterObject1(TfrxMemoView, nil, '', '', 0, 2);
  frxObjects.RegisterObject1(TfrxPictureView, nil, '', '', 0, 3);
  frxObjects.RegisterObject1(TfrxSubreport, nil, '', '', 0, 4);
  frxObjects.RegisterObject1(TfrxLineView, nil, '', '', 0, 5);
  frxObjects.RegisterObject1(TfrxSysMemoView, nil, '', '', 0, 32);
  frxObjects.RegisterCategory('Draw', nil, 'obCatDraw', 6);
  frxObjects.RegisterCategory('Other', nil, 'obCatOther', 21);
  frxObjects.RegisterObject1(TfrxLineView, nil, 'obDiagLine', 'Draw', 1, 7);
  frxObjects.RegisterObject1(TfrxShapeView, nil, 'obRect', 'Draw', 0, 8);
  frxObjects.RegisterObject1(TfrxShapeView, nil, 'obRoundRect', 'Draw', 1, 9);
  frxObjects.RegisterObject1(TfrxShapeView, nil, 'obEllipse', 'Draw', 2, 10);
  frxObjects.RegisterObject1(TfrxShapeView, nil, 'obTrian', 'Draw', 3, 11);
  frxObjects.RegisterObject1(TfrxShapeView, nil, 'obDiamond', 'Draw', 4, 31);

  frxComponentEditors.Register(TfrxReportPage, TfrxPageEditor);
  frxComponentEditors.Register(TfrxView, TfrxViewEditor);
  frxComponentEditors.Register(TfrxMemoView, TfrxMemoEditor);
  frxComponentEditors.Register(TfrxSysMemoView, TfrxSysMemoEditor);
  frxComponentEditors.Register(TfrxDMPMemoView, TfrxMemoEditor);
  frxComponentEditors.Register(TfrxLineView, TfrxLineEditor);
  frxComponentEditors.Register(TfrxDMPLineView, TfrxLineEditor);
  frxComponentEditors.Register(TfrxPictureView, TfrxPictureEditor);
  frxComponentEditors.Register(TfrxBand, TfrxBandEditor);
  frxComponentEditors.Register(TfrxDataBand, TfrxDataBandEditor);
  frxComponentEditors.Register(TfrxHeader, TfrxHeaderEditor);
  frxComponentEditors.Register(TfrxPageHeader, TfrxPageHeaderEditor);
  frxComponentEditors.Register(TfrxPageFooter, TfrxPageFooterEditor);
  frxComponentEditors.Register(TfrxGroupHeader, TfrxGroupHeaderEditor);
  frxComponentEditors.Register(TfrxDialogControl, TfrxDialogControlEditor);
  frxComponentEditors.Register(TfrxSubReport, TfrxSubreportEditor);

  frxPropertyEditors.Register(TypeInfo(Extended), TfrxComponent, 'Left', TfrxLocSizeXProperty);
  frxPropertyEditors.Register(TypeInfo(Extended), TfrxComponent, 'Top', TfrxLocSizeYProperty);
  frxPropertyEditors.Register(TypeInfo(Extended), TfrxComponent, 'Width', TfrxLocSizeXProperty);
  frxPropertyEditors.Register(TypeInfo(Extended), TfrxComponent, 'Height', TfrxLocSizeYProperty);

  frxPropertyEditors.Register(TypeInfo(Extended), TfrxReportPage, 'PaperWidth', TfrxPaperXProperty);
  frxPropertyEditors.Register(TypeInfo(Extended), TfrxReportPage, 'PaperHeight', TfrxPaperYProperty);
  frxPropertyEditors.Register(TypeInfo(Extended), TfrxReportPage, 'LeftMargin', TfrxPaperXProperty);
  frxPropertyEditors.Register(TypeInfo(Extended), TfrxReportPage, 'RightMargin', TfrxPaperXProperty);
  frxPropertyEditors.Register(TypeInfo(Extended), TfrxReportPage, 'TopMargin', TfrxPaperYProperty);
  frxPropertyEditors.Register(TypeInfo(Extended), TfrxReportPage, 'BottomMargin', TfrxPaperYProperty);

  frxPropertyEditors.RegisterEventEditor(TfrxEventProperty);

  frxPropertyEditors.Register(TypeInfo(Boolean), nil, '', TfrxBooleanProperty);
  frxPropertyEditors.Register(TypeInfo(TfrxFrame), nil, '', TfrxFrameProperty);
  frxPropertyEditors.Register(TypeInfo(TPicture), nil, '', TfrxPictureProperty);
  frxPropertyEditors.Register(TypeInfo(TBitmap), nil, '', TfrxBitmapProperty);
  frxPropertyEditors.Register(TypeInfo(TfrxDataSet), nil, '', TfrxDataSetProperty);
  frxPropertyEditors.Register(TypeInfo(String), TfrxView, 'DataField', TfrxDataFieldProperty);
  frxPropertyEditors.Register(TypeInfo(TStrings), nil, '', TfrxStringsProperty);
  frxPropertyEditors.Register(TypeInfo(TWideStrings), TfrxCustomMemoView, 'Memo', TfrxMemoProperty);
  frxPropertyEditors.Register(TypeInfo(TBrushStyle), nil, '', TfrxBrushProperty);
  frxPropertyEditors.Register(TypeInfo(TfrxFrameStyle), nil, '', TfrxFrameStyleProperty);
  frxPropertyEditors.Register(TypeInfo(String), TfrxMemoView, 'DisplayFormat', TfrxDisplayFormatProperty);
  frxPropertyEditors.Register(TypeInfo(Extended), TfrxDataBand, 'ColumnWidth', TfrxLocSizeXProperty);
  frxPropertyEditors.Register(TypeInfo(Extended), TfrxDataBand, 'ColumnGap', TfrxLocSizeXProperty);
  frxPropertyEditors.Register(TypeInfo(String), TfrxPrintOptions, 'Printer', TfrxPrinterProperty);

  frxHideProperties(TfrxReport, 'DefaultLanguage;IniFile;Name;Preview;ScriptLanguage;ScriptText;Tag;Variables;DataSetName;DotMatrixReport;OldStyleProgress;ShowProgress;StoreInDFM');
  frxHideProperties(TfrxEngineOptions, 'NewSilentMode;MaxMemSize;PrintIfEmpty;SilentMode;TempDir;UseFileCache');
  frxHideProperties(TfrxPreviewOptions, 'AllowEdit;Buttons;DoubleBuffered;Maximized;MDIChild;Modal;ShowCaptions;Zoom;ZoomMode');
  frxHideProperties(TfrxReportOptions, 'CreateDate;LastChange;Compressed');
  frxHideProperties(TfrxReportPage, 'Bin;BinOtherPages;ColumnWidth;ColumnPositions;PaperSize;DataSetName;HGuides;VGuides');
  frxHideProperties(TfrxDMPPage, 'BackPicture;Color;Font;Frame');
  frxHideProperties(TfrxReportComponent, 'GroupIndex');
  frxHideProperties(TfrxView, 'DataSetName');
  frxHideProperties(TfrxBand, 'Vertical');
  frxHideProperties(TfrxDataBand, 'DataSetName');
  frxHideProperties(TFont, 'Height;Pitch');
  frxHideProperties(TfrxReportOptions, 'Password');
  frxHideProperties(TfrxHighlight, 'Active');


end.


//<censored>

⌨️ 快捷键说明

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