summaryrefslogtreecommitdiffstats
path: root/app/win/window_impl.h
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-11 20:21:32 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-11 20:21:32 +0000
commit010ea08a647dfdc4c75aaab2fca65128f50f2379 (patch)
tree6cd61817ffebd7d50fa55e5654dd967a3c69617e /app/win/window_impl.h
parentb44dbd15aeb4dbe7a5be36f7f5c55e6cddf0bac9 (diff)
downloadchromium_src-010ea08a647dfdc4c75aaab2fca65128f50f2379.zip
chromium_src-010ea08a647dfdc4c75aaab2fca65128f50f2379.tar.gz
chromium_src-010ea08a647dfdc4c75aaab2fca65128f50f2379.tar.bz2
Move native_widget_types and gtk_native_view_id_manager from base/gfx to
app/gfx in preparation for removing the base_gfx project. This also moves base/window_impl.cc to app/win/window_impl because this file shouldn't be in base. TEST=none BUG=none Review URL: http://codereview.chromium.org/273017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28691 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/win/window_impl.h')
-rw-r--r--app/win/window_impl.h110
1 files changed, 110 insertions, 0 deletions
diff --git a/app/win/window_impl.h b/app/win/window_impl.h
new file mode 100644
index 0000000..fb5d512
--- /dev/null
+++ b/app/win/window_impl.h
@@ -0,0 +1,110 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef APP_WIN_WINDOW_IMPL_H_
+#define APP_WIN_WINDOW_IMPL_H_
+
+#include <atlbase.h>
+#include <atlapp.h>
+#include <atlmisc.h>
+#include <atlcrack.h>
+
+#include <string>
+
+#include "app/gfx/native_widget_types.h"
+#include "base/gfx/rect.h"
+#include "base/logging.h"
+
+namespace app {
+
+// An interface implemented by classes that use message maps.
+// ProcessWindowMessage is implemented by the BEGIN_MESSAGE_MAP_EX macro.
+class MessageMapInterface {
+ public:
+ // Processes one message from the window's message queue.
+ virtual BOOL ProcessWindowMessage(HWND window,
+ UINT message,
+ WPARAM w_param,
+ LPARAM l_param,
+ LRESULT& result,
+ DWORD msg_mad_id = 0) = 0;
+};
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// WindowImpl
+// A convenience class that encapsulates the details of creating and
+// destroying a HWND. This class also hosts the windows procedure used by all
+// Windows.
+//
+///////////////////////////////////////////////////////////////////////////////
+class WindowImpl : public MessageMapInterface {
+ public:
+ WindowImpl();
+ virtual ~WindowImpl();
+
+ // Initializes the Window with a parent and an initial desired size.
+ void Init(HWND parent, const gfx::Rect& bounds);
+
+ // Retrieves the default window icon to use for windows if none is specified.
+ virtual HICON GetDefaultWindowIcon() const;
+
+ // Returns the HWND associated with this Window.
+ HWND hwnd() const { return hwnd_; }
+
+ // Sets the window styles. This is ONLY used when the window is created.
+ // In other words, if you invoke this after invoking Init, nothing happens.
+ void set_window_style(DWORD style) { window_style_ = style; }
+ DWORD window_style() const { return window_style_; }
+
+ // Sets the extended window styles. See comment about |set_window_style|.
+ void set_window_ex_style(DWORD style) { window_ex_style_ = style; }
+ DWORD window_ex_style() const { return window_ex_style_; }
+
+ // Sets the class style to use. The default is CS_DBLCLKS.
+ void set_initial_class_style(UINT class_style) {
+ // We dynamically generate the class name, so don't register it globally!
+ DCHECK_EQ((class_style & CS_GLOBALCLASS), 0);
+ class_style_ = class_style;
+ }
+ UINT initial_class_style() { return class_style_; }
+
+ protected:
+ // Handles the WndProc callback for this object.
+ virtual LRESULT OnWndProc(UINT message, WPARAM w_param, LPARAM l_param);
+
+ private:
+ friend class ClassRegistrar;
+
+ // The window procedure used by all Windows.
+ static LRESULT CALLBACK WndProc(HWND window,
+ UINT message,
+ WPARAM w_param,
+ LPARAM l_param);
+
+ // Gets the window class name to use when creating the corresponding HWND.
+ // If necessary, this registers the window class.
+ std::wstring GetWindowClassName();
+
+ // All classes registered by WidgetWin start with this name.
+ static const wchar_t* const kBaseClassName;
+
+ // Window Styles used when creating the window.
+ DWORD window_style_;
+
+ // Window Extended Styles used when creating the window.
+ DWORD window_ex_style_;
+
+ // Style of the class to use.
+ UINT class_style_;
+
+ // Our hwnd.
+ HWND hwnd_;
+
+ DISALLOW_COPY_AND_ASSIGN(WindowImpl);
+};
+
+} // namespace app
+
+#endif // APP_WIN_WINDOW_IMPL_H_