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 » Can I use Prof-UIS to skin just the menu bar without skinning other controls? Collapse All
Subject Author Date
Connie Lam May 3, 2007 - 7:45 PM

Hello,

Can I use Prof-UIS to skin just the menu bar of my application without skinning other controls? If so, will the other controls use the default system skin?

Thank you!

Technical Support May 4, 2007 - 8:03 AM

Most of the Prof-UIS components are derived from the CExtPmBridge class and there is a CExtPmBridge::PmBridge_GetPM() virtual method which returns a pointer to the paint manager object for painting this or that part of a control. By default, CExtPmBridge::PmBridge_GetPM() returns a pointer to the global paint manager. You could create a custom class derived from CExtMenuControlBar that implements PmBridge_GetPM(). In this method, just return the desired paint manager.

Technical Support May 4, 2007 - 8:49 AM

Here is a ready-to-use solution. The CExtPaintManagerCustomT template is designed to add the custom paint manager capabilities to any Prof-UIS control. Just wrap the class with this template and then use the SetCustomPM method:

CExtPaintManagerCustomT < CExtMenuControlBar > m_wndMenuBar;
m_wndMenuBar.SetCustomPM( RUNTIME_CLASS( CExtPaintManagerXXXX ) );
Here is the template:
//////////////////////////////////////////////////////////////////////////
// template CExtPaintManagerCustomT

template < class _BT > 
class CExtPaintManagerCustomT : public _BT
{
public:
    CExtPaintManagerCustomT(
        CExtPaintManager * pCustomPM = NULL 
        )
        : m_pCustomPM( NULL )
    {
        SetCustomPM( pCustomPM );
    }
    ~CExtPaintManagerCustomT()
    {
        if( m_pCustomPM != NULL )
            delete m_pCustomPM;
        m_pCustomPM = NULL;
    }
    CExtPaintManager * GetCustomPM() const
    {
        return m_pCustomPM;
    }
    bool SetCustomPM( 
        CExtPaintManager * pCustomPM = NULL 
        )
    {
        if( m_pCustomPM != NULL )
        {
            if( pCustomPM == m_pCustomPM )
                return false;
            if( m_pCustomPM != NULL )
            {
                delete m_pCustomPM;
                m_pCustomPM = NULL;
            }
        }
        if( pCustomPM == NULL )
        {
            m_pCustomPM = new __DEFAULT_PAINT_MANAGER_CLASS;
            if(    ! m_pCustomPM->IsKindOf( RUNTIME_CLASS( CExtPaintManager ) ) )
            {
                ASSERT( FALSE );
                return false;
            }
        }
        else
        {
            m_pCustomPM = pCustomPM;
        }
        m_pCustomPM->SyncSysColors();
        m_pCustomPM->InitTranslatedColors();
        m_pCustomPM->InitHelperBrushes();
        return true;
    }
    
    bool SetCustomPM(
        CRuntimeClass * pRTCCustomPM
        )
    {
        if( pRTCCustomPM == NULL )
            return SetCustomPM( (CExtPaintManager *)NULL );
        CObject * pObj = pRTCCustomPM->CreateObject();
        if( pObj == NULL )
        {
            ASSERT( FALSE );
            return false;
        }
        ASSERT_VALID( pObj );
        CExtPaintManager * pPaintManager = DYNAMIC_DOWNCAST( CExtPaintManager, pObj );
        if( pPaintManager == NULL )
        {
            delete pObj;
            ASSERT( FALSE );
            return false;
        }
        return SetCustomPM( pPaintManager );
    }

    virtual CExtPaintManager * PmBridge_GetPM() const
    {
        CExtPaintManager * pPM = GetCustomPM();
        if( pPM != NULL )
            return pPM;
        else
            return _BT::PmBridge_GetPM();
    }

protected:
    CExtPaintManager * m_pCustomPM;
};

Connie Lam May 4, 2007 - 1:33 PM

I have a Java application built using the Eclipse framework (Eclipse uses Standard Widget Toolkit which is basically a Java wrapper of Win32 controls on the Windows platform). If I have the handles of the windows created by Eclipse, is it possible for me to "attach" a skin to the menu bar created by Eclipse, e.g., through JNI code?

Thanks a lot!

Technical Support May 5, 2007 - 4:36 AM

We believe it’s possible to code everything and mix any technologies with each other but when mixing MFC and Java, you will certainly take much time and effort. It is possible to subclass a window handle created by Java with an MFC class implemented in Prof-UIS. But this works only with simple controls like a button or a combo box. More complex UI components like control bars or grids are implemented as component systems containing many sub components which can be based on window handles or they are C++ objects without any handles. It’s unreasonably hard to inject complex MFC/Prof-UIS components into Java environments. Besides, Java controls may contain UI items without handles inside one popup window on the desktop what makes it impossible to attach Prof-UIS controls to them.