Home | History | Annotate | Download | only in tray
      1 // Copyright 2013 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 ASH_SYSTEM_TRAY_FIXED_SIZED_SCROLL_VIEW_H_
      6 #define ASH_SYSTEM_TRAY_FIXED_SIZED_SCROLL_VIEW_H_
      7 
      8 #include "base/basictypes.h"
      9 #include "base/compiler_specific.h"
     10 #include "ui/views/controls/scroll_view.h"
     11 
     12 namespace ash {
     13 namespace internal {
     14 
     15 // A custom scroll-view that has a specified dimension.
     16 class FixedSizedScrollView : public views::ScrollView {
     17  public:
     18   FixedSizedScrollView();
     19   virtual ~FixedSizedScrollView();
     20 
     21   void SetContentsView(views::View* view);
     22 
     23   // Change the fixed size of the view. Invalidates the layout (by calling
     24   // PreferredSizeChanged()).
     25   void SetFixedSize(const gfx::Size& size);
     26 
     27   void set_fixed_size(const gfx::Size& size) { fixed_size_ = size; }
     28 
     29   // Overridden from views::View:
     30   virtual gfx::Size GetPreferredSize() OVERRIDE;
     31   virtual void Layout() OVERRIDE;
     32 
     33  protected:
     34   // Overridden from views::View:
     35   virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE;
     36   virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE;
     37 
     38  private:
     39   gfx::Size fixed_size_;
     40 
     41   DISALLOW_COPY_AND_ASSIGN(FixedSizedScrollView);
     42 };
     43 
     44 }  // namespace internal
     45 }  // namespace ash
     46 
     47 #endif  // ASH_SYSTEM_TRAY_FIXED_SIZED_SCROLL_VIEW_H_
     48