field.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 1991 Stanford University
00003  * Copyright (c) 1991 Silicon Graphics, Inc.
00004  *
00005  * Permission to use, copy, modify, distribute, and sell this software and 
00006  * its documentation for any purpose is hereby granted without fee, provided
00007  * that (i) the above copyright notices and this permission notice appear in
00008  * all copies of the software and related documentation, and (ii) the names of
00009  * Stanford and Silicon Graphics may not be used in any advertising or
00010  * publicity relating to the software without the specific, prior written
00011  * permission of Stanford and Silicon Graphics.
00012  * 
00013  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
00014  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
00015  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
00016  *
00017  * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR
00018  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
00019  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
00020  * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
00021  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
00022  * OF THIS SOFTWARE.
00023  */
00024 
00025 /*
00026  * FieldSEditor -- simple editor for text fields
00027  */
00028 
00029 #ifndef ivlook_sfield_h
00030 #define ivlook_sfield_h
00031 
00032 #include <InterViews/input.h>
00033 #include <InterViews/resource.h>
00034 
00035 class FieldSEditor;
00036 class FieldSEditorImpl;
00037 class String;
00038 class Style;
00039 class WidgetKit;
00040 
00041 class FieldSEditorAction : public Resource {
00042 protected:
00043     FieldSEditorAction();
00044     virtual ~FieldSEditorAction();
00045 public:
00046     virtual void accept(FieldSEditor*);
00047     virtual void cancel(FieldSEditor*);
00048 };
00049 
00050 #if defined(__STDC__) || defined(__ANSI_CPP__)
00051 #define __FieldSEditorCallback(T) T##_FieldSEditorCallback
00052 #define FieldSEditorCallback(T) __FieldSEditorCallback(T)
00053 #define __FieldSEditorMemberFunction(T) T##_FieldSEditorMemberFunction
00054 #define FieldSEditorMemberFunction(T) __FieldSEditorMemberFunction(T)
00055 #else
00056 #define __FieldSEditorCallback(T) T_FieldSEditorCallback
00057 #define FieldSEditorCallback(T) __FieldSEditorCallback(T)
00058 #define __FieldSEditorMemberFunction(T) T_FieldSEditorMemberFunction
00059 #define FieldSEditorMemberFunction(T) __FieldSEditorMemberFunction(T)
00060 #endif
00061 
00062 #define declareFieldSEditorCallback(T) \
00063 typedef void (T::*FieldSEditorMemberFunction(T))(FieldSEditor*); \
00064 class FieldSEditorCallback(T) : public FieldSEditorAction { \
00065 public: \
00066     FieldSEditorCallback(T)( \
00067    T*, FieldSEditorMemberFunction(T) accept, \
00068    FieldSEditorMemberFunction(T) cancel \
00069     ); \
00070     virtual ~FieldSEditorCallback(T)(); \
00071 \
00072     virtual void accept(FieldSEditor*); \
00073     virtual void cancel(FieldSEditor*); \
00074 private: \
00075     T* obj_; \
00076     FieldSEditorMemberFunction(T) accept_; \
00077     FieldSEditorMemberFunction(T) cancel_; \
00078 };
00079 
00080 #define implementFieldSEditorCallback(T) \
00081 FieldSEditorCallback(T)::FieldSEditorCallback(T)( \
00082     T* obj, FieldSEditorMemberFunction(T) accept, \
00083     FieldSEditorMemberFunction(T) cancel \
00084 ) { \
00085     obj_ = obj; \
00086     accept_ = accept; \
00087     cancel_ = cancel; \
00088 } \
00089 \
00090 FieldSEditorCallback(T)::~FieldSEditorCallback(T)() { } \
00091 \
00092 void FieldSEditorCallback(T)::accept(FieldSEditor* f) { (obj_->*accept_)(f); } \
00093 void FieldSEditorCallback(T)::cancel(FieldSEditor* f) { (obj_->*cancel_)(f); }
00094 
00095 class FieldSEditor : public InputHandler {
00096 public:
00097     FieldSEditor(
00098    const String& sample, WidgetKit*, Style*, FieldSEditorAction* = nil
00099     );
00100     virtual ~FieldSEditor();
00101 
00102     virtual void undraw();
00103 
00104     virtual void press(const Event&);
00105     virtual void drag(const Event&);
00106     virtual void release(const Event&);
00107     virtual void keystroke(const Event&);
00108     virtual InputHandler* focus_in();
00109     virtual void focus_out();
00110 
00111     virtual void field(const char*);
00112     virtual void field(const String&);
00113 
00114     virtual void select(int pos);
00115     virtual void select(int left, int right);
00116 
00117     virtual void selection(int& start, int& index) const;
00118 
00119     virtual void edit();
00120     virtual void edit(const char*, int left, int right);
00121     virtual void edit(const String&, int left, int right);
00122 
00123     virtual const String* text() const;
00124 private:
00125     FieldSEditorImpl* impl_;
00126 };
00127 
00128 #endif
Generated on Mon Jun 13 08:10:23 2011 for NEURON by  doxygen 1.6.3