Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Report Control
  New Posts New Posts RSS Feed - [solved] Set smoothing mode for markup cell
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

[solved] Set smoothing mode for markup cell

 Post Reply Post Reply
Author
Message
adrien View Drop Down
Senior Member
Senior Member


Joined: 30 April 2007
Location: New Zealand
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote adrien Quote  Post ReplyReply Direct Link To This Post Topic: [solved] Set smoothing mode for markup cell
    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
Back to Top
adrien View Drop Down
Senior Member
Senior Member


Joined: 30 April 2007
Location: New Zealand
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote adrien Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
adrien View Drop Down
Senior Member
Senior Member


Joined: 30 April 2007
Location: New Zealand
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote adrien Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote olebed Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
adrien View Drop Down
Senior Member
Senior Member


Joined: 30 April 2007
Location: New Zealand
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote adrien Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
adrien View Drop Down
Senior Member
Senior Member


Joined: 30 April 2007
Location: New Zealand
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote adrien Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
adrien View Drop Down
Senior Member
Senior Member


Joined: 30 April 2007
Location: New Zealand
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote adrien Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
adrien View Drop Down
Senior Member
Senior Member


Joined: 30 April 2007
Location: New Zealand
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote adrien Quote  Post ReplyReply Direct Link To This Post 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.


Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote olebed Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote olebed Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote olebed Quote  Post ReplyReply Direct Link To This Post 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();
    }
}
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.141 seconds.