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 //
16 //
17 
18 #ifndef _Decorator_h
19 #define _Decorator_h
20 
21 #include <X11/Intrinsic.h>
22 
23 #include "WorkSpaceComponent.h"
24 #include "DynamicResource.h"
25 #include "DXDragSource.h"
26 
27 class DecoratorStyle;
28 class Network;
29 class DecoratorInfo;
30 class Dialog;
31 
32 #define ClassDecorator	"Decorator"
33 #define DEFAULT_SETTING "(default)"
34 
35 
36 class Decorator : public WorkSpaceComponent, public DXDragSource
37 {
38   friend class DecoratorStyle;
39 
40   // P R I V A T E   P R I V A T E   P R I V A T E
41   // P R I V A T E   P R I V A T E   P R I V A T E
42   private:
43     WidgetClass	widgetClass;
44 
45     //
46     // When the decorator is in a c.p. there is a requirement for it to know its
47     // ControlPanel pointer (because dnd requires printing which requires ownerCp
48     // inside Network::cfgPrint).  But it would be too wierd to put a ControlPanel*
49     // in here because sometimes we live in the vpe.
50     //
51     DecoratorInfo* dndInfo;
52 
53     static 	boolean 	 DecoratorClassInitialized;
54     static      const char *	 ColorNames[];
55     static      const char *	 ColorValues[];
56 
57   // P R O T E C T E D   P R O T E C T E D   P R O T E C T E D
58   // P R O T E C T E D   P R O T E C T E D   P R O T E C T E D
59   protected:
60     // S H A R E W A R E
61     static  String 	   DefaultResources[];
62     static  int		   HiLites;
63 
64     virtual void 	   createDecorator();
65     Dimension 	x,y,width, height;
66     DecoratorStyle *style;
67 
68     // add late breaking news - just like interactors, but not required
completeDecorativePart()69     virtual void completeDecorativePart() {};
70 
71 
72     // D R A G - N - D R O P   R E L A T E D   S T U F F
73     // D R A G - N - D R O P   R E L A T E D   S T U F F
74     static Widget DragIcon;
75 
76     // 1 enum for each type of Drag data we can supply.  Pass these to addSupportedType
77     // and decode them in decodeDragType.  These replace the use of func pointers.
78     // The dictionary lives in the subclasses.
79     enum {
80         Modules,
81         Interactors,
82         Trash,
83 	Text
84     };
85 
86     virtual int decideToDrag(XEvent *);
87     virtual void    dropFinish (long, int, unsigned char);
88     //
89     // Providing these 2 means that subclasses don't have to provide dnd
90     // functionality.  This makes sense for placing arbitrary widgets
91     // which may/may not provide a hunk of data.
92     //
decodeDragType(int,char *,XtPointer *,unsigned long *,long)93     virtual boolean decodeDragType (int, char *, XtPointer *, unsigned long *, long )
94 	{ return FALSE; }
getDragDictionary()95     virtual Dictionary* getDragDictionary() { return NUL(Dictionary*); }
96 
97     //
98     // Constructor
99     //
100     Decorator(void *wClass, const char * name, boolean developerStyle = TRUE);
101 
102     //
103     // When decorators are in the vpe we always want them to get a new size when
104     // something changes, but in panels, it seems better to maintain dimensions.
105     // Inside panels, users try to line things up and make widths of several things
106     // be equal, so I don't want to keep changing widths for them.  That's never
107     // the case in the vpe.
108     //
resizeOnUpdate()109     virtual boolean resizeOnUpdate() { return FALSE; }
110 
111     //
112     // this is for java support. It chops strings up into their individual
113     // lines.  It's used in LabelDecorator and it's a copy of code from
114     // InteractorInstance.
115     // FIXME: It needs to be pushed up the heirarchy.
116     //
117     static int CountLines(const char*);
118     static const char* FetchLine(const char*, int);
119 
120   // P U B L I C   P U B L I C   P U B L I C
121   // P U B L I C   P U B L I C   P U B L I C
122   public:
123     virtual   void	     openDefaultWindow();
getDialog()124     virtual   Dialog*	     getDialog() { return NUL(Dialog*); }
125     virtual   void	     setAppearance (boolean developerStyle);
setStyle(DecoratorStyle * ds)126 	      void           setStyle (DecoratorStyle *ds) {this->style = ds; }
getStyle()127 	      DecoratorStyle *getStyle () { return this->style; }
hasDefaultWindow()128     virtual   boolean	     hasDefaultWindow() { return FALSE; }
129     virtual   void	     uncreateDecorator();
130     virtual   void	     setSelected (boolean state);
131 
132 
133     // G E O M E T R Y   G E O M E T R Y   G E O M E T R Y
134     // G E O M E T R Y   G E O M E T R Y   G E O M E T R Y
135     virtual   void	     setXYPosition (int x, int y);
136     virtual   void	     setXYSize (int w, int h);
137     virtual   void	     getXYPosition (int *x, int *y);
138     virtual   void	     getXYSize (int *x, int *y);
139 
140     // D Y N A M I C   R E S O U R C E S
141     // D Y N A M I C   R E S O U R C E S
142     virtual boolean parseResourceComment (const char *comment,
143     const   char    *filename, int line);
144     virtual void    setResource (const char *, const char *);
getSupportedColorNames()145     const char **getSupportedColorNames() { return Decorator::ColorNames; }
getSupportedColorValues()146     const char **getSupportedColorValues() { return Decorator::ColorValues; }
147 
148     // C O N T R O L   P A N E L   C O M M E N T   F U N C T I O N S
149     // C O N T R O L   P A N E L   C O M M E N T   F U N C T I O N S
150     virtual   boolean	     printComment (FILE *f);
151     virtual   boolean	     parseComment (const char *comment,
152 					      const char *filename, int line);
153 
154     virtual   Network*       getNetwork();
155               void           setDecoratorInfo(DecoratorInfo *);
getDecoratorInfo()156               DecoratorInfo* getDecoratorInfo() { return this->dndInfo; }
157               boolean        createNetFiles (Network*, FILE*, char *);
158 
159     // J A V A     J A V A     J A V A     J A V A     J A V A
160     // J A V A     J A V A     J A V A     J A V A     J A V A
printAsJava(FILE *,const char *,int)161     virtual boolean printAsJava (FILE*, const char*, int) { return TRUE; }
162     virtual boolean printJavaResources (FILE*, const char*, const char*);
163 
164 
165     // T H E   T H I N G S   W E   U S E   A L L   T H E   T I M E
166     // T H E   T H I N G S   W E   U S E   A L L   T H E   T I M E
167     // T H E   T H I N G S   W E   U S E   A L L   T H E   T I M E
manage()168     virtual   void manage() { this->WorkSpaceComponent::manage(); };
169     virtual   void manage(WorkSpace *workSpace);
170     ~Decorator();
getClassName()171     const    char* getClassName() { return ClassDecorator; }
172     virtual  boolean isA(Symbol classname);
173 };
174 
175 
176 #endif // _Decorator_h
177