| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_COCOA_CHROME_BROWSER_WINDOW_H_ | 5 #ifndef CHROME_BROWSER_COCOA_CHROME_BROWSER_WINDOW_H_ |
| 6 #define CHROME_BROWSER_COCOA_CHROME_BROWSER_WINDOW_H_ | 6 #define CHROME_BROWSER_COCOA_CHROME_BROWSER_WINDOW_H_ |
| 7 | 7 |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 | 9 |
| 10 #include "base/scoped_nsobject.h" |
| 11 |
| 12 // Offset from the top of the window frame to the top of the window controls |
| 13 // (zoom, close, miniaturize). |
| 14 const NSInteger kChromeWindowButtonsOffsetFromTop = 7; |
| 15 |
| 16 // Offset from the left of the window frame to the top of the window controls |
| 17 // (zoom, close, miniaturize). |
| 18 const NSInteger kChromeWindowButtonsOffsetFromLeft = 8; |
| 19 |
| 20 // Offset between the window controls (zoom, close, miniaturize). |
| 21 const NSInteger kChromeWindowButtonsInterButtonSpacing = 7; |
| 22 |
| 10 // Cocoa class representing a Chrome browser window. | 23 // Cocoa class representing a Chrome browser window. |
| 11 // We need to override NSWindow with our own class since we need access to all | 24 // We need to override NSWindow with our own class since we need access to all |
| 12 // unhandled keyboard events and subclassing NSWindow is the only method to do | 25 // unhandled keyboard events and subclassing NSWindow is the only method to do |
| 13 // this. | 26 // this. We also handle our own window controls and custom window frame drawing. |
| 14 @interface ChromeBrowserWindow : NSWindow { | 27 @interface ChromeBrowserWindow : NSWindow { |
| 28 @private |
| 15 BOOL shouldHideTitle_; | 29 BOOL shouldHideTitle_; |
| 30 NSButton* closeButton_; |
| 31 NSButton* miniaturizeButton_; |
| 32 NSButton* zoomButton_; |
| 33 BOOL entered_; |
| 34 scoped_nsobject<NSTrackingArea> widgetTrackingArea_; |
| 16 } | 35 } |
| 17 | 36 |
| 18 // See global_keyboard_shortcuts_mac.h for details on the next two functions. | 37 // See global_keyboard_shortcuts_mac.h for details on the next two functions. |
| 19 | 38 |
| 20 // Checks if |event| is a window keyboard shortcut. If so, dispatches it to the | 39 // Checks if |event| is a window keyboard shortcut. If so, dispatches it to the |
| 21 // window controller's |executeCommand:| and returns |YES|. | 40 // window controller's |executeCommand:| and returns |YES|. |
| 22 - (BOOL)handleExtraWindowKeyboardShortcut:(NSEvent*)event; | 41 - (BOOL)handleExtraWindowKeyboardShortcut:(NSEvent*)event; |
| 23 | 42 |
| 24 // Checks if |event| is a browser keyboard shortcut. If so, dispatches it to the | 43 // Checks if |event| is a browser keyboard shortcut. If so, dispatches it to the |
| 25 // window controller's |executeCommand:| and returns |YES|. | 44 // window controller's |executeCommand:| and returns |YES|. |
| 26 - (BOOL)handleExtraBrowserKeyboardShortcut:(NSEvent*)event; | 45 - (BOOL)handleExtraBrowserKeyboardShortcut:(NSEvent*)event; |
| 27 | 46 |
| 28 // Override, so we can handle global keyboard events. | 47 // Override, so we can handle global keyboard events. |
| 29 - (BOOL)performKeyEquivalent:(NSEvent*)theEvent; | 48 - (BOOL)performKeyEquivalent:(NSEvent*)theEvent; |
| 30 | 49 |
| 31 // Tells the window to suppress title drawing. | 50 // Tells the window to suppress title drawing. |
| 32 - (void)setShouldHideTitle:(BOOL)flag; | 51 - (void)setShouldHideTitle:(BOOL)flag; |
| 33 | 52 |
| 53 // Return true if the mouse is currently in our tracking area for our window |
| 54 // widgets. |
| 55 - (BOOL)mouseInGroup:(NSButton*)widget; |
| 56 |
| 57 // Update the tracking areas for our window widgets as appropriate. |
| 58 - (void)updateTrackingAreas; |
| 34 @end | 59 @end |
| 35 | 60 |
| 36 @interface ChromeBrowserWindow (UndocumentedAPI) | 61 @interface ChromeBrowserWindow (UndocumentedAPI) |
| 37 | 62 |
| 38 // Undocumented Cocoa API to suppress drawing of the window's title. | 63 // Undocumented Cocoa API to suppress drawing of the window's title. |
| 39 // -setTitle: still works, but the title set only applies to the | 64 // -setTitle: still works, but the title set only applies to the |
| 40 // miniwindow and menus (and, importantly, Expose). Overridden to | 65 // miniwindow and menus (and, importantly, Expose). Overridden to |
| 41 // return |shouldHideTitle_|. | 66 // return |shouldHideTitle_|. |
| 42 -(BOOL)_isTitleHidden; | 67 -(BOOL)_isTitleHidden; |
| 43 | 68 |
| 44 @end | 69 @end |
| 45 | 70 |
| 46 #endif // CHROME_BROWSER_COCOA_CHROME_BROWSER_WINDOW_H_ | 71 #endif // CHROME_BROWSER_COCOA_CHROME_BROWSER_WINDOW_H_ |
| OLD | NEW |