Professional UI Solutions
Site Map   /  Register
 
 

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.

Forums » Prof-UIS General Discussion » Custom paint in GridCell Collapse All
Subject Author Date
Eugen Rata Jul 14, 2009 - 2:49 PM

Hi

I’m wondering if you’ve got a CellType that would expose its CDC object or maybe an OnPaint event where I can paint myself some GDI objects.
If not, what would be the easiest way to paint myself some rectangle and ellipses inside a specified cell?

Thx

Technical Support Jul 16, 2009 - 12:59 PM

We created a small test project, which demonstrates how to code a simple custom drawn grid cell.

Eugen Rata Jul 16, 2009 - 5:17 PM

Just perfect guys. Thx so much!

Technical Support Jul 15, 2009 - 1:33 PM

Any CExtGridCell grid cell consists of the following parts, which are enumerated from left to right looking at layout of any grid cell:

- Icon. Optional part. It’s absent if the CExtGridCell::IconGet() method returns NULL. The CExtGridCell::OnPaintIcon() virtual method draws this part.

- Check box or radio button. Optional part. It’s present if the __EGCS_CHK_CHECK, __EGCS_CHK_RADIO or __EGCS_CHK_INDETERMINATE grid cell styles are applied. The CExtGridCell::OnPaintCheck() virtual method draws this part.

- Text. Always present part of grid cell until the CExtGridCell::TextGet() method returns empty text. The CExtGridCell::OnPaintText() virtual methods draws this part.

- Rest area. Always present part of grid cell until there is a free space between text and cell buttons. The CExtGridCell::OnPaintRestArea() virtual method draws this part.

- Up-down button. Optional part. It’s present if the __EGCS_BUTTON_UPDOWN grid cell style are applied. The CExtGridCell::OnPaintButton() virtual methods draw this part.

- Drop down button. Optional part. It’s present if the __EGCS_BUTTON_DROPDOWN grid cell style are applied. The CExtGridCell::OnPaintButton() virtual method draws this part.

- Ellipsis button. Optional part. It’s present if the __EGCS_BUTTON_ELLIPSIS grid cell style are applied. The CExtGridCell::OnPaintButton() virtual methods draw this part.

This is how you can repaint any part of any grid cell. For example, the CExtGridCellInplaceSlider::OnPaintRestArea virtual method in the CExtGridCellInplaceSlider grid cell draw the slider or scroll bar like looking control on the surface of the grid cell. Another example, the CExtGridCellPictureBase::OnPaintText() virtual method draws image instead of the text part of grid cell in all the picture grid cell classes.

If you don’t need to improve any of existing grid cell classes, then you can re-draw entire grid cell surface. All the grid cells are painted in two steps. The CExtGridCell::OnPaintBackground() virtual method is invoked first and it draws background of the grid cell. This method is responsible for highlighting selected cells. Then the CExtGridCell::OnPaintForeground() virtual method is invoked for painting all the built-in grid cell parts meant above. You can override the CExtGridCell::OnPaintForeground() virtual method for painting anything instead of default looking grid cell. You can use preliminary drawn cell background or over fill it with anything you need. The completely re-painted grid cell may require to implement other features. You may need to implement cell measuring (the CExtGridCell::OnMeasure***() virtual methods) because they needed for best fitting of grid columns/row which is typically performed on double click over column/row header separators. You may need the grid cell serialization and assignment (the CExtGridCell::Serialize() and CExtGridCell::Serialize() virtual methods) if your grid cell should support copying, pasting and drag-n-dropping. You may need comparison (the CExtGridCell::Compare() virtual method) if your grid cell will be used in sort-able and filter-able grid columns and/or rows. You may need to handle mouse and keyboard events (the CExtGridCell::OnClick(), CExtGridCell::OnHover(), CExtGridCell::OnKey() and CExtGridCell::OnSysKey() virtual methods) if your grid cell should support input. So, if you have any details about your task, then we are ready to discuss them.

Eugen Rata Jul 15, 2009 - 2:12 PM

Hi

Thx for all this info. That’s of course very nice of you to provide such a detailed help, but being a practical person I was expecting to see a small sample that does what I need. :)

Well anyway, i tried some things, I overrode OnPaintBackground, it works fine, I can paint my rectangle, but the picture is gone when cell is selected. What flags shall I check / use in order to make achieve a correct behavior?
Or is better do not touch OnPaintBackground and use OnPaintText instead?
Which way would you go?

Thx