//////////////////////////////////////////////////////////////////////////////// 
// 
// step3.cpp - 
// 
// 1.    - WorkDocument
// 2.               - DrawView
// 3.               - DrawLayer
// 4.             - DrawGroup
// 5.      - WorkNameGroup
// 6.            - DrawLineSeg
// 7.               - DrawArc
// 8.              - DrawLine
// 9.         - DrawCircle
// 10.             - DrawPoint
// 11. Bezier-   - DrawBezier
// 12.         - DrawHatch
// 13.             - DrawText
// 
//////////////////////////////////////////////////////////////////////////////// 
#ifndef __WINDOWS_H
#include <windows.h>
#endif

#ifndef __STDIO_H
#include <stdio.h>
#endif

#ifndef __STRING_H
#include <string.h>
#endif

#ifndef __STDLIB_H
#include <stdlib.h>
#endif

#ifndef __LIBTOOL_H
#include "libtool.h"
#endif

#ifndef __STEP3_RH
#include "step3.rh"
#endif 


//-------------------------------------------------------------------------------
//   
// ---
extern "C" unsigned int __export __pascal LIBRARYID()
{
  return IDR_LIBID;
}


//-------------------------------------------------------------------------------
//   
// ---
void WorkDocument();
void DrawView();
void DrawLayer();
void DrawGroup();
void WorkNameGroup();
void DrawLineSeg();
void DrawArc();
void DrawLine();
void DrawCircle();
void DrawPoint();
void DrawBezier();
void DrawHatch();
void DrawText();


//-------------------------------------------------------------------------------
//   
// ---
extern "C" void __export __pascal LIBRARYENTRY( unsigned int comm )
{
  if ( comm == 1 )
    WorkDocument();  //  
  else
  {
    if ( ksGetCurrentDocument( 1 ) ) //   2D 
    {
      switch ( comm ) 
      {
        case 2  : DrawView();      break; // 
        case 3  : DrawLayer();     break; // 
        case 4  : DrawGroup();     break; // 
        case 5  : WorkNameGroup(); break; //  
        case 6  : DrawLineSeg();   break; // 
        case 7  : DrawArc();       break; // 
        case 8  : DrawLine();      break; // 
        case 9  : DrawCircle();    break; // 
        case 10 : DrawPoint();     break; // 
        case 11 : DrawBezier();    break; // Bezier-
        case 12 : DrawHatch();     break; // 
        case 13 : DrawText();      break; // 
      }
    }
    else
      Message( "   \n  /" );
  }
}


//-------------------------------------------------------------------------------
//   
// ---
void WorkDocument()
{
  DocumentParam parDocument; //   
  
  lstrcpy( parDocument.fileName, "c:\\1.cdw" );         //    
  lstrcpy( parDocument.comment,  "Create document" );   //   
  lstrcpy( parDocument.author,   "User" );              //  
  parDocument.regim              = 0;                   //  ( 0 - , 1 -  )
  parDocument.type               = lt_DocSheetStandart; //   -  
  //     (      )
  parDocument.sheet.stPar.format   = 3;                 //   0( 0 ) ... 4( 4 )
  parDocument.sheet.stPar.multiply = 1;                 //  
  parDocument.sheet.stPar.direct   = 0;                 //   ( 0 -   , 1 -   )
  parDocument.sheet.shtType        = 1;                 //        (      )
  parDocument.sheet.layoutName[0]  = '\0';              //    (Graphic.lyt) 
  //  : ,  3,       1
  reference rDocument = CreateDocument( &parDocument );
 
  /*
  reference rDocument = OpenDocument( "c:\\1.cdw", 1 );
  */
 
  ViewParam parView; //     
  memset( &parView, 0, sizeof(parView) );
  parView.x     = 10;                  //   
  parView.y     = 20;
  parView.scale = 0.5;                 //  
  parView.ang   = 45;                  //   
  parView.color = RGB( 10, 20, 10 );   //     
  parView.state = stACTIVE;            //  
  strcpy( parView.name, "User view" ); //  
  //       2,  0.5,   45 .
  int number = 2;
  CreateSheetView( &parView, &number );
 
  //     5
  Layer( 5 );
  //  
  LineSeg( 20, 10, 40, 10, 1 );
  LineSeg( 40, 10, 40, 30, 1 );
  LineSeg( 40, 30, 20, 30, 1 );
  LineSeg( 20, 30, 20, 10, 1 );
 
  //   
  GetObjParam( rDocument, &parDocument, sizeof( parDocument ), ALLPARAM );
  char buf[ 255 ];
  sprintf( buf, "type = %d, sheet.stPar.format = %d,\nsheet.stPar.multiply = %d, sheet.stPar.direct = %d,\nfileName = %s,\ncomment = %s,\nauthor = %s", 
           parDocument.type, parDocument.sheet.stPar.format, 
           parDocument.sheet.stPar.multiply, parDocument.sheet.stPar.direct, 
           parDocument.fileName, parDocument.comment, parDocument.author );
  Message( buf );
 
  //  
  SaveDocument( 0, "" );
 
  /*
  //  
  CloseDocument( rDocument );
  */
}


//-------------------------------------------------------------------------------
//  
// ---
void DrawView()
{
  ViewParam parView; //     
 
  parView.x     = 10;                  //   
  parView.y     = 20;
  parView.scale = 0.5;                 //  
  parView.ang   = 45;                  //   
  parView.color = RGB( 10, 20, 10 );   //     
  parView.state = stACTIVE;            //  
  strcpy( parView.name, "User view" ); //  
  //     5,  0.5,   45 .
  int number = 5;
  reference rView = CreateSheetView( &parView, &number );

  //   , type -   ( 0 -  , 1 -  )
  reference rGroup = NewGroup( 0 );
    LineSeg( 20, 10, 20, 30, 1 );
    LineSeg( 20, 30, 40, 30, 1 );
    LineSeg( 40, 30, 40, 10, 1 );
    LineSeg( 40, 10, 20, 10, 1 );
  EndGroup(); //    

  Message( "   " ); 
  //      
  if( !AddObjGroup( rGroup, rView ) ) 
    MessageBoxResult(); //         

  //    -45    ( 0, 0 )
  RotateObj( rGroup, 0, 0, -45 );

  Message( "     " );
  //         
  if( !AddObjGroup( rGroup, rView ) )
    MessageBoxResult(); //          (    )
  
  //   a
  GetObjParam( rView, &parView, sizeof( parView ), ALLPARAM );
  number = GetViewNumber( rView );
  char buf[255];
  sprintf( buf, "x = %4.2f, y = %4.2f, scale = %4.2f, ang = %4.2f, color = %x, state = %d, name = %s, number = %d",
           parView.x, parView.y, parView.scale, parView.ang, parView.color, parView.state, parView.name, number );
  Message( buf );

  //     (  0 )
  OpenView( 0 );
  
  Message( "  " );
  //    (   )
  int state = stREADONLY;
  SetObjParam( rView, &state, sizeof( state ), VIEW_LAYER_STATE );
}


//-------------------------------------------------------------------------------
//  
// ---
void DrawLayer()
{
  int number;
  if ( ReadInt( "   ", 1, 0, 255, &number ) )
  {
    //   ,     
    // ,   .   
    reference rLayer = Layer( number );

    Mtr( 20, 15, 0, 1 ); //    ( 20   OX, 15   OY )
      LineSeg( -10, 0,   10, 0,  1 );
      LineSeg(  10, 0,   10, 20, 1 );
      LineSeg(  10, 20, -10, 20, 1 );
      LineSeg( -10, 20, -10, 0,  1 );
    DeleteMtr();         //    

    //  
    LightObj( rLayer, 1 );

    //         
    number = GetLayerNumber( rLayer );
    rLayer = GetLayerReference( number );

    Message( "  " );
    //   
    LightObj( rLayer, 0 );

    LayerParam parLayer; //   

    //   
    GetObjParam( rLayer, &parLayer, sizeof( parLayer ), ALLPARAM );
    char buf [255];
    sprintf( buf, "number = %d, rLayer = %d,\nstate = %d, color = %x, name = %s",
             number, rLayer, parLayer.color, parLayer.state, parLayer.name );
    Message( buf );

    //   
    parLayer.color = RGB( 0, 255, 0 );   //     
    parLayer.state = stACTIVE;           //  
    strcpy ( parLayer.name, "" ); //  
    //          
    Layer( 0 );

    if ( !SetObjParam( rLayer, &parLayer, sizeof( parLayer ), ALLPARAM ) )
      MessageBoxResult(); //      
    else {
      //   
      GetObjParam( rLayer, &parLayer, sizeof( parLayer ), ALLPARAM );
      sprintf( buf, "number = %d, rLayer = %d,\nstate = %d, color = %x, name = %s",
             number, rLayer, parLayer.color, parLayer.state, parLayer.name );
      Message( buf );
    }

    Message( "  " );
    //    (   )
    int state = stACTIVE ;
    SetObjParam( rLayer, &state, sizeof( state ), VIEW_LAYER_STATE );
  }
}


//-------------------------------------------------------------------------------
//   
// ---
void DrawGroup()
{
  //   , type -   ( 0 -  , 1 -  )
  reference rGroup = NewGroup( 0 );
    LineSeg( 10, 10, 10, 20, 0 );
  EndGroup(); //    
 
  //    10   OX
  MoveObj( rGroup, 10, 0 );
  
  //    45    ( 20, 10 )
  RotateObj( rGroup, 20, 10, 45 );

  Message( "  (     )" );
  //   (     )
  ClearGroup( rGroup );
  
  //  
  reference rLineSeg = LineSeg( 10, 10, 20, 10, 0 );
  
  //     
  AddObjGroup( rGroup, rLineSeg );

  //  
  LightObj( rGroup, 1 );
 
  Message( "  " );
  //   
  LightObj( rGroup, 0 );
 
  //    (    )
  DeleteObj( rGroup );
}


//-------------------------------------------------------------------------------
//    
// ---
void WorkNameGroup()
{
  //   , type -   ( 0 -  , 1 -  )
  reference rGroup = NewGroup( 0 );
    LineSeg( 20, 20, 40, 20, 1 );
    LineSeg( 40, 20, 40, 40, 1 );
    LineSeg( 40, 40, 20, 40, 1 );
    LineSeg( 20, 40, 20, 20, 1 );
  EndGroup(); //    
 
  //         
  //        
  //          
  //     ,    
  // - (  ).
  if ( !SaveGroup(  rGroup, "Group" ) )
    exit( EXIT_SUCCESS );
    
  rGroup = GetGroup( "Group" );
  if ( !rGroup )
    exit( EXIT_SUCCESS );
 
  //  
  reference rCircle = Circle( 30, 30, 10, 1 );
 
  //     
  AddObjGroup( rGroup, rCircle );
 
  LightObj( rGroup, 1 );
  Message( "     " );
  LightObj( rGroup, 0 );
 
  //    
  ExcludeObjGroup( rGroup, rCircle );
 
  LightObj( rGroup, 1 );
  Message( "     " );
  LightObj( rGroup, 0 );
}


//-------------------------------------------------------------------------------
//  
// ---
void DrawLineSeg()
{
  Mtr( 30, 20, 45, 1 ); //    ( 30   OX, 25   OY,   45  )
    //  
    reference rLineSeg = LineSeg( 30, 20, //   
                                  60, 20, //   
                                  1 );    //   ( 1 -  , 2 -  , 3 -  ,
                                          // 4 -  , 5 -   , 6 -  ,
                                          // 7 - , 8 - -    ,
                                          // 9 -   , 10 -   ,
                                          // 11 -  ,    )
  DeleteMtr(); //    
  
  LineSegParam parLineSeg; //   

  //   
  GetObjParam( rLineSeg, &parLineSeg, sizeof( parLineSeg ), ALLPARAM );
  char buf [255];
  sprintf( buf, "x1 = %4.2f, y1 = %4.2f, x2 = %4.2f, y2 = %4.2f, style = %d",
           parLineSeg.x1, parLineSeg.y1, parLineSeg.x2, parLineSeg.y2, parLineSeg.style );
  Message( buf );

  //   
  parLineSeg.x2    = 30; //   
  parLineSeg.y2    = 60;
  parLineSeg.style = 2;  //  
  
  //   
  if ( !SetObjParam( rLineSeg, &parLineSeg, sizeof( parLineSeg ), ALLPARAM ) )
    MessageBoxResult(); //         
}


//-------------------------------------------------------------------------------
//  
// ---
void DrawArc()
{
  Mtr( 10, 10, 0, 1 ); //    ( 10   OX, 10   OY )
    //    
    reference rArcByAngle = ArcByAngle( 30, 20,  //   
                                        20,      // 
                                        45, 135, //        
                                        1,       //   ( +1 -   , -1 -    )
                                        1 );     // C  ( 1 - , 2 - , 3 - , 4 - , 
                                                 // 5 - , 6 - , 7 -    , 
                                                 // 8 -  , 9 -  , 10 -  ,
                                                 // 11 - ,    )
  DeleteMtr(); //    
   
  ArcParam parArc; //      ,   
  
  //   
  GetObjParam( rArcByAngle, &parArc, sizeof( parArc ), ALLPARAM );
  char buf [255];
  sprintf( buf, "xc = %4.2f, yc = %4.2f, rad = %4.2f,\nang1 = %4.2f, ang2 = %4.2f, dir = %d, style = %d", 
           parArc.xc, parArc.yc, parArc.rad, parArc.ang1, parArc.ang2, parArc.dir, parArc.style );
  Message( buf );
  
  ArcParam1 parArc1; //     
 
  //     
  parArc1.xc    = 40; //   
  parArc1.yc    = 30;
  parArc1.rad   = 10; // 
  parArc1.x1    = 50; //   
  parArc1.y1    = 30;
  parArc1.x2    = 40; //   
  parArc1.y2    = 20; 
  parArc1.dir   = 1;  //   
  parArc1.style = 2;  // C 

  //   
  if ( !SetObjParam( rArcByAngle, &parArc1, sizeof( parArc1 ), 1 ) )
    MessageBoxResult(); //         
}


//-------------------------------------------------------------------------------
//   
// ---
void DrawLine()
{
  Mtr( 0, 0, 45, 1 ); //    (   45  )
    //   
    reference rLine = Line( 30, 20, //  
                            0 );    //   
  DeleteMtr(); //    

  LineParam parLine; //    
 
  //    
  GetObjParam( rLine, &parLine, sizeof( parLine ), ALLPARAM );
  char buf [255];
  sprintf( buf, "x = %4.2f, y = %4.2f, ang = %4.2f", 
           parLine.x, parLine.y, parLine.ang );
  Message( buf );
 
  //    
  parLine.x   = 0;  //  
  parLine.y   = 0; 
  parLine.ang = 90; //   
 
  //    
  if ( !SetObjParam( rLine, &parLine, sizeof( parLine ), ALLPARAM ) )
    MessageBoxResult(); //         
}


//-------------------------------------------------------------------------------
//  
// ---
void DrawCircle()
{
  Mtr( 0, 0, 0, 2 ); //    (  2:1 )
    //  
    reference rCircle = Circle( 30, 20, //   
                                10,     //  
                                1 );    // C  ( 1 - , 2 - , 3 - , 4 - , 
                                        // 5 - , 6 - , 7 -    , 
                                        // 8 -  , 9 -  , 10 -  ,
                                        // 11 - ,    )
  DeleteMtr(); //    
 
  CircleParam parCircle; //   
  
  //   
  GetObjParam( rCircle, &parCircle, sizeof( parCircle ), ALLPARAM );
  char buf [255];
  sprintf( buf, "xc = %4.2f, yc = %4.2f, rad = %4.2f, style = %d", 
           parCircle.xc, parCircle.yc, parCircle.rad, parCircle.style );
  Message( buf );
 
  //   
  parCircle.xc    = 0;  //   
  parCircle.yc    = 0;
  parCircle.rad   = 20; //  
  parCircle.style = 2;  // C 
  
  //   
  if ( !SetObjParam( rCircle, &parCircle, sizeof( parCircle ), ALLPARAM ) )
    MessageBoxResult(); //         
}


//-------------------------------------------------------------------------------
// C 
// ---
void DrawPoint()
{
  Mtr( 10, 10, 0, 1 ); //    ( 10   OX, 10   OY )
  //  
  reference rPoint = Point( 30, 40, //  
                            0 );    // C   ( 0 - , 1 - , 2 - -,
                                    // 3 - , 4 - , 5 - , 6 - ,
                                    // 7 -  , 8 -   )
    Point( 40,  40, 1 );
    Point( 50,  40, 2 );
    Point( 60,  40, 3 );
    Point( 70,  40, 4 );
    Point( 80,  40, 5 );
    Point( 90,  40, 6 );
    Point( 100, 40, 7 );
  DeleteMtr(); //    
 
  PointParam parPoint; //   
  
  //   
  GetObjParam( rPoint, &parPoint, sizeof( parPoint ), ALLPARAM );
  char buf [255];
  sprintf( buf, "x = %4.2f y = %4.2f style = %d", 
           parPoint.x, parPoint.y, parPoint.style );
  Message( buf );
 
  //    
  parPoint.x     = 20; //  
  parPoint.y     = 30; 
  parPoint.style = 7;  // C  
 
  //   
  if ( !SetObjParam( rPoint, &parPoint, sizeof( parPoint ), ALLPARAM ) )
    MessageBoxResult(); //         
}


//-------------------------------------------------------------------------------
//  Bezier 
// ---
void DrawBezier()
{
  //   
  double x[] = { 0, 20, 50, 70, 100, 50 };
  double y[] = { 0, 20, 10, 20, 0,  -50 };
 
  //  Bezier 
  Bezier( 0,   //    ( 0 -  , 1 -  )
          1 ); // C  ( 1 - , 2 - , 3 - , 4 - , 
               // 5 - , 6 - , 7 -    , 
               // 8 -  , 9 -  , 10 -  ,
               // 11 - ,    )
    for ( int i = 0; i < 5; i++ )
      Point( x[i], y[i], 0 ); //     
  reference rBezier = EndObj(); //  EndObj       
  
  BezierParam parBezier; //    
  
  //   Bezier 
  parBezier.pMathPoint = CreateArray( POINT_ARR, 0 ); //       
  GetObjParam( rBezier, &parBezier, sizeof( parBezier ), ALLPARAM );
  //    
  int count = GetArrayCount( parBezier.pMathPoint );
  char buf [255];
  sprintf( buf, "count = %d, closed = %d, style = %d", 
                 count, parBezier.closed, parBezier.style );
  Message( buf );
  
  //    
  MathPointParam parMathPoint; //    
  
  //     
  for ( int i = 0; i < count; i++ )
  {
    //    
    GetArrayItem( parBezier.pMathPoint, i, &parMathPoint, sizeof( parMathPoint ) );
    sprintf( buf, "x[%d] = %4.2f, y[%d] = %4.2f", 
             i, parMathPoint.x, i, parMathPoint.y );
    Message( buf );
  }
 
  //       
  ClearArray( parBezier.pMathPoint ); //       
  //      
  for ( int i = 0; i < 6; i++ )
  {
    parMathPoint.x = x[i];
    parMathPoint.y = y[i] + 10;
    //    ,     
    AddArrayItem( parBezier.pMathPoint, -1, &parMathPoint, sizeof( parMathPoint ) );
  }
  parBezier.style = 2;  // C 
  parBezier.closed = 1; //    ( 0 -  , 1 -  )
 
  //   Bezier 
  if ( !SetObjParam( rBezier, &parBezier, sizeof( parBezier ), ALLPARAM ) )
    MessageBoxResult(); //         
     
  DeleteArray( parBezier.pMathPoint ); //     
}


//-------------------------------------------------------------------------------
//  
// ---
void DrawHatch()
{
  //   
  Mtr( 30, 20, 0, 0.5 ); //    ( 30   OX, 20   OY,  1:2 )
    //  
    LineSeg ( 20, 30, 70, 30, 2 );
    LineSeg ( 70, 30, 70, 80, 2 );
    LineSeg ( 70, 80, 20, 80, 2 );
    LineSeg ( 20, 80, 20, 30, 2 );
    //  
    Hatch( 0,      //   ( 0 - , 1 - , 2 - , 3 -  ,
                   // 4 - , 5 - , 6 - , 7 - , 8 -  ,
                   // 9 -  , 10 -  , 11 - ,
                   // 12 -  , 13 -    , 14 -  )
           45,     //  
           2,      //  
           0,      //    ( 0 -    )
           0, 0 ); //   
		  LineSeg( 20, 30, 70, 30, 2 ); //     
      LineSeg( 70, 30, 70, 80, 2 );
      LineSeg( 70, 80, 20, 80, 2 );
      LineSeg( 20, 80, 20, 30, 2 );
    reference rHatch = EndObj(); //  EndObj     
  DeleteMtr(); //    
   
  HatchParam parHatch; //   
   
  //   
  GetObjParam( rHatch, &parHatch, sizeof( parHatch ), ALLPARAM );
  char buf [255];
  sprintf( buf, "style = %d, ang = %4.2f, step = %4.2f\nwidth = %4.2f, x = %4.2f, y = %4.2f", 
           parHatch.style, parHatch.ang, parHatch.step, parHatch.width, parHatch.x, parHatch.y );
  Message( buf );
  
  Mtr( 0, 0, 0, 2 ); //    (  2:1 )
    //   
    parHatch.x = 0.8;
    //   
    if ( !SetObjParam( rHatch, &parHatch, sizeof( parHatch ), ALLPARAM ) )
      MessageBoxResult(); //         
  DeleteMtr(); //    
}


//-------------------------------------------------------------------------------
//   
// ---
void PrintTextLine( TextLineParam parTextLine )
{
  char buf[255];
  sprintf( buf, "style = %d", parTextLine.style );
  Message( buf );
 
  TextItemParam parTextItem; //     
  
  //    
  int count = GetArrayCount( parTextLine.pTextItem );
  
  //    
  for ( int i = 0; i < count; i++ )
  {
    //    
    GetArrayItem( parTextLine.pTextItem, i, &parTextItem, sizeof( parTextItem ) );
    sprintf( buf, "i = %d, font.height = %4.2f, s = %s,\nfont.fontName = %s", 
             i, parTextItem.font.height, parTextItem.s, parTextItem.font.fontName );
    Message( buf );
  }
}


//-------------------------------------------------------------------------------
//   
// ---
void PrintTextPar( TextParam parText )
{
  char buf[255];
  sprintf( buf, "hFormat = %d, vFormat = %d, height = %4.2f, width = %4.2f,\nx = %4.2f, y = %4.2f, ang = %4.2f",
           parText.par.hFormat, parText.par.vFormat, parText.par.height, parText.par.width, parText.par.x, parText.par.y, parText.par.ang );
  Message( buf );

  TextLineParam parTextLine; //    
  
  //    
  int count = GetArrayCount( parText.pTextLine );
  
  //    
  for ( int i = 0; i < count; i++ )
  {
    //    
    GetArrayItem( parText.pTextLine, i, &parTextLine, sizeof( parTextLine ) );
    //   
    PrintTextLine( parTextLine );
  }
}


//-------------------------------------------------------------------------------
// 
// ---
void DrawText()
{
  ParagraphParam parParagraph; //   

  //   
  parParagraph.style   = 0;  //    (0 -   ,
                             // 1 -  , 2 -    ,
                             // 3 -   , 4 -    ,
                             // 5 -    -, 6 -  \  -,
                             // 7 -    -, 8 -     ,
                             // 9 -    , 10 -    ,
                             // 11 -    , 12 -     ,
                             // 13 -     ,
                             // 14 -     )
  parParagraph.x       = 30; //    
  parParagraph.y       = 30;
  parParagraph.ang     = 0;  //   
  parParagraph.hFormat = 0;  //    ( 0 -  ,
                             // 1 -  , 2 -     )
  parParagraph.vFormat = 0;  //    ( 0 -  ,
                             // 1-   )
  parParagraph.height  = 25; //   
  parParagraph.width   = 20; //   

  //      
  Paragraph( &parParagraph );
    //  ,   
    TextLine( ITALIC_OFF, 0, 0, "" );
    //   
    //    
    TextLine( NEW_LINE,    //  ,   
              0,           //  
              0,           //    
              " " );  // 
    // , ,    1.5    
    int fraction = 2; //   FRACTION_TYPE
    TextLine( NUMERATOR|ITALIC_ON, FRACTION_TYPE, &fraction, "111" );
    // , 
    TextLine( DENOMINATOR|BOLD_ON, 0, 0, "222" );
    //  ,  ,      
    TextLine( END_FRACTION|BOLD_OFF|ITALIC_OFF, 0, 0, " 333" );

    //   ,    
    TextLine( NEW_LINE, 0, 0, "   " );
    // , 
    TextLine( NUMERATOR|ITALIC_ON, 0, 0, "111 " );
    //    
    TextLine( S_BASE, 0, 0, "222" );
    //  
    TextLine( S_UPPER_INDEX, 0, 0, "" );
    //  
    TextLine( S_LOWER_INDEX, 0, 0, "" );
    //  
    TextLine( S_END, 0, 0, " 333" );
    // , 
    TextLine( DENOMINATOR, 0, 0, "444" );
    //  ,  ,      
    TextLine( END_FRACTION|BOLD_OFF|ITALIC_OFF, 0, 0, " 555" );

    //   
    TextLine( NEW_LINE, 0, 0, " " );
    int symbol = 65; //   - 
    // 
    TextLine( SPECIAL_SYMBOL, SPECIAL, &symbol, "" );
    //      
    TextLine( SPECIAL_SYMBOL_END, 0, 0, " 111" );

    //      
    TextLine( NEW_LINE, 0, 0, " Arial " );
    char name[10];
    lstrcpy( name, "Arial" ); //   - Arial
    unsigned int ch = 64; //     - @
    //    Arial
    TextLine( FONT_SYMBOL, FONT_NAME, name, ( char * ) ch );

  //     EndObj,     
  reference rParagraph = EndObj();

  /*
  TextParam parText; //   

  //   
  GetObjParam( rParagraph, &parText, sizeof( parText ), ALLPARAM );
  //   
  PrintTextPar( parText );
  */

  TextLineParam parTextLine; //    

  //   1-  (  0 )
  GetObjParam( rParagraph, &parTextLine, sizeof( parTextLine ), 0 );
  //   
  PrintTextLine( parTextLine );

  if ( YesNo( "   ?" ) == 1 )
  {
    TextItemParam parTextItem; //     

    //     ITALIC  BOLD   
    GetArrayItem( parTextLine.pTextItem, 0, &parTextItem, sizeof( parTextItem ) );
    parTextItem.font.bitVector = parTextItem.font.bitVector | ITALIC_ON | BOLD_ON; //  ,   
    parTextItem.font.color = RGB ( 0, 255, 0 ); // 
    SetArrayItem( parTextLine.pTextItem, 0, &parTextItem, sizeof( parTextItem ) );
    //     
    SetObjParam( rParagraph, &parTextLine, sizeof( parTextLine ), 0 );
    //   1-  (  0 )
    GetObjParam( rParagraph, &parTextLine, sizeof( parTextLine ), 0 );
    //   
    PrintTextLine( parTextLine );
  }
}
