FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour RibbonBar
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM

RibbonBar

Posted: Fri May 31, 2013 10:49 AM
Dear friends, I'm trying to use the ribbonbar. First problem: why the buttons in the second tab are taller than the ones in the first tab? What I would want to achieve is a series of toolbars switched by tabs.

Code (fw): Select all Collapse
#include "Fivewin.ch"
#include "Ribbon.ch"


FUNCTION MAIN()

    LOCAL oDlg

    DEFINE DIALOG oDlg;
           SIZE 800, 600

    ACTIVATE DIALOG oDlg;
             ON INIT MAKERIBBON( oDlg );
             CENTER

    RETURN NIL


STATIC FUNCTION MAKERIBBON( oDlg )

    LOCAL oRib

    LOCAL oGr1, oGr2, oGr3, oGr4

    LOCAL oMn1

    MENU oMn1 POPUP
        MENUITEM "Test 1" ACTION MSGINFO( "Test 1" )
        MENUITEM "Test 2" ACTION MSGINFO( "Test 2" )
        MENUITEM "Test 3" ACTION MSGINFO( "Test 3" )
    ENDMENU

    DEFINE RIBBONBAR oRib OF oDlg;
           PROMPT "Test 1", "Test 2", "Test 3"

    oRib:SetSize( oDlg:nWidth, 100 )

    ADD GROUP oGr1 RIBBONBAR oRib;
              WIDTH 80;
              TO OPTION 1;

    @ 4, 4 ADD BUTTON GROUP oGr1;
           SIZE oGr1:nWidth - 9, oGr1:nHeight - 7;
           PROMPT "Test 1";
           BITMAP "OPEN.BMP";
           ACTION MSGINFO( "Test 1" )

    ADD GROUP oGr2 RIBBONBAR oRib;
              WIDTH 80;
              TO OPTION 1;

    @ 4, 4 ADD BUTTON GROUP oGr2;
           SIZE oGr2:nWidth - 9, oGr2:nHeight - 7;
           PROMPT "Test 2";
           BITMAP "OPEN.BMP";
           ACTION MSGINFO( "Test 2" );
           POPUP MENU oMn1

    ADD GROUP oGr3 RIBBONBAR oRib;
              WIDTH 80;
              TO OPTION 2;

    @ 4, 4 ADD BUTTON GROUP oGr3;
           SIZE oGr3:nWidth - 9, oGr3:nHeight - 7;
           PROMPT "Test 3";
           BITMAP "OPEN.BMP";
           ACTION MSGINFO( "Test 3" )

    ADD GROUP oGr4 RIBBONBAR oRib;
              WIDTH 80;
              TO OPTION 2;

    @ 4, 4 ADD BUTTON GROUP oGr4;
           SIZE oGr4:nWidth - 9, oGr4:nHeight - 7;
           PROMPT "Test 4";
           BITMAP "OPEN.BMP";
           ACTION MSGINFO( "Test 4" );
           POPUP MENU oMn1

    RETURN NIL


EMG
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM

Re: RibbonBar

Posted: Fri May 31, 2013 11:10 AM
First problem solved:

Code (fw): Select all Collapse
    DEFINE RIBBONBAR oRib OF oDlg;
           HEIGHT 100;
           PROMPT "Test 1", "Test 2", "Test 3"

    oRib:SetSize( oDlg:nWidth )


:-)

EMG
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM

Re: RibbonBar

Posted: Fri May 31, 2013 11:14 AM

Second problem: open the button menu and select an option, you will get a message. Then try doing the same once more. The menu will not popup. Retry and the menu will popup again. It shows only on the click number 1, 3, 5, and so on. Why?

EMG

Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM

Re: RibbonBar

Posted: Fri May 31, 2013 11:22 AM
Third problem: in the following sample, try to click on the fourth menu popup item (Test 4, the one withou action clause). The button will remain selected (ie. a lighter color).

Code (fw): Select all Collapse
#include "Fivewin.ch"
#include "Ribbon.ch"


FUNCTION MAIN()

    LOCAL oDlg

    DEFINE DIALOG oDlg;
           SIZE 800, 600

    ACTIVATE DIALOG oDlg;
             ON INIT MAKERIBBON( oDlg );
             CENTER

    RETURN NIL


STATIC FUNCTION MAKERIBBON( oDlg )

    LOCAL oRib

    LOCAL oGr1, oGr2, oGr3, oGr4

    LOCAL oMn1

    MENU oMn1 POPUP
        MENUITEM "Test 1" ACTION MSGINFO( "Test 1" )
        MENUITEM "Test 2" ACTION MSGINFO( "Test 2" )
        MENUITEM "Test 3" ACTION MSGINFO( "Test 3" )
        MENUITEM "Test 4"
    ENDMENU

    DEFINE RIBBONBAR oRib OF oDlg;
           HEIGHT 100;
           PROMPT "Test 1", "Test 2", "Test 3"

    oRib:SetSize( oDlg:nWidth )

    ADD GROUP oGr1 RIBBONBAR oRib;
              WIDTH 80;
              TO OPTION 1;

    @ 4, 4 ADD BUTTON GROUP oGr1;
           SIZE oGr1:nWidth - 9, oGr1:nHeight - 7;
           PROMPT "Test 1";
           BITMAP "OPEN.BMP";
           ACTION MSGINFO( "Test 1" )

    ADD GROUP oGr2 RIBBONBAR oRib;
              WIDTH 80;
              TO OPTION 1;

    @ 4, 4 ADD BUTTON GROUP oGr2;
           SIZE oGr2:nWidth - 9, oGr2:nHeight - 7;
           PROMPT "Test 2";
           BITMAP "OPEN.BMP";
           ACTION MSGINFO( "Test 2" );
           POPUP MENU oMn1

    ADD GROUP oGr3 RIBBONBAR oRib;
              WIDTH 80;
              TO OPTION 2;

    @ 4, 4 ADD BUTTON GROUP oGr3;
           SIZE oGr3:nWidth - 9, oGr3:nHeight - 7;
           PROMPT "Test 3";
           BITMAP "OPEN.BMP";
           ACTION MSGINFO( "Test 3" )

    ADD GROUP oGr4 RIBBONBAR oRib;
              WIDTH 80;
              TO OPTION 2;

    @ 4, 4 ADD BUTTON GROUP oGr4;
           SIZE oGr4:nWidth - 9, oGr4:nHeight - 7;
           PROMPT "Test 4";
           BITMAP "OPEN.BMP";
           ACTION MSGINFO( "Test 4" );
           POPUP MENU oMn1

    RETURN NIL


EMG
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Posts: 368
Joined: Sun May 31, 2009 06:25 PM

Re: RibbonBar

Posted: Sat Jun 01, 2013 02:31 PM
I think problem 3 can be solved with

Code (fw): Select all Collapse
 MENUITEM "Test 4" ACTION ACTION oDlg:aControls[ 1 ]:setFocus()
Regards,



André Dutheil

FWH 13.04 + HB 3.2 + MSVS 10
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM

Re: RibbonBar

Posted: Sat Jun 01, 2013 04:01 PM
ADutheil wrote:I think problem 3 can be solved with

Code (fw): Select all Collapse
 MENUITEM "Test 4" ACTION ACTION oDlg:aControls[ 1 ]:setFocus()


Thank you, but doing so I'd move the focus from the current control. :-)

EMG
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM

Re: RibbonBar

Posted: Sat Jun 01, 2013 04:47 PM

Enrico,

I have tested problem three, and I see the problem, however, I can't imagine any situation (other than testing) where you would have a menu choice without an ACTION clause. So is this a real problem?

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Re: RibbonBar

Posted: Sat Jun 01, 2013 05:45 PM
Enrico,

It seems that problem 3 gets fixed with this line to include at line 836 in Class TRbtn:

Code (fw): Select all Collapse
                        if oWnd:oPopup == nil
                           oWnd:oPopup = ::oPopup
                           ::oPopup:Activate( ::nTop + ::nHeight(),;
                                              ::nLeft - If( ! oWnd:IsKindOf( "TRBGROUP" ), oWnd:nLeft, 0 ), oWnd, .F. )
                           oWnd:oPopup = nil  // new !!!                                           
                        endif
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM

Re: RibbonBar

Posted: Sat Jun 01, 2013 06:07 PM
James,

James Bott wrote:Enrico,

I have tested problem three, and I see the problem, however, I can't imagine any situation (other than testing) where you would have a menu choice without an ACTION clause. So is this a real problem?

James


What about something like

ACTION n := 4

EMG
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM

Re: RibbonBar

Posted: Sat Jun 01, 2013 06:08 PM
Antonio,

Antonio Linares wrote:Enrico,

It seems that problem 3 gets fixed with this line to include at line 836 in Class TRbtn:

Code (fw): Select all Collapse
                        if oWnd:oPopup == nil
                           oWnd:oPopup = ::oPopup
                           ::oPopup:Activate( ::nTop + ::nHeight(),;
                                              ::nLeft - If( ! oWnd:IsKindOf( "TRBGROUP" ), oWnd:nLeft, 0 ), oWnd, .F. )
                           oWnd:oPopup = nil  // new !!!                                           
                        endif


Yes, it fixes the problem 2 (not 3)! Many thanks!

EMG
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM

Re: RibbonBar

Posted: Sat Jun 01, 2013 06:14 PM

Antonio,

Gee, Enrico and I just had a discussion about not setting objects to nil, but instead calling the End() method. Shouldn't that be done here too? I note that there are functions like Destroy() and DelItems() in the End() method that if not called might cause a memory leak.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM

Re: RibbonBar

Posted: Sat Jun 01, 2013 06:20 PM
Enrico,

What about something like

ACTION n := 4


Point taken. Or, any ACTION that doesn't cause a screen change of focus I suppose.

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM

Re: RibbonBar

Posted: Sat Jun 01, 2013 06:29 PM
James,

James Bott wrote:Enrico,

What about something like

ACTION n := 4


Point taken. Or, any ACTION that doesn't cause a screen change of focus I suppose.

James


Yeah. :-)

EMG
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM

Re: RibbonBar

Posted: Tue Jun 04, 2013 03:29 PM

Fourth problem: there is a flicker on all the controls of the dialog when a ribbonbar tab is clicked. If a sample is needed I can create one.

Any ideas on how to alleviate the flickering?

EMG