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 
42  protected:
45 
46  public:
47  virtual void accept(FieldSEditor*);
48  virtual void cancel(FieldSEditor*);
49 };
50 
51 #if defined(__STDC__) || defined(__ANSI_CPP__)
52 #define __FieldSEditorCallback(T) T##_FieldSEditorCallback
53 #define FieldSEditorCallback(T) __FieldSEditorCallback(T)
54 #define __FieldSEditorMemberFunction(T) T##_FieldSEditorMemberFunction
55 #define FieldSEditorMemberFunction(T) __FieldSEditorMemberFunction(T)
56 #else
57 #define __FieldSEditorCallback(T) T /**/ _FieldSEditorCallback
58 #define FieldSEditorCallback(T) __FieldSEditorCallback(T)
59 #define __FieldSEditorMemberFunction(T) T /**/ _FieldSEditorMemberFunction
60 #define FieldSEditorMemberFunction(T) __FieldSEditorMemberFunction(T)
61 #endif
62 
63 #define declareFieldSEditorCallback(T) \
64  typedef void (T::*FieldSEditorMemberFunction(T))(FieldSEditor*); \
65  class FieldSEditorCallback(T) \
66  : public FieldSEditorAction { \
67  public: \
68  FieldSEditorCallback( \
69  T)(T*, FieldSEditorMemberFunction(T) accept, FieldSEditorMemberFunction(T) cancel); \
70  virtual ~FieldSEditorCallback(T)(); \
71  \
72  virtual void accept(FieldSEditor*); \
73  virtual void cancel(FieldSEditor*); \
74  \
75  private: \
76  T* obj_; \
77  FieldSEditorMemberFunction(T) accept_; \
78  FieldSEditorMemberFunction(T) cancel_; \
79  };
80 
81 #define implementFieldSEditorCallback(T) \
82  FieldSEditorCallback(T)::FieldSEditorCallback( \
83  T)(T * obj, FieldSEditorMemberFunction(T) accept, FieldSEditorMemberFunction(T) cancel) { \
84  obj_ = obj; \
85  accept_ = accept; \
86  cancel_ = cancel; \
87  } \
88  \
89  FieldSEditorCallback(T)::~FieldSEditorCallback(T)() {} \
90  \
91  void FieldSEditorCallback(T)::accept(FieldSEditor* f) { \
92  (obj_->*accept_)(f); \
93  } \
94  void FieldSEditorCallback(T)::cancel(FieldSEditor* f) { \
95  (obj_->*cancel_)(f); \
96  }
97 
98 class FieldSEditor: public InputHandler {
99  public:
101  virtual ~FieldSEditor();
102 
103  virtual void undraw();
104 
105  virtual void press(const Event&);
106  virtual void drag(const Event&);
107  virtual void release(const Event&);
108  virtual void keystroke(const Event&);
109  virtual InputHandler* focus_in();
110  virtual void focus_out();
111 
112  virtual void field(const char*);
113  virtual void field(const String&);
114 
115  virtual void select(int pos);
116  virtual void select(int left, int right);
117 
118  virtual void selection(int& start, int& index) const;
119 
120  virtual void edit();
121  virtual void edit(const char*, int left, int right);
122  virtual void edit(const String&, int left, int right);
123 
124  virtual const String* text() const;
125 
126  private:
127  FieldSEditorImpl* impl_;
128 };
129 
130 #endif
#define InputHandler
Definition: _defines.h:151
#define Style
Definition: _defines.h:281
#define WidgetKit
Definition: _defines.h:331
#define Event
Definition: _defines.h:107
short index
Definition: cabvars.h:10
virtual void cancel(FieldSEditor *)
virtual ~FieldSEditorAction()
virtual void accept(FieldSEditor *)
virtual void field(const String &)
FieldSEditorImpl * impl_
Definition: field.h:127
virtual void focus_out()
virtual void release(const Event &)
virtual void edit()
virtual void edit(const char *, int left, int right)
virtual const String * text() const
virtual void selection(int &start, int &index) const
virtual void press(const Event &)
virtual ~FieldSEditor()
virtual void undraw()
virtual void select(int pos)
virtual void keystroke(const Event &)
virtual void drag(const Event &)
virtual void select(int left, int right)
virtual InputHandler * focus_in()
virtual void edit(const String &, int left, int right)
FieldSEditor(const String &sample, WidgetKit *, Style *, FieldSEditorAction *=NULL)
virtual void field(const char *)
Definition: string.h:34
void start()
Definition: hel2mos.cpp:204
#define left
Definition: rbtqueue.cpp:45
#define right
Definition: rbtqueue.cpp:46
#define NULL
Definition: sptree.h:16