| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_WINDOW_GTK_H_ | |
| 6 #define CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_WINDOW_GTK_H_ | |
| 7 | |
| 8 #include "base/memory/weak_ptr.h" | |
| 9 #include "base/message_loop.h" | |
| 10 #include "chrome/browser/ui/gtk/browser_window_gtk.h" | |
| 11 #include "chrome/browser/ui/panels/native_panel.h" | |
| 12 | |
| 13 class Panel; | |
| 14 class PanelBrowserTitlebarGtk; | |
| 15 class PanelDragGtk; | |
| 16 class NativePanelTestingGtk; | |
| 17 | |
| 18 namespace gfx { | |
| 19 class Image; | |
| 20 } | |
| 21 | |
| 22 class PanelBrowserWindowGtk : public BrowserWindowGtk, | |
| 23 public NativePanel { | |
| 24 public: | |
| 25 enum PaintState { | |
| 26 PAINT_AS_ACTIVE, | |
| 27 PAINT_AS_INACTIVE, | |
| 28 PAINT_AS_MINIMIZED, | |
| 29 PAINT_FOR_ATTENTION | |
| 30 }; | |
| 31 | |
| 32 PanelBrowserWindowGtk(Browser* browser, Panel* panel, | |
| 33 const gfx::Rect& bounds); | |
| 34 virtual ~PanelBrowserWindowGtk(); | |
| 35 | |
| 36 // BrowserWindowGtk override | |
| 37 virtual void Init() OVERRIDE; | |
| 38 | |
| 39 // BrowserWindow overrides | |
| 40 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; | |
| 41 | |
| 42 // Overrides BrowserWindowGtk::NotificationObserver::Observe | |
| 43 virtual void Observe(int type, | |
| 44 const content::NotificationSource& source, | |
| 45 const content::NotificationDetails& details) OVERRIDE; | |
| 46 | |
| 47 bool UsingDefaultTheme() const; | |
| 48 | |
| 49 Panel* panel() const { return panel_.get(); } | |
| 50 PaintState paint_state() const { return paint_state_; } | |
| 51 | |
| 52 protected: | |
| 53 // BrowserWindowGtk overrides | |
| 54 virtual BrowserTitlebarBase* CreateBrowserTitlebar() OVERRIDE; | |
| 55 virtual bool GetWindowEdge(int x, int y, GdkWindowEdge* edge) OVERRIDE; | |
| 56 virtual GdkRegion* GetWindowShape(int width, int height) const OVERRIDE; | |
| 57 virtual bool HandleTitleBarLeftMousePress( | |
| 58 GdkEventButton* event) OVERRIDE; | |
| 59 virtual bool HandleWindowEdgeLeftMousePress( | |
| 60 GtkWindow* window, | |
| 61 GdkWindowEdge edge, | |
| 62 GdkEventButton* event) OVERRIDE; | |
| 63 virtual void SaveWindowPosition() OVERRIDE; | |
| 64 virtual void SetGeometryHints() OVERRIDE; | |
| 65 virtual bool UseCustomFrame() const OVERRIDE; | |
| 66 virtual void DrawFrame(GtkWidget* widget, GdkEventExpose* event) OVERRIDE; | |
| 67 virtual void OnSizeChanged(int width, int height) OVERRIDE; | |
| 68 virtual void ActiveWindowChanged(GdkWindow* active_window) OVERRIDE; | |
| 69 | |
| 70 // Overridden from NativePanel: | |
| 71 virtual void ShowPanel() OVERRIDE; | |
| 72 virtual void ShowPanelInactive() OVERRIDE; | |
| 73 virtual gfx::Rect GetPanelBounds() const OVERRIDE; | |
| 74 virtual void SetPanelBounds(const gfx::Rect& bounds) OVERRIDE; | |
| 75 virtual void SetPanelBoundsInstantly(const gfx::Rect& bounds) OVERRIDE; | |
| 76 virtual void ClosePanel() OVERRIDE; | |
| 77 virtual void ActivatePanel() OVERRIDE; | |
| 78 virtual void DeactivatePanel() OVERRIDE; | |
| 79 virtual bool IsPanelActive() const OVERRIDE; | |
| 80 virtual void PreventActivationByOS(bool prevent_activation) OVERRIDE; | |
| 81 virtual gfx::NativeWindow GetNativePanelHandle() OVERRIDE; | |
| 82 virtual void UpdatePanelTitleBar() OVERRIDE; | |
| 83 virtual void UpdatePanelLoadingAnimations(bool should_animate) OVERRIDE; | |
| 84 virtual void ShowTaskManagerForPanel() OVERRIDE; | |
| 85 virtual FindBar* CreatePanelFindBar() OVERRIDE; | |
| 86 virtual void NotifyPanelOnUserChangedTheme() OVERRIDE; | |
| 87 virtual void PanelWebContentsFocused(content::WebContents* contents) OVERRIDE; | |
| 88 virtual void PanelCut() OVERRIDE; | |
| 89 virtual void PanelCopy() OVERRIDE; | |
| 90 virtual void PanelPaste() OVERRIDE; | |
| 91 virtual void DrawAttention(bool draw_attention) OVERRIDE; | |
| 92 virtual bool IsDrawingAttention() const OVERRIDE; | |
| 93 virtual bool PreHandlePanelKeyboardEvent( | |
| 94 const content::NativeWebKeyboardEvent& event, | |
| 95 bool* is_keyboard_shortcut) OVERRIDE; | |
| 96 virtual void HandlePanelKeyboardEvent( | |
| 97 const content::NativeWebKeyboardEvent& event) OVERRIDE; | |
| 98 virtual void FullScreenModeChanged(bool is_full_screen) OVERRIDE; | |
| 99 virtual Browser* GetPanelBrowser() const OVERRIDE; | |
| 100 virtual void DestroyPanelBrowser() OVERRIDE; | |
| 101 virtual gfx::Size WindowSizeFromContentSize( | |
| 102 const gfx::Size& content_size) const OVERRIDE; | |
| 103 virtual gfx::Size ContentSizeFromWindowSize( | |
| 104 const gfx::Size& window_size) const OVERRIDE; | |
| 105 virtual int TitleOnlyHeight() const OVERRIDE; | |
| 106 virtual void EnsurePanelFullyVisible() OVERRIDE; | |
| 107 virtual void SetPanelAlwaysOnTop(bool on_top) OVERRIDE; | |
| 108 virtual void EnableResizeByMouse(bool enable) OVERRIDE; | |
| 109 virtual void UpdatePanelMinimizeRestoreButtonVisibility() OVERRIDE; | |
| 110 virtual void PanelExpansionStateChanging( | |
| 111 Panel::ExpansionState old_state, | |
| 112 Panel::ExpansionState new_state) OVERRIDE; | |
| 113 virtual NativePanelTesting* CreateNativePanelTesting() OVERRIDE; | |
| 114 | |
| 115 private: | |
| 116 friend class NativePanelTestingGtk; | |
| 117 | |
| 118 // Creates helper for handling drags if not already created. | |
| 119 void EnsureDragHelperCreated(); | |
| 120 | |
| 121 void SetBoundsInternal(const gfx::Rect& bounds); | |
| 122 | |
| 123 PanelBrowserTitlebarGtk* GetPanelTitlebar() const; | |
| 124 | |
| 125 // Returns the image to paint the frame. | |
| 126 const gfx::Image* GetFrameBackground() const; | |
| 127 const gfx::Image* GetDefaultFrameBackground() const; | |
| 128 const gfx::Image* GetThemedFrameBackground() const; | |
| 129 | |
| 130 CHROMEGTK_CALLBACK_1(PanelBrowserWindowGtk, gboolean, | |
| 131 OnTitlebarButtonReleaseEvent, GdkEventButton*); | |
| 132 | |
| 133 scoped_ptr<Panel> panel_; | |
| 134 gfx::Rect bounds_; | |
| 135 | |
| 136 scoped_ptr<PanelDragGtk> drag_helper_; | |
| 137 | |
| 138 // Size of window frame. Empty until the window has been allocated and sized. | |
| 139 gfx::Size frame_size_; | |
| 140 | |
| 141 // Indicates different painting state, active, drawing attention or else. | |
| 142 PaintState paint_state_; | |
| 143 | |
| 144 // Indicates that the panel is currently drawing attention. | |
| 145 bool is_drawing_attention_; | |
| 146 | |
| 147 content::NotificationRegistrar registrar_; | |
| 148 | |
| 149 DISALLOW_COPY_AND_ASSIGN(PanelBrowserWindowGtk); | |
| 150 }; | |
| 151 | |
| 152 #endif // CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_WINDOW_GTK_H_ | |
| OLD | NEW |