Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXTreeListBox.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                      T r e e   L i s t   B o x   W i d g e t                  *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1999,2009 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or modify          *
00009 * it under the terms of the GNU Lesser General Public License as published by   *
00010 * the Free Software Foundation; either version 3 of the License, or             *
00011 * (at your option) any later version.                                           *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                 *
00016 * GNU Lesser General Public License for more details.                           *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public License      *
00019 * along with this program.  If not, see <http://www.gnu.org/licenses/>          *
00020 *********************************************************************************
00021 * $Id: FXTreeListBox.h,v 1.54 2009/01/06 13:07:29 fox Exp $                     *
00022 ********************************************************************************/
00023 #ifndef FXTREELISTBOX_H
00024 #define FXTREELISTBOX_H
00025 
00026 #ifndef FXPACKER_H
00027 #include "FXPacker.h"
00028 #endif
00029 
00030 namespace FX {
00031 
00032 
00033 /// Tree List Box styles
00034 enum {
00035   TREELISTBOX_NORMAL         = 0          /// Normal style
00036   };
00037 
00038 
00039 class FXButton;
00040 class FXMenuButton;
00041 class FXTreeList;
00042 class FXPopup;
00043 
00044 
00045 /**
00046 * The Tree List Box behaves very much like a List Box, except that
00047 * it supports a hierarchical, tree structured display of the items.
00048 * When an item is selected it issues a SEL_COMMAND message with the
00049 * pointer to the item.  While manipulating the tree list, it may send
00050 * SEL_CHANGED messages to indicate which item the cursor is hovering over.
00051 * When items are added, replaced, or removed, the list sends messages of
00052 * the type SEL_INSERTED, SEL_REPLACED, or SEL_DELETED, with the pointer to
00053 * the affected item as argument.
00054 */
00055 class FXAPI FXTreeListBox : public FXPacker {
00056   FXDECLARE(FXTreeListBox)
00057 protected:
00058   FXButton      *field;
00059   FXMenuButton  *button;
00060   FXTreeList    *tree;
00061   FXPopup       *pane;
00062 protected:
00063   FXTreeListBox(){}
00064 private:
00065   FXTreeListBox(const FXTreeListBox&);
00066   FXTreeListBox& operator=(const FXTreeListBox&);
00067 public:
00068   long onFocusUp(FXObject*,FXSelector,void*);
00069   long onFocusDown(FXObject*,FXSelector,void*);
00070   long onFocusSelf(FXObject*,FXSelector,void*);
00071   long onMouseWheel(FXObject*,FXSelector,void*);
00072   long onFieldButton(FXObject*,FXSelector,void*);
00073   long onTreeUpdate(FXObject*,FXSelector,void*);
00074   long onTreeForward(FXObject*,FXSelector,void*);
00075   long onTreeClicked(FXObject*,FXSelector,void*);
00076   long onTreeCommand(FXObject*,FXSelector,void*);
00077 public:
00078   enum{
00079     ID_TREE=FXPacker::ID_LAST,
00080     ID_FIELD,
00081     ID_LAST
00082     };
00083 public:
00084 
00085   /// Construct tree list box
00086   FXTreeListBox(FXComposite *p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=FRAME_SUNKEN|FRAME_THICK|TREELISTBOX_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD);
00087 
00088   /// Create server-side resources
00089   virtual void create();
00090 
00091   /// Detach server-side resources
00092   virtual void detach();
00093 
00094   /// Destroy server-side resources
00095   virtual void destroy();
00096 
00097   /// Perform layout
00098   virtual void layout();
00099 
00100   /// Enable widget
00101   virtual void enable();
00102 
00103   /// Disable widget
00104   virtual void disable();
00105 
00106   /// Return default with
00107   virtual FXint getDefaultWidth();
00108 
00109   /// Return default height
00110   virtual FXint getDefaultHeight();
00111 
00112   /// Return number of items
00113   FXint getNumItems() const;
00114 
00115   /// Return number of visible items
00116   FXint getNumVisible() const;
00117 
00118   /// Set number of visible items to determine default height
00119   void setNumVisible(FXint nvis);
00120 
00121   /// Return first top-level item
00122   FXTreeItem* getFirstItem() const;
00123 
00124   /// Return last top-level item
00125   FXTreeItem* getLastItem() const;
00126 
00127   /// Return true if item is the current item
00128   FXbool isItemCurrent(const FXTreeItem* item) const;
00129 
00130   /// Change current item
00131   virtual void setCurrentItem(FXTreeItem* item,FXbool notify=false);
00132 
00133   /// Return current item
00134   FXTreeItem* getCurrentItem() const;
00135 
00136   /// Fill tree list box by appending items from array of strings
00137   FXint fillItems(FXTreeItem* father,const FXchar** strings,FXIcon* oi=NULL,FXIcon* ci=NULL,void* ptr=NULL,FXbool notify=false);
00138 
00139   /// Fill tree list box by appending items from newline separated strings
00140   FXint fillItems(FXTreeItem* father,const FXString& strings,FXIcon* oi=NULL,FXIcon* ci=NULL,void* ptr=NULL,FXbool notify=false);
00141 
00142   /// Insert [possibly subclassed] item under father before other item
00143   FXTreeItem* insertItem(FXTreeItem* other,FXTreeItem* father,FXTreeItem* item,FXbool notify=false);
00144 
00145   /// Insert item with given text and optional icons, and user-data pointer under father before other item
00146   FXTreeItem* insertItem(FXTreeItem* other,FXTreeItem* father,const FXString& text,FXIcon* oi=NULL,FXIcon* ci=NULL,void* ptr=NULL,FXbool notify=false);
00147 
00148   /// Append [possibly subclassed] item as last child of father
00149   FXTreeItem* appendItem(FXTreeItem* father,FXTreeItem* item,FXbool notify=false);
00150 
00151   /// Append item with given text and optional icons, and user-data pointer as last child of father
00152   FXTreeItem* appendItem(FXTreeItem* father,const FXString& text,FXIcon* oi=NULL,FXIcon* ci=NULL,void* ptr=NULL,FXbool notify=false);
00153 
00154   /// Prepend [possibly subclassed] item as first child of father
00155   FXTreeItem* prependItem(FXTreeItem* father,FXTreeItem* item,FXbool notify=false);
00156 
00157   /// Prepend item with given text and optional icons, and user-data pointer as first child of father
00158   FXTreeItem* prependItem(FXTreeItem* father,const FXString& text,FXIcon* oi=NULL,FXIcon* ci=NULL,void* ptr=NULL,FXbool notify=false);
00159 
00160   /// Move item under father before other item
00161   FXTreeItem *moveItem(FXTreeItem* other,FXTreeItem* father,FXTreeItem* item);
00162 
00163   /// Extract item
00164   FXTreeItem* extractItem(FXTreeItem* item,FXbool notify=false);
00165 
00166   /// Remove item
00167   void removeItem(FXTreeItem* item,FXbool notify=false);
00168 
00169   /// Remove all items in range [fm...to]
00170   void removeItems(FXTreeItem* fm,FXTreeItem* to,FXbool notify=false);
00171 
00172   /// Remove all items from list
00173   void clearItems(FXbool notify=false);
00174 
00175   /**
00176   * Search items by name, beginning from item start.  If the
00177   * start item is NULL the search will start at the first, top-most item
00178   * in the list.  Flags may be SEARCH_FORWARD or SEARCH_BACKWARD to control
00179   * the search direction; this can be combined with SEARCH_NOWRAP or SEARCH_WRAP
00180   * to control whether the search wraps at the start or end of the list.
00181   * The option SEARCH_IGNORECASE causes a case-insensitive match.  Finally,
00182   * passing SEARCH_PREFIX causes searching for a prefix of the item name.
00183   * Return NULL if no matching item is found.
00184   */
00185   FXTreeItem* findItem(const FXString& text,FXTreeItem* start=NULL,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const;
00186 
00187   /**
00188   * Search items by associated user data, beginning from item start. If the
00189   * start item is NULL the search will start at the first, top-most item
00190   * in the list.  Flags may be SEARCH_FORWARD or SEARCH_BACKWARD to control
00191   * the search direction; this can be combined with SEARCH_NOWRAP or SEARCH_WRAP
00192   * to control whether the search wraps at the start or end of the list.
00193   */
00194   FXTreeItem* findItemByData(const void *ptr,FXTreeItem* start=NULL,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const;
00195 
00196   /// Return true if item is leaf-item, i.e. has no children
00197   FXbool isItemLeaf(const FXTreeItem* item) const;
00198 
00199   /// Sort the toplevel items with the sort function
00200   void sortRootItems();
00201 
00202   /// Sort all items recursively
00203   void sortItems();
00204 
00205   /// Sort child items of item
00206   void sortChildItems(FXTreeItem* item);
00207 
00208   /// Change item label
00209   void setItemText(FXTreeItem* item,const FXString& text);
00210 
00211   /// Return item label
00212   FXString getItemText(const FXTreeItem* item) const;
00213 
00214   /// Change item's open icon, delete old one if it was owned
00215   void setItemOpenIcon(FXTreeItem* item,FXIcon* icon,FXbool owned=false);
00216 
00217   /// Return item's open icon
00218   FXIcon* getItemOpenIcon(const FXTreeItem* item) const;
00219 
00220   /// Change item's closed icon, delete old one if it was owned
00221   void setItemClosedIcon(FXTreeItem* item,FXIcon* icon,FXbool owned=false);
00222 
00223   /// Return item's closed icon
00224   FXIcon* getItemClosedIcon(const FXTreeItem* item) const;
00225 
00226   /// Change item's user data
00227   void setItemData(FXTreeItem* item,void* ptr) const;
00228 
00229   /// Return item's user data
00230   void* getItemData(const FXTreeItem* item) const;
00231 
00232   /// Return item sort function
00233   FXTreeListSortFunc getSortFunc() const;
00234 
00235   /// Change item sort function
00236   void setSortFunc(FXTreeListSortFunc func);
00237 
00238   /// Show or hide menu
00239   void showMenu(FXbool shw);
00240 
00241   /// Is the menu pane shown
00242   FXbool isMenuShown() const;
00243 
00244   /// Change font
00245   void setFont(FXFont* fnt);
00246 
00247   /// Return font
00248   FXFont* getFont() const;
00249 
00250   /// Change list style
00251   void setListStyle(FXuint style);
00252 
00253   /// Return list style
00254   FXuint getListStyle() const;
00255 
00256   /// Change popup pane shrinkwrap mode
00257   void setShrinkWrap(FXbool flag);
00258 
00259   /// Return popup pane shrinkwrap mode
00260   FXbool getShrinkWrap() const;
00261 
00262   /// Change help text
00263   void setHelpText(const FXString& txt);
00264 
00265   /// Return help text
00266   const FXString& getHelpText() const;
00267 
00268   /// Change tip text
00269   void setTipText(const FXString& txt);
00270 
00271   /// Return tip text
00272   const FXString& getTipText() const;
00273 
00274   /// Save object to a stream
00275   virtual void save(FXStream& store) const;
00276 
00277   /// Load object from a stream
00278   virtual void load(FXStream& store);
00279 
00280   /// Destructor
00281   virtual ~FXTreeListBox();
00282   };
00283 
00284 }
00285 
00286 #endif

Copyright © 1997-2009 Jeroen van der Zijp