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

Side by Side Diff: base/window_impl.h

Issue 165022: Factor out window creation into base::WindowImpl. This class will be used in... (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 | « base/base.gyp ('k') | 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')
Property Changes:
Name: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef BASE_WINDOW_IMPL_H_
6 #define BASE_WINDOW_IMPL_H_
7
8 #include <atlbase.h>
9 #include <atlapp.h>
10 #include <atlmisc.h>
11 #include <atlcrack.h>
12
13 #include <string>
14
15 #include "base/gfx/native_widget_types.h"
16 #include "base/gfx/rect.h"
17 #include "base/logging.h"
18
19 namespace base {
20
21 ///////////////////////////////////////////////////////////////////////////////
22 //
23 // WindowImpl
24 // A convenience class that encapsulates the details of creating and
25 // destroying a HWND. This class also hosts the windows procedure used by all
26 // Windows.
27 //
28 ///////////////////////////////////////////////////////////////////////////////
29 class WindowImpl {
30 public:
31 WindowImpl();
32 virtual ~WindowImpl();
33
34 BEGIN_MSG_MAP_EX(WidgetWin)
35 // No messages to handle
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
44 // Retrieves the default window icon to use for windows if none is specified.
45 virtual HICON GetDefaultWindowIcon() const;
46
47 // 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.
49 void set_window_style(DWORD style) { window_style_ = style; }
50 DWORD window_style() const { return window_style_; }
51
52 // Sets the extended window styles. See comment about |set_window_style|.
53 void set_window_ex_style(DWORD style) { window_ex_style_ = style; }
54 DWORD window_ex_style() const { return window_ex_style_; }
55
56 // Sets the class style to use. The default is CS_DBLCLKS.
57 void set_initial_class_style(UINT class_style) {
58 // We dynamically generate the class name, so don't register it globally!
59 DCHECK_EQ((class_style & CS_GLOBALCLASS), 0);
60 class_style_ = class_style;
61 }
62 UINT initial_class_style() { return class_style_; }
63
64 protected:
65 // Call close instead of this to Destroy the window.
66 BOOL DestroyWindow();
67
68 // Handles the WndProc callback for this object.
69 virtual LRESULT OnWndProc(UINT message, WPARAM w_param, LPARAM l_param);
70
71 private:
72 friend class ClassRegistrar;
73
74 // The windows procedure used by all Windows.
75 static LRESULT CALLBACK WndProc(HWND window,
76 UINT message,
77 WPARAM w_param,
78 LPARAM l_param);
79
80 // Gets the window class name to use when creating the corresponding HWND.
81 // If necessary, this registers the window class.
82 std::wstring GetWindowClassName();
83
84 // All classes registered by WidgetWin start with this name.
85 static const wchar_t* const kBaseClassName;
86
87 // Window Styles used when creating the window.
88 DWORD window_style_;
89
90 // Window Extended Styles used when creating the window.
91 DWORD window_ex_style_;
92
93 // Style of the class to use.
94 UINT class_style_;
95
96 // Our hwnd.
97 HWND hwnd_;
98
99 DISALLOW_COPY_AND_ASSIGN(WindowImpl);
100 };
101
102 } // namespace base
103
104 #endif // BASE_WINDOW_IMPL_H_
OLDNEW
« no previous file with comments | « base/base.gyp ('k') | base/window_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698