Print Page | Close Window

[solved] Set smoothing mode for markup cell

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Report Control
Forum Description: Topics Related to Codejock Report Control
URL: http://forum.codejock.com/forum_posts.asp?TID=23461
Printed Date: 14 May 2024 at 2:32pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: [solved] Set smoothing mode for markup cell
Posted By: adrien
Subject: [solved] Set smoothing mode for markup cell
Date Posted: 09 October 2017 at 6:44pm
Hi

Is it possible to set text smoothing mode for a report control cell?

I've been searching for a long time, and tried using markup attributes in the markup itself (doesn't work).

I don't want to have to override OnPaint to set the mode on the DC, surely there should be a way when you set up a markup context to give it information about how you want it to draw, and it pass it to the DC?

Adrien


-------------
http://www.wingate.com - http://www.wingate.com



Replies:
Posted By: adrien
Date Posted: 09 October 2017 at 6:48pm
P.S. I want to do this because the default text rendering is very ugly and jaggy.

I'm quite disappointed that the default isn't to use a decent text rendering mode.  I can't imagine anyone ever wants their text to look unaliased.


-------------
http://www.wingate.com - http://www.wingate.com


Posted By: adrien
Date Posted: 09 October 2017 at 6:52pm
CXTPMarkupDrawingContext constructor (all of them) set 

m_bUseTextSmooting(FALSE)

are you kidding me?

You need to make this accessible via the markup context so we can turn it on without patching your code.


-------------
http://www.wingate.com - http://www.wingate.com


Posted By: olebed
Date Posted: 11 October 2017 at 8:27am
Hello adrien,

You can see how it works in our sample  Samples\Utilities\MarkupPad\MarkupPadView.cpp
void CMarkupPadView::OnPaint() 
{
    CPaintDC dc(this); // device context for painting
    
    CXTPClientRect rc(this);

    CXTPBufferDC dcMem(dc);
    dcMem.FillSolidRect(rc, GetSysColor(COLOR_WINDOW));

    CXTPMarkupDrawingContext dcMarkup(this, dcMem);
    dcMarkup.SetSmoothingMode(GetDocument()->GetSmoothingMode(), GetDocument()->IsTextSmooting());
    DrawMarkup(&dcMarkup, rc);
}

Regards,
 Oleksandr Lebed


Posted By: adrien
Date Posted: 17 October 2017 at 7:54pm
Hi

the problem with this is that means I need to override OnPaint.

We don't currently do that.  It should be possible to set smoothing without having to override OnPaint


-------------
http://www.wingate.com - http://www.wingate.com


Posted By: adrien
Date Posted: 17 October 2017 at 9:48pm
Also, that's for a markup pad view, which is your own class.

I need to get this into a report control.  If I override OnPaint for CXTPReportControl I have to do a LOT of copy / paste figure out how to make it a different kind of device context (e.g. CPaintDC becomes CXTPMarkupDrawingContext etc).

This is just error prone.  It would be very simple since you allow setting a report control to use markup if you would allow the natural extensions of that, e.g. set smoothing.

Either that or fix the broken support for the XAML font quality attributes so they actually work.

If Paint() were virtual I could override it.


-------------
http://www.wingate.com - http://www.wingate.com


Posted By: adrien
Date Posted: 17 October 2017 at 9:54pm
guess not, since CXTPMarkupDrawingContext doesn't derive from CDC I can't pass it into Paint.

Looks like I need to patch your DLL.


-------------
http://www.wingate.com - http://www.wingate.com


Posted By: adrien
Date Posted: 17 October 2017 at 10:39pm
OK, I've spent now about a day on this.

It looks like fundamentally the report control does not support smooth text in report controls.

The CXTPMarkupUIElement class has no attribute to remember text smoothing (or any smoothing)

for markup report row items rendering comes down to 

CXTPReportRecordItem::OnDrawCaption

this calls 

XTPMarkupMeasureElement(m_pMarkupUIElement, rcItem.Width(), INT_MAX);
XTPMarkupRenderElement(m_pMarkupUIElement, pDrawArgs->pDC->GetSafeHdc(), &rcItem);

There's no opportunity to set any features on the markup DC

I guess I could override  CXTPReportRecordItem::OnDrawCaption

but Thats way too much work for such a simple task.

If I'm missing something (apart from a sense of humour) please can you tell me how I can get smooth text in a derived report control class which uses markup.




-------------
http://www.wingate.com - http://www.wingate.com


Posted By: olebed
Date Posted: 18 October 2017 at 4:20am
Hello adrien,

Yes there is a really problem.  I have confused CXTPMarkupDrawingContext and CXTPMarkupContext.  CXTPMarkupDrawingContext is created temporary on every measuring or drawing of ReportItems with markup.

So I think good solution will be setting this smoothing option to CXTPMarkupContext which more public than CXTPMarkupDrawingContext. Then every time on creating CXTPMarkupDrawingContext the smoothing option will be copied from CXTPMarkupContext.

Thank you for bringing this to our attention.

Regards,
 Oleksandr Lebed


Posted By: olebed
Date Posted: 05 December 2017 at 4:28am
The issue have been fixed by adding public methods to CXTPMarkupContext
CXTPMarkupContext::SetDefaultSmoothingMode
CXTPMarkupContext::GetDefaultSmoothingMode

CXTPMarkupContext::SetDefaultTextSmoothing
CXTPMarkupContext::GetDefaultTextSmoothing

Fix will be available in next release.


Posted By: olebed
Date Posted: 05 December 2017 at 7:45pm
Using in ReportSample:
void CReportSampleView::OnReportMarkup()
{
    CXTPMarkupContext* pMarkupContext = GetReportCtrl().GetMarkupContext();
    BOOL bEnabled = pMarkupContext != NULL;
    
    bEnabled = !bEnabled; // enable ALL

    GetReportCtrl().EnableMarkup(bEnabled);
    
    if (pMarkupContext)
    {
        pMarkupContext->SetDefaultSmoothingMode(xtpMarkupSmoothingHighQuality);
        pMarkupContext->SetDefaultTextSmoothing(TRUE);

        GetReportCtrl().GetColumns()->GetAt(COLUMN_SUBJECT)->SetCaption(cstrMarkupShortSample);
        GetReportCtrl().GetRecords()->GetAt(9)->GetItem(COLUMN_SUBJECT)->SetCaption(cstrMarkupShortSample);
        GetReportCtrl().GetRecords()->GetAt(9)->GetItemPreview()->SetCaption(cstrMarkupLongSample);        
        GetReportCtrl().RedrawControl();
    }
    else
    {
        GetReportCtrl().GetColumns()->GetAt(COLUMN_SUBJECT)->SetCaption(_T("Subject"));
        GetReportCtrl().GetRecords()->GetAt(9)->GetItem(COLUMN_SUBJECT)->SetCaption(_T("[Codejock] Newsletter"));
        GetReportCtrl().GetRecords()->GetAt(9)->GetItemPreview()->SetCaption(_T("An in-between week here at Codejock. VSLive was last week, TechEd is in a couple of weeks; Last month's article winners have been awarded and this month's voting is just starting; Last week was Winter and this week is forecast to be Summer. It makes a developer want to just kick back and crank some code right? Right?"));        
        GetReportCtrl().RedrawControl();
    }
}



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net