• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved.
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
5 // met:
6 //
7 //    * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 //    * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following disclaimer
11 // in the documentation and/or other materials provided with the
12 // distribution.
13 //    * Neither the name of Google Inc. nor the name Chromium Embedded
14 // Framework nor the names of its contributors may be used to endorse
15 // or promote products derived from this software without specific prior
16 // written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // ---------------------------------------------------------------------------
31 //
32 // The contents of this file must follow a specific format in order to
33 // support the CEF translator tool. See the translator.README.txt file in the
34 // tools directory for more information.
35 //
36 
37 #ifndef CEF_INCLUDE_VIEWS_CEF_WINDOW_DELEGATE_H_
38 #define CEF_INCLUDE_VIEWS_CEF_WINDOW_DELEGATE_H_
39 #pragma once
40 
41 #include "include/views/cef_panel_delegate.h"
42 
43 class CefWindow;
44 
45 ///
46 // Implement this interface to handle window events. The methods of this class
47 // will be called on the browser process UI thread unless otherwise indicated.
48 ///
49 /*--cef(source=client)--*/
50 class CefWindowDelegate : public CefPanelDelegate {
51  public:
52   ///
53   // Called when |window| is created.
54   ///
55   /*--cef()--*/
OnWindowCreated(CefRefPtr<CefWindow> window)56   virtual void OnWindowCreated(CefRefPtr<CefWindow> window) {}
57 
58   ///
59   // Called when |window| is destroyed. Release all references to |window| and
60   // do not attempt to execute any methods on |window| after this callback
61   // returns.
62   ///
63   /*--cef()--*/
OnWindowDestroyed(CefRefPtr<CefWindow> window)64   virtual void OnWindowDestroyed(CefRefPtr<CefWindow> window) {}
65 
66   ///
67   // Return the parent for |window| or NULL if the |window| does not have a
68   // parent. Windows with parents will not get a taskbar button. Set |is_menu|
69   // to true if |window| will be displayed as a menu, in which case it will not
70   // be clipped to the parent window bounds. Set |can_activate_menu| to false
71   // if |is_menu| is true and |window| should not be activated (given keyboard
72   // focus) when displayed.
73   ///
74   /*--cef()--*/
GetParentWindow(CefRefPtr<CefWindow> window,bool * is_menu,bool * can_activate_menu)75   virtual CefRefPtr<CefWindow> GetParentWindow(CefRefPtr<CefWindow> window,
76                                                bool* is_menu,
77                                                bool* can_activate_menu) {
78     return nullptr;
79   }
80 
81   ///
82   // Return the initial bounds for |window| in density independent pixel (DIP)
83   // coordinates. If this method returns an empty CefRect then
84   // GetPreferredSize() will be called to retrieve the size, and the window will
85   // be placed on the screen with origin (0,0). This method can be used in
86   // combination with CefView::GetBoundsInScreen() to restore the previous
87   // window bounds.
88   ///
89   /*--cef()--*/
GetInitialBounds(CefRefPtr<CefWindow> window)90   virtual CefRect GetInitialBounds(CefRefPtr<CefWindow> window) {
91     return CefRect();
92   }
93 
94   ///
95   // Return the initial show state for |window|.
96   ///
97   /*--cef(default_retval=CEF_SHOW_STATE_NORMAL)--*/
GetInitialShowState(CefRefPtr<CefWindow> window)98   virtual cef_show_state_t GetInitialShowState(CefRefPtr<CefWindow> window) {
99     return CEF_SHOW_STATE_NORMAL;
100   }
101 
102   ///
103   // Return true if |window| should be created without a frame or title bar. The
104   // window will be resizable if CanResize() returns true. Use
105   // CefWindow::SetDraggableRegions() to specify draggable regions.
106   ///
107   /*--cef()--*/
IsFrameless(CefRefPtr<CefWindow> window)108   virtual bool IsFrameless(CefRefPtr<CefWindow> window) { return false; }
109 
110   ///
111   // Return true if |window| can be resized.
112   ///
113   /*--cef()--*/
CanResize(CefRefPtr<CefWindow> window)114   virtual bool CanResize(CefRefPtr<CefWindow> window) { return true; }
115 
116   ///
117   // Return true if |window| can be maximized.
118   ///
119   /*--cef()--*/
CanMaximize(CefRefPtr<CefWindow> window)120   virtual bool CanMaximize(CefRefPtr<CefWindow> window) { return true; }
121 
122   ///
123   // Return true if |window| can be minimized.
124   ///
125   /*--cef()--*/
CanMinimize(CefRefPtr<CefWindow> window)126   virtual bool CanMinimize(CefRefPtr<CefWindow> window) { return true; }
127 
128   ///
129   // Return true if |window| can be closed. This will be called for user-
130   // initiated window close actions and when CefWindow::Close() is called.
131   ///
132   /*--cef()--*/
CanClose(CefRefPtr<CefWindow> window)133   virtual bool CanClose(CefRefPtr<CefWindow> window) { return true; }
134 
135   ///
136   // Called when a keyboard accelerator registered with
137   // CefWindow::SetAccelerator is triggered. Return true if the accelerator was
138   // handled or false otherwise.
139   ///
140   /*--cef()--*/
OnAccelerator(CefRefPtr<CefWindow> window,int command_id)141   virtual bool OnAccelerator(CefRefPtr<CefWindow> window, int command_id) {
142     return false;
143   }
144 
145   ///
146   // Called after all other controls in the window have had a chance to
147   // handle the event. |event| contains information about the keyboard event.
148   // Return true if the keyboard event was handled or false otherwise.
149   ///
150   /*--cef()--*/
OnKeyEvent(CefRefPtr<CefWindow> window,const CefKeyEvent & event)151   virtual bool OnKeyEvent(CefRefPtr<CefWindow> window,
152                           const CefKeyEvent& event) {
153     return false;
154   }
155 };
156 
157 #endif  // CEF_INCLUDE_VIEWS_CEF_WINDOW_DELEGATE_H_
158