Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(411)

Side by Side Diff: base/window_impl.h

Issue 165543: Revert "Reverting 23406" as it didn't break any tests.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/window_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 BASE_WINDOW_IMPL_H_ 5 #ifndef BASE_WINDOW_IMPL_H_
6 #define BASE_WINDOW_IMPL_H_ 6 #define BASE_WINDOW_IMPL_H_
7 7
8 #include <atlbase.h> 8 #include <atlbase.h>
9 #include <atlapp.h> 9 #include <atlapp.h>
10 #include <atlmisc.h> 10 #include <atlmisc.h>
11 #include <atlcrack.h> 11 #include <atlcrack.h>
12 12
13 #include <string> 13 #include <string>
14 14
15 #include "base/gfx/native_widget_types.h" 15 #include "base/gfx/native_widget_types.h"
16 #include "base/gfx/rect.h" 16 #include "base/gfx/rect.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 18
19 namespace base { 19 namespace base {
20 20
21 // An interface implemented by classes that use message maps.
22 // ProcessWindowMessage is implemented by the BEGIN_MESSAGE_MAP_EX macro.
23 class MessageMapInterface {
24 public:
25 // Processes one message from the window's message queue.
26 virtual BOOL ProcessWindowMessage(HWND window,
27 UINT message,
28 WPARAM w_param,
29 LPARAM l_param,
30 LRESULT& result,
31 DWORD msg_mad_id = 0) = 0;
32 };
33
21 /////////////////////////////////////////////////////////////////////////////// 34 ///////////////////////////////////////////////////////////////////////////////
22 // 35 //
23 // WindowImpl 36 // WindowImpl
24 // A convenience class that encapsulates the details of creating and 37 // A convenience class that encapsulates the details of creating and
25 // destroying a HWND. This class also hosts the windows procedure used by all 38 // destroying a HWND. This class also hosts the windows procedure used by all
26 // Windows. 39 // Windows.
27 // 40 //
28 /////////////////////////////////////////////////////////////////////////////// 41 ///////////////////////////////////////////////////////////////////////////////
29 class WindowImpl { 42 class WindowImpl : public MessageMapInterface {
30 public: 43 public:
31 WindowImpl(); 44 WindowImpl();
32 virtual ~WindowImpl(); 45 virtual ~WindowImpl();
33 46
34 BEGIN_MSG_MAP_EX(WindowImpl) 47 // Initializes the Window with a parent and an initial desired size.
35 // No messages to handle 48 void Init(HWND parent, const gfx::Rect& bounds);
36 END_MSG_MAP()
37
38 // Initialize the Window with a parent and an initial desired size.
39 virtual void Init(HWND parent, const gfx::Rect& bounds);
40
41 // Returns the gfx::NativeView associated with this Window.
42 virtual gfx::NativeView GetNativeView() const;
43 49
44 // Retrieves the default window icon to use for windows if none is specified. 50 // Retrieves the default window icon to use for windows if none is specified.
45 virtual HICON GetDefaultWindowIcon() const; 51 virtual HICON GetDefaultWindowIcon() const;
46 52
53 // Returns the HWND associated with this Window.
54 HWND hwnd() const { return hwnd_; }
55
47 // Sets the window styles. This is ONLY used when the window is created. 56 // Sets the window styles. This is ONLY used when the window is created.
48 // In other words, if you invoke this after invoking Init, nothing happens. 57 // In other words, if you invoke this after invoking Init, nothing happens.
49 void set_window_style(DWORD style) { window_style_ = style; } 58 void set_window_style(DWORD style) { window_style_ = style; }
50 DWORD window_style() const { return window_style_; } 59 DWORD window_style() const { return window_style_; }
51 60
52 // Sets the extended window styles. See comment about |set_window_style|. 61 // Sets the extended window styles. See comment about |set_window_style|.
53 void set_window_ex_style(DWORD style) { window_ex_style_ = style; } 62 void set_window_ex_style(DWORD style) { window_ex_style_ = style; }
54 DWORD window_ex_style() const { return window_ex_style_; } 63 DWORD window_ex_style() const { return window_ex_style_; }
55 64
56 // Sets the class style to use. The default is CS_DBLCLKS. 65 // Sets the class style to use. The default is CS_DBLCLKS.
57 void set_initial_class_style(UINT class_style) { 66 void set_initial_class_style(UINT class_style) {
58 // We dynamically generate the class name, so don't register it globally! 67 // We dynamically generate the class name, so don't register it globally!
59 DCHECK_EQ((class_style & CS_GLOBALCLASS), 0); 68 DCHECK_EQ((class_style & CS_GLOBALCLASS), 0);
60 class_style_ = class_style; 69 class_style_ = class_style;
61 } 70 }
62 UINT initial_class_style() { return class_style_; } 71 UINT initial_class_style() { return class_style_; }
63 72
64 protected: 73 protected:
65 // Call close instead of this to Destroy the window.
66 BOOL DestroyWindow();
67
68 // Handles the WndProc callback for this object. 74 // Handles the WndProc callback for this object.
69 virtual LRESULT OnWndProc(UINT message, WPARAM w_param, LPARAM l_param); 75 virtual LRESULT OnWndProc(UINT message, WPARAM w_param, LPARAM l_param);
70 76
71 private: 77 private:
72 friend class ClassRegistrar; 78 friend class ClassRegistrar;
73 79
74 // The windows procedure used by all Windows. 80 // The window procedure used by all Windows.
75 static LRESULT CALLBACK WndProc(HWND window, 81 static LRESULT CALLBACK WndProc(HWND window,
76 UINT message, 82 UINT message,
77 WPARAM w_param, 83 WPARAM w_param,
78 LPARAM l_param); 84 LPARAM l_param);
79 85
80 // Gets the window class name to use when creating the corresponding HWND. 86 // Gets the window class name to use when creating the corresponding HWND.
81 // If necessary, this registers the window class. 87 // If necessary, this registers the window class.
82 std::wstring GetWindowClassName(); 88 std::wstring GetWindowClassName();
83 89
84 // All classes registered by WidgetWin start with this name. 90 // All classes registered by WidgetWin start with this name.
(...skipping 10 matching lines...) Expand all
95 101
96 // Our hwnd. 102 // Our hwnd.
97 HWND hwnd_; 103 HWND hwnd_;
98 104
99 DISALLOW_COPY_AND_ASSIGN(WindowImpl); 105 DISALLOW_COPY_AND_ASSIGN(WindowImpl);
100 }; 106 };
101 107
102 } // namespace base 108 } // namespace base
103 109
104 #endif // BASE_WINDOW_IMPL_H_ 110 #endif // BASE_WINDOW_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | base/window_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698