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 Tech Support » Putting multiple icons in report grid cell Collapse All
Subject Author Date
Eric Houvenaghel Jun 11, 2009 - 1:51 PM

Hi, I am using the report grid.


Is there a way to put several icons in a grid cell.


The only way I know at this time is using SetImageList and IconIndexSet.


But this allows only one icon to be set in the cell.


The only way I can think of is using a new column for each icon.


I’d like to avoid that if I can.


Let  me know.


Thanks.

Technical Support Jun 12, 2009 - 1:42 PM

The CExtCmdIcon class is implemented as a container for these four CExtBitmap properties: m_bmpNormal, m_bmpDisabled, m_bmpHover and m_bmpPressed. In the most cases, the m_bmpNormal is used only as a bitmap. Your icons are 4 BPP. This means the icon data contains two bitmaps: the 4BPP color surface bitmap and 1 BPP mask surface bitmap. But the m_bmpNormal property is the single CExtBitmap object. Prof-UIS converts any icons into 32 BPP CExtBitmap objects with alpha channel. So, you should be able to scale CExtCmdIcon and CExtBitmap objects. But there is a special case: your icon is 4 BPP and does not have transparent pixels and mask surface. This case is very rarely occur in the real life. This means the m_bmpNormal property contains 4 BPP bitmap surface. You should invoke the CExtBitmap::Make32() method to make it 32 BPP before scaling.

Eric Houvenaghel Jun 12, 2009 - 11:51 AM

Nervermind, I got it.


I wasn’t loading the icon properly.


Was using:



    CExtCmdIcon Icon;

    Icon.m_bmpNormal.LoadBMP_Resource(MAKEINTRESOURCE(IDB_BITMAP1));

    GridIconInsert(&Icon);



Now using:



    //

    CExtCmdIcon Icon;

    CBitmap Bitmap;



    // TESTING

    Bitmap.LoadBitmap(IDB_BITMAP1);

    Icon.AssignFromHBITMAP(Bitmap);

    GridIconInsert(&Icon);

Technical Support Jun 12, 2009 - 5:54 AM

How would you like to display several icons in a grid cell? Next to each other and to the left of the cell’s text? Which cell classes should display more than one icon? If a grid cell has 3 icons, how much icons other cells in the same row and/or column should have?

Having more than one icon in a grid cell is a task which is not related to the report grid. It’s related to grid cells in any grid. By default the grid cells keep icon indices referring to the icon objects stored in the data provider inside the grid control. But this is not the limitation. Here is a color picker grid cell:



And here is a font face name picker grid cell:



These grid cells do not display icons. The color picker cell displays a box which is a color preview. The font face name picker cell displays a box which is a font preview. Both box areas are icons. These icons are not related to the grid controls and their data providers. These icons are generated on the fly and they can have any size. It’s possible to generate similar icons which will have, for instance, 16 pixels height and some 16 x count of displayed real icons width. The grid classes and grid cell classes are ready for this trick. The implementation of this trick is very simple. The CExtGridCell::IconGetSize() virtual method is used to get the size of the icon area inside any grid cell. The CExtGridCell::OnPaintIcon() virtual method is invoked to paint icon area part of any grid cell. These two virtual methods do all the work related to the icon area part of any grid cell. Overriding of these two virtual methods allow to draw anything inside grid cell instead of supported by default cell icon. By default, these two methods are operating with the icon object returned by the CExtGridCell::IconGet() virtual method. The last method just returns icon stored inside the data provider icon collection using the in-cell stored icon index returned by the CExtGridCell::IconIndexGet() virtual method. So, by overriding the only one CExtGridCell::IconGet() virtual method you can code grid cells generating their icon images on-the-fly. Some of Prof-UIS grid cells, including meant above, are using these tricks to display what they need instead of icons.

In conclusion, the multi-icon grid cell can be coded as small template class which implements the CExtGridCell::IconGetSize() and CExtGridCell::OnPaintIcon() virtual methods. But we need more details about your task. Do you need just several icons inside some or all of grid cells and these icons should be displayed near each other? Or do you have to tell us some more interesting details?

Eric Houvenaghel Jun 12, 2009 - 10:36 AM

OK, I am in the process of using your suggested method for manipulating grid cell icons.

I am having one problem.

Some of the icons I have are to big for the height of the cell.

Please note that row height is constant in our implementation of the report gird.

However, I am not able to scale the icons using CExtCmdIcon::Scale.

This is because of following if statement in CExtBitmap::Scale:

   

    if(IsEmpty() ||    nWidth <= 0 ||    nHeight <= 0 ||    GetBPP() < 16)

        return false;



For the icon I’m using, GetBPP() = 4 (16 colour).

A regular VC++ resource icon.

If I don’t scale the icon, it will spill over into the row below.

Anyway to get around that?