Sample:
http://www.sitasoft.net/fivewin/samples/testqck.rar
- Code: Select all Expand view
- #include "Fivewin.ch"
#include "Ribbon.ch"
Function Main()
local oWnd, oRibbon
local oGrupo, oBtn1, oBtn2, oQbtn1, oQbtn2, oQbtn3
local oQck, oBtn
SetBalloon( .T. )
Define window ownd Title "Fivewin RibbonBar"
DEFINE RIBBONBAR oRibbon PROMPTS "Start","Edition","Tools","Themes","Help" OF oWnd ;
HEIGHT 180 TOPMARGIN 60
ADD GROUP oGrupo RIBBON oRibbon TO OPTION 1 PROMPT "Only a Group to Test"
@ 04,04 ADD BUTTON oBtn1 PROMPT "Testing 1" BITMAP "..\bitmaps\paste32.bmp";
GROUP oGrupo SIZE 142,40 LEFT ;
Action( oBtn := oRibbon:oQuickAcc:AddButton("..\bitmaps\16x16\calc.bmp",{|| MsgInfo("1")} ),;
oBtn:bRClicked := {| nRow, nCol, nFlags, oBtn | MenuQuickDelete( oBtn, oQck ) } )
@ 45,04 ADD BUTTON oBtn2 PROMPT "Testing 2" BITMAP "..\bitmaps\stylechange32.bmp";
GROUP oGrupo SIZE 142,40 LEFT;
Action oRibbon:oQuickAcc:DelButton( ATail( oRibbon:oQuickAcc:aButtons ) )
DEFINE QUICKBUTTON OF oRibbon ;
BITMAP "..\Bitmaps\16x16\fivetech.bmp", "..\Bitmaps\btnqcka.bmp", "..\Bitmaps\btnqckb.bmp", "..\Bitmaps\btnqckc.bmp" ;
ACTION AbreMenu( oWnd )
DEFINE QUICKACCESS oQck OF oRibbon
ADD BUTTON oQbtn1 QUICKACCESS oQck BITMAP "..\bitmaps\16x16\floppy.bmp" ;
ACTION MsgInfo("1")
ADD BUTTON oQbtn2 QUICKACCESS oQck BITMAP "..\bitmaps\16x16\closeall.bmp" ;
ACTION MsgInfo("2")
ADD BUTTON oQbtn3 QUICKACCESS oQck BITMAP "..\bitmaps\16x16\additem.bmp" ;
ACTION MsgInfo("3")
ADD BUTTON oQbtn3 QUICKACCESS oQck BITMAP "..\bitmaps\16x16\adddbf.bmp" ;
ACTION MsgInfo("4")
oBtn1:bRClicked := {| nRow, nCol, nFlags, oBtn | MenuQuickAdd( oBtn, oQck, "..\bitmaps\16x16\paste.bmp" ) }
oBtn2:bRClicked := {| nRow, nCol, nFlags, oBtn | MenuQuickAdd( oBtn, oQck, , .T.) }
AEval( oQck:aButtons, {|o| o:bRClicked := {| nRow, nCol, nFlags, oBtn | MenuQuickDelete( oBtn, oQck ) } } )
oRibbon:nSeparation( 5 )
SET MESSAGE OF oWnd TO "Sample Quick Button + Quick Access" CENTERED CLOCK KEYBOARD 2007
Activate window ownd
Return Nil
Function AbreMenu( oWindow )
Local oMenu
MENU oMenu POPUP 2007
MENUITEM "Open"
MENU
MENUITEM "New"
SEPARATOR
MENUITEM "Other"
ENDMENU
MENUITEM "Save As..."
MENU
MENUITEM "DBF..."
SEPARATOR
MENUITEM "XML..."
ENDMENU
SEPARATOR
MENUITEM "Close App..." Action oWindow:End()
ENDMENU
ACTIVATE POPUP oMenu AT 48, 2 OF oWindow
return NIL
FUNCTION MenuQuickDelete( oBtn, oQuickAcc )
Local oMenu
MENU oMenu POPUP 2007
MENUITEM "Remove QuickAccess" Action oQuickAcc:DelButton( oBtn )
ENDMENU
ACTIVATE POPUP oMenu AT oBtn:nHeight, oBtn:nLeft OF oQuickAcc:oRibbon
Return Nil
FUNCTION MenuQuickAdd( oBtn, oQuickAcc, cName, lAdjust )
Local oMenu, o
DEFAULT cName := oBtn:cName
DEFAULT lAdjust := .F.
MENU oMenu POPUP 2007
MENUITEM "Add to QuickAccess" ;
ACTION ( oBtn:Cargo := oQuickAcc:AddButton( cName, oBtn:bAction, , lAdjust ),;
oBtn:Cargo:bRClicked := {| nRow, nCol, nFlags, oBtn | MenuQuickDelete( oBtn, oQuickAcc ) } );
WHEN ( If( oBtn:Cargo == NIL, .T.,;
AScan( oQuickAcc:aButtons, {| oB | oB:hWnd == oBtn:Cargo:hWnd } ) == 0 ) )
ENDMENU
ACTIVATE POPUP oMenu AT oBtn:nHeight() + oBtn:nTop, oBtn:nLeft OF oBtn:oWnd
Return Nil
Thanks to lailton by collaborate to build this feature, shared code and time