00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * Joe Drew 00008 * Side Effects Software Inc 00009 * 477 Richmond Street West 00010 * Toronto, Ontario 00011 * Canada M5V 3E7 00012 * 416-504-9876 00013 * 00014 * NAME: OP_NetworkBoxList.h (OP Library, C++) 00015 * 00016 * COMMENTS: 00017 */ 00018 00019 #ifndef __OP_NetworkBoxList__ 00020 #define __OP_NetworkBoxList__ 00021 00022 #include "OP_API.h" 00023 #include <SYS/SYS_Types.h> 00024 #include <UT/UT_PtrArray.h> 00025 00026 #include "OP_Error.h" 00027 #include "OP_Node.h" 00028 00029 class OP_Network; 00030 class OP_NetworkBox; 00031 class OP_NetworkBoxItem; 00032 class OP_SaveFlags; 00033 00034 class OP_API OP_NetworkBoxList : public UT_PtrArray<OP_NetworkBox *> 00035 { 00036 public: 00037 OP_NetworkBoxList(OP_Network *net); 00038 virtual ~OP_NetworkBoxList(); 00039 00040 /// Remove all network boxes from this list 00041 void clearAndDestroy(); 00042 00043 /// Create a network box with the specified name and insert it into this 00044 /// OP_NetworkBoxList at the next available index. Returns a pointer to the 00045 /// OP_NetworkBox created or NULL if creation was unsuccessful. Pass in NULL 00046 /// as the name if you'd like a default name. If a duplicate name is passed 00047 /// in, it will be altered to make it unique. Passing in 'items' will 00048 /// automatically create a network box containing those items with the 00049 /// netbox positioned properly around them. 00050 OP_NetworkBox *createNetworkBox(const char *name, 00051 UT_PtrArray<OP_NetworkBoxItem *> *items = NULL); 00052 00053 /// Find and return a given network box by name, or NULL if it's not found 00054 OP_NetworkBox *findNetworkBox(const char *name) const; 00055 00056 /// Find the index of a given network box by name. Returns -1 if not found 00057 int findNetworkBoxIndex(const char *name) const; 00058 00059 /// Find the index of a given network box by ptr. Returns -1 if not found 00060 int findNetworkBoxIndex(OP_NetworkBox *netbox) const; 00061 00062 /// Remove a network box by ptr. Returns true if it was successfully 00063 /// removed; false if the box wasn't found 00064 bool deleteNetworkBox(OP_NetworkBox *netbox); 00065 00066 /// Remove a network box by index. Returns true if it was successfully 00067 /// removed; false if the index is invalid 00068 bool deleteNetworkBox(int index); 00069 00070 /// Save the entire list to the ostream os. 'path_prefix' should be the path 00071 /// you want to save the netboxes as being under. 00072 OP_ERROR save(ostream &os, const OP_SaveFlags &flags, 00073 const char *path_prefix) const; 00074 00075 ///Load a network box from 'is'. Can load from both .hip files and the 00076 ///clipboard. 'path' is used as the new netbox's name (only the portion of 00077 ///path after the last slash). If 'overwrite' is specified, the new netbox 00078 ///will overwrite any other netboxes in this network with the same name, 00079 ///rather than modify its name to be unique. 'created' is used to return a 00080 ///ptr to the new network box. 00081 bool load(UT_IStream &is, const char *path, 00082 int overwrite = 0, OP_NetworkBox **created = NULL); 00083 00084 ///Saves all picked netboxes in this list to the clipboard for copy/paste, 00085 ///etc. Returns the total # items saved. 00086 int savePickedToClipboard(ostream &os, const OP_SaveFlags &flags, 00087 int all=0) const; 00088 00089 ///Saves all netboxes in the provided list to the clipboard. Returns the 00090 ///total # of items saved. 00091 int saveListToClipboard(ostream &os, const OP_SaveFlags &flags, 00092 const UT_PtrArray<OP_NetworkBox *> 00093 &netboxes) const; 00094 00095 ///Save 'netbox' to 'os'. 'path_prefix' should be the path you want to save 00096 ///the netbox as being under. 00097 OP_ERROR saveSingleNetworkBox(ostream &os, OP_NetworkBox &netbox, 00098 const OP_SaveFlags &flags, 00099 const char *path_prefix) const; 00100 00101 ///DEPRECATED: Do not use this. It only exists to allow backwards- 00102 /// compatibility loading support for saves done with the old 00103 /// save mechanism (OP_NETWORKBOX_LIST_VERSION of 1) during the 00104 /// brief time during which it was available. Use 'load()' 00105 /// instead. 00106 /// 00107 ///Loads a single netbox from the clipboard. 00108 SYS_DEPRECATED OP_NetworkBox *loadFromClipboard(UT_IStream &is, 00109 const char *path) const; 00110 00111 private: 00112 00113 OP_Network *myNetwork; 00114 }; 00115 00116 #endif
1.5.9