| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_VIEWS_CONTROLS_LABEL_H_ | 5 #ifndef CHROME_VIEWS_CONTROLS_LABEL_H_ |
| 6 #define CHROME_VIEWS_CONTROLS_LABEL_H_ | 6 #define CHROME_VIEWS_CONTROLS_LABEL_H_ |
| 7 | 7 |
| 8 #include "chrome/common/gfx/chrome_font.h" | 8 #include "chrome/common/gfx/chrome_font.h" |
| 9 #include "chrome/views/view.h" | 9 #include "chrome/views/view.h" |
| 10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 virtual void OnMouseExited(const MouseEvent& event); | 146 virtual void OnMouseExited(const MouseEvent& event); |
| 147 | 147 |
| 148 // The background color to use when the mouse is over the label. Label | 148 // The background color to use when the mouse is over the label. Label |
| 149 // takes ownership of the Background. | 149 // takes ownership of the Background. |
| 150 void SetMouseOverBackground(Background* background); | 150 void SetMouseOverBackground(Background* background); |
| 151 const Background* GetMouseOverBackground() const; | 151 const Background* GetMouseOverBackground() const; |
| 152 | 152 |
| 153 // Sets the enabled state. Setting the enabled state resets the color. | 153 // Sets the enabled state. Setting the enabled state resets the color. |
| 154 virtual void SetEnabled(bool enabled); | 154 virtual void SetEnabled(bool enabled); |
| 155 | 155 |
| 156 // Overridden from View: |
| 157 virtual gfx::Insets GetInsets() const; |
| 158 |
| 156 // Resizes the label so its width is set to the width of the longest line and | 159 // Resizes the label so its width is set to the width of the longest line and |
| 157 // its height deduced accordingly. | 160 // its height deduced accordingly. |
| 158 // This is only intended for multi-line labels and is useful when the label's | 161 // This is only intended for multi-line labels and is useful when the label's |
| 159 // text contains several lines separated with \n. | 162 // text contains several lines separated with \n. |
| 160 // |max_width| is the maximum width that will be used (longer lines will be | 163 // |max_width| is the maximum width that will be used (longer lines will be |
| 161 // wrapped). If 0, no maximum width is enforced. | 164 // wrapped). If 0, no maximum width is enforced. |
| 162 void SizeToFit(int max_width); | 165 void SizeToFit(int max_width); |
| 163 | 166 |
| 164 #if defined(OS_WIN) | 167 #if defined(OS_WIN) |
| 165 // TODO(port): Make portable equivalents of accessibility-related functions. | 168 // TODO(port): Make portable equivalents of accessibility-related functions. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 177 // Overriden from View. | 180 // Overriden from View. |
| 178 virtual bool GetAccessibleState(VARIANT* state); | 181 virtual bool GetAccessibleState(VARIANT* state); |
| 179 #endif // defined(OS_WIN) | 182 #endif // defined(OS_WIN) |
| 180 | 183 |
| 181 // Gets/sets the flag to determine whether the label should be collapsed when | 184 // Gets/sets the flag to determine whether the label should be collapsed when |
| 182 // it's hidden (not visible). If this flag is true, the label will return a | 185 // it's hidden (not visible). If this flag is true, the label will return a |
| 183 // preferred size of (0, 0) when it's not visible. | 186 // preferred size of (0, 0) when it's not visible. |
| 184 void set_collapse_when_hidden(bool value) { collapse_when_hidden_ = value; } | 187 void set_collapse_when_hidden(bool value) { collapse_when_hidden_ = value; } |
| 185 bool collapse_when_hidden() const { return collapse_when_hidden_; } | 188 bool collapse_when_hidden() const { return collapse_when_hidden_; } |
| 186 | 189 |
| 190 void set_paint_as_focused(bool paint_as_focused) { |
| 191 paint_as_focused_ = paint_as_focused; |
| 192 } |
| 193 |
| 187 private: | 194 private: |
| 188 // These tests call CalculateDrawStringParams in order to verify the | 195 // These tests call CalculateDrawStringParams in order to verify the |
| 189 // calculations done for drawing text. | 196 // calculations done for drawing text. |
| 190 FRIEND_TEST(LabelTest, DrawSingleLineString); | 197 FRIEND_TEST(LabelTest, DrawSingleLineString); |
| 191 FRIEND_TEST(LabelTest, DrawMultiLineString); | 198 FRIEND_TEST(LabelTest, DrawMultiLineString); |
| 192 | 199 |
| 193 static ChromeFont GetDefaultFont(); | 200 static ChromeFont GetDefaultFont(); |
| 194 | 201 |
| 195 // Returns parameters to be used for the DrawString call. | 202 // Returns parameters to be used for the DrawString call. |
| 196 void CalculateDrawStringParams(std::wstring* paint_text, | 203 void CalculateDrawStringParams(std::wstring* paint_text, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 224 std::wstring tooltip_text_; | 231 std::wstring tooltip_text_; |
| 225 // Whether the mouse is over this label. | 232 // Whether the mouse is over this label. |
| 226 bool contains_mouse_; | 233 bool contains_mouse_; |
| 227 scoped_ptr<Background> mouse_over_background_; | 234 scoped_ptr<Background> mouse_over_background_; |
| 228 // Whether to collapse the label when it's not visible. | 235 // Whether to collapse the label when it's not visible. |
| 229 bool collapse_when_hidden_; | 236 bool collapse_when_hidden_; |
| 230 // The following member variable is used to control whether the alignment | 237 // The following member variable is used to control whether the alignment |
| 231 // needs to be flipped around for RTL locales. Please refer to the definition | 238 // needs to be flipped around for RTL locales. Please refer to the definition |
| 232 // of RTLAlignmentMode for more information. | 239 // of RTLAlignmentMode for more information. |
| 233 RTLAlignmentMode rtl_alignment_mode_; | 240 RTLAlignmentMode rtl_alignment_mode_; |
| 241 // When embedded in a larger control that is focusable, setting this flag |
| 242 // allows this view to be painted as focused even when it is itself not. |
| 243 bool paint_as_focused_; |
| 234 | 244 |
| 235 DISALLOW_COPY_AND_ASSIGN(Label); | 245 DISALLOW_COPY_AND_ASSIGN(Label); |
| 236 }; | 246 }; |
| 237 | 247 |
| 238 } // namespace views | 248 } // namespace views |
| 239 | 249 |
| 240 #endif // CHROME_VIEWS_CONTROLS_LABEL_H_ | 250 #endif // CHROME_VIEWS_CONTROLS_LABEL_H_ |
| OLD | NEW |