CodeJock ToolBar
Posted: Sun Nov 04, 2018 7:23 am
Hi Roger
In the sample program below, Is it possible to add a dropdown menu to the toolbar button ?
Thanks
Joe
#INCLUDE "dcdialog.CH"
#INCLUDE "XCodeJock.CH"
#INCLUDE "CommandBars.CH"
#INCLUDE "Definitions.CH"
#INCLUDE "Appevent.CH"
#INCLUDE "fileio.CH"
#INCLUDE "dcbitmap.CH"
#DEFINE TRUE .t.
#DEFINE FALSE .f.
FUNCTION Main()
LOCAL Getlist[0], Getoptions, oCommandBars, oStatic, nTheme, oDlg, nHandle, ;
aDir := Directory(), oBrowse
nHandle := DllLoad('..\..\..\BIN19\DCRES.DLL')
DC_BitmapResourceFile( nHandle )
nTheme := xtpThemeWhidbey
CJCOMMANDBARS oCommandBars ;
VISUALTHEME nTheme ;
SHOWTEXTBELOWICONS TRUE ;
SCALEMODE xtpScalePixel
@0,0 DCSAY '' OBJECT oStatic COLOR GRA_CLR_RED, GRA_CLR_WHITE ;
SIZE 120, 20 ;
FONT '16.Arial Bold' SAYWORDBREAK ;
SAYOPTIONS XBPSTATIC_TEXT_VCENTER + XBPSTATIC_TEXT_CENTER + XBPSTATIC_TEXT_WORDBREAK ;
EVAL {|o|o:setCaption('Mini Toolbar Test Program')}
*/
@ 2.5,0 DCBROWSE oBrowse DATA aDir PARENT oStatic ;
FONT '10.Lucida Console';
SIZE DCGUI_PARENTWIDTH, DCGUI_PARENTHEIGHT-2.5 PIXEL //;
// RESIZE DCGUI_RESIZE_RESIZEONLY
DCBROWSECOL ELEMENT 1 HEADER 'File Name' WIDTH 25 PARENT oBrowse //250
DCBROWSECOL ELEMENT 2 HEADER 'File Size' WIDTH 10 PARENT oBrowse //100
DCBROWSECOL ELEMENT 3 HEADER 'File Date' WIDTH 10 PARENT oBrowse //100
DCBROWSECOL ELEMENT 4 HEADER 'File Time' WIDTH 10 PARENT oBrowse //100
DCBROWSECOL ELEMENT 5 HEADER 'File Time 1' WIDTH 10 PARENT oBrowse //100
DCBROWSECOL ELEMENT 6 HEADER 'File Time 2' WIDTH 10 PARENT oBrowse //100
DCGETOPTIONS; // PIXEL
CLOSEQUERY MSG {||SaveState(oCommandBars),.t.} ;
COLOR GRA_CLR_WHITE RESIZEDEFAULT DCGUI_RESIZE_RESIZEONLY;
HIDE
DCREAD GUI TITLE 'CodeJock Command Bar w/ToolBar' OPTIONS GetOptions ;
EVAL {|o|oDlg := o, ;
BuildToolBar( oCommandBars, oDlg, GetList ), ;
o:show()} ;
SETAPPWINDOW
RETURN nil
* -----------
PROC appsys ; RETURN
* -----------
STATIC FUNCTION BuildToolbar( oCommandBars, oDlg, GetList )
LOCAL oControl, oMenuBar, iCount, cIconPath, aIconArray[5], oOptions, ;
oToolBar1, oToolBar2, oImageManager
oOptions := oCommandBars:getProperty("options")
// Re-Add the Menu Bar
CJADDTOOLBAR oToolBar1 NAME 'ToolBar1' PARENT oCommandBars ;
ALIGN xtpBarTop ICONSIZE 16,16 ; // 32,32
ShowGripper TRUE ;
TEXTORIENTATION xtpBarTextHorizontal
// oToolBar1:enableDocking(xtpFlagStretchedShared)
// oOptions:showExpandButtonAlways := .t.
cIconPath := '.\icons\'
//Add buttons
FOR iCount := ID_STANDARD_1 TO ID_STANDARD_19
CJADDTOOLBUTTON oControl ;
ID iCount ;
PARENT oToolBar1 ;
CATEGORY "Standard" ;
TOOLTIP 'Standard Button ' + Alltrim(Str(iCount)) ;
CAPTION "Standard " + Alltrim(Str(iCount)) ;
ACTION ActionBlock(iCount,oCommandBars,oDlg) ;
ICON cIconPath + "standard_" + Alltrim(Str(iCount - 500)) + ".ico" ;
DESCRIPTIONTEXT 'Just Testing' ;
STYLE xtpButtonIconAndCaptionBelow
NEXT
CJADDTOOLBAR oToolBar2 NAME 'ToolBar 2' PARENT oCommandBars ALIGN xtpBarBottom ICONSIZE 24,16 ShowGripper TRUE
oToolBar2:enableDocking(xtpFlagStretchedShared)
FOR iCount := ID_STANDARD_16 TO ID_STANDARD_19
CJADDTOOLBUTTON oControl ;
ID iCount ;
PARENT oToolBar2 ;
CATEGORY "Small" ;
TOOLTIP 'Small Button ' + Alltrim(Str(iCount)) ;
CAPTION "Small " + Alltrim(Str(iCount)) ;
ACTION ActionBlock(iCount,oCommandBars,oDlg) ;
ICON cIconPath + "standard_" + Alltrim(Str(iCount - 500)) + ".ico"
NEXT
CJADDTOOLBUTTON oControl ;
ID BITMAP_BUG_M ;
PARENT oToolBar1 ;
CATEGORY "Small" ;
TOOLTIP "I am a normal Bug" ;
CAPTION "Bug" ;
HOTKEY 0, VK_F12 ;
ACTION {||DC_WinAlert('test')} ;
ICON BITMAP_BUG_M
CJADDTOOLBUTTON oControl ;
ID BITMAP_OBJECT_M ;
PARENT oToolBar2 ;
CATEGORY "Small" ;
TOOLTIP "I am a small Object" ;
CAPTION "Small Object" ;
HOTKEY FSHIFT + FCONTROL, Asc('Z') ;
ACTION {||DC_SpawnUrl('http://donnay-software.com')} ;
ICON BITMAP_OBJECT_M
aIconArray[1] := ID_STANDARD_15
aIconArray[2] := ID_STANDARD_16
aIconArray[3] := ID_STANDARD_17
aIconArray[4] := ID_STANDARD_18
aIconArray[5] := ID_STANDARD_19
CJLoadBitmap cIconPath + 'usertools.bmp' ;
ID aIconArray STATE xtpImageNormal PARENT oCommandBars:icons
oOptions:UseDisabledIcons := .T.
oCommandBars:EnableCustomization(.T.)
oOptions:updatePeriod := 1000
oCommandBars:update := {||oCommandBars:ResizeDrawingArea(oDlg,.t.,GetList)}
RestoreState(oCommandBars)
oMenuBar := oCommandBars:AddMenuBar("Menu")
oMenuBar:visible := .f.
oCommandBars:recalcLayout()
oCommandBars:ResizeDrawingArea(oDlg,.t.,GetList)
RETURN nil
* ---------------
STATIC FUNCTION ActionBlock( nId, oCommandBars, oDlg )
RETURN {||DC_MsgBox('You clicked on ' + Alltrim(Str(nId))), ;
oCommandBars:resizeDrawingArea(oDlg)}
/*
* ---------------
STATIC FUNCTION SaveState( oCommandBars )
LOCAL cXml, nHandle
cXml := oCommandBars:SaveStateToXmlString( 'ToolBar1')
nHandle := FCreate('ToolbarDemo.Xml')
FWrite(nHandle,cXml )
FClose(nHandle)
RETURN nil
* ---------------
STATIC FUNCTION RestoreState( oCommandBars )
LOCAL cXml, cFileName
cFileName := 'ToolbarDemo.Xml'
IF Fexists(cFileName)
cXml := MemoRead(cFileName)
oCommandBars:LoadStateFromXmlString('ToolBar1',cXml)
ENDIF
RETURN nil
*/
* ------------
STATIC FUNCTION SaveState( oCommandBars )
LOCAL cTxt, nHandle
cTxt := oCommandBars:SaveStateToString( .t.,.t.,.t.)
nHandle := FCreate('ToolbarDemo.txt')
FWrite(nHandle,cTxt )
FClose(nHandle)
RETURN nil
* ---------------
STATIC FUNCTION RestoreState( oCommandBars, oRibbonbar )
LOCAL cTxt, cFileName
cFileName := 'ToolbarDemo.txt'
IF Fexists(cFileName)
cTxt := MemoRead(cFileName)
oCommandBars:LoadStateFromString(cTxt ,.t.,.t.,.t.)
ENDIF
RETURN nil
In the sample program below, Is it possible to add a dropdown menu to the toolbar button ?
Thanks
Joe
#INCLUDE "dcdialog.CH"
#INCLUDE "XCodeJock.CH"
#INCLUDE "CommandBars.CH"
#INCLUDE "Definitions.CH"
#INCLUDE "Appevent.CH"
#INCLUDE "fileio.CH"
#INCLUDE "dcbitmap.CH"
#DEFINE TRUE .t.
#DEFINE FALSE .f.
FUNCTION Main()
LOCAL Getlist[0], Getoptions, oCommandBars, oStatic, nTheme, oDlg, nHandle, ;
aDir := Directory(), oBrowse
nHandle := DllLoad('..\..\..\BIN19\DCRES.DLL')
DC_BitmapResourceFile( nHandle )
nTheme := xtpThemeWhidbey
CJCOMMANDBARS oCommandBars ;
VISUALTHEME nTheme ;
SHOWTEXTBELOWICONS TRUE ;
SCALEMODE xtpScalePixel
@0,0 DCSAY '' OBJECT oStatic COLOR GRA_CLR_RED, GRA_CLR_WHITE ;
SIZE 120, 20 ;
FONT '16.Arial Bold' SAYWORDBREAK ;
SAYOPTIONS XBPSTATIC_TEXT_VCENTER + XBPSTATIC_TEXT_CENTER + XBPSTATIC_TEXT_WORDBREAK ;
EVAL {|o|o:setCaption('Mini Toolbar Test Program')}
*/
@ 2.5,0 DCBROWSE oBrowse DATA aDir PARENT oStatic ;
FONT '10.Lucida Console';
SIZE DCGUI_PARENTWIDTH, DCGUI_PARENTHEIGHT-2.5 PIXEL //;
// RESIZE DCGUI_RESIZE_RESIZEONLY
DCBROWSECOL ELEMENT 1 HEADER 'File Name' WIDTH 25 PARENT oBrowse //250
DCBROWSECOL ELEMENT 2 HEADER 'File Size' WIDTH 10 PARENT oBrowse //100
DCBROWSECOL ELEMENT 3 HEADER 'File Date' WIDTH 10 PARENT oBrowse //100
DCBROWSECOL ELEMENT 4 HEADER 'File Time' WIDTH 10 PARENT oBrowse //100
DCBROWSECOL ELEMENT 5 HEADER 'File Time 1' WIDTH 10 PARENT oBrowse //100
DCBROWSECOL ELEMENT 6 HEADER 'File Time 2' WIDTH 10 PARENT oBrowse //100
DCGETOPTIONS; // PIXEL
CLOSEQUERY MSG {||SaveState(oCommandBars),.t.} ;
COLOR GRA_CLR_WHITE RESIZEDEFAULT DCGUI_RESIZE_RESIZEONLY;
HIDE
DCREAD GUI TITLE 'CodeJock Command Bar w/ToolBar' OPTIONS GetOptions ;
EVAL {|o|oDlg := o, ;
BuildToolBar( oCommandBars, oDlg, GetList ), ;
o:show()} ;
SETAPPWINDOW
RETURN nil
* -----------
PROC appsys ; RETURN
* -----------
STATIC FUNCTION BuildToolbar( oCommandBars, oDlg, GetList )
LOCAL oControl, oMenuBar, iCount, cIconPath, aIconArray[5], oOptions, ;
oToolBar1, oToolBar2, oImageManager
oOptions := oCommandBars:getProperty("options")
// Re-Add the Menu Bar
CJADDTOOLBAR oToolBar1 NAME 'ToolBar1' PARENT oCommandBars ;
ALIGN xtpBarTop ICONSIZE 16,16 ; // 32,32
ShowGripper TRUE ;
TEXTORIENTATION xtpBarTextHorizontal
// oToolBar1:enableDocking(xtpFlagStretchedShared)
// oOptions:showExpandButtonAlways := .t.
cIconPath := '.\icons\'
//Add buttons
FOR iCount := ID_STANDARD_1 TO ID_STANDARD_19
CJADDTOOLBUTTON oControl ;
ID iCount ;
PARENT oToolBar1 ;
CATEGORY "Standard" ;
TOOLTIP 'Standard Button ' + Alltrim(Str(iCount)) ;
CAPTION "Standard " + Alltrim(Str(iCount)) ;
ACTION ActionBlock(iCount,oCommandBars,oDlg) ;
ICON cIconPath + "standard_" + Alltrim(Str(iCount - 500)) + ".ico" ;
DESCRIPTIONTEXT 'Just Testing' ;
STYLE xtpButtonIconAndCaptionBelow
NEXT
CJADDTOOLBAR oToolBar2 NAME 'ToolBar 2' PARENT oCommandBars ALIGN xtpBarBottom ICONSIZE 24,16 ShowGripper TRUE
oToolBar2:enableDocking(xtpFlagStretchedShared)
FOR iCount := ID_STANDARD_16 TO ID_STANDARD_19
CJADDTOOLBUTTON oControl ;
ID iCount ;
PARENT oToolBar2 ;
CATEGORY "Small" ;
TOOLTIP 'Small Button ' + Alltrim(Str(iCount)) ;
CAPTION "Small " + Alltrim(Str(iCount)) ;
ACTION ActionBlock(iCount,oCommandBars,oDlg) ;
ICON cIconPath + "standard_" + Alltrim(Str(iCount - 500)) + ".ico"
NEXT
CJADDTOOLBUTTON oControl ;
ID BITMAP_BUG_M ;
PARENT oToolBar1 ;
CATEGORY "Small" ;
TOOLTIP "I am a normal Bug" ;
CAPTION "Bug" ;
HOTKEY 0, VK_F12 ;
ACTION {||DC_WinAlert('test')} ;
ICON BITMAP_BUG_M
CJADDTOOLBUTTON oControl ;
ID BITMAP_OBJECT_M ;
PARENT oToolBar2 ;
CATEGORY "Small" ;
TOOLTIP "I am a small Object" ;
CAPTION "Small Object" ;
HOTKEY FSHIFT + FCONTROL, Asc('Z') ;
ACTION {||DC_SpawnUrl('http://donnay-software.com')} ;
ICON BITMAP_OBJECT_M
aIconArray[1] := ID_STANDARD_15
aIconArray[2] := ID_STANDARD_16
aIconArray[3] := ID_STANDARD_17
aIconArray[4] := ID_STANDARD_18
aIconArray[5] := ID_STANDARD_19
CJLoadBitmap cIconPath + 'usertools.bmp' ;
ID aIconArray STATE xtpImageNormal PARENT oCommandBars:icons
oOptions:UseDisabledIcons := .T.
oCommandBars:EnableCustomization(.T.)
oOptions:updatePeriod := 1000
oCommandBars:update := {||oCommandBars:ResizeDrawingArea(oDlg,.t.,GetList)}
RestoreState(oCommandBars)
oMenuBar := oCommandBars:AddMenuBar("Menu")
oMenuBar:visible := .f.
oCommandBars:recalcLayout()
oCommandBars:ResizeDrawingArea(oDlg,.t.,GetList)
RETURN nil
* ---------------
STATIC FUNCTION ActionBlock( nId, oCommandBars, oDlg )
RETURN {||DC_MsgBox('You clicked on ' + Alltrim(Str(nId))), ;
oCommandBars:resizeDrawingArea(oDlg)}
/*
* ---------------
STATIC FUNCTION SaveState( oCommandBars )
LOCAL cXml, nHandle
cXml := oCommandBars:SaveStateToXmlString( 'ToolBar1')
nHandle := FCreate('ToolbarDemo.Xml')
FWrite(nHandle,cXml )
FClose(nHandle)
RETURN nil
* ---------------
STATIC FUNCTION RestoreState( oCommandBars )
LOCAL cXml, cFileName
cFileName := 'ToolbarDemo.Xml'
IF Fexists(cFileName)
cXml := MemoRead(cFileName)
oCommandBars:LoadStateFromXmlString('ToolBar1',cXml)
ENDIF
RETURN nil
*/
* ------------
STATIC FUNCTION SaveState( oCommandBars )
LOCAL cTxt, nHandle
cTxt := oCommandBars:SaveStateToString( .t.,.t.,.t.)
nHandle := FCreate('ToolbarDemo.txt')
FWrite(nHandle,cTxt )
FClose(nHandle)
RETURN nil
* ---------------
STATIC FUNCTION RestoreState( oCommandBars, oRibbonbar )
LOCAL cTxt, cFileName
cFileName := 'ToolbarDemo.txt'
IF Fexists(cFileName)
cTxt := MemoRead(cFileName)
oCommandBars:LoadStateFromString(cTxt ,.t.,.t.,.t.)
ENDIF
RETURN nil