diff options
author | maruel@google.com <maruel@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-15 12:27:03 +0000 |
---|---|---|
committer | maruel@google.com <maruel@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-15 12:27:03 +0000 |
commit | 1eb89e8fbf2d31247f5ceb271d8887a63d4a2bcf (patch) | |
tree | b78be07dbada3ac0f6d2435558e4a6aaba198ffc /chrome/views | |
parent | ea15e98a9353494df754a11fb49f0e4b8c0d4789 (diff) | |
download | chromium_src-1eb89e8fbf2d31247f5ceb271d8887a63d4a2bcf.zip chromium_src-1eb89e8fbf2d31247f5ceb271d8887a63d4a2bcf.tar.gz chromium_src-1eb89e8fbf2d31247f5ceb271d8887a63d4a2bcf.tar.bz2 |
Large patch set (159 files total) to cleanup the includes.
- Slightly reduce the size of the generated .lib files ~3%.
- Reduce the number of implicit and explicit atl and windows includes. hooray!
- Help incremental build by reducing the number of unnecessary included files.
- Split some template class in two, one base class for the common code and the specialization that inherits from the base class.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@937 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/views')
46 files changed, 323 insertions, 193 deletions
diff --git a/chrome/views/SConscript b/chrome/views/SConscript index eb5a380..e627aea 100644 --- a/chrome/views/SConscript +++ b/chrome/views/SConscript @@ -71,6 +71,7 @@ input_files = [ 'client_view.cc', 'combo_box.cc', 'custom_frame_window.cc', + 'dialog_delegate.cc', 'dialog_client_view.cc', 'decision.cc', 'event.cc', @@ -112,6 +113,7 @@ input_files = [ 'view.cc', 'view_storage.cc', 'window.cc', + 'window_delegate.cc', ] env.ChromeStaticLibrary('views', input_files) diff --git a/chrome/views/accelerator.cc b/chrome/views/accelerator.cc index e8152ce..c0ff1dd 100644 --- a/chrome/views/accelerator.cc +++ b/chrome/views/accelerator.cc @@ -27,9 +27,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include <string> -#include <windows.h> - #include "chrome/views/accelerator.h" #include "base/logging.h" diff --git a/chrome/views/accelerator.h b/chrome/views/accelerator.h index 468e0d2..c803b43 100644 --- a/chrome/views/accelerator.h +++ b/chrome/views/accelerator.h @@ -33,8 +33,10 @@ // It also defines the < operator so that it can be used as a key in a std::map. // -#ifndef CHROME_VIEWS_ACCELERATOR_H__ -#define CHROME_VIEWS_ACCELERATOR_H__ +#ifndef CHROME_VIEWS_ACCELERATOR_H_ +#define CHROME_VIEWS_ACCELERATOR_H_ + +#include <string> #include "chrome/views/event.h" @@ -117,4 +119,4 @@ class AcceleratorTarget { }; } -#endif // #ifndef CHROME_VIEWS_ACCELERATOR_H__
\ No newline at end of file +#endif // CHROME_VIEWS_ACCELERATOR_H_ diff --git a/chrome/views/accessibility/accessible_wrapper.h b/chrome/views/accessibility/accessible_wrapper.h index 05a4d6a..81ee3e4 100644 --- a/chrome/views/accessibility/accessible_wrapper.h +++ b/chrome/views/accessibility/accessible_wrapper.h @@ -27,12 +27,11 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifndef CHROME_VIEWS_ACCESSIBILITY_ACCESSIBLE_WRAPPER_H__ -#define CHROME_VIEWS_ACCESSIBILITY_ACCESSIBLE_WRAPPER_H__ +#ifndef CHROME_VIEWS_ACCESSIBILITY_ACCESSIBLE_WRAPPER_H_ +#define CHROME_VIEWS_ACCESSIBILITY_ACCESSIBLE_WRAPPER_H_ #include <atlcomcli.h> #include <oleacc.h> -#include <windows.h> #include "base/basictypes.h" @@ -75,6 +74,7 @@ class AccessibleWrapper { // View needed to initialize IAccessible. ChromeViews::View* view_; - DISALLOW_EVIL_CONSTRUCTORS(AccessibleWrapper); + DISALLOW_COPY_AND_ASSIGN(AccessibleWrapper); }; -#endif // CHROME_VIEWS_ACCESSIBILITY_ACCESSIBLE_WRAPPER_H__ + +#endif // CHROME_VIEWS_ACCESSIBILITY_ACCESSIBLE_WRAPPER_H_ diff --git a/chrome/views/accessibility/autocomplete_accessibility.cc b/chrome/views/accessibility/autocomplete_accessibility.cc index cb88ff6..fc6d710 100644 --- a/chrome/views/accessibility/autocomplete_accessibility.cc +++ b/chrome/views/accessibility/autocomplete_accessibility.cc @@ -31,6 +31,7 @@ #include "base/logging.h" #include "chrome/common/l10n_util.h" +#include "chrome/views/accessibility/accessible_wrapper.h" #include "generated_resources.h" diff --git a/chrome/views/accessibility/view_accessibility.cc b/chrome/views/accessibility/view_accessibility.cc index c435f1e..b1fdb9a 100644 --- a/chrome/views/accessibility/view_accessibility.cc +++ b/chrome/views/accessibility/view_accessibility.cc @@ -32,6 +32,7 @@ #include "base/logging.h" #include "chrome/browser/view_ids.h" #include "chrome/browser/views/location_bar_view.h" +#include "chrome/views/accessibility/accessible_wrapper.h" HRESULT ViewAccessibility::Initialize(ChromeViews::View* view) { if (!view) { diff --git a/chrome/views/base_button.cc b/chrome/views/base_button.cc index 6fc440a..81b97ab 100644 --- a/chrome/views/base_button.cc +++ b/chrome/views/base_button.cc @@ -27,9 +27,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include <atlbase.h> -#include <atlapp.h> - #include "chrome/views/base_button.h" #include "base/base_drag_source.h" @@ -37,6 +34,7 @@ #include "chrome/common/drag_drop_types.h" #include "chrome/common/gfx/chrome_canvas.h" #include "chrome/common/os_exchange_data.h" +#include "chrome/common/throb_animation.h" namespace ChromeViews { @@ -171,7 +169,7 @@ void BaseButton::SetTooltipText(const std::wstring& tooltip) { bool BaseButton::OnMousePressed(const ChromeViews::MouseEvent& e) { if (state_ != BS_DISABLED) { - if (IsTriggerableEvent(e) && HitTest(e.GetLocation())) { + if (IsTriggerableEvent(e) && HitTest(WTL::CPoint(e.GetX(), e.GetY()))) { SetState(BS_PUSHED); } if (IsFocusable()) @@ -182,7 +180,7 @@ bool BaseButton::OnMousePressed(const ChromeViews::MouseEvent& e) { bool BaseButton::OnMouseDragged(const ChromeViews::MouseEvent& e) { if (state_ != BS_DISABLED) { - if (!HitTest(e.GetLocation())) + if (!HitTest(WTL::CPoint(e.GetX(), e.GetY()))) SetState(BS_NORMAL); else if (IsTriggerableEvent(e)) SetState(BS_PUSHED); @@ -200,7 +198,7 @@ void BaseButton::OnMouseReleased(const ChromeViews::MouseEvent& e, } if (state_ != BS_DISABLED) { - if (canceled || !HitTest(e.GetLocation())) { + if (canceled || !HitTest(WTL::CPoint(e.GetX(), e.GetY()))) { SetState(BS_NORMAL); } else { SetState(BS_HOT); @@ -225,7 +223,7 @@ void BaseButton::OnMouseMoved(const ChromeViews::MouseEvent& e) { using namespace ChromeViews; if (state_ != BS_DISABLED) { - if (HitTest(e.GetLocation())) { + if (HitTest(WTL::CPoint(e.GetX(), e.GetY()))) { SetState(BS_HOT); } else { SetState(BS_NORMAL); diff --git a/chrome/views/base_button.h b/chrome/views/base_button.h index 7b655bb..21fc9bf 100644 --- a/chrome/views/base_button.h +++ b/chrome/views/base_button.h @@ -30,14 +30,12 @@ #ifndef CHROME_VIEWS_BASE_BUTTON_H__ #define CHROME_VIEWS_BASE_BUTTON_H__ -#include <windows.h> - -#include "base/logging.h" -#include "chrome/common/throb_animation.h" +#include "chrome/common/animation.h" #include "chrome/views/event.h" #include "chrome/views/view.h" class OSExchangeData; +class ThrobAnimation; namespace ChromeViews { diff --git a/chrome/views/bitmap_scroll_bar.cc b/chrome/views/bitmap_scroll_bar.cc index ac7f5f6..43e3b9d 100644 --- a/chrome/views/bitmap_scroll_bar.cc +++ b/chrome/views/bitmap_scroll_bar.cc @@ -34,6 +34,7 @@ #include "chrome/common/l10n_util.h" #include "chrome/views/menu.h" #include "chrome/views/scroll_view.h" +#include "chrome/views/view_container.h" #include "skia/include/SkBitmap.h" #include "generated_resources.h" diff --git a/chrome/views/button.cc b/chrome/views/button.cc index adc0647..680ace9 100644 --- a/chrome/views/button.cc +++ b/chrome/views/button.cc @@ -35,6 +35,7 @@ #include "base/gfx/image_operations.h" #include "chrome/common/gfx/chrome_canvas.h" #include "chrome/common/l10n_util.h" +#include "chrome/common/throb_animation.h" #include "chrome/views/event.h" #include "chrome/views/view_container.h" #include "chrome/app/chrome_dll_resource.h" diff --git a/chrome/views/button.h b/chrome/views/button.h index 9840ea3..f85201e 100644 --- a/chrome/views/button.h +++ b/chrome/views/button.h @@ -30,8 +30,6 @@ #ifndef CHROME_VIEWS_BUTTON_H_ #define CHROME_VIEWS_BUTTON_H_ -#include <windows.h> - #include "chrome/views/base_button.h" #include "skia/include/SkBitmap.h" diff --git a/chrome/views/button_dropdown.cc b/chrome/views/button_dropdown.cc index dfcd3da..196c170 100644 --- a/chrome/views/button_dropdown.cc +++ b/chrome/views/button_dropdown.cc @@ -65,7 +65,7 @@ ButtonDropDown::~ButtonDropDown() { //////////////////////////////////////////////////////////////////////////////// bool ButtonDropDown::OnMousePressed(const ChromeViews::MouseEvent& e) { - if (IsEnabled() && e.IsLeftMouseButton() && HitTest(e.GetLocation())) { + if (IsEnabled() && e.IsLeftMouseButton() && HitTest(WTL::CPoint(e.GetX(), e.GetY()))) { // Store the y pos of the mouse coordinates so we can use them later to // determine if the user dragged the mouse down (which should pop up the // drag down menu immediately, instead of waiting for the timer) @@ -91,7 +91,7 @@ void ButtonDropDown::OnMouseReleased(const ChromeViews::MouseEvent& e, if (e.IsLeftMouseButton()) show_menu_factory_.RevokeAll(); - if (IsEnabled() && e.IsRightMouseButton() && HitTest(e.GetLocation())) { + if (IsEnabled() && e.IsRightMouseButton() && HitTest(WTL::CPoint(e.GetX(), e.GetY()))) { show_menu_factory_.RevokeAll(); // Make the button look depressed while the menu is open. // NOTE: SetState() schedules a paint, but it won't occur until after the diff --git a/chrome/views/checkbox.cc b/chrome/views/checkbox.cc index 56ac361..f9df22c2 100644 --- a/chrome/views/checkbox.cc +++ b/chrome/views/checkbox.cc @@ -166,10 +166,10 @@ void CheckBox::HighlightButton(bool f) { } bool CheckBox::LabelHitTest(const MouseEvent& event) { - CPoint p(event.GetLocation()); + CPoint p(event.GetX(), event.GetY()); gfx::Rect r; ComputeTextRect(&r); - return r.Contains(event.GetLocation().x, event.GetLocation().y); + return r.Contains(event.GetX(), event.GetY()); } void CheckBox::OnMouseEntered(const MouseEvent& event) { diff --git a/chrome/views/chrome_menu.cc b/chrome/views/chrome_menu.cc index 75736d9..6b74d50 100644 --- a/chrome/views/chrome_menu.cc +++ b/chrome/views/chrome_menu.cc @@ -47,6 +47,7 @@ #include "chrome/common/os_exchange_data.h" #include "chrome/views/border.h" #include "chrome/views/hwnd_view_container.h" +#include "chrome/views/root_view.h" #include "generated_resources.h" // Margins between the top of the item and the label. diff --git a/chrome/views/combo_box.cc b/chrome/views/combo_box.cc index 7aad1cf..3c19ee0 100644 --- a/chrome/views/combo_box.cc +++ b/chrome/views/combo_box.cc @@ -33,6 +33,7 @@ #include "base/gfx/rect.h" #include "chrome/common/gfx/chrome_canvas.h" #include "chrome/common/gfx/chrome_font.h" +#include "chrome/common/l10n_util.h" #include "chrome/common/resource_bundle.h" // Limit how small a combobox can be. diff --git a/chrome/views/controller.h b/chrome/views/controller.h index 9101131..d57b2de 100644 --- a/chrome/views/controller.h +++ b/chrome/views/controller.h @@ -30,6 +30,8 @@ #ifndef CHROME_VIEWS_CONTROLLER_H_ #define CHROME_VIEWS_CONTROLLER_H_ +#include <string> + /////////////////////////////////////////////////////////////////////////////// // // Controller class @@ -41,6 +43,8 @@ /////////////////////////////////////////////////////////////////////////////// class Controller { public: + virtual ~Controller() { } + // Whether or not a command is supported by this controller. virtual bool SupportsCommand(int id) const = 0; diff --git a/chrome/views/custom_frame_window.cc b/chrome/views/custom_frame_window.cc index 2a96cb9..7679e3f 100644 --- a/chrome/views/custom_frame_window.cc +++ b/chrome/views/custom_frame_window.cc @@ -42,6 +42,7 @@ #include "chrome/views/client_view.h" #include "chrome/views/native_button.h" #include "chrome/views/non_client_view.h" +#include "chrome/views/root_view.h" #include "chrome/views/window_delegate.h" #include "generated_resources.h" diff --git a/chrome/views/dialog_delegate.cc b/chrome/views/dialog_delegate.cc new file mode 100644 index 0000000..8aa375d --- /dev/null +++ b/chrome/views/dialog_delegate.cc @@ -0,0 +1,58 @@ +// Copyright 2008, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include "chrome/views/dialog_delegate.h" + +#include "chrome/views/window.h" + +namespace ChromeViews { + +// Overridden from WindowDelegate: +View* DialogDelegate::GetInitiallyFocusedView() const { + // Try to focus the OK then the Cancel button if present. + DialogClientView* dcv = GetDialogClientView(); + if (GetDialogButtons() & DIALOGBUTTON_OK) + return dcv->ok_button(); + if (GetDialogButtons() & DIALOGBUTTON_CANCEL) + return dcv->cancel_button(); + return NULL; +} + +ClientView* DialogDelegate::CreateClientView(Window* window) { + return new DialogClientView(window, GetContentsView()); +} + +DialogClientView* DialogDelegate::GetDialogClientView() const { + ClientView* client_view = window()->client_view(); + DialogClientView* dialog_client_view = client_view->AsDialogClientView(); + DCHECK(dialog_client_view); + return dialog_client_view; +} + +} // namespace ChromeViews diff --git a/chrome/views/dialog_delegate.h b/chrome/views/dialog_delegate.h index 9ca4ade..cf55b36 100644 --- a/chrome/views/dialog_delegate.h +++ b/chrome/views/dialog_delegate.h @@ -27,8 +27,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifndef CHROME_VIEWS_DIALOG_DELEGATE_H__ -#define CHROME_VIEWS_DIALOG_DELEGATE_H__ +#ifndef CHROME_VIEWS_DIALOG_DELEGATE_H_ +#define CHROME_VIEWS_DIALOG_DELEGATE_H_ #include "chrome/views/dialog_client_view.h" #include "chrome/views/window_delegate.h" @@ -122,31 +122,16 @@ class DialogDelegate : public WindowDelegate { virtual bool Accept() { return true; } // Overridden from WindowDelegate: - virtual View* GetInitiallyFocusedView() const { - // Try to focus the OK then the Cancel button if present. - DialogClientView* dcv = GetDialogClientView(); - if (GetDialogButtons() & DIALOGBUTTON_OK) - return dcv->ok_button(); - if (GetDialogButtons() & DIALOGBUTTON_CANCEL) - return dcv->cancel_button(); - return NULL; - } + virtual View* GetInitiallyFocusedView() const; // Overridden from WindowDelegate: - virtual ClientView* CreateClientView(Window* window) { - return new DialogClientView(window, GetContentsView()); - } + virtual ClientView* CreateClientView(Window* window); // A helper for accessing the DialogClientView object contained by this // delegate's Window. - DialogClientView* GetDialogClientView() const { - ClientView* client_view = window()->client_view(); - DialogClientView* dialog_client_view = client_view->AsDialogClientView(); - DCHECK(dialog_client_view); - return dialog_client_view; - } + DialogClientView* GetDialogClientView() const; }; } // namespace ChromeViews -#endif // #ifndef CHROME_VIEWS_DIALOG_DELEGATE_H__ +#endif // #ifndef CHROME_VIEWS_DIALOG_DELEGATE_H_ diff --git a/chrome/views/event.cc b/chrome/views/event.cc index b3d9194..ac8d716 100644 --- a/chrome/views/event.cc +++ b/chrome/views/event.cc @@ -34,6 +34,12 @@ namespace ChromeViews { +Event::Event(EventType type, int flags) + : type_(type), + time_stamp_(GetTickCount()), + flags_(flags) { +} + int Event::GetWindowsFlags() const { // TODO: need support for x1/x2. int result = 0; @@ -109,4 +115,8 @@ int KeyEvent::GetKeyStateFlags() const { return flags; } +bool KeyEvent::IsExtendedKey() const { + return (message_flags_ & KF_EXTENDED) == KF_EXTENDED; } + +} // namespace ChromeViews diff --git a/chrome/views/event.h b/chrome/views/event.h index a9b93bf..00bbdf8 100644 --- a/chrome/views/event.h +++ b/chrome/views/event.h @@ -30,12 +30,6 @@ #ifndef CHROME_VIEWS_EVENT_H__ #define CHROME_VIEWS_EVENT_H__ -// TODO(maruel): Remove these as soon as LocatedEvent::GetLocation() is -// removed. -#include <atlbase.h> -#include <atlapp.h> -#include <atlmisc.h> - #include "base/basictypes.h" #include "base/gfx/point.h" #include "webkit/glue/window_open_disposition.h" @@ -115,18 +109,14 @@ class Event { int GetWindowsFlags() const; // Convert windows flags to ChromeViews::Event flags - static int ConvertWindowsFlags(UINT win_flags); + static int ConvertWindowsFlags(uint32 win_flags); // Convert WebInputEvent::Modifiers flags to ChromeViews::Event flags. // Note that this only deals with keyboard modifiers. static int ConvertWebInputEventFlags(int web_input_event_flags); protected: - Event(EventType type, int flags) - : type_(type), - time_stamp_(GetTickCount()), - flags_(flags) { - } + Event(EventType type, int flags); Event(const Event& model) : type_(model.GetType()), @@ -177,11 +167,6 @@ class LocatedEvent : public Event { return location_; } - // WARNING: DEPRECATED. Returns the location in WTL::CPoint format. - WTL::CPoint GetLocation() const { - return WTL::CPoint(location_.x(), location_.y()); - } - private: gfx::Point location_; }; @@ -271,9 +256,7 @@ class KeyEvent : public Event { return character_; } - bool IsExtendedKey() const { - return (message_flags_ & KF_EXTENDED) == KF_EXTENDED; - } + bool IsExtendedKey() const; int GetRepeatCount() const { return repeat_count_; diff --git a/chrome/views/focus_manager_unittest.cc b/chrome/views/focus_manager_unittest.cc index ce26b04..cb99446 100644 --- a/chrome/views/focus_manager_unittest.cc +++ b/chrome/views/focus_manager_unittest.cc @@ -39,16 +39,15 @@ #include "chrome/views/background.h" #include "chrome/views/border.h" #include "chrome/views/checkbox.h" -#include "chrome/views/focus_manager.h" #include "chrome/views/hwnd_view_container.h" #include "chrome/views/label.h" #include "chrome/views/link.h" #include "chrome/views/native_button.h" #include "chrome/views/radio_button.h" +#include "chrome/views/root_view.h" #include "chrome/views/scroll_view.h" #include "chrome/views/tabbed_pane.h" #include "chrome/views/text_field.h" -#include "chrome/views/view.h" #include "chrome/views/window.h" #include "chrome/views/window_delegate.h" #include "SkColor.h" diff --git a/chrome/views/hwnd_view_container.cc b/chrome/views/hwnd_view_container.cc index cf1a58a..a360919 100644 --- a/chrome/views/hwnd_view_container.cc +++ b/chrome/views/hwnd_view_container.cc @@ -30,15 +30,12 @@ #include "chrome/views/hwnd_view_container.h" #include "base/gfx/native_theme.h" -#include "base/message_loop.h" #include "base/string_util.h" #include "base/win_util.h" #include "chrome/common/gfx/chrome_canvas.h" -#include "chrome/common/notification_service.h" #include "chrome/common/win_util.h" #include "chrome/views/aero_tooltip_manager.h" #include "chrome/views/accessibility/view_accessibility.h" -#include "chrome/views/focus_manager.h" #include "chrome/views/hwnd_notification_source.h" #include "chrome/views/root_view.h" diff --git a/chrome/views/hwnd_view_container.h b/chrome/views/hwnd_view_container.h index 5a13c16..8187d47 100644 --- a/chrome/views/hwnd_view_container.h +++ b/chrome/views/hwnd_view_container.h @@ -27,21 +27,26 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifndef CHROME_VIEWS_HWND_VIEW_CONTAINER_H__ -#define CHROME_VIEWS_HWND_VIEW_CONTAINER_H__ +#ifndef CHROME_VIEWS_HWND_VIEW_CONTAINER_H_ +#define CHROME_VIEWS_HWND_VIEW_CONTAINER_H_ #include <atlbase.h> -#include <atlapp.h> #include <atlcrack.h> #include "base/message_loop.h" #include "chrome/views/focus_manager.h" #include "chrome/views/layout_manager.h" -#include "chrome/views/root_view.h" #include "chrome/views/view_container.h" +class ChromeCanvas; + +namespace gfx { +class Rect; +} + namespace ChromeViews { +class RootView; class TooltipManager; bool SetRootViewForHWND(HWND hwnd, RootView* root_view); @@ -555,6 +560,6 @@ class HWNDViewContainer : public ViewContainer, HWND hwnd_; }; -} +} // namespace ChromeViews -#endif // #ifndef CHROME_VIEWS_HWND_VIEW_CONTAINER_H__ +#endif // #ifndef CHROME_VIEWS_HWND_VIEW_CONTAINER_H_ diff --git a/chrome/views/label.cc b/chrome/views/label.cc index 590294b..4237336 100644 --- a/chrome/views/label.cc +++ b/chrome/views/label.cc @@ -31,10 +31,13 @@ #include <math.h> +#include "base/logging.h" #include "base/string_util.h" #include "chrome/common/gfx/chrome_canvas.h" #include "chrome/common/gfx/chrome_font.h" +#include "chrome/common/gfx/insets.h" #include "chrome/common/gfx/url_elider.h" +#include "chrome/common/l10n_util.h" #include "chrome/common/resource_bundle.h" #include "chrome/views/background.h" #include "chrome/views/view_container.h" diff --git a/chrome/views/link.cc b/chrome/views/link.cc index 3b19aa1..b42ca6e 100644 --- a/chrome/views/link.cc +++ b/chrome/views/link.cc @@ -109,7 +109,7 @@ bool Link::OnMousePressed(const MouseEvent& e) { bool Link::OnMouseDragged(const MouseEvent& e) { SetHighlighted(enabled_ && (e.IsLeftMouseButton() || e.IsMiddleMouseButton()) && - HitTest(e.GetLocation())); + HitTest(WTL::CPoint(e.GetX(), e.GetY()))); return true; } @@ -119,7 +119,7 @@ void Link::OnMouseReleased(const MouseEvent& e, bool canceled) { SetHighlighted(false); if (enabled_ && !canceled && (e.IsLeftMouseButton() || e.IsMiddleMouseButton()) && - HitTest(e.GetLocation())) { + HitTest(WTL::CPoint(e.GetX(), e.GetY()))) { // Focus the link on click. RequestFocus(); diff --git a/chrome/views/menu.cc b/chrome/views/menu.cc index 0b3b72f..81abcf3 100644 --- a/chrome/views/menu.cc +++ b/chrome/views/menu.cc @@ -27,23 +27,22 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include <windows.h> +#include "chrome/views/menu.h" + #include <atlbase.h> #include <atlcrack.h> #include <atlapp.h> #include <atlframe.h> - -#include "chrome/views/menu.h" +#include <atlmisc.h> #include "base/gfx/rect.h" +#include "base/logging.h" #include "chrome/views/accelerator.h" -#include "chrome/views/controller.h" #include "base/string_util.h" #include "chrome/common/gfx/chrome_canvas.h" #include "chrome/common/gfx/chrome_font.h" #include "chrome/common/l10n_util.h" #include "chrome/common/stl_util-inl.h" -#include "chrome/common/win_util.h" const SkBitmap* Menu::Delegate::kEmptyIcon = 0; @@ -64,6 +63,13 @@ static const int kArrowWidth = 10; // Current active MenuHostWindow. If NULL, no menu is active. static MenuHostWindow* active_host_window = NULL; +// The data of menu items needed to display. +struct Menu::ItemData { + std::wstring label; + SkBitmap icon; + bool submenu; +}; + namespace { static int ChromeGetMenuItemID(HMENU hMenu, int pos) { @@ -219,6 +225,16 @@ class MenuHostWindow : public CWindowImpl<MenuHostWindow, CWindow, } // namespace +bool Menu::Delegate::IsRightToLeftUILayout() const { + return l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT; +} + +const SkBitmap& Menu::Delegate::GetEmptyIcon() const { + if (kEmptyIcon == NULL) + kEmptyIcon = new SkBitmap(); + return *kEmptyIcon; +} + Menu::Menu(Delegate* delegate, AnchorPoint anchor, HWND owner) : delegate_(delegate), menu_(CreatePopupMenu()), diff --git a/chrome/views/menu.h b/chrome/views/menu.h index 44a69c2..07f00b1 100644 --- a/chrome/views/menu.h +++ b/chrome/views/menu.h @@ -27,18 +27,17 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifndef CHROME_VIEWS_MENU_H__ -#define CHROME_VIEWS_MENU_H__ +#ifndef CHROME_VIEWS_MENU_H_ +#define CHROME_VIEWS_MENU_H_ + +#include <windows.h> -#include <atlbase.h> -#include <atlapp.h> -#include <atlmisc.h> #include <vector> -#include "base/message_loop.h" -#include "chrome/common/l10n_util.h" +#include "base/basictypes.h" #include "chrome/views/controller.h" -#include "skia/include/SkBitmap.h" + +class SkBitmap; namespace { class MenuHostWindow; @@ -70,6 +69,8 @@ class Menu { ///////////////////////////////////////////////////////////////////////////// class Delegate : public Controller { public: + virtual ~Delegate() { } + // Whether or not an item should be shown as checked. virtual bool IsItemChecked(int id) const { return false; @@ -139,9 +140,7 @@ class Menu { // is a right-to-left menu only if the view's layout is right-to-left // (since the view can use a different layout than the locale's language // layout). - virtual bool IsRightToLeftUILayout() const { - return l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT; - } + virtual bool IsRightToLeftUILayout() const; // Controller virtual bool SupportsCommand(int id) const { @@ -159,11 +158,7 @@ class Menu { protected: // Returns an empty icon. Will initialize kEmptyIcon if it hasn't been // initialized. - const SkBitmap& GetEmptyIcon() const { - if (kEmptyIcon == NULL) - kEmptyIcon = new SkBitmap(); - return *kEmptyIcon; - } + const SkBitmap& GetEmptyIcon() const; private: // Will be initialized to an icon of 0 width and 0 height when first using. @@ -200,7 +195,7 @@ class Menu { // actions to. Controller* controller_; - DISALLOW_EVIL_CONSTRUCTORS(BaseControllerDelegate); + DISALLOW_COPY_AND_ASSIGN(BaseControllerDelegate); }; // How this popup should align itself relative to the point it is run at. @@ -217,13 +212,6 @@ class Menu { SEPARATOR }; - // The data of menu items needed to display. - struct ItemData { - std::wstring label; - SkBitmap icon; - bool submenu; - }; - // Construct a Menu using the specified controller to determine command // state. // delegate A Menu::Delegate implementation that provides more @@ -324,6 +312,9 @@ class Menu { Delegate* delegate_; private: + // The data of menu items needed to display. + struct ItemData; + explicit Menu(Menu* parent); void AddMenuItemInternal(int index, @@ -378,7 +369,7 @@ class Menu { // Whether the menu is visible. bool is_menu_visible_; - DISALLOW_EVIL_CONSTRUCTORS(Menu); + DISALLOW_COPY_AND_ASSIGN(Menu); }; -#endif // CHROME_VIEWS_MENU_H__ +#endif // CHROME_VIEWS_MENU_H_ diff --git a/chrome/views/menu_button.cc b/chrome/views/menu_button.cc index 452fbac..82fdb5c 100644 --- a/chrome/views/menu_button.cc +++ b/chrome/views/menu_button.cc @@ -33,6 +33,7 @@ #include "chrome/views/menu_button.h" #include "chrome/app/theme/theme_resources.h" +#include "chrome/common/drag_drop_types.h" #include "chrome/common/gfx/chrome_canvas.h" #include "chrome/common/l10n_util.h" #include "chrome/common/resource_bundle.h" @@ -206,7 +207,7 @@ bool MenuButton::OnMousePressed(const ChromeViews::MouseEvent& e) { if (GetState() != BS_DISABLED) { // If we're draggable (GetDragOperations returns a non-zero value), then // don't pop on press, instead wait for release. - if (e.IsOnlyLeftMouseButton() && HitTest(e.GetLocation()) && + if (e.IsOnlyLeftMouseButton() && HitTest(WTL::CPoint(e.GetX(), e.GetY())) && GetDragOperations(e.GetX(), e.GetY()) == DragDropTypes::DRAG_NONE) { TimeDelta delta = Time::Now() - menu_closed_time_; int64 delta_in_milliseconds = delta.InMilliseconds(); @@ -222,7 +223,7 @@ void MenuButton::OnMouseReleased(const ChromeViews::MouseEvent& e, bool canceled) { if (GetDragOperations(e.GetX(), e.GetY()) != DragDropTypes::DRAG_NONE && GetState() != BS_DISABLED && !canceled && !InDrag() && - e.IsOnlyLeftMouseButton() && HitTest(e.GetLocation())) { + e.IsOnlyLeftMouseButton() && HitTest(WTL::CPoint(e.GetX(), e.GetY()))) { Activate(); } else { TextButton::OnMouseReleased(e, canceled); diff --git a/chrome/views/native_button.cc b/chrome/views/native_button.cc index 97b66e1..fa9e0c6 100644 --- a/chrome/views/native_button.cc +++ b/chrome/views/native_button.cc @@ -29,6 +29,7 @@ #include "chrome/views/native_button.h" +#include "base/logging.h" #include "chrome/common/l10n_util.h" #include "chrome/common/resource_bundle.h" #include "chrome/views/background.h" diff --git a/chrome/views/native_control.cc b/chrome/views/native_control.cc index d9ef5a9..f16bb74 100644 --- a/chrome/views/native_control.cc +++ b/chrome/views/native_control.cc @@ -35,6 +35,7 @@ #include <atlframe.h> #include "base/win_util.h" +#include "chrome/common/l10n_util.h" #include "chrome/views/border.h" #include "chrome/views/focus_manager.h" #include "chrome/views/view_container.h" diff --git a/chrome/views/painter.cc b/chrome/views/painter.cc index a45d179..dcc69675 100644 --- a/chrome/views/painter.cc +++ b/chrome/views/painter.cc @@ -29,6 +29,7 @@ #include "chrome/views/painter.h" +#include "base/logging.h" #include "chrome/app/theme/theme_resources.h" #include "chrome/common/gfx/chrome_canvas.h" #include "chrome/common/resource_bundle.h" diff --git a/chrome/views/root_view.cc b/chrome/views/root_view.cc index 8145d16..c533ef0 100644 --- a/chrome/views/root_view.cc +++ b/chrome/views/root_view.cc @@ -27,22 +27,18 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include <algorithm> - #include "chrome/views/root_view.h" +#include <algorithm> + #include "base/base_drag_source.h" #include "base/logging.h" #include "base/message_loop.h" -#include "chrome/common/notification_service.h" -#include "chrome/common/os_exchange_data.h" -#include "chrome/views/event.h" -#include "chrome/views/focus_manager.h" +#include "chrome/common/drag_drop_types.h" +#include "chrome/common/gfx/chrome_canvas.h" #include "chrome/views/root_view_drop_target.h" #include "chrome/views/view_container.h" -#include "chrome/common/gfx/chrome_canvas.h" - namespace ChromeViews { ///////////////////////////////////////////////////////////////////////////// @@ -307,7 +303,7 @@ bool RootView::OnMousePressed(const MouseEvent& e) { bool hit_disabled_view = false; // Walk up the tree until we find a view that wants the mouse event. - for (mouse_pressed_handler_ = GetViewForPoint(e.GetLocation()); + for (mouse_pressed_handler_ = GetViewForPoint(WTL::CPoint(e.GetX(), e.GetY())); mouse_pressed_handler_ && (mouse_pressed_handler_ != this); mouse_pressed_handler_ = mouse_pressed_handler_->GetParent()) { if (!mouse_pressed_handler_->IsEnabled()) { @@ -384,7 +380,7 @@ bool RootView::OnMouseDragged(const MouseEvent& e) { SetMouseLocationAndFlags(e); CPoint p; - ConvertPointToMouseHandler(e.GetLocation(), &p); + ConvertPointToMouseHandler(WTL::CPoint(e.GetX(), e.GetY()), &p); MouseEvent mouse_event(e.GetType(), p.x, p.y, e.GetFlags()); if (!mouse_pressed_handler_->ProcessMouseDragged(mouse_event, &drag_info)) { @@ -402,7 +398,7 @@ void RootView::OnMouseReleased(const MouseEvent& e, bool canceled) { if (mouse_pressed_handler_) { CPoint p; - ConvertPointToMouseHandler(e.GetLocation(), &p); + ConvertPointToMouseHandler(WTL::CPoint(e.GetX(), e.GetY()), &p); MouseEvent mouse_released(e.GetType(), p.x, p.y, e.GetFlags()); // We allow the view to delete us from ProcessMouseReleased. As such, // configure state such that we're done first, then call View. @@ -415,10 +411,10 @@ void RootView::OnMouseReleased(const MouseEvent& e, bool canceled) { } void RootView::UpdateCursor(const MouseEvent& e) { - View *v = GetViewForPoint(e.GetLocation()); + View *v = GetViewForPoint(WTL::CPoint(e.GetX(), e.GetY())); if (v && v != this) { - CPoint l(e.GetLocation()); + CPoint l(e.GetX(), e.GetY()); View::ConvertPointToView(this, v, &l); HCURSOR cursor = v->GetCursorForPoint(e.GetType(), l.x, l.y); if (cursor) { @@ -432,7 +428,7 @@ void RootView::UpdateCursor(const MouseEvent& e) { } void RootView::OnMouseMoved(const MouseEvent& e) { - View *v = GetViewForPoint(e.GetLocation()); + View *v = GetViewForPoint(WTL::CPoint(e.GetX(), e.GetY())); // Find the first enabled view. while (v && !v->IsEnabled()) v = v->GetParent(); diff --git a/chrome/views/root_view_drop_target.cc b/chrome/views/root_view_drop_target.cc index bad4e07..496a3561 100644 --- a/chrome/views/root_view_drop_target.cc +++ b/chrome/views/root_view_drop_target.cc @@ -32,6 +32,7 @@ #include "base/logging.h" #include "chrome/common/drag_drop_types.h" #include "chrome/views/root_view.h" +#include "chrome/views/view_container.h" namespace ChromeViews { diff --git a/chrome/views/tabbed_pane.cc b/chrome/views/tabbed_pane.cc index 5d9677a..dbb8b98 100644 --- a/chrome/views/tabbed_pane.cc +++ b/chrome/views/tabbed_pane.cc @@ -32,15 +32,18 @@ #include <vssym32.h> #include "base/gfx/native_theme.h" +#include "base/gfx/skia_utils.h" #include "base/logging.h" #include "chrome/common/gfx/chrome_canvas.h" #include "chrome/common/gfx/chrome_font.h" +#include "chrome/common/l10n_util.h" #include "chrome/common/resource_bundle.h" #include "chrome/common/stl_util-inl.h" +#include "chrome/common/throb_animation.h" #include "chrome/views/background.h" #include "chrome/views/hwnd_view_container.h" +#include "chrome/views/root_view.h" #include "skia/include/SkColor.h" -#include "base/gfx/skia_utils.h" namespace ChromeViews { diff --git a/chrome/views/text_button.cc b/chrome/views/text_button.cc index 19a7eab..c5dae80 100644 --- a/chrome/views/text_button.cc +++ b/chrome/views/text_button.cc @@ -29,12 +29,10 @@ #include "chrome/views/text_button.h" -#include <atlbase.h> -#include <atlapp.h> - #include "chrome/app/theme/theme_resources.h" #include "chrome/common/gfx/chrome_canvas.h" #include "chrome/common/resource_bundle.h" +#include "chrome/common/throb_animation.h" #include "chrome/common/win_util.h" #include "chrome/views/button.h" #include "chrome/views/event.h" diff --git a/chrome/views/text_field.cc b/chrome/views/text_field.cc index 9d2d3e8..2c6efb6 100644 --- a/chrome/views/text_field.cc +++ b/chrome/views/text_field.cc @@ -41,6 +41,7 @@ #include "base/win_util.h" #include "chrome/browser/browser_process.h" #include "chrome/common/clipboard_service.h" +#include "chrome/common/gfx/insets.h" #include "chrome/common/l10n_util.h" #include "chrome/common/logging_chrome.h" #include "chrome/common/win_util.h" diff --git a/chrome/views/tree_view.cc b/chrome/views/tree_view.cc index f4e43e1..2d2c527 100644 --- a/chrome/views/tree_view.cc +++ b/chrome/views/tree_view.cc @@ -35,9 +35,11 @@ #include "chrome/app/theme/theme_resources.h" #include "chrome/common/gfx/chrome_canvas.h" #include "chrome/common/gfx/icon_util.h" +#include "chrome/common/l10n_util.h" #include "chrome/common/resource_bundle.h" #include "chrome/common/stl_util-inl.h" #include "chrome/views/focus_manager.h" +#include "chrome/views/view_container.h" namespace ChromeViews { diff --git a/chrome/views/view.cc b/chrome/views/view.cc index 8df8da5..ad80fee 100644 --- a/chrome/views/view.cc +++ b/chrome/views/view.cc @@ -30,14 +30,19 @@ #include "chrome/views/view.h" #include <algorithm> -#include <sstream> + +#ifndef NDEBUG #include <iostream> +#endif #include "base/logging.h" #include "base/message_loop.h" #include "base/string_util.h" +#include "chrome/common/drag_drop_types.h" #include "chrome/common/gfx/chrome_canvas.h" +#include "chrome/common/l10n_util.h" #include "chrome/common/os_exchange_data.h" +#include "chrome/views/accessibility/accessible_wrapper.h" #include "chrome/views/background.h" #include "chrome/views/border.h" #include "chrome/views/layout_manager.h" @@ -288,6 +293,11 @@ void View::SetLayoutManager(LayoutManager* layout_manager) { } } +bool View::UILayoutIsRightToLeft() const { + return (ui_mirroring_is_enabled_for_rtl_languages_ && + l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT); +} + //////////////////////////////////////////////////////////////////////////////// // // View - Right-to-left UI layout @@ -540,7 +550,7 @@ void View::SetContextMenuController(ContextMenuController* menu_controller) { bool View::ProcessMousePressed(const MouseEvent& e, DragInfo* drag_info) { const bool enabled = enabled_; int drag_operations; - if (enabled && e.IsOnlyLeftMouseButton() && HitTest(e.GetLocation())) + if (enabled && e.IsOnlyLeftMouseButton() && HitTest(WTL::CPoint(e.GetX(), e.GetY()))) drag_operations = GetDragOperations(e.GetX(), e.GetY()); else drag_operations = 0; diff --git a/chrome/views/view.h b/chrome/views/view.h index 066550a..41cb526 100644 --- a/chrome/views/view.h +++ b/chrome/views/view.h @@ -27,26 +27,26 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifndef CHROME_VIEWS_VIEW_H__ -#define CHROME_VIEWS_VIEW_H__ +#ifndef CHROME_VIEWS_VIEW_H_ +#define CHROME_VIEWS_VIEW_H_ +#include <map> +#include <vector> + +// TODO(maruel): Remove these once WTL::CRect and WTL::CPoint are no more used. #include <atlbase.h> #include <atlapp.h> #include <atlmisc.h> -#include <map> -#include <vector> -#include "base/basictypes.h" #include "base/gfx/rect.h" #include "base/scoped_ptr.h" -#include "chrome/common/drag_drop_types.h" -#include "chrome/common/l10n_util.h" -#include "chrome/common/gfx/insets.h" -#include "chrome/views/accessibility/accessible_wrapper.h" #include "chrome/views/accelerator.h" -#include "chrome/views/event.h" -#include "chrome/views/view_container.h" +namespace gfx { +class Insets; +} + +class AccessibleWrapper; class ChromeCanvas; class OSExchangeData; class SkBitmap; @@ -193,7 +193,7 @@ class View : public AcceleratorTarget { // This is the function subclasses should use whenever they need to obtain // the left position of one of their child views (for example, when // implementing View::Layout()). - inline int GetX() const { + int GetX() const { return GetX(IGNORE_MIRRORING_TRANSFORMATION); }; @@ -209,13 +209,13 @@ class View : public AcceleratorTarget { // coordinate of a child View. int GetX(PositionMirroringSettings settings) const; - inline int GetY() const { + int GetY() const { return bounds_.top; }; - inline int GetWidth() const { + int GetWidth() const { return bounds_.Width(); }; - inline int GetHeight() const { + int GetHeight() const { return bounds_.Height(); }; @@ -306,10 +306,7 @@ class View : public AcceleratorTarget { // Indicates whether the UI layout for this view is right-to-left. The view // has an RTL UI layout if RTL hasn't been disabled for the view and if the // locale's language is an RTL language. - bool UILayoutIsRightToLeft() const { - return (ui_mirroring_is_enabled_for_rtl_languages_ && - l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT); - } + bool UILayoutIsRightToLeft() const; // Enables or disables the right-to-left layout for the view. If |enable| is // true, the layout will become right-to-left only if the locale's language @@ -356,7 +353,7 @@ class View : public AcceleratorTarget { // UI mirroring is transparent to most View subclasses and therefore there is // no need to call this routine from anywhere within your subclass // implementation. - inline int View::MirroredX() const; + int View::MirroredX() const; // Given a rectangle specified in this View's coordinate system, the function // computes the 'left' value for the mirrored rectangle within this View. If @@ -1291,7 +1288,7 @@ class View : public AcceleratorTarget { View* previous_focusable_view_; // The list of accelerators. - scoped_ptr<std::vector<Accelerator>> accelerators_; + scoped_ptr<std::vector<Accelerator> > accelerators_; // The task used to restore automatically the focus to the last focused // floating view. @@ -1315,9 +1312,9 @@ class View : public AcceleratorTarget { // right-to-left locales for this View. bool flip_canvas_on_paint_for_rtl_ui_; - DISALLOW_EVIL_CONSTRUCTORS(View); + DISALLOW_COPY_AND_ASSIGN(View); }; -} +} // namespace ChromeViews -#endif // CHROME_VIEWS_VIEW_H__ +#endif // CHROME_VIEWS_VIEW_H_ diff --git a/chrome/views/view_container.h b/chrome/views/view_container.h index daf106c..65269bb 100644 --- a/chrome/views/view_container.h +++ b/chrome/views/view_container.h @@ -27,12 +27,17 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifndef CHROME_VIEWS_VIEW_CONTAINER_H__ -#define CHROME_VIEWS_VIEW_CONTAINER_H__ +#ifndef CHROME_VIEWS_VIEW_CONTAINER_H_ +#define CHROME_VIEWS_VIEW_CONTAINER_H_ -#include <atlbase.h> -#include <atlapp.h> -#include <atlmisc.h> +// TODO(maruel): Remove once HWND is abstracted. +#include <windows.h> + +// TODO(maruel): Remove once gfx::Rect is used instead. +namespace WTL { +class CRect; +} +using WTL::CRect; namespace ChromeViews { @@ -59,6 +64,7 @@ class Accelerator; class ViewContainer { public: + virtual ~ViewContainer() { } // Returns the bounds of this container in the screen coordinate system. // If the receiving view container is a frame which is larger than its @@ -96,11 +102,9 @@ class ViewContainer { // Returns the accelerator given a command id. Returns false if there is // no accelerator associated with a given id, which is a common condition. virtual bool GetAccelerator(int cmd_id, - ChromeViews::Accelerator* accelerator) = 0; + Accelerator* accelerator) = 0; }; +} // namespace ChromeViews - -} - -#endif // CHROME_VIEWS_VIEW_CONTAINER_H__ +#endif // CHROME_VIEWS_VIEW_CONTAINER_H_ diff --git a/chrome/views/view_unittest.cc b/chrome/views/view_unittest.cc index 9ecc585..284b9f5 100644 --- a/chrome/views/view_unittest.cc +++ b/chrome/views/view_unittest.cc @@ -27,15 +27,10 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include <atlbase.h> -#include <atlapp.h> -#include <atlmisc.h> -#include <atlcrack.h> -#include <atlwin.h> - #include "chrome/common/gfx/chrome_canvas.h" #include "chrome/views/background.h" #include "chrome/views/event.h" +#include "chrome/views/root_view.h" #include "chrome/views/view.h" #include "chrome/views/window.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/chrome/views/views.vcproj b/chrome/views/views.vcproj index 4baf1be..ff56556 100644 --- a/chrome/views/views.vcproj +++ b/chrome/views/views.vcproj @@ -286,6 +286,10 @@ > </File> <File + RelativePath=".\dialog_delegate.cc" + > + </File> + <File RelativePath=".\dialog_delegate.h" > </File> @@ -618,6 +622,10 @@ > </File> <File + RelativePath=".\window_delegate.cc" + > + </File> + <File RelativePath=".\window_delegate.h" > </File> diff --git a/chrome/views/window.cc b/chrome/views/window.cc index 72b365d..681a802 100644 --- a/chrome/views/window.cc +++ b/chrome/views/window.cc @@ -29,16 +29,20 @@ #include "chrome/views/window.h" +#include "base/win_util.h" #include "chrome/app/chrome_dll_resource.h" // TODO(beng): some day make this unfortunate dependency not exist. #include "chrome/browser/browser_list.h" +#include "chrome/common/gfx/chrome_font.h" #include "chrome/common/gfx/icon_util.h" #include "chrome/common/l10n_util.h" #include "chrome/common/pref_service.h" #include "chrome/common/resource_bundle.h" #include "chrome/common/win_util.h" +#include "chrome/views/client_view.h" #include "chrome/views/custom_frame_window.h" #include "chrome/views/non_client_view.h" +#include "chrome/views/root_view.h" #include "chrome/views/window_delegate.h" #include "generated_resources.h" diff --git a/chrome/views/window_delegate.cc b/chrome/views/window_delegate.cc new file mode 100644 index 0000000..0613ca4 --- /dev/null +++ b/chrome/views/window_delegate.cc @@ -0,0 +1,54 @@ +// Copyright 2008, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include "chrome/views/window_delegate.h" + +#include "chrome/views/client_view.h" +#include "chrome/views/window.h" +#include "skia/include/SkBitmap.h" + +namespace ChromeViews { + +WindowDelegate::WindowDelegate() { +} + +WindowDelegate::~WindowDelegate() { + window_.release(); +} + +// Returns the icon to be displayed in the window. +SkBitmap WindowDelegate::GetWindowIcon() { + return SkBitmap(); +} + +ClientView* WindowDelegate::CreateClientView(Window* window) { + return new ClientView(window, GetContentsView()); +} + +} // namespace ChromeViews diff --git a/chrome/views/window_delegate.h b/chrome/views/window_delegate.h index 67990a0..1d97b1b 100644 --- a/chrome/views/window_delegate.h +++ b/chrome/views/window_delegate.h @@ -27,22 +27,27 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifndef CHROME_VIEWS_WINDOW_DELEGATE_H__ -#define CHROME_VIEWS_WINDOW_DELEGATE_H__ +#ifndef CHROME_VIEWS_WINDOW_DELEGATE_H_ +#define CHROME_VIEWS_WINDOW_DELEGATE_H_ -#include <atlbase.h> -#include <atlapp.h> -#include <atlmisc.h> #include <string> -#include "chrome/views/client_view.h" -#include "chrome/views/window.h" -#include "skia/include/SkBitmap.h" +#include "base/scoped_ptr.h" + +class SkBitmap; + +// TODO(maruel): Remove once gfx::Rect is used instead. +namespace WTL { +class CRect; +} +using WTL::CRect; namespace ChromeViews { +class ClientView; class DialogDelegate; class View; +class Window; /////////////////////////////////////////////////////////////////////////////// // @@ -55,9 +60,8 @@ class View; /////////////////////////////////////////////////////////////////////////////// class WindowDelegate { public: - virtual ~WindowDelegate() { - window_.release(); - } + WindowDelegate(); + virtual ~WindowDelegate(); virtual DialogDelegate* AsDialogDelegate() { return NULL; } @@ -106,9 +110,7 @@ class WindowDelegate { } // Returns the icon to be displayed in the window. - virtual SkBitmap GetWindowIcon() { - return SkBitmap(); - } + virtual SkBitmap GetWindowIcon(); // Returns true if a window icon should be shown. virtual bool ShouldShowWindowIcon() const { @@ -142,9 +144,7 @@ class WindowDelegate { // Called by the Window to create the Client View used to host the contents // of the window. - virtual ClientView* CreateClientView(Window* window) { - return new ClientView(window, GetContentsView()); - } + virtual ClientView* CreateClientView(Window* window); // An accessor to the Window this delegate is bound to. Window* window() const { return window_.get(); } @@ -161,4 +161,4 @@ class WindowDelegate { } // namespace ChromeViews -#endif // #ifndef CHROME_VIEWS_WINDOW_DELEGATE_H__ +#endif // CHROME_VIEWS_WINDOW_DELEGATE_H_ |