| 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 VIEWS_VIEW_H_ | 5 #ifndef VIEWS_VIEW_H_ |
| 6 #define VIEWS_VIEW_H_ | 6 #define VIEWS_VIEW_H_ |
| 7 | 7 |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| 11 #include <map> | 11 #include <map> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/gfx/rect.h" | 15 #include "base/gfx/rect.h" |
| 16 #include "base/scoped_ptr.h" | 16 #include "base/scoped_ptr.h" |
| 17 #include "views/accelerator.h" | 17 #include "views/accelerator.h" |
| 18 #include "views/accessibility/accessibility_types.h" | 18 #include "views/accessibility/accessibility_types.h" |
| 19 #include "views/background.h" | 19 #include "views/background.h" |
| 20 #include "views/border.h" | 20 #include "views/border.h" |
| 21 | 21 |
| 22 #if defined(OS_WIN) | 22 #if defined(OS_WIN) |
| 23 struct IDataObject; | 23 struct IDataObject; |
| 24 #endif // defined(OS_WIN) | 24 #endif // defined(OS_WIN) |
| 25 | 25 |
| 26 namespace gfx { | 26 namespace gfx { |
| 27 class Canvas; |
| 27 class Insets; | 28 class Insets; |
| 28 class Path; | 29 class Path; |
| 29 } | 30 } |
| 30 | 31 |
| 31 class ChromeCanvas; | |
| 32 class OSExchangeData; | 32 class OSExchangeData; |
| 33 class ViewAccessibilityWrapper; | 33 class ViewAccessibilityWrapper; |
| 34 class ThemeProvider; | 34 class ThemeProvider; |
| 35 | 35 |
| 36 namespace views { | 36 namespace views { |
| 37 | 37 |
| 38 class Background; | 38 class Background; |
| 39 class Border; | 39 class Border; |
| 40 class FocusManager; | 40 class FocusManager; |
| 41 class FocusTraversable; | 41 class FocusTraversable; |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 // | 281 // |
| 282 // By default, right-to-left UI layout is enabled for the view and therefore | 282 // By default, right-to-left UI layout is enabled for the view and therefore |
| 283 // this function must be called (with false as the |enable| parameter) in | 283 // this function must be called (with false as the |enable| parameter) in |
| 284 // order to disable the right-to-left layout property for a specific instance | 284 // order to disable the right-to-left layout property for a specific instance |
| 285 // of the view. Disabling the right-to-left UI layout is necessary in case a | 285 // of the view. Disabling the right-to-left UI layout is necessary in case a |
| 286 // UI element will not appear correctly when mirrored. | 286 // UI element will not appear correctly when mirrored. |
| 287 void EnableUIMirroringForRTLLanguages(bool enable) { | 287 void EnableUIMirroringForRTLLanguages(bool enable) { |
| 288 ui_mirroring_is_enabled_for_rtl_languages_ = enable; | 288 ui_mirroring_is_enabled_for_rtl_languages_ = enable; |
| 289 } | 289 } |
| 290 | 290 |
| 291 // This method determines whether the ChromeCanvas object passed to | 291 // This method determines whether the gfx::Canvas object passed to |
| 292 // View::Paint() needs to be transformed such that anything drawn on the | 292 // View::Paint() needs to be transformed such that anything drawn on the |
| 293 // canvas object during View::Paint() is flipped horizontally. | 293 // canvas object during View::Paint() is flipped horizontally. |
| 294 // | 294 // |
| 295 // By default, this function returns false (which is the initial value of | 295 // By default, this function returns false (which is the initial value of |
| 296 // |flip_canvas_on_paint_for_rtl_ui_|). View subclasses that need to paint on | 296 // |flip_canvas_on_paint_for_rtl_ui_|). View subclasses that need to paint on |
| 297 // a flipped ChromeCanvas when the UI layout is right-to-left need to call | 297 // a flipped gfx::Canvas when the UI layout is right-to-left need to call |
| 298 // EnableCanvasFlippingForRTLUI(). | 298 // EnableCanvasFlippingForRTLUI(). |
| 299 bool FlipCanvasOnPaintForRTLUI() const { | 299 bool FlipCanvasOnPaintForRTLUI() const { |
| 300 return flip_canvas_on_paint_for_rtl_ui_ ? UILayoutIsRightToLeft() : false; | 300 return flip_canvas_on_paint_for_rtl_ui_ ? UILayoutIsRightToLeft() : false; |
| 301 } | 301 } |
| 302 | 302 |
| 303 // Enables or disables flipping of the ChromeCanvas during View::Paint(). | 303 // Enables or disables flipping of the gfx::Canvas during View::Paint(). |
| 304 // Note that if canvas flipping is enabled, the canvas will be flipped only | 304 // Note that if canvas flipping is enabled, the canvas will be flipped only |
| 305 // if the UI layout is right-to-left; that is, the canvas will be flipped | 305 // if the UI layout is right-to-left; that is, the canvas will be flipped |
| 306 // only if UILayoutIsRightToLeft() returns true. | 306 // only if UILayoutIsRightToLeft() returns true. |
| 307 // | 307 // |
| 308 // Enabling canvas flipping is useful for leaf views that draw a bitmap that | 308 // Enabling canvas flipping is useful for leaf views that draw a bitmap that |
| 309 // needs to be flipped horizontally when the UI layout is right-to-left | 309 // needs to be flipped horizontally when the UI layout is right-to-left |
| 310 // (views::Button, for example). This method is helpful for such classes | 310 // (views::Button, for example). This method is helpful for such classes |
| 311 // because their drawing logic stays the same and they can become agnostic to | 311 // because their drawing logic stays the same and they can become agnostic to |
| 312 // the UI directionality. | 312 // the UI directionality. |
| 313 void EnableCanvasFlippingForRTLUI(bool enable) { | 313 void EnableCanvasFlippingForRTLUI(bool enable) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 // soon as possible. | 361 // soon as possible. |
| 362 virtual void SchedulePaint(int x, int y, int w, int h); | 362 virtual void SchedulePaint(int x, int y, int w, int h); |
| 363 | 363 |
| 364 // Paint the receiving view. g is prepared such as it is in | 364 // Paint the receiving view. g is prepared such as it is in |
| 365 // receiver's coordinate system. g's state is restored after this | 365 // receiver's coordinate system. g's state is restored after this |
| 366 // call so your implementation can change the graphics configuration | 366 // call so your implementation can change the graphics configuration |
| 367 // | 367 // |
| 368 // Default implementation paints the background if it is defined | 368 // Default implementation paints the background if it is defined |
| 369 // | 369 // |
| 370 // Override this method when implementing a new control. | 370 // Override this method when implementing a new control. |
| 371 virtual void Paint(ChromeCanvas* canvas); | 371 virtual void Paint(gfx::Canvas* canvas); |
| 372 | 372 |
| 373 // Paint the background if any. This method is called by Paint() and | 373 // Paint the background if any. This method is called by Paint() and |
| 374 // should rarely be invoked directly. | 374 // should rarely be invoked directly. |
| 375 virtual void PaintBackground(ChromeCanvas* canvas); | 375 virtual void PaintBackground(gfx::Canvas* canvas); |
| 376 | 376 |
| 377 // Paint the border if any. This method is called by Paint() and | 377 // Paint the border if any. This method is called by Paint() and |
| 378 // should rarely be invoked directly. | 378 // should rarely be invoked directly. |
| 379 virtual void PaintBorder(ChromeCanvas* canvas); | 379 virtual void PaintBorder(gfx::Canvas* canvas); |
| 380 | 380 |
| 381 // Paints the focus border (only if the view has the focus). | 381 // Paints the focus border (only if the view has the focus). |
| 382 // This method is called by Paint() and should rarely be invoked directly. | 382 // This method is called by Paint() and should rarely be invoked directly. |
| 383 // The default implementation paints a gray border around the view. Override | 383 // The default implementation paints a gray border around the view. Override |
| 384 // it for custom focus effects. | 384 // it for custom focus effects. |
| 385 virtual void PaintFocusBorder(ChromeCanvas* canvas); | 385 virtual void PaintFocusBorder(gfx::Canvas* canvas); |
| 386 | 386 |
| 387 // Paint this View immediately. | 387 // Paint this View immediately. |
| 388 virtual void PaintNow(); | 388 virtual void PaintNow(); |
| 389 | 389 |
| 390 // Tree functions | 390 // Tree functions |
| 391 | 391 |
| 392 // Add a child View. | 392 // Add a child View. |
| 393 void AddChildView(View* v); | 393 void AddChildView(View* v); |
| 394 | 394 |
| 395 // Adds a child View at the specified position. | 395 // Adds a child View at the specified position. |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 // Returns true if the mouse was dragged enough to start a drag operation. | 779 // Returns true if the mouse was dragged enough to start a drag operation. |
| 780 // delta_x and y are the distance the mouse was dragged. | 780 // delta_x and y are the distance the mouse was dragged. |
| 781 static bool ExceededDragThreshold(int delta_x, int delta_y); | 781 static bool ExceededDragThreshold(int delta_x, int delta_y); |
| 782 | 782 |
| 783 // This method is the main entry point to process paint for this | 783 // This method is the main entry point to process paint for this |
| 784 // view and its children. This method is called by the painting | 784 // view and its children. This method is called by the painting |
| 785 // system. You should call this only if you want to draw a sub tree | 785 // system. You should call this only if you want to draw a sub tree |
| 786 // inside a custom graphics. | 786 // inside a custom graphics. |
| 787 // To customize painting override either the Paint or PaintChildren method, | 787 // To customize painting override either the Paint or PaintChildren method, |
| 788 // not this one. | 788 // not this one. |
| 789 virtual void ProcessPaint(ChromeCanvas* canvas); | 789 virtual void ProcessPaint(gfx::Canvas* canvas); |
| 790 | 790 |
| 791 // Paint the View's child Views, in reverse order. | 791 // Paint the View's child Views, in reverse order. |
| 792 virtual void PaintChildren(ChromeCanvas* canvas); | 792 virtual void PaintChildren(gfx::Canvas* canvas); |
| 793 | 793 |
| 794 // Sets the ContextMenuController. Setting this to non-null makes the View | 794 // Sets the ContextMenuController. Setting this to non-null makes the View |
| 795 // process mouse events. | 795 // process mouse events. |
| 796 void SetContextMenuController(ContextMenuController* menu_controller); | 796 void SetContextMenuController(ContextMenuController* menu_controller); |
| 797 ContextMenuController* GetContextMenuController() { | 797 ContextMenuController* GetContextMenuController() { |
| 798 return context_menu_controller_; | 798 return context_menu_controller_; |
| 799 } | 799 } |
| 800 | 800 |
| 801 // Provides default implementation for context menu handling. The default | 801 // Provides default implementation for context menu handling. The default |
| 802 // implementation calls the ShowContextMenu of the current | 802 // implementation calls the ShowContextMenu of the current |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1192 scoped_ptr<ViewAccessibilityWrapper> accessibility_; | 1192 scoped_ptr<ViewAccessibilityWrapper> accessibility_; |
| 1193 #endif | 1193 #endif |
| 1194 | 1194 |
| 1195 DragController* drag_controller_; | 1195 DragController* drag_controller_; |
| 1196 | 1196 |
| 1197 // Indicates whether or not the view is going to be mirrored (that is, use a | 1197 // Indicates whether or not the view is going to be mirrored (that is, use a |
| 1198 // right-to-left UI layout) if the locale's language is a right-to-left | 1198 // right-to-left UI layout) if the locale's language is a right-to-left |
| 1199 // language like Arabic or Hebrew. | 1199 // language like Arabic or Hebrew. |
| 1200 bool ui_mirroring_is_enabled_for_rtl_languages_; | 1200 bool ui_mirroring_is_enabled_for_rtl_languages_; |
| 1201 | 1201 |
| 1202 // Indicates whether or not the ChromeCanvas object passed to View::Paint() | 1202 // Indicates whether or not the gfx::Canvas object passed to View::Paint() |
| 1203 // is going to be flipped horizontally (using the appropriate transform) on | 1203 // is going to be flipped horizontally (using the appropriate transform) on |
| 1204 // right-to-left locales for this View. | 1204 // right-to-left locales for this View. |
| 1205 bool flip_canvas_on_paint_for_rtl_ui_; | 1205 bool flip_canvas_on_paint_for_rtl_ui_; |
| 1206 | 1206 |
| 1207 DISALLOW_COPY_AND_ASSIGN(View); | 1207 DISALLOW_COPY_AND_ASSIGN(View); |
| 1208 }; | 1208 }; |
| 1209 | 1209 |
| 1210 } // namespace views | 1210 } // namespace views |
| 1211 | 1211 |
| 1212 #endif // VIEWS_VIEW_H_ | 1212 #endif // VIEWS_VIEW_H_ |
| OLD | NEW |