1 /***********************************************************************/
2 /* Open Visualization Data Explorer                                    */
3 /* (C) Copyright IBM Corp. 1989,1999                                   */
4 /* ALL RIGHTS RESERVED                                                 */
5 /* This code licensed under the                                        */
6 /*    "IBM PUBLIC LICENSE - Open Visualization Data Explorer"          */
7 /***********************************************************************/
8 
9 #include <dxconfig.h>
10 #include "../base/defines.h"
11 
12 
13 
14 
15 #ifndef _EditorWorkSpace_h
16 #define _EditorWorkSpace_h
17 
18 #include "WorkSpace.h"
19 #include "DXDropSite.h"
20 
21 
22 //
23 // Class name definition:
24 //
25 #define ClassEditorWorkSpace	"EditorWorkSpace"
26 
27 #define ORG_NONE                0       /* uninitialized origin value   */
28 #define ORG_SOURCE              1       /* source origin value          */
29 #define ORG_DESTINATION         2       /* destination origin value     */
30 
31 class NodeDefinition;
32 class Node;
33 class Ark;
34 class PageTab;
35 class WorkSpaceInfo;
36 
37 typedef struct _TrackingIndex
38 {
39     Node*                 node;           /* node index                   */
40     int                   param;          /* parameter index              */
41 
42 } TrackingIndex;
43 
44 
45 //
46 // EditorWorkSpace class definition:
47 //
48 class EditorWorkSpace : public WorkSpace, public DXDropSite
49 {
50   private:
51     //
52     // Private member data:
53     //
54     static Boolean EditorWorkSpaceClassInitialized;
55     static String  DefaultResources[];
56 
57     // 1 per class... Holds the data types thid drop site can swallow.
58     static Dictionary *DropTypeDictionary;
59 
60     // Define constants for the data types we can swallow in a dnd operation.  Use
61     // these instead of func pointers.  They're passed to addSupportedType and
62     // decoded in decodeDropType.
63     enum {
64 	Modules,
65 	ToolName,
66 	File,
67 	Text
68     };
69     static void SetOwner(void*);
70     static void DeleteSelections(void*);
71     static void Select(void*);
72 
73 
74     //
75     // Initialized to FALSE.  Set to TRUE, when the page has been filled with
76     // standins/decorators.  Reset to FALSE if any node is added to the group
77     // represented in this page.
78     //
79     boolean members_initialized;
80 
81     //
82     // Initialized to TRUE.  The user can turn it off.  Then editor won't have
83     // to open the page in order to produce postscript output.  The user's mechanism
84     // for turning this off is thru the PageSelector dialog.
85     //
86     boolean included_in_ps;
87 
88   protected:
89 
90     friend class StandIn;
91     friend class EditorWindow;
92     friend class PageTab; // really only needs PageTab::mergeNetElements90
93 
94     //
95     // Protected member data:
96     //
97 
98     EditorWindow    *editor;	    // Editor this workspace belongs to
99     Widget          io_tab;         /* source tab widget            */
100 
101     TrackingIndex   src;            /* source tab node & param.     */
102     TrackingIndex   dst;            /* dest.  tab node & param.     */
103 
104     int             origin;         /* originating location         */
105 
106     boolean         (*notify)();    /* network change notification  */
107                                         /*  callback                    */
108     XtPointer       client_data;    /* client data for the callback */
109 
110     XtEventHandler  tracker;        /* mouse tracking routine       */
111 
112     GC              gc_xor;         /* workspace XOR GC             */
113     GC              gc;             /* workspace  GC                */
114     Cursor          cursor[MAX_CURSORS];
115                                     /* workspace cursors            */
116 
117     boolean         first;          /* first line drawing?          */
118 
119     int             start_x;        /* line drawing coordinates     */
120     int             start_y;
121     int             first_x;
122     int             first_y;
123     int             last_x;
124     int             last_y;
125 
126     Widget          source_spot;    /* source spot widget           */
127     Widget          hot_spot;       /* hot spot widget              */
128     Node            *hot_spot_node; /* hot spot node index          */
129     int             remove_arcs;
130     Ark*             arc;
131 
132     XmFontList      font_list;      /* For the small font of parameter names */
133     Widget	    labeled_tab;    /* Tab whose label is currently displayed */
134     StandIn	    *labeled_si;    /* SI that is currently displaying	*/
135 				    /* a parameter label		*/
136 
137     //
138     // Called when the workspace background gets a double click.
139     //
140     void doDefaultAction(Widget w, XtPointer callData);
141 
142     //
143     // Called when the workspace background gets a single click.
144     //
145     void doBackgroundAction(Widget w, XtPointer callData);
146 
147     //
148     // Drag and Drop related stuff
149     // setRootWidget is not really dnd stuff.  It exists only because it
150     // provides a place to invoke this->setDropWidget().  This could be
151     // done elsewhere.
152     //
153     virtual void setRootWidget(Widget root, boolean standardDestroy = TRUE);
154     boolean mergeNetElements (Network *tmpnet, List *tmppanels, int x, int y);
155     boolean compoundTextTransfer (char *, XtPointer, unsigned long, int, int);
156     boolean decodeDropType (int, char *, XtPointer, unsigned long, int, int);
157 
getDropDictionary()158     virtual Dictionary *getDropDictionary(){ return EditorWorkSpace::DropTypeDictionary; }
159 
160     //
161     // Constructor:
162     //
163     EditorWorkSpace(const char *name, Widget parent, WorkSpaceInfo *info,
164 			EditorWindow *editor);
165 
166     //
167     // Destructor:
168     //
169     ~EditorWorkSpace();
170 
171     //
172     // Record scrollbar positions so that they can be recorded/reset when
173     // switching pages.
174     //
175     int scrollx;
176     int scrolly;
177     boolean recorded_positions;
178     boolean record_positions;
179 
180     //
181     // Track changes in the positions of things in the canvas so
182     // that we can provide an undo.  This is needed due to the new
183     // function that lays out the graph automatically.  The function
184     // might make a bad layout that the user would want to undo.
185     //
186     virtual void doPosChangeAction (Widget, XtPointer);
187 
188   public:
189 
190     //
191     // Record scrollbar positions so that they can be recorded/reset when
192     // switching pages.
193     //
setRecordedScrollPos(int x,int y)194     void setRecordedScrollPos (int x, int y) {
195 	this->recorded_positions = TRUE;
196 	this->scrollx = x;
197 	this->scrolly = y;
198     }
getRecordedScrollPos(int * x,int * y)199     void getRecordedScrollPos (int *x, int *y) {
200 	*x = this->scrollx;
201 	*y = this->scrolly;
202     }
hasScrollBarPositions()203     boolean hasScrollBarPositions() {
204 	return (this->recorded_positions && this->record_positions);
205     }
unsetRecordedScrollPos()206     void unsetRecordedScrollPos () { this->recorded_positions = FALSE; }
useRecordedPositions(boolean use_them)207     void useRecordedPositions(boolean use_them) {
208 	this->unsetRecordedScrollPos();
209 	this->record_positions = use_them;
210     }
getUsesRecordedPositions()211     boolean getUsesRecordedPositions() { return this->record_positions; }
212     void restorePosition();
213 
214     //
215     // One time class initializations.
216     //
217     void initializeRootWidget(boolean fromFirstIntanceOfADerivedClass = FALSE);
218 
219     //
220     // Get the bounding box of the children which are selected
221     //
222     virtual void getSelectedBoundingBox (int *minx, int *miny, int *maxx, int *maxy);
223 
membersInitialized()224     boolean membersInitialized() { return this->members_initialized; }
225     void setMembersInitialized(boolean init=TRUE) { this->members_initialized = init; }
226 
227     virtual void manage();
228     virtual void unmanage();
229 
230     void setPostscriptInclusion(boolean incl=TRUE) { this->included_in_ps = incl; }
getPostscriptInclusion()231     boolean getPostscriptInclusion() { return this->included_in_ps; }
232 
233     //
234     // Returns a pointer to the class name.
235     //
getClassName()236     const char* getClassName()
237     {
238 	return ClassEditorWorkSpace;
239     }
240 
241 };
242 
243 
244 #endif // _EditorWorkSpace_h
245