X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=blobdiff_plain;f=cinelerra-5.1%2Fguicast%2Fbctextbox.C;h=b81da1fb35e261568755a89d4c09e7dd766a3280;hp=078134c011f6a0c8b595c762a83bf0e8783dd840;hb=HEAD;hpb=3d5faf45a6c261bb3e9973b42cf682415a1fde2e diff --git a/cinelerra-5.1/guicast/bctextbox.C b/cinelerra-5.1/guicast/bctextbox.C index 078134c0..afbf7147 100644 --- a/cinelerra-5.1/guicast/bctextbox.C +++ b/cinelerra-5.1/guicast/bctextbox.C @@ -58,14 +58,14 @@ BC_TextBox::BC_TextBox(int x, int y, int w, int rows, } BC_TextBox::BC_TextBox(int x, int y, int w, int rows, - int size, wchar_t *wtext, int has_border, int font) + int size, wchr_t *wtext, int has_border, int font) : BC_SubWindow(x, y, w, 0, -1) { is_utf8 = 1; skip_cursor = 0; reset_parameters(rows, has_border, font, size); - wdemand(wcslen(wtext)); - wcsncpy(this->wtext, wtext, wsize); + wdemand(wstrlen(wtext)); + wstrncpy(this->wtext, wtext, wsize); } BC_TextBox::BC_TextBox(int x, int y, int w, int rows, @@ -79,15 +79,15 @@ BC_TextBox::BC_TextBox(int x, int y, int w, int rows, } BC_TextBox::BC_TextBox(int x, int y, int w, int rows, - const wchar_t *wtext, int has_border, int font, int is_utf8) + const wchr_t *wtext, int has_border, int font, int is_utf8) : BC_SubWindow(x, y, w, 0, -1) { this->is_utf8 = is_utf8; skip_cursor = 0; reset_parameters(rows, has_border, font, BCTEXTLEN); wsize = BCTEXTLEN; - wtext = new wchar_t[wsize+1]; - wcsncpy(this->wtext, wtext, wsize); + wtext = new wchr_t[wsize+1]; + wstrncpy(this->wtext, wtext, wsize); this->wtext[wsize] = 0; } @@ -224,20 +224,20 @@ int BC_TextBox::wtext_update() int nsize = tsize > 0 ? tsize : tlen + BCTEXTLEN; wdemand(nsize); wlen = BC_Resources::encode(src_enc, dst_enc, text, tlen, - (char*)wtext, wsize*sizeof(wchar_t)) / sizeof(wchar_t); + (char*)wtext, wsize*sizeof(wchr_t)) / sizeof(wchr_t); dirty = 0; } wtext[wlen] = 0; return wlen; } -int BC_TextBox::text_update(const wchar_t *wcp, int wsz, char *tcp, int tsz) +int BC_TextBox::text_update(const wchr_t *wcp, int wsz, char *tcp, int tsz) { const char *src_enc = BC_Resources::wide_encoding; const char *dst_enc = BC_Resources::encoding; - if( wsz < 0 ) wsz = wcslen(wcp); + if( wsz < 0 ) wsz = wstrlen(wcp); int len = BC_Resources::encode(src_enc, dst_enc, - (char*)wcp, wsz*sizeof(wchar_t), tcp, tsz); + (char*)wcp, wsz*sizeof(wchr_t), tcp, tsz); tcp[len] = 0; return len; } @@ -460,11 +460,11 @@ int BC_TextBox::update(const char *text) return 0; } -int BC_TextBox::update(const wchar_t *wtext) +int BC_TextBox::update(const wchr_t *wtext) { - int wtext_len = wcslen(wtext); + int wtext_len = wstrlen(wtext); wdemand(wtext_len); - wcsncpy(this->wtext, wtext, wsize); + wstrncpy(this->wtext, wtext, wsize); this->wlen = wtext_len; if(highlight_letter1 > wtext_len) highlight_letter1 = wtext_len; if(highlight_letter2 > wtext_len) highlight_letter2 = wtext_len; @@ -541,7 +541,7 @@ const char* BC_TextBox::get_text() return text; } -const wchar_t* BC_TextBox::get_wtext() +const wchr_t* BC_TextBox::get_wtext() { wtext_update(); return wtext; @@ -664,7 +664,7 @@ void BC_TextBox::draw(int flush) for(i=0, k=text_y; i < wtext_len && k < get_h(); k += text_height) { // Draw row of text row_begin = i; - wchar_t *wtext_row = &wtext[i]; + wchr_t *wtext_row = &wtext[i]; for( ; iget_keypress(), len; - wchar_t *wkeys = top_level->get_wkeystring(&len); + wchr_t *wkeys = top_level->get_wkeystring(&len); switch( key ) { case KPENTER: key = '\n'; goto kpchr; case KPMINUS: key = '-'; goto kpchr; @@ -1152,13 +1152,16 @@ int BC_TextBox::keypress_event() int result = 0; int dispatch_event = 0; +// Evtl catch Alt/H + if (context_help_check_and_show()) return 1; + if(!active || !enabled) return 0; int wtext_len = wtext_update(); last_keypress = get_keypress(); if( unicode_active >= 0 ) { - wchar_t wch = 0; + wchr_t wch = 0; int wlen = -1; switch( last_keypress ) { //unicode active acitons @@ -1642,7 +1645,7 @@ int BC_TextBox::keypress_event() case 'u': case 'U': { if( shift_down() ) { unicode_active = ibeam_letter; - wchar_t wkey = 'U'; + wchr_t wkey = 'U'; insert_text(&wkey, 1); find_ibeam(1); highlight_letter1 = unicode_active; @@ -1737,7 +1740,7 @@ int BC_TextBox::wdemand(int len) { if( wtext && wsize >= len ) return 0; int nsize = len + wlen/2 + BCTEXTLEN; - wchar_t *ntext = new wchar_t[nsize+1]; + wchr_t *ntext = new wchr_t[nsize+1]; ntext[nsize] = 0; memcpy(ntext, wtext, wsize*sizeof(wtext[0])); delete [] wtext; wtext = ntext; wsize = nsize; @@ -1756,9 +1759,9 @@ int BC_TextBox::tdemand(int len) return 1; } -void BC_TextBox::insert_text(const wchar_t *wcp, int len) +void BC_TextBox::insert_text(const wchr_t *wcp, int len) { - if( len < 0 ) len = wcslen(wcp); + if( len < 0 ) len = wstrlen(wcp); int wtext_len = wtext_update(); wdemand(wtext_len + len + 1); if( unicode_active < 0 && highlight_letter1 < highlight_letter2 ) { @@ -2101,11 +2104,11 @@ void BC_TextBox::paste_selection(int clipboard_num) int len = clipboard_len(clipboard_num); if( len > 0 ) { - char cstring[len]; wchar_t wstring[len]; + char cstring[len]; wchr_t wstring[len]; from_clipboard(cstring, len, clipboard_num); --len; //printf("BC_TextBox::paste_selection %d '%*.*s'\n",len,len,len,cstring); len = BC_Resources::encode(BC_Resources::encoding, BC_Resources::wide_encoding, - cstring,len, (char *)wstring,(len+1)*sizeof(wchar_t)) / sizeof(wchar_t); + cstring,len, (char *)wstring,(len+1)*sizeof(wchr_t)) / sizeof(wchr_t); insert_text(wstring, len); last_keypress = 0; } @@ -2212,7 +2215,7 @@ BC_ScrollTextBox::BC_ScrollTextBox(BC_WindowBase *parent_window, BC_ScrollTextBox::BC_ScrollTextBox(BC_WindowBase *parent_window, int x, int y, int w, int rows, - const wchar_t *default_wtext, int default_size) + const wchr_t *default_wtext, int default_size) { this->parent_window = parent_window; this->x = x; @@ -2263,7 +2266,7 @@ void BC_ScrollTextBox::update(const char *text) update_scrollbars(); } -void BC_ScrollTextBox::update(const wchar_t *wtext) +void BC_ScrollTextBox::update(const wchr_t *wtext) { this->text->update(wtext); update_scrollbars(); @@ -2289,7 +2292,7 @@ int BC_ScrollTextBox::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(); } +const wchr_t *BC_ScrollTextBox::get_wtext() { return text->get_wtext(); } int BC_ScrollTextBox::get_buttonpress() { @@ -2325,10 +2328,10 @@ BC_ScrollTextBoxText::BC_ScrollTextBoxText(BC_ScrollTextBox *gui, const char *te this->gui = gui; } -BC_ScrollTextBoxText::BC_ScrollTextBoxText(BC_ScrollTextBox *gui, const wchar_t *wtext) +BC_ScrollTextBoxText::BC_ScrollTextBoxText(BC_ScrollTextBox *gui, const wchr_t *wtext) : BC_TextBox(gui->x, gui->y, gui->w - get_resources()->vscroll_data[SCROLL_HANDLE_UP]->get_w(), - gui->rows, gui->default_size, (wchar_t*)wtext, 1, MEDIUMFONT) + gui->rows, gui->default_size, (wchr_t*)wtext, 1, MEDIUMFONT) { this->gui = gui; } @@ -2377,7 +2380,8 @@ void BC_ScrollTextBox::update_scrollbars() delete yscroll; yscroll = 0; } - if( view_rows != text->get_rows() || view_w != text->get_w() ) { + if( view_rows != text->get_rows() || view_w != text->get_w() || + x != text->get_x() || y != text->get_y() ) { text->reposition_window(x, y, view_w, view_rows); } if( need_xscroll && !xscroll ) { @@ -2469,7 +2473,7 @@ BC_PopupTextBoxText::BC_PopupTextBoxText(BC_PopupTextBox *popup, int x, int y, c this->popup = popup; } -BC_PopupTextBoxText::BC_PopupTextBoxText(BC_PopupTextBox *popup, int x, int y, const wchar_t *wtext) +BC_PopupTextBoxText::BC_PopupTextBoxText(BC_PopupTextBox *popup, int x, int y, const wchr_t *wtext) : BC_TextBox(x, y, popup->text_w, 1, wtext, BCTEXTLEN) { this->popup = popup; @@ -2487,6 +2491,7 @@ BC_PopupTextBoxText::~BC_PopupTextBoxText() int BC_PopupTextBoxText::handle_event() { + popup->list_item = -1; popup->handle_event(); return 1; } @@ -2500,10 +2505,10 @@ BC_PopupTextBoxList::BC_PopupTextBoxList(BC_PopupTextBox *popup, int x, int y) } int BC_PopupTextBoxList::handle_event() { - BC_ListBoxItem *item = get_selection(0, 0); - if(item) - { - popup->textbox->update(item->get_text()); + int k = get_selection_number(0, 0); + popup->list_item = k; + if( k >= 0 && k < popup->list_items->size() ) { + popup->textbox->update(popup->list_items->get(k)->get_text()); popup->textbox->set_text_row(0); popup->handle_event(); } @@ -2558,58 +2563,31 @@ void BC_PopupTextBox::update(const char *text) void BC_PopupTextBox::update_list(ArrayList *data) { + list_items = data; listbox->update(data, 0, 0, 1); } - -const char* BC_PopupTextBox::get_text() -{ - return textbox->get_text(); -} - -const wchar_t* BC_PopupTextBox::get_wtext() -{ - return textbox->get_wtext(); -} - -int BC_PopupTextBox::get_number() -{ - return listbox->get_selection_number(0, 0); -} - -int BC_PopupTextBox::get_x() -{ - return x; -} - -int BC_PopupTextBox::get_y() -{ - return y; -} - -int BC_PopupTextBox::get_w() -{ - return textbox->get_w() + listbox->get_w(); -} - -int BC_PopupTextBox::get_h() -{ - return textbox->get_h(); -} - -int BC_PopupTextBox::get_show_query() +int BC_PopupTextBox::handle_event() { - return listbox->get_show_query(); + return 1; } -void BC_PopupTextBox::set_show_query(int v) -{ - listbox->set_show_query(v); -} +const char *BC_PopupTextBox::get_text() { return textbox->get_text(); } +const wchr_t *BC_PopupTextBox::get_wtext() { return textbox->get_wtext(); } +int BC_PopupTextBox::get_number() { return list_item; } +void BC_PopupTextBox::set_number(int v) { list_item = v; } +int BC_PopupTextBox::get_x() { return x; } +int BC_PopupTextBox::get_y() { return y; } +int BC_PopupTextBox::get_w() { return textbox->get_w() + listbox->get_w(); } +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::get_back_color() { return textbox->get_back_color(); } +void BC_PopupTextBox::set_back_color(int v) { textbox->set_back_color(v); } -int BC_PopupTextBox::handle_event() +void BC_PopupTextBox::set_tooltip(const char *text) { - return 1; + listbox->set_tooltip(text); } void BC_PopupTextBox::reposition_window(int x, int y) @@ -2626,12 +2604,6 @@ void BC_PopupTextBox::reposition_window(int x, int y) // if(flush) parent_window->flush(); } -void BC_PopupTextBox::set_tooltip(const char *text) -{ - listbox->set_tooltip(text); -} - - BC_TumbleTextBoxText::BC_TumbleTextBoxText(BC_TumbleTextBox *popup, int64_t default_value, int x, int y) @@ -2806,7 +2778,7 @@ const char* BC_TumbleTextBox::get_text() return textbox->get_text(); } -const wchar_t* BC_TumbleTextBox::get_wtext() +const wchr_t* BC_TumbleTextBox::get_wtext() { return textbox->get_wtext(); } @@ -2893,12 +2865,8 @@ void BC_TumbleTextBox::reposition_window(int x, int y) this->x = x; this->y = y; - textbox->reposition_window(x, - y, - text_w, - 1); - tumbler->reposition_window(x + textbox->get_w(), - y); + textbox->reposition_window(x, y, text_w, 1); + tumbler->reposition_window(x + textbox->get_w(), y); // if(flush) parent_window->flush(); }