Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Side by Side Diff: chrome/views/text_button.h

Issue 7344: Convert GetPreferredSize from:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_TEXT_BUTTON_H__ 5 #ifndef CHROME_VIEWS_TEXT_BUTTON_H__
6 #define CHROME_VIEWS_TEXT_BUTTON_H__ 6 #define CHROME_VIEWS_TEXT_BUTTON_H__
7 7
8 #include <windows.h> 8 #include <windows.h>
9 9
10 #include "chrome/common/gfx/chrome_font.h" 10 #include "chrome/common/gfx/chrome_font.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 public: 68 public:
69 TextButton(const std::wstring& text); 69 TextButton(const std::wstring& text);
70 virtual ~TextButton(); 70 virtual ~TextButton();
71 71
72 typedef enum TextAlignment { 72 typedef enum TextAlignment {
73 ALIGN_LEFT, 73 ALIGN_LEFT,
74 ALIGN_CENTER, 74 ALIGN_CENTER,
75 ALIGN_RIGHT 75 ALIGN_RIGHT
76 }; 76 };
77 77
78 void GetPreferredSize(CSize* result); 78 virtual gfx::Size GetPreferredSize();
79 void GetMinimumSize(CSize* result); 79 virtual gfx::Size GetMinimumSize();
80 virtual bool OnMousePressed(const ChromeViews::MouseEvent& e); 80 virtual bool OnMousePressed(const ChromeViews::MouseEvent& e);
81 81
82 // Call SetText once per string in your set of possible values at 82 // Call SetText once per string in your set of possible values at
83 // button creation time, so that it can contain the largest of them 83 // button creation time, so that it can contain the largest of them
84 // and avoid resizing the button when the text changes. 84 // and avoid resizing the button when the text changes.
85 virtual void SetText(const std::wstring& text); 85 virtual void SetText(const std::wstring& text);
86 86
87 void TextButton::SetTextAlignment(TextAlignment alignment) { 87 void TextButton::SetTextAlignment(TextAlignment alignment) {
88 alignment_ = alignment; 88 alignment_ = alignment;
89 } 89 }
(...skipping 16 matching lines...) Expand all
106 // Sets the enabled state. Setting the enabled state resets the color. 106 // Sets the enabled state. Setting the enabled state resets the color.
107 virtual void SetEnabled(bool enabled); 107 virtual void SetEnabled(bool enabled);
108 108
109 // Sets the max width. The preferred width of the button will never be larger 109 // Sets the max width. The preferred width of the button will never be larger
110 // then the specified value. A value <= 0 indicates the preferred width 110 // then the specified value. A value <= 0 indicates the preferred width
111 // is not constrained in anyway. 111 // is not constrained in anyway.
112 void set_max_width(int max_width) { max_width_ = max_width; } 112 void set_max_width(int max_width) { max_width_ = max_width; }
113 113
114 private: 114 private:
115 std::wstring text_; 115 std::wstring text_;
116 CSize text_size_; 116 gfx::Size text_size_;
117 117
118 // Track the size of the largest text string seen so far, so that 118 // Track the size of the largest text string seen so far, so that
119 // changing text_ will not resize the button boundary. 119 // changing text_ will not resize the button boundary.
120 CSize max_text_size_; 120 gfx::Size max_text_size_;
121 121
122 TextAlignment alignment_; 122 TextAlignment alignment_;
123 123
124 ChromeFont font_; 124 ChromeFont font_;
125 125
126 // Text color. 126 // Text color.
127 SkColor color_; 127 SkColor color_;
128 128
129 SkBitmap icon_; 129 SkBitmap icon_;
130 130
131 // See setter for details. 131 // See setter for details.
132 int max_width_; 132 int max_width_;
133 133
134 DISALLOW_EVIL_CONSTRUCTORS(TextButton); 134 DISALLOW_EVIL_CONSTRUCTORS(TextButton);
135 }; 135 };
136 136
137 137
138 } // namespace 138 } // namespace
139 139
140 #endif // CHROME_VIEWS_TEXT_BUTTON_H__ 140 #endif // CHROME_VIEWS_TEXT_BUTTON_H__
141 141
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698