slistbox.h
上传用户:hzhsqp
上传日期:2007-01-06
资源大小:1600k
文件大小:12k
- /*
- * slistbox.h
- *
- * String list box control.
- *
- * Portable Windows Library
- *
- * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is Portable Windows Library.
- *
- * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
- *
- * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * $Log: slistbox.h,v $
- * Revision 1.24 1999/11/16 06:51:41 robertj
- * Created PCustomListBox to allow motif native code PStringListBox implementation
- *
- * Revision 1.23 1999/11/16 05:19:36 craigs
- * Created PCustomListBox to allow native code PStringListBox implementation
- *
- * Revision 1.22 1999/03/10 03:49:53 robertj
- * More documentation adjustments.
- *
- * Revision 1.21 1999/03/09 08:01:50 robertj
- * Changed comments for doc++ support (more to come).
- *
- * Revision 1.20 1999/02/16 08:08:46 robertj
- * MSVC 6.0 compatibility changes.
- *
- * Revision 1.19 1998/12/01 12:55:58 robertj
- * new directory structure.
- *
- * Revision 1.18 1998/10/16 11:08:12 robertj
- * GNU compatibility.
- *
- * Revision 1.17 1998/09/23 06:29:04 robertj
- * Added open source copyright license.
- *
- * Revision 1.16 1998/09/14 12:41:34 robertj
- * Added tab stops to string output in list box.
- *
- * Revision 1.15 1995/10/14 15:05:24 robertj
- * Added addition of colection as strings to box.
- *
- * Revision 1.14 1995/06/17 11:13:23 robertj
- * Documentation update.
- *
- * Revision 1.13 1995/03/14 12:42:38 robertj
- * Updated documentation to use HTML codes.
- *
- * Revision 1.12 1995/01/14 06:19:40 robertj
- * Documentation
- *
- * Revision 1.11 1994/10/30 11:47:08 robertj
- * Changed mechanism for doing notification callback functions.
- *
- * Revision 1.10 1994/08/23 11:32:52 robertj
- * Oops
- *
- * Revision 1.9 1994/08/22 00:46:48 robertj
- * Added pragma fro GNU C++ compiler.
- *
- * Revision 1.8 1994/06/25 11:55:15 robertj
- * Unix version synchronisation.
- *
- * Revision 1.7 1994/04/03 08:34:18 robertj
- * Added help and focus functionality.
- *
- * Revision 1.6 1994/03/07 07:38:19 robertj
- * Major enhancementsacross the board.
- *
- * Revision 1.5 1994/01/03 04:42:23 robertj
- * Mass changes to common container classes and interactors etc etc etc.
- *
- * Revision 1.4 1993/09/27 16:35:25 robertj
- * Removed special constructor for dialog resource loading.
- *
- * Revision 1.3 1993/08/21 01:50:33 robertj
- * Made Clone() function optional, default will assert if called.
- *
- * Revision 1.2 1993/07/14 12:49:16 robertj
- * Fixed RCS keywords.
- *
- */
- #define _PSTRINGLISTBOX
- #ifdef __GNUC__
- #pragma interface
- #endif
- #ifndef _PLISTBOX
- #include <pwlib/listbox.h>
- #endif
- /**A scrollable list box control for selection of a one or more of
- Ref{PString} objects.
- */
- class PStringListBox : public PListBox
- {
- PCLASSINFO(PStringListBox, PListBox);
- public:
- /** Create a list box with the specified options. */
- PStringListBox(
- PInteractor * parent, /// Interactor into which the control is placed.
- StringSorting sorted = Sorted,
- /**If set to #Sorted# then strings will be inserted in sorted
- order. This requires that the Ref{PObject::Compare()} function
- operate correctly for objects placed into the list box.
- */
- SelectType select = SingleSelect,
- /**If set to #MultiSelect# then more than one item may be
- selected at a time. Otherwise only zero or one item may be selected.
- */
- PDIMENSION columnWidth = 0
- /**If this parameter is zero then only one column with a vertical scroll
- bar is displayed. If non-zero, then multiple columns of this width,
- in font based coordinates, will be used and a horizontal scroll bar
- displayed.
- */
- );
- /** Create control from interactor layout with the specified control ID. */
- PStringListBox(
- PInteractorLayout * parent, /// Interactor into which the box is placed.
- PRESOURCE_ID ctlID, /// Identifier for the control in the layout.
- const PNotifier & notify, /// Function to call when changes state.
- PINDEX * valuePtr /// Variable to change to the list box state.
- );
- /** Destroy the list box and all the strings it contains. */
- virtual ~PStringListBox();
- /**@name New functions for class */
- /**Add a new entry to the list box. If the sorted option was used this will
- place the entry in the correct position. Otherwise it adds it to the
- end of the list.
- If the #update# parameter is FALSE then it is the users
- responsibility to redraw the list box, ie call
- Ref{PInteractor::Invalidate()} or Ref{PInteractor::Update()} some
- time afterward. This is typically used if a large number of entries are
- to be added to the list box in one go. The user would add the entries
- and then call the Ref{PInteractor::Invalidate()} function on the list
- box to force a redraw. This is much faster and tidier in appearance.
- @return
- the index that the entry was placed.
- */
- virtual PINDEX AddString(
- const PString & str, /// String to add to the list box.
- BOOL update = TRUE /// Flag to indicate screen should be updated.
- );
- /**Add a collection of new entries to the list box. Each element of the
- collection is added in order using the Ref{AddEntry()} function. Thus,
- for example, a sorted list string will be added in sorted order.
- If the collection is not of string objects then they are translated into
- a string by the use of the Ref{operator<<} function.
- */
- void AddStrings(
- const PCollection & objects, /// New objects to add to list box.
- BOOL update = TRUE /// Flag to indicate screen should be updated.
- );
- /**Insert an entry at the specified location. If the sorted option was used
- this will place the entry in the correct position, {bf not} that
- specified by the #index# parameter.
- If the #update# parameter is FALSE then it is the users
- responsibility to redraw the list box, ie call
- Ref{PInteractor::Invalidate()} or Ref{PInteractor::Update()} some
- time afterward. This is typically used if a large number of entries are
- to be added to the list box in one go. The user would add the entries
- and then call the Ref{PInteractor::Invalidate()} function on the list
- box to force a redraw. This is much faster and tidier in appearance.
- */
- virtual void InsertString(
- const PString & str, /// String to insert into list box.
- PINDEX index, /// Index position in list box to insert entry.
- BOOL update = TRUE /// Flag to indicate screen should be updated.
- );
-
- /**Delete the string from the list box. If the delete objects option was
- selected then all the objects added to the list box are deleted as well.
- If the #update# parameter is FALSE then it is the users
- responsibility to redraw the list box, ie call
- Ref{PInteractor::Invalidate()} or Ref{PInteractor::Update()} some
- time afterward. This is typically used if a large number of entries are
- to be deleted to the list box in one go. The user would delete the
- entries and then call the Ref{PInteractor::Invalidate()} function on
- the list box to force a redraw. This is much faster and tidier in
- appearance.
- */
- virtual void DeleteString(
- PINDEX index, /// Index position in list box to delete entry.
- BOOL update = TRUE /// Flag to indicate screen should be updated.
- );
- /**Find the string in the list box starting at the string after the
- specified index. If the #index# is #P_MAX_INDEX#
- then searches the whole list.
-
- The #exact# flag indicates that the whole string must match
- otherwise a string in the list box that matches up to the length of
- the argument string will be found.
- */
- virtual PINDEX FindString(
- const PString & str, /// String to search for.
- PINDEX startIndex = P_MAX_INDEX, /// Starting index for the search.
- BOOL exact = FALSE /// Flag for search for exact string or substring.
- ) const;
- /**Set the string at the index position. If the index is beyond the end
- of the list then simply adds the entry to the end of the list.
- If there was an existing entry at the index position then that entry
- is removed.
- If the sorted option was used this will place the entry in the correct
- position, {bf not} that specified by the #index#
- parameter. Note the removal of the previous value still takes place.
- If the #update# parameter is FALSE then it is the users
- responsibility to redraw the list box, ie call
- Ref{PInteractor::Invalidate()} or Ref{PInteractor::Update()} some
- time afterward. This is typically used if a large number of entries are
- to be changed in the list box in one go. The user would change the
- entries and then call the Ref{PInteractor::Invalidate()} function on
- the list box to force a redraw. This is much faster and tidier in
- appearance.
- */
- void SetString(
- const PString & str, /// New string to set for the entry.
- PINDEX index, /// Index position in list box to set entry.
- BOOL update = TRUE /// Flag to indicate screen should be updated.
- );
- /**Get the string at the index. If the index is beyond the end of the
- list then returns the empty string.
- @return
- string placed in the list box at the index.
- */
- virtual PString GetString(
- PINDEX index /// Index into the list for the string to retrieve.
- ) const;
- /**Get the selected string in a non-multiselect list box. This is
- equivalent to going #GetString(GetSelection())#.
- @return
- string that is selected.
- */
- PString GetSelectedString() const;
- /**Set the tab stop positions for strings in each row of the list box.
- The first form sets all tab stops to be the same distance. There are an
- infinite number of tab stops of this size.
- The other forms set explicit tab stops for the specified positions. The
- distance between the last two entries, or between 0 and the first array
- entry if there is only one entry, is used for all subsequent tab stops.
- */
- void SetTabStops(
- PDIMENSION tab /// Repeated tab stop locations
- );
- void SetTabStops(
- const PORDINATE * tabs, /// Array of tab stop positions
- PINDEX count /// Count of tab stops in the array.
- );
- void SetTabStops(
- const PIntArray & tabs /// Array of tab stop positions
- );
- protected:
- PIntArray tabStops;
- #ifdef DOC_PLUS_PLUS
- };
- #endif
- // Class declaration continued in platform specific header file ///////////////