00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __OP_PostIt__
00021 #define __OP_PostIt__
00022
00023 #include "OP_API.h"
00024 #include <iostream.h>
00025
00026 #include <SYS/SYS_Types.h>
00027 #include <UT/UT_String.h>
00028 #include <UT/UT_Color.h>
00029 #include <UT/UT_PtrArray.h>
00030
00031 #include "OP_Node.h"
00032 #include "OP_PostItNoteFlags.h"
00033
00034 class OP_Network;
00035 class OP_Stat;
00036 class UT_AutoUndoBlock;
00037
00038 #define OP_POSTIT_DEFAULT_W 2.5F
00039 #define OP_POSTIT_DEFAULT_H 2.5F
00040 #define OP_POSTIT_MINIMUM_W 1.0F
00041 #define OP_POSTIT_MINIMUM_H 1.0F
00042 #define OP_POSTIT_MINIMIZED_W 2.5F
00043 #define OP_POSTIT_MINIMIZED_H 0.11F
00044
00045 #define OP_INVALID_POSTIT_ID -999
00046
00047 class OP_API OP_PostIt : public OP_NetworkBoxItem
00048 {
00049 public:
00050
00051
00052 OP_PostIt(const UT_String &name, OP_Network *net);
00053 virtual ~OP_PostIt();
00054
00055 virtual void setXY(fpreal x, fpreal y);
00056 virtual fpreal getX() const;
00057 virtual fpreal getY() const;
00058 virtual fpreal getW() const;
00059 virtual fpreal getH() const;
00060 fpreal getMaximizedW() const;
00061 fpreal getMaximizedH() const;
00062
00063 bool setXYWithBoundsChecks(fpreal x, fpreal y);
00064 bool setWWithBoundsChecks(fpreal h);
00065 bool setHWithBoundsChecks(fpreal h);
00066
00067 virtual const OP_PostItNoteFlags &flags() const
00068 { return static_cast<const OP_PostItNoteFlags &>(OP_NetworkBoxItem::flags()); }
00069 virtual OP_PostItNoteFlags &flags()
00070 { return static_cast<OP_PostItNoteFlags &>(OP_NetworkBoxItem::flags()); }
00071
00072
00073
00074 virtual int getPicked() const;
00075
00076
00077
00078 virtual int setPicked(int on_off, bool propagate_parent_event = true);
00079
00080
00081
00082
00083 static OP_PostIt *lookupPostItNote(int unique_id);
00084
00085 int getUniqueId() const { return myUniqueId; }
00086
00087
00088
00089
00090
00091 bool setName(const UT_String &name);
00092 virtual const UT_String &getItemName() const { return myName; };
00093
00094 bool setText(const UT_String &text);
00095 virtual const UT_String &getText() const { return myText; };
00096
00097 virtual OP_ItemType getItemType() const;
00098
00099 virtual OP_Network *getParentNetwork() const;
00100
00101
00102
00103
00104
00105
00106
00107
00108 void setW(fpreal w, bool force = false);
00109 void setH(fpreal h, bool force = false);
00110
00111
00112
00113
00114
00115
00116 void getItemBounds(fpreal &x1, fpreal &y1, fpreal &x2,
00117 fpreal &y2, bool incl_buff_border = true)
00118 const;
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129 void setResizing(bool resizing);
00130 bool getResizing();
00131
00132
00133
00134
00135
00136
00137 void setXY(fpreal x, fpreal y, bool force, bool propagate_parent_event);
00138
00139
00140
00141 virtual bool setColor(const UT_Color &color);
00142 virtual const UT_Color *getColor() const { return &myColor; }
00143
00144 const char* getType(void) const;
00145
00146 virtual OP_ERROR save(ostream &os, const OP_SaveFlags &sflags, const char *path_prefix);
00147 virtual OP_ERROR saveIntrinsic(ostream &os, const OP_SaveFlags &sflags);
00148
00149
00150
00151
00152 virtual bool load(UT_IStream &is, const char *ext="", const char *path=0);
00153
00154 void clearErrors()
00155 {
00156 UTgetErrorManager()->clearAndDestroyErrors();
00157 myErrorManager.clearAndDestroyErrors();
00158 }
00159
00160 virtual OP_ERROR error()
00161 {
00162 if( UTgetErrorManager()->getNumErrors() > 0 )
00163 stealGlobalErrors();
00164 return myErrorManager.getSeverity();
00165 }
00166 void opMessage(int code, const char *m=0) const
00167 { UTaddMessage("OP",code,m);}
00168 void opWarning(int code, const char *m=0) const
00169 { UTaddWarning("OP",code,m);}
00170 void opError(int code, const char *m=0) const
00171 { UTaddError("OP", code, m);}
00172
00173 UT_ErrorManager &getMyErrorManager() { return myErrorManager; }
00174 void stealErrors(UT_ErrorManager &src, bool borrow_only);
00175
00176 virtual OP_ERROR getErrorSeverity()
00177 { return myErrorManager.getSeverity(); }
00178
00179 void getFullPath(UT_String &str) const;
00180 static void clearAllPendingUndoFlags(void);
00181
00182
00183 bool getMinimized() const;
00184
00185
00186
00187
00188
00189 bool setMinimized(bool isminimized,
00190 bool update_position,
00191 bool propagate_parent_event);
00192
00193
00194
00195 int saveCommand(ostream &os) const;
00196
00197 private:
00198
00199
00200 void setUniqueId(int id);
00201
00202 OP_ERROR saveIntrinsicError();
00203 OP_ERROR saveError();
00204
00205 bool loadPostItFlags(UT_IStream &is, const char *path);
00206 bool loadNetworkBox(UT_IStream &is, const char *path);
00207 bool loadIntrinsic(UT_IStream &is, const char *path);
00208 virtual bool loadPacket(UT_IStream &is, short class_id, short signature, const char *path = 0);
00209 virtual bool loadPacket(UT_IStream &is, const char *token, const char *path=0);
00210
00211 void stealGlobalErrors();
00212
00213
00214 OP_ERROR saveNetworkBox(ostream &os, const OP_SaveFlags &sflags, const char *path_prefix);
00215
00216 void saveForUndoTextChange(void);
00217 void saveForUndoRename(void);
00218 void saveForUndoMinimize(void);
00219 void saveForUndoColor(void);
00220 void saveForUndoLayout(void);
00221 void saveForUndoResize(void);
00222 void setAnyUndoFlag(void);
00223
00224 void clearUndoFlags(void);
00225 bool getAnyUndoPending() const;
00226
00227 friend class OP_Network;
00228
00229 private:
00230
00231 UT_ErrorManager myErrorManager;
00232
00233
00234
00235 int myUniqueId;
00236
00237 UT_String myName;
00238 UT_String myText;
00239 OP_Network *myNetwork;
00240
00241
00242
00243 OP_Stat myStats;
00244
00245 UT_Color myColor;
00246
00247
00248 fpreal myX, myY;
00249 fpreal myW, myH;
00250
00251 bool myAnyUndoFlagSet;
00252 UT_AutoUndoBlock *myUndoResizeBlock;
00253 };
00254
00255 #endif
00256