00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef PGENTRY_H
00020 #define PGENTRY_H
00021
00022 #include "pandabase.h"
00023
00024 #include "pgItem.h"
00025
00026 #include "textNode.h"
00027 #include "pointerTo.h"
00028 #include "pvector.h"
00029 #include "clockObject.h"
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 class EXPCL_PANDA PGEntry : public PGItem {
00046 PUBLISHED:
00047 PGEntry(const string &name);
00048 virtual ~PGEntry();
00049
00050 protected:
00051 PGEntry(const PGEntry ©);
00052
00053 public:
00054 virtual PandaNode *make_copy() const;
00055 virtual bool has_cull_callback() const;
00056 virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data);
00057
00058 virtual void press(const MouseWatcherParameter ¶m, bool background);
00059 virtual void keystroke(const MouseWatcherParameter ¶m, bool background);
00060
00061 virtual void accept(const MouseWatcherParameter ¶m);
00062 virtual void overflow(const MouseWatcherParameter ¶m);
00063 virtual void type(const MouseWatcherParameter ¶m);
00064 virtual void erase(const MouseWatcherParameter ¶m);
00065
00066 PUBLISHED:
00067 enum State {
00068 S_focus = 0,
00069 S_no_focus,
00070 S_inactive
00071 };
00072
00073 void setup(float width, int num_lines);
00074
00075 INLINE void set_text(const string &text);
00076 INLINE string get_text() const;
00077
00078 INLINE void set_cursor_position(int position);
00079 INLINE int get_cursor_position() const;
00080
00081 INLINE void set_max_chars(int max_chars);
00082 INLINE int get_max_chars() const;
00083 INLINE void set_max_width(float max_width);
00084 INLINE float get_max_width() const;
00085 INLINE void set_num_lines(int num_lines);
00086 INLINE int get_num_lines() const;
00087
00088 INLINE void set_blink_rate(float blink_rate);
00089 INLINE float get_blink_rate() const;
00090
00091 INLINE const NodePath &get_cursor_def();
00092 INLINE void clear_cursor_def();
00093
00094 INLINE void set_cursor_keys_active(bool flag);
00095 INLINE bool get_cursor_keys_active() const;
00096
00097 INLINE void set_obscure_mode(bool flag);
00098 INLINE bool get_obscure_mode() const;
00099
00100 void set_text_def(int state, TextNode *node);
00101 TextNode *get_text_def(int state) const;
00102
00103 virtual void set_active(bool active);
00104 virtual void set_focus(bool focus);
00105
00106 INLINE static string get_accept_prefix();
00107 INLINE static string get_overflow_prefix();
00108 INLINE static string get_type_prefix();
00109 INLINE static string get_erase_prefix();
00110
00111 INLINE string get_accept_event(const ButtonHandle &button) const;
00112 INLINE string get_overflow_event() const;
00113 INLINE string get_type_event() const;
00114 INLINE string get_erase_event() const;
00115
00116 public:
00117 INLINE void set_wtext(const wstring &wtext);
00118 INLINE const wstring &get_wtext() const;
00119
00120
00121 private:
00122 const wstring &get_display_wtext();
00123 void slot_text_def(int state);
00124 void update_text();
00125 void update_cursor();
00126 void show_hide_cursor(bool visible);
00127 void update_state();
00128
00129 wstring _wtext;
00130 wstring _obscured_wtext;
00131 int _cursor_position;
00132 bool _cursor_stale;
00133 bool _cursor_visible;
00134
00135 int _max_chars;
00136 float _max_width;
00137 int _num_lines;
00138
00139 typedef pvector< PT(TextNode) > TextDefs;
00140 TextDefs _text_defs;
00141
00142
00143 NodePath _text_render_root;
00144
00145
00146
00147 NodePath _current_text;
00148 TextNode *_last_text_def;
00149 bool _text_geom_stale;
00150
00151
00152
00153
00154 class WWLine {
00155 public:
00156 wstring _str;
00157 float _left;
00158 };
00159 typedef pvector<WWLine> WWLines;
00160 WWLines _ww_lines;
00161
00162
00163
00164
00165 NodePath _cursor_def;
00166
00167 double _blink_start;
00168 double _blink_rate;
00169
00170 bool _cursor_keys_active;
00171 bool _obscure_mode;
00172
00173 public:
00174 static TypeHandle get_class_type() {
00175 return _type_handle;
00176 }
00177 static void init_type() {
00178 PGItem::init_type();
00179 register_type(_type_handle, "PGEntry",
00180 PGItem::get_class_type());
00181 }
00182 virtual TypeHandle get_type() const {
00183 return get_class_type();
00184 }
00185 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00186
00187 private:
00188 static TypeHandle _type_handle;
00189 };
00190
00191 #include "pgEntry.I"
00192
00193 #endif