![]() |
Main Page
Class Hierarchy
Alphabetical List
Compound List
File List
Compound Members
![]() |
00001 /******************************************************************************** 00002 * FXNetworkListEx.h Copyright (C) 2001 by Dustin Graves. All Rights Reserved. * 00003 ********************************************************************************* 00004 * This library is free software; you can redistribute it and/or * 00005 * modify it under the terms of the GNU Lesser General Public * 00006 * License as published by the Free Software Foundation; either * 00007 * version 2.1 of the License, or (at your option) any later version. * 00008 * * 00009 * This library is distributed in the hope that it will be useful, * 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00012 * Lesser General Public License for more details. * 00013 * * 00014 * You should have received a copy of the GNU Lesser General Public * 00015 * License along with this library; if not, write to the Free Software * 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * 00017 ********************************************************************************/ 00018 #ifdef WIN32 00019 #ifndef FXNETWORKLISTEX_H 00020 #define FXNETWORKLISTEX_H 00021 00022 #ifndef FXTREEELIST_H 00023 #include <fox/FXTreeList.h> 00024 using namespace FX; 00025 #endif 00026 namespace FXEX { 00027 00028 //Network List options 00029 enum { 00030 NETWORKLISTEX_SHOWSHARES = 0x08000000 //Show connectables as well as containers 00031 }; 00032 00033 /** 00034 * Network share, as an item 00035 */ 00036 class FXAPI FXNetworkItemEx : public FXTreeItem { 00037 FXDECLARE(FXNetworkItemEx) 00038 friend class FXNetworkListEx; 00039 00040 protected: 00041 FXuint type; 00042 NETRESOURCE *netres; 00043 00044 protected: 00045 FXNetworkItemEx():FXTreeItem(),type(0),netres(NULL){} 00046 void setNetResource(const NETRESOURCE* nr); 00047 00048 private: 00049 void freeNetResource(); 00050 00051 protected: 00052 enum { 00053 CONNECTABLE = 256, 00054 CONTAINER = 512 00055 }; 00056 enum { 00057 NETWORKITEMEX_GENERIC = 0, 00058 NETWORKITEMEX_NETHOOD = 1, 00059 NETWORKITEMEX_ROOT = 2, 00060 NETWORKITEMEX_NETWORK = 4, 00061 NETWORKITEMEX_DOMAIN = 8, 00062 NETWORKITEMEX_COMPUTER = 16, 00063 NETWORKITEMEX_SHARE = 32 //In case we ever want to show shares on computers 00064 }; 00065 00066 public: 00067 /// ctor 00068 FXNetworkItemEx(const FXString& text,FXIcon* oi=NULL,FXIcon* ci=NULL,void* ptr=NULL):FXTreeItem(text,oi,ci,ptr),type(NETWORKITEMEX_GENERIC),netres(NULL){} 00069 00070 // get property 00071 FXbool isConnectable() const {return (state&CONNECTABLE)!=0;} 00072 FXbool isContainer() const {return (state&CONTAINER)!=0;} 00073 00074 /// get resource type 00075 FXbool isGeneric() const {return (type&NETWORKITEMEX_GENERIC)!=0;} 00076 FXbool isNethood() const {return (type&NETWORKITEMEX_NETHOOD)!=0;} 00077 FXbool isRoot() const {return (type&NETWORKITEMEX_ROOT)!=0;} 00078 FXbool isNetwork() const {return (type&NETWORKITEMEX_NETWORK)!=0;} 00079 FXbool isDomain() const {return (type&NETWORKITEMEX_DOMAIN)!=0;} 00080 FXbool isComputer() const {return (type&NETWORKITEMEX_COMPUTER)!=0;} 00081 FXbool isShare() const {return (type&NETWORKITEMEX_SHARE)!=0;} 00082 00083 /// dtor 00084 virtual ~FXNetworkItemEx(); 00085 }; 00086 00087 /** 00088 * List network shares 00089 */ 00090 class FXAPI FXNetworkListEx : public FXTreeList { 00091 FXDECLARE(FXNetworkListEx) 00092 00093 protected: 00094 FXIcon *nethoodicon; 00095 FXIcon *genericicon; 00096 FXIcon *rooticon; 00097 FXIcon *networkicon; 00098 FXIcon *domainicon; 00099 FXIcon *computericon; 00100 FXIcon *shareicon; 00101 00102 protected: 00103 FXNetworkListEx() : FXTreeList() {} 00104 virtual FXTreeItem* createItem(const FXString& text,FXIcon* oi,FXIcon* ci,void* ptr); 00105 FXbool listNetworkPlaces(); 00106 FXbool enumerateNetwork(FXNetworkItemEx* par,NETRESOURCE* container); 00107 FXbool relistNetworkPlaces(); 00108 00109 private: 00110 FXNetworkListEx(const FXNetworkListEx&); 00111 FXNetworkListEx &operator=(const FXNetworkListEx&); 00112 00113 public: 00114 long onOpened(FXObject*,FXSelector,void*); 00115 long onClosed(FXObject*,FXSelector,void*); 00116 long onExpanded(FXObject*,FXSelector,void*); 00117 long onCollapsed(FXObject*,FXSelector,void*); 00118 long onCmdSetValue(FXObject*,FXSelector,void*); 00119 long onCmdSetStringValue(FXObject*,FXSelector,void*); 00120 long onCmdGetStringValue(FXObject*,FXSelector,void*); 00121 00122 public: 00123 static FXint cmpName(const FXTreeItem* a,const FXTreeItem* b); 00124 00125 public: 00126 enum { 00127 ID_REFRESH=FXTreeList::ID_LAST, 00128 ID_LAST 00129 }; 00130 00131 public: 00132 /// ctor 00133 FXNetworkListEx(FXComposite *p,FXint nvis,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0); 00134 00135 /// create resources 00136 virtual void create(); 00137 00138 /// detach resources 00139 virtual void detach(); 00140 00141 /// destroy resources 00142 virtual void destroy(); 00143 00144 /// When called, will relist net neighborhood. A wait cursor is optional. 00145 FXbool refreshNetworkList(FXbool waitCursor=FALSE); 00146 00147 /// When called, option to relist net neighborhood. A wait cursor is optional. 00148 void showNetworkShares(FXbool show,FXbool refresh=FALSE,FXbool waitCursor=FALSE); 00149 FXbool showNetworkShares() const; 00150 00151 /// get property 00152 FXbool isItemConnectable(const FXTreeItem* item) const; 00153 FXbool isItemContainer(const FXTreeItem* item) const; 00154 00155 /// get resource type 00156 FXbool isItemGeneric(const FXNetworkItemEx* item) const; 00157 FXbool isItemNethood(const FXNetworkItemEx* item) const; 00158 FXbool isItemRoot(const FXNetworkItemEx* item) const; 00159 FXbool isItemNetwork(const FXNetworkItemEx* item) const; 00160 FXbool isItemDomain(const FXNetworkItemEx* item) const; 00161 FXbool isItemComputer(const FXNetworkItemEx* item) const; 00162 FXbool isItemShare(const FXNetworkItemEx* item) const; 00163 00164 /// manipulate the selection 00165 void setCurrentSelection(const FXString& name); 00166 FXString getCurrentSelection() const; 00167 00168 /// Finds network name from the item's label 00169 FXString getNetworkName(const FXString& name) const; 00170 FXString getNetworkName(const FXNetworkItemEx* item) const; 00171 FXString getCurrentNetworkName() const; 00172 00173 /// save to stream 00174 virtual void save(FXStream& store) const; 00175 00176 /// load from stream 00177 virtual void load(FXStream& store); 00178 00179 /// dtor 00180 virtual ~FXNetworkListEx(); 00181 }; 00182 00183 } // namespace FXEX 00184 #endif // FXNETWORKLISTEX_H 00185 #endif 00186