Home | History | Annotate | Download | only in aura
      1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef UI_AURA_WINDOW_DELEGATE_H_
      6 #define UI_AURA_WINDOW_DELEGATE_H_
      7 
      8 #include "base/compiler_specific.h"
      9 #include "base/memory/ref_counted.h"
     10 #include "ui/aura/aura_export.h"
     11 #include "ui/base/events/event_constants.h"
     12 #include "ui/base/events/event_handler.h"
     13 #include "ui/gfx/native_widget_types.h"
     14 
     15 namespace gfx {
     16 class Canvas;
     17 class Path;
     18 class Point;
     19 class Rect;
     20 class Size;
     21 }
     22 
     23 namespace ui {
     24 class GestureEvent;
     25 class KeyEvent;
     26 class MouseEvent;
     27 class Texture;
     28 class TouchEvent;
     29 }
     30 
     31 namespace aura {
     32 
     33 // Delegate interface for aura::Window.
     34 class AURA_EXPORT WindowDelegate : public ui::EventHandler {
     35  public:
     36   // Returns the window's minimum size, or size 0,0 if there is no limit.
     37   virtual gfx::Size GetMinimumSize() const = 0;
     38 
     39   // Returns the window's maximum size, or size 0,0 if there is no limit.
     40   virtual gfx::Size GetMaximumSize() const = 0;
     41 
     42   // Called when the Window's position and/or size changes.
     43   virtual void OnBoundsChanged(const gfx::Rect& old_bounds,
     44                                const gfx::Rect& new_bounds) = 0;
     45 
     46   // Returns the native cursor for the specified point, in window coordinates,
     47   // or NULL for the default cursor.
     48   virtual gfx::NativeCursor GetCursor(const gfx::Point& point) = 0;
     49 
     50   // Returns the non-client component (see hit_test.h) containing |point|, in
     51   // window coordinates.
     52   virtual int GetNonClientComponent(const gfx::Point& point) const = 0;
     53 
     54   // Returns true if event handling should descend into |child|. |location| is
     55   // in terms of the Window.
     56   virtual bool ShouldDescendIntoChildForEventHandling(
     57       Window* child,
     58       const gfx::Point& location) = 0;
     59 
     60   // Returns true of the window can be focused.
     61   virtual bool CanFocus() = 0;
     62 
     63   // Invoked when mouse capture is lost on the window.
     64   virtual void OnCaptureLost() = 0;
     65 
     66   // Asks the delegate to paint window contents into the supplied canvas.
     67   virtual void OnPaint(gfx::Canvas* canvas) = 0;
     68 
     69   // Called when the window's device scale factor has changed.
     70   virtual void OnDeviceScaleFactorChanged(float device_scale_factor) = 0;
     71 
     72   // Called from Window's destructor before OnWindowDestroyed and before the
     73   // children have been destroyed and the window has been removed from its
     74   // parent.
     75   virtual void OnWindowDestroying() = 0;
     76 
     77   // Called when the Window has been destroyed (i.e. from its destructor). This
     78   // is called after OnWindowDestroying and after the children have been
     79   // deleted and the window has been removed from its parent.
     80   // The delegate can use this as an opportunity to delete itself if necessary.
     81   virtual void OnWindowDestroyed() = 0;
     82 
     83   // Called when the TargetVisibility() of a Window changes. |visible|
     84   // corresponds to the target visibility of the window. See
     85   // Window::TargetVisibility() for details.
     86   virtual void OnWindowTargetVisibilityChanged(bool visible) = 0;
     87 
     88   // Called from Window::HitTest to check if the window has a custom hit test
     89   // mask. It works similar to the views counterparts. That is, if the function
     90   // returns true, GetHitTestMask below will be called to get the mask.
     91   // Otherwise, Window will hit-test against its bounds.
     92   virtual bool HasHitTestMask() const = 0;
     93 
     94   // Called from Window::HitTest to retrieve hit test mask when HasHitTestMask
     95   // above returns true.
     96   virtual void GetHitTestMask(gfx::Path* mask) const = 0;
     97 
     98   // Called from RecreateLayer() if the layer the window is associated with has
     99   // an external texture.
    100   virtual scoped_refptr<ui::Texture> CopyTexture() = 0;
    101 
    102  protected:
    103   virtual ~WindowDelegate() {}
    104 };
    105 
    106 }  // namespace aura
    107 
    108 #endif  // UI_AURA_WINDOW_DELEGATE_H_
    109