4.3.4 Data navigation

Data navigation

Every time data is stored, there must be a way to navigate that data to find records. The classes in this category cover the topic of data navigation rather well.

Data Navigation Buttons

Class

_datanavbtns

Base class

Container

Class library

_datanav.vcx

Parent class

_container

Sample

None

Dependencies

_base.vcx, _data.h

The Data Navigation buttons provide a simple VCR-button interface to navigate in a data source. Figure 10 shows an example of these buttons.

Figure 10. The Data Navigation buttons are located in the lower left corner of the form.

The Data Navigation buttons use the Data Checker object to check whether data has to be updated before the record pointer is moved; if so, there might be conflicts that have to be resolved.

Unlike commonly believed, the Data Navigation buttons do not utilize the Data Navigation object. This class has all the necessary behavior itself and it raises events that you can use to implement additional behavior. Before the record pointer is moved, the BeforeRecordPointerMoved() method is called. By default, this method only makes sure the correct data source is selected. The name of the data source we want to navigate is stored in a property called SkipTable (not cSkipTable as incorrectly listed by the documentation). After navigating, the RecordPointerMoved() method fires. This method makes sure the current form is refreshed properly. You can overwrite this method to add additional refresh behavior. The form in Figure 10 uses this method to make sure the record pointer movement gets displayed properly by briefly setting the focus to the grid.

Finally, the EnableDisableButtons() method is fired. This method ensures that buttons get disabled when the record pointer is at the first or the last record. The Data Navigation buttons are passive, which means that they do not recognize any record pointer movement unless it was initialized by the Data Navigation Buttons object. In Figure 10, the record pointer could also be moved if the user clicked on a row in the grid. To make sure the buttons are updated properly, we have to call the EnableDisableButtons() method from the grid's AfterRowColChange() event.

Data Navigation Object

Class

_tablenav

Base class

Custom

Class library

_table.vcx

Parent class

_table

Sample

...\Samples\Vfp98\Solution\Ffc\datanav.scx

Dependencies

_base.vcx, _table.h

The Data Navigation object provides the most important data navigation behavior, such as navigating to the next or previous record, as well as navigating to a specific record, which is identified by its record number. The Data Navigation object is used by many navigation buttons and other navigation interfaces.

The object has five important methods, which are GoTop(), GoPrevious(), GoNext(), GoBottom() and GoToRecord(). When using the GoToRecord() method, you have to pass the record number as a parameter. Typically, when you issue a GoNext() at the last record, or a GoPrevious() at the first one, the object will display a message. You can alter this behavior by setting the lCycle property to .T., which means that the record pointer will be moved to the first record when an end-of-file is encountered, and to the last record when the record pointer is at the beginning of the file.

The class has a few empty methods that you can overwrite to give some feedback. Those methods are DoBottomMessage(), DoCycleBottomMessage(), DoCycleTopMessage() and DoTopMessage(). By default, the object doesn't give any feedback when the desired navigation can't take place because the record pointer already is at the first or the last record. Using these methods, you can react properly to this event, or bring up some user interface.

After moving the record pointer successfully, a method called RefreshUIAfterChange() is invoked. This method simply issues a refresh of the current form. Overwrite this method if you need some additional refresh behavior.

GoTo Dialog Box

Class

_gotodialog

Base class

Form

Class library

_table.vcx

Parent class

_form

Sample

...\Samples\Vfp98\Solution\Ffc\datanav.scx

Dependencies

_base.vcx, _table.h

The GoTo dialog box is a simple dialog (form) that utilizes the Data Navigation object to navigate to a certain record, which is identified by its record number. The interface is rather simple. I've found that, for most uses, the interface must be subclassed to match one's application.

GoTo Dialog Box Button

Class

_gotobutton

Base class

CommandButton

Class library

_table2.vcx

Parent class

_dialogbutton

Sample

...\Samples\Vfp98\Solution\Ffc\datanav.scx

Dependencies

_base.vcx, _table2.h, _table.vcx, _table.h

This button is a very simple foundation class. Its whole purpose is to bring up the GoTo dialog box. Note that the GoTo dialog box is stored in another class library, which also requires a couple of additional files in order to run.

GoTo Spinner

Class

_goto

Base class

Container

Class library

_table2.vcx

Parent class

_container

Sample

None

Dependencies

_base.vcx

The GoTo Spinner is very similar to the GoTo dialog box, but it is only a simple container. Figure 11 shows this spinner in a toolbar. This object also utilizes the Data Navigation object to move the record pointer.

Using this object is rather simple. You can drop it on every form or container that has some data in its data session.

Navigation Toolbar (Container)

Class

_navtoolbarclass

Base class

Container

Class library

_table2.vcx

Parent class

_container

Sample

...\Samples\Vfp98\Solution\Ffc\datasort.scx

Dependencies

_base.vcx, _table2.h

The Navigation Toolbar object (as documented in the Visual FoxPro Foundation Class documentation) is a simple container object with a timer that can be dropped on any form. When initialized, it instantiates a navigation toolbar (documented below). You can specify a different toolbar class using the cClass and cClassLib properties. All other properties are for internal use only.

Navigation Toolbar (Toolbar)

Class

_tbrnavigation

Base class

Toolbar

Class library

_table2.vcx

Parent class

_toolbar

Sample

...\Samples\Vfp98\Solution\Ffc\datasort.scx

Dependencies

_base.vcx, _table.vcx, _table.h, _table2.h, top.bmp, previous.bmp, next.bmp, bottom.bmp, sortup.bmp, sortdown.bmp, filter.bmp, find.bmp

The Navigation Toolbar provides a simple and elegant interface for the most important data navigation features, including simple navigation, record-sorting sequences, data filtering and Find dialogs. To do so, it utilizes several other foundation classes such as the VCR Navigation Picture buttons, the GoTo Spinner, the Sort Selector, the Filter Dialog Box button and the Find Dialog Box button. Figure 11 shows an example of this toolbar.

The Navigation Toolbar container uses this toolbar by default. The toolbar can be modified through the properties and methods of the member objects as described in the individual sections about those objects.

Figure 11. The Navigation toolbar, including the GoTo Spinner, the
Sort Selector, the Filter button and the Find button.

Simple Picture Navigation Buttons

Class

_nav2picbuttons

Base class

Container

Class library

_table2.vcx

Parent class

_nav2buttons

Sample

...\Samples\Vfp98\Solution\Ffc\datanav.scx

Dependencies

_base.vcx, _table.vcx, _table.h, _table2.h, previous.bmp, next.bmp

The Simple Picture navigation buttons are identical to the Simple Navigation buttons but they use images rather than simple characters.

 

Simple Navigation Buttons

Class

_nav2buttons

Base class

Container

Class library

_table2.vcx

Parent class

_container

Sample

...\Samples\Vfp98\Solution\Ffc\datanav.scx

Dependencies

_base.vcx, _table.vcx, _table.h, _table2.h

The Simple Navigation buttons provide a two-button interface to navigate to the previous or next record. This class utilizes the Data Navigation object. The Simple Navigation buttons can be dropped on any form or container that has some kind of data source.

The object has a method called TableNav(). It can be used to navigate to the previous or next record. The navigation direction is specified by the first parameter, which can be NEXT or PREVIOUS. The object also has an lCycle property. When this property is set, the value is directly passed on to the Data Navigation object.

VCR Buttons

Class

_nav4buttons

Base class

Container

Class library

_table.vcx

Parent class

_nav2buttons

Sample

...\Samples\Vfp98\Solution\Ffc\datanav.scx

Dependencies

_base.vcx, _table.h

The VCR buttons are very similar to the Simple Navigation buttons, but they also feature go-top and go-bottom buttons.

VCR Picture Navigation Buttons

Class

_nav4picbuttons

Base class

Container

Class library

_table2.vcx

Parent class

_nav4buttons

Sample

...\Samples\Vfp98\Solution\Ffc\datanav.scx

Dependencies

_base.vcx, _table.h, _table.vcx, _table2.h, top.bmp, previous.bmp, next.bmp, bottom.bmp

The VCR Picture Navigation buttons are identical to the regular VCR buttons, but they use images for each button rather than simple characters.



Advanced Object Oriented Programming with Visual FoxPro 6. 0
Advanced Object Oriented Programming with Visual FoxPro 6.0
ISBN: 0965509389
EAN: 2147483647
Year: 1998
Pages: 113
Authors: Markus Egger

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net