Code: Select all
#INCLUDE "dcdialog.CH"
#INCLUDE "appevent.CH"
#DEFINE EVENT_DATABASE_TOP xbeP_User + 1
#DEFINE EVENT_DATABASE_PREVIOUS xbeP_User + 2
#DEFINE EVENT_DATABASE_NEXT xbeP_User + 3
#DEFINE EVENT_DATABASE_BOTTOM xbeP_User + 4
#DEFINE NAVIGATE_TOP 1
#DEFINE NAVIGATE_BOTTOM 2
#define COLOR_YELLOW GraMakeRGBColor( { 255, 255, 0 } )
#define COLOR_BROWN GraMakeRGBColor( { 127, 127, 0 } )
#define COLOR_WHITE GraMakeRGBColor( { 255, 255, 255 } )
#define COLOR_BLACK GraMakeRGBColor( { 0, 0, 0 } )
#define COLOR_ORANGE GraMakeRGBColor( { 253, 120, 41 } )
FUNCTION Main()
LOCAL GetList[0], oMenuBar, oSubMenu, oDlg, oStatTop, GetOptions, oToolbar, oConfig
DC_LoadRdds()
DC_PushButtonStyle(1)
oConfig := DC_XbpPushButtonXPConfig():new()
oConfig:bitmapOffset := 5
oConfig:fgColorMouse := COLOR_BLACK
oConfig:bgColorMouse := COLOR_ORANGE
oConfig:fgColor := COLOR_BLACK
oConfig:bgColor := COLOR_BROWN
oConfig:gradientStep := 10
oConfig:gradientReverse := .t.
oConfig:radius := 5
oConfig:bgColorClick := COLOR_YELLOW
DCSTATUSBAR oStatTop ALIGN DCGUI_ALIGN_TOP HEIGHT 24
@ 0,0 DCTOOLBAR oToolBar PARENT oStatTop SIZE 400,24 PIXEL BUTTONSIZE 80,24 TYPE XBPSTATIC_TYPE_TEXT SPACE 5
DCADDBUTTONXP CAPTION '~Top' PARENT oToolBar ACTION {||PostAppEvent(EVENT_DATABASE_TOP,,,SetDisplayFocus())} ;
WHEN {||!Navigate() $ {NAVIGATE_TOP,0}} CONFIG oConfig
DCADDBUTTONXP CAPTION '~Previous' PARENT oToolBar ACTION {||PostAppEvent(EVENT_DATABASE_PREVIOUS,,,SetDisplayFocus())} ;
WHEN {||!Navigate() $ {NAVIGATE_TOP,0}} CONFIG oConfig
DCADDBUTTONXP CAPTION '~Next' PARENT oToolBar ACTION {||PostAppEvent(EVENT_DATABASE_NEXT,,,SetDisplayFocus())} ;
WHEN {||!Navigate() $ {NAVIGATE_BOTTOM,0}} CONFIG oConfig
DCADDBUTTONXP CAPTION '~Bottom' PARENT oToolBar ACTION {||PostAppEvent(EVENT_DATABASE_BOTTOM,,,SetDisplayFocus())} ;
WHEN {||!Navigate() $ {NAVIGATE_BOTTOM,0}} CONFIG oConfig
DCMENUBAR oMenuBar
DCSUBMENU oSubMenu PROMPT 'File' PARENT oMenuBar
DCMENUITEM 'Browse Xtest' PARENT oSubMenu ;
ACTION {|o|o := Thread():new(), Sleep(5), o:start({||BrowseXtest(oDlg,GetList)})}
DCGETOPTIONS WINDOWWIDTH 800 WINDOWHEIGHT 600
DCREAD GUI TITLE 'Test Program' OPTIONS GetOptions PARENT @oDlg
RETURN nil
* -----------
PROC Appsys ; RETURN
* -----------
FUNCTION SetDisplayFocus( oDlg )
STATIC soDlg
IF Valtype(oDlg) == 'O'
soDlg := oDlg
ENDIF
RETURN soDlg
* -----------
FUNCTION BrowseXTest( oMainDlg, aMainGetList )
LOCAL GetList[0], oBrowse, oDlg
USE XTest INDEX XTest VIA 'DBFCDX'
DCUSEREVENT EVENT_DATABASE_TOP ACTION {||Xtest->(dbGoTop()),oBrowse:refreshAll()}
DCUSEREVENT EVENT_DATABASE_PREVIOUS ACTION {||Xtest->(dbSkip(-1)),oBrowse:refreshAll()}
DCUSEREVENT EVENT_DATABASE_NEXT ACTION {||Xtest->(dbSkip()),oBrowse:refreshAll()}
DCUSEREVENT EVENT_DATABASE_BOTTOM ACTION {||Xtest->(dbGoBottom()),oBrowse:refreshAll()}
@ 0,0 DCBROWSE oBrowse ALIAS 'Xtest' SIZE 80,20 ;
ITEMMARKED {||TestNavigate(Alias(),aMainGetList)}
DCBROWSECOL FIELD Xtest->areacode HEADER 'Area' WIDTH 4 PARENT oBrowse
DCBROWSECOL FIELD Xtest->exchange HEADER 'Exchange' WIDTH 4 PARENT oBrowse
DCBROWSECOL FIELD Xtest->number HEADER 'Number' WIDTH 4 PARENT oBrowse
DCREAD GUI FIT TITLE 'Browsing XTest' APPWINDOW oMainDlg:drawingArea ;
EVAL {|o|oDlg := o, o:setDisplayFocus := {||SetDisplayFocus(oDlg),TestNavigate(Alias(),aMainGetList)}, SetDisplayFocus(oDlg)}
Navigate(0)
RETURN nil
* ------------
FUNCTION TestNavigate( cAlias, aMainGetList )
IF (cAlias)->(DC_TestBof())
Navigate(NAVIGATE_TOP)
ELSEIF (cAlias)->(DC_TestEof())
Navigate(NAVIGATE_BOTTOM)
ELSE
Navigate(-1)
ENDIF
DC_GetWhen(aMainGetList)
RETURN nil
* -----------
GETSETFUNCTION Navigate DEFAULT 0