home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / elistb.zip / READ.ME < prev    next >
Text File  |  1993-06-02  |  7KB  |  155 lines

  1. Revision 1.3
  2.  
  3. Contains fixes for flickering, searching and cleans up the message processing.
  4. Read this carefully if you looked at the first version (1.0 but not id'd as
  5. such.)
  6.  
  7. Thanks to Rick Fishman whose suggestions made things much better.
  8.  
  9.  
  10. NOTE:  This code is UNSUPPORTED!  Mail will not be answered unless you are
  11.        a "registered contributor".   You can become a registered contributor
  12.        by submitting a real bug (preferably with a fix) or a useful extension.
  13.  
  14.        The author, for want of a more rational judge :-) will decide which
  15.        bugs and extensions qualify.
  16.  
  17. The message, above, is repeated in ELISTBOX.HPP.
  18.  
  19. It is present without being "commented" so that you cannot compile the code
  20. without seeing the message!
  21.  
  22.  
  23.   Support for Extended List Boxes
  24.  
  25.   There are several classes needed to support ELBs: Row, Column and the
  26.   subclasses of Column for specific data types and the ELB class itself.
  27.  
  28.   These classes in some sense encapsulate arrays of structures.
  29.   A column is identified by a ( char* ) which points to the first element
  30.   of the (sub)array of the things to be displayed and an offset to the "next"
  31.   element in the (sub)array in a "true" array the offset will be 0 in a
  32.   subarray of an array of structures the offset will be sizeof( struct ).
  33.  
  34.   Thereafter the variables are dealt with as "indexed vectors" (i.e.
  35.   they are used as if they were strictly one dimensional.)
  36.  
  37.   ELB's (Extended List Boxes) have somewhat less structure than do regular
  38.   list boxes.  They do, however, have sufficient
  39.   structure so that the more ordinary uses of list boxes can be accomplished
  40.   with no more code than is required for an ordinary LB and in many cases
  41.   somewhat less.  Almost all of the data in the ELB is SHARED BETWEEN the
  42.   user and the control -- this gives more freedom and concommitently requires
  43.   more responsibility of the programmer.  Caveat Programmer, you'll have more
  44.   chances to get into trouble but not if you stick to the beaten path.    I.e.
  45.   don't do things that you probably wouldn't do with LBs.
  46.  
  47.  
  48.   Constructing an ELB
  49.  
  50.   The author being ignorant and lazy picked the most convenient of the
  51.   standard controls to subclass to obtain the ELB -- the MLE control
  52.   has all of the needed stuff (and probably a lot more.)  The most important
  53.   feature of the MLE is that the Dialog Editor knows how to put it on the
  54.   screen (halleluja!)
  55.  
  56.   Make an MLE box with a Vert scrollbar (I do it with the dialog editor)
  57.   then execute WinCreateELB to make it into an ELB.
  58.  
  59.   WinCreateELB is the function which transforms a Multiline entry Box
  60.   control in a dialog template into an extended list box.
  61.   This function should (usually) be executed in the WM_INITDLG message in the
  62.   proceedure which manages the dialog containing the ELB.
  63.  
  64.    void WinCreateELB( HWND Wnd, ULONG id, Row& row, long& lastchangendx,
  65.               char* selectvectorptr=( char * )NULL );
  66.  
  67.    the creating function supplies a Row reference which in turn describes
  68.    (holds) the Columns to be displayed and a minimal amount of additional
  69.    info -- that which is common to all columns (e.g. their length since all
  70.    displayed Columns must have a common (minimum) length.)  The Columns are
  71.    all subclasses of the Column class and know how to index and draw
  72.    themselves, they also know the Header and position to be displayed in the
  73.    ELB.
  74.  
  75. Note: Perhaps the heading and display position should be in the Row.
  76.  
  77.    ELB's like list boxes can be "Single Select" or "Multi Select."
  78.    The way the code contained here works is: if the Selection Vector (an
  79.    array of characters) has a NULL descriptor in the Row which describes
  80.    the ELB the ELB is taken to be Single Select.
  81.  
  82.  
  83.    ELB Processing
  84.  
  85.    The ELB posts the following messages to its owner in a WM_CONTROL message:
  86.  
  87.    The active row index is 0 based and indicates the row on which the "Cursor"
  88.    is currently set.
  89.  
  90.    All of the messages are of the same form:
  91.      Message==WM_CONTROL, mp1==MPFROM2SHORT( ELBID, ELB_MSG ) and
  92.      mp2==message specific (see below)
  93.  
  94.  
  95.    ELB_SELCHANGED -- Tells the owner that the selection has been changed
  96.              mp2 == the index of the item whose selection state
  97.              is being changed -- single sel ELB's this is the message
  98.              is NOT SENT it is redundant for single sel ELBs.
  99.  
  100.    ELB_SEARCH      -- Tells the owner that an ascii key has been struck while
  101.              the ELB has the Focus.  This is so that the programmer
  102.              can give their own behavior to the "search function" in
  103.              an ordinary LB.  This is one of the cases where I gave up
  104.              trying to figure out a rational default behavior.    It is
  105.              the authors belief that the standard LB search behavior
  106.              is by NO MEANS RATIONAL.
  107.  
  108.         mp2==MPFROM2SHORT(  index of the active row, the char struck )
  109.  
  110.    ELB_DBLCLK and ELB_ENTER   -- Tell the owner that something the user did is
  111.              is in some sense URGENT and they want the program's
  112.              attention.
  113.  
  114.             mp2==the index of the active row
  115.  
  116.  
  117.    The first Click of a dblclick sends an ELB_SELCHANGED
  118.    before it sends ELB_DBLCLK.    Enter does not send an ELB_SELCHANGED
  119.    nor does it change selection state of the then active line as does the
  120.    dblclick!
  121.  
  122.    The ONLY KEY which will change the selection state of a multisel ELB row                                         *
  123.    is the space key.  This is a behavior of Multisel LBs.
  124.  
  125.    Since the ELB and the procs which manipulate it share access to the data
  126.    in the columns displayed and to the selection vector (when present)
  127.    any manipulation of the data, selection state and other parameters of an
  128.    ELB can be accomplished by manipulating the data in the shared data.
  129.  
  130.    There is one message the ELB understands and that is:
  131.  
  132.    WM_SETACTIVE -- this message will force the row designated by the setting
  133.    of mp1 which is MPFROM2SHORT( new active, 0 ), mp2 is not used and should
  134.    be zero (I should, but don't, look at it!)
  135.  
  136.    ELB's work with arrays of structures -- which I use a lot!
  137.    The use of column classes which use the starting address and offset to the
  138.    next element is the basic implementation technique to accomplish this
  139.    function.  Let the COMPILER DO THE WORK!  The Column class contains the
  140.    column header, and the display starting and ending points expressed in avg
  141.    character widths -- a reversion to pre-PM days.
  142.  
  143.  
  144.  
  145. Function draw() in each class derived from Column has considerable code in
  146. common with the others.  This seems like the best way to do this even though
  147. "inline" functions could have been used.
  148.  
  149. The only differences in these subclasses are the defaulted parameters and
  150. the method of "finding" the indexed element and, of course, the actual
  151. presentation.
  152.  
  153. Pardon the bizarre behavior of the test program.  I wanted to test as much
  154. as I could with as little code as possible!
  155.