NEURON
field.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 1991 Stanford University
3  * Copyright (c) 1991 Silicon Graphics, Inc.
4  *
5  * Permission to use, copy, modify, distribute, and sell this software and
6  * its documentation for any purpose is hereby granted without fee, provided
7  * that (i) the above copyright notices and this permission notice appear in
8  * all copies of the software and related documentation, and (ii) the names of
9  * Stanford and Silicon Graphics may not be used in any advertising or
10  * publicity relating to the software without the specific, prior written
11  * permission of Stanford and Silicon Graphics.
12  *
13  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
14  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
15  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
16  *
17  * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR
18  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
19  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
20  * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
21  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
22  * OF THIS SOFTWARE.
23  */
24 
25 /*
26  * FieldSEditor -- simple editor for text fields
27  */
28 
29 #ifndef ivlook_sfield_h
30 #define ivlook_sfield_h
31 
32 #include <InterViews/input.h>
33 #include <InterViews/resource.h>
34 
35 class FieldSEditor;
36 class FieldSEditorImpl;
37 class String;
38 class Style;
39 class WidgetKit;
40 
41 class FieldSEditorAction : public Resource {
42 protected:
44  virtual ~FieldSEditorAction();
45 public:
46  virtual void accept(FieldSEditor*);
47  virtual void cancel(FieldSEditor*);
48 };
49 
50 #if defined(__STDC__) || defined(__ANSI_CPP__)
51 #define __FieldSEditorCallback(T) T##_FieldSEditorCallback
52 #define FieldSEditorCallback(T) __FieldSEditorCallback(T)
53 #define __FieldSEditorMemberFunction(T) T##_FieldSEditorMemberFunction
54 #define FieldSEditorMemberFunction(T) __FieldSEditorMemberFunction(T)
55 #else
56 #define __FieldSEditorCallback(T) T/**/_FieldSEditorCallback
57 #define FieldSEditorCallback(T) __FieldSEditorCallback(T)
58 #define __FieldSEditorMemberFunction(T) T/**/_FieldSEditorMemberFunction
59 #define FieldSEditorMemberFunction(T) __FieldSEditorMemberFunction(T)
60 #endif
61 
62 #define declareFieldSEditorCallback(T) \
63 typedef void (T::*FieldSEditorMemberFunction(T))(FieldSEditor*); \
64 class FieldSEditorCallback(T) : public FieldSEditorAction { \
65 public: \
66  FieldSEditorCallback(T)( \
67  T*, FieldSEditorMemberFunction(T) accept, \
68  FieldSEditorMemberFunction(T) cancel \
69  ); \
70  virtual ~FieldSEditorCallback(T)(); \
71 \
72  virtual void accept(FieldSEditor*); \
73  virtual void cancel(FieldSEditor*); \
74 private: \
75  T* obj_; \
76  FieldSEditorMemberFunction(T) accept_; \
77  FieldSEditorMemberFunction(T) cancel_; \
78 };
79 
80 #define implementFieldSEditorCallback(T) \
81 FieldSEditorCallback(T)::FieldSEditorCallback(T)( \
82  T* obj, FieldSEditorMemberFunction(T) accept, \
83  FieldSEditorMemberFunction(T) cancel \
84 ) { \
85  obj_ = obj; \
86  accept_ = accept; \
87  cancel_ = cancel; \
88 } \
89 \
90 FieldSEditorCallback(T)::~FieldSEditorCallback(T)() { } \
91 \
92 void FieldSEditorCallback(T)::accept(FieldSEditor* f) { (obj_->*accept_)(f); } \
93 void FieldSEditorCallback(T)::cancel(FieldSEditor* f) { (obj_->*cancel_)(f); }
94 
95 class FieldSEditor : public InputHandler {
96 public:
98  const String& sample, WidgetKit*, Style*, FieldSEditorAction* = NULL
99  );
100  virtual ~FieldSEditor();
101 
102  virtual void undraw();
103 
104  virtual void press(const Event&);
105  virtual void drag(const Event&);
106  virtual void release(const Event&);
107  virtual void keystroke(const Event&);
108  virtual InputHandler* focus_in();
109  virtual void focus_out();
110 
111  virtual void field(const char*);
112  virtual void field(const String&);
113 
114  virtual void select(int pos);
115  virtual void select(int left, int right);
116 
117  virtual void selection(int& start, int& index) const;
118 
119  virtual void edit();
120  virtual void edit(const char*, int left, int right);
121  virtual void edit(const String&, int left, int right);
122 
123  virtual const String* text() const;
124 private:
125  FieldSEditorImpl* impl_;
126 };
127 
128 #endif
#define text
Definition: plot.cpp:81
#define WidgetKit
Definition: _defines.h:331
#define InputHandler
Definition: _defines.h:151
void start()
Definition: hel2mos.cpp:205
virtual void drag(const Event &e)
Definition: ocinput.h:21
FieldSEditorImpl * impl_
Definition: field.h:125
virtual void press(const Event &e)
Definition: ocinput.h:20
virtual ~FieldSEditorAction()
#define left
Definition: rbtqueue.cpp:45
#define Event
Definition: _defines.h:107
virtual void release(const Event &e)
Definition: ocinput.h:22
#define right
Definition: rbtqueue.cpp:46
virtual void cancel(FieldSEditor *)
Definition: string.h:34
#define Style
Definition: _defines.h:281
virtual void accept(FieldSEditor *)
return NULL
Definition: cabcode.cpp:461
short index
Definition: cabvars.h:11
void edit(void)