00001 #ifndef BCTEXTBOX_H
00002 #define BCTEXTBOX_H
00003
00004 #include "bclistbox.h"
00005 #include "bcsubwindow.h"
00006 #include "bctumble.h"
00007 #include "fonts.h"
00008 #include "bctimer.inc"
00009
00010 #define BCCURSORW 2
00011
00012
00013
00014 class BC_TextBox : public BC_SubWindow
00015 {
00016 public:
00017 BC_TextBox(int x,
00018 int y,
00019 int w,
00020 int rows,
00021 char *text,
00022 int has_border = 1,
00023 int font = MEDIUMFONT);
00024 BC_TextBox(int x,
00025 int y,
00026 int w,
00027 int rows,
00028 int64_t text,
00029 int has_border = 1,
00030 int font = MEDIUMFONT);
00031 BC_TextBox(int x,
00032 int y,
00033 int w,
00034 int rows,
00035 int text,
00036 int has_border = 1,
00037 int font = MEDIUMFONT);
00038 BC_TextBox(int x,
00039 int y,
00040 int w,
00041 int rows,
00042 float text,
00043 int has_border = 1,
00044 int font = MEDIUMFONT,
00045 int precision = 4);
00046 virtual ~BC_TextBox();
00047
00048
00049 virtual int handle_event() { return 0; };
00050
00051 virtual int motion_event() { return 0; };
00052 void set_selection(int char1, int char2, int ibeam);
00053 int update(char *text);
00054 int update(int64_t value);
00055 int update(float value);
00056 void disable();
00057 void enable();
00058 int get_enabled();
00059
00060 int initialize();
00061
00062 int focus_in_event();
00063 int focus_out_event();
00064 int cursor_enter_event();
00065 int cursor_leave_event();
00066 int cursor_motion_event();
00067 virtual int button_press_event();
00068 int button_release_event();
00069 int repeat_event(int64_t repeat_id);
00070 int keypress_event();
00071 int activate();
00072 int deactivate();
00073 char* get_text();
00074 int get_text_rows();
00075
00076 void set_text_row(int row);
00077 int get_text_row();
00078 int reposition_window(int x, int y, int w = -1, int rows = -1);
00079 int uses_text();
00080 static int calculate_h(BC_WindowBase *gui, int font, int has_border, int rows);
00081 static int calculate_row_h(int rows, BC_WindowBase *parent_window, int has_border = 1, int font = MEDIUMFONT);
00082 static int pixels_to_rows(BC_WindowBase *window, int font, int pixels);
00083 void set_precision(int precision);
00084
00085
00086 void set_keypress_draw(int value);
00087 int get_ibeam_letter();
00088 void set_ibeam_letter(int number, int redraw = 1);
00089
00090 int get_last_keypress();
00091
00092
00093
00094 void set_separators(char *separators);
00095
00096
00097
00098 int select_whole_text(int select);
00099 void cycle_textboxes(int amout);
00100
00101 private:
00102 int reset_parameters(int rows, int has_border, int font);
00103 void draw();
00104 void draw_border();
00105 void draw_cursor();
00106 void copy_selection(int clipboard_num);
00107 void paste_selection(int clipboard_num);
00108 void delete_selection(int letter1, int letter2, int text_len);
00109 void insert_text(char *string);
00110
00111
00112 void do_separators(int ibeam_left);
00113 void get_ibeam_position(int &x, int &y);
00114 void find_ibeam(int dispatch_event);
00115 void select_word(int &letter1, int &letter2, int ibeam_letter);
00116 int get_cursor_letter(int cursor_x, int cursor_y);
00117 int get_row_h(int rows);
00118 void default_keypress(int &dispatch_event, int &result);
00119
00120
00121
00122 int text_x, text_y;
00123
00124 int ibeam_x, ibeam_y;
00125
00126 int ibeam_letter;
00127 int highlight_letter1, highlight_letter2;
00128 int highlight_letter3, highlight_letter4;
00129 int text_x1, text_start, text_end, text_selected, word_selected;
00130 int text_ascent, text_descent, text_height;
00131 int left_margin, right_margin, top_margin, bottom_margin;
00132 int has_border;
00133 int font;
00134 int rows;
00135 int highlighted;
00136 int high_color, back_color;
00137 int background_color;
00138 char text[BCTEXTLEN], text_row[BCTEXTLEN], temp_string[2];
00139 int active;
00140 int enabled;
00141 int precision;
00142 int keypress_draw;
00143
00144
00145 Timer *skip_cursor;
00146
00147 int last_keypress;
00148 char *separators;
00149 };
00150
00151
00152
00153 class BC_ScrollTextBoxText;
00154 class BC_ScrollTextBoxYScroll;
00155
00156
00157 class BC_ScrollTextBox
00158 {
00159 public:
00160 BC_ScrollTextBox(BC_WindowBase *parent_window,
00161 int x,
00162 int y,
00163 int w,
00164 int rows,
00165 char *default_text);
00166 virtual ~BC_ScrollTextBox();
00167 void create_objects();
00168 virtual int handle_event();
00169
00170 char* get_text();
00171 void update(char *text);
00172 void reposition_window(int x, int y, int w, int rows);
00173 int get_x();
00174 int get_y();
00175 int get_w();
00176
00177 int get_rows();
00178
00179 friend class BC_ScrollTextBoxText;
00180 friend class BC_ScrollTextBoxYScroll;
00181
00182 private:
00183 BC_ScrollTextBoxText *text;
00184 BC_ScrollTextBoxYScroll *yscroll;
00185 BC_WindowBase *parent_window;
00186 char *default_text;
00187 int x, y, w, rows;
00188 };
00189
00190 class BC_ScrollTextBoxText : public BC_TextBox
00191 {
00192 public:
00193 BC_ScrollTextBoxText(BC_ScrollTextBox *gui);
00194 virtual ~BC_ScrollTextBoxText();
00195 int handle_event();
00196 int motion_event();
00197 BC_ScrollTextBox *gui;
00198 };
00199
00200 class BC_ScrollTextBoxYScroll : public BC_ScrollBar
00201 {
00202 public:
00203 BC_ScrollTextBoxYScroll(BC_ScrollTextBox *gui);
00204 virtual ~BC_ScrollTextBoxYScroll();
00205 int handle_event();
00206 BC_ScrollTextBox *gui;
00207 };
00208
00209
00210
00211
00212 class BC_PopupTextBoxText;
00213 class BC_PopupTextBoxList;
00214
00215 class BC_PopupTextBox : public BC_RelocatableWidget
00216 {
00217 public:
00218 BC_PopupTextBox(BC_WindowBase *parent_window,
00219 ArrayList<BC_ListBoxItem*> *list_items,
00220 char *default_text,
00221 int x,
00222 int y,
00223 int text_w,
00224 int list_h);
00225 virtual ~BC_PopupTextBox();
00226 int create_objects();
00227 virtual int handle_event();
00228 char* get_text();
00229 int get_number();
00230 int get_x();
00231 int get_y();
00232 int get_w();
00233 int get_h();
00234 void update(char *text);
00235 void update_list(ArrayList<BC_ListBoxItem*> *data);
00236 int reposition_widget(int x, int y, int w = -1, int h = -1);
00237 void reposition_window(int x, int y);
00238
00239 friend class BC_PopupTextBoxText;
00240 friend class BC_PopupTextBoxList;
00241
00242 private:
00243 int x, y, text_w, list_h;
00244 char *default_text;
00245 ArrayList<BC_ListBoxItem*> *list_items;
00246 BC_PopupTextBoxText *textbox;
00247 BC_PopupTextBoxList *listbox;
00248 BC_WindowBase *parent_window;
00249 };
00250
00251 class BC_PopupTextBoxText : public BC_TextBox
00252 {
00253 public:
00254 BC_PopupTextBoxText(BC_PopupTextBox *popup, int x, int y);
00255 virtual ~BC_PopupTextBoxText();
00256 int handle_event();
00257 BC_PopupTextBox *popup;
00258 };
00259
00260 class BC_PopupTextBoxList : public BC_ListBox
00261 {
00262 public:
00263 BC_PopupTextBoxList(BC_PopupTextBox *popup, int x, int y);
00264 int handle_event();
00265 BC_PopupTextBox *popup;
00266 };
00267
00268
00269 class BC_TumbleTextBoxText;
00270 class BC_TumbleTextBoxTumble;
00271
00272 class BC_TumbleTextBox : public BC_RelocatableWidget
00273 {
00274 public:
00275 BC_TumbleTextBox(BC_WindowBase *parent_window,
00276 int64_t default_value,
00277 int64_t min,
00278 int64_t max,
00279 int x,
00280 int y,
00281 int text_w);
00282 BC_TumbleTextBox(BC_WindowBase *parent_window,
00283 int default_value,
00284 int min,
00285 int max,
00286 int x,
00287 int y,
00288 int text_w);
00289 BC_TumbleTextBox(BC_WindowBase *parent_window,
00290 float default_value,
00291 float min,
00292 float max,
00293 int x,
00294 int y,
00295 int text_w);
00296 virtual ~BC_TumbleTextBox();
00297
00298 int create_objects();
00299 void reset();
00300 virtual int handle_event();
00301 char* get_text();
00302 int update(char *value);
00303 int update(int64_t value);
00304 int update(float value);
00305 int get_x();
00306 int get_y();
00307 int get_w();
00308 int get_h();
00309 int reposition_widget(int x, int y, int w = -1, int h = -1);
00310 void reposition_window(int x, int y);
00311 void set_boundaries(int64_t min, int64_t max);
00312 void set_boundaries(float min, float max);
00313 void set_precision(int precision);
00314 void set_increment(float value);
00315 void set_log_floatincrement(int value);
00316
00317 friend class BC_TumbleTextBoxText;
00318 friend class BC_TumbleTextBoxTumble;
00319
00320 private:
00321 int x, y, text_w;
00322 int64_t default_value, min, max;
00323 float default_value_f, min_f, max_f;
00324 int use_float;
00325 int precision;
00326 float increment;
00327 int log_floatincrement;
00328 BC_TumbleTextBoxText *textbox;
00329 BC_Tumbler *tumbler;
00330 BC_WindowBase *parent_window;
00331 };
00332
00333 class BC_TumbleTextBoxText : public BC_TextBox
00334 {
00335 public:
00336 BC_TumbleTextBoxText(BC_TumbleTextBox *popup,
00337 int64_t default_value,
00338 int64_t min,
00339 int64_t max,
00340 int x,
00341 int y);
00342 BC_TumbleTextBoxText(BC_TumbleTextBox *popup,
00343 float default_value,
00344 float min,
00345 float max,
00346 int x,
00347 int y);
00348 BC_TumbleTextBoxText(BC_TumbleTextBox *popup, int x, int y);
00349 virtual ~BC_TumbleTextBoxText();
00350 int handle_event();
00351 int button_press_event();
00352 BC_TumbleTextBox *popup;
00353 };
00354
00355
00356 #endif