Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

bctextbox.h

Go to the documentation of this file.
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 // Whenever the contents of the text change
00049         virtual int handle_event() { return 0; };
00050 // Whenever the position of the text changes
00051         virtual int motion_event() { return 0; };
00052         int update(char *text);
00053         int update(int64_t value);
00054         int update(float value);
00055         void disable();
00056         void enable();
00057         int get_enabled();
00058 
00059         int initialize();
00060 
00061         int focus_in_event();
00062         int focus_out_event();
00063         int cursor_enter_event();
00064         int cursor_leave_event();
00065         int cursor_motion_event();
00066         virtual int button_press_event();
00067         int button_release_event();
00068         int repeat_event(int64_t repeat_id);
00069         int keypress_event();
00070         int activate();
00071         int deactivate();
00072         char* get_text();
00073         int get_text_rows();
00074 // Set top left of text view
00075         void set_text_row(int row);
00076         int get_text_row();
00077         int reposition_window(int x, int y, int w = -1, int rows = -1);
00078         int uses_text();
00079         static int calculate_h(BC_WindowBase *gui, int font, int has_border, int rows);
00080         static int calculate_row_h(int rows, BC_WindowBase *parent_window, int has_border = 1, int font = MEDIUMFONT);
00081         static int pixels_to_rows(BC_WindowBase *window, int font, int pixels);
00082         void set_precision(int precision);
00083 // Whether to draw every time there is a keypress or rely on user to
00084 // follow up every keypress with an update().
00085         void set_keypress_draw(int value);
00086         int get_ibeam_letter();
00087         void set_ibeam_letter(int number, int redraw = 1);
00088 // Used for custom formatting text boxes
00089         int get_last_keypress();
00090 // Table of separators to skip.  Used by time textboxes
00091 // The separator format is "0000:0000".  Things not alnum are considered
00092 // separators.  The alnums are replaced by user text.
00093         void set_separators(char *separators);
00094 
00095 // 1 - selects text, -1 - deselects, 0 - do nothing
00096 // in all cases it returns text_selected after the operation
00097         int select_whole_text(int select);
00098         void cycle_textboxes(int amout);
00099         
00100 private:
00101         int reset_parameters(int rows, int has_border, int font);
00102         void draw();
00103         void draw_border();
00104         void draw_cursor();
00105         void copy_selection(int clipboard_num);
00106         void paste_selection(int clipboard_num);
00107         void delete_selection(int letter1, int letter2, int text_len);
00108         void insert_text(char *string);
00109 // Reformat text according to separators.
00110 // ibeam_left causes the ibeam to move left.
00111         void do_separators(int ibeam_left);
00112         void get_ibeam_position(int &x, int &y);
00113         void find_ibeam(int dispatch_event);
00114         void select_word(int &letter1, int &letter2, int ibeam_letter);
00115         int get_cursor_letter(int cursor_x, int cursor_y);
00116         int get_row_h(int rows);
00117         void default_keypress(int &dispatch_event, int &result);
00118 
00119 
00120 // Top left of text relative to window
00121         int text_x, text_y;
00122 // Top left of cursor relative to text
00123         int ibeam_x, ibeam_y;
00124 
00125         int ibeam_letter;
00126         int highlight_letter1, highlight_letter2;
00127         int highlight_letter3, highlight_letter4;
00128         int text_x1, text_start, text_end, text_selected, word_selected;
00129         int text_ascent, text_descent, text_height;
00130         int left_margin, right_margin, top_margin, bottom_margin;
00131         int has_border;
00132         int font;
00133         int rows;
00134         int highlighted;
00135         int high_color, back_color;
00136         int background_color;
00137         char text[BCTEXTLEN], text_row[BCTEXTLEN], temp_string[2];
00138         int active;
00139         int enabled;
00140         int precision;
00141         int keypress_draw;
00142 // Cause the repeater to skip a cursor refresh if a certain event happened
00143 // within a certain time of the last repeat event
00144         Timer *skip_cursor;
00145 // Used for custom formatting text boxes
00146         int last_keypress;
00147         char *separators;
00148 };
00149 
00150 
00151 
00152 class BC_ScrollTextBoxText;
00153 class BC_ScrollTextBoxYScroll;
00154 
00155 
00156 class BC_ScrollTextBox
00157 {
00158 public:
00159         BC_ScrollTextBox(BC_WindowBase *parent_window, 
00160                 int x, 
00161                 int y, 
00162                 int w,
00163                 int rows,
00164                 char *default_text);
00165         virtual ~BC_ScrollTextBox();
00166         void create_objects();
00167         virtual int handle_event();
00168         
00169         char* get_text();
00170         void update(char *text);
00171         void reposition_window(int x, int y, int w, int rows);
00172         int get_x();
00173         int get_y();
00174         int get_w();
00175 // Visible rows for resizing
00176         int get_rows();
00177 
00178         friend class BC_ScrollTextBoxText;
00179         friend class BC_ScrollTextBoxYScroll;
00180 
00181 private:
00182         BC_ScrollTextBoxText *text;
00183         BC_ScrollTextBoxYScroll *yscroll;
00184         BC_WindowBase *parent_window;
00185         char *default_text;
00186         int x, y, w, rows;
00187 };
00188 
00189 class BC_ScrollTextBoxText : public BC_TextBox
00190 {
00191 public:
00192         BC_ScrollTextBoxText(BC_ScrollTextBox *gui);
00193         virtual ~BC_ScrollTextBoxText();
00194         int handle_event();
00195         int motion_event();
00196         BC_ScrollTextBox *gui;
00197 };
00198 
00199 class BC_ScrollTextBoxYScroll : public BC_ScrollBar
00200 {
00201 public:
00202         BC_ScrollTextBoxYScroll(BC_ScrollTextBox *gui);
00203         virtual ~BC_ScrollTextBoxYScroll();
00204         int handle_event();
00205         BC_ScrollTextBox *gui;
00206 };
00207 
00208 
00209 
00210 
00211 class BC_PopupTextBoxText;
00212 class BC_PopupTextBoxList;
00213 
00214 class BC_PopupTextBox
00215 {
00216 public:
00217         BC_PopupTextBox(BC_WindowBase *parent_window, 
00218                 ArrayList<BC_ListBoxItem*> *list_items,
00219                 char *default_text,
00220                 int x, 
00221                 int y, 
00222                 int text_w,
00223                 int list_h);
00224         virtual ~BC_PopupTextBox();
00225         int create_objects();
00226         virtual int handle_event();
00227         char* get_text();
00228         int get_number();
00229         int get_x();
00230         int get_y();
00231         int get_w();
00232         int get_h();
00233         void update(char *text);
00234         void update_list(ArrayList<BC_ListBoxItem*> *data);
00235         void reposition_window(int x, int y);
00236 
00237         friend class BC_PopupTextBoxText;
00238         friend class BC_PopupTextBoxList;
00239 
00240 private:
00241         int x, y, text_w, list_h;
00242         char *default_text;
00243         ArrayList<BC_ListBoxItem*> *list_items;
00244         BC_PopupTextBoxText *textbox;
00245         BC_PopupTextBoxList *listbox;
00246         BC_WindowBase *parent_window;
00247 };
00248 
00249 class BC_PopupTextBoxText : public BC_TextBox
00250 {
00251 public:
00252         BC_PopupTextBoxText(BC_PopupTextBox *popup, int x, int y);
00253         virtual ~BC_PopupTextBoxText();
00254         int handle_event();
00255         BC_PopupTextBox *popup;
00256 };
00257 
00258 class BC_PopupTextBoxList : public BC_ListBox
00259 {
00260 public:
00261         BC_PopupTextBoxList(BC_PopupTextBox *popup, int x, int y);
00262         int handle_event();
00263         BC_PopupTextBox *popup;
00264 };
00265 
00266 
00267 class BC_TumbleTextBoxText;
00268 class BC_TumbleTextBoxTumble;
00269 
00270 class BC_TumbleTextBox : public BC_RelocatableWidget
00271 {
00272 public:
00273         BC_TumbleTextBox(BC_WindowBase *parent_window, 
00274                 int64_t default_value,
00275                 int64_t min,
00276                 int64_t max,
00277                 int x, 
00278                 int y, 
00279                 int text_w);
00280         BC_TumbleTextBox(BC_WindowBase *parent_window, 
00281                 int default_value,
00282                 int min,
00283                 int max,
00284                 int x, 
00285                 int y, 
00286                 int text_w);
00287         BC_TumbleTextBox(BC_WindowBase *parent_window, 
00288                 float default_value,
00289                 float min,
00290                 float max,
00291                 int x, 
00292                 int y, 
00293                 int text_w);
00294         virtual ~BC_TumbleTextBox();
00295 
00296         int create_objects();
00297         void reset();
00298         virtual int handle_event();
00299         char* get_text();
00300         int update(char *value);
00301         int update(int64_t value);
00302         int update(float value);
00303         int get_x();
00304         int get_y();
00305         int get_w();
00306         int get_h();
00307         int  reposition_widget(int x, int y, int w = -1, int h = -1);
00308         void reposition_window(int x, int y);
00309         void set_boundaries(int64_t min, int64_t max);
00310         void set_boundaries(float min, float max);
00311         void set_precision(int precision);
00312         void set_increment(float value);
00313 
00314         friend class BC_TumbleTextBoxText;
00315         friend class BC_TumbleTextBoxTumble;
00316 
00317 private:
00318         int x, y, text_w;
00319         int64_t default_value, min, max;
00320         float default_value_f, min_f, max_f;
00321         int use_float;
00322         int precision;
00323         float increment;
00324         BC_TumbleTextBoxText *textbox;
00325         BC_Tumbler *tumbler;
00326         BC_WindowBase *parent_window;
00327 };
00328 
00329 class BC_TumbleTextBoxText : public BC_TextBox
00330 {
00331 public:
00332         BC_TumbleTextBoxText(BC_TumbleTextBox *popup, 
00333                 int64_t default_value,
00334                 int64_t min,
00335                 int64_t max,
00336                 int x, 
00337                 int y);
00338         BC_TumbleTextBoxText(BC_TumbleTextBox *popup, 
00339                 float default_value,
00340                 float min,
00341                 float max,
00342                 int x, 
00343                 int y);
00344         BC_TumbleTextBoxText(BC_TumbleTextBox *popup, int x, int y);
00345         virtual ~BC_TumbleTextBoxText();
00346         int handle_event();
00347         int button_press_event();
00348         BC_TumbleTextBox *popup;
00349 };
00350 
00351 
00352 #endif

Generated on Sun Jan 8 13:26:33 2006 for Guicast-svn by  doxygen 1.4.4