| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ | 5 #ifndef VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ |
| 6 #define VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ | 6 #define VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ |
| 7 | 7 |
| 8 #include "third_party/skia/include/core/SkBitmap.h" | 8 #include "third_party/skia/include/core/SkBitmap.h" |
| 9 #include "views/view.h" | 9 #include "views/view.h" |
| 10 | 10 |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 // Returns the descendant with the specified command. | 239 // Returns the descendant with the specified command. |
| 240 MenuItemView* GetMenuItemByID(int id); | 240 MenuItemView* GetMenuItemByID(int id); |
| 241 | 241 |
| 242 // Invoke if you remove/add children to the menu while it's showing. This | 242 // Invoke if you remove/add children to the menu while it's showing. This |
| 243 // recalculates the bounds. | 243 // recalculates the bounds. |
| 244 void ChildrenChanged(); | 244 void ChildrenChanged(); |
| 245 | 245 |
| 246 // Sizes any child views. | 246 // Sizes any child views. |
| 247 virtual void Layout(); | 247 virtual void Layout(); |
| 248 | 248 |
| 249 // Returns the amount of space needed to accomodate the accelerator. The |
| 250 // space needed for the accelerator is NOT included in the preferred width. |
| 251 int GetAcceleratorTextWidth(); |
| 252 |
| 249 protected: | 253 protected: |
| 250 // Creates a MenuItemView. This is used by the various AddXXX methods. | 254 // Creates a MenuItemView. This is used by the various AddXXX methods. |
| 251 MenuItemView(MenuItemView* parent, int command, Type type); | 255 MenuItemView(MenuItemView* parent, int command, Type type); |
| 252 | 256 |
| 253 private: | 257 private: |
| 254 // Calculates all sizes that we can from the OS. | 258 // Calculates all sizes that we can from the OS. |
| 255 // | 259 // |
| 256 // This is invoked prior to Running a menu. | 260 // This is invoked prior to Running a menu. |
| 257 static void UpdateMenuPartSizes(bool has_icons); | 261 static void UpdateMenuPartSizes(bool has_icons); |
| 258 | 262 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 282 void RemoveEmptyMenus(); | 286 void RemoveEmptyMenus(); |
| 283 | 287 |
| 284 // Given bounds within our View, this helper routine mirrors the bounds if | 288 // Given bounds within our View, this helper routine mirrors the bounds if |
| 285 // necessary. | 289 // necessary. |
| 286 void AdjustBoundsForRTLUI(gfx::Rect* rect) const; | 290 void AdjustBoundsForRTLUI(gfx::Rect* rect) const; |
| 287 | 291 |
| 288 // Actual paint implementation. If for_drag is true, portions of the menu | 292 // Actual paint implementation. If for_drag is true, portions of the menu |
| 289 // are not rendered. | 293 // are not rendered. |
| 290 void Paint(gfx::Canvas* canvas, bool for_drag); | 294 void Paint(gfx::Canvas* canvas, bool for_drag); |
| 291 | 295 |
| 296 // Paints the accelerator. |
| 297 void PaintAccelerator(gfx::Canvas* canvas); |
| 298 |
| 292 // Destroys the window used to display this menu and recursively destroys | 299 // Destroys the window used to display this menu and recursively destroys |
| 293 // the windows used to display all descendants. | 300 // the windows used to display all descendants. |
| 294 void DestroyAllMenuHosts(); | 301 void DestroyAllMenuHosts(); |
| 295 | 302 |
| 303 // Returns the accelerator text. |
| 304 std::wstring GetAcceleratorText(); |
| 305 |
| 296 // Returns the various margins. | 306 // Returns the various margins. |
| 297 int GetTopMargin(); | 307 int GetTopMargin(); |
| 298 int GetBottomMargin(); | 308 int GetBottomMargin(); |
| 299 | 309 |
| 300 // Returns the preferred width (and padding) of any children. | 310 // Returns the preferred width (and padding) of any children. |
| 301 int GetChildPreferredWidth(); | 311 int GetChildPreferredWidth(); |
| 302 | 312 |
| 303 // The delegate. This is only valid for the root menu item. You shouldn't | 313 // The delegate. This is only valid for the root menu item. You shouldn't |
| 304 // use this directly, instead use GetDelegate() which walks the tree as | 314 // use this directly, instead use GetDelegate() which walks the tree as |
| 305 // as necessary. | 315 // as necessary. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 | 360 |
| 351 // Preferred height of menu items. Reset every time a menu is run. | 361 // Preferred height of menu items. Reset every time a menu is run. |
| 352 static int pref_menu_height_; | 362 static int pref_menu_height_; |
| 353 | 363 |
| 354 DISALLOW_COPY_AND_ASSIGN(MenuItemView); | 364 DISALLOW_COPY_AND_ASSIGN(MenuItemView); |
| 355 }; | 365 }; |
| 356 | 366 |
| 357 } // namespace views | 367 } // namespace views |
| 358 | 368 |
| 359 #endif // VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ | 369 #endif // VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ |
| OLD | NEW |