![]() |
Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
![]() |
00001 /******************************************************************************** 00002 * * 00003 * I c o n L i s t W i d g e t * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 1999,2003 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: FXIconList.h,v 1.72 2003/06/27 14:39:45 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXICONLIST_H 00025 #define FXICONLIST_H 00026 00027 #ifndef FXSCROLLAREA_H 00028 #include "FXScrollArea.h" 00029 #endif 00030 00031 namespace FX { 00032 00033 00034 /// Icon list styles 00035 enum { 00036 ICONLIST_EXTENDEDSELECT = 0, /// Extended selection mode 00037 ICONLIST_SINGLESELECT = 0x00100000, /// At most one selected item 00038 ICONLIST_BROWSESELECT = 0x00200000, /// Always exactly one selected item 00039 ICONLIST_MULTIPLESELECT = 0x00300000, /// Multiple selection mode 00040 ICONLIST_AUTOSIZE = 0x00400000, /// Automatically size item spacing 00041 ICONLIST_DETAILED = 0, /// List mode 00042 ICONLIST_MINI_ICONS = 0x00800000, /// Mini Icon mode 00043 ICONLIST_BIG_ICONS = 0x01000000, /// Big Icon mode 00044 ICONLIST_ROWS = 0, /// Row-wise mode 00045 ICONLIST_COLUMNS = 0x02000000, /// Column-wise mode 00046 ICONLIST_NORMAL = ICONLIST_EXTENDEDSELECT 00047 }; 00048 00049 00050 class FXIcon; 00051 class FXHeader; 00052 class FXFont; 00053 class FXIconList; 00054 class FXFileList; 00055 00056 00057 /// Icon item 00058 class FXAPI FXIconItem : public FXObject { 00059 FXDECLARE(FXIconItem) 00060 friend class FXIconList; 00061 friend class FXFileList; 00062 protected: 00063 FXString label; 00064 FXIcon *bigIcon; 00065 FXIcon *miniIcon; 00066 void *data; 00067 FXuint state; 00068 FXint x,y; 00069 protected: 00070 FXIconItem():bigIcon(NULL),miniIcon(NULL),data(NULL),state(0),x(0),y(0){} 00071 virtual void draw(const FXIconList* list,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const; 00072 virtual FXint hitItem(const FXIconList* list,FXint rx,FXint ry,FXint rw=1,FXint rh=1) const; 00073 protected: 00074 virtual void drawBigIcon(const FXIconList* list,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const; 00075 virtual void drawMiniIcon(const FXIconList* list,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const; 00076 virtual void drawDetails(const FXIconList* list,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const; 00077 protected: 00078 enum { 00079 SELECTED = 1, 00080 FOCUS = 2, 00081 DISABLED = 4, 00082 DRAGGABLE = 8, 00083 BIGICONOWNED = 16, 00084 MINIICONOWNED = 32 00085 }; 00086 public: 00087 FXIconItem(const FXString& text,FXIcon* bi=NULL,FXIcon* mi=NULL,void* ptr=NULL):label(text),bigIcon(bi),miniIcon(mi),data(ptr),state(0){} 00088 virtual void setText(const FXString& txt){ label=txt; } 00089 const FXString& getText() const { return label; } 00090 virtual void setBigIcon(FXIcon* icn){ bigIcon=icn; } 00091 FXIcon* getBigIcon() const { return bigIcon; } 00092 virtual void setMiniIcon(FXIcon* icn){ miniIcon=icn; } 00093 FXIcon* getMiniIcon() const { return miniIcon; } 00094 void setData(void* ptr){ data=ptr; } 00095 void* getData() const { return data; } 00096 virtual void setFocus(FXbool focus); 00097 FXbool hasFocus() const { return (state&FOCUS)!=0; } 00098 virtual void setSelected(FXbool selected); 00099 FXbool isSelected() const { return (state&SELECTED)!=0; } 00100 virtual void setEnabled(FXbool enabled); 00101 FXbool isEnabled() const { return (state&DISABLED)==0; } 00102 virtual void setDraggable(FXbool draggable); 00103 FXbool isDraggable() const { return (state&DRAGGABLE)!=0; } 00104 virtual void setIconOwned(FXuint owned=(BIGICONOWNED|MINIICONOWNED)); 00105 FXuint isIconOwned() const { return (state&(BIGICONOWNED|MINIICONOWNED)); } 00106 virtual FXint getWidth(const FXIconList* list) const; 00107 virtual FXint getHeight(const FXIconList* list) const; 00108 virtual void create(); 00109 virtual void detach(); 00110 virtual void destroy(); 00111 virtual void save(FXStream& store) const; 00112 virtual void load(FXStream& store); 00113 virtual ~FXIconItem(); 00114 }; 00115 00116 00117 /// Icon item collate function 00118 typedef FXint (*FXIconListSortFunc)(const FXIconItem*,const FXIconItem*); 00119 00120 00121 /// Icon List Widget 00122 class FXAPI FXIconList : public FXScrollArea { 00123 FXDECLARE(FXIconList) 00124 protected: 00125 FXHeader *header; // Header control 00126 FXIconItem **items; // Item list 00127 FXint nitems; // Number of items 00128 FXint nrows; // Number of rows 00129 FXint ncols; // Number of columns 00130 FXint anchor; // Anchor item 00131 FXint current; // Current item 00132 FXint extent; // Extent item 00133 FXint cursor; // Cursor item 00134 FXFont *font; // Font 00135 FXIconListSortFunc sortfunc; // Item sort function 00136 FXColor textColor; // Text color 00137 FXColor selbackColor; // Selected back color 00138 FXColor seltextColor; // Selected text color 00139 // FXint itemWidth; // Item width 00140 // FXint itemHeight; // Item height 00141 FXint listWidth; // Width of entire list 00142 FXint listHeight; // Height of entire list 00143 FXint itemSpace; // Space for item label 00144 FXint anchorx; // Rectangular selection 00145 FXint anchory; 00146 FXint currentx; 00147 FXint currenty; 00148 FXint grabx; // Grab point x 00149 FXint graby; // Grab point y 00150 FXString lookup; // Lookup string 00151 FXString help; // Help text 00152 FXbool state; // State of item 00153 protected: 00154 FXIconList(); 00155 virtual FXIconItem *createItem(const FXString& text,FXIcon *big,FXIcon* mini,void* ptr); 00156 virtual void moveContents(FXint x,FXint y); 00157 void drawLasso(FXint x0,FXint y0,FXint x1,FXint y1); 00158 void recompute(); 00159 // void getrowscols(FXint& nr,FXint& nc,FXint w,FXint h) const; 00160 void lassoChanged(FXint ox,FXint oy,FXint ow,FXint oh,FXint nx,FXint ny,FXint nw,FXint nh,FXbool notify); 00161 private: 00162 FXIconList(const FXIconList&); 00163 FXIconList &operator=(const FXIconList&); 00164 public: 00165 long onPaint(FXObject*,FXSelector,void*); 00166 long onEnter(FXObject*,FXSelector,void*); 00167 long onLeave(FXObject*,FXSelector,void*); 00168 long onUngrabbed(FXObject*,FXSelector,void*); 00169 long onKeyPress(FXObject*,FXSelector,void*); 00170 long onKeyRelease(FXObject*,FXSelector,void*); 00171 long onLeftBtnPress(FXObject*,FXSelector,void*); 00172 long onLeftBtnRelease(FXObject*,FXSelector,void*); 00173 long onRightBtnPress(FXObject*,FXSelector,void*); 00174 long onRightBtnRelease(FXObject*,FXSelector,void*); 00175 long onMotion(FXObject*,FXSelector,void*); 00176 long onQueryTip(FXObject*,FXSelector,void*); 00177 long onQueryHelp(FXObject*,FXSelector,void*); 00178 long onTipTimer(FXObject*,FXSelector,void*); 00179 long onCmdSelectAll(FXObject*,FXSelector,void*); 00180 long onCmdDeselectAll(FXObject*,FXSelector,void*); 00181 long onCmdSelectInverse(FXObject*,FXSelector,void*); 00182 long onCmdArrangeByRows(FXObject*,FXSelector,void*); 00183 long onUpdArrangeByRows(FXObject*,FXSelector,void*); 00184 long onCmdArrangeByColumns(FXObject*,FXSelector,void*); 00185 long onUpdArrangeByColumns(FXObject*,FXSelector,void*); 00186 long onCmdShowDetails(FXObject*,FXSelector,void*); 00187 long onUpdShowDetails(FXObject*,FXSelector,void*); 00188 long onCmdShowBigIcons(FXObject*,FXSelector,void*); 00189 long onUpdShowBigIcons(FXObject*,FXSelector,void*); 00190 long onCmdShowMiniIcons(FXObject*,FXSelector,void*); 00191 long onUpdShowMiniIcons(FXObject*,FXSelector,void*); 00192 long onHeaderChanged(FXObject*,FXSelector,void*); 00193 long onHeaderResize(FXObject*,FXSelector,void*); 00194 long onFocusIn(FXObject*,FXSelector,void*); 00195 long onFocusOut(FXObject*,FXSelector,void*); 00196 long onClicked(FXObject*,FXSelector,void*); 00197 long onDoubleClicked(FXObject*,FXSelector,void*); 00198 long onTripleClicked(FXObject*,FXSelector,void*); 00199 long onCommand(FXObject*,FXSelector,void*); 00200 long onAutoScroll(FXObject*,FXSelector,void*); 00201 long onLookupTimer(FXObject*,FXSelector,void*); 00202 long onCmdSetValue(FXObject*,FXSelector,void*); 00203 long onCmdGetIntValue(FXObject*,FXSelector,void*); 00204 long onCmdSetIntValue(FXObject*,FXSelector,void*); 00205 public: 00206 static FXint ascending(const FXIconItem* a,const FXIconItem* b); 00207 static FXint descending(const FXIconItem* a,const FXIconItem* b); 00208 static FXint ascendingCase(const FXIconItem* a,const FXIconItem* b); 00209 static FXint descendingCase(const FXIconItem* a,const FXIconItem* b); 00210 public: 00211 enum { 00212 ID_SHOW_DETAILS=FXScrollArea::ID_LAST, 00213 ID_SHOW_MINI_ICONS, 00214 ID_SHOW_BIG_ICONS, 00215 ID_ARRANGE_BY_ROWS, 00216 ID_ARRANGE_BY_COLUMNS, 00217 ID_HEADER_CHANGE, 00218 ID_LOOKUPTIMER, 00219 ID_SELECT_ALL, 00220 ID_DESELECT_ALL, 00221 ID_SELECT_INVERSE, 00222 ID_LAST 00223 }; 00224 public: 00225 00226 /// Construct icon list 00227 FXIconList(FXComposite *p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=ICONLIST_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0); 00228 00229 /// Create server-side resources 00230 virtual void create(); 00231 00232 /// Detach server-side resources 00233 virtual void detach(); 00234 00235 /// Recalculate layout 00236 virtual void recalc(); 00237 00238 /// Perform layout 00239 virtual void layout(); 00240 00241 /// Compute and return content width 00242 virtual FXint getContentWidth(); 00243 00244 /// Return content height 00245 virtual FXint getContentHeight(); 00246 00247 /// Icon list can receive focus 00248 virtual FXbool canFocus() const; 00249 00250 /// Move the focus to this window 00251 virtual void setFocus(); 00252 00253 /// Remove the focus from this window 00254 virtual void killFocus(); 00255 00256 /// Return viewport size 00257 virtual FXint getViewportHeight(); 00258 00259 /// Resize this window to the specified width and height 00260 virtual void resize(FXint w,FXint h); 00261 00262 /// Move and resize this window in the parent's coordinates 00263 virtual void position(FXint x,FXint y,FXint w,FXint h); 00264 00265 /// Return number of items 00266 FXint getNumItems() const { return nitems; } 00267 00268 /// Return number of rows 00269 FXint getNumRows() const { return nrows; } 00270 00271 /// Return number of columns 00272 FXint getNumCols() const { return ncols; } 00273 00274 /// Return header control 00275 FXHeader* getHeader() const { return header; } 00276 00277 /// Append header with given text and optional icon 00278 void appendHeader(const FXString& text,FXIcon *icon=NULL,FXint size=1); 00279 00280 /// Remove header at index 00281 void removeHeader(FXint index); 00282 00283 /// Change text of header at index 00284 void setHeaderText(FXint index,const FXString& text); 00285 00286 /// Return text of header at index 00287 FXString getHeaderText(FXint index) const; 00288 00289 /// Change icon of header at index 00290 void setHeaderIcon(FXint index,FXIcon *icon); 00291 00292 /// Return icon of header at index 00293 FXIcon* getHeaderIcon(FXint index) const; 00294 00295 /// Change size of header at index 00296 void setHeaderSize(FXint index,FXint size); 00297 00298 /// Return width of header at index 00299 FXint getHeaderSize(FXint index) const; 00300 00301 /// Return number of headers 00302 FXint getNumHeaders() const; 00303 00304 /// Return the item at the given index 00305 FXIconItem *getItem(FXint index) const; 00306 00307 /// Replace the item with a [possibly subclassed] item 00308 FXint setItem(FXint index,FXIconItem* item,FXbool notify=FALSE); 00309 00310 /// Replace items text, icons, and user-data pointer 00311 FXint setItem(FXint index,const FXString& text,FXIcon *big=NULL,FXIcon* mini=NULL,void* ptr=NULL,FXbool notify=FALSE); 00312 00313 /// Insert a new [possibly subclassed] item at the give index 00314 FXint insertItem(FXint index,FXIconItem* item,FXbool notify=FALSE); 00315 00316 /// Insert item at index with given text, icons, and user-data pointer 00317 FXint insertItem(FXint index,const FXString& text,FXIcon *big=NULL,FXIcon* mini=NULL,void* ptr=NULL,FXbool notify=FALSE); 00318 00319 /// Append a [possibly subclassed] item to the end of the list 00320 FXint appendItem(FXIconItem* item,FXbool notify=FALSE); 00321 00322 /// Append new item with given text and optional icons, and user-data pointer 00323 FXint appendItem(const FXString& text,FXIcon *big=NULL,FXIcon* mini=NULL,void* ptr=NULL,FXbool notify=FALSE); 00324 00325 /// Prepend a [possibly subclassed] item to the end of the list 00326 FXint prependItem(FXIconItem* item,FXbool notify=FALSE); 00327 00328 /// Prepend new item with given text and optional icons, and user-data pointer 00329 FXint prependItem(const FXString& text,FXIcon *big=NULL,FXIcon* mini=NULL,void* ptr=NULL,FXbool notify=FALSE); 00330 00331 /// Move item from oldindex to newindex 00332 FXint moveItem(FXint newindex,FXint oldindex,FXbool notify=FALSE); 00333 00334 /// Remove item from list 00335 void removeItem(FXint index,FXbool notify=FALSE); 00336 00337 /// Remove all items from list 00338 void clearItems(FXbool notify=FALSE); 00339 00340 /// Return item width 00341 FXint getItemWidth(FXint index) const; 00342 00343 /// Return item height 00344 FXint getItemHeight(FXint index) const; 00345 00346 /// Return item width 00347 // FXint getItemWidth() const { return itemWidth; } 00348 00349 /// Return item height 00350 // FXint getItemHeight() const { return itemHeight; } 00351 00352 /// Return index of item at x,y, or -1 if none 00353 FXint getItemAt(FXint x,FXint y) const; 00354 00355 /** 00356 * Search items for item by name, starting from start item; the 00357 * flags argument controls the search direction, and case sensitivity. 00358 */ 00359 FXint findItem(const FXString& text,FXint start=-1,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const; 00360 00361 /// Scroll to make item at index visible 00362 void makeItemVisible(FXint index); 00363 00364 /// Change item text 00365 void setItemText(FXint index,const FXString& text); 00366 00367 /// Return item text 00368 FXString getItemText(FXint index) const; 00369 00370 /// Change item big icon 00371 void setItemBigIcon(FXint index,FXIcon* icon); 00372 00373 /// Return big icon of item at index 00374 FXIcon* getItemBigIcon(FXint index) const; 00375 00376 /// Change item mini icon 00377 void setItemMiniIcon(FXint index,FXIcon* icon); 00378 00379 /// Return mini icon of item at index 00380 FXIcon* getItemMiniIcon(FXint index) const; 00381 00382 /// Change item user-data pointer 00383 void setItemData(FXint index,void* ptr); 00384 00385 /// Return item user-data pointer 00386 void* getItemData(FXint index) const; 00387 00388 /// Return TRUE if item at index is selected 00389 FXbool isItemSelected(FXint index) const; 00390 00391 /// Return TRUE if item at index is current 00392 FXbool isItemCurrent(FXint index) const; 00393 00394 /// Return TRUE if item at index is visible 00395 FXbool isItemVisible(FXint index) const; 00396 00397 /// Return TRUE if item at index is enabled 00398 FXbool isItemEnabled(FXint index) const; 00399 00400 /// Return item hit code: 0 outside, 1 icon, 2 text 00401 FXint hitItem(FXint index,FXint x,FXint y,FXint ww=1,FXint hh=1) const; 00402 00403 /// Repaint item at index 00404 void updateItem(FXint index) const; 00405 00406 /// Enable item at index 00407 FXbool enableItem(FXint index); 00408 00409 /// Disable item at index 00410 FXbool disableItem(FXint index); 00411 00412 /// Select item at index 00413 virtual FXbool selectItem(FXint index,FXbool notify=FALSE); 00414 00415 /// Deselect item at index 00416 virtual FXbool deselectItem(FXint index,FXbool notify=FALSE); 00417 00418 /// Toggle item at index 00419 virtual FXbool toggleItem(FXint index,FXbool notify=FALSE); 00420 00421 /// Select items in rectangle 00422 virtual FXbool selectInRectangle(FXint x,FXint y,FXint w,FXint h,FXbool notify=FALSE); 00423 00424 /// Extend selection from anchor index to index 00425 virtual FXbool extendSelection(FXint index,FXbool notify=FALSE); 00426 00427 /// Deselect all items 00428 virtual FXbool killSelection(FXbool notify=FALSE); 00429 00430 /// Change current item index 00431 virtual void setCurrentItem(FXint index,FXbool notify=FALSE); 00432 00433 /// Return current item index, or -1 if none 00434 FXint getCurrentItem() const { return current; } 00435 00436 /// Change anchor item index 00437 void setAnchorItem(FXint index); 00438 00439 /// Return anchor item index, or -1 if none 00440 FXint getAnchorItem() const { return anchor; } 00441 00442 /// Return index of item under cursor, or -1 if none 00443 FXint getCursorItem() const { return cursor; } 00444 00445 /// Sort items 00446 void sortItems(); 00447 00448 /// Change text font 00449 void setFont(FXFont* fnt); 00450 00451 /// Return text font 00452 FXFont* getFont() const { return font; } 00453 00454 /// Return normal text color 00455 FXColor getTextColor() const { return textColor; } 00456 00457 /// Change normal text color 00458 void setTextColor(FXColor clr); 00459 00460 /// Return selected text background 00461 FXColor getSelBackColor() const { return selbackColor; } 00462 00463 /// Change selected text background 00464 void setSelBackColor(FXColor clr); 00465 00466 /// Return selected text color 00467 FXColor getSelTextColor() const { return seltextColor; } 00468 00469 /// Change selected text color 00470 void setSelTextColor(FXColor clr); 00471 00472 /// Change maximum item space for each item 00473 void setItemSpace(FXint s); 00474 00475 /// Return maximum item space 00476 FXint getItemSpace() const { return itemSpace; } 00477 00478 /// Return sort function 00479 FXIconListSortFunc getSortFunc() const { return sortfunc; } 00480 00481 /// Change sort function 00482 void setSortFunc(FXIconListSortFunc func){ sortfunc=func; } 00483 00484 /// Get the current icon list style 00485 FXuint getListStyle() const; 00486 00487 /// Set the current icon list style. 00488 void setListStyle(FXuint style); 00489 00490 /// Set the status line help text for this widget 00491 void setHelpText(const FXString& text); 00492 00493 /// Get the status line help text for this widget 00494 FXString getHelpText() const { return help; } 00495 00496 /// Save list to a stream 00497 virtual void save(FXStream& store) const; 00498 00499 /// Load list from a stream 00500 virtual void load(FXStream& store); 00501 00502 /// Destructor 00503 virtual ~FXIconList(); 00504 }; 00505 00506 } 00507 00508 #endif
![]() |