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