5 #include "bcsubwindow.h"
14 class BC_TextBox
: public BC_SubWindow
23 int font
= MEDIUMFONT
);
30 int font
= MEDIUMFONT
);
37 int font
= MEDIUMFONT
);
44 int font
= MEDIUMFONT
,
46 virtual ~BC_TextBox();
48 // Whenever the contents of the text change
49 virtual int handle_event() { return 0; };
50 // Whenever the position of the text changes
51 virtual int motion_event() { return 0; };
52 void set_selection(int char1
, int char2
, int ibeam
);
53 int update(char *text
);
54 int update(int64_t value
);
55 int update(float value
);
63 int focus_out_event();
64 int cursor_enter_event();
65 int cursor_leave_event();
66 int cursor_motion_event();
67 virtual int button_press_event();
68 int button_release_event();
69 int repeat_event(int64_t repeat_id
);
75 // Set top left of text view
76 void set_text_row(int row
);
78 int reposition_window(int x
, int y
, int w
= -1, int rows
= -1);
80 static int calculate_h(BC_WindowBase
*gui
, int font
, int has_border
, int rows
);
81 static int calculate_row_h(int rows
, BC_WindowBase
*parent_window
, int has_border
= 1, int font
= MEDIUMFONT
);
82 static int pixels_to_rows(BC_WindowBase
*window
, int font
, int pixels
);
83 void set_precision(int precision
);
84 // Whether to draw every time there is a keypress or rely on user to
85 // follow up every keypress with an update().
86 void set_keypress_draw(int value
);
87 int get_ibeam_letter();
88 void set_ibeam_letter(int number
, int redraw
= 1);
89 // Used for custom formatting text boxes
90 int get_last_keypress();
91 // Table of separators to skip. Used by time textboxes
92 // The separator format is "0000:0000". Things not alnum are considered
93 // separators. The alnums are replaced by user text.
94 void set_separators(char *separators
);
96 // 1 - selects text, -1 - deselects, 0 - do nothing
97 // in all cases it returns text_selected after the operation
98 int select_whole_text(int select
);
99 void cycle_textboxes(int amout
);
102 int reset_parameters(int rows
, int has_border
, int font
);
106 void copy_selection(int clipboard_num
);
107 void paste_selection(int clipboard_num
);
108 void delete_selection(int letter1
, int letter2
, int text_len
);
109 void insert_text(char *string
);
110 // Reformat text according to separators.
111 // ibeam_left causes the ibeam to move left.
112 void do_separators(int ibeam_left
);
113 void get_ibeam_position(int &x
, int &y
);
114 void find_ibeam(int dispatch_event
);
115 void select_word(int &letter1
, int &letter2
, int ibeam_letter
);
116 int get_cursor_letter(int cursor_x
, int cursor_y
);
117 int get_row_h(int rows
);
118 void default_keypress(int &dispatch_event
, int &result
);
121 // Top left of text relative to window
123 // Top left of cursor relative to text
124 int ibeam_x
, ibeam_y
;
127 int highlight_letter1
, highlight_letter2
;
128 int highlight_letter3
, highlight_letter4
;
129 int text_x1
, text_start
, text_end
, text_selected
, word_selected
;
130 int text_ascent
, text_descent
, text_height
;
131 int left_margin
, right_margin
, top_margin
, bottom_margin
;
136 int high_color
, back_color
;
137 int background_color
;
138 char text
[BCTEXTLEN
], text_row
[BCTEXTLEN
], temp_string
[2];
143 // Cause the repeater to skip a cursor refresh if a certain event happened
144 // within a certain time of the last repeat event
146 // Used for custom formatting text boxes
153 class BC_ScrollTextBoxText
;
154 class BC_ScrollTextBoxYScroll
;
157 class BC_ScrollTextBox
160 BC_ScrollTextBox(BC_WindowBase
*parent_window
,
166 virtual ~BC_ScrollTextBox();
167 void create_objects();
168 virtual int handle_event();
171 void update(char *text
);
172 void reposition_window(int x
, int y
, int w
, int rows
);
176 // Visible rows for resizing
179 friend class BC_ScrollTextBoxText
;
180 friend class BC_ScrollTextBoxYScroll
;
183 BC_ScrollTextBoxText
*text
;
184 BC_ScrollTextBoxYScroll
*yscroll
;
185 BC_WindowBase
*parent_window
;
190 class BC_ScrollTextBoxText
: public BC_TextBox
193 BC_ScrollTextBoxText(BC_ScrollTextBox
*gui
);
194 virtual ~BC_ScrollTextBoxText();
197 BC_ScrollTextBox
*gui
;
200 class BC_ScrollTextBoxYScroll
: public BC_ScrollBar
203 BC_ScrollTextBoxYScroll(BC_ScrollTextBox
*gui
);
204 virtual ~BC_ScrollTextBoxYScroll();
206 BC_ScrollTextBox
*gui
;
212 class BC_PopupTextBoxText
;
213 class BC_PopupTextBoxList
;
215 class BC_PopupTextBox
: public BC_RelocatableWidget
218 BC_PopupTextBox(BC_WindowBase
*parent_window
,
219 ArrayList
<BC_ListBoxItem
*> *list_items
,
225 virtual ~BC_PopupTextBox();
226 int create_objects();
227 virtual int handle_event();
234 void update(char *text
);
235 void update_list(ArrayList
<BC_ListBoxItem
*> *data
);
236 int reposition_widget(int x
, int y
, int w
= -1, int h
= -1);
237 void reposition_window(int x
, int y
);
239 friend class BC_PopupTextBoxText
;
240 friend class BC_PopupTextBoxList
;
243 int x
, y
, text_w
, list_h
;
245 ArrayList
<BC_ListBoxItem
*> *list_items
;
246 BC_PopupTextBoxText
*textbox
;
247 BC_PopupTextBoxList
*listbox
;
248 BC_WindowBase
*parent_window
;
251 class BC_PopupTextBoxText
: public BC_TextBox
254 BC_PopupTextBoxText(BC_PopupTextBox
*popup
, int x
, int y
);
255 virtual ~BC_PopupTextBoxText();
257 BC_PopupTextBox
*popup
;
260 class BC_PopupTextBoxList
: public BC_ListBox
263 BC_PopupTextBoxList(BC_PopupTextBox
*popup
, int x
, int y
);
265 BC_PopupTextBox
*popup
;
269 class BC_TumbleTextBoxText
;
270 class BC_TumbleTextBoxTumble
;
272 class BC_TumbleTextBox
: public BC_RelocatableWidget
275 BC_TumbleTextBox(BC_WindowBase
*parent_window
,
276 int64_t default_value
,
282 BC_TumbleTextBox(BC_WindowBase
*parent_window
,
289 BC_TumbleTextBox(BC_WindowBase
*parent_window
,
296 virtual ~BC_TumbleTextBox();
298 int create_objects();
300 virtual int handle_event();
302 int update(char *value
);
303 int update(int64_t value
);
304 int update(float value
);
309 int reposition_widget(int x
, int y
, int w
= -1, int h
= -1);
310 void reposition_window(int x
, int y
);
311 void set_boundaries(int64_t min
, int64_t max
);
312 void set_boundaries(float min
, float max
);
313 void set_precision(int precision
);
314 void set_increment(float value
);
316 friend class BC_TumbleTextBoxText
;
317 friend class BC_TumbleTextBoxTumble
;
321 int64_t default_value
, min
, max
;
322 float default_value_f
, min_f
, max_f
;
326 BC_TumbleTextBoxText
*textbox
;
328 BC_WindowBase
*parent_window
;
331 class BC_TumbleTextBoxText
: public BC_TextBox
334 BC_TumbleTextBoxText(BC_TumbleTextBox
*popup
,
335 int64_t default_value
,
340 BC_TumbleTextBoxText(BC_TumbleTextBox
*popup
,
346 BC_TumbleTextBoxText(BC_TumbleTextBox
*popup
, int x
, int y
);
347 virtual ~BC_TumbleTextBoxText();
349 int button_press_event();
350 BC_TumbleTextBox
*popup
;