Пример #1
0
static void hb_conDevPos( int iRow, int iCol )
{
   HB_FHANDLE hFile;

   HB_TRACE( HB_TR_DEBUG, ( "hb_conDevPos(%d, %d)", iRow, iCol ) );

   /* Position printer if SET DEVICE TO PRINTER and valid printer file
      otherwise position console */

   if( ( hFile = hb_setGetPrinterHandle( HB_SET_PRN_DEV ) ) != FS_ERROR )
   {
      int iPRow = iRow;
      int iPCol = iCol + hb_setGetMargin();
      PHB_PRNPOS pPrnPos = hb_prnPos();

      if( pPrnPos->row != iPRow || pPrnPos->col != iPCol )
      {
         char buf[ 256 ];
         int iPtr = 0;

         if( pPrnPos->row != iPRow )
         {
            if( ++pPrnPos->row > iPRow )
            {
               memcpy( &buf[ iPtr ], "\x0C\x0D\x00\x00", 2 );  /* Source buffer is 4 bytes to make CodeGuard happy */
               iPtr += 2;
               pPrnPos->row = 0;
            }
            else
            {
               memcpy( &buf[ iPtr ], s_szCrLf, s_iCrLfLen );
               iPtr += s_iCrLfLen;
            }

            while( pPrnPos->row < iPRow )
            {
               if( iPtr + s_iCrLfLen > ( int ) sizeof( buf ) )
               {
                  hb_fsWrite( hFile, buf, ( HB_USHORT ) iPtr );
                  iPtr = 0;
               }
               memcpy( &buf[ iPtr ], s_szCrLf, s_iCrLfLen );
               iPtr += s_iCrLfLen;
               ++pPrnPos->row;
            }
            pPrnPos->col = 0;
         }
         else if( pPrnPos->col > iPCol )
         {
            buf[ iPtr++ ] = '\x0D';
            pPrnPos->col = 0;
         }

         while( pPrnPos->col < iPCol )
         {
            if( iPtr == ( int ) sizeof( buf ) )
            {
               hb_fsWrite( hFile, buf, ( HB_USHORT ) iPtr );
               iPtr = 0;
            }
            buf[ iPtr++ ] = ' ';
            ++pPrnPos->col;
         }

         if( iPtr )
            hb_fsWrite( hFile, buf, ( HB_USHORT ) iPtr );
      }
   }
   else
      hb_gtSetPos( iRow, iCol );
}
Пример #2
0
int main( void )
{
   const char * test = "Testing GT API Functions";
   const char * test2 = "This message wraps!";

   void * scr;
   HB_SIZE size;

   /* NOTE: always have to initialze video subsystem */
   hb_gtInit( 0, 0, 0 );

   /* save screen */

   hb_gtRectSize( 1, 1, hb_gtMaxRow(), hb_gtMaxCol(), &size );
   scr = hb_xgrab( size );
   hb_gtSave( 1, 1, hb_gtMaxRow() - 1, hb_gtMaxCol() - 1, scr );

   /* writing text */
   hb_gtSetPos( 3, 3 );
   hb_gtWrite( test, strlen( test ) );
   hb_gtSetPos( 12, 42 );
   hb_gtWrite( test, strlen( test ) );

   /* wrapping text */
   hb_gtSetPos( 7, 70 );
   hb_gtWrite( test2, strlen( test2 ) );

   /* writing color text */
   hb_gtSetColorStr( "W+/B, B/W" );
   hb_gtColorSelect( HB_CLR_STANDARD );
   hb_gtWrite( "Enhanced color (B/W)", 20 );
   hb_gtSetPos( 22, 62 );
   hb_gtColorSelect( HB_CLR_ENHANCED );
   hb_gtWrite( "Standard Color (W+/B)", 21 );

   /* boxes */
   hb_gtBoxS( 10, 10, 20, 20 );
   hb_gtBoxD( 10, 40, 15, 45 );

   /* cursor functions */
   hb_gtSetPos( 12, 1 );

   /* none */
   hb_gtSetCursor( SC_NONE );
   hb_inkey( HB_TRUE, 0.0, INKEY_ALL );

   /* underline */
   hb_gtSetCursor( SC_NORMAL );
   hb_inkey( HB_TRUE, 0.0, INKEY_ALL );

   /* lower half block */
   hb_gtSetCursor( SC_INSERT );
   hb_inkey( HB_TRUE, 0.0, INKEY_ALL );

   /* full block */
   hb_gtSetCursor( SC_SPECIAL1 );
   hb_inkey( HB_TRUE, 0.0, INKEY_ALL );

   /* upper half block */
   hb_gtSetCursor( SC_SPECIAL2 );
   hb_inkey( HB_TRUE, 0.0, INKEY_ALL );

   /* restore screen */
   hb_gtRest( 1, 1, hb_gtMaxRow() - 1, hb_gtMaxCol() - 1, scr );
   hb_xfree( scr );

   return 0;
}