Print Page | Close Window

CXTPPropertyGridItem colors

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Property Grid
Forum Description: Topics Related to Codejock Property Grid
URL: http://forum.codejock.com/forum_posts.asp?TID=2213
Printed Date: 14 May 2024 at 5:14am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: CXTPPropertyGridItem colors
Posted By: hpesata
Subject: CXTPPropertyGridItem colors
Date Posted: 12 May 2005 at 5:55am
Hi!

XTP 9601

I need to set different for/background-colors for different property-grid-items.
CXTPPropertyGrid::SetCustomColors() just enables me to change the color for ALL items.

A similar function like CXTListBase::SetRowColor() would be what I need,
something like pItem->SetColor(clrFore, clrBack).

are there any plans on including this functionality in future versions ?
I saw several requestes on this topic in the forum.

thanx in advance!

regards,
Hans




Replies:
Posted By: Oleg
Date Posted: 12 May 2005 at 3:44pm

Yes, we have this in our TODO list for 10.0 release.

Thank  you.



-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Kevin6
Date Posted: 13 May 2005 at 7:37am

I also have this problem. Is there a work around for now that you can suggest?

(Also when is the planned release date for 10.0?)

Regards,

Kevin.

 



-------------
Kevin.


Posted By: Oleg
Date Posted: 13 May 2005 at 8:12am

You can:

1. Create custom item inherited from CXTPPropertyGridItem

2. Override OnDrawItemValue

 

or

 

1 Create custom pain manager inherited from CXTPPropertyGridPaintManager

2. Override void DrawItem(PDRAWITEMSTRUCT lpDrawItemStruct)



-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Kevin6
Date Posted: 13 May 2005 at 8:16am

Thanks Oleg, but you avoided my other question!

I have quite a large application to write and could leave the colouring for now and come back to it later. But I would need to know if 10.0 was 3, 6, 12+ months away. Just a general idea would do.

Regards,

Kevin.

 

 

 



-------------
Kevin.


Posted By: Oleg
Date Posted: 13 May 2005 at 3:18pm
In Summer :)

-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Kevin6
Date Posted: 17 May 2005 at 10:19am

Thanks, that good enough for me!

Regards,

Kevin.

 



-------------
Kevin.


Posted By: CGrant
Date Posted: 30 May 2005 at 8:59am
Originally posted by oleg oleg wrote:

You can:

1. Create custom item inherited from CXTPPropertyGridItem

2. Override OnDrawItemValue

I'd also like to see a sinple way to set the background color, but the suggestion worked for me. In my case I wanted a simple valid / invalid coloring of items (numeric items outside a min to max range)

I always find code examples handy; so I have a class dervied from the ...GridItemNumber that adds range checking by looking at the ::SetValue string to set bool m_valid. The draw override uses it like this:

BOOL RangeCheckedGridItemNumber::OnDrawItemValue(CDC& dc, CRect rcValue)
{
 if (!m_valid)
 {
  // Highlight in red for invalid items
  CBrush red(RGB(255,128,128));
  dc.FillRect(rcValue, &red);
 }

 return CXTPPropertyGridItemNumber::OnDrawItemValue(dc, rcValue);
}

Keep up the good work

Colin



Posted By: hpesata
Date Posted: 31 May 2005 at 3:16am
Hi Colin!

thanx for your hint!

I am lookong for a way to also color the item-caption, not only the value.
Do You have any idea on how to do that ?

thanx in advance!

regards,
Hans



Posted By: CGrant
Date Posted: 01 June 2005 at 8:02pm

Originally posted by hpesata hpesata wrote:


I am looking for a way to also color the item-caption, not only the value.
Do You have any idea on how to do that ?

I had hoped it would be easy but I haven't exactly managed it. The closest I could get involved my own class derived from CXTPPropertyGridPaintManager


class CColorItemPaintManager : public CXTPPropertyGridPaintManager
{
public:
    CColorItemPaintManager(CXTPPropertyGrid* pGrid);
    virtual ~CColorItemPaintManager();
    virtual void DrawItem(PDRAWITEMSTRUCT lpDrawItemStruct);
};

which I set in to the property grid when I created it


if ( m_wndPropertyGrid.Create( rc, this, IDC_PROPERTY_GRID ) )
{
    m_pPaintManager = new CColorItemPaintManager(&m_wndPropertyGrid);
    m_wndPropertyGrid.SetCustomTheme(m_pPaintManager);

and then, as an example, override DrawItem to splat red down on the selected row.


void CColorItemPaintManager::DrawItem(PDRAWITEMSTRUCT lpDrawItemStruct)
{
    if (ODS_SELECTED == (ODS_SELECTED & lpDrawItemStruct->itemState))
    {
        CRect rc = lpDrawItemStruct->rcItem;
        CDC dc;
        dc.Attach(lpDrawItemStruct->hDC);
        dc.FillSolidRect(rc, RGB(255,0,0));
        dc.Detach();
    }
    else
    {
        CXTPPropertyGridPaintManager::DrawItem(lpDrawItemStruct);
    }
}

The grid item value is still getting painted nicely but the caption is just a solid red rectangle. Filling it in nicely needs a fair bit more work - see Samples\PropertyGrid\OwnerDraw\SimpleGridPage.cpp for its DrawItem code.

Good luck!

Colin

 



Posted By: hpesata
Date Posted: 02 June 2005 at 3:30am
Hi Colin!

Thanx a lot for your detailled support!

regards,
Hans



Posted By: CGrant
Date Posted: 07 June 2005 at 7:48pm

Now that I've coughed up the price of the MFC version of PropertyGrid I've got the sources , so I've revisited it to see if it would be easy enough to change the base class to get grid items coloured.

I fell foul of include ordering so I opted for this slightly odd approach: I added a virtual method to the class CXTPPropertyGridItem to get the background colour for that item.


virtual void GetBackgroundColour(COLORREF & clr) { }

and changed the CXTPPropertyGridPaintManager::DrawItem to use that colour


    COLORREF clrWindow = pView->m_clrBack;   <-- existing line
    pItem->GetBackgroundColour(clrWindow);    <--- added line

That meant that nothing changed until I had my own class RangeCheckedGridItemNumber derived CXTPPropertyGridItemNumber from that overrode the  mehtod


void RangeCheckedGridItemNumber::GetBackgroundColour(COLORREF & clr)
{
    clr = RGB(0,255,0);  // very green
}

Obviously you can have any logic you like in your method. I quite like the solution since it is a minimal change, but it does change the library; I hope the next release will have its own SetBackgroundColor() method instead

Colin




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