Hel^

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Hel^

eric b-3
Hello,

In the startCenter (modified backingwindow), I use a toolbox, and the  
following methods:

     maToolbox.InsertItem( nItemId_Draw, Image( aDrawHelpImage ) );
     maToolbox.SetItemText( nItemId_Draw, aDrawHelpText );
     maToolbox.ShowItem( nItemId_Draw );

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)


Thanks in advance,
Eric Bachard


--
qɔᴉɹə




Reply | Threaded
Open this post in threaded view
|

Re: Hel^

Philipp Lohmann
Hi,

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.

Kind regards, 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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: QuickHelpText and other methods

eric b-3
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 | Threaded
Open this post in threaded view
|

Re: QuickHelpText and other methods

Philipp Lohmann
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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: QuickHelpText and other methods

eric b-3
Hi Philipp,

Apologies for the long delay, but found no student to work on that, so I
  finaly did the work myself (last week).


Philipp Lohmann a écrit :

> The item text is the text that can be drawn next to the button (try

[...cut...]

> 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 thatoccurs (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.

Indeed. In the workwindow, itself using a DecoToolbox.


> 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.

Works perfectly, thanks a lot for your -one more time - golden advices :)

>
> 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 ) {}

Works perfectly either !


> simply doing nothing so no help bubble gets shown.


To share everything, I explained what i did on a wiki page (not up to
date, but I'll add new screenshots very soon)

The link : http://wiki.ooo4kids.org/index.php/NewStartCenterBehavior


Thank you very much, and Seasons Greatings :)
Eric

--
Education Project:
http://wiki.services.openoffice.org/wiki/Education_Project
Projet OOo4Kids : http://wiki.ooo4kids.org/index.php/Main_Page
L'association EducOOo : http://www.educoo.org
Blog : http://eric.bachard.org/news

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]