Page 1 of 1

CodeJock ToolBar

Posted: Sun Nov 04, 2018 7:23 am
by unixkd
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

Re: CodeJock ToolBar

Posted: Sun Nov 04, 2018 8:52 am
by Tom
DCPUSHBUTTONXP has a menu (dropdown) option. Use that instead of CJ!

And please use the "code" tag to mark the code in your messages, Joe. It's much easier to read then.

Re: CodeJock ToolBar

Posted: Sun Nov 04, 2018 10:20 am
by unixkd
I use DCPUSHBUTTONXP extensively and I am aware of that feature but just want to know if Donnay implemented it in Codejock Toolbar.

Joe

Re: CodeJock ToolBar

Posted: Sun Nov 04, 2018 3:45 pm
by Auge_Ohr
hi,

i wonder why you want to use Codejock Toolbar and not XbpToolbar while both are same ("ToolbarWindow32") :?:
Is it possible to add a dropdown menu to the toolbar button ?
Yes ... but i don't know how with Codejock

Xbase++ XbpToolbar() have XbpToolBarButtonMenuItem()
native DXE_Toolbar use same Constante XBPTOOLBAR_BUTTON_DROPDOWN and Snytax.

p.s. DXE LIB also have REBAR() to enhance Toolbar(s)
DXE_Rebar.jpg
DXE_Rebar.jpg (59.71 KiB) Viewed 28476 times

Re: CodeJock ToolBar

Posted: Mon Nov 05, 2018 7:30 am
by rdonnay
I haven't done anything with XCodeJock in a long time.

I found that just about any kind of GUI look or function could be written using DC* commands in Xbase++.

This requires no ActiveX.

I always hated command bars.
They are complicated to write and maintain and have always seemed to be convuluted and

Most likely, a menu can be added because you can add anything to a push button.
Look at \exp20\samples\menu\buttonmenu.prg

Re: CodeJock ToolBar

Posted: Mon Nov 05, 2018 12:21 pm
by unixkd
Thanks all

I examined the xcodejock.ch and made ONE line modification and I got it working as shown below.
CJToolbar.png
CJToolbar.png (163.99 KiB) Viewed 28448 times