Exemplo n.º 1
0
CLIPPER CharCount( void )
{
   USHORT uiChars = 0;
   USHORT uiLen;
   USHORT i;
   HANDLE vmhString;

   BYTEP  cStringP;
   BYTE   cFindMe;

   ITEM   itemString, itemFindMe, itemRet;
   

   if (PCOUNT != 2)
   {
      _ret();           // NOTE: Withhold service
      return;           // Early return!
   }

   itemRet    = _itemPutNL( NULL, 0 );
   itemString = _itemParam( 1 );
   itemFindMe = _itemParam( 2 );

   if ( (_itemType( itemString ) == CHARACTER) &&
        (_itemType( itemFindMe ) == CHARACTER) )
   {
      _itemCopyC( itemFindMe, &cFindMe, 1 );
   
      vmhString = _xvalloc( _itemSize( itemString ), NULL );
      cStringP = _xvlock( vmhString );

      uiLen = _itemCopyC( itemString, cStringP, NULL );

      for( i = 0; i < uiLen; i++ )
      {
         if ( cStringP[i] == cFindMe )
            uiChars++;
      }
      
      _xvunlock( vmhString );   
      _xvfree( vmhString );


      itemRet = _itemPutNL( itemRet, (long)uiChars );
      
   }

   _itemReturn( itemRet );

   _itemRelease( itemRet );
   _itemRelease( itemString );
   _itemRelease( itemFindMe );

   return;
}
Exemplo n.º 2
0
CLIPPER IsDouble( void )
{
   ITEM itemRet, itemNum;

   itemRet = _itemPutL( NULL, FALSE );

   if (PCOUNT > 0)
   {
      itemNum = _itemParam( 1 );

      if (_itemType( itemNum ) & DOUBLE)
         itemRet = _itemPutL( itemRet, TRUE );

      _itemRelease( itemNum );
   }
   
   _itemRelease( _itemReturn( itemRet ) );

   return;
}
Exemplo n.º 3
0
//---------------------------------------------------------------------------//
CLIPPER WBRWPANE( void ) // ( hWnd, hDC, Self, bLine, aSizes, nFirstItem,
                           //   nClrFore, nClrBack, hFont, aJustify, nStyle
                           //   lCellStyle, lFocused ) -> nRowsSkipped
                           //   bTextColor, bBkColor, nClrLine, nColorFondo, bFont ) // New's by CesoTech
{
   HWND hWnd        = ( HWND ) _parnl( 1 );
   HDC hDC          = ( HDC ) _parnl( 2 );
   WORD wRows;
   WORD wLastBottom = 0;
   WORD wRow        = 1;
   WORD wSkipped    = 1;
   void * Self    = _param( 3, -1 );
   void * bLine   = _param( 4, -1 );
   void * pASizes = _param( 5, -1 );
   HFONT hFont      = ( HFONT ) _parnl( 9 );
   HFONT hOldFont;
   BOOL bDestroyDC  = FALSE;
   WORD wHeight ;
   RECT rct, box, client;
   WORD wIndex      = _parni( 6 );
   void * bClrFore = 0;
   void * bClrBack = 0;
   COLORREF clrFore = 0;
   COLORREF clrBack = 0;
   HPEN hGrayPen    = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNSHADOW ) ) ; // RGB( 128, 128, 128 ) );
   HPEN hWhitePen   = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNHIGHLIGHT ) ); // GetStockObject( WHITE_PEN );

   BOOL bColBlock   = ( _itemType( pASizes ) & BLOCK );

   void * pAJustify = ISARRAY( 10 ) ? _param( 10, -1 ): 0;
   WORD nHeightCtrl ; // by CeSoTech
   WORD nStyle = _parni( 11 );

   if( PCOUNT() > 6 )
   {
      if( ISBLOCK( 7 ) )
         bClrFore = _param( 7, -1 );
      else
         clrFore = _parnl( 7 );
   }

   if( PCOUNT() > 7 )
   {
      if( ISBLOCK( 8 ) )
      {
         bClrBack = _param( 8, -1 );
         _cEval0( bClrBack );
         clrBack = _parnl( -1 );
      }
      else
         clrBack = _parnl( 8 );
   }

   if( ! hDC )
   {
      bDestroyDC = TRUE;
      hDC = GetDC( hWnd );
   }

   if( ! pSkip )
       pSkip = _get_sym( "SKIP" );

   if( hFont )
      hOldFont = SelectObject( hDC, hFont );

   /////////////////////////
   // Borremos el Area de la derecha no coubierta
   if ( !bAdjBrowse && !bAdjLastCol )
   {
       GetClientRect( hWnd, &rct );
       SetBkColor( hDC, _parnl( 17 ) ) ;

       for( wIndex=wIndex ; wIndex <= (WORD) _parinfa( 5, NULL); wIndex++ )
       {
            rct.left += _parni( 5, wIndex ) ;
       }

       if ( !(nStyle == 0 || nStyle == 7 || nStyle == 8 || nStyle == 3) )
          rct.left++;

       ExtTextOut( hDC, rct.left, rct.top, ETO_OPAQUE | ETO_CLIPPED,
                   &rct, "", 0, 0 );

       wIndex = _parni( 6 );
       GetClientRect( hWnd, &rct );
   }
   /////////////////////////

   GetClientRect( hWnd, &client );

   nHeightCtrl = client.bottom-client.top ; // by CeSoTech

   wHeight = wLineHeight + 1 ;

   wRows = WBrwRowsC( hWnd, hDC, hFont );

   if( ! bClrFore )
      SetTextColor( hDC, clrFore );
      SetBkColor( hDC, clrBack );

   while( wRow <= wRows && wSkipped == 1 )
   {
      rct.top    = client.top + ( bDrawHeaders ? wHeaderHeight+1 : 0 ) +
                   (wHeight * (wRow-1) ) ;

      rct.bottom = rct.top + wHeight;
      rct.left   = 0;
      rct.right  = client.right;

      _cEval0( bLine );
      _xpushm( _eval );

      if( bClrFore )
      {
         _cEval0( bClrFore );
         SetTextColor( hDC, _parnl( -1 ) );
      }

      if( bClrBack )
      {
         _cEval0( bClrBack );
         SetBkColor( hDC, _parnl( -1 ) );
      }

      if( bColBlock )
         _cEval0( pASizes );

      PaintTheLine( hDC, &rct, wIndex, _tos,
                    ( bColBlock ? _eval : pASizes ),
                    hWhitePen, hGrayPen,
                    bColBlock, pAJustify, 0, FALSE, _parni( 11 ),
                    _parni ( 12 ), _parl( 13 ),
                    ISBLOCK( 14 ) ? _param( 14, -1 ) : 0,   // CeSoTech
                    ISBLOCK( 15 ) ? _param( 15, -1 ) : 0,   // CeSoTech
                    wRow, nHeightCtrl,                      // CeSoTech
                    ISNUM( 16 ) ? _parnl( 16 ) : -1,        // CeSoTech
                    FALSE, FALSE,                           // CeSoTech
                    ISBLOCK( 18 ) ? _param( 18, -1 ) : 0,   // CeSoTech
                    FALSE ) ;

      _0POP();

      _putsym( pSkip );
      _xpushm( Self );
      _putq( 1 );
      _xsend( 1 );

      wLastBottom = rct.bottom ;
      wSkipped = _parni( -1 );

      if( wSkipped == 1 )
          wRow++;
   }

   ////////////////////////
   // Borremos el Area de Abajo no cubierta
   GetClientRect( hWnd, &rct );
   SetBkColor( hDC, _parnl( 17 ) ) ;

   rct.top = wLastBottom + 1 ;
   if ( wLastBottom == 0 ) // No Mostro Registros
      rct.top = ( bDrawHeaders ? wHeaderHeight+1 : 0 ) ;

   rct.bottom-=  1 + ( bDrawFooters ? wFooterHeight+1 : 0 ) ;

   if (nStyle == 0 || nStyle == 5 || nStyle == 6 ||
       nStyle == 9 || nStyle == 10 || nStyle == 3 )
      rct.top--;

   if ( !bDrawFooters )
      rct.bottom++;


   if ( rct.top < rct.bottom )
   {
      ExtTextOut( hDC, rct.left, rct.top, ETO_OPAQUE | ETO_CLIPPED,
                  &rct, "", 0, 0 );
   }
   ////////////////////////

   DeleteObject( hGrayPen );
   DeleteObject( hWhitePen );

   if( hFont )
      SelectObject( hDC, hOldFont );

   if( bDestroyDC )
       ReleaseDC( hWnd, hDC );

   _retni( wRow );

}
Exemplo n.º 4
0
//-----------------------------------------------------------------------=
                                                        // ÚÄ1ra Col.a Pintar
                                                        // ³
static void PaintTheLine( HDC hDC, RECT * rct, WORD wIndex,
                               void *pAtext, void *pAsizes,
                               HPEN hWhitePen, HPEN hGrayPen, BOOL bTree,
                               void *pAJustify, WORD wPressed,
                               BOOL bHeader, WORD nStyle,
                               WORD wFocus, BOOL bFocused,
                               void *pTextColor, void *pBkColor,
                               WORD wRowPos, WORD nHeightCtrl,
                               LONG nClrLine, BOOL bFooter,
                               BOOL bSelect, void *pFont,
                               BOOL bDrawFocusRect )
{
   RECT box, wholebox, rctadj;
   int iMaxRight = rct->right;

   WORD wLenJust = 0 ;
   WORD wLen     = _VARRAYLEN( pAtext );
   WORD wType, wcLen;
   LONG lValue;
   char * cValue;
   HPEN hOldPen, hPen;
   BITMAP bmp;
   WORD wRow, wCol;
   LONG lColor ;
   HBRUSH hBrush;
   LONG lTextColorOld = -1 ; // CeSoTech
   LONG lBkColorOld   = -1 ; // CeSoTech
   void * pEvalOld ;
   HFONT hFont ; // CeSoTech
   WORD wAlign ; // CeSoTech

   // CeSoTech
   LONG nClrLineC = ( nStyle == 2 || nStyle == 6 || nStyle == 8 ||
                      nStyle == 10 ) ? GetSysColor( COLOR_BTNSHADOW ) : 0 ;

   // CeSoTech
   if ( nClrLine >= 0 )   // Desde Clipper manda color especifico linea
      nClrLineC = nClrLine ;

   if ( ! bDrawHeaders )
      bHeader = FALSE ;

   if ( bFooter )
      bHeader = TRUE ; //-> Para que lo pinte con similar aspecto

   //CeSoTech
   // Si es un estilo sin separadores horizontales, pintar uno mas arriba
   //CeSoTech para que que bien completa el area !!!
   if ( ! (bHeader) && (nStyle == 0 || nStyle == 5 || nStyle == 6 ||
                        nStyle == 9 || nStyle == 10) )
      rct->top--       ;

   wholebox.top    = rct->top+1;
   wholebox.left   = rct->left;
   wholebox.bottom = rct->bottom;
   wholebox.right  = rct->right;

   rct->right  = 0;

   box.top    = rct->top ;
   box.bottom = rct->bottom - 1;

   if( !wIndex || wIndex > wLen )
       wIndex = 1;

   if ( pAJustify )
       wLenJust = _VARRAYLEN( pAJustify );

   while( wIndex <= wLen )
   {

        rct->left   = rct->right;

        rct->right  = ( wIndex == wLen ? iMaxRight
                                      : rct->left + GetInt( pAsizes, wIndex ) );

        // CeSoTech // Cuando estoy estoy en la ultima celda, NO pintar hasta
                    // el final si no existe ajuste de ultima columna.
        if ( ( wIndex == wLen ) && ( ! bAdjLastCol )  )
        {
           rct->right  = rct->left + GetInt( pAsizes, wIndex ) +( bHeader ? 1 : 0 ) ;
           if ( !bAdjBrowse )
              wholebox.right = rct->right ; // Tambien ajusto el borde focus

        }
        // CeSoTech //

        wAlign = HA_LEFT | VA_CENTER ;  // Alineacion por defecto
        wcLen = 0;
        ///////// INICIO Toma de datos celda !!!

        if ( wIndex <= wLenJust )
        {
          _put();
          //_cAt( pAJustify, wIndex, S_ANY, _tos );
          _cAt( pAJustify, wIndex, S_LOG, _tos );
          wAlign = ( WORD ) _itemGetL( _tos );
          //wAlign = _sptol( _tos ); //_sptoq( _tos );
          _0POP();
        }
        _put();
        _cAt( pAtext, wIndex, S_ANY, _tos );
        wType = _itemType( _tos );
        // aki esta er tema
        if ( wType & NUMERIC )
           lValue = _sptol( _tos );
        else if ( wType & CHARACTER )
        {
           cValue = _VSTR( _tos );
           wcLen = _itemSize( _tos );
        }

        _0POP();
        ///////// FIN Toma de datos celda !!!

        if( wFocus > 0 && wIndex != wFocus )
        {
           if( rct->right >= iMaxRight )
           {
               wIndex = wLen + 1;   // ya no pintamos m s
           }
           else
              ++wIndex;
           continue;
        }

        if( bTree || ( GetInt( pAsizes, wIndex ) > 0 ) )    //Si NO es columna oculta (x Freeze)
        {                                                   //(Es lo mismo no hacer esto,

           if( (wType & NUMERIC) && bTree )
           {
               if( lValue )
               {
                  DrawMasked( hDC, (HBITMAP) lValue, ( rct->top < 1 ? 1 : rct->top ), rct->left );
               }
           }
           else  // Si es Numerico Bmp no Tree, o , es Character !!!!
           {

               if ( pBkColor )  // Bloque de Color Fondo Celda
               {
                  _putsym( _SymEVAL );
                  _xpushm( pBkColor );
                  _putln( wRowPos );
                  _putln( wIndex );
                  _putln( bFooter ? 2 : ( bHeader ? 1 : ( bSelect ? 3 : 0 ) ) );
                  _xeval( 3 ) ;
                  if ( _parinfo( -1 ) & NUMERIC )
                    lBkColorOld = SetBkColor( hDC, _parnl( - 1 ) ) ;
               }

               if( pTextColor ) // Bloque de Color Texto Celda
               {
                  _putsym( _SymEVAL );
                  _xpushm( pTextColor );
                  _putln( wRowPos );
                  _putln( wIndex );
                  _putln( bFooter ? 2 : ( bHeader ? 1 : ( bSelect ? 3 : 0 ) ) );
                  _xeval( 3 ) ;
                  if ( _parinfo( -1 ) & NUMERIC )
                    lTextColorOld = SetTextColor( hDC, _parnl( - 1 ) ) ;
               }

               hFont = 0 ;
               if( pFont )      // Bloque de Font Celda
               {
                  _putsym( _SymEVAL );
                  _xpushm( pFont );
                  _putln( wRowPos );
                  _putln( wIndex );
                  _putln( bFooter ? 2 : ( bHeader ? 1 : ( bSelect ? 3 : 0 ) ) );
                  _xeval( 3 ) ;
                  if ( _parinfo( -1 ) & NUMERIC )
                     hFont = (HFONT) _parnl( - 1 ) ;
               }

               /////// CeSoTech ///////
               if (!bHeader) rct->top ++;

               if( wType & NUMERIC )   // Es un BitMap
               {
                  FW_DrawBitmapCenter( hDC, (HBITMAP) lValue, rct, nStyle, bSelect );
               }
               else                    // Es una Cadena
               {
                  FW_DrawText( hDC, rct,
                               ( wType & CHARACTER ) ? cValue : "",
                               wAlign, wcLen, hFont, bHeader ) ;

               }


               /////// CeSoTech restauracion de colores //////
               if ( lTextColorOld >= 0 )
               {
                  SetTextColor( hDC, lTextColorOld ) ;
                  lTextColorOld = -1 ;
               }
               if ( lBkColorOld >= 0 )
               {
                  SetBkColor( hDC, lBkColorOld ) ;
                  lBkColorOld = -1 ;
               }


               /// CeSoTech ///
               // Si hay modalidad ajustar el Browse y no hay ajuste de ultima
               // columna, deber‚ pintar hasta el final hasta cubrir toda
               // el area, hasta llegar a la derecha del control. (Col.Ficticia)
               if ( bAdjBrowse && wIndex == wLen && !bAdjLastCol &&
                    rct->right <= iMaxRight )
               {
                  rctadj.top    = rct->top;
                  rctadj.left   = rct->right ;
                  rctadj.bottom = rct->bottom;
                  rctadj.right  = wholebox.right  ;

                  if ( nStyle == 3 )
                     rctadj.top--;

                  if ( wFocus == 0 )  // Si No es CellStyle (Pinto hasta final)
                     ExtTextOut( hDC, 0, rct->top, ETO_OPAQUE, &rctadj, "", 0, 0 );

                  if ( bHeader ) // Pinto Bordes Header Falso
                   {
                      rctadj.right  = wholebox.right - 2  ;
                      rctadj.bottom = rctadj.bottom - 2 ;
                      WndDrawBox( hDC, &rctadj, hWhitePen, hGrayPen );
                      rctadj.bottom++  ;
                      rctadj.right++  ;
                      WndDrawBox( hDC, &rctadj, hWhitePen, GetStockObject( BLACK_PEN ) );

                      if ( bFooter ) // Si es Footer (Linea Negra de Arriba Foot)
                      {
                        hPen = GetStockObject( BLACK_PEN );
                        hOldPen = SelectObject( hDC, hPen );
                        MoveToEx( hDC, rctadj.left-1, rctadj.top-1, NULL );
                        LineTo( hDC, rctadj.right+1, rctadj.top-1 );
                        SelectObject( hDC, hOldPen );
                      }

                  }
               }
               /// CeSoTech Fin ///

               if (!bHeader) rct->top --;
           }

           box.left   = rct->left;

           box.right  = ( wIndex < wLen && rct->right <= iMaxRight ?
                                                        rct->right - 1 :
                                                        iMaxRight - 1 );

           // CeSoTech // El Borde derecho de Box de la ultima columna,
                       // no estirarlo cuando no exista ajuste de ultima columna
                       // PERO cuando nLineStyle (nStyle) es 7/8 (Lineas Horiz)
                       // queda anti-estetico cortar los renglones, cuando no hay
                       // ajuste ult.col. y hay ajuste de browse. Por ello
                       // se verificara que para cortar el borde no se de esta
                       // condicion.
           if ( ( wIndex == wLen ) && ( ! bAdjLastCol ) )
           {
              if (! (!bHeader && (nStyle==7 || nStyle==8) && !bAdjLastCol && bAdjBrowse) )
               box.right  = rct->left + GetInt( pAsizes, wIndex ) - 1 ;
           }

           if( ! bTree )
           {
              WndDrawBox( hDC, &box, hGrayPen, hWhitePen );
           }
           else
           {
              if( ! ( wType & NUMERIC ) )
              {
                 box.left -= 16;
              }
           }

          // CeSoTech if( bFocused && wFocus > 0 && wIndex == wFocus )
           if( bDrawFocusRect && bFocused && wFocus > 0 &&
               wIndex == wFocus && nStyle != 3)
           {
            rct->left++;
            rct->top++;
            DrawFocusRect( hDC, rct );
            rct->left--;
            rct->top--;
           }

        }

        if( rct->right >= iMaxRight )
        {
            wIndex = wLen + 1;   // ya no pintamos m s
        }
        else
           ++wIndex;


   }

   if (bDrawFocusRect && !bTree && bFocused && wFocus==0 && nStyle!=3) // CeSoTech
      DrawFocusRect( hDC, &wholebox );

}