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

FXTreeListBox.h

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,2002 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or                 *
00009 * modify it under the terms of the GNU Lesser General Public                    *
00010 * License as published by the Free Software Foundation; either                  *
00011 * version 2.1 of the License, or (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 GNU             *
00016 * Lesser General Public License for more details.                               *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public              *
00019 * License along with this library; if not, write to the Free Software           *
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
00021 *********************************************************************************
00022 * $Id: FXTreeListBox.h,v 1.21 2002/09/30 13:06:56 fox Exp $                     *
00023 ********************************************************************************/
00024 #ifndef FXTREELISTBOX_H
00025 #define FXTREELISTBOX_H
00026 
00027 #ifndef FXPACKER_H
00028 #include "FXPacker.h"
00029 #endif
00030 
00031 namespace FX {
00032 
00033 
00034 /// Tree List Box styles
00035 enum {
00036   TREELISTBOX_NORMAL         = 0          /// Normal style
00037   };
00038 
00039 
00040 class FXButton;
00041 class FXMenuButton;
00042 class FXTreeList;
00043 class FXPopup;
00044 
00045 
00046 /// Tree List Box
00047 class FXAPI FXTreeListBox : public FXPacker {
00048   FXDECLARE(FXTreeListBox)
00049 protected:
00050   FXButton      *field;
00051   FXMenuButton  *button;
00052   FXTreeList    *tree;
00053   FXPopup       *pane;
00054 protected:
00055   FXTreeListBox(){}
00056   virtual void layout();
00057 private:
00058   FXTreeListBox(const FXTreeListBox&);
00059   FXTreeListBox& operator=(const FXTreeListBox&);
00060 public:
00061   long onFocusUp(FXObject*,FXSelector,void*);
00062   long onFocusDown(FXObject*,FXSelector,void*);
00063   long onFocusSelf(FXObject*,FXSelector,void*);
00064   long onChanged(FXObject*,FXSelector,void*);
00065   long onCommand(FXObject*,FXSelector,void*);
00066   long onFieldButton(FXObject*,FXSelector,void*);
00067   long onTreeChanged(FXObject*,FXSelector,void*);
00068   long onTreeClicked(FXObject*,FXSelector,void*);
00069   long onUpdFmTree(FXObject*,FXSelector,void*);
00070 public:
00071   enum{
00072     ID_TREE=FXPacker::ID_LAST,
00073     ID_FIELD,
00074     ID_LAST
00075     };
00076 public:
00077 
00078   /// Construct tree list box
00079   FXTreeListBox(FXComposite *p,FXint nvis,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);
00080 
00081   /// Create server-side resources
00082   virtual void create();
00083 
00084   /// Detach server-side resources
00085   virtual void detach();
00086 
00087   /// Destroy server-side resources
00088   virtual void destroy();
00089 
00090   /// Enable widget
00091   virtual void enable();
00092 
00093   /// Disable widget
00094   virtual void disable();
00095 
00096   /// Return default with
00097   virtual FXint getDefaultWidth();
00098 
00099   /// Return default height
00100   virtual FXint getDefaultHeight();
00101 
00102   /// Return number of items
00103   FXint getNumItems() const;
00104 
00105   /// Return number of visible items
00106   FXint getNumVisible() const;
00107 
00108   /// Set number of visible items to determine default height
00109   void setNumVisible(FXint nvis);
00110 
00111   /// Return first top-level item
00112   FXTreeItem* getFirstItem() const;
00113 
00114   /// Return last top-level item
00115   FXTreeItem* getLastItem() const;
00116 
00117   /// Add item as first child of parent p
00118   FXTreeItem* addItemFirst(FXTreeItem* p,FXTreeItem* item);
00119 
00120   /// Add item as last child after parent p
00121   FXTreeItem* addItemLast(FXTreeItem* p,FXTreeItem* item);
00122 
00123   /// Add item after other item
00124   FXTreeItem* addItemAfter(FXTreeItem* other,FXTreeItem* item);
00125 
00126   /// Add item before other item
00127   FXTreeItem* addItemBefore(FXTreeItem* other,FXTreeItem* item);
00128 
00129   /// Add item as first child of parent p
00130   FXTreeItem* addItemFirst(FXTreeItem* p,const FXString& text,FXIcon* oi=NULL,FXIcon* ci=NULL,void* ptr=NULL);
00131 
00132   /// Add item as last child of parent p
00133   FXTreeItem* addItemLast(FXTreeItem* p,const FXString& text,FXIcon* oi=NULL,FXIcon* ci=NULL,void* ptr=NULL);
00134 
00135   /// Add item after other item
00136   FXTreeItem* addItemAfter(FXTreeItem* other,const FXString& text,FXIcon* oi=NULL,FXIcon* ci=NULL,void* ptr=NULL);
00137 
00138   /// Add item before other item
00139   FXTreeItem* addItemBefore(FXTreeItem* other,const FXString& text,FXIcon* oi=NULL,FXIcon* ci=NULL,void* ptr=NULL);
00140 
00141   /// Remove item
00142   void removeItem(FXTreeItem* item);
00143 
00144   /// Remove all items in range [fm...to]
00145   void removeItems(FXTreeItem* fm,FXTreeItem* to);
00146 
00147   /// Remove all items from list
00148   void clearItems();
00149 
00150   /**
00151   * Search items for item by name, starting from start item; the
00152   * flags argument controls the search direction, and case sensitivity.
00153   */
00154   FXTreeItem* findItem(const FXString& text,FXTreeItem* start=NULL,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const;
00155 
00156   /// Return TRUE if item is the current item
00157   FXbool isItemCurrent(const FXTreeItem* item) const;
00158 
00159   /// Return TRUE if item is leaf-item, i.e. has no children
00160   FXbool isItemLeaf(const FXTreeItem* item) const;
00161 
00162   /// Sort child items of item
00163   void sortChildItems(FXTreeItem* item);
00164 
00165   /// Sort the toplevel items with the sort function
00166   void sortItems();
00167 
00168   /// Change current item
00169   void setCurrentItem(FXTreeItem* item,FXbool notify=FALSE);
00170 
00171   /// Return current item
00172   FXTreeItem* getCurrentItem() const;
00173 
00174   /// Change item label
00175   void setItemText(FXTreeItem* item,const FXString& text);
00176 
00177   /// Return item label
00178   FXString getItemText(const FXTreeItem* item) const;
00179 
00180   /// Change item's open icon
00181   void setItemOpenIcon(FXTreeItem* item,FXIcon* icon);
00182 
00183   /// Return item's open icon
00184   FXIcon* getItemOpenIcon(const FXTreeItem* item) const;
00185 
00186   /// Change item's closed icon
00187   void setItemClosedIcon(FXTreeItem* item,FXIcon* icon);
00188 
00189   /// Return item's closed icon
00190   FXIcon* getItemClosedIcon(const FXTreeItem* item) const;
00191 
00192   /// Change item's user data
00193   void setItemData(FXTreeItem* item,void* ptr) const;
00194 
00195   /// Return item's user data
00196   void* getItemData(const FXTreeItem* item) const;
00197 
00198   /// Return item sort function
00199   FXTreeListSortFunc getSortFunc() const;
00200 
00201   /// Change item sort function
00202   void setSortFunc(FXTreeListSortFunc func);
00203 
00204   /// Is the pane shown
00205   FXbool isPaneShown() const;
00206 
00207   /// Change font
00208   void setFont(FXFont* fnt);
00209 
00210   /// Return font
00211   FXFont* getFont() const;
00212 
00213   /// Return list style
00214   FXuint getListStyle() const;
00215 
00216   /// Change list style
00217   void setListStyle(FXuint style);
00218 
00219   /// Change help text
00220   void setHelpText(const FXString& txt);
00221 
00222   /// Return help text
00223   const FXString& getHelpText() const;
00224 
00225   /// Change tip text
00226   void setTipText(const FXString& txt);
00227 
00228   /// Return tip text
00229   const FXString& getTipText() const;
00230 
00231   /// Save object to a stream
00232   virtual void save(FXStream& store) const;
00233 
00234   /// Load object from a stream
00235   virtual void load(FXStream& store);
00236 
00237   /// Destructor
00238   virtual ~FXTreeListBox();
00239   };
00240 
00241 }
00242 
00243 #endif