Version: 2.9.4
Public Member Functions
wxRichTextField Class Reference

#include </home/zeitlin/src/wx/github/interface/wx/richtext/richtextbuffer.h>

Inheritance diagram for wxRichTextField:

Detailed Description

This class implements the general concept of a field, an object that represents additional functionality such as a footnote, a bookmark, a page number, a table of contents, and so on.

Extra information (such as a bookmark name) can be stored in the object properties.

Drawing, layout, and property editing is delegated to classes derived from wxRichTextFieldType, such as instances of wxRichTextFieldTypeStandard; this makes the use of fields an efficient method of introducing extra functionality, since most of the information required to draw a field (such as a bitmap) is kept centrally in a single field type definition.

The FieldType property, accessed by SetFieldType/GetFieldType, is used to retrieve the field type definition. So be careful not to overwrite this property.

wxRichTextField is derived from wxRichTextParagraphLayoutBox, which means that it can contain its own read-only content, refreshed when the application calls the UpdateField function. Whether a field is treated as a composite or a single graphic is determined by the field type definition. If using wxRichTextFieldTypeStandard, passing the display type wxRICHTEXT_FIELD_STYLE_COMPOSITE to the field type definition causes the field to behave like a composite; the other display styles display a simple graphic. When implementing a composite field, you will still need to derive from wxRichTextFieldTypeStandard or wxRichTextFieldType, if only to implement UpdateField to refresh the field content appropriately. wxRichTextFieldTypeStandard is only one possible implementation, but covers common needs especially for simple, static fields using text or a bitmap.

Register field types on application initialisation with the static function wxRichTextParagraphLayoutBox::AddFieldType. They will be deleted automatically on application exit.

An application can write a field to a control with wxRichTextCtrl::WriteField, taking a field type, the properties for the field, and optional attributes.

Library:  wxRichText
Category:  Rich Text
参照:
wxRichTextFieldTypeStandard, wxRichTextFieldType, wxRichTextParagraphLayoutBox, wxRichTextProperties, wxRichTextCtrl

Public Member Functions

 wxRichTextField (const wxString &fieldType=wxEmptyString, wxRichTextObject *parent=NULL)
 Default constructor; optionally pass the parent object.
 wxRichTextField (const wxRichTextField &obj)
 Copy constructor.
virtual bool Draw (wxDC &dc, wxRichTextDrawingContext &context, const wxRichTextRange &range, const wxRichTextSelection &selection, const wxRect &rect, int descent, int style)
 Draw the item, within the given range.
virtual bool Layout (wxDC &dc, wxRichTextDrawingContext &context, const wxRect &rect, const wxRect &parentRect, int style)
 Lay the item out at the specified position with the given size constraint.
virtual bool GetRangeSize (const wxRichTextRange &range, wxSize &size, int &descent, wxDC &dc, wxRichTextDrawingContext &context, int flags, wxPoint position=wxPoint(0, 0), wxArrayInt *partialExtents=NULL) const
 Returns the object size for the given range.
virtual wxString GetXMLNodeName () const
 Returns the XML node name of this object.
virtual bool CanEditProperties () const
 Returns true if we can edit the object's properties via a GUI.
virtual bool EditProperties (wxWindow *parent, wxRichTextBuffer *buffer)
virtual wxString GetPropertiesMenuLabel () const
 Returns the label to be used for the properties context menu item.
virtual bool AcceptsFocus () const
 Returns true if objects of this class can accept the focus, i.e.
virtual void CalculateRange (long start, long &end)
 Calculates the range of the object.
virtual bool IsAtomic () const
 If a field has children, we don't want the user to be able to edit it.
virtual bool IsEmpty () const
 Returns true if the buffer is empty.
virtual bool IsTopLevel () const
 Returns true if this object is top-level, i.e.
void SetFieldType (const wxString &fieldType)
wxString GetFieldType () const
virtual bool UpdateField (wxRichTextBuffer *buffer)
 Update the field; delegated to the associated field type.
virtual wxRichTextObjectClone () const
 Clones the object.
void Copy (const wxRichTextField &obj)

List of all members.


Constructor & Destructor Documentation

wxRichTextField::wxRichTextField ( const wxString fieldType = wxEmptyString,
wxRichTextObject parent = NULL 
)

Default constructor; optionally pass the parent object.

wxRichTextField::wxRichTextField ( const wxRichTextField obj) [inline]

Copy constructor.


Member Function Documentation

virtual bool wxRichTextField::AcceptsFocus ( ) const [inline, virtual]

Returns true if objects of this class can accept the focus, i.e.

a call to SetFocusObject is possible. For example, containers supporting text, such as a text box object, can accept the focus, but a table can't (set the focus to individual cells instead).

Reimplemented from wxRichTextParagraphLayoutBox.

virtual void wxRichTextField::CalculateRange ( long  start,
long &  end 
) [virtual]

Calculates the range of the object.

By default, guess that the object is 1 unit long.

Reimplemented from wxRichTextCompositeObject.

virtual bool wxRichTextField::CanEditProperties ( ) const [virtual]

Returns true if we can edit the object's properties via a GUI.

Reimplemented from wxRichTextObject.

virtual wxRichTextObject* wxRichTextField::Clone ( ) const [inline, virtual]

Clones the object.

Reimplemented from wxRichTextParagraphLayoutBox.

void wxRichTextField::Copy ( const wxRichTextField obj)
virtual bool wxRichTextField::Draw ( wxDC dc,
wxRichTextDrawingContext context,
const wxRichTextRange range,
const wxRichTextSelection selection,
const wxRect rect,
int  descent,
int  style 
) [virtual]

Draw the item, within the given range.

Some objects may ignore the range (for example paragraphs) while others must obey it (lines, to implement wrapping)

Reimplemented from wxRichTextParagraphLayoutBox.

virtual bool wxRichTextField::EditProperties ( wxWindow parent,
wxRichTextBuffer buffer 
) [virtual]
wxString wxRichTextField::GetFieldType ( ) const [inline]
virtual wxString wxRichTextField::GetPropertiesMenuLabel ( ) const [virtual]

Returns the label to be used for the properties context menu item.

Reimplemented from wxRichTextObject.

virtual bool wxRichTextField::GetRangeSize ( const wxRichTextRange range,
wxSize size,
int &  descent,
wxDC dc,
wxRichTextDrawingContext context,
int  flags,
wxPoint  position = wxPoint(0, 0),
wxArrayInt partialExtents = NULL 
) const [virtual]

Returns the object size for the given range.

Returns false if the range is invalid for this object.

Reimplemented from wxRichTextParagraphLayoutBox.

virtual wxString wxRichTextField::GetXMLNodeName ( ) const [inline, virtual]

Returns the XML node name of this object.

This must be overridden for wxXmlNode-base XML export to work.

Reimplemented from wxRichTextParagraphLayoutBox.

virtual bool wxRichTextField::IsAtomic ( ) const [inline, virtual]

If a field has children, we don't want the user to be able to edit it.

Reimplemented from wxRichTextCompositeObject.

virtual bool wxRichTextField::IsEmpty ( ) const [inline, virtual]

Returns true if the buffer is empty.

Reimplemented from wxRichTextCompositeObject.

virtual bool wxRichTextField::IsTopLevel ( ) const [virtual]

Returns true if this object is top-level, i.e.

contains its own paragraphs, such as a text box.

Reimplemented from wxRichTextParagraphLayoutBox.

virtual bool wxRichTextField::Layout ( wxDC dc,
wxRichTextDrawingContext context,
const wxRect rect,
const wxRect parentRect,
int  style 
) [virtual]

Lay the item out at the specified position with the given size constraint.

Layout must set the cached size. is the available space for the object, and parentRect is the container that is used to determine a relative size or position (for example if a text box must be 50% of the parent text box).

Reimplemented from wxRichTextParagraphLayoutBox.

void wxRichTextField::SetFieldType ( const wxString fieldType) [inline]
virtual bool wxRichTextField::UpdateField ( wxRichTextBuffer buffer) [virtual]

Update the field; delegated to the associated field type.

This would typically expand the field to its value, if this is a dynamically changing and/or composite field.

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines