00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef QGO4WIDGET_H
00015 #define QGO4WIDGET_H
00016
00017 #include <QWidget>
00018
00019 #include <QDragMoveEvent>
00020 #include <QCloseEvent>
00021 #include <QDropEvent>
00022 #include <QDragEnterEvent>
00023 #include <QIcon>
00024
00025 class TObject;
00026 class TClass;
00027 class TPad;
00028 class TGo4Slot;
00029 class TGo4ViewPanel;
00030 class TGo4BrowserProxy;
00031 class TGo4AnalysisProxy;
00032 class QMenu;
00033 class QAction;
00034 class QSignalMapper;
00035
00036 #ifdef WIN32
00037
00038 #ifdef GO4_EXPORT
00039 #define GO4_CLASS_EXPORT __declspec(dllexport)
00040 #else
00041 #define GO4_CLASS_EXPORT __declspec(dllimport)
00042 #endif
00043
00044 #else
00045
00046 #define GO4_CLASS_EXPORT
00047
00048 #endif
00049
00050
00051 #ifdef WIN32
00052 class GO4_CLASS_EXPORT QGo4Widget : public QWidget {
00053 #else
00054 #include <QtDesigner/QDesignerExportWidget>
00055 class QDESIGNER_WIDGET_EXPORT QGo4Widget : public QWidget {
00056 #endif
00057
00058 Q_OBJECT
00059
00060 friend class TGo4MainWindow;
00061
00062 public:
00063 enum { service_DragEnter = 1,
00064 service_DropEvent = 2,
00065 service_CreateItem = 3,
00066 service_DrawItem = 4,
00067 service_EditItem = 5,
00068 service_ShowInfo = 6,
00069 service_EditInSlot = 7,
00070 service_SaveItem = 8,
00071 service_UpdateAnalysisItem = 9,
00072 service_StatusMessage = 15,
00073 service_CreateViewPanel = 17,
00074 service_BrowserItemRemote = 18,
00075 service_Browser = 19,
00076 service_SaveToMemory = 20,
00077 service_GetAnalysis = 21,
00078 service_AddEditorLink = 22,
00079 service_AddDirectLink = 23,
00080 service_AddLinkInSlot = 24,
00081 service_GetTopSlot = 25,
00082 service_AddEditorSlot = 26,
00083 service_SetLinkedName = 27,
00084 service_GetLinkedName = 28,
00085 service_GetLinkedName2 = 29,
00086 service_GetLinked0 = 30,
00087 service_GetLinked1 = 31,
00088 service_GetLinked2 = 32,
00089 service_RemoveLink = 33,
00090 service_RemoveAllLinks = 34,
00091 service_ObjectCreated = 35,
00092 service_ConnectPad = 36,
00093 service_LastActivePanel = 37,
00094 service_WhereItemDrawn = 38,
00095 service_UndrawItem = 39,
00096 service_General = 40,
00097 service_PanelTimer = 41,
00098 service_HelpWindow = 42,
00099 service_HotStart = 43,
00100 panel_Activated = 101,
00101 panel_Modified = 102,
00102 panel_Updated = 103,
00103 panel_ActiveUpdated = 104,
00104 panel_PadDeleted = 105,
00105 panel_Deleted = 106 };
00106
00107 QGo4Widget(QWidget * parent = 0, const char * name = 0, Qt::WindowFlags f = 0 );
00108 virtual ~QGo4Widget();
00109
00110 virtual bool IsAcceptDrag(const char* itemname, TClass* cl, int kind);
00111 virtual void DropItem(const char* itemname, TClass* cl, int kind);
00112 virtual void ResetWidget();
00113
00114 void ObjectCreatedByWidget(const char* itemname, TClass* cl);
00115
00116 void ProcessSignal(const char* linkname, bool assigned, TObject* obj, TGo4Slot* slot);
00117
00118 signals:
00119 void widgetService(QGo4Widget* editor, int serviceid, const char* str, void* par);
00120
00121 public slots:
00122 void ResetWidgetSlot();
00123
00124 protected:
00125 virtual void closeEvent(QCloseEvent* e);
00126 virtual void dragEnterEvent(QDragEnterEvent *e);
00127 virtual void dragMoveEvent(QDragMoveEvent* e);
00128 virtual void dropEvent(QDropEvent* e);
00129
00131 void AddLink(const char* itemname, const char* linkname);
00132
00134 void AddLink(TGo4Slot* slot, const char* linkname);
00135
00137 TGo4Slot* AddLink(const char* itemname, TGo4Slot* parent);
00138
00140 TGo4Slot* GetTopSlot(bool force = false);
00141
00143 TGo4Slot* AddSlot(const char* slotname);
00144
00146 void SetLinkedName(TGo4Slot* slot, const char* itemname);
00147
00149 const char* GetLinkedName(const char* linkname);
00150
00152 const char* GetLinkedName(TGo4Slot* slot);
00153
00154 TObject* GetLinked(const char* linkname, int updatelevel);
00155 void RemoveLink(const char* linkname, bool blockreset = true);
00156 void RemoveAllLinks(bool blockreset = true);
00157 void RemoveLinksMasked(const char* startedwith = 0, bool blockreset = true);
00158
00159 bool BrowserItemRemote(const char* itemname);
00160 TGo4BrowserProxy* Browser();
00161
00162 void StatusMessage(const QString& message);
00163
00168 void AskToCreateObject(TClass* cl, int isremote);
00169 void ShowItemInfo(const QString& itemname);
00170 TGo4ViewPanel* CreateViewPanel(int ndiv = 0);
00171 TGo4ViewPanel* DrawItem(const QString& itemname, TGo4ViewPanel* panel = 0, TPad* pad = 0, bool activate = true, int updatelevel = -1);
00172 TGo4ViewPanel* WhereItemDrawn(const char* itemname);
00173 void HelpWindow(const char* filename, const char* msg = 0);
00174 void UndrawItem(const char* itemname);
00175 TGo4ViewPanel* LastActivePanel();
00176 void EditItem(const QString& itemname);
00177 void EditObjectInSlot(TGo4Slot* slot);
00178 QString SaveObjectInMemory(const char* foldername, TObject* obj);
00179 bool SaveItemToFile(const char* itemname, const char* subfolder = 0);
00180 bool UpdateItemInAnalysis(const char* itemname, TObject* obj = 0);
00181 void InformThatObjectCreated(const char* itemname, TClass* cl);
00182 TGo4AnalysisProxy* GetAnalysis(const char* itemname = 0);
00183 void StartHotstart(const char* filename);
00184
00186 void ConnectPad(TPad* pad);
00187
00188 void CallServiceFunc(int id, const char* str = 0, void* par = 0);
00189 void ServiceCall(const char* name, void* par = 0);
00190
00191 virtual void requestedObjectCreated(const char* itemname, TClass* cl);
00192 virtual void linkedObjectUpdated(const char* linkname, TObject* obj);
00193 virtual void linkedObjectRemoved(const char* linkname);
00194 virtual void linkedUpdated(TGo4Slot* slot, TObject* obj);
00195 virtual void linkedRemoved(TGo4Slot* slot, TObject* obj);
00196
00197 void setCanDestroyWidget(bool on = true) { fCanDestroyWidget = on; }
00198
00199 void CallPanelFunc(int id, TPad* pad = 0);
00200
00201 void ShootResetWidget();
00202 void ShootCloseWidget(bool closeparent = false);
00203
00204 bool IsUpdateBlocked() const { return fBlockUpdate; }
00205
00206 private:
00207 bool fWaitsForObjectCreation;
00208 bool fCanDestroyWidget;
00209 bool fResetWidgetShooted;
00210 bool fBlockUpdate;
00211
00212 TGo4BrowserProxy* fBrowserProxy;
00213 };
00214
00215 extern QAction* AddChkAction(QMenu* menu,
00216 const QString& text, bool checked,
00217 QObject* recv, const char* member);
00218
00219 extern QAction* AddIdAction(QMenu* menu, QSignalMapper* map,
00220 const QString& text, int id, int enabled = -1, int checked = -1);
00221
00222 extern QAction* AddIdAction(QMenu* menu, QSignalMapper* map,
00223 const QIcon& icon, const QString& text, int id, int enabled = -1, int checked = -1);
00224
00225 QAction* SetIdAction(QSignalMapper* map, int id, int enabled = -1, int checked = -1);
00226
00227
00228 #endif