clistbox.h
上传用户:hzhsqp
上传日期:2007-01-06
资源大小:1600k
文件大小:10k
- /*
- * clistbox.h
- *
- * Custom 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: clistbox.h,v $
- * Revision 1.2 1999/11/16 06:51:41 robertj
- * Created PCustomListBox to allow motif native code PStringListBox implementation
- *
- * Revision 1.1 1999/11/16 05:19:36 craigs
- * Created PCustomListBox to allow native code PStringListBox implementation
- *
- *
- */
- #define _PCUSTOMLISTBOX
- #ifdef __GNUC__
- #pragma interface
- #endif
- #ifndef _PLISTBOX
- #include <pwlib/listbox.h>
- #endif
- class PCustomListBox : public PListBox
- {
- PCLASSINFO(PCustomListBox, PListBox);
- public:
- /** Create a custom list box with the specified options. */
- PCustomListBox(
- 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.
- */
- BOOL deleteObj = TRUE
- /**If this parameter is TRUE then when the list box is destroyed all
- entries objects are deleted as well using the delete operator.
- Similarly if Ref{DeleteEntry()} or Ref{DeleteAllEntries()} is
- called the entry or entries are deleted, again using the delete
- operator).
- */
- );
- PCustomListBox(
- PInteractor * parent, /// Interactor into which the control is placed.
- const PNotifier & notify, /// Function to call when changes state.
- 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.
- */
- BOOL deleteObj = TRUE
- /**If this parameter is TRUE then when the list box is destroyed all
- entries objects are deleted as well using the delete operator.
- Similarly if Ref{DeleteEntry()} or Ref{DeleteAllEntries()} is
- called the entry or entries are deleted, again using the delete
- operator).
- */
- );
- /** Create control from interactor layout with the specified control ID. */
- PCustomListBox(
- 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.
- );
- /**@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 AddEntry(
- PObject * obj, /// New object to add to list box.
- BOOL update = TRUE /// Flag to indicate screen should be updated.
- ) = 0;
- /**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.
- */
- void AddEntries(
- 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 InsertEntry(
- PObject * obj, /// New object to add to list box.
- PINDEX index, /// Index position in list box to insert entry.
- BOOL update = TRUE /// Flag to indicate screen should be updated.
- ) = 0;
- /**Find the entry in the list box starting at the entry after the specified
- index. If the #index# parameter is #P_MAX_INDEX#
- then searches the whole list from the beginning.
- This uses the objects Ref{PObject::Compare()} function to test for
- equality on the objects in the list.
- */
- virtual PINDEX FindEntry(
- const PObject & obj, /// Object value to search for.
- PINDEX startIndex = P_MAX_INDEX /// Starting index for the search.
- ) const = 0;
- /**Set the entry 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 and if the delet objects option selected it is also deleted
- using the delete operator.
- 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.
- */
- virtual void SetEntry(
- PObject * obj, /// New object to add to list box.
- PINDEX index, /// Index position in list box to set entry.
- BOOL update = TRUE /// Flag to indicate screen should be updated.
- ) = 0;
- /**Get the entry at the index. If the index is beyond the end of the
- list then returns NULL.
- @return
- pointer to the object placed in the list box at the index.
- */
- virtual const PObject * GetEntry(
- PINDEX index /// Index into the list for the entry to retrieve.
- ) const = 0;
- /**@name System callback functions. */
- /**The system calls this whenever an object in the list needs to be
- redrawn.
- */
- virtual void OnDrawEntry(
- PINDEX index, /// Index of entry to draw in the list box.
- PObject & obj, /// Object to draw for this entry in the list box.
- PCanvas & canvas, /// Canvas in which to draw the object entry.
- const PRect & rect, /// Rectangle of canvas in which the item is drawn.
- BOOL hasFocus, /// Flag indicating the item has the focus.
- BOOL isSelected /// Flag indicating the item is selected.
- ) = 0;
- /**The system calls this whenever it needs to get the size of an object in
- the list. The default function returns the full width of the list box
- and the font size as the height.
- */
- virtual PDim OnMeasureEntry(
- PINDEX index, /// Index of entry to measure in the list box.
- PObject & obj, /// Object to measure for this entry in the list box.
- PCanvas & canvas /// Canvas in which to measure the object entry.
- );
- #ifdef DOC_PLUS_PLUS
- };
- #endif
- // Class declaration continued in platform specific header file ///////////////