Forum
Please
Log In
to post a new message or reply to an existing one. If you are not registered, please
register.
NOTE: Some forums may be read-only if you are not currently subscribed to
our technical support services.
Subject |
Author |
Date |
|
Bogdan Munteanu
|
Oct 10, 2011 - 4:52 PM
|
Dear customer support,
I believe there are some problems with the Print Preview functionality in Prof UIS whenever used with multiline text cells. If the cell contents exceeds one line, the subsequent lines overlap the contents of the cells underneath.
I emailed you an example based on Synchronized Grids with the erroneous behavior.
Could you please confirm and advise,
Thank you,
Bogdan
|
|
Bogdan Munteanu
|
Oct 11, 2011 - 5:05 PM
|
Dear support,
Your fix works for multiline, thank you!
There seems to be another issue with rendering cells with very long contents: whenever in the last column, the text exceeds the page margin:
I sent you an email showing that behavior.
Thank you, Bogdan
|
|
Technical Support
|
Oct 13, 2011 - 12:17 PM
|
It seems there is only one way to resolve this issue: make the text multiline.
|
|
Bogdan Munteanu
|
Nov 6, 2011 - 4:18 AM
|
How can this be done for the value cells of a property grid? (The example I sent was not a data grid but a property grid control.) Thank you.
|
|
Technical Support
|
Nov 7, 2011 - 12:42 PM
|
The property grid control supports data cells of a variable height automatically.
|
|
Bogdan Munteanu
|
Nov 13, 2011 - 2:46 PM
|
Can you reply to my latest message? Thank you, Bogdan
|
|
Technical Support
|
Nov 15, 2011 - 2:54 AM
|
We still trying to resolve this issue without modifying method signatures. The current version of the print/preview page generating algorithm assumes all the cells have the size less than the page size. So, the fastest way to resolve this is to override the CExtGridCell::MeasureCell API and provide alternative a cell size which fit the page size. Generally, this task does not have a 100% working solution. Even if we turn on text wrapping, then cell height can potentially exceed the page height.
|
|
Bogdan Munteanu
|
Nov 7, 2011 - 4:47 PM
|
I apologize, I wasn’t clear… As a solution to a print preview where the contents exceeds the right side of the page, you sent me an email that read:
“You can limit the maximal cell width by invoking the ExtentSet( extent, 1 ) method of column header cell and specify __EGCS_EX_WRAP_TEXT extended cell style for all data cells.”
I am not sure how to set the maximal cell width of the column header of a property grid.
Thank you for your prompt response,
Bogdan
|
|
Technical Support
|
Oct 11, 2011 - 12:16 PM
|
Thank you for reporting this issue. To fix it, please update the source code for the following method:
CSize CExtGridCell::MeasureCell(
CExtGridWnd * pWndGrid, // can be NULL
CDC & dcMeasure,
LONG nVisibleColNo,
LONG nVisibleRowNo,
LONG nColNo,
LONG nRowNo,
INT nColType,
INT nRowType,
DWORD dwHelperPaintFlags
) const
{
__EXT_DEBUG_GRID_ASSERT_VALID( this );
__EXT_DEBUG_GRID_ASSERT( dcMeasure.GetSafeHdc() != NULL );
if( pWndGrid->GetSafeHwnd() == NULL )
pWndGrid = NULL;
DWORD dwCellStyle = GetStyle();
DWORD dwCellStyleEx = GetStyleEx();
// MEASURE ICON SIZE
CSize _sizeIcon = IconGetSize();
if( _sizeIcon.cx > 0 )
_sizeIcon.cx += 2;
// MEASURE EXISTING TEXT SIZE
UINT nDrawTextFlags = DT_LEFT|DT_TOP|DT_CALCRECT|DT_NOPREFIX;
CRect rcCellTextMeasured( 0, 0, 0, 0 );
if( (dwCellStyleEx&(__EGCS_EX_WRAP_TEXT|__EGCS_EX_MULTILINE_TEXT)) != 0L )
{
if( ( dwCellStyleEx & __EGCS_EX_WRAP_TEXT ) != 0L )
nDrawTextFlags |= DT_WORDBREAK;
if( pWndGrid != NULL )
{
INT nWidth = pWndGrid->OnSiwQueryItemExtentH( nColNo );
if( pWndGrid->GridLinesVertGet() )
nWidth --;
DWORD dwAreaFlags = CExtGridHitTestInfo::CellTypesToAreaFlags( nColType, nRowType );
CRect rcTextAreaMargins = OnQueryTextAreaMargins( *pWndGrid, dcMeasure, nVisibleColNo, nVisibleRowNo, nColNo, nRowNo, nColType, nRowType, dwAreaFlags, dwHelperPaintFlags );
nWidth -= rcTextAreaMargins.left + rcTextAreaMargins.right;
INT nHeight = 0; //pWndGrid->OnSiwQueryItemExtentV( nRowNo );
rcCellTextMeasured.SetRect( 0, 0, nWidth, nHeight );
}
}
else
nDrawTextFlags |= DT_SINGLELINE;
LPCTSTR strTextBuffer = LPCTSTR( GetTextBuffer() );
int nTextBufferLen =
( strTextBuffer != NULL )
? int(_tcslen(strTextBuffer))
: int(0);
HGDIOBJ hOldFont = NULL;
HFONT hCellFont = NULL;
bool bFontMustBeDestroyed = false;
if( pWndGrid != NULL )
{
hCellFont = OnQueryCellFont( *pWndGrid, nVisibleColNo, nVisibleRowNo, nColNo, nRowNo, nColType, nRowType, 0, bFontMustBeDestroyed, 0 );
if( hCellFont == NULL )
{
bFontMustBeDestroyed = false;
hCellFont = (HFONT)pWndGrid->OnSiwGetDefaultFont().GetSafeHandle();
}
if( hCellFont != NULL )
hOldFont = ::SelectObject( dcMeasure, (HGDIOBJ)hCellFont );
}
OnAdjustMeasureTextFlags( nDrawTextFlags, nVisibleColNo, nVisibleRowNo, nColNo, nRowNo, nColType, nRowType, 0 );
bool bTextIsMeasured = false;
if( nTextBufferLen > 0 )
{
CExtRichContentLayout::stat_DrawText(
dcMeasure.m_hDC,
strTextBuffer, nTextBufferLen,
(RECT *)&rcCellTextMeasured,
nDrawTextFlags, 0
);
bTextIsMeasured = true;
} // if( nTextBufferLen > 0 )
else
{
CExtSafeString strCopy;
TextGet( strCopy );
if( ! strCopy.IsEmpty() )
{
CExtRichContentLayout::stat_DrawText(
dcMeasure.m_hDC,
LPCTSTR( strCopy ), strCopy.GetLength(),
(RECT *)&rcCellTextMeasured,
nDrawTextFlags, 0
);
bTextIsMeasured = true;
} // if( ! strCopy.IsEmpty() )
} // else from if( nTextBufferLen > 0 )
if( !bTextIsMeasured )
rcCellTextMeasured = CRect( 0, 0, 0, 0 );
CRect rcCellTextMeasured2( 0, 0, 0, 0 );
static CExtSafeString g_sTestText( _T("AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789;[]{}\\/=+-_*&ˆ%$#@!~") );
CExtRichContentLayout::stat_DrawText(
dcMeasure.m_hDC,
LPCTSTR( g_sTestText ), g_sTestText.GetLength(),
(RECT *)&rcCellTextMeasured2,
nDrawTextFlags, 0
);
if( pWndGrid != NULL && hCellFont != NULL )
::SelectObject( dcMeasure, hOldFont );
if( bFontMustBeDestroyed && hCellFont != NULL )
::DeleteObject( hCellFont );
INT nAlignHeight = rcCellTextMeasured2.Height();
CSize _sizeText = rcCellTextMeasured.Size();
_sizeText.cy = max( _sizeText.cy, nAlignHeight );
if( _sizeText.cx > 0 )
_sizeText.cx += 4;
if( _sizeText.cy > 0 )
_sizeText.cy += 4;
if( pWndGrid != NULL )
{
CRect rcTextAreaMargins = OnQueryTextAreaMargins( *pWndGrid, dcMeasure, nVisibleColNo, nVisibleRowNo, nColNo, nRowNo, nColType, nRowType, 0, 0 );
_sizeText.cx += rcTextAreaMargins.left + rcTextAreaMargins.right;
_sizeText.cy += rcTextAreaMargins.top + rcTextAreaMargins.bottom;
}
else
{
if( _sizeIcon.cx > 0 )
_sizeText.cx += 4;
}
// MEASURE BUTTONS SIZE
CSize _sizeAllButtons( 0, 0 );
if( (dwCellStyle&(__EGCS_BUTTON_ELLIPSIS|__EGCS_BUTTON_DROPDOWN|__EGCS_BUTTON_UPDOWN)) != 0
&& ( pWndGrid == NULL
|| (pWndGrid->BseGetStyle()&__EGWS_BSE_BUTTONS_PERSISTENT) != 0
)
&& ( dwHelperPaintFlags & __EGCPF_SIMPLIFIED_RENDERING_TARGET ) == 0
)
{
CSize _sizeOneButton(
::GetSystemMetrics( SM_CXVSCROLL ),
::GetSystemMetrics( SM_CYHSCROLL )
);
if( (dwCellStyle&__EGCS_BUTTON_ELLIPSIS) != 0 )
{
_sizeAllButtons.cx += _sizeOneButton.cx;
_sizeAllButtons.cy = max( _sizeAllButtons.cy, _sizeOneButton.cx );
}
if( (dwCellStyle&__EGCS_BUTTON_DROPDOWN) != 0 )
{
_sizeAllButtons.cx += _sizeOneButton.cx;
_sizeAllButtons.cy = max( _sizeAllButtons.cy, _sizeOneButton.cx );
}
if( (dwCellStyle&__EGCS_BUTTON_UPDOWN) != 0 )
{
_sizeAllButtons.cx += _sizeOneButton.cx;
_sizeAllButtons.cy = max( _sizeAllButtons.cy, _sizeOneButton.cx );
}
}
// MEASURE CHECK/RADIO SIZE
CSize _sizeCheck( 0, 0 );
if( (dwCellStyle&__EGCS_CHK_MASK) != 0 )
{
if( pWndGrid != NULL )
_sizeCheck =
OnCalcCheckSize(
false, false, ( (dwCellStyle&__EGCS_READ_ONLY) == 0 ) ? true : false, *pWndGrid, dcMeasure,
nVisibleColNo, nVisibleRowNo, nColNo, nRowNo, nColType, nRowType, 0, 0
);
else
{
_sizeCheck.cx = 13;
_sizeCheck.cy = 13;
}
}
// MEASURE SORT ARROW SIZE
CSize _sizeSortArrow( 0, 0 );
if( (dwCellStyle&__EGCS_SORT_ARROW) != 0 )
{
_sizeSortArrow.cx = __EXT_SORT_ARROW_GLYPH_EXTENT_HORZ;
_sizeSortArrow.cy = __EXT_SORT_ARROW_GLYPH_EXTENT_VERT;
}
// MEASURE FOCUS ARROW SIZE
CSize _sizeFocusArrow( 0, 0 );
if( (dwCellStyle&(__EGCS_HDR_FOCUS_ARROW_RESERVE_SPACE|__EGCS_HDR_FOCUS_ARROW_DISPLAY)) != 0 )
{
_sizeFocusArrow.cx = __EXT_FOCUS_ARROW_GLYPH_EXTENT_HORZ;
_sizeFocusArrow.cy = __EXT_FOCUS_ARROW_GLYPH_EXTENT_VERT;
}
// MEASURE ENTIRE SIZE
CSize _sizeMeasured = _sizeIcon;
_sizeMeasured.cx += _sizeText.cx;
_sizeMeasured.cx += _sizeAllButtons.cx;
_sizeMeasured.cx += _sizeCheck.cx;
_sizeMeasured.cx += _sizeSortArrow.cx;
_sizeMeasured.cx += _sizeFocusArrow.cx;
_sizeMeasured.cy = max( _sizeMeasured.cy, _sizeText.cy );
_sizeMeasured.cy = max( _sizeMeasured.cy, _sizeAllButtons.cy );
_sizeMeasured.cy = max( _sizeMeasured.cy, _sizeCheck.cy );
_sizeMeasured.cy = max( _sizeMeasured.cy, _sizeSortArrow.cy );
_sizeMeasured.cy = max( _sizeMeasured.cy, _sizeFocusArrow.cy );
return _sizeMeasured;
}
|
|