Home | History | Annotate | Download | only in bubble
      1 // Copyright (c) 2011 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 CHROME_BROWSER_UI_VIEWS_BUBBLE_BORDER_WIDGET_WIN_H_
      6 #define CHROME_BROWSER_UI_VIEWS_BUBBLE_BORDER_WIDGET_WIN_H_
      7 #pragma once
      8 
      9 #include "chrome/browser/ui/views/bubble/bubble_border.h"
     10 #include "views/widget/widget_win.h"
     11 
     12 class BorderContents;
     13 
     14 // This is a window that surrounds the info bubble and paints the margin and
     15 // border.  It is a separate window so that it can be a layered window, so that
     16 // we can use >1-bit alpha shadow images on the borders, which look nicer than
     17 // the Windows CS_DROPSHADOW shadows.  The info bubble window itself cannot be a
     18 // layered window because that prevents it from hosting native child controls.
     19 class BorderWidgetWin : public views::WidgetWin {
     20  public:
     21   BorderWidgetWin();
     22   virtual ~BorderWidgetWin() { }
     23 
     24   // Initializes the BrowserWidget making |owner| its owning window.
     25   void Init(BorderContents* border_contents, HWND owner);
     26 
     27   // Given the size of the contained contents (without margins), and the rect
     28   // (in screen coordinates) to point to, sets the border window positions and
     29   // sizes the border window and returns the bounds (in screen coordinates) the
     30   // contents should use. |arrow_location| is prefered arrow location,
     31   // the function tries to preserve the location and direction, in case of RTL
     32   // arrow location is mirrored.
     33   virtual gfx::Rect SizeAndGetBounds(const gfx::Rect& position_relative_to,
     34                                      BubbleBorder::ArrowLocation arrow_location,
     35                                      const gfx::Size& contents_size);
     36 
     37   // Simple accessors.
     38   BorderContents* border_contents() { return border_contents_; }
     39 
     40  protected:
     41   BorderContents* border_contents_;
     42 
     43  private:
     44   // Overridden from WidgetWin:
     45   virtual LRESULT OnMouseActivate(UINT message,
     46                                   WPARAM w_param,
     47                                   LPARAM l_param) OVERRIDE;
     48 
     49   DISALLOW_COPY_AND_ASSIGN(BorderWidgetWin);
     50 };
     51 
     52 #endif  // CHROME_BROWSER_UI_VIEWS_BUBBLE_BORDER_WIDGET_WIN_H_
     53