00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef LABEL_H_
00016 #define LABEL_H_
00017
00018 #include <vector>
00019 #include <string>
00020 #include "input.h"
00021 #include "win_font.h"
00022
00023 using namespace std;
00024
00025 class label: public image
00026 {
00027 public :
00028
00029
00030
00031
00032 label ();
00033
00034
00035
00036
00037
00038 ~label ();
00039
00040
00041
00042
00043
00044 void set_font (win_font & font);
00045
00046
00047
00048
00049
00050 void set_text (const string & text);
00051
00052
00053
00054
00055
00056 void add_text (const string & text);
00057
00058
00059
00060
00061
00062
00063 void set_form (const u_int8 form);
00064
00065
00066
00067
00068
00069 void set_cursor_visible (const bool b);
00070
00071
00072
00073
00074
00075 void set_cursor_moveable (const bool b);
00076
00077
00078
00079
00080
00081 bool update ();
00082
00083
00084
00085
00086
00087 bool input_update ();
00088
00089
00090
00091
00092
00093 const string text_string () const;
00094
00095
00096
00097
00098
00099 const char * text_char () const;
00100
00101
00102
00103
00104
00105 void resize (u_int16 l, u_int16 h);
00106
00107
00108 #ifdef SWIG
00109
00110 #define label_NOTHING 0;
00111 #define label_AUTO_HEIGHT 1;
00112 #define label_AUTO_SIZE 2;
00113
00114 #define label_KEY_CURSOR_NEXT SDLK_RIGHT;
00115 #define label_KEY_CURSOR_PREVIOUS SDLK_LEFT;
00116
00117 #endif
00118
00119 #ifndef SWIG
00120
00121 static const u_int8 NOTHING = 0;
00122 static const u_int8 AUTO_HEIGHT = 1;
00123 static const u_int8 AUTO_SIZE = 2;
00124
00125
00126 const static SDLKey KEY_CURSOR_NEXT = SDLK_RIGHT;
00127 const static SDLKey KEY_CURSOR_PREVIOUS = SDLK_LEFT;
00128
00129
00130
00131 protected :
00132 u_int16 ucd (u_int16 & idx);
00133
00134 struct Sline_text
00135 {
00136 u_int16 idx_beg;
00137 s_int16 idx_end;
00138 u_int16 pos_x;
00139 };
00140
00141 struct Scursor
00142 {
00143 u_int16 pos_x;
00144 u_int16 pos_y;
00145 u_int16 idx;
00146 u_int16 line;
00147 };
00148
00149
00150
00151
00152 void init_vec_cursor ();
00153
00154
00155
00156
00157
00158
00159 void build(const bool erase_all);
00160
00161
00162
00163
00164
00165 void build_form_nothing ();
00166
00167
00168
00169
00170
00171 void build_form_auto_height ();
00172
00173
00174
00175 void build_form_auto_size();
00176
00177
00178
00179
00180 void clean_surface (const bool erase_all);
00181
00182
00183
00184 u_int8 find_word (u_int16 & index, u_int16 & wlength, u_int16 & wlengthpix, const u_int16 rlength);
00185
00186
00187
00188 void draw_string (const bool at_cursor);
00189
00190
00191
00192
00193
00194 void update_cursor ();
00195
00196
00197
00198 void cursor_next ();
00199
00200
00201
00202
00203 void cursor_previous ();
00204
00205
00206
00207 void cursor_draw ();
00208
00209 void cursor_undraw ();
00210
00211 bool last_letter (u_int16 idx);
00212
00213
00214 win_font * my_font_;
00215
00216
00217
00218 string my_text_;
00219
00220
00221 string new_text_;
00222
00223
00224 u_int8 my_form_;
00225
00226
00227
00228 bool visible_cursor_;
00229
00230
00231 bool moveable_cursor_;
00232
00233
00234 u_int16 cursor_cur_blink_;
00235
00236
00237 static u_int16 cursor_blink_cycle;
00238
00239
00240 Scursor my_cursor_;
00241
00242
00243 Scursor my_old_cursor_;
00244
00245
00246 vector<Sline_text> my_vect_;
00247
00248 u_int16 start_line_;
00249
00250 #endif
00251
00252
00253 };
00254 #endif
00255
00256
00257
00258