Hi,
On 4/20/10 11:19 AM, eric b wrote:
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 ?
The item text is the text that can be drawn next to the button (try
Tools->Customize->Toolbars and change the "Toolbar" dropdown button to
"Icons&Text" to see how that looks like. You'd want the help text or
quickhelp text instead (which already gets set anyway).
Then you don't draw in the InsertItem* methods - or rather you cause an
update there, but there are different circumstances where you need to
paint that "target rectangle", basically whenever a paint event for that
occurs (think someone moves another window over your rectangle and it
gets hidden, then visible again).
However if I understand you correctly, that target rectangle would be
somewhere outside the toolbox, so it would be in a different window.
If I would have to implement this; I'd rather atach an event handler to
the toolbox in question (using the AddEventListener method) and listen
for events of type VCLEVENT_TOOLBOX_HIGHLIGHT to know when the user has
moved the pointer over a new item. You can then get the helptext for
that item from the toolbox and set it on a Control (e.g. a FixedText)
which does the text painting on its own.
To prevent the toolbox from still popping up its quick help window,
derive from the toolbox (you already have, your's is a DecoToolbox in
backingwindow.cxx) and implement
void RequestHelp( const HelpEvent& rHEvt ) {}
simply doing nothing so no help bubble gets shown.
Just my 2 cents, pl
--
"If the designers of X-window built cars, there would be no fewer than
five steering wheels hidden about the cockpit, none of which followed
the same principles -- but you'd be able to shift gears with your
car stereo. Useful feature, that."
-- From the programming notebooks of a heretic, 1990.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@gsl.openoffice.org
For additional commands, e-mail: dev-h...@gsl.openoffice.org