OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_UI_GTK_BROWSER_WINDOW_GTK_H_ | 5 #ifndef CHROME_BROWSER_UI_GTK_BROWSER_WINDOW_GTK_H_ |
6 #define CHROME_BROWSER_UI_GTK_BROWSER_WINDOW_GTK_H_ | 6 #define CHROME_BROWSER_UI_GTK_BROWSER_WINDOW_GTK_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
10 | 10 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 // An implementation of BrowserWindow for GTK. | 43 // An implementation of BrowserWindow for GTK. |
44 // Cross-platform code will interact with this object when | 44 // Cross-platform code will interact with this object when |
45 // it needs to manipulate the window. | 45 // it needs to manipulate the window. |
46 | 46 |
47 class BrowserWindowGtk : public BrowserWindow, | 47 class BrowserWindowGtk : public BrowserWindow, |
48 public content::NotificationObserver, | 48 public content::NotificationObserver, |
49 public TabStripModelObserver, | 49 public TabStripModelObserver, |
50 public ui::ActiveWindowWatcherXObserver, | 50 public ui::ActiveWindowWatcherXObserver, |
51 public InfoBarContainer::Delegate { | 51 public InfoBarContainer::Delegate { |
52 public: | 52 public: |
53 enum TitleDecoration { | |
54 PANGO_MARKUP, | |
55 PLAIN_TEXT | |
56 }; | |
57 | |
58 explicit BrowserWindowGtk(Browser* browser); | 53 explicit BrowserWindowGtk(Browser* browser); |
59 virtual ~BrowserWindowGtk(); | 54 virtual ~BrowserWindowGtk(); |
60 | 55 |
61 // Separating initialization from constructor allows invocation of virtual | 56 // Separating initialization from constructor allows invocation of virtual |
62 // functions during initialization. | 57 // functions during initialization. |
63 virtual void Init(); | 58 virtual void Init(); |
64 | 59 |
65 // Allows for a derived class to decorate title text with pango markup. | 60 // Returns whether to draw the content drop shadow on the sides and bottom |
66 // Returns the type of text used for title. | 61 // of the browser window. When false, we still draw a shadow on the top of |
67 virtual TitleDecoration GetWindowTitle(std::string* title) const; | 62 // the toolbar (under the tab strip), but do not round the top corners. |
| 63 virtual bool ShouldDrawContentDropShadow() const; |
68 | 64 |
69 // Overridden from BrowserWindow: | 65 // Overridden from BrowserWindow: |
70 virtual void Show() OVERRIDE; | 66 virtual void Show() OVERRIDE; |
71 virtual void ShowInactive() OVERRIDE; | 67 virtual void ShowInactive() OVERRIDE; |
72 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; | 68 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; |
73 virtual void Close() OVERRIDE; | 69 virtual void Close() OVERRIDE; |
74 virtual void Activate() OVERRIDE; | 70 virtual void Activate() OVERRIDE; |
75 virtual void Deactivate() OVERRIDE; | 71 virtual void Deactivate() OVERRIDE; |
76 virtual bool IsActive() const OVERRIDE; | 72 virtual bool IsActive() const OVERRIDE; |
77 virtual void FlashFrame(bool flash) OVERRIDE; | 73 virtual void FlashFrame(bool flash) OVERRIDE; |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 | 235 |
240 BrowserToolbarGtk* GetToolbar() { return toolbar_.get(); } | 236 BrowserToolbarGtk* GetToolbar() { return toolbar_.get(); } |
241 | 237 |
242 gfx::Rect bounds() const { return bounds_; } | 238 gfx::Rect bounds() const { return bounds_; } |
243 | 239 |
244 // Returns the tab we're currently displaying in the tab contents container. | 240 // Returns the tab we're currently displaying in the tab contents container. |
245 TabContentsWrapper* GetDisplayedTab(); | 241 TabContentsWrapper* GetDisplayedTab(); |
246 | 242 |
247 static void RegisterUserPrefs(PrefService* prefs); | 243 static void RegisterUserPrefs(PrefService* prefs); |
248 | 244 |
249 // Returns whether to draw the content drop shadow on the sides and bottom | |
250 // of the browser window. When false, we still draw a shadow on the top of | |
251 // the toolbar (under the tab strip), but do not round the top corners. | |
252 bool ShouldDrawContentDropShadow(); | |
253 | |
254 // Tells GTK that the toolbar area is invalidated and needs redrawing. We | 245 // Tells GTK that the toolbar area is invalidated and needs redrawing. We |
255 // have this method as a hack because GTK doesn't queue the toolbar area for | 246 // have this method as a hack because GTK doesn't queue the toolbar area for |
256 // redraw when it should. | 247 // redraw when it should. |
257 void QueueToolbarRedraw(); | 248 void QueueToolbarRedraw(); |
258 | 249 |
259 // Get the position where the infobar arrow should be anchored in | 250 // Get the position where the infobar arrow should be anchored in |
260 // |relative_to| coordinates. This is the middle of the omnibox location icon. | 251 // |relative_to| coordinates. This is the middle of the omnibox location icon. |
261 int GetXPositionOfLocationIcon(GtkWidget* relative_to); | 252 int GetXPositionOfLocationIcon(GtkWidget* relative_to); |
262 | 253 |
263 protected: | 254 protected: |
(...skipping 17 matching lines...) Expand all Loading... |
281 GdkEventButton* event); | 272 GdkEventButton* event); |
282 | 273 |
283 // Save the window position in the prefs. | 274 // Save the window position in the prefs. |
284 virtual void SaveWindowPosition(); | 275 virtual void SaveWindowPosition(); |
285 | 276 |
286 // Sets the default size for the window and the way the user is allowed to | 277 // Sets the default size for the window and the way the user is allowed to |
287 // resize it. | 278 // resize it. |
288 virtual void SetGeometryHints(); | 279 virtual void SetGeometryHints(); |
289 | 280 |
290 // Returns |true| if we should use the custom frame. | 281 // Returns |true| if we should use the custom frame. |
291 virtual bool UseCustomFrame(); | 282 virtual bool UseCustomFrame() const; |
| 283 |
| 284 // Whether we should draw the tab background instead of the theme_frame |
| 285 // background because this window is a popup. |
| 286 virtual bool UsingCustomPopupFrame() const; |
292 | 287 |
293 // Called when the window size changed. | 288 // Called when the window size changed. |
294 virtual void OnSizeChanged(int width, int height); | 289 virtual void OnSizeChanged(int width, int height); |
295 | 290 |
296 // Draws the normal custom frame using theme_frame. | 291 // Draws the normal custom frame using theme_frame. |
297 virtual void DrawCustomFrame(cairo_t* cr, GtkWidget* widget, | 292 virtual void DrawCustomFrame(cairo_t* cr, GtkWidget* widget, |
298 GdkEventExpose* event); | 293 GdkEventExpose* event); |
299 | 294 |
300 // Draws the tab image as the frame so we can write legible text. | 295 // Draws the tab image as the frame so we can write legible text. |
301 virtual void DrawPopupFrame(cairo_t* cr, GtkWidget* widget, | 296 virtual void DrawPopupFrame(cairo_t* cr, GtkWidget* widget, |
302 GdkEventExpose* event); | 297 GdkEventExpose* event); |
303 | 298 |
304 // 'focus-in-event' handler. | 299 // 'focus-in-event' handler. |
305 virtual void HandleFocusIn(GtkWidget* widget, GdkEventFocus* event); | 300 virtual void HandleFocusIn(GtkWidget* widget, GdkEventFocus* event); |
306 | 301 |
307 // Returns the size of the window frame around the client content area. | 302 // Returns the size of the window frame around the client content area. |
308 gfx::Size GetNonClientFrameSize() const; | 303 gfx::Size GetNonClientFrameSize() const; |
309 | 304 |
| 305 // Invalidate window to force repaint. |
| 306 void InvalidateWindow(); |
| 307 |
310 // Top level window. | 308 // Top level window. |
311 GtkWindow* window_; | 309 GtkWindow* window_; |
312 // GtkAlignment that holds the interior components of the chromium window. | 310 // GtkAlignment that holds the interior components of the chromium window. |
313 // This is used to draw the custom frame border and content shadow. | 311 // This is used to draw the custom frame border and content shadow. |
314 GtkWidget* window_container_; | 312 GtkWidget* window_container_; |
315 // VBox that holds everything (tabs, toolbar, bookmarks bar, tab contents). | 313 // VBox that holds everything (tabs, toolbar, bookmarks bar, tab contents). |
316 GtkWidget* window_vbox_; | 314 GtkWidget* window_vbox_; |
317 // VBox that holds everything below the toolbar. | 315 // VBox that holds everything below the toolbar. |
318 GtkWidget* render_area_vbox_; | 316 GtkWidget* render_area_vbox_; |
319 // Floating container that holds the render area. It is needed to position | 317 // Floating container that holds the render area. It is needed to position |
(...skipping 25 matching lines...) Expand all Loading... |
345 | 343 |
346 // Connect accelerators that aren't connected to menu items (like ctrl-o, | 344 // Connect accelerators that aren't connected to menu items (like ctrl-o, |
347 // ctrl-l, etc.). | 345 // ctrl-l, etc.). |
348 void ConnectAccelerators(); | 346 void ConnectAccelerators(); |
349 | 347 |
350 // Change whether we're showing the custom blue frame. | 348 // Change whether we're showing the custom blue frame. |
351 // Must be called once at startup. | 349 // Must be called once at startup. |
352 // Triggers relayout of the content. | 350 // Triggers relayout of the content. |
353 void UpdateCustomFrame(); | 351 void UpdateCustomFrame(); |
354 | 352 |
355 // Invalidate window to force repaint. | |
356 void InvalidateWindow(); | |
357 | |
358 // Set the bounds of the current window. If |exterior| is true, set the size | 353 // Set the bounds of the current window. If |exterior| is true, set the size |
359 // of the window itself, otherwise set the bounds of the web contents. | 354 // of the window itself, otherwise set the bounds of the web contents. |
360 // If |move| is true, set the position of the window, otherwise leave the | 355 // If |move| is true, set the position of the window, otherwise leave the |
361 // position to the WM. | 356 // position to the WM. |
362 void SetBoundsImpl(const gfx::Rect& bounds, bool exterior, bool move); | 357 void SetBoundsImpl(const gfx::Rect& bounds, bool exterior, bool move); |
363 | 358 |
364 CHROMEGTK_CALLBACK_1(BrowserWindowGtk, gboolean, OnConfigure, | 359 CHROMEGTK_CALLBACK_1(BrowserWindowGtk, gboolean, OnConfigure, |
365 GdkEventConfigure*); | 360 GdkEventConfigure*); |
366 CHROMEGTK_CALLBACK_1(BrowserWindowGtk, gboolean, OnWindowState, | 361 CHROMEGTK_CALLBACK_1(BrowserWindowGtk, gboolean, OnWindowState, |
367 GdkEventWindowState*); | 362 GdkEventWindowState*); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 | 437 |
443 // Hides UI elements for unsupported window features. | 438 // Hides UI elements for unsupported window features. |
444 void HideUnsupportedWindowFeatures(); | 439 void HideUnsupportedWindowFeatures(); |
445 | 440 |
446 // Helper functions that query |browser_| concerning support for UI features | 441 // Helper functions that query |browser_| concerning support for UI features |
447 // in this window. (For example, a popup window might not support a tabstrip). | 442 // in this window. (For example, a popup window might not support a tabstrip). |
448 bool IsTabStripSupported() const; | 443 bool IsTabStripSupported() const; |
449 bool IsToolbarSupported() const; | 444 bool IsToolbarSupported() const; |
450 bool IsBookmarkBarSupported() const; | 445 bool IsBookmarkBarSupported() const; |
451 | 446 |
452 // Whether we should draw the tab background instead of the theme_frame | |
453 // background because this window is a popup. | |
454 bool UsingCustomPopupFrame() const; | |
455 | |
456 // Returns |true| if the window bounds match the monitor size. | 447 // Returns |true| if the window bounds match the monitor size. |
457 bool BoundsMatchMonitorSize(); | 448 bool BoundsMatchMonitorSize(); |
458 | 449 |
459 // Put the bookmark bar where it belongs. | 450 // Put the bookmark bar where it belongs. |
460 void PlaceBookmarkBar(bool is_floating); | 451 void PlaceBookmarkBar(bool is_floating); |
461 | 452 |
462 // Determine whether we use should default to native decorations or the custom | 453 // Determine whether we use should default to native decorations or the custom |
463 // frame based on the currently-running window manager. | 454 // frame based on the currently-running window manager. |
464 static bool GetCustomFramePrefDefault(); | 455 static bool GetCustomFramePrefDefault(); |
465 | 456 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 scoped_ptr<FullscreenExitBubbleGtk> fullscreen_exit_bubble_; | 554 scoped_ptr<FullscreenExitBubbleGtk> fullscreen_exit_bubble_; |
564 | 555 |
565 FullscreenExitBubbleType fullscreen_exit_bubble_type_; | 556 FullscreenExitBubbleType fullscreen_exit_bubble_type_; |
566 | 557 |
567 content::NotificationRegistrar registrar_; | 558 content::NotificationRegistrar registrar_; |
568 | 559 |
569 DISALLOW_COPY_AND_ASSIGN(BrowserWindowGtk); | 560 DISALLOW_COPY_AND_ASSIGN(BrowserWindowGtk); |
570 }; | 561 }; |
571 | 562 |
572 #endif // CHROME_BROWSER_UI_GTK_BROWSER_WINDOW_GTK_H_ | 563 #endif // CHROME_BROWSER_UI_GTK_BROWSER_WINDOW_GTK_H_ |
OLD | NEW |