1 #include "bcclipboard.h"
2 #include "bclistboxitem.h"
3 #include "bcresources.h"
13 BC_TextBox::BC_TextBox(int x, int y, int w, int rows, char *text, int has_border, int font)
14 : BC_SubWindow(x, y, w, 0, -1)
16 reset_parameters(rows, has_border, font);
17 strcpy(this->text, text);
20 BC_TextBox::BC_TextBox(int x, int y, int w, int rows, int64_t text, int has_border, int font)
21 : BC_SubWindow(x, y, w, 0, -1)
23 reset_parameters(rows, has_border, font);
24 sprintf(this->text, "%lld", text);
27 BC_TextBox::BC_TextBox(int x, int y, int w, int rows, float text, int has_border, int font)
28 : BC_SubWindow(x, y, w, 0, -1)
30 reset_parameters(rows, has_border, font);
31 sprintf(this->text, "%0.4f", text);
34 BC_TextBox::BC_TextBox(int x, int y, int w, int rows, int text, int has_border, int font)
35 : BC_SubWindow(x, y, w, 0, -1)
37 reset_parameters(rows, has_border, font);
38 sprintf(this->text, "%d", text);
41 BC_TextBox::~BC_TextBox()
45 int BC_TextBox::reset_parameters(int rows, int has_border, int font)
48 this->has_border = has_border;
52 highlight_letter1 = highlight_letter2 = 0;
53 highlight_letter3 = highlight_letter4 = 0;
56 text_selected = word_selected = 0;
64 int BC_TextBox::initialize()
67 text_ascent = get_text_ascent(font) + 1;
68 text_descent = get_text_descent(font) + 1;
69 text_height = text_ascent + text_descent;
70 ibeam_letter = strlen(text);
73 left_margin = right_margin = 4;
74 top_margin = bottom_margin = 2;
78 left_margin = right_margin = 2;
79 top_margin = bottom_margin = 0;
86 // Create the subwindow
87 BC_SubWindow::initialize();
92 high_color = LTYELLOW;
97 back_color = bg_color;
101 set_cursor(IBEAM_CURSOR);
105 void BC_TextBox::set_precision(int precision)
107 this->precision = precision;
110 int BC_TextBox::update(char *text)
112 //printf("BC_TextBox::update 1 %d %s %s\n", strcmp(text, this->text), text, this->text);
113 int text_len = strlen(text);
114 // Don't update if contents are the same
115 if(!strcmp(text, this->text)) return 0;
117 strcpy(this->text, text);
118 if(highlight_letter1 > text_len) highlight_letter1 = text_len;
119 if(highlight_letter2 > text_len) highlight_letter2 = text_len;
120 ibeam_letter = text_len;
125 int BC_TextBox::update(int64_t value)
127 char string[BCTEXTLEN];
128 sprintf(string, "%lld", value);
135 int BC_TextBox::update(float value)
137 char string[BCTEXTLEN];
138 sprintf(string, "%f", value);
139 char *ptr = strchr(string, '.');
141 //printf("BC_TextBox::update 1 %d\n", precision);
142 if(ptr) ptr[precision + 1] = 0;
148 void BC_TextBox::disable()
153 if(active) top_level->deactivate();
158 void BC_TextBox::enable()
167 int BC_TextBox::pixels_to_rows(BC_WindowBase *window, int font, int pixels)
169 return (pixels - 4) /
170 (window->get_text_ascent(font) + 1 +
171 window->get_text_descent(font) + 1);
174 int BC_TextBox::calculate_row_h(int rows,
175 BC_WindowBase *parent_window,
180 (parent_window->get_text_ascent(font) + 1 +
181 parent_window->get_text_descent(font) + 1) +
182 (has_border ? 4 : 0);
185 char* BC_TextBox::get_text()
190 int BC_TextBox::get_text_rows()
192 int text_len = strlen(text);
194 for(int i = 0; i < text_len; i++)
196 if(text[i] == 0xa) result++;
202 int BC_TextBox::get_row_h(int rows)
204 return rows * text_height + top_margin + bottom_margin;
207 int BC_TextBox::reposition_window(int x, int y, int w, int rows)
212 new_h = get_row_h(rows);
215 BC_WindowBase::reposition_window(x, y, w, new_h);
220 void BC_TextBox::draw_border()
223 set_color(background_color);
224 draw_box(0, 0, left_margin, get_h());
225 draw_box(get_w() - right_margin, 0, right_margin, get_h());
230 draw_3d_border(0, 0, w, h,
231 top_level->get_resources()->button_shadow,
234 top_level->get_resources()->button_light);
236 draw_3d_border(0, 0, w, h,
237 top_level->get_resources()->button_shadow,
239 top_level->get_resources()->button_up,
240 top_level->get_resources()->button_light);
244 void BC_TextBox::draw_cursor()
246 set_color(background_color);
248 draw_box(ibeam_x, ibeam_y, BCCURSORW, text_height);
253 void BC_TextBox::draw()
255 int i, j, k, text_len;
256 int row_begin, row_end;
257 int highlight_x1, highlight_x2;
263 background_color = WHITE;
269 background_color = high_color;
273 background_color = back_color;
277 set_color(background_color);
278 draw_box(0, 0, w, h);
280 // Draw text with selection
282 text_len = strlen(text);
283 //printf("BC_TextBox::draw 0 %s %d %d %d %d\n", text, text_y, text_len, get_w(), text_height);
285 for(i = 0, k = text_y; i < text_len && k < get_h(); k += text_height)
288 if(text[i] == '\n') i++;
290 for(j = 0; text[i] != '\n' && i < text_len; j++, i++)
292 text_row[j] = text[i];
297 //printf("BC_TextBox::draw 1 %d %d %c\n", row_begin, row_end, text_row[j - 1]);
299 if(k > -text_height + top_margin && k < get_h() - bottom_margin)
301 // Draw highlighted region of row
302 if(highlight_letter2 > highlight_letter1 &&
303 highlight_letter2 > row_begin && highlight_letter1 < row_end)
305 if(active && enabled)
306 set_color(top_level->get_resources()->text_highlight);
310 if(highlight_letter1 >= row_begin && highlight_letter1 < row_end)
311 highlight_x1 = get_text_width(font, text_row, highlight_letter1 - row_begin);
315 if(highlight_letter2 > row_begin && highlight_letter2 <= row_end)
316 highlight_x2 = get_text_width(font, text_row, highlight_letter2 - row_begin);
318 highlight_x2 = get_w();
320 draw_box(highlight_x1 + text_x,
322 highlight_x2 - highlight_x1,
326 // Draw text over highlight
332 draw_text(text_x, k + text_ascent, text_row);
333 // Get ibeam location
334 if(ibeam_letter >= row_begin && ibeam_letter <= row_end)
336 //printf("BC_TextBox::draw 2 %d %d %d\n", row_begin, row_end, ibeam_letter);
339 ibeam_x = text_x + get_text_width(font, text_row, ibeam_letter - row_begin);
344 //printf("BC_TextBox::draw 3 %d\n", ibeam_y);
351 //printf("BC_TextBox::draw 4 %d\n", ibeam_y);
363 int BC_TextBox::cursor_enter_event()
365 if(top_level->event_win == win)
377 int BC_TextBox::cursor_leave_event()
388 int BC_TextBox::button_press_event()
390 if(get_buttonpress() > 2) return 0;
392 int cursor_letter = 0;
393 int text_len = strlen(text);
395 if(!enabled) return 0;
397 if(top_level->event_win == win)
401 top_level->deactivate();
405 cursor_letter = get_cursor_letter(top_level->cursor_x, top_level->cursor_y);
406 if(get_double_click())
409 select_word(highlight_letter1, highlight_letter2, cursor_letter);
410 highlight_letter3 = highlight_letter1;
411 highlight_letter4 = highlight_letter2;
412 ibeam_letter = highlight_letter2;
413 copy_selection(PRIMARY_SELECTION);
416 if(get_buttonpress() == 2)
418 highlight_letter3 = highlight_letter4 =
419 ibeam_letter = highlight_letter1 =
420 highlight_letter2 = cursor_letter;
421 paste_selection(PRIMARY_SELECTION);
426 highlight_letter3 = highlight_letter4 =
427 ibeam_letter = highlight_letter1 =
428 highlight_letter2 = cursor_letter;
431 if(ibeam_letter < 0) ibeam_letter = 0;
432 if(ibeam_letter > text_len) ibeam_letter = text_len;
439 top_level->deactivate();
445 int BC_TextBox::button_release_event()
449 if(text_selected || word_selected)
458 int BC_TextBox::cursor_motion_event()
460 int cursor_letter, text_len = strlen(text), letter1, letter2;
463 if(text_selected || word_selected)
465 cursor_letter = get_cursor_letter(top_level->cursor_x, top_level->cursor_y);
468 select_word(letter1, letter2, cursor_letter);
473 letter1 = letter2 = cursor_letter;
476 if(letter1 <= highlight_letter3)
478 highlight_letter1 = letter1;
479 highlight_letter2 = highlight_letter4;
480 ibeam_letter = letter1;
483 if(letter2 >= highlight_letter4)
485 highlight_letter2 = letter2;
486 highlight_letter1 = highlight_letter3;
487 ibeam_letter = letter2;
490 copy_selection(PRIMARY_SELECTION);
499 int BC_TextBox::activate()
501 top_level->active_subwindow = this;
504 top_level->set_repeat(top_level->get_resources()->blink_rate);
508 int BC_TextBox::deactivate()
511 top_level->unset_repeat(top_level->get_resources()->blink_rate);
516 int BC_TextBox::repeat_event(int64_t duration)
518 if(duration == top_level->get_resources()->blink_rate &&
528 void BC_TextBox::default_keypress(int &dispatch_event, int &result)
530 if((top_level->get_keypress() == RETURN) ||
531 // (top_level->get_keypress() > 30 && top_level->get_keypress() < 127))
532 (top_level->get_keypress() > 30 && top_level->get_keypress() <= 255))
534 // Substitute UNIX linefeed
535 if(top_level->get_keypress() == RETURN)
536 temp_string[0] = 0xa;
538 temp_string[0] = top_level->get_keypress();
540 insert_text(temp_string);
548 int BC_TextBox::keypress_event()
550 // Result == 2 contents changed
551 // Result == 1 trapped keypress
552 // Result == 0 nothing
555 int dispatch_event = 0;
557 if(!active || !enabled) return 0;
559 text_len = strlen(text);
560 switch(top_level->get_keypress())
563 top_level->deactivate();
570 top_level->deactivate();
576 default_keypress(dispatch_event, result);
579 // Handle like a default keypress
582 top_level->cycle_textboxes(1);
587 top_level->cycle_textboxes(-1);
595 if(top_level->shift_down())
597 // Initialize highlighting
598 if(highlight_letter1 == highlight_letter2)
600 highlight_letter1 = ibeam_letter - 1;
601 highlight_letter2 = ibeam_letter;
604 // Extend left highlight
605 if(highlight_letter1 == ibeam_letter)
610 // Shrink right highlight
611 if(highlight_letter2 == ibeam_letter)
617 highlight_letter1 = highlight_letter2;
628 if(ibeam_letter < text_len)
631 if(top_level->shift_down())
633 // Initialize highlighting
634 if(highlight_letter1 == highlight_letter2)
636 highlight_letter1 = ibeam_letter;
637 highlight_letter2 = ibeam_letter + 1;
640 // Shrink left highlight
641 if(highlight_letter1 == ibeam_letter)
646 // Expand right highlight
647 if(highlight_letter2 == ibeam_letter)
653 highlight_letter1 = highlight_letter2;
667 int new_letter = get_cursor_letter(ibeam_x, ibeam_y - text_height);
668 //printf("BC_TextBox::keypress_event %d\n", new_letter);
670 if(top_level->shift_down())
672 // Initialize highlighting
673 if(highlight_letter1 == highlight_letter2)
675 highlight_letter1 = new_letter;
676 highlight_letter2 = ibeam_letter;
679 // Expand left highlight
680 if(highlight_letter1 == ibeam_letter)
682 highlight_letter1 = new_letter;
685 // Shrink right highlight
686 if(highlight_letter2 == ibeam_letter)
688 highlight_letter2 = new_letter;
692 highlight_letter1 = highlight_letter2 = new_letter;
694 if(highlight_letter1 > highlight_letter2)
696 int temp = highlight_letter1;
697 highlight_letter1 = highlight_letter2;
698 highlight_letter2 = temp;
700 ibeam_letter = new_letter;
709 // if(ibeam_letter > 0)
712 int new_letter = get_cursor_letter(ibeam_x, ibeam_y + text_height);
713 //printf("BC_TextBox::keypress_event %d\n", new_letter);
715 if(top_level->shift_down())
717 // Initialize highlighting
718 if(highlight_letter1 == highlight_letter2)
720 highlight_letter1 = new_letter;
721 highlight_letter2 = ibeam_letter;
724 // Shrink left highlight
725 if(highlight_letter1 == ibeam_letter)
727 highlight_letter1 = new_letter;
730 // Expand right highlight
731 if(highlight_letter2 == ibeam_letter)
733 highlight_letter2 = new_letter;
737 highlight_letter1 = highlight_letter2 = new_letter;
739 if(highlight_letter1 > highlight_letter2)
741 int temp = highlight_letter1;
742 highlight_letter1 = highlight_letter2;
743 highlight_letter2 = temp;
745 ibeam_letter = new_letter;
754 if(top_level->shift_down())
756 if(highlight_letter1 == highlight_letter2)
758 highlight_letter2 = text_len;
759 highlight_letter1 = ibeam_letter;
762 if(highlight_letter1 == ibeam_letter)
764 highlight_letter1 = highlight_letter2;
765 highlight_letter2 = text_len;
768 if(highlight_letter2 == ibeam_letter)
770 highlight_letter2 = text_len;
774 highlight_letter1 = highlight_letter2;
776 ibeam_letter = text_len;
783 if(top_level->shift_down())
785 if(highlight_letter1 == highlight_letter2)
787 highlight_letter2 = ibeam_letter;
788 highlight_letter1 = 0;
791 if(highlight_letter1 == ibeam_letter)
793 highlight_letter1 = 0;
796 if(highlight_letter2 == ibeam_letter)
798 highlight_letter2 = highlight_letter1;
799 highlight_letter1 = 0;
803 highlight_letter1 = highlight_letter2;
812 if(highlight_letter1 == highlight_letter2)
816 delete_selection(ibeam_letter - 1, ibeam_letter, text_len);
822 delete_selection(highlight_letter1, highlight_letter2, text_len);
823 highlight_letter2 = ibeam_letter = highlight_letter1;
833 if(highlight_letter1 == highlight_letter2)
835 if(ibeam_letter < text_len)
837 delete_selection(ibeam_letter, ibeam_letter + 1, text_len);
842 delete_selection(highlight_letter1, highlight_letter2, text_len);
843 highlight_letter2 = ibeam_letter = highlight_letter1;
857 if(get_keypress() == 'c' || get_keypress() == 'C')
859 if(highlight_letter1 != highlight_letter2)
861 copy_selection(SECONDARY_SELECTION);
866 if(get_keypress() == 'v' || get_keypress() == 'V')
868 paste_selection(SECONDARY_SELECTION);
875 if(get_keypress() == 'x' || get_keypress() == 'X')
877 if(highlight_letter1 != highlight_letter2)
879 copy_selection(SECONDARY_SELECTION);
880 delete_selection(highlight_letter1, highlight_letter2, text_len);
881 highlight_letter2 = ibeam_letter = highlight_letter1;
893 default_keypress(dispatch_event, result);
897 if(dispatch_event) handle_event();
903 int BC_TextBox::uses_text()
908 void BC_TextBox::delete_selection(int letter1, int letter2, int text_len)
912 for(i = letter1, j = letter2; j < text_len; i++, j++)
919 void BC_TextBox::insert_text(char *string)
921 int i, j, text_len, string_len;
923 string_len = strlen(string);
924 text_len = strlen(text);
925 if(highlight_letter1 < highlight_letter2)
927 delete_selection(highlight_letter1, highlight_letter2, text_len);
928 highlight_letter2 = ibeam_letter = highlight_letter1;
931 text_len = strlen(text);
933 for(i = text_len, j = text_len + string_len; i >= ibeam_letter; i--, j--)
936 for(i = ibeam_letter, j = 0; j < string_len; j++, i++)
939 ibeam_letter += string_len;
942 void BC_TextBox::get_ibeam_position(int &x, int &y)
944 int i, j, k, row_begin, row_end, text_len;
946 text_len = strlen(text);
947 for(i = 0, k = 0; i < text_len; k += text_height)
950 for(j = 0; text[i] != '\n' && i < text_len; j++, i++)
952 text_row[j] = text[i];
958 if(ibeam_letter >= row_begin && ibeam_letter <= row_end)
960 x = get_text_width(font, text_row, ibeam_letter - row_begin);
964 if(text[i] == '\n') i++;
972 void BC_TextBox::set_text_row(int row)
974 text_y = -(row * text_height) + top_margin;
978 int BC_TextBox::get_text_row()
980 return -(text_y - top_margin) / text_height;
983 void BC_TextBox::find_ibeam(int dispatch_event)
986 int old_x = text_x, old_y = text_y;
988 get_ibeam_position(x, y);
989 if(left_margin + text_x + x >= get_w() - right_margin - BCCURSORW)
991 text_x = -(x - (get_w() - get_w() / 4)) + left_margin;
992 if(text_x > left_margin) text_x = left_margin;
995 if(left_margin + text_x + x < left_margin)
997 text_x = -(x - (get_w() / 4)) + left_margin;
998 if(text_x > left_margin) text_x = left_margin;
1001 if((y >= get_h() - text_height - bottom_margin) ||
1004 text_y = -(y - (get_h() / 2)) + top_margin;
1005 if(text_y > top_margin) text_y = top_margin;
1008 if(dispatch_event && (old_x != text_x || old_y != text_y)) motion_event();
1011 int BC_TextBox::get_cursor_letter(int cursor_x, int cursor_y)
1013 int i, j, k, l, row_begin, row_end, text_len, result = 0, done = 0;
1014 text_len = strlen(text);
1022 for(i = 0, k = text_y; i < text_len && !done; k += text_height)
1025 for(j = 0; text[i] != '\n' && i < text_len; j++, i++)
1027 text_row[j] = text[i];
1032 if(cursor_y >= k && cursor_y < k + text_height)
1034 for(j = 0; j <= row_end - row_begin && !done; j++)
1036 l = get_text_width(font, text_row, j) + text_x;
1039 result = row_begin + j - 1;
1049 if(text[i] == '\n') i++;
1051 if(i >= text_len && !done)
1056 if(result < 0) result = 0;
1057 if(result > text_len) result = text_len;
1061 void BC_TextBox::select_word(int &letter1, int &letter2, int ibeam_letter)
1063 int text_len = strlen(text);
1064 letter1 = letter2 = ibeam_letter;
1067 if(isalnum(text[letter1])) letter1--;
1068 }while(letter1 > 0 && isalnum(text[letter1]));
1069 if(!isalnum(text[letter1])) letter1++;
1073 if(isalnum(text[letter2])) letter2++;
1074 }while(letter2 < text_len && isalnum(text[letter2]));
1075 if(letter2 < text_len && text[letter2] == ' ') letter2++;
1077 if(letter1 < 0) letter1 = 0;
1078 if(letter2 < 0) letter2 = 0;
1079 if(letter1 > text_len) letter1 = text_len;
1080 if(letter2 > text_len) letter2 = text_len;
1083 void BC_TextBox::copy_selection(int clipboard_num)
1085 int text_len = strlen(text);
1087 if(highlight_letter1 >= text_len ||
1088 highlight_letter2 > text_len ||
1089 highlight_letter1 < 0 ||
1090 highlight_letter2 < 0 ||
1091 highlight_letter2 - highlight_letter1 <= 0) return;
1093 get_clipboard()->to_clipboard(&text[highlight_letter1],
1094 highlight_letter2 - highlight_letter1,
1098 void BC_TextBox::paste_selection(int clipboard_num)
1100 int len = get_clipboard()->clipboard_len(clipboard_num);
1103 char *string = new char[len + 1];
1104 get_clipboard()->from_clipboard(string, len, clipboard_num);
1105 insert_text(string);
1115 BC_ScrollTextBox::BC_ScrollTextBox(BC_WindowBase *parent_window,
1122 this->parent_window = parent_window;
1127 this->default_text = default_text;
1130 BC_ScrollTextBox::~BC_ScrollTextBox()
1140 void BC_ScrollTextBox::create_objects()
1142 // Must be created first
1143 parent_window->add_subwindow(text = new BC_ScrollTextBoxText(this));
1144 parent_window->add_subwindow(yscroll = new BC_ScrollTextBoxYScroll(this));
1147 int BC_ScrollTextBox::handle_event()
1152 int BC_ScrollTextBox::get_x()
1157 int BC_ScrollTextBox::get_y()
1162 int BC_ScrollTextBox::get_w()
1167 int BC_ScrollTextBox::get_rows()
1173 char* BC_ScrollTextBox::get_text()
1175 return text->get_text();
1178 void BC_ScrollTextBox::update(char *text)
1180 this->text->update(text);
1181 yscroll->update_length(this->text->get_text_rows(),
1182 this->text->get_text_row(),
1183 yscroll->get_handlelength());
1186 void BC_ScrollTextBox::reposition_window(int x, int y, int w, int rows)
1192 text->reposition_window(x,
1194 w - yscroll->get_span(),
1196 yscroll->reposition_window(x + w - yscroll->get_span(),
1198 BC_TextBox::calculate_row_h(rows,
1200 yscroll->update_length(text->get_text_rows(),
1201 text->get_text_row(),
1213 BC_ScrollTextBoxText::BC_ScrollTextBoxText(BC_ScrollTextBox *gui)
1214 : BC_TextBox(gui->x,
1216 gui->w - get_resources()->vscroll_data[SCROLL_HANDLE_UP]->get_w(),
1223 BC_ScrollTextBoxText::~BC_ScrollTextBoxText()
1232 int BC_ScrollTextBoxText::handle_event()
1234 gui->yscroll->update_length(get_text_rows(),
1236 gui->yscroll->get_handlelength());
1237 return gui->handle_event();
1240 int BC_ScrollTextBoxText::motion_event()
1242 gui->yscroll->update_length(get_text_rows(),
1244 gui->yscroll->get_handlelength());
1249 BC_ScrollTextBoxYScroll::BC_ScrollTextBoxYScroll(BC_ScrollTextBox *gui)
1250 : BC_ScrollBar(gui->x +
1252 get_resources()->vscroll_data[SCROLL_HANDLE_UP]->get_w(),
1255 BC_TextBox::calculate_row_h(gui->rows,
1256 gui->parent_window),
1257 gui->text->get_text_rows(),
1264 BC_ScrollTextBoxYScroll::~BC_ScrollTextBoxYScroll()
1268 int BC_ScrollTextBoxYScroll::handle_event()
1270 gui->text->set_text_row(get_position());
1283 BC_PopupTextBoxText::BC_PopupTextBoxText(BC_PopupTextBox *popup, int x, int y)
1284 : BC_TextBox(x, y, popup->text_w, 1, popup->default_text)
1286 this->popup = popup;
1289 BC_PopupTextBoxText::~BC_PopupTextBoxText()
1300 int BC_PopupTextBoxText::handle_event()
1302 popup->handle_event();
1306 BC_PopupTextBoxList::BC_PopupTextBoxList(BC_PopupTextBox *popup, int x, int y)
1309 popup->text_w + BC_WindowBase::get_resources()->listbox_button[0]->get_w(),
1319 this->popup = popup;
1321 int BC_PopupTextBoxList::handle_event()
1323 popup->textbox->update(get_selection(0, 0)->get_text());
1324 popup->handle_event();
1331 BC_PopupTextBox::BC_PopupTextBox(BC_WindowBase *parent_window,
1332 ArrayList<BC_ListBoxItem*> *list_items,
1341 this->list_h = list_h;
1342 this->default_text = default_text;
1343 this->text_w = text_w;
1344 this->parent_window = parent_window;
1345 this->list_items = list_items;
1348 BC_PopupTextBox::~BC_PopupTextBox()
1358 int BC_PopupTextBox::create_objects()
1360 int x = this->x, y = this->y;
1361 parent_window->add_subwindow(textbox = new BC_PopupTextBoxText(this, x, y));
1362 x += textbox->get_w();
1363 parent_window->add_subwindow(listbox = new BC_PopupTextBoxList(this, x, y));
1367 void BC_PopupTextBox::update(char *text)
1369 textbox->update(text);
1372 void BC_PopupTextBox::update_list(ArrayList<BC_ListBoxItem*> *data)
1374 listbox->update(data,
1381 char* BC_PopupTextBox::get_text()
1383 return textbox->get_text();
1386 int BC_PopupTextBox::get_number()
1388 return listbox->get_selection_number(0, 0);
1391 int BC_PopupTextBox::get_x()
1396 int BC_PopupTextBox::get_y()
1401 int BC_PopupTextBox::get_w()
1403 return textbox->get_w() + listbox->get_w();
1406 int BC_PopupTextBox::get_h()
1408 return textbox->get_h();
1411 int BC_PopupTextBox::handle_event()
1416 void BC_PopupTextBox::reposition_window(int x, int y)
1421 textbox->reposition_window(x1, y1);
1422 x1 += textbox->get_w();
1423 listbox->reposition_window(x1, y1);
1439 BC_TumbleTextBoxText::BC_TumbleTextBoxText(BC_TumbleTextBox *popup,
1440 int64_t default_value,
1451 this->popup = popup;
1454 BC_TumbleTextBoxText::BC_TumbleTextBoxText(BC_TumbleTextBox *popup,
1455 float default_value,
1466 this->popup = popup;
1469 BC_TumbleTextBoxText::~BC_TumbleTextBoxText()
1481 int BC_TumbleTextBoxText::handle_event()
1483 popup->handle_event();
1492 BC_TumbleTextBox::BC_TumbleTextBox(BC_WindowBase *parent_window,
1493 int64_t default_value,
1505 this->default_value = default_value;
1506 this->text_w = text_w;
1507 this->parent_window = parent_window;
1512 BC_TumbleTextBox::BC_TumbleTextBox(BC_WindowBase *parent_window,
1525 this->default_value = default_value;
1526 this->text_w = text_w;
1527 this->parent_window = parent_window;
1532 BC_TumbleTextBox::BC_TumbleTextBox(BC_WindowBase *parent_window,
1533 float default_value_f,
1543 this->min_f = min_f;
1544 this->max_f = max_f;
1545 this->default_value_f = default_value_f;
1546 this->text_w = text_w;
1547 this->parent_window = parent_window;
1552 BC_TumbleTextBox::~BC_TumbleTextBox()
1554 // Recursive delete. Normally ~BC_TumbleTextBox is never called but textbox
1555 // is deleted anyway by the windowbase so textbox deletes this.
1556 if(tumbler) delete tumbler;
1558 // Don't delete text here if we were called by ~BC_TumbleTextBoxText
1567 void BC_TumbleTextBox::reset()
1574 void BC_TumbleTextBox::set_precision(int precision)
1576 this->precision = precision;
1579 void BC_TumbleTextBox::set_increment(float value)
1581 this->increment = value;
1582 if(tumbler) tumbler->set_increment(value);
1585 int BC_TumbleTextBox::create_objects()
1587 int x = this->x, y = this->y;
1591 parent_window->add_subwindow(textbox = new BC_TumbleTextBoxText(this,
1597 textbox->set_precision(precision);
1600 parent_window->add_subwindow(textbox = new BC_TumbleTextBoxText(this,
1607 x += textbox->get_w();
1610 parent_window->add_subwindow(tumbler = new BC_FTumbler(textbox,
1616 parent_window->add_subwindow(tumbler = new BC_ITumbler(textbox,
1622 tumbler->set_increment(precision);
1626 char* BC_TumbleTextBox::get_text()
1628 return textbox->get_text();
1631 int BC_TumbleTextBox::update(char *value)
1633 textbox->update(value);
1637 int BC_TumbleTextBox::update(int64_t value)
1639 textbox->update(value);
1643 int BC_TumbleTextBox::update(float value)
1645 textbox->update(value);
1650 int BC_TumbleTextBox::get_x()
1655 int BC_TumbleTextBox::get_y()
1660 int BC_TumbleTextBox::get_w()
1662 return textbox->get_w() + tumbler->get_w();
1665 int BC_TumbleTextBox::get_h()
1667 return textbox->get_h();
1670 int BC_TumbleTextBox::handle_event()
1675 void BC_TumbleTextBox::reposition_window(int x, int y)
1680 textbox->reposition_window(x,
1684 tumbler->reposition_window(x + textbox->get_w(),
1689 void BC_TumbleTextBox::set_boundaries(int64_t min, int64_t max)
1691 tumbler->set_boundaries(min, max);
1694 void BC_TumbleTextBox::set_boundaries(float min, float max)
1696 tumbler->set_boundaries(min, max);