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

📄 rm_insp.pas

📁 这是一个功能强大
💻 PAS
📖 第 1 页 / 共 3 页
字号:
  end;
end;




{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
{ TRMInspForm }

procedure TRMInspForm.OnGetEditorClassEvent(Sender: TObject;
  AInstance: TPersistent; APropInfo: PPropInfo; var AEditorClass: TELPropEditorClass);
begin
  aEditorClass := nil;
  if aPropInfo.PropType^.Kind = tkMethod then
  begin
    aEditorClass := TMethodEditor;
  end;
end;

constructor TRMInspForm.Create(AOwner: TComponent);

  procedure _RegisterPropEditor;
  var
    i: Integer;
    liItem: TRMAddinPropEditor;
  begin
    FInsp.RegisterPropEditor(TypeInfo(TWideStrings), nil, 'Memo', TStringsPropEditor);
    FInsp.RegisterPropEditor(TypeInfo(string), TRMBand, 'ChildBand', TChildBandEditor);
    FInsp.RegisterPropEditor(TypeInfo(string), TRMBandHeader, 'DataBandName', TGroupHeaderBandEditor);
    FInsp.RegisterPropEditor(TypeInfo(string), TRMBandFooter, 'DataBandName', TGroupHeaderBandEditor);
    FInsp.RegisterPropEditor(TypeInfo(string), TRMBandGroupHeader, 'MasterBandName', TGroupHeaderBandEditor);
    FInsp.RegisterPropEditor(TypeInfo(string), TRMBandGroupFooter, 'GroupHeaderBandName', TGroupFooterBandEditor);
    FInsp.RegisterPropEditor(TypeInfo(string), TRMBandDetailData, 'MasterBandName', TGroupHeaderBandEditor);
    FInsp.RegisterPropEditor(TypeInfo(string), TRMCustomBandView, 'DataSetName', TDataSetEditor);
    FInsp.RegisterPropEditor(TypeInfo(string), TRMBandGroupHeader, 'GroupCondition', TGroupConditionEditor);
    FInsp.RegisterPropEditor(TypeInfo(string), TRMCalcMemoView, 'ResultExpression', TExpressionEditor);
    FInsp.RegisterPropEditor(TypeInfo(string), TRMBand, 'PrintCondition', TExpressionEditor);
    FInsp.RegisterPropEditor(TypeInfo(string), TRMBand, 'NewPageCondition', TExpressionEditor);
    FInsp.RegisterPropEditor(TypeInfo(string), TRMBand, 'OutlineText', TExpressionEditor);

    FInsp.RegisterPropEditor(TypeInfo(TRMHighlight), TRMCustomMemoView, 'Highlight', THighlightEditor);
    FInsp.RegisterPropEditor(TypeInfo(string), TRMHighlight, 'Condition', TExpressionEditor);
    FInsp.RegisterPropEditor(TypeInfo(string), TRMReportView, 'ShiftWith', TShiftWithEditor);
    FInsp.RegisterPropEditor(TypeInfo(string), TRMReportView, 'StretchWith', TShiftWithEditor);
    FInsp.RegisterPropEditor(TypeInfo(string), TRMReportView, 'ShiftRelativeTo', TShiftWithEditor);
    FInsp.RegisterPropEditor(TypeInfo(string), TRMReportView, 'DataField', TDataFieldEditor);
    FInsp.RegisterPropEditor(TypeInfo(string), TRMRepeatedOptions, 'MasterMemoView', TMasterMemoViewEditor);
    FInsp.RegisterPropEditor(TypeInfo(string), nil, 'DisplayFormat', TDisplayFormatEditor);
    FInsp.RegisterPropEditor(TypeInfo(string), nil, 'StyleName', TStyleNameEditor);

    FInsp.RegisterPropEditor(TypeInfo(TRMCalcOptions), TRMCalcMemoView, 'CalcOptions', TCalcOptionsEditor);
    FInsp.RegisterPropEditor(TypeInfo(string), TRMCalcOptions, 'Filter', TExpressionEditor);
    FInsp.RegisterPropEditor(TypeInfo(string), TRMCalcOptions, 'IntalizeValue', TExpressionEditor);
    FInsp.RegisterPropEditor(TypeInfo(string), TRMCalcOptions, 'AggregateValue', TExpressionEditor);
    FInsp.RegisterPropEditor(TypeInfo(string), TRMCalcOptions, 'AggrBandName', TGroupHeaderBandEditor);
    FInsp.RegisterPropEditor(TypeInfo(string), TRMCalcOptions, 'ResetGroupName', TExpressionEditor);
    FInsp.RegisterPropEditor(TypeInfo(string), TRMReportView, 'SubReport', TReportView_SubReportEditor);

    FInsp.RegisterPropEditor(TypeInfo(TPicture), nil, 'Picture', TPicturePropEditor);
    FInsp.RegisterPropEditor(TypeInfo(TPicture), TRMPictureView, 'Picture', TPictureView_PictureEditor);
    FInsp.RegisterPropEditor(TypeInfo(TPicture), TRMReportPage, 'BackPicture', TPageBackPictureEditor);
    FInsp.RegisterPropEditor(TypeInfo(TBitmap), nil, '', TBitmappropEditor);

    if FAddinPropEditors <> nil then
    begin
      for i := 0 to FAddinPropEditors.Count - 1 do
      begin
        liItem := FAddinPropEditors[i];
        with liItem do
          FInsp.RegisterPropEditor(TypeInfo, ObjectClass, PropName, EditorClass);
      end;
    end;
  end;

begin
  inherited Create(AOwner);

  FPanelTop := TPanel.Create(Self);
  FPanelTop.Parent := Self;
  FPanelTop.Align := alTop;
  FPanelTop.Height := 26;
  FPanelTop.BevelOuter := bvNone;

{$IFNDEF COMPILER7_UP}
  FObjects := TStringList.Create();
{$ENDIF}
  FcmbObjects := TComboBox.Create(Self);
  with FcmbObjects do
  begin
    Parent := FPanelTop;
    SetBounds(0, 2, 21, 169);
    Style := csDropDownList;
    DropDownCount := 12;
    ItemHeight := 15;
    Sorted := True;
{$IFDEF COMPILER7_UP}
    Items.NameValueSeparator := ' ';
{$ENDIF}
    OnClick := cmbObjectsClick;
    OnDropDown := cmbObjectsDropDown;
  end;

  FTab := TTabControl.Create(Self);
  with FTab do
  begin
    Parent := Self;
    HotTrack := True;
    Align := alClient;
    OnChange := OnTabChangeEvent;
  end;

  FInsp := TELPropertyInspector.Create(Self);
  with FInsp do
  begin
    Parent := FTab;
    Align := alClient;
    OnClick := Insp_OnClick;
    OnGetEditorClass := OnGetEditorClassEvent;
  end;
  _RegisterPropEditor;

  FSplitter1 := TSplitter.Create(Self);
  with FSplitter1 do
  begin
    Parent := Self;
    Align := alBottom;
    Cursor := crVSplit;
  end;

  FPanelBottom := TPanel.Create(Self);
  with FPanelBottom do
  begin
    Parent := Self;
    Align := alBottom;
    Height := 54;
    BevelOuter := bvNone;
    BorderWidth := 2;
  end;
  FPanel2 := TPanel.Create(Self);
  with FPanel2 do
  begin
    Parent := FPanelBottom;
    SetBounds(2, 2, 172, 50);
    Align := alClient;
    BevelOuter := bvLowered;
    OnResize := Panel2Resize;
  end;
  FLabelTitle := TLabel.Create(Self);
  with FLabelTitle do
  begin
    Parent := FPanel2;
    SetBounds(6, 1, 155, 13);
    AutoSize := False;
  end;
  FLabelCommon := TLabel.Create(Self);
  with FLabelCommon do
  begin
    Parent := FPanel2;
    SetBounds(12, 17, 154, 28);
    AutoSize := False;
    Color := clBtnFace;
    WordWrap := True;
  end;

{$IFDEF USE_TB2k}
  Parent := TWinControl(AOwner);
  Floating := True;
{$ENDIF}
  FullSize := False;
  CloseButtonWhenDocked := True;
  UseLastDock := False;

  SetBounds(438, 179, 184, 308);
  FSaveHeight := ClientHeight;
  OnResize := OnResizeEvent;
  OnVisibleChanged := OnVisibleChangedEvent;
  OnMove := OnMoveEvent;

  OnResizeEvent(nil);
  Localize;
end;

destructor TRMInspForm.Destroy;
begin
{$IFNDEF COMPILER7_UP}
  FObjects.Free();
{$ENDIF}
  inherited Destroy;
end;

procedure TRMInspForm.SetCurReport(aObject: TObject);
begin
  FCurReport := TRMReport(aObject);
end;

procedure TRMInspForm.Localize;
begin
  Font.Name := RMLoadStr(SRMDefaultFontName);
  Font.Size := StrToInt(RMLoadStr(SRMDefaultFontSize));
  Font.Charset := StrToInt(RMLoadStr(SCharset));

  FInsp.Font.Assign(Font);

  RMSetStrProp(Self, 'Caption', rmRes + 70);
  Tab.Tabs.Clear;
  Tab.Tabs.Add(RMLoadStr(rmRes + 71));
  Tab.Tabs.Add(RMLoadStr(rmRes + 72));

  FLabelCommon.Font.Color := clBlue;
end;

procedure TRMInspForm.BeginUpdate;
begin
  FInsp.BeginUpdate;
end;

procedure TRMInspForm.EndUpdate;
begin
  FInsp.EndUpdate;
  Insp_OnClick(nil);
end;

procedure TRMInspForm.AddObject(aObject: TPersistent);
begin
  FInsp.Add(aObject);
end;

procedure TRMInspForm.AddObjects(aObjects: array of TPersistent);
begin
  FInsp.AddObjects(aObjects);
end;

procedure TRMInspForm.ClearObjects;
begin
  FInsp.Clear;
end;

procedure TRMInspForm.SetCurrentObject(aClassName, aName: string);
begin
  if (FcmbObjects.ItemIndex < 0) or (Objects.Names[FcmbObjects.ItemIndex] <> aName) then
  begin
    FCurObjectClassName := aClassName;
    cmbObjectsDropDown(nil);
    FcmbObjects.ItemIndex := Objects.IndexOfName(aName);
  end;
end;

{$IFNDEF COMPILER7_UP}

function CVStringsSep(Src, dsc: TStrings; OldSep, NewSep: Char): boolean;
var
  i: integer;
begin
  Result := false;
  if (Src = nil) or (Src.Count = 0) then Exit;
  if dsc = nil then dsc := TStringList.Create();

  Dsc.Clear;
  Dsc.AddStrings(Src);
  for i := 0 to Dsc.Count - 1 do
  begin
    Dsc[i] := StringReplace(Dsc[i], OldSep, NewSep, []);
  end;
  Result := True;
end;
{$ENDIF}

procedure TRMInspForm.cmbObjectsDropDown(Sender: TObject);
var
  s: string;
begin
  if FcmbObjects.ItemIndex <> -1 then
    s := Objects.Names[FcmbObjects.ItemIndex]
  else
    s := '';

  if Assigned(FOnGetObjects) then
    FOnGetObjects(FcmbObjects.Items);

{$IFNDEF COMPILER7_UP}
  CVStringsSep(FcmbObjects.Items, FObjects, ' ', '='); //转换
{$ENDIF}
  FcmbObjects.ItemIndex := Objects.IndexOfName(s);
end;

procedure TRMInspForm.cmbObjectsClick(Sender: TObject);
begin
  if Assigned(FOnSelectionChanged) then
    FOnSelectionChanged(Objects.Names[FCmbObjects.ItemIndex]);
end;

procedure TRMInspForm.OnResizeEvent(Sender: TObject);
begin
  FSaveHeight := ClientHeight;
  FcmbObjects.Width := ClientWidth;
end;

procedure TRMInspForm.OnVisibleChangedEvent(Sender: TObject);
begin
end;

function TRMInspForm.GetSplitterPos: Integer;
begin
  Result := FInsp.Splitter;
end;

procedure TRMInspForm.SetSplitterPos(Value: Integer);
begin
  if (Value > 10) and (Value < FInsp.ClientWidth - 10) then
  begin
    FInsp.Splitter := Value;
  end;
end;

function TRMInspForm.GetSplitterPos1: Integer;
begin
  Result := FInsp.Height;
end;

procedure TRMInspForm.SetSplitterPos1(Value: Integer);
begin
  FInsp.Height := Value;
end;

procedure TRMInspForm.OnTabChangeEvent(Sender: TObject);
begin
  BeginUpdate;
  if FTab.TabIndex = 0 then
    FInsp.PropKinds := [pkProperties]
  else
    FInsp.PropKinds := [pkEvents];
  EndUpdate;
end;

procedure TRMInspForm.WMLButtonDBLCLK(var Message: TWMNCLButtonDown);
var
  liSaveHeight: Integer;
begin
  FInsp.ClosePopup;
  if ClientHeight > 0 then
  begin
    liSaveHeight := ClientHeight;
    ClientHeight := 0;
    FSaveHeight := liSaveHeight;
  end
  else
    ClientHeight := FSaveHeight;
end;

procedure TRMInspForm.RestorePos;
begin
  if ClientHeight > 0 then
  begin
  end
  else
    ClientHeight := FSaveHeight;
end;

procedure TRMInspForm.WMRButtonDBLCLK(var Message: TWMNCRButtonDown);
var
  liSaveHeight: Integer;
begin
  FInsp.ClosePopup;
  if ClientHeight > 0 then
  begin
    liSaveHeight := ClientHeight;
    ClientHeight := 0;
    FSaveHeight := liSaveHeight;
  end
  else
    ClientHeight := FSaveHeight;
end;

procedure TRMInspForm.OnMoveEvent(Sender: TObject);
begin
  FInsp.ClosePopup;
end;

function TRMInspForm.GetObjects: TStrings;
begin
{$IFDEF COMPILER7_UP}
  Result := FcmbObjects.Items;
{$ELSE}
  Result := FObjects;
{$ENDIF}
end;

procedure TRMInspForm.Panel2Resize(Sender: TObject);
begin
  FLabelTitle.Width := FPanel2.ClientWidth - FLabelTitle.Left - 2;
  FLabelCommon.Width := FPanel2.ClientWidth - FLabelCommon.Left - 2;
  FLabelCommon.Height := FPanel2.ClientHeight - FLabelCommon.Top - 2;
end;

procedure TRMInspForm.Insp_OnClick(Sender: TObject);
var
  lActiveItem: TELPropsPageItem;
  t: TPersistent;
  PropInf: PPropInfo;
begin
  lActiveItem := FInsp.ActiveItem;
  t := TPersistent(FInsp.Objects[0]); //dejoy modify by 2003-9-28
  if lActiveItem = nil then
  begin
    FLabelTitle.Caption := '';
    FLabelCommon.Caption := '';
  end
  else
  begin
    if RMLocalizedPropertyNames then
      FLabelTitle.Caption := lActiveItem.VirtualCaption
    else
      FLabelTitle.Caption := lActiveItem.Caption;

    //dejoy added begin at 2003-9-28
    PropInf := GetPropInfo(t, lActiveItem.Caption, [tkMethod]);
    if PropInf <> nil then
    begin
      FLabelCommon.Caption := GetMethodDefinition(PropInf.PropType^);
      if lActiveItem.PropCommon <> FLabelTitle.Caption then
        FLabelCommon.Caption := FLabelCommon.Caption + #13#10 + lActiveItem.PropCommon;
    end
    else
      FLabelCommon.Caption := lActiveItem.PropCommon;
    //dejoy added end at 2003-9-28
  end;
end;

{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}

procedure ClearPropeditors;
var
  i: Integer;
begin
  if FAddinPropEditors <> nil then
  begin
    for i := 0 to FAddinPropEditors.Count - 1 do
    begin
      TRMAddinPropEditor(FAddinPropEditors[i]).Free;
    end;
    FAddinPropEditors.Clear;
  end;
end;

initialization

finalization
  if FAddinPropEditors <> nil then
  begin
    ClearPropeditors;
    FAddinPropEditors.Free;
    FAddinPropEditors := nil;
  end;

end.

⌨️ 快捷键说明

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