cxrichedit.pas

来自「胜天进销存源码,国产优秀的进销存」· PAS 代码 · 共 1,877 行 · 第 1/5 页

PAS
1,877
字号
procedure TcxRichInnerEditHelper.LockBounds(ALock: Boolean);
begin
  with Edit do
    if ALock then
      Inc(FLockBoundsCount)
    else
      if FLockBoundsCount > 0 then
        Dec(FLockBoundsCount);
end;

function TcxRichInnerEditHelper.GetOnChange: TNotifyEvent;
begin
  Result := Edit.OnChange;
end;

procedure TcxRichInnerEditHelper.SafelySetFocus;
var
  APrevAutoSelect: Boolean;
begin
  with Edit do
  begin
    APrevAutoSelect := AutoSelect;
    AutoSelect := False;
    SetFocus;
    AutoSelect := APrevAutoSelect;
  end;
end;

function TcxRichInnerEditHelper.CallDefWndProc(AMsg: UINT; WParam: WPARAM;
  LParam: LPARAM): LRESULT;
begin
  Result := CallWindowProc(Edit.DefWndProc, Edit.Handle, AMsg, WParam, LParam);
end;

function TcxRichInnerEditHelper.GetEditValue: TcxEditValue;
begin
  with Edit do
    Result := Text;
end;

procedure TcxRichInnerEditHelper.SetEditValue(const Value: TcxEditValue);
var
  AContainer: TcxCustomRichEdit;
begin
  AContainer := Edit.Container;
  if AContainer.PropertiesChange then
    Exit;

  if AContainer.ActiveProperties.MemoMode or not CanAllocateHandle(Edit) then
    Edit.Text := VarToStr(Value)
  else
  begin
    Edit.Container.LockChangeEvents(True);
    try
      Edit.HandleNeeded;
      LoadRichFromString(Edit.RichLines, VarToStr(Value));
    finally
      Edit.Container.LockChangeEvents(False);
    end;
  end;
end;

procedure TcxRichInnerEditHelper.SetParent(Value: TWinControl);
begin
  Edit.Parent := Value;
end;

procedure TcxRichInnerEditHelper.SetOnChange(Value: TNotifyEvent);
begin
  Edit.OnChange := Value;
end;

// IcxInnerTextEdit 
procedure TcxRichInnerEditHelper.ClearSelection;
begin
  Edit.ClearSelection;
end;

procedure TcxRichInnerEditHelper.CopyToClipboard;
begin
  Edit.CopyToClipboard;
end;

function TcxRichInnerEditHelper.GetAlignment: TAlignment;
begin
  Result := Edit.Alignment;
end;

function TcxRichInnerEditHelper.GetAutoSelect: Boolean;
begin
  Result := Edit.AutoSelect;
end;

function TcxRichInnerEditHelper.GetCharCase: TEditCharCase;
begin
  Result := Edit.CharCase;
end;

function TcxRichInnerEditHelper.GetEchoMode: TcxEditEchoMode;
begin
  Result := eemNormal;
end;

function TcxRichInnerEditHelper.GetFirstVisibleCharIndex: Integer;
var
  R: TRect;
begin
  SendMessage(Edit.Handle, EM_GETRECT, 0, Integer(@R));
  Result := SendMessage(Edit.Handle, EM_CHARFROMPOS, 0, LParam(@R.TopLeft));
end;

function TcxRichInnerEditHelper.GetHideSelection: Boolean;
begin
  Result := Edit.HideSelection;
end;

function TcxRichInnerEditHelper.GetInternalUpdating: Boolean;
begin
  Result := Edit.FInternalUpdating;
end;

function TcxRichInnerEditHelper.GetMaxLength: Integer;
begin
  Result := Edit.MaxLength;
end;

function TcxRichInnerEditHelper.GetMultiLine: Boolean;
begin
  Result := True;
end;

function TcxRichInnerEditHelper.GetOEMConvert: Boolean;
begin
  Result := Edit.OEMConvert;
end;

function TcxRichInnerEditHelper.GetOnSelChange: TNotifyEvent;
begin
  Result := Edit.OnSelectionChange;
end;

function TcxRichInnerEditHelper.GetPasswordChar: TCaptionChar;
begin
  Result := #0;
end;

function TcxRichInnerEditHelper.GetReadOnly: Boolean;
begin
  Result := Edit.ReadOnly;
end;

function TcxRichInnerEditHelper.GetSelLength: Integer;
begin
  Result := Edit.SelLength;
end;

function TcxRichInnerEditHelper.GetSelStart: Integer;
begin
  Result := Edit.SelStart;
end;

function TcxRichInnerEditHelper.GetSelText: string;
begin
  Result := Edit.SelText;
end;

procedure TcxRichInnerEditHelper.SelectAll;
begin
  if not Edit.Container.IsInplace then
    Edit.SelectAll;
end;

procedure TcxRichInnerEditHelper.SetAlignment(Value: TAlignment);
begin
  Edit.Alignment := Value;
end;

procedure TcxRichInnerEditHelper.SetAutoSelect(Value: Boolean);
begin
  Edit.AutoSelect := Value;
end;

procedure TcxRichInnerEditHelper.SetCharCase(Value: TEditCharCase);
begin
  Edit.CharCase := Value;
end;

procedure TcxRichInnerEditHelper.SetEchoMode(Value: TcxEditEchoMode);
begin
end;

procedure TcxRichInnerEditHelper.SetHideSelection(Value: Boolean);
begin
  if not Edit.Container.IsInplace then
    Edit.HideSelection := Value;
end;

procedure TcxRichInnerEditHelper.SetInternalUpdating(Value: Boolean);
begin
  Edit.FInternalUpdating := Value;
end;

procedure TcxRichInnerEditHelper.SetImeMode(Value: TImeMode);
begin
  Edit.ImeMode := Value;
end;

procedure TcxRichInnerEditHelper.SetImeName(const Value: TImeName);
begin
  Edit.ImeName := Value;
end;

procedure TcxRichInnerEditHelper.SetMaxLength(Value: Integer);
begin
  Edit.MaxLength := Value;
end;

procedure TcxRichInnerEditHelper.SetOEMConvert(Value: Boolean);
begin
  Edit.OEMConvert := Value;
end;

procedure TcxRichInnerEditHelper.SetOnSelChange(Value: TNotifyEvent);
begin
  Edit.OnSelectionChange := Value;
end;

procedure TcxRichInnerEditHelper.SetPasswordChar(Value: TCaptionChar);
begin
end;

procedure TcxRichInnerEditHelper.SetReadOnly(Value: Boolean);
begin
  Edit.ReadOnly := Value;
end;

procedure TcxRichInnerEditHelper.SetSelLength(Value: Integer);
begin
  Edit.SelLength := Value;
end;

procedure TcxRichInnerEditHelper.SetSelStart(Value: Integer);
begin
  with Edit do
    SelStart := Value;
end;

procedure TcxRichInnerEditHelper.SetSelText(Value: string);
begin
  Edit.SelText := Value;
end;

function TcxRichInnerEditHelper.GetImeLastChar: Char;
begin
  Result := #0;
end;

function TcxRichInnerEditHelper.GetImeMode: TImeMode;
begin
  Result := Edit.ImeMode;
end;

function TcxRichInnerEditHelper.GetImeName: TImeName;
begin
  Result := Edit.ImeName;
end;

function TcxRichInnerEditHelper.GetControlContainer: TcxContainer;
begin
  Result := Edit.Container;
end;

// IcxInnerMemo
function TcxRichInnerEditHelper.GetCaretPos: TPoint;
begin
  Result := Edit.CaretPos;
end;

function TcxRichInnerEditHelper.GetLines: TStrings;
begin
  Result := Edit.Lines;
end;

function TcxRichInnerEditHelper.GetScrollBars: TScrollStyle;
begin
  Result := Edit.ScrollBars;
end;

function TcxRichInnerEditHelper.GetWantReturns: Boolean;
begin
  Result := Edit.WantReturns;
end;

function TcxRichInnerEditHelper.GetWantTabs: Boolean;
begin
  Result := Edit.WantTabs;
end;

function TcxRichInnerEditHelper.GetWordWrap: Boolean;
begin
  Result := Edit.WordWrap;
end;

procedure TcxRichInnerEditHelper.SetCaretPos(const Value: TPoint);
begin
  SetMemoCaretPos(Edit, Value);
end;

procedure TcxRichInnerEditHelper.SetScrollBars(Value: TScrollStyle);
begin
  Edit.ScrollBars := Value;
end;

procedure TcxRichInnerEditHelper.SetWantReturns(Value: Boolean);
begin
  Edit.WantReturns := Value;
end;

procedure TcxRichInnerEditHelper.SetWantTabs(Value: Boolean);
begin
  Edit.WantTabs := Value;
end;

procedure TcxRichInnerEditHelper.SetWordWrap(Value: Boolean);
begin
  Edit.WordWrap := Value;
end;

{ TcxRichEditStrings }

constructor TcxRichEditStrings.Create(ARichEdit: TcxRichInnerEdit);
begin
  inherited Create;
  FRichEdit := ARichEdit;
  FTextType := SF_TEXT;
end;

destructor TcxRichEditStrings.Destroy;
begin
  FreeAndNil(FConverter);
  inherited Destroy;
end;

procedure TcxRichEditStrings.Clear;
begin
  if Count > 0 then
    RichEdit.Lines.Clear;
end;

function TcxRichEditStrings.CalcStreamTextType(AStreamOperation: TcxRichEditStreamOperation; ACustom: Boolean;
  ACustomStreamModes: TcxRichEditStreamModes): Longint;
var
  AStreamModes, AAllowStreamModes: TcxRichEditStreamModes;
begin
  if ACustom then
    AStreamModes := ACustomStreamModes
  else
    AStreamModes := GetStreamModes;
  AAllowStreamModes := GetAllowStreamModesByStreamOperation(AStreamOperation);
  if RichEdit.MemoMode or RichEdit.PlainText then
  begin
    Result := SF_TEXT;
    if (resmUnicode in AStreamModes) and (resmUnicode in AAllowStreamModes) then
      Result := Result or SF_UNICODE;
    if (resmTextIzed in AStreamModes) and (resmTextIzed in AAllowStreamModes) then
      Result := SF_TEXTIZED;
  end
  else
  begin
    Result := SF_RTF;
    if (resmRtfNoObjs in AStreamModes) and (resmRtfNoObjs in AAllowStreamModes) then
      Result := SF_RTFNOOBJS;
    if (resmPlainRtf in AStrea

⌨️ 快捷键说明

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