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.
5 #ifndef CHROME_BROWSER_UI_COCOA_FRAMED_BROWSER_WINDOW_H_
6 #define CHROME_BROWSER_UI_COCOA_FRAMED_BROWSER_WINDOW_H_
8 #import <Cocoa/Cocoa.h>
10 #include "chrome/browser/ui/cocoa/chrome_browser_window.h"
12 // Offsets from the top/left of the window frame to the top of the window
13 // controls (zoom, close, miniaturize) for a window with a tabstrip.
14 const NSInteger kFramedWindowButtonsWithTabStripOffsetFromTop
= 11;
15 const NSInteger kFramedWindowButtonsWithTabStripOffsetFromLeft
= 11;
17 // Offsets from the top/left of the window frame to the top of the window
18 // controls (zoom, close, miniaturize) for a window without a tabstrip.
19 const NSInteger kFramedWindowButtonsWithoutTabStripOffsetFromTop
= 4;
20 const NSInteger kFramedWindowButtonsWithoutTabStripOffsetFromLeft
= 8;
22 // The amount of window background image that is painted at the top of the
23 // window, so that it shows behind the tap strip area.
24 const CGFloat kBrowserFrameViewPaintHeight
= 60.0;
26 // Cocoa class representing a framed browser window.
27 // We need to override NSWindow with our own class since we need access to all
28 // unhandled keyboard events and subclassing NSWindow is the only method to do
29 // this. We also handle our own window controls and custom window frame drawing.
30 @interface FramedBrowserWindow
: ChromeBrowserWindow
{
32 BOOL shouldHideTitle_
;
34 NSButton
* closeButton_
;
35 NSButton
* miniaturizeButton_
;
36 NSButton
* zoomButton_
;
38 CGFloat windowButtonsInterButtonSpacing_
;
41 // Designated initializer.
42 - (id
)initWithContentRect
:(NSRect
)contentRect
43 hasTabStrip
:(BOOL
)hasTabStrip
;
45 // Tells the window to suppress title drawing.
46 - (void)setShouldHideTitle
:(BOOL
)flag
;
48 // Returns the desired spacing between window control views.
49 - (CGFloat
)windowButtonsInterButtonSpacing
;
51 // Calls the superclass's implementation of |-toggleFullScreen:|.
52 - (void)toggleSystemFullScreen
;
54 // Called by CustomFrameView to determine a custom location for the Lion
55 // fullscreen button. Returns NSZeroPoint to use the Lion default.
56 - (NSPoint
)fullScreenButtonOriginAdjustment
;
58 // Draws the window theme into the specified rect. Returns whether a theme was
59 // drawn (whether incognito or full pattern theme; an overlay image doesn't
61 + (BOOL
)drawWindowThemeInDirtyRect
:(NSRect
)dirtyRect
64 forceBlackBackground
:(BOOL
)forceBlackBackground
;
66 // Gets the color to draw title text.
67 - (NSColor
*)titleColor
;
71 @interface
NSWindow (UndocumentedAPI
)
73 // Undocumented Cocoa API to suppress drawing of the window's title.
74 // -setTitle: still works, but the title set only applies to the
75 // miniwindow and menus (and, importantly, Expose). Overridden to
76 // return |shouldHideTitle_|.
77 -(BOOL
)_isTitleHidden
;
81 #endif // CHROME_BROWSER_UI_COCOA_FRAMED_BROWSER_WINDOW_H_