Grigory Filatov

Contributed works of Grigory Filatov

Adaptation FiveWin TsBrowse class
Color Table
Center Window’s Title
Closes application when no activity
Copy Protection (Get BIOS Name)

GetFonts
Get list of all controls

GIF animation demo

WITH OBJECT

WITH OBJECT

Identifies an object to receive multiple messages.

Syntax

       WITH OBJECT <object>
          :<message1>
          [<statements>]
          [:<messageN>]
       END

Arguments

WITH OBJECT <object> <object> is the symbolic name of a variable that holds a reference to an object. The object is to receive messages in the WITH OBJECT control structure.

:<message> All expressions that begin with the send operator in the OBJECT WITH block are sent as messages to <object>.

Description

The WITH OBJECT control structure delimits a block of statements where the object variable <object> receives multiple messages in abbreviated form. The name of the object variable can be omitted from a message sending expression, so that only the send operator (:) followed by the message to send must be typed.

WITH OBJECT basically relieves a programmer from typing. The name of the object variable is typed only once at the beginning of the WITH OBJECT block, and all subsequent messages sent to the object start with the send operator, omitting the object’s variable name.

Example

       // The example builds a simple database browser using a TBrowse object.
       // The columns added to the object and the cursor navigation logic is
       // programmed using the WITH OBJECT control structure.
       #include "inkey.ch"
       PROCEDURE Main
          LOCAL oTBrowse, aFields, cField, nKey
          USE Customer
          aFields := Array( FCount() )
          AEval( aFields, {|x,i| aFields[i] := FieldName(i) } )
          oTBrowse := TBrowseDB()
          WITH OBJECT oTBrowse
             FOR EACH cField IN aFields
                :addColumn( TBColumnNew( cField, FieldBlock( cField ) ) )
             NEXT
          END
          nKey := 0
          DO WHILE nKey <> K_ESC
             WITH OBJECT oTBrowse
                DO WHILE .NOT. :stabilize()
                ENDDO
                nKey := Inkey(0)
                SWITCH nKey
                   CASE K_UP
                     :up()       ; EXIT
                   CASE K_DOWN
                     :down()     ; EXIT
                   CASE K_LEFT
                     :left()     ; EXIT
                   CASE K_RIGHT
                     :right()    ; EXIT
                   CASE K_PGUP
                     :pageUp()   ; EXIT
                   CASE K_PGDN
                     :pageDown() ; EXIT
                   CASE K_HOME
                     :home()     ; EXIT
                   CASE K_END
                     :end()      ; EXIT
                END
             END
          ENDDO
          CLOSE Customer
       RETURN

Seealso

CLASS, METHOD

DATA

 

DATA

 

Alternate syntax for VAR: instance variable for the objects.

Syntax

      DATA <DataName1> [,<DataNameN>] [ AS <type> ] [ INIT <uValue> ]
      [[EXPORTED | VISIBLE] | [PROTECTED] | [HIDDEN]] [READONLY | RO]

Arguments

<DataName1> Name of the DATA

<type> Optional data type specification from the following: Character, Numeric, Date, Logical, Codeblock, Nil.

<uValue> Optional initial value when creating a new object.

EXPORTED Specifies that this DATA is accessible to functions and methods outside of the class. VISIBLE is a synonym for EXPORTED.

PROTECTED Specifies that this DATA is only accessible to functions and methods within this class and its subclasses.

HIDDEN Specifies that this DATA is only accessible to the class where it was defined, and is not inherited by the subclasses.

READONLY Restricts assignment to the variable. If specified with the EXPORTED clause, assignment is only permitted from the current class and its subclasses. If specified with the PROTECTED clause, assignment is only permitted from the current class. RO is a synonym for READONLY.

Description

DATA elements can also be thought of as the “properties” of an object. They can be of any data type, including codeblock. Once an object has been created, the DATA elements are referenced with the colon (:) as in MyObject:Heading := “Last name”. Usually a class also defines methods to manipulate the DATA.

You can use the “AS <type>” clause to enforce that the DATA is maintained as a certain type. Otherwise it will take on the type of whatever value is first assigned to it.

Use the “INIT <uValue>” clause to initialize that DATA to <uValue> whenever a new object is created.

VAR can be a synonym for DATA, or it can use a slightly different syntax for compatibility with other dialects.

Examples

      CREATE CLASS TBColumn

         DATA Block      // Code block to retrieve data for the column
         DATA Cargo      // User-definable variable
         DATA ColorBlock // Code block that determines color of data items
         DATA ColSep     // Column separator character
         DATA DefColor   // Array of numeric indexes into the color table
         DATA Footing    // Column footing
         DATA FootSep    // Footing separator character
         DATA Heading    // Column heading
         DATA HeadSep    // Heading separator character
         DATA Width      // Column display width
         DATA ColPos     // Temporary column position on screen

         METHOD New()    // Constructor

      ENDCLASS

Compliance

Harbour

Platforms

All

Seealso

Object Oriented Programming, CLASS, METHOD, CLASSDATA, VAR

CLASSDATA

 

CLASSDATA

Define a CLASSDATA variable for a class (NOT for an Object!)

Syntax

      CLASSDATA <DataName1> [,<DataNameN>] [ AS <type> ] [ INIT <uValue> ]

Arguments

<DataName1> Name of the DATA

<type> Optional data type specification from the following: Character, Numeric, Date, Logical, Codeblock, Nil

<uValue> Optional initial value at program startup

Description

CLASSDATA variables can also be thought of as the “properties” of an entire class. Each CLASSDATA exists only once, no matter how many objects are created. A common usage is for a counter that is incremented whenever an object is created and decremented when one is destroyed, thus monitoring the number of objects in existence for this class.

You can use the “AS <type>” clause to enforce that the CLASSDATA is maintained as a certain type. Otherwise it will take on the type of whatever value is first assigned to it. Use the “INIT <uValue>” clause to initialize that DATA to <uValue> whenever the class is first used.

Examples

      CREATE CLASS TWindow
         DATA   hWnd, nOldProc
         CLASSDATA lRegistered AS LOGICAL
      ENDCLASS

Compliance

Harbour

Platforms

All

Seealso

Object Oriented Programming, CLASS, METHOD, DATA

HBClass()

HBClass()

HBClass() is used in the creation of all classes

Syntax

      oClass := HBClass():New("TMyClass")

        -or-

      HBClass() is usually accessed by defining a class with the commands
      defined in hbclass.h:

        CLASS HBGetList    // Calls HBClass() to create the HBGetList class
           ...
        ENDCLASS

Returns

An instance of the HBClass Class. This special object’s :New() method can then create the classes you define.

Description

HBClass is a class that … The class methods are as follows:

New() Create a new instance of the class

Examples

      FUNCTION TestObject()
         LOCAL oObject

         oObject := HBClass():New( "TMyClass" )
         oObject:End()

         RETURN NIL

Compliance

Object Oriented syntax in Harbour is compatible with CA-Cl*pper.

However CA-Cl*pper only allowed creation of objects from a few standard classes, and did not let the programmer create new classes.

In Harbour, you can create your own classes–complete with Methods, Instance Variables, Class Variables and Inheritance. Entire applications can be designed and coded in Object Oriented style.

Platforms

All

Files

Library is core

Seealso

__objHasData(), Object Oriented Programming, CLASS

TBrowseNew()

TBrowseNew()

Create a Browse Object

Constructor

TBrowseNew(<nTop>, <nLeft>, <nBottom>, <nRight>) –> <oBrowse>

Arguments

 
      <nTop>    Top Row

      <nLeft>   Top Left Column

      <nBottom> Bottom Row

      <nRight>  Bottom Right Column

Returns

<oBrowse> An new Browse Object

Description

This function set up a browsing window at top-left coordinates of <nTop>, <nLeft> to bottom-right coordinates of <nBottom>, <nRight>.

To browse Database files use TBrowseDB() function insted.

Datanolink

 
      :aColumns       Array to hold all browse columns

      :autoLite       Logical value to control highlighting

      :cargo          User-definable variable

      :colorSpec      Color table for the TBrowse display

      :colPos         Current cursor column position

      :colSep         Column separator character

      :footSep        Footing separator character

      :freeze         Number of columns to freeze

      :goBottomBlock  Code block executed by TBrowse:goBottom()

      :goTopBlock     Code block executed by TBrowse:goTop()

      :headSep        Heading separator character

      :hitBottom      Indicates the end of available data

      :hitTop         Indicates the beginning of available data

      :leftVisible    Indicates position of leftmost unfrozen column 
                      in display

      :nBottom        Bottom row number for the TBrowse display

      :nLeft          Leftmost column for the TBrowse display

      :nRight         Rightmost column for the TBrowse display

      :nTop           Top row number for the TBrowse display

      :rightVisible   Indicates position of rightmost unfrozen column
      in display

      :rowCount       Number of visible data rows in the TBrowse
      display

      :rowPos         Current cursor row position

      :skipBlock      Code block used to reposition data source

      :stable         Indicates if the TBrowse object is stable

      :aRedraw        Array of logical items indicating, is appropriate
                      row need to be redraw

      :RelativePos    Indicates record position relatively position of
                      first record on the screen

      :lHeaders       Internal variable which indicates whether there
                      are column footers to paint

      :lFooters       Internal variable which indicates whether there
                      are column footers to paint

      :aRect          The rectangle specified with ColorRect()

      :aRectColor     The color positions to use in the rectangle
                      specified with ColorRect()

      :aKeys        Holds the Default movement keys

Methodslink

 
      AddColumn() Adds an new TBColumn object to the current Browse

      Applykey()  Perform the Browse Key movement

      SetKey()    Add an New key to the Keyboard dictionary

Methodsnolink

New(nTop, nLeft, nBottom, nRight) Create an new Browse class and set the default values

      Down()       Moves the cursor down one row

      End()        Moves the cursor to the rightmost visible data column

      GoBottom()   Repositions the data source to the bottom of file

      GoTop()      Repositions the data source to the top of file

      Home()       Moves the cursor to the leftmost visible data column

      Left()       Moves the cursor left one column

      PageDown()   Repositions the data source downward

      PageUp()     Repositions the data source upward

      PanEnd()     Moves the cursor to the rightmost data column

      PanHome()    Moves the cursor to the leftmost visible data column

      PanLeft()    Pans left without changing the cursor position

      PanRight()   Pans right without changing the cursor position

      Right()      Moves the cursor right one column

      Up()         Moves the cursor up one row

      ColCount()    Return the Current number of Columns

      ColorRect()   Alters the color of a rectangular group of cells

      ColWidth( nColumn )  Returns the display width of a particular column

      Configure( nMode )   Reconfigures the internal settings of the TBrowse
                           object nMode is an undocumented parameter in CA-Cl*pper

      LeftDetermine()      Determine leftmost unfrozen column in display

      DeHilite()           Dehighlights the current cell

      DelColumn( nPos )    Delete a column object from a browse

      ForceStable()        Performs a full stabilization

      GetColumn( nColumn ) Gets a specific TBColumn object

      Hilite()             Highlights the current cell

      InsColumn( nPos, oCol )   Insert a column object in a browse

      Invalidate()        Forces entire redraw during next stabilization

      RefreshAll()        Causes all data to be recalculated during the next
                          stabilize

      RefreshCurrent()    Causes the current row to be refilled and repainted
                          on next stabilize

      SetColumn( nColumn, oCol )   Replaces one TBColumn object with another

      Stabilize()          Performs incremental stabilization

      DispCell( nColumn, cColor )  Displays a single cell

Examples

      See tests/testbrw.prg

Compliance

This functions is Compatible with CA-Cl*pper 5.2. The applykey() and SetKey() methods are only visible if HB_COMPAT_C53 is defined.

Platforms

All

Files

Library is core

Seealso

TBrowseNew(), TBColumnNew()

VAR

VAR

Alternate syntax for VAR: instance variable for the objects.

Syntax

      VAR <DataName1> [, <DataNameN>] [ AS <type> ] [ INIT <uValue> ]
      [[EXPORTED | VISIBLE] | [PROTECTED] | [HIDDEN]] [READONLY | RO]

Arguments

<DataName1> Name of the VAR

<type> Optional data type specification from the following: Character, Numeric, Date, Logical, Codeblock, Nil.

<uValue> Optional initial value when creating a new object.

EXPORTED Specifies that this VAR is accessible to functions and methods outside of the class. VISIBLE is a synonym for EXPORTED.

PROTECTED Specifies that this VAR is only accessible to functions and methods within this class and its subclasses.

HIDDEN Specifies that this VAR is only accessible to the class where it was defined, and is not inherited by the subclasses.

READONLY Restricts assignment to the variable. If specified with the EXPORTED clause, assignment is only permitted from the current class and its subclasses. If specified with the PROTECTED clause, assignment is only permitted from the current class. RO is a synonym for READONLY.

Description

VAR elements can also be thought of as the “properties” of an object. They can be of any data type, including codeblock. Once an object has been created, the VAR elements are referenced with the colon (:) as in MyObject:Heading := “Last name”. Usually a class also defines methods to manipulate the VAR.

You can use the “AS <type>” clause to enforce that the VAR is maintained as a certain type. Otherwise it will take on the type of whatever value is first assigned to it.

Use the “INIT <uValue>” clause to initialize that VAR to <uValue> whenever a new object is created.

VAR can be a synonym for VAR, or it can use a slightly different syntax for compatibility with other dialects.

Examples

      CREATE CLASS TBColumn

         VAR Block      // Code block to retrieve data for the column
         VAR Cargo      // User-definable variable
         VAR ColorBlock // Code block that determines color of data items
         VAR ColSep     // Column separator character
         VAR DefColor   // Array of numeric indexes into the color table
         VAR Footing    // Column footing
         VAR FootSep    // Footing separator character
         VAR Heading    // Column heading
         VAR HeadSep    // Heading separator character
         VAR Width      // Column display width
         VAR ColPos     // Temporary column position on screen

         METHOD New()   // Constructor

      ENDCLASS

Compliance

Harbour

Platforms

All

Seealso

Object Oriented Programming, CLASS, METHOD, CLASS VAR, VAR