Classes

Class XbpRtf() Foundation

Class function of the XbpRtf() class

Superclass
Description

Objects of the XbpRtf class encapsulate the functionality of a Rich Text Edit Control which allows for editing formatted text. An XbpRtf object is able to load, display, print and save RTF-formatted files.

Xbase++ applications can use the XbpRtf object for implementing a full-featured text editor. Also, XbpRtf objects can be used for manipulating RTF-encoded character data created by other applications.

To function properly, the XbpRtf class requires a certain system component, the Microsoft Rich Text ActiveX Control Version 6.0, to be installed on your computer. Normally, this component is not installed along with the operating system, so provisions must be taken to distribute it with your Xbase++ application. An installation package with the required system files for using the XbpRtf Xbase Part is available from Alaska Software. The corresponding archive should be located on your Xbase++ disk or CD ROM. For further information, please click the 'Info' button on this page.

Class methods
:new()
Creates an instance of the XbpRtf class.
Life cycle
:create()
Requests system resources for the object.
:configure()
Reconfigures the XbpRtf object after :create() has been executed.
:destroy()
Releases the system resources of the object.
Runtime Data

Unless documented otherwise, the instance variables in the following section can only be used after method :create() has been called.

:appearance
Configures the visual appearance of the XbpRtf object.
:bulletIndent
Specifies the indentation for paragraphs preceded by a bullet.
:changed
Indicates if the edit buffer has changed.
:hideSelection
Controls highlighting of selected text.
:locked
Specifies whether the object is locked.
:maxLength
Sets the maximum length of the edit buffer.
:popupMenu
The popup menu of the XbpRtf object.
:rightMargin
Specifies the right margin for the XbpRtf object.
:scrollbars
Configures the scroll bars of the XbpRtf object.
:text
Contains the contents of the edit buffer.
:textRTF
Contains the RTF-encoded contents of the edit buffer.
:usePopupMenu
Specifies whether a popup menu is displayed by the XbpRtf object.
Working with the selection

The following instance variables and methods are used to manipulate the selection, that is, the text currently selected in the XbpRtf object. If no text is selected when a certain text attribute is changed, the attribute is set for all text entered at the current insertion point.

Unless documented otherwise, the instance variables in the following section can only be used after method :create()was called.

:selAlignment
Configures the alignment of the paragraph containing the selection.
:selBold
Configures bold type face for the selection.
:selBullet
Indicates a paragraph preceded by a bullet.
:selCharOffset
Specifies how characters are placed within the current selection.
:selColor
Contains the color used to display the text in the XbpRtf object.
:selFontName
Contains the name of the font assigned to the selection.
:selFontSize
Contains the size of the font assigned to the selection.
:selHangingIndent
Configures indentation between the first and subsequent lines of the current paragraph.
:selIndent
Configures left indentation of the current paragraph.
:selItalic
Configures italic type face for the selection.
:selLength
Contains the number of selected characters.
:selReadOnly
Specifies whether the text in the current selection can be edited by the user.
:selRightIndent
Configures right-indentation of the current paragraph.
:selStart
Indicates the first character of the selection.
:selStrikeThru
Configures the strike-through format of the text in the selection.
:selTabCount
Specifies the number of tab stops defined for the text following the current selection or insertion point.
:selText
Contains the text within the current selection. If no text is selected, return is the empty string ("").
:selUnderline
Configures underlined type face for the selection.
File handling
:loadFile()
Loads the specified file into the text buffer.
:saveFile()
Saves the contens of the text buffer in the specified file.
Methods for editing
:clear()
Clears the text buffer.
:copy()
Copies the selection into the clipboard.
:cut()
Cuts the text in the selection.
:find()
Searches a character string in the text buffer.
:getLineFromChar()
Determines the number of the line that contains the character specified.
:getLineStart()
Determines the number of the first character within the line specified.
:undo()
Voids the last change applied to the text buffer.
:paste()
Pastes the contents of the clipboard into the text buffer.
:print()
Prints the text buffer.
:selTabs()
Sets a tab position.
:span()
Selects text in the XbpRtf object based on a set of characters specified.
Notifications
xbeRTF_Change
Text buffer changed.
xbeRTF_SelChange
Text selection changed.
Examples
Example for using the XbpRtf Xbase Part

// 
// Example for using the XbpRtf Xbase Part 
// 
#include "XBP.CH" 
#include "GRA.CH" 
#include "AppEvent.CH" 

PROCEDURE Main() 

  LOCAL oRTF 
  LOCAL nEvent, mp1, mp2, oXbp 

  SetAppWindow():useShortCuts := .T. 

  // 
  // Create the XbpRtf object 
  // 
  oRTF := XbpRTF():new() 
  oRTF:create( ,, {10,10},{300,300},{{XBP_PP_COMPOUNDNAME,"12.Arial"}} ) 

  // Assign text to the RTF object's text buffer 
  oRTF:text := "Text with varying " + Chr(10) +; 
               "text attributes. Made possible by the " + Chr(10) +; 
               "XbpRtf edit control." + Chr(10) 
  // 
  // Use the selection manipulation methods to 
  // assign different attributes to the text 
  // 
  // Set the selection using abolute character positions 
  oRTF:SelStart    := 5 
  oRTF:SelLength   := 30 
  oRTF:SelColor    := GRA_CLR_BLUE 

  // Set the selection by selecting a specific word 
  // in the text 
  oRTF:SelStart    := 0 
  oRTF:Find( "Made possible" ) 
  oRTF:SelBold     := .T. 

  // Find a specific word and expand the selection 
  // to include another one 
  oRTF:SelLength   := 0 
  oRTF:Find( "XbpRtf" ) 
  oRTF:Span( ".",, .T. ) 
  oRTF:SelColor    := GRA_CLR_RED 
  oRTF:SelFontName := "Courier New" 
  oRTF:SelFontSize := 15 
  oRTF:SelBold     := .T. 

  // 
  // Reset the text cursor 
  // 
  oRTF:SelStart    := Len( oRTF:Text ) 

  // 
  // Event Loop 
  // 
  nEvent := xbe_None 
  DO WHILE nEvent != xbeP_Close 
     nEvent := AppEvent( @mp1, @mp2, @oXbp ) 
     oXbp:handleEvent( nEvent, mp1, mp2 ) 
  ENDDO 

RETURN 
Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.