diff options
88 files changed, 721 insertions, 313 deletions
diff --git a/chrome/browser/ui/views/accessible_pane_view.cc b/chrome/browser/ui/views/accessible_pane_view.cc index c6789bc..94782c7 100644 --- a/chrome/browser/ui/views/accessible_pane_view.cc +++ b/chrome/browser/ui/views/accessible_pane_view.cc @@ -87,6 +87,10 @@ bool AccessiblePaneView::SetPaneFocusAndFocusDefault( return SetPaneFocus(view_storage_id, GetDefaultFocusableChild()); } +views::View* AccessiblePaneView::GetDefaultFocusableChild() { + return NULL; +} + void AccessiblePaneView::RemovePaneFocus() { focus_manager_->RemoveFocusChangeListener(this); pane_has_focus_ = false; diff --git a/chrome/browser/ui/views/accessible_pane_view.h b/chrome/browser/ui/views/accessible_pane_view.h index 349fc0d..be08980 100644 --- a/chrome/browser/ui/views/accessible_pane_view.h +++ b/chrome/browser/ui/views/accessible_pane_view.h @@ -58,7 +58,7 @@ class AccessiblePaneView : public views::View, protected: // A subclass can override this to provide a default focusable child // other than the first focusable child. - virtual views::View* GetDefaultFocusableChild() { return NULL; } + virtual views::View* GetDefaultFocusableChild(); // Remove pane focus. virtual void RemovePaneFocus(); diff --git a/chrome/browser/ui/views/autocomplete/autocomplete_result_view.cc b/chrome/browser/ui/views/autocomplete/autocomplete_result_view.cc index eaf858a..613c6a2 100644 --- a/chrome/browser/ui/views/autocomplete/autocomplete_result_view.cc +++ b/chrome/browser/ui/views/autocomplete/autocomplete_result_view.cc @@ -34,6 +34,28 @@ const int kMinimumTextVerticalPadding = 3; //////////////////////////////////////////////////////////////////////////////// // AutocompleteResultView, public: +// Precalculated data used to draw the portion of a match classification that +// fits entirely within one run. +struct AutocompleteResultView::ClassificationData { + string16 text; + const gfx::Font* font; + SkColor color; + int pixel_width; +}; + +// Precalculated data used to draw a complete visual run within the match. +// This will include all or part of at leasdt one, and possibly several, +// classifications. +struct AutocompleteResultView::RunData { + size_t run_start; // Offset within the match text where this run begins. + int visual_order; // Where this run occurs in visual order. The earliest + // run drawn is run 0. + bool is_rtl; + int pixel_width; + Classifications classifications; // Classification pieces within this run, + // in logical order. +}; + // This class is a utility class for calculations affected by whether the result // view is horizontally mirrored. The drawing functions can be written as if // all drawing occurs left-to-right, and then use this class to get the actual diff --git a/chrome/browser/ui/views/autocomplete/autocomplete_result_view.h b/chrome/browser/ui/views/autocomplete/autocomplete_result_view.h index a8e7673..1fba8a5 100644 --- a/chrome/browser/ui/views/autocomplete/autocomplete_result_view.h +++ b/chrome/browser/ui/views/autocomplete/autocomplete_result_view.h @@ -80,28 +80,10 @@ class AutocompleteResultView : public views::View { int text_vertical_padding_; private: - // Precalculated data used to draw the portion of a match classification that - // fits entirely within one run. - struct ClassificationData { - string16 text; - const gfx::Font* font; - SkColor color; - int pixel_width; - }; + struct ClassificationData; typedef std::vector<ClassificationData> Classifications; - // Precalculated data used to draw a complete visual run within the match. - // This will include all or part of at leasdt one, and possibly several, - // classifications. - struct RunData { - size_t run_start; // Offset within the match text where this run begins. - int visual_order; // Where this run occurs in visual order. The earliest - // run drawn is run 0. - bool is_rtl; - int pixel_width; - Classifications classifications; // Classification pieces within this run, - // in logical order. - }; + struct RunData; typedef std::vector<RunData> Runs; // Predicate functions for use when sorting the runs. diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc index 149681d..cf2cb2a 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc +++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc @@ -716,6 +716,10 @@ double BookmarkBarView::GetAnimationValue() const { return size_animation_->GetCurrentValue(); } +int BookmarkBarView::GetToolbarOverlap() const { + return GetToolbarOverlap(false); +} + bool BookmarkBarView::IsAlwaysShown() const { return profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar); } diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.h b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.h index 8b88a28cb..b447606 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.h +++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.h @@ -114,9 +114,7 @@ class BookmarkBarView : public DetachableToolbarView, virtual bool IsDetached() const; virtual bool IsOnTop() const; virtual double GetAnimationValue() const; - virtual int GetToolbarOverlap() const { - return GetToolbarOverlap(false); - } + virtual int GetToolbarOverlap() const; // View methods: virtual gfx::Size GetPreferredSize(); @@ -182,8 +180,8 @@ class BookmarkBarView : public DetachableToolbarView, bool is_animating(); // SlideAnimationDelegate implementation. - void AnimationProgressed(const ui::Animation* animation); - void AnimationEnded(const ui::Animation* animation); + virtual void AnimationProgressed(const ui::Animation* animation); + virtual void AnimationEnded(const ui::Animation* animation); // BookmarkMenuController::Observer virtual void BookmarkMenuDeleted(BookmarkMenuController* controller); diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc index 9c2ca9e..cd6fea2 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc +++ b/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc @@ -333,6 +333,10 @@ bool BookmarkBubbleView::CloseOnEscape() { return delegate_ ? delegate_->CloseOnEscape() : true; } +bool BookmarkBubbleView::FadeInOnShow() { + return false; +} + std::wstring BookmarkBubbleView::accessible_name() { return UTF16ToWide( l10n_util::GetStringUTF16(IDS_BOOMARK_BUBBLE_ADD_BOOKMARK)); diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h b/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h index c691c79..173e97f 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h +++ b/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h @@ -91,7 +91,7 @@ class BookmarkBubbleView : public views::View, virtual void InfoBubbleClosing(InfoBubble* info_bubble, bool closed_by_escape); virtual bool CloseOnEscape(); - virtual bool FadeInOnShow() { return false; } + virtual bool FadeInOnShow(); virtual std::wstring accessible_name(); // Closes the bubble. diff --git a/chrome/browser/ui/views/clear_browsing_data.cc b/chrome/browser/ui/views/clear_browsing_data.cc index ca85a4fc..36119d0 100644 --- a/chrome/browser/ui/views/clear_browsing_data.cc +++ b/chrome/browser/ui/views/clear_browsing_data.cc @@ -358,6 +358,14 @@ views::ClientView* ClearBrowsingDataView::CreateClientView( return client_view; } +views::View* ClearBrowsingDataView::GetExtraView() { + return throbber_view_; +} + +bool ClearBrowsingDataView::GetSizeExtraViewHeightToButtons() { + return true; +} + //////////////////////////////////////////////////////////////////////////////// // ClearBrowsingDataView, ComboboxModel implementation: diff --git a/chrome/browser/ui/views/clear_browsing_data.h b/chrome/browser/ui/views/clear_browsing_data.h index b7e2ce9..ed853df1 100644 --- a/chrome/browser/ui/views/clear_browsing_data.h +++ b/chrome/browser/ui/views/clear_browsing_data.h @@ -64,9 +64,9 @@ class ClearBrowsingDataView : public views::View, virtual std::wstring GetWindowTitle() const; virtual bool Accept(); virtual views::View* GetContentsView(); - views::ClientView* CreateClientView(views::Window* window); - virtual views::View* GetExtraView() { return throbber_view_; } - virtual bool GetSizeExtraViewHeightToButtons() { return true; } + virtual views::ClientView* CreateClientView(views::Window* window); + virtual views::View* GetExtraView(); + virtual bool GetSizeExtraViewHeightToButtons(); virtual views::View* GetInitiallyFocusedView(); // Overridden from ui::ComboboxModel: diff --git a/chrome/browser/ui/views/download_shelf_view.cc b/chrome/browser/ui/views/download_shelf_view.cc index b37804f..a8180f9 100644 --- a/chrome/browser/ui/views/download_shelf_view.cc +++ b/chrome/browser/ui/views/download_shelf_view.cc @@ -385,6 +385,10 @@ void DownloadShelfView::Close() { shelf_animation_->Hide(); } +Browser* DownloadShelfView::browser() const { + return browser_; +} + void DownloadShelfView::Closed() { // When the close animation is complete, remove all completed downloads. size_t i = 0; diff --git a/chrome/browser/ui/views/download_shelf_view.h b/chrome/browser/ui/views/download_shelf_view.h index 10f65fa..25d1601 100644 --- a/chrome/browser/ui/views/download_shelf_view.h +++ b/chrome/browser/ui/views/download_shelf_view.h @@ -70,7 +70,7 @@ class DownloadShelfView : public AccessiblePaneView, virtual bool IsClosing() const; virtual void Show(); virtual void Close(); - virtual Browser* browser() const { return browser_; } + virtual Browser* browser() const; // Implementation of MouseWatcherDelegate. virtual void MouseMovedOutOfView(); @@ -96,7 +96,7 @@ class DownloadShelfView : public AccessiblePaneView, void AddDownloadView(DownloadItemView* view); // Paints the border. - void OnPaintBorder(gfx::Canvas* canvas); + virtual void OnPaintBorder(gfx::Canvas* canvas); // Returns true if the shelf is wide enough to show the first download item. bool CanFitFirstDownloadItem(); diff --git a/chrome/browser/ui/views/extensions/extension_installed_bubble.cc b/chrome/browser/ui/views/extensions/extension_installed_bubble.cc index 9ea61f3..08d7c6c 100644 --- a/chrome/browser/ui/views/extensions/extension_installed_bubble.cc +++ b/chrome/browser/ui/views/extensions/extension_installed_bubble.cc @@ -270,6 +270,8 @@ ExtensionInstalledBubble::ExtensionInstalledBubble(const Extension* extension, Source<Profile>(browser->profile())); } +ExtensionInstalledBubble::~ExtensionInstalledBubble() {} + void ExtensionInstalledBubble::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { @@ -370,3 +372,11 @@ void ExtensionInstalledBubble::InfoBubbleClosing(InfoBubble* info_bubble, Release(); // Balanced in ctor. } + +bool ExtensionInstalledBubble::CloseOnEscape() { + return true; +} + +bool ExtensionInstalledBubble::FadeInOnShow() { + return true; +} diff --git a/chrome/browser/ui/views/extensions/extension_installed_bubble.h b/chrome/browser/ui/views/extensions/extension_installed_bubble.h index ff15b6d..20060eb 100644 --- a/chrome/browser/ui/views/extensions/extension_installed_bubble.h +++ b/chrome/browser/ui/views/extensions/extension_installed_bubble.h @@ -54,7 +54,7 @@ class ExtensionInstalledBubble ExtensionInstalledBubble(const Extension* extension, Browser *browser, SkBitmap icon); - ~ExtensionInstalledBubble() {} + virtual ~ExtensionInstalledBubble(); // Shows the bubble. Called internally via PostTask. void ShowInternal(); @@ -67,8 +67,8 @@ class ExtensionInstalledBubble // InfoBubbleDelegate virtual void InfoBubbleClosing(InfoBubble* info_bubble, bool closed_by_escape); - virtual bool CloseOnEscape() { return true; } - virtual bool FadeInOnShow() { return true; } + virtual bool CloseOnEscape(); + virtual bool FadeInOnShow(); const Extension* extension_; Browser* browser_; diff --git a/chrome/browser/ui/views/frame/browser_bubble_host.cc b/chrome/browser/ui/views/frame/browser_bubble_host.cc index ed13309..4a08f86 100644 --- a/chrome/browser/ui/views/frame/browser_bubble_host.cc +++ b/chrome/browser/ui/views/frame/browser_bubble_host.cc @@ -7,6 +7,10 @@ #include "base/logging.h" #include "chrome/browser/ui/views/browser_bubble.h" +BrowserBubbleHost::BrowserBubbleHost() {} + +BrowserBubbleHost::~BrowserBubbleHost() {} + void BrowserBubbleHost::WindowMoved() { // Do safe iteration in case the bubble winds up closing as a result of this // message. diff --git a/chrome/browser/ui/views/frame/browser_bubble_host.h b/chrome/browser/ui/views/frame/browser_bubble_host.h index 990f39e..139befb 100644 --- a/chrome/browser/ui/views/frame/browser_bubble_host.h +++ b/chrome/browser/ui/views/frame/browser_bubble_host.h @@ -17,7 +17,8 @@ class BrowserBubble; // close events. class BrowserBubbleHost { public: - BrowserBubbleHost() {} + BrowserBubbleHost(); + ~BrowserBubbleHost(); // Invoked when the window containing the attached browser-bubbles is moved. // Calls BrowserBubble::BrowserWindowMoved on all attached bubbles. diff --git a/chrome/browser/ui/views/frame/browser_view.h b/chrome/browser/ui/views/frame/browser_view.h index fecd185..d33ccbe7 100644 --- a/chrome/browser/ui/views/frame/browser_view.h +++ b/chrome/browser/ui/views/frame/browser_view.h @@ -171,7 +171,7 @@ class BrowserView : public BrowserBubbleHost, bool ShouldShowOffTheRecordAvatar() const; // Handle the specified |accelerator| being pressed. - bool AcceleratorPressed(const views::Accelerator& accelerator); + virtual bool AcceleratorPressed(const views::Accelerator& accelerator); // Provides the containing frame with the accelerator for the specified // command id. This can be used to provide menu item shortcut hints etc. @@ -228,7 +228,7 @@ class BrowserView : public BrowserBubbleHost, bool IsPositionInWindowCaption(const gfx::Point& point); // Returns whether the fullscreen bubble is visible or not. - bool IsFullscreenBubbleVisible() const; + virtual bool IsFullscreenBubbleVisible() const; // Invoked from the frame when the full screen state changes. This is only // used on Linux. diff --git a/chrome/browser/ui/views/info_bubble.cc b/chrome/browser/ui/views/info_bubble.cc index 632d750..eafec4f 100644 --- a/chrome/browser/ui/views/info_bubble.cc +++ b/chrome/browser/ui/views/info_bubble.cc @@ -239,6 +239,12 @@ LRESULT BorderWidget::OnMouseActivate(HWND window, } #endif +// InfoBubbleDelegate --------------------------------------------------------- + +std::wstring InfoBubbleDelegate::accessible_name() { + return L""; +} + // InfoBubble ----------------------------------------------------------------- // static diff --git a/chrome/browser/ui/views/info_bubble.h b/chrome/browser/ui/views/info_bubble.h index 36f7998..f8c8571 100644 --- a/chrome/browser/ui/views/info_bubble.h +++ b/chrome/browser/ui/views/info_bubble.h @@ -171,7 +171,7 @@ class InfoBubbleDelegate { virtual bool FadeInOnShow() = 0; // The name of the window to which this delegate belongs. - virtual std::wstring accessible_name() { return L""; } + virtual std::wstring accessible_name(); }; // TODO(sky): this code is ifdef-tastic. It might be cleaner to refactor the diff --git a/chrome/browser/ui/views/js_modal_dialog_views.cc b/chrome/browser/ui/views/js_modal_dialog_views.cc index 6657ade..f6ae4d6 100644 --- a/chrome/browser/ui/views/js_modal_dialog_views.cc +++ b/chrome/browser/ui/views/js_modal_dialog_views.cc @@ -133,6 +133,10 @@ std::wstring JSModalDialogViews::GetDialogButtonLabel( /////////////////////////////////////////////////////////////////////////////// // JSModalDialogViews, views::WindowDelegate implementation: +bool JSModalDialogViews::IsModal() const { + return true; +} + views::View* JSModalDialogViews::GetContentsView() { return message_box_view_; } diff --git a/chrome/browser/ui/views/js_modal_dialog_views.h b/chrome/browser/ui/views/js_modal_dialog_views.h index 1a9a7c3..8dcdfab 100644 --- a/chrome/browser/ui/views/js_modal_dialog_views.h +++ b/chrome/browser/ui/views/js_modal_dialog_views.h @@ -42,7 +42,7 @@ class JSModalDialogViews : public NativeAppModalDialog, ui::MessageBoxFlags::DialogButton button) const; // Overridden from views::WindowDelegate: - virtual bool IsModal() const { return true; } + virtual bool IsModal() const; virtual views::View* GetContentsView(); virtual views::View* GetInitiallyFocusedView(); virtual void OnClose(); diff --git a/chrome/browser/ui/views/location_bar/content_setting_image_view.cc b/chrome/browser/ui/views/location_bar/content_setting_image_view.cc index be5c7fb..b342465 100644 --- a/chrome/browser/ui/views/location_bar/content_setting_image_view.cc +++ b/chrome/browser/ui/views/location_bar/content_setting_image_view.cc @@ -227,6 +227,10 @@ bool ContentSettingImageView::CloseOnEscape() { return true; } +bool ContentSettingImageView::FadeInOnShow() { + return false; +} + void ContentSettingImageView::AnimateToState(double state) { if (state >= 1.0) { // Animaton is over, clear the variables. diff --git a/chrome/browser/ui/views/location_bar/content_setting_image_view.h b/chrome/browser/ui/views/location_bar/content_setting_image_view.h index 5e876fd..ef6ffd1 100644 --- a/chrome/browser/ui/views/location_bar/content_setting_image_view.h +++ b/chrome/browser/ui/views/location_bar/content_setting_image_view.h @@ -52,7 +52,7 @@ class ContentSettingImageView : public views::ImageView, virtual void InfoBubbleClosing(InfoBubble* info_bubble, bool closed_by_escape); virtual bool CloseOnEscape(); - virtual bool FadeInOnShow() { return false; } + virtual bool FadeInOnShow(); // ui::LinearAnimation override: virtual void AnimateToState(double state); diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc index ad5f83c..9b461e3 100644 --- a/chrome/browser/ui/views/location_bar/location_bar_view.cc +++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc @@ -1149,6 +1149,22 @@ void LocationBarView::Revert() { location_entry_->RevertAll(); } +const AutocompleteEditView* LocationBarView::location_entry() const { + return location_entry_.get(); +} + +AutocompleteEditView* LocationBarView::location_entry() { + return location_entry_.get(); +} + +LocationBarTesting* LocationBarView::GetLocationBarForTesting() { + return this; +} + +int LocationBarView::PageActionCount() { + return page_action_views_.size(); +} + int LocationBarView::PageActionVisibleCount() { int result = 0; for (size_t i = 0; i < page_action_views_.size(); i++) { diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.h b/chrome/browser/ui/views/location_bar/location_bar_view.h index 2d53468..44e3f11 100644 --- a/chrome/browser/ui/views/location_bar/location_bar_view.h +++ b/chrome/browser/ui/views/location_bar/location_bar_view.h @@ -235,18 +235,12 @@ class LocationBarView : public LocationBar, virtual void InvalidatePageActions() OVERRIDE; virtual void SaveStateToContents(TabContents* contents) OVERRIDE; virtual void Revert() OVERRIDE; - virtual const AutocompleteEditView* location_entry() const OVERRIDE { - return location_entry_.get(); - } - virtual AutocompleteEditView* location_entry() OVERRIDE { - return location_entry_.get(); - } - virtual LocationBarTesting* GetLocationBarForTesting() OVERRIDE { - return this; - } + virtual const AutocompleteEditView* location_entry() const OVERRIDE; + virtual AutocompleteEditView* location_entry() OVERRIDE; + virtual LocationBarTesting* GetLocationBarForTesting() OVERRIDE; // Overridden from LocationBarTesting: - virtual int PageActionCount() OVERRIDE { return page_action_views_.size(); } + virtual int PageActionCount() OVERRIDE; virtual int PageActionVisibleCount() OVERRIDE; virtual ExtensionAction* GetPageAction(size_t index) OVERRIDE; virtual ExtensionAction* GetVisiblePageAction(size_t index) OVERRIDE; diff --git a/chrome/browser/ui/views/location_bar/star_view.cc b/chrome/browser/ui/views/location_bar/star_view.cc index 886aec2..ad1a15f 100644 --- a/chrome/browser/ui/views/location_bar/star_view.cc +++ b/chrome/browser/ui/views/location_bar/star_view.cc @@ -73,3 +73,7 @@ void StarView::InfoBubbleClosing(InfoBubble* info_bubble, bool StarView::CloseOnEscape() { return true; } + +bool StarView::FadeInOnShow() { + return false; +} diff --git a/chrome/browser/ui/views/location_bar/star_view.h b/chrome/browser/ui/views/location_bar/star_view.h index ad02f9e..cd80a00 100644 --- a/chrome/browser/ui/views/location_bar/star_view.h +++ b/chrome/browser/ui/views/location_bar/star_view.h @@ -37,7 +37,7 @@ class StarView : public views::ImageView, public InfoBubbleDelegate { virtual void InfoBubbleClosing(InfoBubble* info_bubble, bool closed_by_escape); virtual bool CloseOnEscape(); - virtual bool FadeInOnShow() { return false; } + virtual bool FadeInOnShow(); // The CommandUpdater for the Browser object that owns the location bar. CommandUpdater* command_updater_; diff --git a/chrome/browser/ui/views/options/options_page_view.cc b/chrome/browser/ui/views/options/options_page_view.cc index b81b3af..ec0c109 100644 --- a/chrome/browser/ui/views/options/options_page_view.cc +++ b/chrome/browser/ui/views/options/options_page_view.cc @@ -21,6 +21,10 @@ OptionsPageView::~OptionsPageView() { /////////////////////////////////////////////////////////////////////////////// // OptionsPageView, views::View overrides: +bool OptionsPageView::CanClose() const { + return true; +} + void OptionsPageView::ViewHierarchyChanged(bool is_add, views::View* parent, views::View* child) { diff --git a/chrome/browser/ui/views/options/options_page_view.h b/chrome/browser/ui/views/options/options_page_view.h index bbbc8c4..c26cc9f 100644 --- a/chrome/browser/ui/views/options/options_page_view.h +++ b/chrome/browser/ui/views/options/options_page_view.h @@ -26,7 +26,7 @@ class OptionsPageView : public views::View, // Returns true if the window containing this view can be closed, given the // current state of this view. This can be used to prevent the window from // being closed when a modal dialog box is showing, for example. - virtual bool CanClose() const { return true; } + virtual bool CanClose() const; protected: // This class cannot be instantiated directly, but its constructor must be diff --git a/chrome/browser/ui/views/page_info_bubble_view.cc b/chrome/browser/ui/views/page_info_bubble_view.cc index cd3fcc3..b112a00 100644 --- a/chrome/browser/ui/views/page_info_bubble_view.cc +++ b/chrome/browser/ui/views/page_info_bubble_view.cc @@ -207,6 +207,18 @@ void PageInfoBubbleView::ModelChanged() { resize_animation_.Show(); } +bool PageInfoBubbleView::CloseOnEscape() { + return true; +} + +bool PageInfoBubbleView::FadeInOnShow() { + return false; +} + +std::wstring PageInfoBubbleView::accessible_name() { + return L"PageInfoBubble"; +} + void PageInfoBubbleView::LinkActivated(views::Link* source, int event_flags) { // We want to make sure the info bubble closes once the link is activated. So // we close it explicitly rather than relying on a side-effect of opening a diff --git a/chrome/browser/ui/views/page_info_bubble_view.h b/chrome/browser/ui/views/page_info_bubble_view.h index 0f57d5a..4483b50 100644 --- a/chrome/browser/ui/views/page_info_bubble_view.h +++ b/chrome/browser/ui/views/page_info_bubble_view.h @@ -44,9 +44,9 @@ class PageInfoBubbleView : public views::View, // InfoBubbleDelegate methods: virtual void InfoBubbleClosing(InfoBubble* info_bubble, bool closed_by_escape) {} - virtual bool CloseOnEscape() { return true; } - virtual bool FadeInOnShow() { return false; } - virtual std::wstring accessible_name() { return L"PageInfoBubble"; } + virtual bool CloseOnEscape(); + virtual bool FadeInOnShow(); + virtual std::wstring accessible_name(); // LinkController methods: virtual void LinkActivated(views::Link* source, int event_flags); diff --git a/chrome/browser/ui/views/sad_tab_view.cc b/chrome/browser/ui/views/sad_tab_view.cc index fc79866..85e500e 100644 --- a/chrome/browser/ui/views/sad_tab_view.cc +++ b/chrome/browser/ui/views/sad_tab_view.cc @@ -70,6 +70,8 @@ SadTabView::SadTabView(TabContents* tab_contents, Kind kind) } } +SadTabView::~SadTabView() {} + void SadTabView::OnPaint(gfx::Canvas* canvas) { SkPaint paint; SkSafeUnref(paint.setShader( diff --git a/chrome/browser/ui/views/sad_tab_view.h b/chrome/browser/ui/views/sad_tab_view.h index 8694aa4..e87ecb4 100644 --- a/chrome/browser/ui/views/sad_tab_view.h +++ b/chrome/browser/ui/views/sad_tab_view.h @@ -31,7 +31,7 @@ class SadTabView : public views::View, }; explicit SadTabView(TabContents* tab_contents, Kind kind); - virtual ~SadTabView() {} + virtual ~SadTabView(); // Overridden from views::View: virtual void OnPaint(gfx::Canvas* canvas); diff --git a/chrome/browser/ui/views/tabs/base_tab.cc b/chrome/browser/ui/views/tabs/base_tab.cc index 740dc1d..e6d6bc8 100644 --- a/chrome/browser/ui/views/tabs/base_tab.cc +++ b/chrome/browser/ui/views/tabs/base_tab.cc @@ -480,6 +480,18 @@ void BaseTab::ShowContextMenuForView(views::View* source, controller()->ShowContextMenuForTab(this, p); } +int BaseTab::loading_animation_frame() const { + return loading_animation_frame_; +} + +bool BaseTab::should_display_crashed_favicon() const { + return should_display_crashed_favicon_; +} + +int BaseTab::fav_icon_hiding_offset() const { + return fav_icon_hiding_offset_; +} + void BaseTab::SetFavIconHidingOffset(int offset) { fav_icon_hiding_offset_ = offset; ScheduleIconPaint(); diff --git a/chrome/browser/ui/views/tabs/base_tab.h b/chrome/browser/ui/views/tabs/base_tab.h index f51eab9..7767df3e 100644 --- a/chrome/browser/ui/views/tabs/base_tab.h +++ b/chrome/browser/ui/views/tabs/base_tab.h @@ -136,13 +136,9 @@ class BaseTab : public ui::AnimationDelegate, virtual const gfx::Rect& GetTitleBounds() const = 0; virtual const gfx::Rect& GetIconBounds() const = 0; - virtual int loading_animation_frame() const { - return loading_animation_frame_; - } - virtual bool should_display_crashed_favicon() const { - return should_display_crashed_favicon_; - } - virtual int fav_icon_hiding_offset() const { return fav_icon_hiding_offset_; } + virtual int loading_animation_frame() const; + virtual bool should_display_crashed_favicon() const; + virtual int fav_icon_hiding_offset() const; static gfx::Font* font() { return font_; } static int font_height() { return font_height_; } diff --git a/chrome/browser/ui/views/tabs/base_tab_strip.cc b/chrome/browser/ui/views/tabs/base_tab_strip.cc index 715e2e2..9a57e0f 100644 --- a/chrome/browser/ui/views/tabs/base_tab_strip.cc +++ b/chrome/browser/ui/views/tabs/base_tab_strip.cc @@ -390,6 +390,10 @@ void BaseTabStrip::StartMiniTabAnimation() { AnimateToIdealBounds(); } +bool BaseTabStrip::ShouldHighlightCloseButtonAfterRemove() { + return true; +} + void BaseTabStrip::RemoveAndDeleteTab(BaseTab* tab) { int tab_data_index = TabIndexOfTab(tab); diff --git a/chrome/browser/ui/views/tabs/base_tab_strip.h b/chrome/browser/ui/views/tabs/base_tab_strip.h index fd92839..e6e9677 100644 --- a/chrome/browser/ui/views/tabs/base_tab_strip.h +++ b/chrome/browser/ui/views/tabs/base_tab_strip.h @@ -173,7 +173,7 @@ class BaseTabStrip : public views::View, virtual void StartMiniTabAnimation(); // Returns whether the highlight button should be highlighted after a remove. - virtual bool ShouldHighlightCloseButtonAfterRemove() { return true; } + virtual bool ShouldHighlightCloseButtonAfterRemove(); // Animates all the views to their ideal bounds. // NOTE: this does *not* invoke GenerateIdealBounds, it uses the bounds diff --git a/chrome/browser/ui/views/tabs/tab.cc b/chrome/browser/ui/views/tabs/tab.cc index 56c268a..e6cf2f0 100644 --- a/chrome/browser/ui/views/tabs/tab.cc +++ b/chrome/browser/ui/views/tabs/tab.cc @@ -310,6 +310,10 @@ void Tab::OnThemeChanged() { LoadTabImages(); } +std::string Tab::GetClassName() const { + return kViewClassName; +} + bool Tab::HasHitTestMask() const { return true; } diff --git a/chrome/browser/ui/views/tabs/tab.h b/chrome/browser/ui/views/tabs/tab.h index debd280..6eb1765d 100644 --- a/chrome/browser/ui/views/tabs/tab.h +++ b/chrome/browser/ui/views/tabs/tab.h @@ -66,7 +66,7 @@ class Tab : public BaseTab { virtual void OnPaint(gfx::Canvas* canvas); virtual void Layout(); virtual void OnThemeChanged(); - virtual std::string GetClassName() const { return kViewClassName; } + virtual std::string GetClassName() const; virtual bool HasHitTestMask() const; virtual void GetHitTestMask(gfx::Path* path) const; virtual bool GetTooltipTextOrigin(const gfx::Point& p, gfx::Point* origin); diff --git a/chrome/browser/ui/views/tabs/tab_renderer_data.cc b/chrome/browser/ui/views/tabs/tab_renderer_data.cc new file mode 100644 index 0000000..47f96d6 --- /dev/null +++ b/chrome/browser/ui/views/tabs/tab_renderer_data.cc @@ -0,0 +1,34 @@ +// Copyright (c) 2011 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. + +#include "chrome/browser/ui/views/tabs/tab_renderer_data.h" + +TabRendererData::TabRendererData() + : network_state(NETWORK_STATE_NONE), + loading(false), + crashed_status(base::TERMINATION_STATUS_STILL_RUNNING), + off_the_record(false), + show_icon(true), + mini(false), + blocked(false), + app(false) { +} + +TabRendererData::~TabRendererData() {} + +bool TabRendererData::Equals(const TabRendererData& data) { + return + favicon.pixelRef() && + favicon.pixelRef() == data.favicon.pixelRef() && + favicon.pixelRefOffset() == data.favicon.pixelRefOffset() && + network_state == data.network_state && + title == data.title && + loading == data.loading && + crashed_status == data.crashed_status && + off_the_record == data.off_the_record && + show_icon == data.show_icon && + mini == data.mini && + blocked == data.blocked && + app == data.app; +} diff --git a/chrome/browser/ui/views/tabs/tab_renderer_data.h b/chrome/browser/ui/views/tabs/tab_renderer_data.h index 43962df..28b55fc 100644 --- a/chrome/browser/ui/views/tabs/tab_renderer_data.h +++ b/chrome/browser/ui/views/tabs/tab_renderer_data.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -21,16 +21,8 @@ struct TabRendererData { NETWORK_STATE_LOADING, // connected, transferring data. }; - TabRendererData() - : network_state(NETWORK_STATE_NONE), - loading(false), - crashed_status(base::TERMINATION_STATUS_STILL_RUNNING), - off_the_record(false), - show_icon(true), - mini(false), - blocked(false), - app(false) { - } + TabRendererData(); + ~TabRendererData(); // This interprets the crashed status to decide whether or not this // render data represents a tab that is "crashed" (i.e. the render @@ -43,21 +35,7 @@ struct TabRendererData { // Returns true if the TabRendererData is same as given |data|. Two favicons // are considered equals if two SkBitmaps point to the same SkPixelRef object. - bool Equals(const TabRendererData& data) { - return - favicon.pixelRef() && - favicon.pixelRef() == data.favicon.pixelRef() && - favicon.pixelRefOffset() == data.favicon.pixelRefOffset() && - network_state == data.network_state && - title == data.title && - loading == data.loading && - crashed_status == data.crashed_status && - off_the_record == data.off_the_record && - show_icon == data.show_icon && - mini == data.mini && - blocked == data.blocked && - app == data.app; - } + bool Equals(const TabRendererData& data); SkBitmap favicon; NetworkState network_state; diff --git a/chrome/browser/ui/views/tabs/tab_strip.h b/chrome/browser/ui/views/tabs/tab_strip.h index 7f0a339..42e717ec 100644 --- a/chrome/browser/ui/views/tabs/tab_strip.h +++ b/chrome/browser/ui/views/tabs/tab_strip.h @@ -209,13 +209,13 @@ class TabStrip : public BaseTabStrip, // animating to their desired position/bounds. This is used by the standard // Layout method and other callers like the DraggedTabController that need // stable representations of Tab positions. - void GenerateIdealBounds(); + virtual void GenerateIdealBounds(); // Starts various types of TabStrip animations. void StartResizeLayoutAnimation(); void StartMoveTabAnimation(int from_model_index, int to_model_index); - void StartMiniTabAnimation(); + virtual void StartMiniTabAnimation(); void StartMouseInitiatedRemoveTabAnimation(int model_index); // Calculates the available width for tabs, assuming a Tab is to be closed. diff --git a/chrome/browser/ui/views/theme_install_bubble_view.h b/chrome/browser/ui/views/theme_install_bubble_view.h index 450d4cf..b363073 100644 --- a/chrome/browser/ui/views/theme_install_bubble_view.h +++ b/chrome/browser/ui/views/theme_install_bubble_view.h @@ -34,7 +34,7 @@ class Widget; class ThemeInstallBubbleView : public NotificationObserver, public views::Label { public: - ~ThemeInstallBubbleView(); + virtual ~ThemeInstallBubbleView(); // NotificationObserver virtual void Observe(NotificationType type, @@ -51,7 +51,7 @@ class ThemeInstallBubbleView : public NotificationObserver, void Reposition(); // Inherited from views. - gfx::Size GetPreferredSize(); + virtual gfx::Size GetPreferredSize(); // Shut down the popup and remove our notifications. void Close(); diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index a5a2c12..f99278a 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -3168,6 +3168,7 @@ 'browser/ui/views/tabs/tab.cc', 'browser/ui/views/tabs/tab.h', 'browser/ui/views/tabs/tab_controller.h', + 'browser/ui/views/tabs/tab_renderer_data.cc', 'browser/ui/views/tabs/tab_renderer_data.h', 'browser/ui/views/tabs/tab_strip.cc', 'browser/ui/views/tabs/tab_strip.h', @@ -4057,6 +4058,7 @@ ['include', '^browser/ui/views/tabs/tab.cc'], ['include', '^browser/ui/views/tabs/tab.h'], ['include', '^browser/ui/views/tabs/tab_controller.h'], + ['include', '^browser/ui/views/tabs/tab_renderer_data.cc'], ['include', '^browser/ui/views/tabs/tab_renderer_data.h'], ['include', '^browser/ui/views/tabs/tab_strip.cc'], ['include', '^browser/ui/views/tabs/tab_strip.h'], diff --git a/ui/views/focus/focus_manager.cc b/ui/views/focus/focus_manager.cc index fa2b8f2..c56565a 100644 --- a/ui/views/focus/focus_manager.cc +++ b/ui/views/focus/focus_manager.cc @@ -101,6 +101,10 @@ FocusManager::WidgetFocusManager::GetInstance() { return Singleton<WidgetFocusManager>::get(); } +FocusManager::WidgetFocusManager::WidgetFocusManager() : enabled_(true) {} + +FocusManager::WidgetFocusManager::~WidgetFocusManager() {} + //////////////////////////////////////////////////////////////////////////////// // FocusManager, public: diff --git a/ui/views/focus/focus_manager.h b/ui/views/focus/focus_manager.h index 1f48744..e31b8e6 100644 --- a/ui/views/focus/focus_manager.h +++ b/ui/views/focus/focus_manager.h @@ -150,7 +150,8 @@ class FocusManager { void DisableNotifications() { enabled_ = false; } private: - WidgetFocusManager() : enabled_(true) {} + WidgetFocusManager(); + ~WidgetFocusManager(); typedef std::vector<WidgetFocusChangeListener*> WidgetFocusChangeListenerList; diff --git a/views/controls/label.cc b/views/controls/label.cc index 1b105f0..810769a 100644 --- a/views/controls/label.cc +++ b/views/controls/label.cc @@ -77,6 +77,10 @@ void Label::OnBoundsChanged() { text_size_valid_ &= !is_multi_line_; } +std::string Label::GetClassName() const { + return kViewClassName; +} + void Label::OnPaint(gfx::Canvas* canvas) { OnPaintBackground(canvas); @@ -128,6 +132,14 @@ const GURL Label::GetURL() const { return url_set_ ? url_ : GURL(UTF16ToUTF8(text_)); } +void Label::SetColor(const SkColor& color) { + color_ = color; +} + +SkColor Label::GetColor() const { + return color_; +} + void Label::SetHorizontalAlignment(Alignment alignment) { // If the View's UI layout is right-to-left and rtl_alignment_mode_ is // USE_UI_ALIGNMENT, we need to flip the alignment so that the alignment diff --git a/views/controls/label.h b/views/controls/label.h index d916659..1bb2b59 100644 --- a/views/controls/label.h +++ b/views/controls/label.h @@ -69,7 +69,7 @@ class Label : public View { virtual void OnBoundsChanged(); // Returns views/Label. - virtual std::string GetClassName() const { return kViewClassName; } + virtual std::string GetClassName() const; // Overridden to paint virtual void OnPaint(gfx::Canvas* canvas); @@ -97,10 +97,10 @@ class Label : public View { const GURL GetURL() const; // Set the color - virtual void SetColor(const SkColor& color) { color_ = color; } + virtual void SetColor(const SkColor& color); // Return a reference to the currently used color. - virtual SkColor GetColor() const { return color_; } + virtual SkColor GetColor() const; // Set horizontal alignment. If the locale is RTL, and the RTL alignment // setting is set as USE_UI_ALIGNMENT, the alignment is flipped around. diff --git a/views/controls/menu/menu_2.cc b/views/controls/menu/menu_2.cc index f64f275..4fa5851 100644 --- a/views/controls/menu/menu_2.cc +++ b/views/controls/menu/menu_2.cc @@ -16,6 +16,8 @@ Menu2::Menu2(ui::MenuModel* model) Rebuild(); } +Menu2::~Menu2() {} + gfx::NativeMenu Menu2::GetNativeMenu() const { return wrapper_->GetNativeMenu(); } diff --git a/views/controls/menu/menu_2.h b/views/controls/menu/menu_2.h index 8916b7c..7204120 100644 --- a/views/controls/menu/menu_2.h +++ b/views/controls/menu/menu_2.h @@ -33,7 +33,7 @@ class Menu2 { // MyClass : menu_(this) {} // is likely to have problems. explicit Menu2(ui::MenuModel* model); - virtual ~Menu2() {} + virtual ~Menu2(); // How the menu is aligned relative to the point it is shown at. // The alignment is reversed by menu if text direction is right to left. diff --git a/views/controls/menu/menu_config.cc b/views/controls/menu/menu_config.cc index cfdebea..d3c510d 100644 --- a/views/controls/menu/menu_config.cc +++ b/views/controls/menu/menu_config.cc @@ -10,6 +10,33 @@ namespace views { static MenuConfig* config_instance = NULL; +MenuConfig::MenuConfig() + : text_color(SK_ColorBLACK), + item_top_margin(3), + item_bottom_margin(4), + item_no_icon_top_margin(1), + item_no_icon_bottom_margin(3), + item_left_margin(4), + label_to_arrow_padding(10), + arrow_to_edge_padding(5), + icon_to_label_padding(8), + gutter_to_label(5), + check_width(16), + check_height(16), + radio_width(16), + radio_height(16), + arrow_height(9), + arrow_width(9), + gutter_width(0), + separator_height(6), + render_gutter(false), + show_mnemonics(false), + scroll_arrow_height(3), + label_to_accelerator_padding(10) { +} + +MenuConfig::~MenuConfig() {} + void MenuConfig::Reset() { delete config_instance; config_instance = NULL; diff --git a/views/controls/menu/menu_config.h b/views/controls/menu/menu_config.h index ae5446d..06a31f1 100644 --- a/views/controls/menu/menu_config.h +++ b/views/controls/menu/menu_config.h @@ -14,30 +14,8 @@ namespace views { // Layout type information for menu items. Use the instance() method to obtain // the MenuConfig for the current platform. struct MenuConfig { - MenuConfig() - : text_color(SK_ColorBLACK), - item_top_margin(3), - item_bottom_margin(4), - item_no_icon_top_margin(1), - item_no_icon_bottom_margin(3), - item_left_margin(4), - label_to_arrow_padding(10), - arrow_to_edge_padding(5), - icon_to_label_padding(8), - gutter_to_label(5), - check_width(16), - check_height(16), - radio_width(16), - radio_height(16), - arrow_height(9), - arrow_width(9), - gutter_width(0), - separator_height(6), - render_gutter(false), - show_mnemonics(false), - scroll_arrow_height(3), - label_to_accelerator_padding(10) { - } + MenuConfig(); + ~MenuConfig(); // Resets the single shared MenuConfig instance. The next time instance() is // invoked a new MenuConfig is created and configured. diff --git a/views/controls/menu/menu_controller.cc b/views/controls/menu/menu_controller.cc index 906bd40..6551687 100644 --- a/views/controls/menu/menu_controller.cc +++ b/views/controls/menu/menu_controller.cc @@ -243,6 +243,12 @@ struct MenuController::SelectByCharDetails { int next_match; }; +// MenuController:State ------------------------------------------------------ + +MenuController::State::State() : item(NULL), submenu_open(false) {} + +MenuController::State::~State() {} + // MenuController ------------------------------------------------------------ // static diff --git a/views/controls/menu/menu_controller.h b/views/controls/menu/menu_controller.h index 2da3a4b..dfd68b4 100644 --- a/views/controls/menu/menu_controller.h +++ b/views/controls/menu/menu_controller.h @@ -131,7 +131,8 @@ class MenuController : public MessageLoopForUI::Dispatcher { // Tracks selection information. struct State { - State() : item(NULL), submenu_open(false) {} + State(); + ~State(); // The selected menu item. MenuItemView* item; diff --git a/views/controls/menu/menu_delegate.cc b/views/controls/menu/menu_delegate.cc new file mode 100644 index 0000000..e70fb17 --- /dev/null +++ b/views/controls/menu/menu_delegate.cc @@ -0,0 +1,113 @@ +// Copyright (c) 2011 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. + +#include "views/controls/menu/menu_delegate.h" + +namespace views { + +bool MenuDelegate::IsItemChecked(int id) const { + return false; +} + +std::wstring MenuDelegate::GetLabel(int id) const { + return std::wstring(); +} + +std::wstring MenuDelegate::GetTooltipText(int id, + const gfx::Point& screen_loc) { + return std::wstring(); +} + +bool MenuDelegate::GetAccelerator(int id, Accelerator* accelerator) { + return false; +} + +bool MenuDelegate::ShowContextMenu(MenuItemView* source, + int id, + const gfx::Point& p, + bool is_mouse_gesture) { + return false; +} + +bool MenuDelegate::SupportsCommand(int id) const { + return true; +} + +bool MenuDelegate::IsCommandEnabled(int id) const { + return true; +} + +bool MenuDelegate::GetContextualLabel(int id, std::wstring* out) const { + return false; +} + +bool MenuDelegate::ShouldCloseAllMenusOnExecute(int id) { + return true; +} + +void MenuDelegate::ExecuteCommand(int id, int mouse_event_flags) { + ExecuteCommand(id); +} + +bool MenuDelegate::IsTriggerableEvent(const MouseEvent& e) { + return e.IsLeftMouseButton() || e.IsRightMouseButton(); +} + +bool MenuDelegate::CanDrop(MenuItemView* menu, const OSExchangeData& data) { + return false; +} + +bool MenuDelegate::GetDropFormats( + MenuItemView* menu, + int* formats, + std::set<OSExchangeData::CustomFormat>* custom_formats) { + return false; +} + +bool MenuDelegate::AreDropTypesRequired(MenuItemView* menu) { + return false; +} + +int MenuDelegate::GetDropOperation(MenuItemView* item, + const DropTargetEvent& event, + DropPosition* position) { + NOTREACHED() << "If you override CanDrop, you need to override this too"; + return ui::DragDropTypes::DRAG_NONE; +} + +int MenuDelegate::OnPerformDrop(MenuItemView* menu, + DropPosition position, + const DropTargetEvent& event) { + NOTREACHED() << "If you override CanDrop, you need to override this too"; + return ui::DragDropTypes::DRAG_NONE; +} + +bool MenuDelegate::CanDrag(MenuItemView* menu) { + return false; +} + +void MenuDelegate::WriteDragData(MenuItemView* sender, OSExchangeData* data) { + NOTREACHED() << "If you override CanDrag, you must override this too."; +} + +int MenuDelegate::GetDragOperations(MenuItemView* sender) { + NOTREACHED() << "If you override CanDrag, you must override this too."; + return 0; +} + +MenuItemView* MenuDelegate::GetSiblingMenu(MenuItemView* menu, + const gfx::Point& screen_point, + MenuItemView::AnchorPosition* anchor, + bool* has_mnemonics, + MenuButton** button) { + return NULL; +} + +int MenuDelegate::GetMaxWidthForMenu() { + // NOTE: this needs to be large enough to accommodate the wrench menu with + // big fonts. + return 800; +} + +} // namespace views diff --git a/views/controls/menu/menu_delegate.h b/views/controls/menu/menu_delegate.h index f30d095..6a5cc5b 100644 --- a/views/controls/menu/menu_delegate.h +++ b/views/controls/menu/menu_delegate.h @@ -47,27 +47,19 @@ class MenuDelegate { // Whether or not an item should be shown as checked. This is invoked for // radio buttons and check buttons. - virtual bool IsItemChecked(int id) const { - return false; - } + virtual bool IsItemChecked(int id) const; // The string shown for the menu item. This is only invoked when an item is // added with an empty label. - virtual std::wstring GetLabel(int id) const { - return std::wstring(); - } + virtual std::wstring GetLabel(int id) const; // The tooltip shown for the menu item. This is invoked when the user // hovers over the item, and no tooltip text has been set for that item. - virtual std::wstring GetTooltipText(int id, const gfx::Point& screen_loc) { - return std::wstring(); - } + virtual std::wstring GetTooltipText(int id, const gfx::Point& screen_loc); // If there is an accelerator for the menu item with id |id| it is set in // |accelerator| and true is returned. - virtual bool GetAccelerator(int id, Accelerator* accelerator) { - return false; - } + virtual bool GetAccelerator(int id, Accelerator* accelerator); // Shows the context menu with the specified id. This is invoked when the // user does the appropriate gesture to show a context menu. The id @@ -80,20 +72,12 @@ class MenuDelegate { virtual bool ShowContextMenu(MenuItemView* source, int id, const gfx::Point& p, - bool is_mouse_gesture) { - return false; - } + bool is_mouse_gesture); // Controller - virtual bool SupportsCommand(int id) const { - return true; - } - virtual bool IsCommandEnabled(int id) const { - return true; - } - virtual bool GetContextualLabel(int id, std::wstring* out) const { - return false; - } + virtual bool SupportsCommand(int id) const; + virtual bool IsCommandEnabled(int id) const; + virtual bool GetContextualLabel(int id, std::wstring* out) const; virtual void ExecuteCommand(int id) { } @@ -102,23 +86,17 @@ class MenuDelegate { // the user selects the menu with the command |id|. This returns true to // indicate that all menus should be closed. Return false if only the // context menu should be closed. - virtual bool ShouldCloseAllMenusOnExecute(int id) { - return true; - } + virtual bool ShouldCloseAllMenusOnExecute(int id); // Executes the specified command. mouse_event_flags give the flags of the // mouse event that triggered this to be invoked (views::MouseEvent // flags). mouse_event_flags is 0 if this is triggered by a user gesture // other than a mouse event. - virtual void ExecuteCommand(int id, int mouse_event_flags) { - ExecuteCommand(id); - } + virtual void ExecuteCommand(int id, int mouse_event_flags); // Returns true if the specified mouse event is one the user can use // to trigger, or accept, the mouse. Defaults to left or right mouse buttons. - virtual bool IsTriggerableEvent(const MouseEvent& e) { - return e.IsLeftMouseButton() || e.IsRightMouseButton(); - } + virtual bool IsTriggerableEvent(const MouseEvent& e); // Invoked to determine if drops can be accepted for a submenu. This is // ONLY invoked for menus that have submenus and indicates whether or not @@ -134,22 +112,16 @@ class MenuDelegate { // // To restrict which children can be dropped on override GetDropOperation. - virtual bool CanDrop(MenuItemView* menu, const OSExchangeData& data) { - return false; - } + virtual bool CanDrop(MenuItemView* menu, const OSExchangeData& data); // See view for a description of this method. virtual bool GetDropFormats( MenuItemView* menu, int* formats, - std::set<OSExchangeData::CustomFormat>* custom_formats) { - return false; - } + std::set<OSExchangeData::CustomFormat>* custom_formats); // See view for a description of this method. - virtual bool AreDropTypesRequired(MenuItemView* menu) { - return false; - } + virtual bool AreDropTypesRequired(MenuItemView* menu); // Returns the drop operation for the specified target menu item. This is // only invoked if CanDrop returned true for the parent menu. position @@ -159,10 +131,7 @@ class MenuDelegate { // If a drop should not be allowed, returned ui::DragDropTypes::DRAG_NONE. virtual int GetDropOperation(MenuItemView* item, const DropTargetEvent& event, - DropPosition* position) { - NOTREACHED() << "If you override CanDrop, you need to override this too"; - return ui::DragDropTypes::DRAG_NONE; - } + DropPosition* position); // Invoked to perform the drop operation. This is ONLY invoked if // canDrop returned true for the parent menu item, and GetDropOperation @@ -171,29 +140,19 @@ class MenuDelegate { // menu indicates the menu the drop occurred on. virtual int OnPerformDrop(MenuItemView* menu, DropPosition position, - const DropTargetEvent& event) { - NOTREACHED() << "If you override CanDrop, you need to override this too"; - return ui::DragDropTypes::DRAG_NONE; - } + const DropTargetEvent& event); // Invoked to determine if it is possible for the user to drag the specified // menu item. - virtual bool CanDrag(MenuItemView* menu) { - return false; - } + virtual bool CanDrag(MenuItemView* menu); // Invoked to write the data for a drag operation to data. sender is the // MenuItemView being dragged. - virtual void WriteDragData(MenuItemView* sender, OSExchangeData* data) { - NOTREACHED() << "If you override CanDrag, you must override this too."; - } + virtual void WriteDragData(MenuItemView* sender, OSExchangeData* data); // Invoked to determine the drag operations for a drag session of sender. // See DragDropTypes for possible values. - virtual int GetDragOperations(MenuItemView* sender) { - NOTREACHED() << "If you override CanDrag, you must override this too."; - return 0; - } + virtual int GetDragOperations(MenuItemView* sender); // Notification the menu has closed. This is only sent when running the // menu for a drop. @@ -213,16 +172,10 @@ class MenuDelegate { const gfx::Point& screen_point, MenuItemView::AnchorPosition* anchor, bool* has_mnemonics, - MenuButton** button) { - return NULL; - } + MenuButton** button); // Returns the max width menus can grow to be. - virtual int GetMaxWidthForMenu() { - // NOTE: this needs to be large enough to accommodate the wrench menu with - // big fonts. - return 800; - } + virtual int GetMaxWidthForMenu(); }; } // namespace views diff --git a/views/controls/menu/menu_host_gtk.h b/views/controls/menu/menu_host_gtk.h index 9f2f007..2d4884f 100644 --- a/views/controls/menu/menu_host_gtk.h +++ b/views/controls/menu/menu_host_gtk.h @@ -21,10 +21,10 @@ class MenuHostGtk : public WidgetGtk, public MenuHost { virtual ~MenuHostGtk(); // MenuHost overrides. - void InitMenuHost(gfx::NativeWindow parent, - const gfx::Rect& bounds, - View* contents_view, - bool do_capture); + virtual void InitMenuHost(gfx::NativeWindow parent, + const gfx::Rect& bounds, + View* contents_view, + bool do_capture); virtual bool IsMenuHostVisible(); virtual void ShowMenuHost(bool do_capture); virtual void HideMenuHost(); diff --git a/views/controls/menu/menu_item_view.cc b/views/controls/menu/menu_item_view.cc index ed44c3a..60bc7cd 100644 --- a/views/controls/menu/menu_item_view.cc +++ b/views/controls/menu/menu_item_view.cc @@ -318,6 +318,14 @@ SubmenuView* MenuItemView::CreateSubmenu() { return submenu_; } +bool MenuItemView::HasSubmenu() const { + return (submenu_ != NULL); +} + +SubmenuView* MenuItemView::GetSubmenu() const { + return submenu_; +} + void MenuItemView::SetTitle(const std::wstring& title) { title_ = WideToUTF16Hack(title); SetAccessibleName(GetAccessibleNameForMenuItem(title_, GetAcceleratorText())); diff --git a/views/controls/menu/menu_item_view.h b/views/controls/menu/menu_item_view.h index 5b5e09c..c028346 100644 --- a/views/controls/menu/menu_item_view.h +++ b/views/controls/menu/menu_item_view.h @@ -199,10 +199,10 @@ class MenuItemView : public View { virtual SubmenuView* CreateSubmenu(); // Returns true if this menu item has a submenu. - virtual bool HasSubmenu() const { return (submenu_ != NULL); } + virtual bool HasSubmenu() const; // Returns the view containing child menu items. - virtual SubmenuView* GetSubmenu() const { return submenu_; } + virtual SubmenuView* GetSubmenu() const; // Returns the parent menu item. MenuItemView* GetParentMenuItem() const { return parent_menu_item_; } diff --git a/views/controls/menu/menu_separator.h b/views/controls/menu/menu_separator.h index 393b3b2..7260e16 100644 --- a/views/controls/menu/menu_separator.h +++ b/views/controls/menu/menu_separator.h @@ -16,8 +16,8 @@ class MenuSeparator : public View { MenuSeparator() {} // View overrides. - void OnPaint(gfx::Canvas* canvas); - gfx::Size GetPreferredSize(); + virtual void OnPaint(gfx::Canvas* canvas); + virtual gfx::Size GetPreferredSize(); private: DISALLOW_COPY_AND_ASSIGN(MenuSeparator); diff --git a/views/controls/menu/submenu_view.h b/views/controls/menu/submenu_view.h index cbe2674..792189f 100644 --- a/views/controls/menu/submenu_view.h +++ b/views/controls/menu/submenu_view.h @@ -61,7 +61,7 @@ class SubmenuView : public View { virtual AccessibilityTypes::Role GetAccessibleRole(); // Painting. - void PaintChildren(gfx::Canvas* canvas); + virtual void PaintChildren(gfx::Canvas* canvas); // Drag and drop methods. These are forwarded to the MenuController. virtual bool GetDropFormats( diff --git a/views/controls/message_box_view.cc b/views/controls/message_box_view.cc index 3df7b6b..d1a7864 100644 --- a/views/controls/message_box_view.cc +++ b/views/controls/message_box_view.cc @@ -46,6 +46,8 @@ MessageBoxView::MessageBoxView(int dialog_flags, Init(dialog_flags, default_prompt); } +MessageBoxView::~MessageBoxView() {} + std::wstring MessageBoxView::GetInputText() { if (prompt_field_) return UTF16ToWideHack(prompt_field_->text()); diff --git a/views/controls/message_box_view.h b/views/controls/message_box_view.h index 7d1b5b0..811ad29 100644 --- a/views/controls/message_box_view.h +++ b/views/controls/message_box_view.h @@ -32,6 +32,8 @@ class MessageBoxView : public views::View { const std::wstring& message, const std::wstring& default_prompt); + virtual ~MessageBoxView(); + // Returns the text box. views::Textfield* text_box() { return prompt_field_; } diff --git a/views/controls/throbber.cc b/views/controls/throbber.cc index 19d42d2..e750f0b 100644 --- a/views/controls/throbber.cc +++ b/views/controls/throbber.cc @@ -104,6 +104,8 @@ SmoothedThrobber::SmoothedThrobber(int frame_time_ms) stop_delay_ms_(kStopDelay) { } +SmoothedThrobber::~SmoothedThrobber() {} + void SmoothedThrobber::Start() { stop_timer_.Stop(); diff --git a/views/controls/throbber.h b/views/controls/throbber.h index 692482d..afc2537 100644 --- a/views/controls/throbber.h +++ b/views/controls/throbber.h @@ -63,6 +63,7 @@ class SmoothedThrobber : public Throbber { public: SmoothedThrobber(int frame_delay_ms); SmoothedThrobber(int frame_delay_ms, SkBitmap* frames); + virtual ~SmoothedThrobber(); virtual void Start(); virtual void Stop(); diff --git a/views/focus/focus_manager.cc b/views/focus/focus_manager.cc index ae3e760..8e130c9 100644 --- a/views/focus/focus_manager.cc +++ b/views/focus/focus_manager.cc @@ -63,6 +63,10 @@ void FocusManager::WidgetFocusManager::OnWidgetFocusEvent( } } +FocusManager::WidgetFocusManager::WidgetFocusManager() : enabled_(true) {} + +FocusManager::WidgetFocusManager::~WidgetFocusManager() {} + // static FocusManager::WidgetFocusManager* FocusManager::WidgetFocusManager::GetInstance() { diff --git a/views/focus/focus_manager.h b/views/focus/focus_manager.h index 46a867e..250adb3 100644 --- a/views/focus/focus_manager.h +++ b/views/focus/focus_manager.h @@ -150,7 +150,8 @@ class FocusManager { void DisableNotifications() { enabled_ = false; } private: - WidgetFocusManager() : enabled_(true) {} + WidgetFocusManager(); + ~WidgetFocusManager(); typedef std::vector<WidgetFocusChangeListener*> WidgetFocusChangeListenerList; diff --git a/views/view.cc b/views/view.cc index 5643e80..895c678 100644 --- a/views/view.cc +++ b/views/view.cc @@ -48,6 +48,15 @@ char View::kViewClassName[] = "views/View"; void View::SetHotTracked(bool flag) { } +bool View::IsHotTracked() const { + return false; +} + +// FATE TBD -------------------------------------------------------------------- + +Widget* View::child_widget() { + return NULL; +} // Creation and lifetime ------------------------------------------------------- @@ -340,6 +349,10 @@ void View::SetVisible(bool flag) { } } +bool View::IsVisible() const { + return is_visible_; +} + bool View::IsVisibleInRootView() const { return IsVisible() && parent() ? parent()->IsVisibleInRootView() : false; } @@ -544,6 +557,10 @@ int View::GetGroup() const { return group_; } +bool View::IsGroupFocusTraversable() const { + return true; +} + void View::GetViewsWithGroup(int group_id, std::vector<View*>* out) { if (group_ == group_id) out->push_back(this); @@ -861,6 +878,10 @@ void View::ResetAccelerators() { UnregisterAccelerators(false); } +bool View::AcceleratorPressed(const Accelerator& accelerator) { + return false; +} + // Focus ----------------------------------------------------------------------- bool View::HasFocus() { @@ -900,6 +921,10 @@ bool View::IsAccessibilityFocusableInRootView() const { IsVisibleInRootView(); } +void View::set_accessibility_focusable(bool accessibility_focusable) { + accessibility_focusable_ = accessibility_focusable; +} + FocusManager* View::GetFocusManager() { Widget* widget = GetWidget(); return widget ? widget->GetFocusManager() : NULL; @@ -911,6 +936,18 @@ void View::RequestFocus() { focus_manager->SetFocusedView(this); } +bool View::SkipDefaultKeyEventProcessing(const KeyEvent& e) { + return false; +} + +FocusTraversable* View::GetFocusTraversable() { + return NULL; +} + +FocusTraversable* View::GetPaneFocusTraversable() { + return NULL; +} + // Tooltips -------------------------------------------------------------------- bool View::GetTooltipText(const gfx::Point& p, std::wstring* tooltip) { @@ -988,6 +1025,14 @@ void View::NotifyAccessibilityEvent(AccessibilityTypes::Event event_type) { NotifyAccessibilityEvent(event_type, true); } +string16 View::GetAccessibleDefaultAction() { + return string16(); +} + +string16 View::GetAccessibleKeyboardShortcut() { + return string16(); +} + bool View::GetAccessibleName(string16* name) { DCHECK(name); @@ -1001,6 +1046,14 @@ AccessibilityTypes::Role View::GetAccessibleRole() { return AccessibilityTypes::ROLE_CLIENT; } +AccessibilityTypes::State View::GetAccessibleState() { + return 0; +} + +string16 View::GetAccessibleValue() { + return string16(); +} + void View::SetAccessibleName(const string16& name) { accessible_name_ = name; } diff --git a/views/view.h b/views/view.h index 695fffb..3e62f99 100644 --- a/views/view.h +++ b/views/view.h @@ -154,13 +154,13 @@ class View : public AcceleratorTarget { // TODO(beng): delete // Returns whether the view is hot-tracked. - virtual bool IsHotTracked() const { return false; } + virtual bool IsHotTracked() const; // FATE TBD ------------------------------------------------------------------ // TODO(beng): Figure out what these methods are for and delete them. // TODO(beng): this one isn't even google3-style. wth. - virtual Widget* child_widget() { return NULL; } + virtual Widget* child_widget(); // Creation and lifetime ----------------------------------------------------- @@ -309,7 +309,7 @@ class View : public AcceleratorTarget { virtual void SetVisible(bool flag); // Return whether a view is visible - virtual bool IsVisible() const { return is_visible_; } + virtual bool IsVisible() const; // Return whether a view and its ancestors are visible. Returns true if the // path from this view to the root view is visible. @@ -459,7 +459,7 @@ class View : public AcceleratorTarget { // when moving focus with the Tab/Shift-Tab key. If this returns false, // only the selected view from the group (obtained with // GetSelectedViewForGroup()) is focused. - virtual bool IsGroupFocusTraversable() const { return true; } + virtual bool IsGroupFocusTraversable() const; // Fills the provided vector with all the available views which belong to the // provided group. @@ -693,9 +693,7 @@ class View : public AcceleratorTarget { // Called when a keyboard accelerator is pressed. // Derived classes should implement desired behavior and return true if they // handled the accelerator. - virtual bool AcceleratorPressed(const Accelerator& accelerator) { - return false; - } + virtual bool AcceleratorPressed(const Accelerator& accelerator); // Focus --------------------------------------------------------------------- @@ -732,9 +730,7 @@ class View : public AcceleratorTarget { // Set whether this view can be made focusable if the user requires // full keyboard access, even though it's not normally focusable. // Note that this is false by default. - virtual void set_accessibility_focusable(bool accessibility_focusable) { - accessibility_focusable_ = accessibility_focusable; - } + virtual void set_accessibility_focusable(bool accessibility_focusable); // Convenience method to retrieve the FocusManager associated with the // Widget that contains this view. This can return NULL if this view is not @@ -759,21 +755,19 @@ class View : public AcceleratorTarget { // have it processed as an accelerator (if any) or as a tab traversal (if the // key event is for the TAB key). In that case, OnKeyPressed will // subsequently be invoked for that event. - virtual bool SkipDefaultKeyEventProcessing(const KeyEvent& e) { - return false; - } + virtual bool SkipDefaultKeyEventProcessing(const KeyEvent& e); // Subclasses that contain traversable children that are not directly // accessible through the children hierarchy should return the associated // FocusTraversable for the focus traversal to work properly. - virtual FocusTraversable* GetFocusTraversable() { return NULL; } + virtual FocusTraversable* GetFocusTraversable(); // Subclasses that can act as a "pane" must implement their own // FocusTraversable to keep the focus trapped within the pane. // If this method returns an object, any view that's a direct or // indirect child of this view will always use this FocusTraversable // rather than the one from the widget. - virtual FocusTraversable* GetPaneFocusTraversable() { return NULL; } + virtual FocusTraversable* GetPaneFocusTraversable(); // Tooltips ------------------------------------------------------------------ @@ -893,13 +887,11 @@ class View : public AcceleratorTarget { // describes the default action that will occur when executing // IAccessible::DoDefaultAction. For instance, default action of a button is // 'Press'. - virtual string16 GetAccessibleDefaultAction() { return string16(); } + virtual string16 GetAccessibleDefaultAction(); // Returns a string containing the mnemonic, or the keyboard shortcut, for a // given control. - virtual string16 GetAccessibleKeyboardShortcut() { - return string16(); - } + virtual string16 GetAccessibleKeyboardShortcut(); // Returns a brief, identifying string, containing a unique, readable name of // a given control. Sets the input string appropriately, and returns true if @@ -912,12 +904,10 @@ class View : public AcceleratorTarget { virtual AccessibilityTypes::Role GetAccessibleRole(); // Returns the accessibility state of the current view. - virtual AccessibilityTypes::State GetAccessibleState() { - return 0; - } + virtual AccessibilityTypes::State GetAccessibleState(); // Returns the current value associated with a view. - virtual string16 GetAccessibleValue() { return string16(); } + virtual string16 GetAccessibleValue(); // Assigns a string name to the given control. Needed as a View does not know // which name will be associated with it until it is created to be a diff --git a/views/views.gyp b/views/views.gyp index f8b145c..5e0d0cc 100644 --- a/views/views.gyp +++ b/views/views.gyp @@ -135,6 +135,7 @@ 'controls/menu/menu_config_win.cc', 'controls/menu/menu_controller.cc', 'controls/menu/menu_controller.h', + 'controls/menu/menu_delegate.cc', 'controls/menu/menu_delegate.h', 'controls/menu/menu_gtk.cc', 'controls/menu/menu_gtk.h', diff --git a/views/widget/default_theme_provider.cc b/views/widget/default_theme_provider.cc index 8a03bab..7d2dfec 100644 --- a/views/widget/default_theme_provider.cc +++ b/views/widget/default_theme_provider.cc @@ -12,10 +12,25 @@ namespace views { +DefaultThemeProvider::DefaultThemeProvider() {} + +DefaultThemeProvider::~DefaultThemeProvider() {} + +void DefaultThemeProvider::Init(Profile* profile) {} + SkBitmap* DefaultThemeProvider::GetBitmapNamed(int id) const { return ResourceBundle::GetSharedInstance().GetBitmapNamed(id); } +SkColor DefaultThemeProvider::GetColor(int id) const { + // Return debugging-blue. + return 0xff0000ff; +} + +bool DefaultThemeProvider::GetDisplayProperty(int id, int* result) const { + return false; +} + bool DefaultThemeProvider::ShouldUseNativeFrame() const { #if defined(OS_WIN) return WidgetWin::IsAeroGlassEnabled(); @@ -24,4 +39,12 @@ bool DefaultThemeProvider::ShouldUseNativeFrame() const { #endif } +bool DefaultThemeProvider::HasCustomImage(int id) const { + return false; +} + +RefCountedMemory* DefaultThemeProvider::GetRawData(int id) const { + return NULL; +} + } // namespace views diff --git a/views/widget/default_theme_provider.h b/views/widget/default_theme_provider.h index c407f7d..9d0ec52 100644 --- a/views/widget/default_theme_provider.h +++ b/views/widget/default_theme_provider.h @@ -22,20 +22,17 @@ namespace views { class DefaultThemeProvider : public ui::ThemeProvider { public: - DefaultThemeProvider() { }; - virtual ~DefaultThemeProvider() { }; + DefaultThemeProvider(); + virtual ~DefaultThemeProvider(); // Overridden from ui::ThemeProvider. - virtual void Init(Profile* profile) { } + virtual void Init(Profile* profile); virtual SkBitmap* GetBitmapNamed(int id) const; - virtual SkColor GetColor(int id) const { - // Return debugging-blue. - return 0xff0000ff; - } - virtual bool GetDisplayProperty(int id, int* result) const { return false; } + virtual SkColor GetColor(int id) const; + virtual bool GetDisplayProperty(int id, int* result) const; virtual bool ShouldUseNativeFrame() const; - virtual bool HasCustomImage(int id) const { return false; } - virtual RefCountedMemory* GetRawData(int id) const { return NULL; } + virtual bool HasCustomImage(int id) const; + virtual RefCountedMemory* GetRawData(int id) const; private: DISALLOW_COPY_AND_ASSIGN(DefaultThemeProvider); diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc index de79e73..66be067 100644 --- a/views/widget/widget_gtk.cc +++ b/views/widget/widget_gtk.cc @@ -1224,6 +1224,10 @@ void WidgetGtk::OnShow(GtkWidget* widget) { void WidgetGtk::OnHide(GtkWidget* widget) { } +bool WidgetGtk::ReleaseCaptureOnMouseReleased() { + return true; +} + void WidgetGtk::DoGrab() { has_capture_ = true; gtk_grab_add(window_contents_); diff --git a/views/widget/widget_gtk.h b/views/widget/widget_gtk.h index 3a5bafa..f9b557d 100644 --- a/views/widget/widget_gtk.h +++ b/views/widget/widget_gtk.h @@ -265,7 +265,7 @@ class WidgetGtk : public Widget, // Returns whether capture should be released on mouse release. The default // is true. - virtual bool ReleaseCaptureOnMouseReleased() { return true; } + virtual bool ReleaseCaptureOnMouseReleased(); // Does a mouse grab on this widget. virtual void DoGrab(); diff --git a/views/window/client_view.cc b/views/window/client_view.cc index de198ed..9fb3e70 100644 --- a/views/window/client_view.cc +++ b/views/window/client_view.cc @@ -24,6 +24,14 @@ int ClientView::NonClientHitTest(const gfx::Point& point) { return bounds().Contains(point) ? HTCLIENT : HTNOWHERE; } +DialogClientView* ClientView::AsDialogClientView() { + return NULL; +} + +bool ClientView::CanClose() { + return true; +} + void ClientView::WindowClosing() { window_->GetDelegate()->WindowClosing(); } diff --git a/views/window/client_view.h b/views/window/client_view.h index 08ddcd4..405ec4e 100644 --- a/views/window/client_view.h +++ b/views/window/client_view.h @@ -31,13 +31,13 @@ class ClientView : public View { virtual ~ClientView() {} // Manual RTTI ftw. - virtual DialogClientView* AsDialogClientView() { return NULL; } + virtual DialogClientView* AsDialogClientView(); // Returns true to signal that the Window can be closed. Specialized // ClientView subclasses can override this default behavior to allow the // close to be blocked until the user corrects mistakes, accepts a warning // dialog, etc. - virtual bool CanClose() { return true; } + virtual bool CanClose(); // Notification that the window is closing. The default implementation // forwards the notification to the delegate. diff --git a/views/window/dialog_client_view.cc b/views/window/dialog_client_view.cc index 730972e..cdf684c 100644 --- a/views/window/dialog_client_view.cc +++ b/views/window/dialog_client_view.cc @@ -297,6 +297,10 @@ int DialogClientView::NonClientHitTest(const gfx::Point& point) { return ClientView::NonClientHitTest(point); } +DialogClientView* DialogClientView::AsDialogClientView() { + return this; +} + //////////////////////////////////////////////////////////////////////////////// // DialogClientView, View overrides: diff --git a/views/window/dialog_client_view.h b/views/window/dialog_client_view.h index d6d87a5..06a2d73 100644 --- a/views/window/dialog_client_view.h +++ b/views/window/dialog_client_view.h @@ -68,7 +68,7 @@ class DialogClientView : public ClientView, virtual bool CanClose(); virtual void WindowClosing(); virtual int NonClientHitTest(const gfx::Point& point); - virtual DialogClientView* AsDialogClientView() { return this; } + virtual DialogClientView* AsDialogClientView(); // FocusChangeListener implementation: virtual void FocusWillChange(View* focused_before, View* focused_now); diff --git a/views/window/dialog_delegate.cc b/views/window/dialog_delegate.cc index 4ae9a91..43bdce3 100644 --- a/views/window/dialog_delegate.cc +++ b/views/window/dialog_delegate.cc @@ -12,6 +12,34 @@ namespace views { // Overridden from WindowDelegate: +DialogDelegate* DialogDelegate::AsDialogDelegate() { return this; } + +int DialogDelegate::GetDialogButtons() const { + return ui::MessageBoxFlags::DIALOGBUTTON_OK | + ui::MessageBoxFlags::DIALOGBUTTON_CANCEL; +} + +bool DialogDelegate::AreAcceleratorsEnabled( + ui::MessageBoxFlags::DialogButton button) { + return true; +} + +std::wstring DialogDelegate::GetDialogButtonLabel( + ui::MessageBoxFlags::DialogButton button) const { + // empty string results in defaults for + // ui::MessageBoxFlags::DIALOGBUTTON_OK, + // ui::MessageBoxFlags::DIALOGBUTTON_CANCEL. + return L""; +} + +View* DialogDelegate::GetExtraView() { + return NULL; +} + +bool DialogDelegate::GetSizeExtraViewHeightToButtons() { + return false; +} + int DialogDelegate::GetDefaultDialogButton() const { if (GetDialogButtons() & MessageBoxFlags::DIALOGBUTTON_OK) return MessageBoxFlags::DIALOGBUTTON_OK; @@ -20,6 +48,28 @@ int DialogDelegate::GetDefaultDialogButton() const { return MessageBoxFlags::DIALOGBUTTON_NONE; } +bool DialogDelegate::IsDialogButtonEnabled( + ui::MessageBoxFlags::DialogButton button) const { + return true; +} + +bool DialogDelegate::IsDialogButtonVisible( + ui::MessageBoxFlags::DialogButton button) const { + return true; +} + +bool DialogDelegate::Cancel() { + return true; +} + +bool DialogDelegate::Accept(bool window_closiang) { + return Accept(); +} + +bool DialogDelegate::Accept() { + return true; +} + View* DialogDelegate::GetInitiallyFocusedView() { // Focus the default button if any. DialogClientView* dcv = GetDialogClientView(); @@ -51,4 +101,8 @@ DialogClientView* DialogDelegate::GetDialogClientView() const { return dialog_client_view; } +AccessibilityTypes::Role DialogDelegate::accessible_role() const { + return AccessibilityTypes::ROLE_DIALOG; +} + } // namespace views diff --git a/views/window/dialog_delegate.h b/views/window/dialog_delegate.h index ac6d4e9..1b8e8a4 100644 --- a/views/window/dialog_delegate.h +++ b/views/window/dialog_delegate.h @@ -29,7 +29,7 @@ class View; /////////////////////////////////////////////////////////////////////////////// class DialogDelegate : public WindowDelegate { public: - virtual DialogDelegate* AsDialogDelegate() { return this; } + virtual DialogDelegate* AsDialogDelegate(); // Returns a mask specifying which of the available DialogButtons are visible // for the dialog. Note: If an OK button is provided, you should provide a @@ -38,38 +38,28 @@ class DialogDelegate : public WindowDelegate { // you should reconsider, or beng says there will be stabbings. // // To use the extra button you need to override GetDialogButtons() - virtual int GetDialogButtons() const { - return ui::MessageBoxFlags::DIALOGBUTTON_OK | - ui::MessageBoxFlags::DIALOGBUTTON_CANCEL; - } + virtual int GetDialogButtons() const; // Returns whether accelerators are enabled on the button. This is invoked // when an accelerator is pressed, not at construction time. This // returns true. virtual bool AreAcceleratorsEnabled( - ui::MessageBoxFlags::DialogButton button) { - return true; - } + ui::MessageBoxFlags::DialogButton button); // Returns the label of the specified DialogButton. virtual std::wstring GetDialogButtonLabel( - ui::MessageBoxFlags::DialogButton button) const { - // empty string results in defaults for - // ui::MessageBoxFlags::DIALOGBUTTON_OK, - // ui::MessageBoxFlags::DIALOGBUTTON_CANCEL. - return L""; - } + ui::MessageBoxFlags::DialogButton button) const; // Override this function if with a view which will be shown in the same // row as the OK and CANCEL buttons but flush to the left and extending // up to the buttons. - virtual View* GetExtraView() { return NULL; } + virtual View* GetExtraView(); // Returns whether the height of the extra view should be at least as tall as // the buttons. The default (false) is to give the extra view it's preferred // height. By returning true the height becomes // max(extra_view preferred height, buttons preferred height). - virtual bool GetSizeExtraViewHeightToButtons() { return false; } + virtual bool GetSizeExtraViewHeightToButtons(); // Returns the default dialog button. This should not be a mask as only // one button should ever be the default button. Return @@ -81,22 +71,18 @@ class DialogDelegate : public WindowDelegate { // Returns whether the specified dialog button is enabled. virtual bool IsDialogButtonEnabled( - ui::MessageBoxFlags::DialogButton button) const { - return true; - } + ui::MessageBoxFlags::DialogButton button) const; // Returns whether the specified dialog button is visible. virtual bool IsDialogButtonVisible( - ui::MessageBoxFlags::DialogButton button) const { - return true; - } + ui::MessageBoxFlags::DialogButton button) const; // For Dialog boxes, if there is a "Cancel" button, this is called when the // user presses the "Cancel" button or the Close button on the window or // in the system menu, or presses the Esc key. This function should return // true if the window can be closed after it returns, or false if it must // remain open. - virtual bool Cancel() { return true; } + virtual bool Cancel(); // For Dialog boxes, this is called when the user presses the "OK" button, // or the Enter key. Can also be called on Esc key or close button @@ -106,8 +92,8 @@ class DialogDelegate : public WindowDelegate { // true, it means that this handler is being called because the window is // being closed (e.g. by Window::Close) and there is no Cancel handler, // so Accept is being called instead. - virtual bool Accept(bool window_closing) { return Accept(); } - virtual bool Accept() { return true; } + virtual bool Accept(bool window_closing); + virtual bool Accept(); // Overridden from WindowDelegate: virtual View* GetInitiallyFocusedView(); @@ -124,9 +110,7 @@ class DialogDelegate : public WindowDelegate { private: // Overridden from WindowDelegate: - AccessibilityTypes::Role accessible_role() const { - return AccessibilityTypes::ROLE_DIALOG; - } + virtual AccessibilityTypes::Role accessible_role() const; }; } // namespace views diff --git a/views/window/non_client_view.cc b/views/window/non_client_view.cc index 210bd10..e882105 100644 --- a/views/window/non_client_view.cc +++ b/views/window/non_client_view.cc @@ -181,6 +181,14 @@ AccessibilityTypes::Role NonClientView::GetAccessibleRole() { //////////////////////////////////////////////////////////////////////////////// // NonClientFrameView, View overrides: +bool NonClientFrameView::AlwaysUseCustomFrame() const { + return false; +} + +bool NonClientFrameView::AlwaysUseNativeFrame() const { + return false; +} + bool NonClientFrameView::HitTest(const gfx::Point& l) const { // For the default case, we assume the non-client frame view never overlaps // the client view. diff --git a/views/window/non_client_view.h b/views/window/non_client_view.h index db1daff..d45c30e 100644 --- a/views/window/non_client_view.h +++ b/views/window/non_client_view.h @@ -48,12 +48,12 @@ class NonClientFrameView : public View { // Returns true if this FrameView should always use the custom frame, // regardless of the system settings. An example is the Constrained Window, // which is a child window and must always provide its own frame. - virtual bool AlwaysUseCustomFrame() const { return false; } + virtual bool AlwaysUseCustomFrame() const; // Like AlwaysUseCustomFrame, returns true if this FrameView should always use // the native frame, regardless of theme settings. An example is popup/app // windows, which we do not ever want to show themed. - virtual bool AlwaysUseNativeFrame() const { return false; } + virtual bool AlwaysUseNativeFrame() const; virtual gfx::Rect GetWindowBoundsForClientBounds( const gfx::Rect& client_bounds) const = 0; diff --git a/views/window/window.cc b/views/window/window.cc index ea6fcc1..07380f1 100644 --- a/views/window/window.cc +++ b/views/window/window.cc @@ -49,4 +49,8 @@ void Window::CloseSecondaryWidget(Widget* widget) { } } +bool Window::IsAppWindow() const { + return false; +} + } // namespace views diff --git a/views/window/window.h b/views/window/window.h index e5c1137..03e4f16 100644 --- a/views/window/window.h +++ b/views/window/window.h @@ -138,7 +138,7 @@ class Window { // Returns true if the Window is considered to be an "app window" - i.e. // any window which when it is the last of its type closed causes the // application to exit. - virtual bool IsAppWindow() const { return false; } + virtual bool IsAppWindow() const; // Toggles the enable state for the Close button (and the Close menu item in // the system menu). diff --git a/views/window/window_delegate.cc b/views/window/window_delegate.cc index 69bcc03..aa710ee 100644 --- a/views/window/window_delegate.cc +++ b/views/window/window_delegate.cc @@ -16,6 +16,50 @@ WindowDelegate::WindowDelegate() : window_(NULL) { WindowDelegate::~WindowDelegate() { } +DialogDelegate* WindowDelegate::AsDialogDelegate() { + return NULL; +} + +bool WindowDelegate::CanResize() const { + return false; +} + +bool WindowDelegate::CanMaximize() const { + return false; +} + +bool WindowDelegate::IsModal() const { + return false; +} + +AccessibilityTypes::Role WindowDelegate::accessible_role() const { + return AccessibilityTypes::ROLE_WINDOW; +} + +AccessibilityTypes::State WindowDelegate::accessible_state() const { + return 0; +} + +std::wstring WindowDelegate::GetAccessibleWindowTitle() const { + return GetWindowTitle(); +} + +std::wstring WindowDelegate::GetWindowTitle() const { + return L""; +} + +View* WindowDelegate::GetInitiallyFocusedView() { + return NULL; +} + +bool WindowDelegate::ShouldShowWindowTitle() const { + return true; +} + +bool WindowDelegate::ShouldShowClientEdge() const { + return true; +} + SkBitmap WindowDelegate::GetWindowAppIcon() { // Use the window icon as app icon by default. return GetWindowIcon(); @@ -26,6 +70,18 @@ SkBitmap WindowDelegate::GetWindowIcon() { return SkBitmap(); } +bool WindowDelegate::ShouldShowWindowIcon() const { + return false; +} + +bool WindowDelegate::ExecuteWindowsCommand(int command_id) { + return false; +} + +std::wstring WindowDelegate::GetWindowName() const { + return std::wstring(); +} + void WindowDelegate::SaveWindowPlacement(const gfx::Rect& bounds, bool maximized) { std::wstring window_name = GetWindowName(); @@ -58,6 +114,10 @@ bool WindowDelegate::ShouldRestoreWindowSize() const { return true; } +View* WindowDelegate::GetContentsView() { + return NULL; +} + ClientView* WindowDelegate::CreateClientView(Window* window) { return new ClientView(window, GetContentsView()); } diff --git a/views/window/window_delegate.h b/views/window/window_delegate.h index 04ac6b3..9b02387 100644 --- a/views/window/window_delegate.h +++ b/views/window/window_delegate.h @@ -38,55 +38,37 @@ class WindowDelegate { WindowDelegate(); virtual ~WindowDelegate(); - virtual DialogDelegate* AsDialogDelegate() { return NULL; } + virtual DialogDelegate* AsDialogDelegate(); // Returns true if the window can ever be resized. - virtual bool CanResize() const { - return false; - } + virtual bool CanResize() const; // Returns true if the window can ever be maximized. - virtual bool CanMaximize() const { - return false; - } + virtual bool CanMaximize() const; // Returns true if the dialog should be displayed modally to the window that // opened it. Only windows with WindowType == DIALOG can be modal. - virtual bool IsModal() const { - return false; - } + virtual bool IsModal() const; - virtual AccessibilityTypes::Role accessible_role() const { - return AccessibilityTypes::ROLE_WINDOW; - } + virtual AccessibilityTypes::Role accessible_role() const; - virtual AccessibilityTypes::State accessible_state() const { - return 0; - } + virtual AccessibilityTypes::State accessible_state() const; // Returns the title to be read with screen readers. - virtual std::wstring GetAccessibleWindowTitle() const { - return GetWindowTitle(); - } + virtual std::wstring GetAccessibleWindowTitle() const; // Returns the text to be displayed in the window title. - virtual std::wstring GetWindowTitle() const { - return L""; - } + virtual std::wstring GetWindowTitle() const; // Returns the view that should have the focus when the dialog is opened. If // NULL no view is focused. - virtual View* GetInitiallyFocusedView() { return NULL; } + virtual View* GetInitiallyFocusedView(); // Returns true if the window should show a title in the title bar. - virtual bool ShouldShowWindowTitle() const { - return true; - } + virtual bool ShouldShowWindowTitle() const; // Returns true if the window's client view wants a client edge. - virtual bool ShouldShowClientEdge() const { - return true; - } + virtual bool ShouldShowClientEdge() const; // Returns the app icon for the window. On Windows, this is the ICON_BIG used // in Alt-Tab list and Win7's taskbar. @@ -96,19 +78,15 @@ class WindowDelegate { virtual SkBitmap GetWindowIcon(); // Returns true if a window icon should be shown. - virtual bool ShouldShowWindowIcon() const { - return false; - } + virtual bool ShouldShowWindowIcon() const; // Execute a command in the window's controller. Returns true if the command // was handled, false if it was not. - virtual bool ExecuteWindowsCommand(int command_id) { return false; } + virtual bool ExecuteWindowsCommand(int command_id); // Returns the window's name identifier. Used to identify this window for // state restoration. - virtual std::wstring GetWindowName() const { - return std::wstring(); - } + virtual std::wstring GetWindowName() const; // Saves the window's bounds and maximized states. By default this uses the // process' local state keyed by window name (See GetWindowName above). This @@ -135,9 +113,7 @@ class WindowDelegate { virtual void DeleteDelegate() {} // Returns the View that is contained within this Window. - virtual View* GetContentsView() { - return NULL; - } + virtual View* GetContentsView(); // Called by the Window to create the Client View used to host the contents // of the window. diff --git a/views/window/window_gtk.cc b/views/window/window_gtk.cc index 6c0b7a6..345160e 100644 --- a/views/window/window_gtk.cc +++ b/views/window/window_gtk.cc @@ -269,6 +269,14 @@ void WindowGtk::FrameTypeChanged() { ThemeChanged(); } +Window* WindowGtk::AsWindow() { + return this; +} + +const Window* WindowGtk::AsWindow() const { + return this; +} + //////////////////////////////////////////////////////////////////////////////// // WindowGtk, WidgetGtk overrides: diff --git a/views/window/window_gtk.h b/views/window/window_gtk.h index 164a924..05edbcc 100644 --- a/views/window/window_gtk.h +++ b/views/window/window_gtk.h @@ -60,8 +60,8 @@ class WindowGtk : public WidgetGtk, public Window { virtual bool ShouldUseNativeFrame() const; virtual void FrameTypeChanged(); - virtual Window* AsWindow() { return this; } - virtual const Window* AsWindow() const { return this; } + virtual Window* AsWindow(); + virtual const Window* AsWindow() const; // Overridden from WidgetGtk: virtual gboolean OnButtonPress(GtkWidget* widget, GdkEventButton* event); |