# TK_Text

## Functions

| `TK_Text`
| `~TK_Text`
`TK_Status` | `Read`
`TK_Status` | `Write`
`TK_Status` | `Clone`
`TK_Status` | `ReadAscii`
`TK_Status` | `WriteAscii`
void | `Reset`
void | `SetString`
void | `SetString`
void | `SetString`
void | `SetString`
char const * | `GetString`
char * | `GetString`
void | `SetPosition`
void | `SetPosition`
float const * | `GetPosition`
void | `SetDPosition`
void | `SetDPosition`
double const * | `GetDPosition`
void | `SetEncoding`
int | `GetEncoding`
void | `SetTextRegion`
void | `SetTextDRegion`
int | `GetTextRegionCount`
float const * | `GetTextRegionPoints`
double const * | `GetTextRegionDPoints`
int | `GetTextRegionOptions`
int | `GetTextRegionFitting`
void | `SetStringCursors`
int | `GetStringCursorCount`
int const * | `GetStringCursors`
int * | `GetStringCursors`
void | `SetTextLeaders`
int | `GetTextLeaderCount`
float const * | `GetTextLeaders`
float * | `GetTextLeaders`
unsigned char const * | `GetTextLeaderFlags`
unsigned char * | `GetTextLeaderFlags`
void | `SetDTextLeaders`
int | `GetDTextLeaderCount`
double const * | `GetDTextLeaders`
double * | `GetDTextLeaders`
unsigned char const * | `GetDTextLeaderFlags`
unsigned char * | `GetDTextLeaderFlags`

## Detailed Description

class TK_Text : public BBaseOpcodeHandler

  Handles the TKE_Text and TKE_Text_With_Encoding opcodes.

  TK_Text provides support for writing/reading the TKE_Text and TKE_Text_With_Encoding opcode objects to/from an HSF file.

  The HOOPS/3dGS scene-graph can contain ‘text’ primitives which are defined by a position and character string, and possibly by an encoding value for multibyte (non-ASCII) text.

  Public Functions

  TK_Text(unsigned char opcode)

    constructor

  ~TK_Text()
  virtual TK_Status Read(BStreamFileToolkit &tk)

    Reads data from the toolkit buffer, decodes/decompresses it, and maps it to the opcode handlers data members. User-defined classes which need to write out custom data should utilize one of the available GetData() methods.

    Parameters

      tk – A reference to the BStreamFileToolkit object.

    Returns

      The result of the function call.

  virtual TK_Status Write(BStreamFileToolkit &tk)

    Encodes/compresses data and writes data to the toolkit buffer. User-defined classes which need to write out custom data should utilize one of the available PutData() methods, and first write out the opcode associated with the group of binary data followed by the data itself.

    Parameters

      tk – A reference to the BStreamFileToolkit object.

    Returns

      The result of the function call.

  virtual TK_Status Clone(BStreamFileToolkit &tk, BBaseOpcodeHandler **handler) const

    Copies the opcode handler

    Parameters

      - tk – A reference to the BStreamFileToolkit object.

      - handler – A pointer to the opcode handler object. Passed by reference.

    Returns

      The result of the function call.

  TK_Status ReadAscii(BStreamFileToolkit &tk)

    Deprecated.

  TK_Status WriteAscii(BStreamFileToolkit &tk)

    Deprecated.

  virtual void Reset()

    Resets the current opcode handler. This is called by the toolkit when it is done processing an opcode. This method reinitializes any opcode handler variables and frees up temporary data.

  inline void SetString(char const *string)

    Sets the text string. Allocates the buffer and copies the string

  void SetString(unsigned short const *string)

    Sets the text string using Unicode data. Allocates the buffer and copies the string, and sets encoding

  void SetString(unsigned int const *string)

    Sets the text string using wide Unicode data. Allocates the buffer and copies the string, and sets encoding

  inline void SetString(int length)

    Sets the text string buffer. Allocates a buffer large enough to hold a string of ‘length’ bytes

  inline char const *GetString() const

    Returns the text string (if encoding is a form of Unicode, the pointer should be recast to the correct type)

  inline char *GetString()

    Returns the text string buffer, which may be modified directly (if encoding is a form of Unicode, the pointer should be recast to the correct type)

  inline void SetPosition(float x, float y, float z)

    Sets the text position using discrete float values

  inline void SetPosition(float const p[])

    Sets the text position using a float triplet

  inline float const *GetPosition() const

    Returns the text position as the address of a float triplet

  inline void SetDPosition(double x, double y, double z)

    Sets the text position using discrete double values

  inline void SetDPosition(double const p[])

    Sets the text position using a double triplet

  inline double const *GetDPosition() const

    Returns the text position as the address of a double triplet

  inline void SetEncoding(int e)

    Set the type of encoding for this string. Encodings are specified by TKO_Text_Encodings.

  inline int GetEncoding() const

    Returns the type of encoding for this string. Encodings are specified by TKO_Text_Encodings.

  void SetTextRegion(int c, float const p[], int o = 0, int f = 0)

    Set the text region for this string.

  void SetTextDRegion(int c, double const p[], int o = 0, int f = 0)

    Set the text region for this string.

  inline int GetTextRegionCount() const

    Returns the number of points defining the text region.

  inline float const *GetTextRegionPoints() const

    Returns the points defining the text region.

  inline double const *GetTextRegionDPoints() const

    Returns the points defining the text region.

  inline int GetTextRegionOptions() const

    Returns the options for the text region.

  inline int GetTextRegionFitting() const

    Returns the fit options for the text region.

  void SetStringCursors(int length, int *locations = 0)

    Sets the text string cursors. Allocates a buffer large enough to hold a ‘length’ row/column pairs, and optionally copies data

  inline int GetStringCursorCount() const

    Returns the number of string cursors

  inline int const *GetStringCursors() const

    Returns the string cursor buffer

  inline int *GetStringCursors()

    Returns the string cursor buffer, which may be modified directly

  void SetTextLeaders(int length, float *locations = 0, unsigned char *flags = 0)

    Sets the text leaders. Allocates a buffer large enough to hold a ‘length’ points & flags, and optionally copies data

  inline int GetTextLeaderCount() const

    Returns the number of text leaders

  inline float const *GetTextLeaders() const

    Returns the text leader buffer

  inline float *GetTextLeaders()

    Returns the text leader buffer, which may be modified directly

  inline unsigned char const *GetTextLeaderFlags() const

    Returns the text leader flags buffer

  inline unsigned char *GetTextLeaderFlags()

    Returns the text leader flags buffer, which may be modified directly

  void SetDTextLeaders(int length, double *locations = 0, unsigned char *flags = 0)

    Sets the text leaders. Allocates a buffer large enough to hold a ‘length’ dpoints & flags, and optionally copies data

  inline int GetDTextLeaderCount() const

    Returns the number of text leaders

  inline double const *GetDTextLeaders() const

    Returns the text leader buffer

  inline double *GetDTextLeaders()

    Returns the text leader buffer, which may be modified directly

  inline unsigned char const *GetDTextLeaderFlags() const

    Returns the text leader flags buffer

  inline unsigned char *GetDTextLeaderFlags()

    Returns the text leader flags buffer, which may be modified directly