Le 12 avr. 10 à 13:55, Philipp Lohmann a écrit :

Hi,


Hi Philipp,


First, sorry for the delay, and the dumb title ... I modified it, say, more accurately


On 4/2/10 6:37 PM, eric b wrote:
Doing that, I can display a help string when the mouse cursor rolls over
application icons. That's nice, but I'd like to display the text in a
given area, and I don't find a method doing that (at least in toolbox.hxx).

Is there one I missed, or, shall I implement a new one, passing a given
rectangle as argument (e.g.) ? (I'll reverse the code, of course)

no, there is no such method.



Ok, then in the Toolbox class, I found a SetItemText method, currently :

{
        USHORT nPos = GetItemPos( nItemId );

        if ( nPos != TOOLBOX_ITEM_NOTFOUND )
        {
                ImplToolItem* pItem = &mpData->m_aItems[nPos];
                // Nur wenn alles berechnet ist, mehr Aufwand treiben
                if ( !mbCalc &&
                         ((meButtonType != BUTTON_SYMBOL) || !pItem->maImage) )
                {
                        long nOldWidth = GetCtrlTextWidth( pItem->maText );
                        pItem->maText = ImplConvertMenuString( rText );
            mpData->ImplClearLayoutData();
                        if ( nOldWidth != GetCtrlTextWidth( pItem->maText ) )
                                ImplInvalidate( TRUE );
                        else
                                ImplUpdateItem( nPos );
                }
                else
                        pItem->maText = ImplConvertMenuString( rText );

        // Notify button changed event to prepare accessibility bridge
ImplCallEventListeners( VCLEVENT_TOOLBOX_BUTTONSTATECHANGED, reinterpret_cast< void* >( nPos ) );

        // Notify
ImplCallEventListeners( VCLEVENT_TOOLBOX_ITEMTEXTCHANGED, reinterpret_cast< void* >( nPos ) );
        }
}


The idea consist in an overloaded Toolbox::SetItemText() with a new itemId, linked to the rectangle where we'd like to draw the help text. e.g. add :

void ToolBox::SetItemText( USHORT nItemId, const XubString& rText, USHORT nTargetRectItemId )
{
        /* inside the method, do :

1) get the nPos of the first itemId: USHORT nPos = GetItemPos ( nItemId );

        2) Verify the itemId is valid

        if ( nPos != TOOLBOX_ITEM_NOTFOUND )
        {
          // do the right work
        }
        else do nothing

        3) if nPos does match with a valid item,

create the pItem as previously : ImplToolItem* pItem = &mpData- >m_aItems[nPos];

        4) do the same job with the text (like in the not overloaded method)

        5) get the nPosTargetRect of the target rectangle

6) if ok, ImplUpdateItem( nPosTargetRect ); // nPosTargetRect is a fixed value

This is the idea: draw the text at the right location (the target rectangle for instance)


        7) .. and so on for the rest (like in the not overloaded method)

        }


        */

The counterpart is, the nTargetRectItemId must be defined, and its location defined too.

What do you think ?


Thanks,
Eric

--
qɔᴉɹə




Reply via email to