rvico TRichView Reference | Overview

Scrolling in RichView

Top  Previous  Next

Vertical scrolling

Documents in RichView can have almost unlimited height. But ranges of scrollbars are limited, and RichView cannot use pixels as scrolling units (small step of scrollbar). Scrolling units of RVScroller (ancestor of RichView) are referred here as "RVSU" (RichView Scrolling Units). By default, 1 RVSU = 10 pixels, but the component can increase it automatically during formatting if the range of vertical scrollbar exceeds 30,000. You can set a number of pixels in 1 RVSU with VSmallStep property (but the component can increase it during formatting).

For example, you may want to set RVSU to the height of one line of the normal text. After assigning a new value to VSmallStep, you should reformat document using Format method).

You can get or set position of vertical scrollbar using VScrollPos property (in range 0..VScrollMax)

You can also use method ScrollTo for scrolling to the specified vertical position, measured in pixels.

ScrollTo(y) is equivalent to VScrollPos := y div VSmallStep, so ScrollTo cannot scroll exactly to the specified position.

You can show and hide vertical scrollbar with VScrollVisible property.

DocumentHeight property is a vertical height of a document in pixels (height of scrollable area). For example, you can use this value to set height of RichView. DocumentHeight includes values of TopMargin and BottomMargin.

You can get vertical coordinate in document for:

checkpoints

hypertext link (GetJumpPointY)

any item (GetItemCoords)

Horizontal scrolling

Horizontal scrollbar appears automatically when necessary.

You can hide it with HScrollVisible property.

You can get or set the position of horizontal scrollbar using HScrollPos property (in range 0..HScrollMax)

You can use some properties to control width of a document (a width of scrollable area minus margins), thus controlling a horizontal scrolling (see LeftMargin, RightMargin)

By default, if the document does not contain wide images, controls or tables, text is wrapped to fit the client width of RichView minus margins.

If there are pictures or controls, width of scrolling area is equal to

max(client width of RichView,

   "maximal width of pictures or controls" + "maximal left + first line + right indent" + margins),

and text is wrapped to fit width of the scrolling area minus margins.

Text in paragraphs with no-wrap option can also affect to width of scrolling area, in the same was as wide pictures or controls.

Use MinTextWidth property to set the minimal width for text wrapping (text wraps when its length in pixels exceeds this value). Horizontal scrollable area cannot be less than MinTextWidth+margins (but can be greater because of wide pictures or wide client width of RichView). You can use MinTextWidth to speed up formatting when RichView is resized. Formatting is very quick if width of scrollable area is not changed. For example, if you set MinTextWidth to the size of screen, RichView will not perform full reformatting when user resizes it (well, it's not convenient to read text with horizontal scrollbar)

Explaining MinTextWidth

Explaining MinTextWidth

Use MaxTextWidth property to set maximal width for text wrapping. This value does not affect width of scrollable area.

Explaining MaxTextWidth

Explaining MaxTextWidth

A similar effect can be achieved using rvoClientTextWidth option from Options. If this option is set, width for text wrapping is always equal to client width of RichView minus margins. It is useful if your document can have wide pictures or controls, or no-wrap paragraphs.

You can set no-wrap option for paragraph style. If this option is set, this paragraph will not be wrapped automatically.


TRichView © trichview.com