add 2 asset list fmts, user title rework, added show edit, bt tweak
[goodguy/history.git] / cinelerra-5.1 / guicast / bctextbox.C
index bdbe6040e51cf63939c1e1a1464c567ceccf941c..da7afa0f42e8b701228ad73d0cf3beeedf652d50 100644 (file)
@@ -166,6 +166,8 @@ int BC_TextBox::reset_parameters(int rows, int has_border, int font, int size)
        text_x = 0;
        enabled = 1;
        highlighted = 0;
+       back_color = -1;
+       high_color = -1;
        precision = 4;
        if (!skip_cursor)
                skip_cursor = new Timer;
@@ -191,8 +193,9 @@ int BC_TextBox::tstrlen()
 
 int BC_TextBox::tstrcmp(const char *cp)
 {
-       if( !tsize ) return strcmp(text, cp);
-       return strncmp(text, cp, tsize);
+       const char *tp = get_text();
+       if( !tsize ) return strcmp(tp, cp);
+       return strncmp(tp, cp, tsize);
 }
 
 char *BC_TextBox::tstrcpy(const char *cp)
@@ -280,13 +283,13 @@ int BC_TextBox::initialize()
        BC_Resources *resources = get_resources();
        if(has_border)
        {
-               back_color = resources->text_background;
-               high_color = resources->text_background_hi;
+               if( back_color < 0 ) back_color = resources->text_background;
+               if( high_color < 0 ) high_color = resources->text_background_hi;
        }
        else
        {
-               high_color = resources->text_background_noborder_hi;
-               back_color = bg_color;
+               if( back_color < 0 ) back_color = bg_color;
+               if( high_color < 0 ) high_color = resources->text_background_noborder_hi;
        }
 
        draw(0);
@@ -401,9 +404,9 @@ void BC_TextBox::set_suggestions(ArrayList<char*> *suggestions, int column)
 // Show the highlighted text
                if( suggestions->size() == 1 ) {
                        highlight_letter1 = wtext_update();
-                       text_update(wtext,wlen, text,tsize);
+                       int len = text_update(wtext,wlen, text,tsize);
                        char *current_suggestion = suggestions->get(0);
-                       int col = highlight_letter1 - suggestion_column;
+                       int col = len - suggestion_column;
                        if( col < 0 ) col = 0;
                        char *cur = current_suggestion + col;
                        tstrcat(cur);
@@ -455,7 +458,8 @@ int BC_TextBox::update(const char *text)
 {
 //printf("BC_TextBox::update 1 %d %s %s\n", tstrcmp(text), text, this->text);
 // Don't update if contents are the same
-       if(!tstrcmp(text)) return 0;
+       int bg_color = has_border || !highlighted ? back_color : high_color;
+       if( bg_color == background_color && !tstrcmp(text)) return 0;
        tstrcpy(text);
        int wtext_len = wtext_update();
        if(highlight_letter1 > wtext_len) highlight_letter1 = wtext_len;
@@ -518,6 +522,8 @@ int BC_TextBox::get_text_x() { return text_x; }
 int BC_TextBox::get_text_y() { return text_y; }
 void BC_TextBox::set_text_x(int v) { text_x = v; }
 void BC_TextBox::set_text_y(int v) { text_y = v; }
+int BC_TextBox::get_back_color() { return back_color; }
+void BC_TextBox::set_back_color(int v) { back_color = v; }
 
 int BC_TextBox::pixels_to_rows(BC_WindowBase *window, int font, int pixels)
 {
@@ -654,12 +660,7 @@ void BC_TextBox::draw(int flush)
 
 //printf("BC_TextBox::draw %d %s\n", __LINE__, text);
 // Background
-       if(has_border)
-               background_color = resources->text_background;
-       else if(highlighted)
-               background_color = high_color;
-       else
-               background_color = back_color;
+       background_color = has_border || !highlighted ? back_color : high_color;
        set_color(background_color);
        draw_box(0, 0, w, h);
 
@@ -2077,6 +2078,7 @@ void BC_TextBox::paste_selection(int clipboard_num)
                len = BC_Resources::encode(BC_Resources::encoding, BC_Resources::wide_encoding,
                        cstring,len, (char *)wstring,(len+1)*sizeof(wchar_t)) / sizeof(wchar_t);
                insert_text(wstring, len);
+               last_keypress = 0;
        }
 }