nc_sdw_listview


Ancestor nc_service_datawindow

Hierarchy
nc_sdw_listview
nc_service_datawindow
nc_ec_service
nonvisualobject

Author none

Library dwlvcols.pbl

Description This service allows the user to interact with the datawindow column headers of a tabular style datawindow as if the header was a listview control. Users can resize the column headers and double click the header to have it resize automatically to the maximum column width. The service also features a serialization type interface for recording the column widths and later restoring the column widths.

This service monitors the event queue for the following event types:

  • mousemove
  • clicked or lbuttondown
  • doubleclicked
  • lbuttonup (must be mapped as pbm_lbuttonup)

    You may want to inherit this service and override the following functions to call the correct functions in your class library:

  • GetSetting
  • SetSetting
  • TextWidth
  • SetCapture
  • GetCapture
  • ParentWindow

  • Usage Add the service to the datawindow manager.

    Model
    nc_sdw_listview
    Protected:
    Long il_Gaps[]
    Long il_NGaps, il_CurGap
    Long il_HeaderHeight
    Long il_I
    String is_ObjectNames[]
    String is_ColumnNames[]
    Boolean ib_Hot
    Boolean ib_Resize
    Constant Long cil_MinWidth=10
    // added this so remove the requirement for my class library
    Window iw_ParentWindow
    DoubleClick (as_name) returns (none)
    DuplicateColumn (ai_fromgap, ai_togap) returns (none)
    ExtractColumns (as_Widths, ai_Widths[]) returns integer
    FindGap (xpos) returns (none)
    idw_parent (adw_dw) returns (none)
    LoadColumns (as_widths) returns integer
    MouseResize (xpos) returns (none)
    ParentWindow () returns window
    Perform (as_event, aa_args[]) returns integer
    releasecapture () returns (none)
    ResizeColumns (xpos, ai_col) returns (none)
    SaveColumns () returns string
    setcapture () returns (none)
    setparentwindow (aw_W) returns (none)

    Functions

    DoubleClick

    Description This fucntion works out the maximum width of the column and resizes the column to fit this size.
    Return (none)
    Access public
    Arguments
    Argument DataType Description
    as_Name string The name of the column header double clicked.

    Usage this.DoubleClick( 'ken_t' )

    DuplicateColumn

    Description Resize a column to be the same width as the specified column.
    Return (none)
    Access public
    Arguments
    Argument DataType Description
    ai_FromGap integer Columns whose width we want to use.
    ai_ToGap integer Column that want the new width.

    Usage nsdw_lv.DuplicateColumns( 6, 2 )

    ExtractColumns

    Description Extract the internal column width settings from the string created by the SaveColumns function and view and return them in an encoded string.
    Return integer
    The number of column widths extracted from the string.
    Access protected
    Arguments
    Argument DataType Description
    as_Widths string encoded string to remove the settings from.
    ai_Widths[] integer Reference variable to load the widths into.

    Usage li_Widths = lnca_lv.ExtractColumns( as_Cols, li_Width )

    FindGap

    Description Figure out if the mouse is positioned over a gap in the column headers. If it is then switch the mouse pointer.
    Return (none)
    Access protected
    Arguments
    Argument DataType Description
    xpos integer X Position of the mouse.

    Usage nsdw_LV.FindGap( xpos )

    idw_parent

    Description This function overrides the ancestor function so that we can interagate the datawindow and cache some values for later use. This function is called automatically by the datawindow manager.

    Function gets all the header text items, ending in _t and check that they have matching columns. Load them into an array then sort them in to ascending sequence. Then calculate where the gaps are. NOTE THIS ROUTINE ASSUMES THE DATAWINDOW UNITS ARE PIXELS!

    Return (none)
    Access public
    Arguments
    Argument DataType Description
    adw_dw datawindow Datawindow being processed by the manager.

    Usage lsdw_Col.idw_Parent( adw_DW )

    LoadColumns

    Description Load the columns widths create by the savecolumns function back into the datawindow.
    Return integer
  • 1 all loaded ok
  • -1 load failed
  • Access public
    Arguments
    Argument DataType Description
    as_Widths string The encoded width string containing the column widths.

    Usage lsdw_LV.LoadColumns( ls_Widths )

    MouseResize

    Description Call the resize columns function.
    Return (none)
    Access protected
    Arguments
    Argument DataType Description
    xpos integer X Position of the mouse drag that resized the columns.

    Usage nsdw_lv.MouseResize( 600 )

    ParentWindow

    Description Insulation function used to return the parent window of the datawindow. You should override this function with your class library specific code.
    Return window
    Handle of the datawindow's parent window
    Access protected
    Arguments none
    Usage lw_Win = this.ParentWindow()

    Perform

    Description This function recieves the notification of the events from the datawindow. The code is kept to a minimum because we will be recieveing mousemove notifications of which there will be loads so we need to execute this function as quickly as possible.
    Return integer
  • -1, error occured
  • 0, no processing
  • 1, event was processed
  • Access public
    Arguments
    Argument DataType Description
    as_Event string Event that occured
    aa_Args[] any Arguments to the event

    Usage lsdw_Cols.Perform( 'clicked', la_Args )

    releasecapture

    Description Release the mouse capture.
    Return (none)
    Access protected
    Arguments none
    Usage none

    ResizeColumns

    Description Resize the two columns to the new location the left hand column's width should be X to the new pos if the new pos < x then = 0 the right hand column X and width should change to be the difference between current and new. We always recalc from scratch as we may have missed some mouse move events due to queue overflow.
    Return (none)
    Access protected
    Arguments
    Argument DataType Description
    xpos integer X Position of the mouse drag that resized the columns.
    ai_col integer Column that was resized.

    Usage nsdw_lv.ResizeColumns( 6, 2 )

    SaveColumns

    Description Extract the internal column width settings and return them in an encoded string.
    Return string
    An encoded string containing the columns widths
    Access public
    Arguments none
    Usage ls_ColWidths = lsdw_LV.SaveColumns()

    setcapture

    Description Capture all mouse movements.
    Return (none)
    Access protected
    Arguments none
    Usage none

    setparentwindow

    Description none
    Return (none)
    Access public
    Arguments
    Argument DataType Description
    aw_W window

    Usage none
    Events

    constructor
    Description none

    References
    UsesUsed By
    nc_sdw_listview
    nc_service_datawindow
    nc_sdw_listview


    Document Generated: 6/16/01 13:33:49