framed_browser_window.h revision 21d179b334e59e9a3bfcaed4c4430bef1bc5759d
1// Copyright (c) 2010 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_COCOA_FRAMED_BROWSER_WINDOW_H_
6#define CHROME_BROWSER_UI_COCOA_FRAMED_BROWSER_WINDOW_H_
7#pragma once
8
9#import <Cocoa/Cocoa.h>
10
11#include "base/scoped_nsobject.h"
12#include "chrome/browser/ui/cocoa/chrome_browser_window.h"
13
14// Offset from the top of the window frame to the top of the window controls
15// (zoom, close, miniaturize) for a window with a tabstrip.
16const NSInteger kFramedWindowButtonsWithTabStripOffsetFromTop = 6;
17
18// Offset from the top of the window frame to the top of the window controls
19// (zoom, close, miniaturize) for a window without a tabstrip.
20const NSInteger kFramedWindowButtonsWithoutTabStripOffsetFromTop = 4;
21
22// Offset from the left of the window frame to the top of the window controls
23// (zoom, close, miniaturize).
24const NSInteger kFramedWindowButtonsOffsetFromLeft = 8;
25
26// Offset between the window controls (zoom, close, miniaturize).
27const NSInteger kFramedWindowButtonsInterButtonSpacing = 7;
28
29// Cocoa class representing a framed browser window.
30// We need to override NSWindow with our own class since we need access to all
31// unhandled keyboard events and subclassing NSWindow is the only method to do
32// this. We also handle our own window controls and custom window frame drawing.
33@interface FramedBrowserWindow : ChromeBrowserWindow {
34 @private
35  BOOL shouldHideTitle_;
36  NSButton* closeButton_;
37  NSButton* miniaturizeButton_;
38  NSButton* zoomButton_;
39  BOOL entered_;
40  scoped_nsobject<NSTrackingArea> widgetTrackingArea_;
41}
42
43// Tells the window to suppress title drawing.
44- (void)setShouldHideTitle:(BOOL)flag;
45
46// Return true if the mouse is currently in our tracking area for our window
47// widgets.
48- (BOOL)mouseInGroup:(NSButton*)widget;
49
50// Update the tracking areas for our window widgets as appropriate.
51- (void)updateTrackingAreas;
52
53@end
54
55@interface NSWindow (UndocumentedAPI)
56
57// Undocumented Cocoa API to suppress drawing of the window's title.
58// -setTitle: still works, but the title set only applies to the
59// miniwindow and menus (and, importantly, Expose).  Overridden to
60// return |shouldHideTitle_|.
61-(BOOL)_isTitleHidden;
62
63@end
64
65#endif  // CHROME_BROWSER_UI_COCOA_FRAMED_BROWSER_WINDOW_H_
66