From 3a3f6c1ee938f2e8876c7b17dfddcb7b045ecd45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 10 Feb 2006 15:28:49 +0000 Subject: [PATCH] BTextControl::AttachedToWindow() set wrong colors in case the control was disabled (unlike SetEnabled()). They are now both using the correctly working _UpdateTextViewColors() method. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16333 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/interface/TextControl.h | 1 + src/kits/interface/TextControl.cpp | 82 +++++++++++++----------------- 2 files changed, 35 insertions(+), 48 deletions(-) diff --git a/headers/os/interface/TextControl.h b/headers/os/interface/TextControl.h index 2d95a701a8..a0c5213ebb 100644 --- a/headers/os/interface/TextControl.h +++ b/headers/os/interface/TextControl.h @@ -81,6 +81,7 @@ class BTextControl : public BControl { BTextControl& operator=(const BTextControl& other); void _CommitValue(); + void _UpdateTextViewColors(); void _InitData(const char* label, const char* initialText, BMessage* archive = NULL); diff --git a/src/kits/interface/TextControl.cpp b/src/kits/interface/TextControl.cpp index 66f626074b..fc6202f01d 100644 --- a/src/kits/interface/TextControl.cpp +++ b/src/kits/interface/TextControl.cpp @@ -324,31 +324,8 @@ BTextControl::AttachedToWindow() { BControl::AttachedToWindow(); - bool enabled = IsEnabled(); - rgb_color textColor; - rgb_color color = HighColor(); - BFont font; - - fText->GetFontAndColor(0, &font, &color); - - if (enabled) - textColor = color; - else - textColor = tint_color(color, B_LIGHTEN_2_TINT); - - fText->SetFontAndColor(&font, B_FONT_ALL, &textColor); - - if (enabled) { - color.red = 255; - color.green = 255; - color.blue = 255; - } else - color = tint_color(color, B_LIGHTEN_2_TINT); - - fText->SetViewColor(color); - fText->SetLowColor(color); - - fText->MakeEditable(enabled); + _UpdateTextViewColors(); + fText->MakeEditable(IsEnabled()); } @@ -373,29 +350,7 @@ BTextControl::SetEnabled(bool state) if (Window()) { fText->MakeEditable(state); - rgb_color textColor; - rgb_color color = {0, 0, 0, 255}; - BFont font; - - fText->GetFontAndColor(0, &font, &color); - - if (state) - textColor = color; - else - textColor = tint_color(color, B_DISABLED_LABEL_TINT); - - fText->SetFontAndColor(&font, B_FONT_ALL, &textColor); - - if (state) { - color.red = 255; - color.green = 255; - color.blue = 255; - } else - color = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), - B_LIGHTEN_2_TINT); - - fText->SetViewColor(color); - fText->SetLowColor(color); + _UpdateTextViewColors(); fText->Invalidate(); Window()->UpdateIfNeeded(); @@ -622,6 +577,37 @@ BTextControl::operator=(const BTextControl&) } +void +BTextControl::_UpdateTextViewColors() +{ + bool enabled = IsEnabled(); + rgb_color textColor; + rgb_color color = {0, 0, 0, 255}; + BFont font; + + fText->GetFontAndColor(0, &font, &color); + + if (enabled) + textColor = color; + else + textColor = tint_color(color, B_DISABLED_LABEL_TINT); + + fText->SetFontAndColor(&font, B_FONT_ALL, &textColor); + + if (enabled) { + color.red = 255; + color.green = 255; + color.blue = 255; + } else { + color = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), + B_LIGHTEN_2_TINT); + } + + fText->SetViewColor(color); + fText->SetLowColor(color); +} + + void BTextControl::_CommitValue() {