X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fguicast%2Fbctextbox.C;h=a661135240c61909a9f25b09e78973853157f904;hb=4c1a91d9f9373e564ecbeb8f568e4a3e7fe48e64;hp=e8cb09ced1fc35afb853cea90382e99766229cd8;hpb=77815ec03df6a03ed75433e8cf8ae1e83fb76d6e;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/guicast/bctextbox.C b/cinelerra-5.1/guicast/bctextbox.C index e8cb09ce..a6611352 100644 --- a/cinelerra-5.1/guicast/bctextbox.C +++ b/cinelerra-5.1/guicast/bctextbox.C @@ -133,7 +133,6 @@ BC_TextBox::~BC_TextBox() delete suggestions_popup; suggestions->remove_all_objects(); delete suggestions; - delete [] positions; delete [] wtext; if( size > 0 ) delete [] text; @@ -171,8 +170,6 @@ int BC_TextBox::reset_parameters(int rows, int has_border, int font, int size) wtext = 0; wsize = 0; wlen = 0; - positions = 0; - plen = 0; keypress_draw = 1; last_keypress = 0; separators = 0; @@ -226,12 +223,6 @@ int BC_TextBox::wtext_update() wchar_t *ntext = new wchar_t[nsize+1]; memcpy(ntext, wtext, wsize*sizeof(wtext[0])); delete [] wtext; wtext = ntext; wsize = nsize; - int *npositions = new int[nsize+1]; - if( plen > 0 ) - memcpy(npositions, positions, (plen+1)*sizeof(positions[0])); - else - npositions[0] = 0; - delete [] positions; positions = npositions; plen = nsize; } wlen = BC_Resources::encode(src_enc, dst_enc, text, strlen(text), (char*)wtext, wsize*sizeof(wchar_t)) / sizeof(wchar_t); @@ -406,7 +397,6 @@ void BC_TextBox::set_suggestions(ArrayList *suggestions, int column) if( col < 0 ) col = 0; char *cur = current_suggestion + col; tstrcat(cur); - draw(0); // update positions highlight_letter2 = wtext_update(); //printf("BC_TextBox::set_suggestions %d %d\n", __LINE__, suggestion_column); @@ -687,13 +677,13 @@ void BC_TextBox::draw(int flush) set_color(color); if(highlight_letter1 >= row_begin && highlight_letter1 <= row_end) - highlight_x1 = positions[highlight_letter1]; + highlight_x1 = get_x_position(highlight_letter1, row_begin); else highlight_x1 = 0; if(highlight_letter2 > row_begin && highlight_letter2 <= row_end) - highlight_x2 = positions[highlight_letter2]; + highlight_x2 = get_x_position(highlight_letter2, row_begin); else highlight_x2 = get_w(); @@ -705,17 +695,14 @@ void BC_TextBox::draw(int flush) int len = row_end - row_begin; if( len > 0 ) { set_color(enabled ? resources->text_default : DMGREY); - draw_wtext(text_x, k + text_ascent, wtext_row, len, - 0, &positions[wtext_row - wtext]); + draw_wtext(text_x, k + text_ascent, wtext_row, len, 0); } - else - positions[wtext_row - wtext] = 0; // Get ibeam location if(ibeam_letter >= row_begin && ibeam_letter <= row_end) { need_ibeam = 0; ibeam_y = k - text_y; - ibeam_x = positions[ibeam_letter]; + ibeam_x = get_x_position(ibeam_letter, row_begin); } } } @@ -753,7 +740,6 @@ int BC_TextBox::cursor_enter_event() if( top_level->event_win == win && enabled && !(top_level->get_resources()->textbox_focus_policy & CLICK_ACTIVATE) ) { - tooltip_done = 0; if( !active ) { top_level->deactivate(); activate(); @@ -777,7 +763,7 @@ int BC_TextBox::cursor_leave_event() draw_border(); flash(1); } - if( !suggestions_popup && + if( !suggestions_popup && !get_button_down() && !(top_level->get_resources()->textbox_focus_policy & CLICK_DEACTIVATE) ) deactivate(); return 0; @@ -1014,7 +1000,6 @@ int BC_TextBox::repeat_event(int64_t duration) tooltip_text && tooltip_text[0] != 0 && highlighted) { show_tooltip(); - tooltip_done = 1; result = 1; } @@ -1769,6 +1754,11 @@ void BC_TextBox::do_separators(int ibeam_left) } } +int BC_TextBox::get_x_position(int i, int start) +{ + return get_text_width(font, &wtext[start], i - start); +} + void BC_TextBox::get_ibeam_position(int &x, int &y) { int i, row_begin, row_end; @@ -1781,7 +1771,7 @@ void BC_TextBox::get_ibeam_position(int &x, int &y) row_end = i; if( ibeam_letter >= row_begin && ibeam_letter <= row_end ) { - x = get_text_width(font, &wtext[row_begin], ibeam_letter - row_begin); + x = get_x_position(ibeam_letter, row_begin); //printf("BC_TextBox::get_ibeam_position %d %d %d %d %d\n", ibeam_letter, row_begin, row_end, x, y); return; } @@ -2166,19 +2156,6 @@ void BC_ScrollTextBox::create_objects() set_text_row(0); } -int BC_ScrollTextBox::handle_event() { return 1; } -int BC_ScrollTextBox::button_press_event() { return text->BC_TextBox::button_press_event(); } -int BC_ScrollTextBox::button_release_event() { return text->BC_TextBox::button_release_event(); } -int BC_ScrollTextBox::get_buttonpress() { return text->BC_TextBox::get_buttonpress(); }; -int BC_ScrollTextBox::get_x() { return x; } -int BC_ScrollTextBox::get_y() { return y; } -int BC_ScrollTextBox::get_w() { return w; } -int BC_ScrollTextBox::get_h() { return text->get_h(); } -int BC_ScrollTextBox::get_rows() { return rows; } - -const char* BC_ScrollTextBox::get_text() { return text->get_text(); } -const wchar_t* BC_ScrollTextBox::get_wtext() { return text->get_wtext(); } - void BC_ScrollTextBox::set_text(char *text, int isz) { this->text->set_text(text, isz); @@ -2234,27 +2211,36 @@ void BC_ScrollTextBox::reposition_window(int x, int y, int w, int rows) 0); } -void BC_ScrollTextBox::set_selection(int char1, int char2, int ibeam) +int BC_ScrollTextBox::button_press_event() { - this->text->set_selection(char1, char2, ibeam); + return text->BC_TextBox::button_press_event(); +} +int BC_ScrollTextBox::button_release_event() +{ + return text->BC_TextBox::button_release_event(); } +int BC_ScrollTextBox::get_h() { return text->get_h(); } +const char *BC_ScrollTextBox::get_text() { return text->get_text(); } +const wchar_t *BC_ScrollTextBox::get_wtext() { return text->get_wtext(); } + +int BC_ScrollTextBox::get_buttonpress() +{ + return text->BC_TextBox::get_buttonpress(); +} void BC_ScrollTextBox::wset_selection(int char1, int char2, int ibeam) { - this->text->wset_selection(char1, char2, ibeam); + text->wset_selection(char1, char2, ibeam); +} +void BC_ScrollTextBox::set_selection(int char1, int char2, int ibeam) +{ + text->set_selection(char1, char2, ibeam); } - int BC_ScrollTextBox::get_ibeam_letter() { - return this->text->get_ibeam_letter(); + return text->get_ibeam_letter(); } - - - - - - BC_ScrollTextBoxText::BC_ScrollTextBoxText(BC_ScrollTextBox *gui, const char *text) : BC_TextBox(gui->x, gui->y, gui->w - get_resources()->vscroll_data[SCROLL_HANDLE_UP]->get_w(), @@ -2325,13 +2311,6 @@ int BC_ScrollTextBoxYScroll::handle_event() - - - - - - - BC_PopupTextBoxText::BC_PopupTextBoxText(BC_PopupTextBox *popup, int x, int y, const char *text) : BC_TextBox(x, y, popup->text_w, 1, text, BCTEXTLEN) { @@ -2373,6 +2352,7 @@ int BC_PopupTextBoxList::handle_event() if(item) { popup->textbox->update(item->get_text()); + popup->textbox->set_text_row(0); popup->handle_event(); } return 1; @@ -2421,14 +2401,12 @@ int BC_PopupTextBox::create_objects() void BC_PopupTextBox::update(const char *text) { textbox->update(text); + textbox->set_text_row(0); } void BC_PopupTextBox::update_list(ArrayList *data) { - listbox->update(data, - 0, - 0, - 1); + listbox->update(data, 0, 0, 1); } @@ -2467,6 +2445,16 @@ int BC_PopupTextBox::get_h() return textbox->get_h(); } +int BC_PopupTextBox::get_show_query() +{ + return listbox->get_show_query(); +} + +void BC_PopupTextBox::set_show_query(int v) +{ + listbox->set_show_query(v); +} + int BC_PopupTextBox::handle_event() { return 1; @@ -2707,18 +2695,21 @@ BC_TextBox* BC_TumbleTextBox::get_textbox() int BC_TumbleTextBox::update(const char *value) { textbox->update(value); + textbox->set_text_row(0); return 0; } int BC_TumbleTextBox::update(int64_t value) { textbox->update(value); + textbox->set_text_row(0); return 0; } int BC_TumbleTextBox::update(float value) { textbox->update(value); + textbox->set_text_row(0); return 0; } @@ -2797,3 +2788,9 @@ void BC_TumbleTextBox::set_boundaries(float min, float max) { tumbler->set_boundaries(min, max); } + +void BC_TumbleTextBox::set_tooltip(const char *text) +{ + textbox->set_tooltip(text); +} +