field.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
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