[System] You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following Harbour conventions. Use proper Hungarian notation for variable names (c=character, n=numeric, l=logical, a=array, o=object, b=codeblock).

[User] Implement these Harbour functions: Harbour contribution module 'gtwvw' (): contrib/gtwvw/tests/cb6.prg. Provides functions: CBhandler, CBreader, SetWinFocus, MyAlert. Contains procedures: Main. This file provides platform-specific functionality

[Assistant]
#require "gtwvw"

#include "getexit.ch"
#include "inkey.ch"

#define WVW_CB_KBD_STANDARD  0
#define WVW_CB_KBD_CLIPPER   1

STATIC s_nCB_Kbd := WVW_CB_KBD_CLIPPER

STATIC s_aComboList := {}

MEMVAR __nCBid__, __temp__

#xcommand @ <row>, <col> COMBOBOX <var>                        ;
      OPTIONS <aOptions>                    ;
      WIDTH <nWidth>   =>                   ;
      ;
      ;
      __nCBid__ := wvw_cbCreate( NIL, <row>, <col>, <nWidth>, ;
      <aOptions>, ;
      {| nWinNum, nId, nEvent, nIndex, temp |     ;
      CBhandler( nWinNum, nId, nEvent, nIndex, <"var">, GetList ), HB_SYMBOL_UNUSED( temp );
      },                                          ;
      NIL, NIL, s_nCB_Kbd, NIL );                     ;
      AAdd( s_aComboList, { __nCBid__, <"var"> } );                        ;
      __temp__ := wvw_cbFindString( NIL, __nCBid__, <var> );             ;
      iif( __temp__ >= 0, wvw_cbSetIndex( NIL, __nCBid__, __temp__ ), NIL );   ;
      SetPos( <row>, <col> );                                              ;
      AAdd( GetList, _GET_( <var>, <"var">, Replicate( "X", <nWidth> ),, ) ) ;   ;
      ATail( GetList ):cargo := __nCBid__;                                ;
      ATail( GetList ):reader := {| get | CBreader( get ) }

PROCEDURE Main()

   LOCAL getlist := {}
   LOCAL mname := PadR( "Budyanto Dj.", 30 ), msex := "MALE", mage := 17, mstat := "married"
   LOCAL __nCBid__, __temp__

#if defined( __HBSCRIPT__HBSHELL ) .AND. defined( __PLATFORM__WINDOWS )
   hbshell_gtSelect( "GTWVW" )
#endif

   wvw_SetCodepage( NIL, 255 )
   wvw_SetLineSpacing( NIL, 4 )
   wvw_SetLSpaceColor( NIL, 0 )
   wvw_cbSetFont( NIL, "Arial", 14 )

   CLS

   s_aComboList := {}

   @ 0, 0 SAY     "Name :" GET mname PICT "@K"
   @ 1, 0 SAY     "Sex  :"
   @ 1, 7 COMBOBOX msex OPTIONS { "Male", "Female", "Unknown" } WIDTH 10
   @ 2, 0 SAY     "Stat :"
   @ 2, 7 COMBOBOX mstat OPTIONS { "Married", "Unmarried", "Widowed" } WIDTH 15
   @ 3, 0 SAY     "age  :" GET mage PICT "999"
   READ

   AEval( s_aComboList, {| x | wvw_cbEnable( NIL, x[ 1 ], .F. ) } )

   DevPos( 5, 0 )
   ? "name: '" + mname + "'"
   ? "sex : '" + msex + "'"
   ? "stat: '" + mstat + "'"
   ? "age : " + hb_ntos( mage )
   ? "that's what you've got from GET"
   Inkey( 0 )

   AEval( s_aComboList, {| x | wvw_cbDestroy( NIL, x[ 1 ] ) } )
   s_aComboList := {}

   ?
   ? "Comboboxes have now been removed"
   ? "Now press ESC to exit"

   DO WHILE Inkey( 0 ) != K_ESC
   ENDDO

   RETURN

FUNCTION CBhandler( nWinNum, nId, nEvent, nIndex, cVar, GetList )

   LOCAL i, ccursel
   LOCAL oGet := GetActive()

   HB_SYMBOL_UNUSED( nIndex )

   IF Empty( GetList )
      MyAlert( "Bad practice: you left an active combobox, but READ already ended" )
      RETURN NIL
   ENDIF

   DO CASE
   CASE nEvent == 3
      i := AScan( GetList, {| x | x:Name == cVar } )
      IF i > 0

         IF oGet:HasFocus

            SetWinFocus( nWinNum )
            MSetPos( GetList[ i ]:row, GetList[ i ]:col + 1 )
            hb_keyPut( K_LBUTTONDOWN )
         ENDIF

      ELSE

      ENDIF

   CASE nEvent == 4

      cCurSel := wvw_cbGetCurText( nWinNum, nId )
      oGet:varput( cCurSel )
      oGet:display()

   ENDCASE

   RETURN NIL

FUNCTION CBreader( oGet )

   LOCAL nKey, bKeyBlock
   LOCAL oGetList := __GetListActive()

   IF ! wvw_cbIsFocused( NIL, oGet:cargo )
      wvw_cbSetFocus( NIL, oGet:cargo )
   ENDIF

   oGet:setfocus()
   nKey := Inkey( 0 )

   IF nKey == K_ENTER

      oGet:exitState := GE_DOWN

   ELSEIF nKey == K_UP
      oGet:exitState := GE_UP

   ELSEIF nKey == K_SH_TAB
      oGet:exitState := GE_UP

   ELSEIF nKey == K_DOWN

      oGet:exitState := GE_DOWN

   ELSEIF nKey == K_TAB
      oGet:exitState := GE_DOWN

   ELSEIF nKey == K_ESC
      IF Set( _SET_ESCAPE )
         oGet:exitState := GE_ESCAPE
      ENDIF

   ELSEIF nKey == K_PGUP
      oGet:exitState := GE_WRITE

   ELSEIF nKey == K_PGDN
      oGet:exitState := GE_WRITE

   ELSEIF nKey == K_CTRL_HOME
      oGet:exitState := GE_TOP

   ELSEIF nKey == K_LBUTTONDOWN .OR. nKey == K_LDBLCLK

      IF ! Empty( HitTest( oGetList:aGetList, MRow(), MCol(), NIL ) )
         oGet:exitState := GE_MOUSEHIT
      ELSE
         oGet:exitState := GE_NOEXIT
      ENDIF

   ELSEIF HB_ISBLOCK( bKeyBlock := SetKey( nKey ) )
      oGetList:GetDoSetKey( bKeyBlock )
      oGet:exitState := GE_NOEXIT

   ENDIF

   IF oGet:exitState != GE_NOEXIT
      SetWinFocus( NIL )
      oGet:killfocus()
   ENDIF

   RETURN NIL

STATIC FUNCTION SetWinFocus( nWinNum )

   LOCAL hWnd := wvw_GetWindowHandle( nWinNum )

   win_SetFocus( hWnd )

   RETURN NIL

STATIC FUNCTION MyAlert( cMsg, par2, par3, par4, par5, par6 )

   LOCAL nLineSpacing := wvw_SetLineSpacing( NIL, 0 )
   LOCAL retval := Alert( cMsg, par2, par3, par4, par5, par6 )

   wvw_SetLineSpacing( NIL, nLineSpacing )

   RETURN retval


[System] You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following Harbour conventions. Use proper Hungarian notation for variable names (c=character, n=numeric, l=logical, a=array, o=object, b=codeblock).

[User]
Here is a Harbour (xBase/Clipper) implementation:

Header file for contribution module 'hbfimage' (FreeImage library wrapper): contrib/hbfimage/freeimag.ch. Defines 10 constants including: FREEIMAGE_CH, FI_RGBA_RED, FI_RGBA_GREEN, FI_RGBA_BLUE, FI_RGBA_ALPHA. Defines error handling constants and codes

[Assistant]
#ifndef FREEIMAGE_CH
#define FREEIMAGE_CH

#ifndef FREEIMAGE_BIGENDIAN

#define FI_RGBA_RED           2
#define FI_RGBA_GREEN         1
#define FI_RGBA_BLUE          0
#define FI_RGBA_ALPHA         3
#define FI_RGBA_RED_MASK      0x00FF0000
#define FI_RGBA_GREEN_MASK    0x0000FF00
#define FI_RGBA_BLUE_MASK     0x000000FF
#define FI_RGBA_ALPHA_MASK    0xFF000000
#define FI_RGBA_RED_SHIFT     16
#define FI_RGBA_GREEN_SHIFT   8
#define FI_RGBA_BLUE_SHIFT    0
#define FI_RGBA_ALPHA_SHIFT   24
#else

#define FI_RGBA_RED           0
#define FI_RGBA_GREEN         1
#define FI_RGBA_BLUE          2
#define FI_RGBA_ALPHA         3
#define FI_RGBA_RED_MASK      0xFF000000
#define FI_RGBA_GREEN_MASK    0x00FF0000
#define FI_RGBA_BLUE_MASK     0x0000FF00
#define FI_RGBA_ALPHA_MASK    0x000000FF
#define FI_RGBA_RED_SHIFT     24
#define FI_RGBA_GREEN_SHIFT   16
#define FI_RGBA_BLUE_SHIFT    8
#define FI_RGBA_ALPHA_SHIFT   0
#endif

#define FI_RGBA_RGB_MASK    (FI_RGBA_RED_MASK|FI_RGBA_GREEN_MASK|FI_RGBA_BLUE_MASK)

#define FI16_555_RED_MASK     0x7C00
#define FI16_555_GREEN_MASK   0x03E0
#define FI16_555_BLUE_MASK    0x001F
#define FI16_555_RED_SHIFT    10
#define FI16_555_GREEN_SHIFT  5
#define FI16_555_BLUE_SHIFT   0
#define FI16_565_RED_MASK     0xF800
#define FI16_565_GREEN_MASK   0x07E0
#define FI16_565_BLUE_MASK    0x001F
#define FI16_565_RED_SHIFT    11
#define FI16_565_GREEN_SHIFT  5
#define FI16_565_BLUE_SHIFT   0

#define FIICC_DEFAULT         0x00
#define FIICC_COLOR_IS_CMYK   0x01

#define FIF_UNKNOWN  -1
#define FIF_BMP      0
#define FIF_ICO      1
#define FIF_JPEG     2
#define FIF_JNG      3
#define FIF_KOALA    4
#define FIF_LBM      5
#define FIF_IFF      FIF_LBM
#define FIF_MNG      6
#define FIF_PBM      7
#define FIF_PBMRAW   8
#define FIF_PCD      9
#define FIF_PCX      10
#define FIF_PGM      11
#define FIF_PGMRAW   12
#define FIF_PNG      13
#define FIF_PPM      14
#define FIF_PPMRAW   15
#define FIF_RAS      16
#define FIF_TARGA    17
#define FIF_TIFF     18
#define FIF_WBMP     19
#define FIF_PSD      20
#define FIF_CUT      21
#define FIF_XBM      22
#define FIF_XPM      23
#define FIF_DDS      24
#define FIF_GIF      25
#define FIF_HDR      26

#define FIT_UNKNOWN  0
#define FIT_BITMAP   1
#define FIT_UINT16   2
#define FIT_INT16    3
#define FIT_UINT32   4
#define FIT_INT32    5
#define FIT_FLOAT    6
#define FIT_DOUBLE   7
#define FIT_COMPLEX  8
#define FIT_RGB16    9
#define FIT_RGBA16   10
#define FIT_RGBF     11
#define FIT_RGBAF    12

#define FIC_MINISWHITE  0
#define FIC_MINISBLACK  1
#define FIC_RGB         2
#define FIC_PALETTE     3
#define FIC_RGBALPHA    4
#define FIC_CMYK        5

#define FIQ_WUQUANT     0
#define FIQ_NNQUANT     1

#define FID_FS           0
#define FID_BAYER4x4     1
#define FID_BAYER8x8     2
#define FID_CLUSTER6x6   3
#define FID_CLUSTER8x8   4
#define FID_CLUSTER16x16 5

#define FIJPEG_OP_NONE        0
#define FIJPEG_OP_FLIP_H      1
#define FIJPEG_OP_FLIP_V      2
#define FIJPEG_OP_TRANSPOSE   3
#define FIJPEG_OP_TRANSVERSE  4
#define FIJPEG_OP_ROTATE_90   5
#define FIJPEG_OP_ROTATE_180  6
#define FIJPEG_OP_ROTATE_270  7

#define FITMO_DRAGO03         0
#define FITMO_REINHARD05      1

#define FILTER_BOX         0
#define FILTER_BICUBIC     1
#define FILTER_BILINEAR    2
#define FILTER_BSPLINE     3
#define FILTER_CATMULLROM  4
#define FILTER_LANCZOS3    5

#define FICC_RGB     0
#define FICC_RED     1
#define FICC_GREEN   2
#define FICC_BLUE    3
#define FICC_ALPHA   4
#define FICC_BLACK   5
#define FICC_REAL    6
#define FICC_IMAG    7
#define FICC_MAG     8
#define FICC_PHASE   9

#define FIDT_NOTYPE     0
#define FIDT_BYTE       1
#define FIDT_ASCII      2
#define FIDT_SHORT      3
#define FIDT_LONG       4
#define FIDT_RATIONAL   5
#define FIDT_SBYTE      6
#define FIDT_UNDEFINED  7
#define FIDT_SSHORT     8
#define FIDT_SLONG      9
#define FIDT_SRATIONAL  10
#define FIDT_FLOAT      11
#define FIDT_DOUBLE     12
#define FIDT_IFD        13
#define FIDT_PALETTE    14

#define FIMD_NODATA          -1
#define FIMD_COMMENTS        0
#define FIMD_EXIF_MAIN       1
#define FIMD_EXIF_EXIF       2
#define FIMD_EXIF_GPS        3
#define FIMD_EXIF_MAKERNOTE  4
#define FIMD_EXIF_INTEROP    5
#define FIMD_IPTC            6
#define FIMD_XMP             7
#define FIMD_GEOTIFF         8
#define FIMD_ANIMATION       9
#define FIMD_CUSTOM          10

#define BMP_DEFAULT         0
#define BMP_SAVE_RLE        1
#define CUT_DEFAULT         0
#define DDS_DEFAULT         0
#define GIF_DEFAULT         0
#define GIF_LOAD256         1
#define GIF_PLAYBACK        2
#define HDR_DEFAULT         0
#define ICO_DEFAULT         0
#define ICO_MAKEALPHA       1
#define IFF_DEFAULT         0
#define JPEG_DEFAULT        0
#define JPEG_FAST           1
#define JPEG_ACCURATE       2
#define JPEG_QUALITYSUPERB  0x80
#define JPEG_QUALITYGOOD    0x100
#define JPEG_QUALITYNORMAL  0x200
#define JPEG_QUALITYAVERAGE 0x400
#define JPEG_QUALITYBAD     0x800
#define JPEG_CMYK           0x1000
#define KOALA_DEFAULT       0
#define LBM_DEFAULT         0
#define MNG_DEFAULT         0
#define PCD_DEFAULT         0
#define PCD_BASE            1
#define PCD_BASEDIV4        2
#define PCD_BASEDIV16       3
#define PCX_DEFAULT         0
#define PNG_DEFAULT         0
#define PNG_IGNOREGAMMA     1
#define PNM_DEFAULT         0
#define PNM_SAVE_RAW        0
#define PNM_SAVE_ASCII      1
#define PSD_DEFAULT         0
#define RAS_DEFAULT         0
#define TARGA_DEFAULT       0
#define TARGA_LOAD_RGB888   1
#define TIFF_DEFAULT        0
#define TIFF_CMYK           0x0001
#define TIFF_PACKBITS       0x0100
#define TIFF_DEFLATE        0x0200
#define TIFF_ADOBE_DEFLATE  0x0400
#define TIFF_NONE           0x0800
#define TIFF_CCITTFAX3      0x1000
#define TIFF_CCITTFAX4      0x2000
#define TIFF_LZW            0x4000
#define TIFF_JPEG           0x8000
#define WBMP_DEFAULT        0
#define XBM_DEFAULT         0
#define XPM_DEFAULT         0

#endif


[System] You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following Harbour conventions. Use proper Hungarian notation for variable names (c=character, n=numeric, l=logical, a=array, o=object, b=codeblock).

[User] Implement this Harbour module: Harbour Runtime Library file: src/rtl/teditor.prg. Defines classes: HBEditor. This file implements object-oriented classes using Harbour's class system

[Assistant]
#include "hbclass.ch"

#include "button.ch"
#include "color.ch"
#include "error.ch"
#include "fileio.ch"
#include "inkey.ch"
#include "setcurs.ch"

#pragma linenumber=on

#define _REFRESH_NONE   0
#define _REFRESH_LINE   1
#define _REFRESH_ALL    2

CREATE CLASS HBEditor

   EXPORTED:

   METHOD LoadFile( cFileName )
   METHOD LoadText( cText )
   METHOD SaveFile()

   METHOD AddLine( cLine, lSoftCR )
   METHOD InsertLine( cLine, lSoftCR, nRow )
   METHOD RemoveLine( nRow )
   METHOD GetLine( nRow )
   METHOD LineLen( nRow )
   METHOD ReformParagraph()
   METHOD GotoLine( nRow )
   METHOD LineCount()

   METHOD GetText( lSoftCR )

   METHOD Display()
   METHOD RefreshLine()
   METHOD LineColor( nRow )

   METHOD GoTo( nRow, nCol, nRefreshMode )
   METHOD MoveCursor( nKey )
   METHOD InsertState( lInsState )
   METHOD Edit( nPassedKey )
   METHOD ExitState()

   METHOD KeyboardHook( nKey )
   METHOD IdleHook()

   METHOD Resize( nTop, nLeft, nBottom, nRight )
   METHOD SetColor( cColorString )
   METHOD Hilite()
   METHOD DeHilite()

   METHOD Row()
   METHOD Col()
   METHOD RowPos()
   METHOD ColPos()
   METHOD Saved()
   METHOD Changed()
   METHOD IsWordWrap()
   METHOD WordWrapCol()
   METHOD hitTest( nMRow, nMCol )

   MESSAGE RefreshWindow() METHOD Display()

   METHOD Init( cText, nTop, nLeft, nBottom, ;
                nRight, lEditMode, nLineLength, nTabSize, ;
                nTextRow, nTextCol, nWndRow, nWndCol )

   PROTECTED:

   VAR cFile          AS STRING      INIT ""

   VAR aText          AS ARRAY       INIT {}

   VAR nTop           AS INTEGER
   VAR nLeft          AS INTEGER
   VAR nBottom        AS INTEGER
   VAR nRight         AS INTEGER

   VAR nFirstCol      AS INTEGER
   VAR nFirstRow      AS INTEGER
   VAR nRow           AS INTEGER
   VAR nCol           AS INTEGER

   VAR nNumCols       AS INTEGER
   VAR nNumRows       AS INTEGER

   VAR nTabWidth      AS INTEGER     INIT 4
   VAR lEditAllow     AS LOGICAL     INIT .T.
   VAR lSaved         AS LOGICAL     INIT .F.
   VAR lWordWrap      AS LOGICAL     INIT .F.
   VAR nWordWrapCol   AS INTEGER     INIT 0
   VAR lDirty         AS LOGICAL     INIT .F.
   VAR lExitEdit      AS LOGICAL     INIT .F.

   VAR cColorSpec     AS CHARACTER

   METHOD BrowseText( nPassedKey )

ENDCLASS

METHOD Init( cText, nTop, nLeft, nBottom, nRight, lEditMode, nLineLength, ;
             nTabSize, nTextRow, nTextCol, nWndRow, nWndCol ) CLASS HBEditor

   ::cColorSpec := SetColor()

   ::lEditAllow := hb_defaultValue( lEditMode, .T. )

   IF HB_ISNUMERIC( nLineLength ) .AND. nLineLength >= 1
      ::lWordWrap := .T.
      ::nWordWrapCol := nLineLength
   ENDIF

   IF HB_ISNUMERIC( nTabSize ) .AND. nTabSize >= 1
      ::nTabWidth := Max( nTabSize, 2 )
   ENDIF

   ::LoadText( hb_defaultValue( cText, "" ) )
   ::InsertState( Set( _SET_INSERT ) )

   ::nRow := hb_defaultValue( nTextRow, 1 )
   ::nCol := hb_defaultValue( nTextCol, 0 ) + 1
   ::nFirstRow := ::nRow - hb_defaultValue( nWndRow, 0 )
   ::nFirstCol := ::nCol - hb_defaultValue( nWndCol, 0 )
   ::Resize( hb_defaultValue( nTop, 0 ), ;
             hb_defaultValue( nLeft, 0 ), ;
             hb_defaultValue( nBottom, MaxRow() ), ;
             hb_defaultValue( nRight, MaxCol() ) )

   RETURN Self

METHOD Resize( nTop, nLeft, nBottom, nRight ) CLASS HBEditor

   IF HB_ISNUMERIC( nTop )
      ::nTop := nTop
   ENDIF
   IF HB_ISNUMERIC( nLeft )
      ::nLeft := nLeft
   ENDIF
   IF HB_ISNUMERIC( nBottom )
      ::nBottom := nBottom
   ENDIF
   IF HB_ISNUMERIC( nRight )
      ::nRight := nRight
   ENDIF

   ::nNumCols := ::nRight - ::nLeft + 1
   ::nNumRows := ::nBottom - ::nTop + 1

   RETURN ::Goto( ::nRow, ::nCol )

METHOD LoadFile( cFileName ) CLASS HBEditor
   RETURN ::LoadText( hb_MemoRead( ::cFile := cFileName ) )

METHOD LoadText( cText ) CLASS HBEditor

   ::aText := Text2Array( cText, iif( ::lWordWrap, ::nWordWrapCol, ), ::nTabWidth )
   ::lDirty := .F.

   RETURN iif( ::nNumCols > 0, ::GoTo( 1, 1 ), Self )

METHOD SaveFile() CLASS HBEditor
   RETURN ! ::cFile == "" .AND. ;
          ! ::lDirty := ! hb_MemoWrit( ::cFile, ::GetText() )

METHOD AddLine( cLine, lSoftCR ) CLASS HBEditor

   AAdd( ::aText, HBTextLine():New( cLine, lSoftCR ) )

   RETURN Self

METHOD InsertLine( cLine, lSoftCR, nRow ) CLASS HBEditor

   hb_AIns( ::aText, nRow, HBTextLine():New( cLine, lSoftCR ), .T. )

   RETURN Self

METHOD RemoveLine( nRow ) CLASS HBEditor

   hb_ADel( ::aText, nRow, .T. )

   RETURN Self

METHOD GetLine( nRow ) CLASS HBEditor
   RETURN iif( nRow >= 1 .AND. nRow <= ::LineCount, ::aText[ nRow ]:cText, "" )

METHOD LineLen( nRow ) CLASS HBEditor
   RETURN hb_ULen( ::GetLine( nRow ) )

METHOD GetText( lSoftCR ) CLASS HBEditor

   LOCAL cText, cEOL, cSoftCR, oLine

   cEOL := hb_eol()
   cSoftCR := iif( ::lWordWrap, iif( hb_defaultValue( lSoftCR, .F. ), ;
                                     Chr( 141 ) + Chr( 10 ), "" ), cEOL )
   cText := ""
   FOR EACH oLine IN ::aText
      cText += oLine:cText
      IF ! oLine:__enumIsLast()
         cText += iif( oLine:lSoftCR, cSoftCR, cEOL )
      ENDIF
   NEXT

   RETURN cText

METHOD GotoLine( nRow ) CLASS HBEditor
   RETURN ::Goto( nRow, ::nCol )

METHOD LineCount() CLASS HBEditor
   RETURN Len( ::aText )

METHOD Display() CLASS HBEditor

   LOCAL nRow, nLine, nCount

   DispBegin()
   nRow := ::nTop
   nLine := ::nFirstRow
   nCount := ::nNumRows
   DO WHILE --nCount >= 0
      hb_DispOutAt( nRow++, ::nLeft, SubStrPad( ::GetLine( nLine ), ::nFirstCol, ::nNumCols ), ::LineColor( nLine++ ) )
   ENDDO
   DispEnd()

   RETURN Self

METHOD RefreshLine() CLASS HBEditor

   hb_DispOutAt( ::Row(), ::nLeft, SubStrPad( ::GetLine( ::nRow ), ::nFirstCol, ::nNumCols ), ::LineColor( ::nRow ) )

   RETURN Self

METHOD LineColor( nRow ) CLASS HBEditor

   HB_SYMBOL_UNUSED( nRow )

   RETURN ::cColorSpec

METHOD GoTo( nRow, nCol, nRefreshMode )

   LOCAL nFirstRow := ::nFirstRow, nFirstCol := ::nFirstCol

   hb_default( @nRefreshMode, _REFRESH_NONE )

   IF nRow < 1
      nRow := 1
   ELSEIF nRow > ::LineCount
      nRow := ::LineCount
   ENDIF
   IF nFirstRow < 1
      nFirstRow := 1
   ELSEIF nRow < nFirstRow
      nFirstRow := nRow
   ELSEIF nRow > nFirstRow + ::nNumRows - 1
      nFirstRow := nRow - ::nNumRows + 1
   ENDIF

   IF nCol == -1
      nCol := ::LineLen( nRow ) + 1
   ENDIF
   IF nCol < 1
      nCol := 1
   ELSEIF ::lWordWrap .AND. nCol > ::nWordWrapCol + 1
      nCol := ::nWordWrapCol + 1
   ENDIF
   IF nFirstCol < 1
      nFirstCol := 1
   ELSEIF nCol < nFirstCol
      nFirstCol := nCol
   ELSEIF nCol > nFirstCol + ::nNumCols - 1