void * __conArrayGet( void *, void *, ... );
long __conGetNL( void *, long * );
long __conRelease( void * );
#include <Windows.h>
#ifdef __HARBOUR__
#include <hbapi.h>
#include <hbapiitm.h>
#include <hbstack.h>
#include <hbvm.h>
// #include <hbfast.h>
#define MoveTo( hDC, x, y ) MoveToEx( hDC, x, y, NULL )
#define _PutSym( _SymEval ) hb_vmPushSymbol( &hb_symEval )
#define _xPushM hb_vmPush
#define _PutLN hb_vmPushLong
#define _xEval hb_vmDo
#define _cEval0 hb_vmEvalBlock
#define _Get_Sym hb_dynsymFindName
#endif
#define LOGICAL HB_IT_LOGICAL
#define NUMERIC HB_IT_NUMERIC
#define CHARACTER HB_IT_STRING
#define BLOCK HB_IT_BLOCK
#define HA_LEFT 0 // by CeSoTech Alineaciones Horizontales y Verticales
#define HA_RIGHT 1
#define HA_CENTER 2
#define VA_TOP 4
#define VA_BOTTOM 8
#define VA_CENTER 32
#ifdef __FLAT__
#undef PCLIPVAR
#define PCLIPVAR PHB_ITEM
#endif
#ifdef __XHARBOUR__
void hb_storvni( int iValue, int iParam, int iIndex );
long hb_parvnl( int iParam, int iIndex );
int hb_parvni( int iParam, int iIndex );
void hb_storvnl( LONG lValue, int iParam, int iIndex );
#endif
static far BOOL bAdjLastCol ; // CeSoTech
static far BOOL bAdjBrowse ; // CeSoTech
static far BOOL bDrawHeaders ; // CeSoTech
static far BOOL bDrawFooters ; // CeSoTech
static far WORD wHeaderHeight; // CeSoTech
static far WORD wFooterHeight; // CeSoTech
static far WORD wLineHeight ; // CeSoTech
static far BOOL bWorking;
WORD WBrwRowsC( HWND hWnd, HDC hDC, HFONT hFont ); // CeSoTech
static void FW_DrawText( HDC hDC, RECT * rct, LPCSTR pText,
WORD wAlign, int iLen, HFONT hFont,
BOOL bHeadFoot ) ; // CeSoTech
static void FW_DrawBitmapCenter( HDC hDC, HBITMAP hBmp, RECT * rct, WORD nStyle, BOOL bFocused ) ;
void MaskRegion( HDC hDC, RECT * rct, COLORREF cTrColor,
COLORREF cBackColor );
FrameDot( HDC hDC, RECT * pRect );
extern void WndDrawBox( HDC, LPRECT, HPEN, HPEN );
extern void DrawBitmap( HDC, HBITMAP, WORD wCol, WORD wRow, WORD wWidth,
WORD wHeight, DWORD dwRaster );
static void near PaintTheLine( HDC hDC, RECT * rct, WORD wIndex,
PCLIPVAR pAtext, PCLIPVAR pAsizes,
HPEN hWhitePen, HPEN hGrayPen, BOOL bTree,
PCLIPVAR pAJustify, WORD wPressed,
BOOL bHeader, WORD nStyle,
WORD nFocus, BOOL bFocused,
PCLIPVAR pTextColor, PCLIPVAR pBkColor,
WORD wRowPos, WORD nHeightCtrl,
LONG nClrLine, BOOL bFooter,
BOOL bSelect, PCLIPVAR pFont,
BOOL bDrawFocusRect ) ;
void DrawMasked( HDC, HBITMAP, WORD wCol, WORD wRow );
// LOW HIGH
extern int _dvtoi( DWORD, DWORD );
void MsgStr( long l );
LPSTR Str( WORD w );
#ifndef __FLAT__
static int near GetInt( PCLIPVAR Array, WORD wIndex );
static far PCLIPSYMBOL pSkip = 0;
#else
static long near GetInt( void * Array, WORD wIndex );
PHB_DYNS pSkip = NULL;
#endif
//---------------------------------------------------------------------------//
static void MaskRegion( HDC hdc, RECT * rct, COLORREF cTransparentColor,
COLORREF cBackgroundColor )
{
HDC hdcTemp, hdcObject, hdcBack, hdcMem;
POINT ptSize;
COLORREF cColor;
HBITMAP bmAndObject, bmAndBack, bmBackOld, bmObjectOld,
bmAndTemp, bmTempOld, bmAndMem, bmMemOld;
HBRUSH hBrush, hBrOld;
ptSize.x = rct->right - rct->left + 1;
ptSize.y = rct->bottom - rct->top + 1;
hBrush = CreateSolidBrush(cBackgroundColor);
hdcTemp = CreateCompatibleDC(hdc);
hdcObject = CreateCompatibleDC(hdc);
hdcBack = CreateCompatibleDC(hdc);
hdcMem = CreateCompatibleDC(hdc);
bmAndTemp = CreateCompatibleBitmap(hdc, ptSize.x, ptSize.y);
bmAndMem = CreateCompatibleBitmap(hdc, ptSize.x, ptSize.y);
bmAndObject = CreateBitmap(ptSize.x, ptSize.y, 1, 1, NULL);
bmAndBack = CreateBitmap(ptSize.x, ptSize.y, 1, 1, NULL);
bmTempOld = SelectObject(hdcTemp, bmAndTemp);
bmMemOld = SelectObject(hdcMem, bmAndMem);
bmBackOld = SelectObject(hdcBack, bmAndBack);
bmObjectOld = SelectObject(hdcObject, bmAndObject);
hBrOld = SelectObject(hdcMem, hBrush);
BitBlt(hdcTemp, 0, 0, ptSize.x, ptSize.y, hdc, rct->left, rct->top, SRCCOPY);
SetMapMode(hdcTemp, GetMapMode(hdc));
cColor = SetBkColor(hdcTemp, cTransparentColor);
BitBlt(hdcObject, 0, 0, ptSize.x, ptSize.y, hdcTemp, 0, 0, SRCCOPY);
SetBkColor(hdcTemp, cColor);
BitBlt(hdcBack, 0, 0, ptSize.x, ptSize.y, hdcObject, 0, 0, NOTSRCCOPY);
PatBlt(hdcMem, 0,0, ptSize.x, ptSize.y, PATCOPY);
BitBlt(hdcMem, 0, 0, ptSize.x, ptSize.y, hdcObject, 0, 0, SRCAND);
BitBlt(hdcTemp, 0, 0, ptSize.x, ptSize.y, hdcBack, 0, 0, SRCAND);
BitBlt(hdcMem, 0, 0, ptSize.x, ptSize.y, hdcTemp, 0, 0, SRCPAINT);
BitBlt(hdc, rct->left, rct->top, ptSize.x, ptSize.y, hdcMem, 0, 0, SRCCOPY);
DeleteObject(SelectObject(hdcMem, hBrOld));
DeleteObject(SelectObject(hdcTemp, bmTempOld));
DeleteObject(SelectObject(hdcMem, bmMemOld));
DeleteObject(SelectObject(hdcBack, bmBackOld));
DeleteObject(SelectObject(hdcObject, bmObjectOld));
DeleteDC(hdcMem);
DeleteDC(hdcBack);
DeleteDC(hdcObject);
DeleteDC(hdcTemp);
}
//---------------------------------------------------------------------------//
#ifdef __CLIPPER__
static int near GetInt( PCLIPVAR Array, WORD wIndex )
{
int iRet = 0;
_cAt( Array, wIndex, -1, ++_tos );
if( _tos->wType & NUMERIC )
iRet = (int) _tos->pPointer1;
else if( _tos->wType & NUM_FLOAT )
iRet = _dvtoi( (DWORD) _tos->pPointer1, (DWORD) _tos->pPointer2 );
--_tos;
return iRet;
}
#endif
#ifdef __XPP__
static long GetInt( void * Array, WORD wIndex )
{
void * chItem = 0;
long l;
__conArrayGet( Array, chItem, wIndex, 0 );
__conGetNL( chItem, &l );
__conRelease( chItem );
return l;
}
#endif
#ifdef __HARBOUR__
#define GetInt( Array, wIndex ) hb_arrayGetNL( Array, wIndex )
#endif
//-----------------------------------------------------------------------=
// ÚÄ1ra Col.a Pintar
// ³
static void near PaintTheLine( HDC hDC, RECT * rct, WORD wIndex,
PCLIPVAR pAtext, PCLIPVAR pAsizes,
HPEN hWhitePen, HPEN hGrayPen, BOOL bTree,
PCLIPVAR pAJustify, WORD wPressed,
BOOL bHeader, WORD nStyle,
WORD wFocus, BOOL bFocused,
PCLIPVAR pTextColor, PCLIPVAR pBkColor,
WORD wRowPos, WORD nHeightCtrl,
LONG nClrLine, BOOL bFooter,
BOOL bSelect, PCLIPVAR pFont,
BOOL bDrawFocusRect )
{
RECT box, wholebox, rctadj;
int iMaxRight = rct->right;
WORD wLenJust = 0 ;
#ifndef __HARBOUR__
WORD wLen = _VARRAYLEN( pAtext );
CLV_WORD lJustify;
#else
WORD wLen = hb_arrayLen( pAtext );
PHB_ITEM uElem = hb_itemNew( NULL );
#endif
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
PCLIPVAR 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 )
#ifndef __HARBOUR__
wLenJust = _VARRAYLEN( pAJustify );
#else
wLenJust = hb_arrayLen( pAJustify );
#endif
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 !!!
#ifndef __HARBOUR__
if ( wIndex <= wLenJust )
{
_cAt( pAJustify, wIndex, 0xFFFF, ( PCLIPVAR ) &lJustify );
wAlign = lJustify.wWord ;
}
_cAt( pAtext, wIndex, 0xFFFF, ++_tos );
wType = _tos->wType;
if ( wType & NUMERIC )
lValue = (LONG) _tos->pPointer1;
if ( wType & CHARACTER )
{
cValue = _VSTR( _tos );
wcLen = _tos->w2;
}
#else
if ( wIndex <= wLenJust )
{
hb_arrayGet( pAJustify, wIndex, uElem );
if ( ( hb_itemType( uElem ) & LOGICAL ) && hb_itemGetL( uElem ) )
wAlign = HA_RIGHT | VA_CENTER ;
else
wAlign = hb_itemGetNL( uElem );
hb_itemClear( uElem );
}
// uElem.type = HB_IT_NIL;
hb_arrayGet( pAtext, wIndex, uElem );
wType = hb_itemType( uElem );
if ( wType & NUMERIC )
lValue = hb_itemGetNL( uElem );
if ( wType & CHARACTER )
{
// cValue = hb_itemGetC( uElem );
cValue = ( char * ) hb_itemGetCPtr( uElem );
wcLen = strlen( cValue );
}
#endif
///////// FIN Toma de datos celda !!!
if( wFocus > 0 && wIndex != wFocus )
{
#ifndef __HARBOUR__
_tos--;
#endif
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,
// pero es para evitar hacer trabajar
// al codigo sin sentido !!! )
if( (wType & NUMERIC) && bTree )
{
if( lValue )
{
FillRect( hDC, rct, hBrush = CreateSolidBrush( GetPixel( hDC, rct->left, rct->top ) ) );
DrawMasked( hDC, (HBITMAP) lValue, rct->top, rct->left );
DeleteObject( hBrush );
}
}
else // Si es Numerico Bmp no Tree, o , es Character !!!!
{
if ( pBkColor ) // Bloque de Color Fondo Celda
{
_PutSym( _SymEval ); //line 387
_xPushM( pBkColor );
_PutLN( wRowPos );
_PutLN( wIndex );
_PutLN( bFooter ? 2 : ( bHeader ? 1 : ( bSelect ? 3 : 0 ) ) );
_xEval( 3 ) ;
if ( hb_parinfo( -1 ) & NUMERIC )
lBkColorOld = SetBkColor( hDC, hb_parnl( - 1 ) ) ;
}
if( pTextColor ) // Bloque de Color Texto Celda
{
_PutSym( _SymEval ); //linr 399
_xPushM( pTextColor );
_PutLN( wRowPos );
_PutLN( wIndex );
_PutLN( bFooter ? 2 : ( bHeader ? 1 : ( bSelect ? 3 : 0 ) ) );
_xEval( 3 ) ;
if ( hb_parinfo( -1 ) & NUMERIC )
lTextColorOld = SetTextColor( hDC, hb_parnl( - 1 ) ) ;
}
hFont = 0 ;
if( pFont ) // Bloque de Font Celda
{
_PutSym( _SymEval ); //line 412
_xPushM( pFont );
_PutLN( wRowPos );
_PutLN( wIndex );
_PutLN( bFooter ? 2 : ( bHeader ? 1 : ( bSelect ? 3 : 0 ) ) );
_xEval( 3 ) ;
if ( hb_parinfo( -1 ) & NUMERIC )
hFont = (HFONT) hb_parnl( - 1 ) ;
}