| 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 WEBKIT_GLUE_WEBMENURUNNER_MAC_H_ | 5 #ifndef WEBKIT_GLUE_WEBMENURUNNER_MAC_H_ |
| 6 #define WEBKIT_GLUE_WEBMENURUNNER_MAC_H_ | 6 #define WEBKIT_GLUE_WEBMENURUNNER_MAC_H_ |
| 7 | 7 |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 // The index of the selected menu item. | 31 // The index of the selected menu item. |
| 32 int index_; | 32 int index_; |
| 33 | 33 |
| 34 // The font size being used for the menu. | 34 // The font size being used for the menu. |
| 35 CGFloat fontSize_; | 35 CGFloat fontSize_; |
| 36 } | 36 } |
| 37 | 37 |
| 38 // Initializes the MenuDelegate with a list of items sent from WebKit. | 38 // Initializes the MenuDelegate with a list of items sent from WebKit. |
| 39 - (id)initWithItems:(const std::vector<WebMenuItem>&)items | 39 - (id)initWithItems:(const std::vector<WebMenuItem>&)items |
| 40 fontSize:(CGFloat)fontSize; | 40 fontSize:(CGFloat)fontSize |
| 41 rightAligned:(BOOL)rightAligned; |
| 41 | 42 |
| 42 // Returns YES if an item was selected from the menu, NO if the menu was | 43 // Returns YES if an item was selected from the menu, NO if the menu was |
| 43 // dismissed. | 44 // dismissed. |
| 44 - (BOOL)menuItemWasChosen; | 45 - (BOOL)menuItemWasChosen; |
| 45 | 46 |
| 46 // Displays and runs a native popup menu. | 47 // Displays and runs a native popup menu. |
| 47 - (void)runMenuInView:(NSView*)view | 48 - (void)runMenuInView:(NSView*)view |
| 48 withBounds:(NSRect)bounds | 49 withBounds:(NSRect)bounds |
| 49 initialIndex:(int)index; | 50 initialIndex:(int)index; |
| 50 | 51 |
| 51 // Returns the index of selected menu item, or its initial value (-1) if no item | 52 // Returns the index of selected menu item, or its initial value (-1) if no item |
| 52 // was selected. | 53 // was selected. |
| 53 - (int)indexOfSelectedItem; | 54 - (int)indexOfSelectedItem; |
| 54 | 55 |
| 55 @end // @interface WebMenuRunner | 56 @end // @interface WebMenuRunner |
| 56 | 57 |
| 57 namespace webkit_glue { | 58 namespace webkit_glue { |
| 58 // Helper function for users of WebMenuRunner, for manufacturing input events to | 59 // Helper function for users of WebMenuRunner, for manufacturing input events to |
| 59 // send to WebKit. If |item_chosen| is YES, we manufacture a mouse click event | 60 // send to WebKit. If |item_chosen| is YES, we manufacture a mouse click event |
| 60 // that corresponds to the menu item that was selected, |selected_index|, based | 61 // that corresponds to the menu item that was selected, |selected_index|, based |
| 61 // on the position of the mouse click. Of |item_chosen| is NO, we create a | 62 // on the position of the mouse click. Of |item_chosen| is NO, we create a |
| 62 // keyboard event that simulates an ESC (menu dismissal) action. The event is | 63 // keyboard event that simulates an ESC (menu dismissal) action. The event is |
| 63 // designed to be sent to WebKit for processing by the PopupMenu class. | 64 // designed to be sent to WebKit for processing by the PopupMenu class. |
| 64 NSEvent* EventWithMenuAction(BOOL item_chosen, int window_num, | 65 NSEvent* EventWithMenuAction(BOOL item_chosen, int window_num, |
| 65 int item_height, int selected_index, | 66 int item_height, int selected_index, |
| 66 NSRect menu_bounds, NSRect view_bounds); | 67 NSRect menu_bounds, NSRect view_bounds); |
| 67 } // namespace webkit_glue | 68 } // namespace webkit_glue |
| 68 | 69 |
| 69 #endif // WEBKIT_GLUE_WEBMENURUNNER_MAC_H_ | 70 #endif // WEBKIT_GLUE_WEBMENURUNNER_MAC_H_ |
| OLD | NEW |