minimize_button_metrics_win.h revision 5821806d5e7f356e8fa4b058a389a808ea183019
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 CHROME_BROWSER_UI_VIEWS_FRAME_MINIMIZE_BUTTON_METRICS_WIN_H_
6#define CHROME_BROWSER_UI_VIEWS_FRAME_MINIMIZE_BUTTON_METRICS_WIN_H_
7
8#include <windows.h>
9
10#include "base/basictypes.h"
11
12// Class that implements obtaining the X coordinate of the native minimize
13// button for the native frame on Windows.
14// This is a separate class because obtaining it is somewhat tricky and this
15// code is shared between BrowserDesktopRootWindowHostWin and BrowserFrameWin.
16class MinimizeButtonMetrics {
17 public:
18  MinimizeButtonMetrics();
19  ~MinimizeButtonMetrics();
20
21  void Init(HWND hwnd);
22
23  // Obtain the X offset of the native minimize button. Since Windows can lie
24  // to us if we call this at the wrong moment, this might come from a cached
25  // value rather than read when called.
26  int GetMinimizeButtonOffsetX() const;
27
28  // Must be called when hwnd_ is activated to update the minimize button
29  // position cache.
30  void OnHWNDActivated();
31
32 private:
33  HWND hwnd_;
34  int cached_minimize_button_x_delta_;
35
36  DISALLOW_COPY_AND_ASSIGN(MinimizeButtonMetrics);
37};
38
39#endif  // CHROME_BROWSER_UI_VIEWS_FRAME_MINIMIZE_BUTTON_METRICS_WIN_H_
40