| 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 // A helper class that contains the gtk widgets that make up the titlebar. The | 5 // A helper class that contains the gtk widgets that make up the titlebar. The |
| 6 // titlebar consists of the tabstrip and if the custom chrome frame is turned | 6 // titlebar consists of the tabstrip and if the custom chrome frame is turned |
| 7 // on, it includes the taller titlebar and minimize, restore, maximize, and | 7 // on, it includes the taller titlebar and minimize, restore, maximize, and |
| 8 // close buttons. | 8 // close buttons. |
| 9 | 9 |
| 10 #ifndef CHROME_BROWSER_GTK_BROWSER_TITLEBAR_H_ | 10 #ifndef CHROME_BROWSER_GTK_BROWSER_TITLEBAR_H_ |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 GtkWidget* widget() { | 28 GtkWidget* widget() { |
| 29 return container_; | 29 return container_; |
| 30 } | 30 } |
| 31 | 31 |
| 32 // Update the appearance of the title bar based on whether we're showing a | 32 // Update the appearance of the title bar based on whether we're showing a |
| 33 // custom frame or not. If |use_custom_frame| is true, we show an extra | 33 // custom frame or not. If |use_custom_frame| is true, we show an extra |
| 34 // tall titlebar and the min/max/close buttons. | 34 // tall titlebar and the min/max/close buttons. |
| 35 void UpdateCustomFrame(bool use_custom_frame); | 35 void UpdateCustomFrame(bool use_custom_frame); |
| 36 | 36 |
| 37 // On Windows, right clicking in the titlebar background brings up the system |
| 38 // menu. There's no such thing on linux, so we just show the menu items we |
| 39 // add to the menu. |
| 40 void ShowContextMenu(); |
| 41 |
| 37 private: | 42 private: |
| 38 // Build the titlebar, the space above the tab | 43 // Build the titlebar, the space above the tab |
| 39 // strip, and (maybe) the min, max, close buttons. |container| is the gtk | 44 // strip, and (maybe) the min, max, close buttons. |container| is the gtk |
| 40 // continer that we put the widget into. | 45 // continer that we put the widget into. |
| 41 void Init(); | 46 void Init(); |
| 42 | 47 |
| 43 // Constructs a CustomDraw button given 3 image ids (IDR_), the box to place | 48 // Constructs a CustomDraw button given 3 image ids (IDR_), the box to place |
| 44 // the button into, and a tooltip id (IDS_). | 49 // the button into, and a tooltip id (IDS_). |
| 45 CustomDrawButton* BuildTitlebarButton(int image, int image_pressed, | 50 CustomDrawButton* BuildTitlebarButton(int image, int image_pressed, |
| 46 int image_hot, GtkWidget* box, | 51 int image_hot, GtkWidget* box, |
| 47 int tooltip); | 52 int tooltip); |
| 48 | 53 |
| 49 // Callback for when the titlebar (include the background of the tab strip) | 54 // Callback for when the titlebar (include the background of the tab strip) |
| 50 // needs to be redrawn. | 55 // needs to be redrawn. |
| 51 static gboolean OnExpose(GtkWidget* widget, GdkEventExpose* e, | 56 static gboolean OnExpose(GtkWidget* widget, GdkEventExpose* e, |
| 52 BrowserTitlebar* window); | 57 BrowserTitlebar* window); |
| 53 | 58 |
| 54 // Callback for when the titlebar (include the background of the tab strip) | |
| 55 // needs to be redrawn. | |
| 56 static gboolean OnMouseButtonPress(GtkWidget* widget, GdkEventButton* e, | |
| 57 BrowserTitlebar* window); | |
| 58 | |
| 59 // Callback for changes to window state. This includes | 59 // Callback for changes to window state. This includes |
| 60 // maximizing/restoring/minimizing the window. | 60 // maximizing/restoring/minimizing the window. |
| 61 static gboolean OnWindowStateChanged(GtkWindow* window, | 61 static gboolean OnWindowStateChanged(GtkWindow* window, |
| 62 GdkEventWindowState* event, | 62 GdkEventWindowState* event, |
| 63 BrowserTitlebar* titlebar); | 63 BrowserTitlebar* titlebar); |
| 64 | 64 |
| 65 // Callback for min/max/close buttons. | 65 // Callback for min/max/close buttons. |
| 66 static void OnButtonClicked(GtkWidget* button, BrowserTitlebar* window); | 66 static void OnButtonClicked(GtkWidget* button, BrowserTitlebar* window); |
| 67 | 67 |
| 68 // -- Context Menu ----------------------------------------------------------- | 68 // -- Context Menu ----------------------------------------------------------- |
| 69 | 69 |
| 70 // On Windows, right clicking in the titlebar background brings up the system | |
| 71 // menu. There's no such thing on linux, so we just show the menu items we | |
| 72 // add to the menu. | |
| 73 void ShowContextMenu(); | |
| 74 // MenuGtk::Delegate implementation: | 70 // MenuGtk::Delegate implementation: |
| 75 virtual bool IsCommandEnabled(int command_id) const; | 71 virtual bool IsCommandEnabled(int command_id) const; |
| 76 virtual bool IsItemChecked(int command_id) const; | 72 virtual bool IsItemChecked(int command_id) const; |
| 77 virtual void ExecuteCommand(int command_id); | 73 virtual void ExecuteCommand(int command_id); |
| 78 | 74 |
| 79 // Pointers to the browser window that owns us and it's GtkWindow. | 75 // Pointers to the browser window that owns us and it's GtkWindow. |
| 80 BrowserWindowGtk* browser_window_; | 76 BrowserWindowGtk* browser_window_; |
| 81 GtkWindow* window_; | 77 GtkWindow* window_; |
| 82 | 78 |
| 83 // The container widget the holds the whole titlebar. | 79 // The container widget the holds the whole titlebar. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 97 | 93 |
| 98 // The background of the title bar and tab strip. | 94 // The background of the title bar and tab strip. |
| 99 scoped_ptr<NineBox> titlebar_background_; | 95 scoped_ptr<NineBox> titlebar_background_; |
| 100 scoped_ptr<NineBox> titlebar_background_otr_; | 96 scoped_ptr<NineBox> titlebar_background_otr_; |
| 101 | 97 |
| 102 // The context menu. | 98 // The context menu. |
| 103 scoped_ptr<MenuGtk> context_menu_; | 99 scoped_ptr<MenuGtk> context_menu_; |
| 104 }; | 100 }; |
| 105 | 101 |
| 106 #endif // CHROME_BROWSER_GTK_BROWSER_TITLEBAR_H_ | 102 #endif // CHROME_BROWSER_GTK_BROWSER_TITLEBAR_H_ |
| OLD | NEW |