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 _ValueInteractor_h
16 #define _ValueInteractor_h
17 
18 #include <Xm/Xm.h>
19 
20 #include "Interactor.h"
21 
22 //
23 // Class name definition:
24 //
25 #define ClassValueInteractor	"ValueInteractor"
26 
27 //
28 // XtCallbackProc (*CB), XtEventHandler (*EH) and XtActionProc (*AP)
29 // DialogCallback (*DCB), XtInputCallbackProc (*ICP), XtWorkProc (*WP)
30 // functions for this and derived classes
31 //
32 extern "C" void ValueInteractor_ValueChangeCB(Widget, XtPointer, XtPointer);
33 
34 class InteractorNode;
35 class InteractorInstance;
36 class Node;
37 class Network;
38 //class ControlPanel;
39 //class Dialog;
40 //class SetAttrDialog;
41 
42 //
43 // Virtual Interactor class definition:
44 //
45 class ValueInteractor : public Interactor
46 {
47   private:
48     //
49     // Private member data:
50     //
51     static boolean ClassInitialized;
52 
53     friend void ValueInteractor_ValueChangeCB(Widget w, XtPointer clientData,
54 					XtPointer callData);
55 
56   protected:
57     //
58     // Protected member data:
59     //
60 
61     static String DefaultResources[];
62     Widget textEditor;
63 
64     //
65     // Build the stepper, dial, ... widget tree and set any information
66     // that is specific to the derived class.  Passes back an unmanaged widget
67     // that is put in the frame created by this->createFrame().
68     //
69     virtual Widget createInteractivePart(Widget p);
70     void completeInteractivePart();
71 
72     //
73     // Build the text editing widget (without callbacks)
74     //
75     Widget createTextEditor(Widget parent);
76 
77 
78     //
79     // Handle a change in the text
80     //
81     void valueChangeCallback(Widget w, XtPointer cb);
82 
83     //
84     // Update the text value with the give string.
85     //
86     void installNewText(const char *text);
87 
88     //
89     // Get the text that is currently displayed in the text window.
90     // The returned string must be freed by the caller.
91     //
92     char *getDisplayedText();
93 
94 
95   public:
96     //
97     // Constructor:
98     //
99     ValueInteractor(const char * name, InteractorInstance *ii);
100 
101     //
102     // Destructor:
103     //
104     ~ValueInteractor();
105 
106     //
107     // Allocate the interactor class and widget tree.
108     //
109     static Interactor *AllocateInteractor(const char *name,
110 					InteractorInstance *ii);
111 
112 
113     virtual void handleInteractivePartStateChange(
114 				InteractorInstance *src_ii,
115 				boolean major_change);
116 
117     //
118     // Update the display values for an interactor;
119     // Called when an InteractorNode does a this->setOutputValue().
120     //
121     virtual void updateDisplayedInteractorValue(void);
122 
123 
124     //
125     // One time initialize for the class.
126     //
127     virtual void initialize();
128 
129     //
130     // Returns a pointer to the class name.
131     //
getClassName()132     const char* getClassName()
133     {
134 	return ClassValueInteractor;
135     }
136 };
137 
138 
139 #endif // _ValueInteractor_h
140