TextObject based inplace editors

Top  Previous  Next

The following code requires the unit WPCTRInplaceWinEdit to be added to the uses clause.

 

This code creates a check box:

clip0025

 

var obj : TWPTextObj;

begin

   obj := WPRichText2.InputInplaceEdit('MYCHECK', inplfrmID_check, 1000);

   obj.Width := 1200;

   obj.InplaceEditor.group := 1;

   obj.InplaceEditor.number := 1;

   obj.InplaceEditor.SetGUIProp(WPINPL_CHECK_PRP_ALIGNMENT, 2);

   obj.InplaceEditor.SetGUIProp(WPINPL_PRP_ID_V_PADDING, 4);

   obj.InplaceEditor.SetGUIProp(WPINPL_PRP_ID_H_PADDING, 0);

   obj.InplaceEditor.SetGUIStrProp( WPINPL_PRP_ID_CAPTION, ' CHECK' );

   obj.InplaceEditor.SetGUIProp(WPINPL_PRP_ID_COLOR, $00FFA0);

end;

 

If you are working on a paragraph (or cell) you can also code

 

  obj := someparagraph.AppendInplaceEditor(inplfrmID_check);

  obj.InplaceEditor.name := 'MYCHECK';

 

Note: Instead of inplfrmID_check you can also write 'wpcubed.check'.

 

If you want to use an custom painted checkbox clip0026 use this code:

 

obj := WPRichText2.InputInplaceEdit('MYCHECK', inplfrmID_check, 1000);

 

and use an event handler

 

function TForm1.DoOnInplaceeditCustomPaint( Sender : TControl;

          Editor : TWPToolsInplaceEditorAbstractBase;

          Canvas:   TCanvas;

        var Bounds : TRect; BaseLine : Integer;  Stage : TWPToolsInplaceEditorPaintStage;

        var PaintData : TObject; Xmul : Single = 1;  Ymul : Single = 1 ) : Boolean;

begin

 Result := true; // default!

if (Stage=wpPaintData) and (Editor is TWPToolsBaseWinControlInplaceEditor) then

begin

   SetTextAlign(Canvas.Handle, TA_BASELINE);

   Canvas.TextOut(Bounds.Left, Bounds.Top + BaseLine,

      TWPToolsBaseWinControlInplaceEditor(Editor).Caption);

   WPImageList1.DrawImage(Canvas,

       Bounds.Right-Bounds.Height, Bounds.Top, Bounds.Height, Bounds.Height, true, true,

       10 + // = basis index of the image in WPImageList

       Ord(TWPToolsBaseWinControlInplaceEditor(Editor).Checked));

   Result := false;

end;

end;

 

Use this code in Form.OnCreate to activate the event handler:

 

WPRichText1.Memo.OnInplaceeditCustomPaint := DoOnInplaceeditCustomPaint;