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,2005 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.37 2005/02/06 17:20:00 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 /** 00047 * The Tree List Box behaves very much like a List Box, except that 00048 * it supports a hierarchical, tree structured display of the items. 00049 * When an item is selected it issues a SEL_COMMAND message with the 00050 * pointer to the item. While manipulating the tree list, it may send 00051 * SEL_CHANGED messages to indicate which item the cursor is hovering over. 00052 */ 00053 class FXAPI FXTreeListBox : public FXPacker { 00054 FXDECLARE(FXTreeListBox) 00055 protected: 00056 FXButton *field; 00057 FXMenuButton *button; 00058 FXTreeList *tree; 00059 FXPopup *pane; 00060 protected: 00061 FXTreeListBox(){} 00062 private: 00063 FXTreeListBox(const FXTreeListBox&); 00064 FXTreeListBox& operator=(const FXTreeListBox&); 00065 public: 00066 long onFocusUp(FXObject*,FXSelector,void*); 00067 long onFocusDown(FXObject*,FXSelector,void*); 00068 long onFocusSelf(FXObject*,FXSelector,void*); 00069 long onFieldButton(FXObject*,FXSelector,void*); 00070 long onTreeUpdate(FXObject*,FXSelector,void*); 00071 long onTreeChanged(FXObject*,FXSelector,void*); 00072 long onTreeClicked(FXObject*,FXSelector,void*); 00073 public: 00074 enum{ 00075 ID_TREE=FXPacker::ID_LAST, 00076 ID_FIELD, 00077 ID_LAST 00078 }; 00079 public: 00080 00081 /// Construct tree list box 00082 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); 00083 00084 /// Create server-side resources 00085 virtual void create(); 00086 00087 /// Detach server-side resources 00088 virtual void detach(); 00089 00090 /// Destroy server-side resources 00091 virtual void destroy(); 00092 00093 /// Perform layout 00094 virtual void layout(); 00095 00096 /// Enable widget 00097 virtual void enable(); 00098 00099 /// Disable widget 00100 virtual void disable(); 00101 00102 /// Return default with 00103 virtual FXint getDefaultWidth(); 00104 00105 /// Return default height 00106 virtual FXint getDefaultHeight(); 00107 00108 /// Return number of items 00109 FXint getNumItems() const; 00110 00111 /// Return number of visible items 00112 FXint getNumVisible() const; 00113 00114 /// Set number of visible items to determine default height 00115 void setNumVisible(FXint nvis); 00116 00117 /// Return first top-level item 00118 FXTreeItem* getFirstItem() const; 00119 00120 /// Return last top-level item 00121 FXTreeItem* getLastItem() const; 00122 00123 /// Fill tree list box by appending items from array of strings 00124 FXint fillItems(FXTreeItem* father,const FXchar** strings,FXIcon* oi=NULL,FXIcon* ci=NULL,void* ptr=NULL); 00125 00126 /// Fill tree list box by appending items from newline separated strings 00127 FXint fillItems(FXTreeItem* father,const FXString& strings,FXIcon* oi=NULL,FXIcon* ci=NULL,void* ptr=NULL); 00128 00129 /// Insert [possibly subclassed] item under father before other item 00130 FXTreeItem* insertItem(FXTreeItem* other,FXTreeItem* father,FXTreeItem* item); 00131 00132 /// Insert item with given text and optional icons, and user-data pointer under father before other item 00133 FXTreeItem* insertItem(FXTreeItem* other,FXTreeItem* father,const FXString& text,FXIcon* oi=NULL,FXIcon* ci=NULL,void* ptr=NULL); 00134 00135 /// Append [possibly subclassed] item as last child of father 00136 FXTreeItem* appendItem(FXTreeItem* father,FXTreeItem* item); 00137 00138 /// Append item with given text and optional icons, and user-data pointer as last child of father 00139 FXTreeItem* appendItem(FXTreeItem* father,const FXString& text,FXIcon* oi=NULL,FXIcon* ci=NULL,void* ptr=NULL); 00140 00141 /// Prepend [possibly subclassed] item as first child of father 00142 FXTreeItem* prependItem(FXTreeItem* father,FXTreeItem* item); 00143 00144 /// Prepend item with given text and optional icons, and user-data pointer as first child of father 00145 FXTreeItem* prependItem(FXTreeItem* father,const FXString& text,FXIcon* oi=NULL,FXIcon* ci=NULL,void* ptr=NULL); 00146 00147 /// Move item under father before other item 00148 FXTreeItem *moveItem(FXTreeItem* other,FXTreeItem* father,FXTreeItem* item); 00149 00150 /// Remove item 00151 void removeItem(FXTreeItem* item); 00152 00153 /// Remove all items in range [fm...to] 00154 void removeItems(FXTreeItem* fm,FXTreeItem* to); 00155 00156 /// Remove all items from list 00157 void clearItems(); 00158 00159 /** 00160 * Search items by name, beginning from item start. If the 00161 * start item is NULL the search will start at the first, top-most item 00162 * in the list. Flags may be SEARCH_FORWARD or SEARCH_BACKWARD to control 00163 * the search direction; this can be combined with SEARCH_NOWRAP or SEARCH_WRAP 00164 * to control whether the search wraps at the start or end of the list. 00165 * The option SEARCH_IGNORECASE causes a case-insensitive match. Finally, 00166 * passing SEARCH_PREFIX causes searching for a prefix of the item name. 00167 * Return NULL if no matching item is found. 00168 */ 00169 FXTreeItem* findItem(const FXString& text,FXTreeItem* start=NULL,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const; 00170 00171 /** 00172 * Search items by associated user data, beginning from item start. If the 00173 * start item is NULL the search will start at the first, top-most item 00174 * in the list. Flags may be SEARCH_FORWARD or SEARCH_BACKWARD to control 00175 * the search direction; this can be combined with SEARCH_NOWRAP or SEARCH_WRAP 00176 * to control whether the search wraps at the start or end of the list. 00177 * The option SEARCH_IGNORECASE causes a case-insensitive match. Finally, 00178 * passing SEARCH_PREFIX causes searching for a prefix of the item name. 00179 * Return NULL if no matching item is found. 00180 */ 00181 FXTreeItem* findItemByData(const void *ptr,FXTreeItem* start=NULL,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const; 00182 00183 /// Return TRUE if item is the current item 00184 FXbool isItemCurrent(const FXTreeItem* item) const; 00185 00186 /// Return TRUE if item is leaf-item, i.e. has no children 00187 FXbool isItemLeaf(const FXTreeItem* item) const; 00188 00189 /// Sort the toplevel items with the sort function 00190 void sortRootItems(); 00191 00192 /// Sort all items recursively 00193 void sortItems(); 00194 00195 /// Sort child items of item 00196 void sortChildItems(FXTreeItem* item); 00197 00198 /// Change current item 00199 virtual void setCurrentItem(FXTreeItem* item,FXbool notify=FALSE); 00200 00201 /// Return current item 00202 FXTreeItem* getCurrentItem() const; 00203 00204 /// Change item label 00205 void setItemText(FXTreeItem* item,const FXString& text); 00206 00207 /// Return item label 00208 FXString getItemText(const FXTreeItem* item) const; 00209 00210 /// Change item's open icon, delete old one if it was owned 00211 void setItemOpenIcon(FXTreeItem* item,FXIcon* icon,FXbool owned=FALSE); 00212 00213 /// Return item's open icon 00214 FXIcon* getItemOpenIcon(const FXTreeItem* item) const; 00215 00216 /// Change item's closed icon, delete old one if it was owned 00217 void setItemClosedIcon(FXTreeItem* item,FXIcon* icon,FXbool owned=FALSE); 00218 00219 /// Return item's closed icon 00220 FXIcon* getItemClosedIcon(const FXTreeItem* item) const; 00221 00222 /// Change item's user data 00223 void setItemData(FXTreeItem* item,void* ptr) const; 00224 00225 /// Return item's user data 00226 void* getItemData(const FXTreeItem* item) const; 00227 00228 /// Return item sort function 00229 FXTreeListSortFunc getSortFunc() const; 00230 00231 /// Change item sort function 00232 void setSortFunc(FXTreeListSortFunc func); 00233 00234 /// Is the pane shown 00235 FXbool isPaneShown() const; 00236 00237 /// Change font 00238 void setFont(FXFont* fnt); 00239 00240 /// Return font 00241 FXFont* getFont() const; 00242 00243 /// Return list style 00244 FXuint getListStyle() const; 00245 00246 /// Change list style 00247 void setListStyle(FXuint style); 00248 00249 /// Change help text 00250 void setHelpText(const FXString& txt); 00251 00252 /// Return help text 00253 const FXString& getHelpText() const; 00254 00255 /// Change tip text 00256 void setTipText(const FXString& txt); 00257 00258 /// Return tip text 00259 const FXString& getTipText() const; 00260 00261 /// Save object to a stream 00262 virtual void save(FXStream& store) const; 00263 00264 /// Load object from a stream 00265 virtual void load(FXStream& store); 00266 00267 /// Destructor 00268 virtual ~FXTreeListBox(); 00269 }; 00270 00271 } 00272 00273 #endif

Copyright © 1997-2005 Jeroen van der Zijp