summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-02 04:47:36 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-02 04:47:36 +0000
commita0d0d38b5d45d7be151bad91a2231d3679432d13 (patch)
tree65866dc75a0ca59d3bd51804db05560e41b9ebf2
parent73c8cb87ca07481b24f7823c1f2f99f0b530ef11 (diff)
downloadchromium_src-a0d0d38b5d45d7be151bad91a2231d3679432d13.zip
chromium_src-a0d0d38b5d45d7be151bad91a2231d3679432d13.tar.gz
chromium_src-a0d0d38b5d45d7be151bad91a2231d3679432d13.tar.bz2
Make Combobox portable
BUG=none TEST=none Review URL: http://codereview.chromium.org/113991 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17382 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/views/bookmark_bubble_view.cc16
-rw-r--r--chrome/browser/views/bookmark_bubble_view.h20
-rw-r--r--chrome/browser/views/bug_report_view.cc14
-rw-r--r--chrome/browser/views/bug_report_view.h10
-rw-r--r--chrome/browser/views/clear_browsing_data.cc14
-rw-r--r--chrome/browser/views/clear_browsing_data.h22
-rw-r--r--chrome/browser/views/first_run_customize_view.cc9
-rw-r--r--chrome/browser/views/first_run_customize_view.h12
-rw-r--r--chrome/browser/views/importer_view.cc14
-rw-r--r--chrome/browser/views/importer_view.h18
-rw-r--r--chrome/browser/views/options/advanced_contents_view.cc42
-rw-r--r--chrome/browser/views/options/fonts_page_view.cc14
-rw-r--r--chrome/browser/views/options/fonts_page_view.h10
-rw-r--r--chrome/browser/views/options/general_page_view.cc60
-rw-r--r--chrome/browser/views/options/general_page_view.h10
-rw-r--r--chrome/browser/views/options/language_combobox_model.cc4
-rw-r--r--chrome/browser/views/options/language_combobox_model.h8
-rw-r--r--chrome/browser/views/options/languages_page_view.cc25
-rw-r--r--chrome/browser/views/options/languages_page_view.h12
-rw-r--r--chrome/browser/views/select_profile_dialog.cc9
-rw-r--r--chrome/browser/views/select_profile_dialog.h12
-rw-r--r--views/controls/combo_box.cc179
-rw-r--r--views/controls/combo_box.h80
-rw-r--r--views/controls/combobox/combobox.cc104
-rw-r--r--views/controls/combobox/combobox.h89
-rw-r--r--views/controls/combobox/native_combobox_gtk.cc78
-rw-r--r--views/controls/combobox/native_combobox_gtk.h43
-rw-r--r--views/controls/combobox/native_combobox_win.cc184
-rw-r--r--views/controls/combobox/native_combobox_win.h52
-rw-r--r--views/controls/combobox/native_combobox_wrapper.h48
-rw-r--r--views/controls/native/native_view_host_win.cc4
-rw-r--r--views/controls/native_control_win.cc18
-rw-r--r--views/controls/native_control_win.h6
-rw-r--r--views/views.gyp9
34 files changed, 800 insertions, 449 deletions
diff --git a/chrome/browser/views/bookmark_bubble_view.cc b/chrome/browser/views/bookmark_bubble_view.cc
index 01c82c2..9a2a8f6 100644
--- a/chrome/browser/views/bookmark_bubble_view.cc
+++ b/chrome/browser/views/bookmark_bubble_view.cc
@@ -21,7 +21,7 @@
#include "views/controls/button/native_button.h"
#include "views/controls/textfield/textfield.h"
-using views::ComboBox;
+using views::Combobox;
using views::ColumnSet;
using views::GridLayout;
using views::Label;
@@ -106,12 +106,12 @@ BookmarkBubbleView::RecentlyUsedFoldersModel::RecentlyUsedFoldersModel(
}
int BookmarkBubbleView::RecentlyUsedFoldersModel::GetItemCount(
- ComboBox* source) {
+ Combobox* source) {
return static_cast<int>(nodes_.size() + 1);
}
std::wstring BookmarkBubbleView::RecentlyUsedFoldersModel::GetItemAt(
- ComboBox* source, int index) {
+ Combobox* source, int index) {
if (index == nodes_.size())
return l10n_util::GetString(IDS_BOOMARK_BUBBLE_CHOOSER_ANOTHER_FOLDER);
return nodes_[index]->GetTitle();
@@ -234,9 +234,9 @@ void BookmarkBubbleView::Init() {
close_button_ = new NativeButton(this, l10n_util::GetString(IDS_CLOSE));
close_button_->SetIsDefault(true);
- parent_combobox_ = new ComboBox(&parent_model_);
+ parent_combobox_ = new Combobox(&parent_model_);
parent_combobox_->SetSelectedItem(parent_model_.node_parent_index());
- parent_combobox_->SetListener(this);
+ parent_combobox_->set_listener(this);
Label* title_label = new Label(l10n_util::GetString(
newly_bookmarked_ ? IDS_BOOMARK_BUBBLE_PAGE_BOOKMARKED :
@@ -334,7 +334,7 @@ void BookmarkBubbleView::LinkActivated(Link* source, int event_flags) {
Close();
}
-void BookmarkBubbleView::ItemChanged(ComboBox* combo_box,
+void BookmarkBubbleView::ItemChanged(Combobox* combobox,
int prev_index,
int new_index) {
if (new_index + 1 == parent_model_.GetItemCount(parent_combobox_)) {
@@ -417,10 +417,10 @@ void BookmarkBubbleView::ApplyEdits() {
profile_);
}
// Last index means 'Choose another folder...'
- if (parent_combobox_->GetSelectedItem() <
+ if (parent_combobox_->selected_item() <
parent_model_.GetItemCount(parent_combobox_) - 1) {
BookmarkNode* new_parent =
- parent_model_.GetNodeAt(parent_combobox_->GetSelectedItem());
+ parent_model_.GetNodeAt(parent_combobox_->selected_item());
if (new_parent != node->GetParent()) {
UserMetrics::RecordAction(L"BookmarkBubble_ChangeParent", profile_);
model->Move(node, new_parent, new_parent->GetChildCount());
diff --git a/chrome/browser/views/bookmark_bubble_view.h b/chrome/browser/views/bookmark_bubble_view.h
index 187a193e..5083a52 100644
--- a/chrome/browser/views/bookmark_bubble_view.h
+++ b/chrome/browser/views/bookmark_bubble_view.h
@@ -9,7 +9,7 @@
#include "chrome/browser/views/info_bubble.h"
#include "googleurl/src/gurl.h"
#include "views/controls/button/button.h"
-#include "views/controls/combo_box.h"
+#include "views/controls/combobox/combobox.h"
#include "views/controls/link.h"
#include "views/view.h"
@@ -30,7 +30,7 @@ class Textfield;
class BookmarkBubbleView : public views::View,
public views::LinkController,
public views::ButtonListener,
- public views::ComboBox::Listener,
+ public views::Combobox::Listener,
public InfoBubbleDelegate {
public:
static void Show(views::Window* window,
@@ -60,13 +60,13 @@ class BookmarkBubbleView : public views::View,
// Model for the combobox showing the list of folders to choose from. The
// list always contains the bookmark bar, other node and parent. The list
// also contains an extra item that shows the text 'Choose another folder...'.
- class RecentlyUsedFoldersModel : public views::ComboBox::Model {
+ class RecentlyUsedFoldersModel : public views::Combobox::Model {
public:
RecentlyUsedFoldersModel(BookmarkModel* bb_model, BookmarkNode* node);
- // ComboBox::Model methods. Call through to nodes_.
- virtual int GetItemCount(views::ComboBox* source);
- virtual std::wstring GetItemAt(views::ComboBox* source, int index);
+ // Combobox::Model methods. Call through to nodes_.
+ virtual int GetItemCount(views::Combobox* source);
+ virtual std::wstring GetItemAt(views::Combobox* source, int index);
// Returns the node at the specified index.
BookmarkNode* GetNodeAt(int index);
@@ -104,8 +104,8 @@ class BookmarkBubbleView : public views::View,
// ButtonListener method, closes the bubble or opens the edit dialog.
virtual void ButtonPressed(views::Button* sender);
- // ComboBox::Listener method. Changes the parent of the bookmark.
- virtual void ItemChanged(views::ComboBox* combo_box,
+ // Combobox::Listener method. Changes the parent of the bookmark.
+ virtual void ItemChanged(views::Combobox* combobox,
int prev_index,
int new_index);
@@ -158,9 +158,9 @@ class BookmarkBubbleView : public views::View,
// Textfield showing the title of the bookmark.
views::Textfield* title_tf_;
- // ComboBox showing a handful of folders the user can choose from, including
+ // Combobox showing a handful of folders the user can choose from, including
// the current parent.
- views::ComboBox* parent_combobox_;
+ views::Combobox* parent_combobox_;
// When the destructor is invoked should the bookmark be removed?
bool remove_bookmark_;
diff --git a/chrome/browser/views/bug_report_view.cc b/chrome/browser/views/bug_report_view.cc
index ac223b6..71545ff 100644
--- a/chrome/browser/views/bug_report_view.cc
+++ b/chrome/browser/views/bug_report_view.cc
@@ -45,7 +45,7 @@ static const int kDescriptionLines = 5;
static const char kReportPhishingUrl[] =
"http://www.google.com/safebrowsing/report_phish/";
-class BugReportComboBoxModel : public views::ComboBox::Model {
+class BugReportComboBoxModel : public views::Combobox::Model {
public:
BugReportComboBoxModel() {}
@@ -60,12 +60,12 @@ class BugReportComboBoxModel : public views::ComboBox::Model {
OTHER_PROBLEM
};
- // views::ComboBox::Model interface.
- virtual int GetItemCount(views::ComboBox* source) {
+ // views::Combobox::Model interface.
+ virtual int GetItemCount(views::Combobox* source) {
return OTHER_PROBLEM + 1;
}
- virtual std::wstring GetItemAt(views::ComboBox* source, int index) {
+ virtual std::wstring GetItemAt(views::Combobox* source, int index) {
return GetItemAtIndex(index);
}
@@ -191,8 +191,8 @@ void BugReportView::SetupControl() {
// Adds all controls.
bug_type_label_ = new views::Label(
l10n_util::GetString(IDS_BUGREPORT_BUG_TYPE));
- bug_type_combo_ = new views::ComboBox(bug_type_model_.get());
- bug_type_combo_->SetListener(this);
+ bug_type_combo_ = new views::Combobox(bug_type_model_.get());
+ bug_type_combo_->set_listener(this);
page_title_label_ = new views::Label(
l10n_util::GetString(IDS_BUGREPORT_REPORT_PAGE_TITLE));
@@ -272,7 +272,7 @@ gfx::Size BugReportView::GetPreferredSize() {
IDS_BUGREPORT_DIALOG_HEIGHT_LINES));
}
-void BugReportView::ItemChanged(views::ComboBox* combo_box,
+void BugReportView::ItemChanged(views::Combobox* combobox,
int prev_index,
int new_index) {
if (new_index == prev_index)
diff --git a/chrome/browser/views/bug_report_view.h b/chrome/browser/views/bug_report_view.h
index 59df265..b801bd6 100644
--- a/chrome/browser/views/bug_report_view.h
+++ b/chrome/browser/views/bug_report_view.h
@@ -7,7 +7,7 @@
#include "chrome/browser/net/url_fetcher.h"
#include "googleurl/src/gurl.h"
-#include "views/controls/combo_box.h"
+#include "views/controls/combobox/combobox.h"
#include "views/controls/textfield/textfield.h"
#include "views/view.h"
#include "views/window/dialog_delegate.h"
@@ -34,7 +34,7 @@ class BugReportComboBoxModel;
// So now use dialog as a placeholder.
class BugReportView : public views::View,
public views::DialogDelegate,
- public views::ComboBox::Listener,
+ public views::Combobox::Listener,
public views::Textfield::Controller {
public:
explicit BugReportView(Profile* profile, TabContents* tab);
@@ -54,8 +54,8 @@ class BugReportView : public views::View,
virtual bool HandleKeystroke(views::Textfield* sender,
const views::Textfield::Keystroke& key);
- // views::ComboBox::Listener implementation:
- virtual void ItemChanged(views::ComboBox* combo_box, int prev_index,
+ // views::Combobox::Listener implementation:
+ virtual void ItemChanged(views::Combobox* combobox, int prev_index,
int new_index);
// Overridden from views::DialogDelegate:
@@ -88,7 +88,7 @@ class BugReportView : public views::View,
void ReportPhishing();
views::Label* bug_type_label_;
- views::ComboBox* bug_type_combo_;
+ views::Combobox* bug_type_combo_;
views::Label* page_title_label_;
views::Label* page_title_text_;
views::Label* page_url_label_;
diff --git a/chrome/browser/views/clear_browsing_data.cc b/chrome/browser/views/clear_browsing_data.cc
index 43692e1..f6da40f 100644
--- a/chrome/browser/views/clear_browsing_data.cc
+++ b/chrome/browser/views/clear_browsing_data.cc
@@ -113,10 +113,10 @@ void ClearBrowsingDataView::Init() {
AddChildView(time_period_label_);
// Add the combo box showing how far back in time we want to delete.
- time_period_combobox_ = new views::ComboBox(this);
+ time_period_combobox_ = new views::Combobox(this);
time_period_combobox_->SetSelectedItem(profile_->GetPrefs()->GetInteger(
prefs::kDeleteTimePeriod));
- time_period_combobox_->SetListener(this);
+ time_period_combobox_->set_listener(this);
AddChildView(time_period_combobox_);
}
@@ -311,14 +311,14 @@ views::View* ClearBrowsingDataView::GetContentsView() {
}
////////////////////////////////////////////////////////////////////////////////
-// ClearBrowsingDataView, views::ComboBox::Model implementation:
+// ClearBrowsingDataView, views::Combobox::Model implementation:
-int ClearBrowsingDataView::GetItemCount(views::ComboBox* source) {
+int ClearBrowsingDataView::GetItemCount(views::Combobox* source) {
DCHECK(source == time_period_combobox_);
return 4;
}
-std::wstring ClearBrowsingDataView::GetItemAt(views::ComboBox* source,
+std::wstring ClearBrowsingDataView::GetItemAt(views::Combobox* source,
int index) {
DCHECK(source == time_period_combobox_);
switch (index) {
@@ -334,7 +334,7 @@ std::wstring ClearBrowsingDataView::GetItemAt(views::ComboBox* source,
////////////////////////////////////////////////////////////////////////////////
// ClearBrowsingDataView, views::ComboBoxListener implementation:
-void ClearBrowsingDataView::ItemChanged(views::ComboBox* sender,
+void ClearBrowsingDataView::ItemChanged(views::Combobox* sender,
int prev_index, int new_index) {
if (sender == time_period_combobox_ && prev_index != new_index)
profile_->GetPrefs()->SetInteger(prefs::kDeleteTimePeriod, new_index);
@@ -409,7 +409,7 @@ static bool IsCheckBoxEnabledAndSelected(views::Checkbox* cb) {
}
void ClearBrowsingDataView::OnDelete() {
- int period_selected = time_period_combobox_->GetSelectedItem();
+ int period_selected = time_period_combobox_->selected_item();
int remove_mask = 0;
if (IsCheckBoxEnabledAndSelected(del_history_checkbox_))
diff --git a/chrome/browser/views/clear_browsing_data.h b/chrome/browser/views/clear_browsing_data.h
index f51979e..f188478 100644
--- a/chrome/browser/views/clear_browsing_data.h
+++ b/chrome/browser/views/clear_browsing_data.h
@@ -7,7 +7,7 @@
#include "chrome/browser/browsing_data_remover.h"
#include "views/controls/button/button.h"
-#include "views/controls/combo_box.h"
+#include "views/controls/combobox/combobox.h"
#include "views/controls/label.h"
#include "views/view.h"
#include "views/window/dialog_delegate.h"
@@ -31,9 +31,9 @@ class MessageLoop;
////////////////////////////////////////////////////////////////////////////////
class ClearBrowsingDataView : public views::View,
public views::DialogDelegate,
- public views::ComboBox::Model,
public views::ButtonListener,
- public views::ComboBox::Listener,
+ public views::Combobox::Model,
+ public views::Combobox::Listener,
public BrowsingDataRemover::Observer {
public:
explicit ClearBrowsingDataView(Profile* profile);
@@ -62,17 +62,17 @@ class ClearBrowsingDataView : public views::View,
virtual bool Accept();
virtual views::View* GetContentsView();
- // Overridden from views::ComboBox::Model:
- virtual int GetItemCount(views::ComboBox* source);
- virtual std::wstring GetItemAt(views::ComboBox* source, int index);
+ // Overridden from views::Combobox::Model:
+ virtual int GetItemCount(views::Combobox* source);
+ virtual std::wstring GetItemAt(views::Combobox* source, int index);
+
+ // Overridden from views::Combobox::Listener:
+ virtual void ItemChanged(views::Combobox* sender, int prev_index,
+ int new_index);
// Overridden from views::ButtonListener:
virtual void ButtonPressed(views::Button* sender);
- // Overridden from views::ComboBox::Listener:
- virtual void ItemChanged(views::ComboBox* sender, int prev_index,
- int new_index);
-
private:
// Adds a new check-box as a child to the view.
views::Checkbox* AddCheckbox(const std::wstring& text, bool checked);
@@ -100,7 +100,7 @@ class ClearBrowsingDataView : public views::View,
views::Checkbox* del_passwords_checkbox_;
views::Checkbox* del_form_data_checkbox_;
views::Label* time_period_label_;
- views::ComboBox* time_period_combobox_;
+ views::Combobox* time_period_combobox_;
// Used to signal enabled/disabled state for controls in the UI.
bool delete_in_progress_;
diff --git a/chrome/browser/views/first_run_customize_view.cc b/chrome/browser/views/first_run_customize_view.cc
index 7a378ef..4639344 100644
--- a/chrome/browser/views/first_run_customize_view.cc
+++ b/chrome/browser/views/first_run_customize_view.cc
@@ -14,7 +14,6 @@
#include "grit/locale_settings.h"
#include "grit/theme_resources.h"
#include "views/controls/button/checkbox.h"
-#include "views/controls/combo_box.h"
#include "views/controls/image_view.h"
#include "views/controls/label.h"
#include "views/controls/throbber.h"
@@ -65,7 +64,7 @@ void FirstRunCustomizeView::SetupControls() {
import_cbox_ = MakeCheckBox(IDS_FR_CUSTOMIZE_IMPORT);
- import_from_combo_ = new views::ComboBox(this);
+ import_from_combo_ = new views::Combobox(this);
AddChildView(import_from_combo_);
shortcuts_label_ =
@@ -160,11 +159,11 @@ void FirstRunCustomizeView::ButtonPressed(views::Button* sender) {
}
}
-int FirstRunCustomizeView::GetItemCount(views::ComboBox* source) {
+int FirstRunCustomizeView::GetItemCount(views::Combobox* source) {
return importer_host_->GetAvailableProfileCount();
}
-std::wstring FirstRunCustomizeView::GetItemAt(views::ComboBox* source,
+std::wstring FirstRunCustomizeView::GetItemAt(views::Combobox* source,
int index) {
return importer_host_->GetSourceProfileNameAt(index);
}
@@ -198,7 +197,7 @@ bool FirstRunCustomizeView::Accept() {
if (!import_cbox_->checked()) {
UserMetrics::RecordAction(L"FirstRunCustom_No_Import", profile_);
} else {
- int browser_selected = import_from_combo_->GetSelectedItem();
+ int browser_selected = import_from_combo_->selected_item();
FirstRun::ImportSettings(profile_,
importer_host_->GetSourceProfileInfoAt(browser_selected).browser_type,
GetDefaultImportItems(), window()->GetNativeWindow());
diff --git a/chrome/browser/views/first_run_customize_view.h b/chrome/browser/views/first_run_customize_view.h
index d7e12b576..13ef358 100644
--- a/chrome/browser/views/first_run_customize_view.h
+++ b/chrome/browser/views/first_run_customize_view.h
@@ -7,7 +7,7 @@
#include "chrome/browser/views/first_run_view_base.h"
#include "views/controls/button/button.h"
-#include "views/controls/combo_box.h"
+#include "views/controls/combobox/combobox.h"
#include "views/view.h"
#include "views/window/dialog_delegate.h"
@@ -26,7 +26,7 @@ class Profile;
// some simple customizations during the first run.
class FirstRunCustomizeView : public FirstRunViewBase,
public views::ButtonListener,
- public views::ComboBox::Model {
+ public views::Combobox::Model {
public:
class CustomizeViewObserver {
public:
@@ -53,9 +53,9 @@ class FirstRunCustomizeView : public FirstRunViewBase,
// Overridden form views::ButtonListener.
virtual void ButtonPressed(views::Button* sender);
- // Overridden form views::ComboBox::Model.
- virtual int GetItemCount(views::ComboBox* source);
- virtual std::wstring GetItemAt(views::ComboBox* source, int index);
+ // Overridden form views::Combobox::Model.
+ virtual int GetItemCount(views::Combobox* source);
+ virtual std::wstring GetItemAt(views::Combobox* source, int index);
// Overridden from views::WindowDelegate.
virtual std::wstring GetWindowTitle() const;
@@ -73,7 +73,7 @@ class FirstRunCustomizeView : public FirstRunViewBase,
views::Label* main_label_;
views::Checkbox* import_cbox_;
- views::ComboBox* import_from_combo_;
+ views::Combobox* import_from_combo_;
views::Label* shortcuts_label_;
views::Checkbox* desktop_shortcut_cbox_;
views::Checkbox* quick_shortcut_cbox_;
diff --git a/chrome/browser/views/importer_view.cc b/chrome/browser/views/importer_view.cc
index 604b668..6775548 100644
--- a/chrome/browser/views/importer_view.cc
+++ b/chrome/browser/views/importer_view.cc
@@ -51,8 +51,8 @@ void ImporterView::SetupControl() {
import_from_label_ =
new views::Label(l10n_util::GetString(IDS_IMPORT_FROM_LABEL));
- profile_combobox_ = new views::ComboBox(this);
- profile_combobox_->SetListener(this);
+ profile_combobox_ = new views::Combobox(this);
+ profile_combobox_->set_listener(this);
import_items_label_ =
new views::Label(l10n_util::GetString(IDS_IMPORT_ITEMS_LABEL));
@@ -135,7 +135,7 @@ bool ImporterView::Accept() {
uint16 items = GetCheckedItems();
Browser* browser = BrowserList::GetLastActive();
- int selected_index = profile_combobox_->GetSelectedItem();
+ int selected_index = profile_combobox_->selected_item();
HWND parent_hwnd =
reinterpret_cast<HWND>(browser->window()->GetNativeHandle());
StartImportingWithUI(parent_hwnd, items, importer_host_.get(),
@@ -151,7 +151,7 @@ views::View* ImporterView::GetContentsView() {
return this;
}
-int ImporterView::GetItemCount(views::ComboBox* source) {
+int ImporterView::GetItemCount(views::Combobox* source) {
DCHECK(source == profile_combobox_);
DCHECK(importer_host_.get());
int item_count = importer_host_->GetAvailableProfileCount();
@@ -160,15 +160,15 @@ int ImporterView::GetItemCount(views::ComboBox* source) {
return item_count;
}
-std::wstring ImporterView::GetItemAt(views::ComboBox* source, int index) {
+std::wstring ImporterView::GetItemAt(views::Combobox* source, int index) {
DCHECK(source == profile_combobox_);
DCHECK(importer_host_.get());
return importer_host_->GetSourceProfileNameAt(index);
}
-void ImporterView::ItemChanged(views::ComboBox* combo_box,
+void ImporterView::ItemChanged(views::Combobox* combobox,
int prev_index, int new_index) {
- DCHECK(combo_box);
+ DCHECK(combobox);
DCHECK(checkbox_items_.size() >=
static_cast<size_t>(importer_host_->GetAvailableProfileCount()));
diff --git a/chrome/browser/views/importer_view.h b/chrome/browser/views/importer_view.h
index 7ce6f62..9194e75 100644
--- a/chrome/browser/views/importer_view.h
+++ b/chrome/browser/views/importer_view.h
@@ -7,7 +7,7 @@
#include "chrome/browser/importer/importer.h"
#include "views/controls/button/native_button.h"
-#include "views/controls/combo_box.h"
+#include "views/controls/combobox/combobox.h"
#include "views/view.h"
#include "views/window/dialog_delegate.h"
@@ -25,8 +25,8 @@ class Profile;
// So now use dialog as a placeholder.
class ImporterView : public views::View,
public views::DialogDelegate,
- public views::ComboBox::Model,
- public views::ComboBox::Listener,
+ public views::Combobox::Model,
+ public views::Combobox::Listener,
public ImportObserver {
public:
explicit ImporterView(Profile* profile);
@@ -44,12 +44,12 @@ class ImporterView : public views::View,
virtual bool Accept();
virtual views::View* GetContentsView();
- // Overridden from views::ComboBox::Model.
- virtual int GetItemCount(views::ComboBox* source);
- virtual std::wstring GetItemAt(views::ComboBox* source, int index);
+ // Overridden from views::Combobox::Model.
+ virtual int GetItemCount(views::Combobox* source);
+ virtual std::wstring GetItemAt(views::Combobox* source, int index);
- // Overridden from ChromeViews::ComboBox::Listener
- virtual void ItemChanged(views::ComboBox* combo_box,
+ // Overridden from ChromeViews::Combobox::Listener
+ virtual void ItemChanged(views::Combobox* combobox,
int prev_index,
int new_index);
@@ -74,7 +74,7 @@ class ImporterView : public views::View,
void SetCheckedItems(uint16 items);
views::Label* import_from_label_;
- views::ComboBox* profile_combobox_;
+ views::Combobox* profile_combobox_;
views::Label* import_items_label_;
views::Checkbox* history_checkbox_;
views::Checkbox* favorites_checkbox_;
diff --git a/chrome/browser/views/options/advanced_contents_view.cc b/chrome/browser/views/options/advanced_contents_view.cc
index 792370ba..880d51f 100644
--- a/chrome/browser/views/options/advanced_contents_view.cc
+++ b/chrome/browser/views/options/advanced_contents_view.cc
@@ -46,7 +46,7 @@
#include "third_party/skia/include/core/SkBitmap.h"
#include "views/background.h"
#include "views/controls/button/checkbox.h"
-#include "views/controls/combo_box.h"
+#include "views/controls/combobox/combobox.h"
#include "views/controls/scroll_view.h"
#include "views/controls/textfield/textfield.h"
#include "views/grid_layout.h"
@@ -421,16 +421,16 @@ void AdvancedSection::InitControlLayout() {
////////////////////////////////////////////////////////////////////////////////
// PrivacySection
-class CookieBehaviorComboModel : public views::ComboBox::Model {
+class CookieBehaviorComboModel : public views::Combobox::Model {
public:
CookieBehaviorComboModel() {}
// Return the number of items in the combo box.
- virtual int GetItemCount(views::ComboBox* source) {
+ virtual int GetItemCount(views::Combobox* source) {
return 3;
}
- virtual std::wstring GetItemAt(views::ComboBox* source, int index) {
+ virtual std::wstring GetItemAt(views::Combobox* source, int index) {
const int kStringIDs[] = {
IDS_OPTIONS_COOKIES_ACCEPT_ALL_COOKIES,
IDS_OPTIONS_COOKIES_RESTRICT_THIRD_PARTY_COOKIES,
@@ -461,7 +461,7 @@ class CookieBehaviorComboModel : public views::ComboBox::Model {
class PrivacySection : public AdvancedSection,
public views::ButtonListener,
- public views::ComboBox::Listener,
+ public views::Combobox::Listener,
public views::LinkController {
public:
explicit PrivacySection(Profile* profile);
@@ -470,8 +470,8 @@ class PrivacySection : public AdvancedSection,
// Overridden from views::ButtonListener:
virtual void ButtonPressed(views::Button* sender);
- // Overridden from views::ComboBox::Listener:
- virtual void ItemChanged(views::ComboBox* sender,
+ // Overridden from views::Combobox::Listener:
+ virtual void ItemChanged(views::Combobox* sender,
int prev_index,
int new_index);
@@ -496,7 +496,7 @@ class PrivacySection : public AdvancedSection,
views::Checkbox* reporting_enabled_checkbox_;
views::Link* learn_more_link_;
views::Label* cookie_behavior_label_;
- views::ComboBox* cookie_behavior_combobox_;
+ views::Combobox* cookie_behavior_combobox_;
views::NativeButton* show_cookies_button_;
// Dummy for now. Used to populate cookies models.
@@ -604,7 +604,7 @@ void PrivacySection::Layout() {
View::Layout();
}
-void PrivacySection::ItemChanged(views::ComboBox* sender,
+void PrivacySection::ItemChanged(views::Combobox* sender,
int prev_index,
int new_index) {
if (sender == cookie_behavior_combobox_) {
@@ -652,9 +652,9 @@ void PrivacySection::InitControlLayout() {
cookie_behavior_label_ = new views::Label(
l10n_util::GetString(IDS_OPTIONS_COOKIES_ACCEPT_LABEL));
allow_cookies_model_.reset(new CookieBehaviorComboModel);
- cookie_behavior_combobox_ = new views::ComboBox(
+ cookie_behavior_combobox_ = new views::Combobox(
allow_cookies_model_.get());
- cookie_behavior_combobox_->SetListener(this);
+ cookie_behavior_combobox_->set_listener(this);
show_cookies_button_ = new views::NativeButton(
this, l10n_util::GetString(IDS_OPTIONS_COOKIES_SHOWCOOKIES));
@@ -868,16 +868,16 @@ void WebContentSection::InitControlLayout() {
////////////////////////////////////////////////////////////////////////////////
// SecuritySection
-class MixedContentComboModel : public views::ComboBox::Model {
+class MixedContentComboModel : public views::Combobox::Model {
public:
MixedContentComboModel() {}
// Return the number of items in the combo box.
- virtual int GetItemCount(views::ComboBox* source) {
+ virtual int GetItemCount(views::Combobox* source) {
return 3;
}
- virtual std::wstring GetItemAt(views::ComboBox* source, int index) {
+ virtual std::wstring GetItemAt(views::Combobox* source, int index) {
const int kStringIDs[] = {
IDS_OPTIONS_INCLUDE_MIXED_CONTENT,
IDS_OPTIONS_INCLUDE_MIXED_CONTENT_IMAGE_ONLY,
@@ -908,7 +908,7 @@ class MixedContentComboModel : public views::ComboBox::Model {
class SecuritySection : public AdvancedSection,
public views::ButtonListener,
- public views::ComboBox::Listener {
+ public views::Combobox::Listener {
public:
explicit SecuritySection(Profile* profile);
virtual ~SecuritySection() {}
@@ -916,8 +916,8 @@ class SecuritySection : public AdvancedSection,
// Overridden from views::ButtonListener:
virtual void ButtonPressed(views::Button* sender);
- // Overridden from views::ComboBox::Listener:
- virtual void ItemChanged(views::ComboBox* sender,
+ // Overridden from views::Combobox::Listener:
+ virtual void ItemChanged(views::Combobox* sender,
int prev_index,
int new_index);
@@ -932,7 +932,7 @@ class SecuritySection : public AdvancedSection,
views::Checkbox* enable_ssl2_checkbox_;
views::Checkbox* check_for_cert_revocation_checkbox_;
views::Label* mixed_content_info_label_;
- views::ComboBox* mixed_content_combobox_;
+ views::Combobox* mixed_content_combobox_;
views::Label* manage_certificates_label_;
views::NativeButton* manage_certificates_button_;
@@ -982,7 +982,7 @@ void SecuritySection::ButtonPressed(views::Button* sender) {
}
}
-void SecuritySection::ItemChanged(views::ComboBox* sender,
+void SecuritySection::ItemChanged(views::Combobox* sender,
int prev_index,
int new_index) {
if (sender == mixed_content_combobox_) {
@@ -1015,9 +1015,9 @@ void SecuritySection::InitControlLayout() {
mixed_content_info_label_ = new views::Label(
l10n_util::GetString(IDS_OPTIONS_MIXED_CONTENT_LABEL));
mixed_content_model_.reset(new MixedContentComboModel);
- mixed_content_combobox_ = new views::ComboBox(
+ mixed_content_combobox_ = new views::Combobox(
mixed_content_model_.get());
- mixed_content_combobox_->SetListener(this);
+ mixed_content_combobox_->set_listener(this);
manage_certificates_label_ = new views::Label(
l10n_util::GetString(IDS_OPTIONS_CERTIFICATES_LABEL));
manage_certificates_button_ = new views::NativeButton(
diff --git a/chrome/browser/views/options/fonts_page_view.cc b/chrome/browser/views/options/fonts_page_view.cc
index a8a115b..abd6b8a 100644
--- a/chrome/browser/views/options/fonts_page_view.cc
+++ b/chrome/browser/views/options/fonts_page_view.cc
@@ -38,7 +38,7 @@ static std::vector<CharacterEncoding::EncodingInfo> sorted_encoding_list;
} // namespace
-class DefaultEncodingComboboxModel : public views::ComboBox::Model {
+class DefaultEncodingComboboxModel : public views::Combobox::Model {
public:
DefaultEncodingComboboxModel() {
canonical_encoding_names_length_ =
@@ -58,11 +58,11 @@ class DefaultEncodingComboboxModel : public views::ComboBox::Model {
virtual ~DefaultEncodingComboboxModel() {}
// Overridden from views::Combobox::Model.
- virtual int GetItemCount(views::ComboBox* source) {
+ virtual int GetItemCount(views::Combobox* source) {
return canonical_encoding_names_length_;
}
- virtual std::wstring GetItemAt(views::ComboBox* source, int index) {
+ virtual std::wstring GetItemAt(views::Combobox* source, int index) {
DCHECK(index >= 0 && canonical_encoding_names_length_ > index);
return sorted_encoding_list[index].encoding_display_name;
}
@@ -253,7 +253,7 @@ void FontsPageView::ButtonPressed(views::Button* sender) {
select_font_dialog_->SelectFont(owning_hwnd, NULL, font_name, font_size);
}
-void FontsPageView::ItemChanged(views::ComboBox* combo_box,
+void FontsPageView::ItemChanged(views::Combobox* combo_box,
int prev_index, int new_index) {
if (combo_box == default_encoding_combobox_) {
if (prev_index != new_index) { // Default-Encoding has been changed.
@@ -463,14 +463,14 @@ void FontsPageView::InitEncodingLayout() {
l10n_util::GetString(
IDS_FONT_LANGUAGE_SETTING_FONT_DEFAULT_ENCODING_SELECTOR_LABEL));
default_encoding_combobox_model_.reset(new DefaultEncodingComboboxModel);
- default_encoding_combobox_ = new views::ComboBox(
+ default_encoding_combobox_ = new views::Combobox(
default_encoding_combobox_model_.get());
int selected_encoding_index = default_encoding_combobox_model_->
GetSelectedEncodingIndex(profile());
default_encoding_combobox_->SetSelectedItem(selected_encoding_index);
default_encoding_selected_ = default_encoding_combobox_model_->
GetEncodingCharsetByIndex(selected_encoding_index);
- default_encoding_combobox_->SetListener(this);
+ default_encoding_combobox_->set_listener(this);
// Now add the views.
using views::GridLayout;
@@ -489,7 +489,7 @@ void FontsPageView::InitEncodingLayout() {
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
GridLayout::USE_PREF, 0, 0);
- // Add Encoding ComboBox.
+ // Add Encoding Combobox.
layout->StartRow(0, double_column_view_set_id);
layout->AddView(default_encoding_combobox_label_);
layout->AddView(default_encoding_combobox_, 1, 1, GridLayout::FILL,
diff --git a/chrome/browser/views/options/fonts_page_view.h b/chrome/browser/views/options/fonts_page_view.h
index 1a83919..eec242a 100644
--- a/chrome/browser/views/options/fonts_page_view.h
+++ b/chrome/browser/views/options/fonts_page_view.h
@@ -8,7 +8,7 @@
#include "chrome/browser/views/options/options_page_view.h"
#include "chrome/browser/shell_dialogs.h"
#include "chrome/common/pref_member.h"
-#include "views/controls/combo_box.h"
+#include "views/controls/combobox/combobox.h"
#include "views/controls/button/button.h"
#include "views/view.h"
@@ -28,7 +28,7 @@ class DefaultEncodingComboboxModel;
// FontsPageView
class FontsPageView : public OptionsPageView,
- public views::ComboBox::Listener,
+ public views::Combobox::Listener,
public SelectFontDialog::Listener,
public views::ButtonListener {
public:
@@ -38,8 +38,8 @@ class FontsPageView : public OptionsPageView,
// views::ButtonListener implementation:
virtual void ButtonPressed(views::Button* sender);
- // views::ComboBox::Listener implementation:
- virtual void ItemChanged(views::ComboBox* combo_box,
+ // views::Combobox::Listener implementation:
+ virtual void ItemChanged(views::Combobox* combo_box,
int prev_index,
int new_index);
@@ -117,7 +117,7 @@ class FontsPageView : public OptionsPageView,
// Default Encoding.
scoped_ptr<DefaultEncodingComboboxModel> default_encoding_combobox_model_;
views::Label* default_encoding_combobox_label_;
- views::ComboBox* default_encoding_combobox_;
+ views::Combobox* default_encoding_combobox_;
std::wstring default_encoding_selected_;
bool default_encoding_changed_;
diff --git a/chrome/browser/views/options/general_page_view.cc b/chrome/browser/views/options/general_page_view.cc
index 0723e13..a248f27 100644
--- a/chrome/browser/views/options/general_page_view.cc
+++ b/chrome/browser/views/options/general_page_view.cc
@@ -382,19 +382,19 @@ CustomHomePagesTableModel::Entry*
///////////////////////////////////////////////////////////////////////////////
// SearchEngineListModel
-class SearchEngineListModel : public views::ComboBox::Model,
+class SearchEngineListModel : public views::Combobox::Model,
public TemplateURLModelObserver {
public:
explicit SearchEngineListModel(Profile* profile);
virtual ~SearchEngineListModel();
- // Sets the ComboBox. SearchEngineListModel needs a handle to the ComboBox
+ // Sets the Combobox. SearchEngineListModel needs a handle to the Combobox
// so that when the TemplateURLModel changes the combobox can be updated.
- void SetComboBox(views::ComboBox* combo_box);
+ void SetCombobox(views::Combobox* combobox);
- // views::ComboBox::Model overrides:
- virtual int GetItemCount(views::ComboBox* source);
- virtual std::wstring GetItemAt(views::ComboBox* source, int index);
+ // views::Combobox::Model overrides:
+ virtual int GetItemCount(views::Combobox* source);
+ virtual std::wstring GetItemAt(views::Combobox* source, int index);
// Returns the TemplateURL at the specified index.
const TemplateURL* GetTemplateURLAt(int index);
@@ -410,12 +410,12 @@ class SearchEngineListModel : public views::ComboBox::Model,
// Resets the selection of the combobox based on the users selected search
// engine.
- void ChangeComboBoxSelection();
+ void ChangeComboboxSelection();
TemplateURLModel* template_url_model_;
// The combobox hosting us.
- views::ComboBox* combo_box_;
+ views::Combobox* combobox_;
// The TemplateURLs we're showing.
typedef std::vector<const TemplateURL*> TemplateURLs;
@@ -426,7 +426,7 @@ class SearchEngineListModel : public views::ComboBox::Model,
SearchEngineListModel::SearchEngineListModel(Profile* profile)
: template_url_model_(profile->GetTemplateURLModel()),
- combo_box_(NULL) {
+ combobox_(NULL) {
if (template_url_model_) {
template_url_model_->Load();
template_url_model_->AddObserver(this);
@@ -439,21 +439,21 @@ SearchEngineListModel::~SearchEngineListModel() {
template_url_model_->RemoveObserver(this);
}
-void SearchEngineListModel::SetComboBox(views::ComboBox* combo_box) {
- combo_box_ = combo_box;
+void SearchEngineListModel::SetCombobox(views::Combobox* combobox) {
+ combobox_ = combobox;
if (template_url_model_ && template_url_model_->loaded())
- ChangeComboBoxSelection();
+ ChangeComboboxSelection();
else
- combo_box_->SetEnabled(false);
+ combobox_->SetEnabled(false);
}
-int SearchEngineListModel::GetItemCount(views::ComboBox* source) {
+int SearchEngineListModel::GetItemCount(views::Combobox* source) {
return static_cast<int>(template_urls_.size());
}
-std::wstring SearchEngineListModel::GetItemAt(views::ComboBox* source,
+std::wstring SearchEngineListModel::GetItemAt(views::Combobox* source,
int index) {
- DCHECK(index < GetItemCount(combo_box_));
+ DCHECK(index < GetItemCount(combobox_));
return template_urls_[index]->short_name();
}
@@ -476,15 +476,15 @@ void SearchEngineListModel::ResetContents() {
template_urls_.push_back(model_urls[i]);
}
- if (combo_box_) {
- combo_box_->ModelChanged();
- ChangeComboBoxSelection();
+ if (combobox_) {
+ combobox_->ModelChanged();
+ ChangeComboboxSelection();
}
}
-void SearchEngineListModel::ChangeComboBoxSelection() {
+void SearchEngineListModel::ChangeComboboxSelection() {
if (template_urls_.size()) {
- combo_box_->SetEnabled(true);
+ combobox_->SetEnabled(true);
const TemplateURL* default_search_provider =
template_url_model_->GetDefaultSearchProvider();
@@ -493,12 +493,12 @@ void SearchEngineListModel::ChangeComboBoxSelection() {
find(template_urls_.begin(), template_urls_.end(),
default_search_provider);
if (i != template_urls_.end()) {
- combo_box_->SetSelectedItem(
+ combobox_->SetSelectedItem(
static_cast<int>(i - template_urls_.begin()));
}
}
} else {
- combo_box_->SetEnabled(false);
+ combobox_->SetEnabled(false);
}
}
@@ -595,11 +595,11 @@ void GeneralPageView::ButtonPressed(views::Button* sender) {
}
///////////////////////////////////////////////////////////////////////////////
-// GeneralPageView, views::ComboBox::Listener implementation:
+// GeneralPageView, views::Combobox::Listener implementation:
-void GeneralPageView::ItemChanged(views::ComboBox* combo_box,
+void GeneralPageView::ItemChanged(views::Combobox* combobox,
int prev_index, int new_index) {
- if (combo_box == default_search_engine_combobox_) {
+ if (combobox == default_search_engine_combobox_) {
SetDefaultSearchProvider();
UserMetricsRecordAction(L"Options_SearchEngineChanged", NULL);
}
@@ -920,9 +920,9 @@ void GeneralPageView::InitHomepageGroup() {
void GeneralPageView::InitDefaultSearchGroup() {
default_search_engines_model_.reset(new SearchEngineListModel(profile()));
default_search_engine_combobox_ =
- new views::ComboBox(default_search_engines_model_.get());
- default_search_engines_model_->SetComboBox(default_search_engine_combobox_);
- default_search_engine_combobox_->SetListener(this);
+ new views::Combobox(default_search_engines_model_.get());
+ default_search_engines_model_->SetCombobox(default_search_engine_combobox_);
+ default_search_engine_combobox_->set_listener(this);
default_search_manage_engines_button_ = new views::NativeButton(
this,
@@ -1087,7 +1087,7 @@ void GeneralPageView::EnableHomepageURLField(bool enabled) {
}
void GeneralPageView::SetDefaultSearchProvider() {
- const int index = default_search_engine_combobox_->GetSelectedItem();
+ const int index = default_search_engine_combobox_->selected_item();
default_search_engines_model_->model()->SetDefaultSearchProvider(
default_search_engines_model_->GetTemplateURLAt(index));
}
diff --git a/chrome/browser/views/options/general_page_view.h b/chrome/browser/views/options/general_page_view.h
index a75fb99..3dcc66c 100644
--- a/chrome/browser/views/options/general_page_view.h
+++ b/chrome/browser/views/options/general_page_view.h
@@ -8,7 +8,7 @@
#include "chrome/browser/views/options/options_page_view.h"
#include "chrome/browser/views/shelf_item_dialog.h"
#include "chrome/common/pref_member.h"
-#include "views/controls/combo_box.h"
+#include "views/controls/combobox/combobox.h"
#include "views/controls/button/button.h"
#include "views/controls/table/table_view_observer.h"
#include "views/view.h"
@@ -31,7 +31,7 @@ class SearchEngineListModel;
// GeneralPageView
class GeneralPageView : public OptionsPageView,
- public views::ComboBox::Listener,
+ public views::Combobox::Listener,
public views::ButtonListener,
public views::Textfield::Controller,
public ShelfItemDialogDelegate,
@@ -44,8 +44,8 @@ class GeneralPageView : public OptionsPageView,
// views::ButtonListener implementation:
virtual void ButtonPressed(views::Button* sender);
- // views::ComboBox::Listener implementation:
- virtual void ItemChanged(views::ComboBox* combo_box,
+ // views::Combobox::Listener implementation:
+ virtual void ItemChanged(views::Combobox* combobox,
int prev_index,
int new_index);
@@ -141,7 +141,7 @@ class GeneralPageView : public OptionsPageView,
// Controls for the Default Search group
OptionsGroupView* default_search_group_;
- views::ComboBox* default_search_engine_combobox_;
+ views::Combobox* default_search_engine_combobox_;
views::NativeButton* default_search_manage_engines_button_;
scoped_ptr<SearchEngineListModel> default_search_engines_model_;
diff --git a/chrome/browser/views/options/language_combobox_model.cc b/chrome/browser/views/options/language_combobox_model.cc
index 7186032..2503b6a 100644
--- a/chrome/browser/views/options/language_combobox_model.cc
+++ b/chrome/browser/views/options/language_combobox_model.cc
@@ -73,11 +73,11 @@ void LanguageComboboxModel::InitNativeNames(
}
// Overridden from views::Combobox::Model:
-int LanguageComboboxModel::GetItemCount(views::ComboBox* source) {
+int LanguageComboboxModel::GetItemCount(views::Combobox* source) {
return static_cast<int>(locale_names_.size());
}
-std::wstring LanguageComboboxModel::GetItemAt(views::ComboBox* source,
+std::wstring LanguageComboboxModel::GetItemAt(views::Combobox* source,
int index) {
DCHECK(static_cast<int>(locale_names_.size()) > index);
LocaleDataMap::const_iterator it =
diff --git a/chrome/browser/views/options/language_combobox_model.h b/chrome/browser/views/options/language_combobox_model.h
index c102902..9109151 100644
--- a/chrome/browser/views/options/language_combobox_model.h
+++ b/chrome/browser/views/options/language_combobox_model.h
@@ -6,12 +6,12 @@
#define CHROME_BROWSER_VIEWS_OPTIONS_LANGUAGE_COMBOBOX_MODEL_H_
#include "chrome/browser/profile.h"
-#include "views/controls/combo_box.h"
+#include "views/controls/combobox/combobox.h"
///////////////////////////////////////////////////////////////////////////////
// LanguageComboboxModel
// The model that fills the dropdown of valid UI languages.
-class LanguageComboboxModel : public views::ComboBox::Model {
+class LanguageComboboxModel : public views::Combobox::Model {
public:
struct LocaleData {
LocaleData() { }
@@ -34,9 +34,9 @@ class LanguageComboboxModel : public views::ComboBox::Model {
void InitNativeNames(const std::vector<std::string>& locale_codes);
// Overridden from views::Combobox::Model:
- virtual int GetItemCount(views::ComboBox* source);
+ virtual int GetItemCount(views::Combobox* source);
- virtual std::wstring GetItemAt(views::ComboBox* source, int index);
+ virtual std::wstring GetItemAt(views::Combobox* source, int index);
// Return the locale for the given index. E.g., may return pt-BR.
std::string GetLocaleFromIndex(int index);
diff --git a/chrome/browser/views/options/languages_page_view.cc b/chrome/browser/views/options/languages_page_view.cc
index 48932f9..400cb16 100644
--- a/chrome/browser/views/options/languages_page_view.cc
+++ b/chrome/browser/views/options/languages_page_view.cc
@@ -29,7 +29,6 @@
#include "third_party/skia/include/core/SkBitmap.h"
#include "unicode/uloc.h"
#include "views/controls/button/radio_button.h"
-#include "views/controls/combo_box.h"
#include "views/controls/tabbed_pane.h"
#include "views/controls/table/table_model.h"
#include "views/controls/table/table_model_observer.h"
@@ -179,7 +178,7 @@ static const char* const accept_language_list[] = {
// This opens another window from where a new accept language can be selected.
//
class AddLanguageWindowView : public views::View,
- public views::ComboBox::Listener,
+ public views::Combobox::Listener,
public views::DialogDelegate {
public:
AddLanguageWindowView(LanguagesPageView* language_delegate, Profile* profile);
@@ -196,8 +195,8 @@ class AddLanguageWindowView : public views::View,
virtual bool IsModal() const { return true; }
virtual views::View* GetContentsView() { return this; }
- // views::ComboBox::Listener implementation:
- virtual void ItemChanged(views::ComboBox* combo_box,
+ // views::Combobox::Listener implementation:
+ virtual void ItemChanged(views::Combobox* combobox,
int prev_index,
int new_index);
@@ -221,7 +220,7 @@ class AddLanguageWindowView : public views::View,
// Combobox and its corresponding model.
scoped_ptr<LanguageComboboxModel> accept_language_combobox_model_;
- views::ComboBox* accept_language_combobox_;
+ views::Combobox* accept_language_combobox_;
// The Profile associated with this window.
Profile* profile_;
@@ -257,7 +256,7 @@ bool AddLanguageWindowView::Accept() {
return true;
}
-void AddLanguageWindowView::ItemChanged(views::ComboBox* combo_box,
+void AddLanguageWindowView::ItemChanged(views::Combobox* combobox,
int prev_index,
int new_index) {
accept_language_selected_ = accept_language_combobox_model_->
@@ -306,10 +305,10 @@ void AddLanguageWindowView::Init() {
}
accept_language_combobox_model_.reset(new LanguageComboboxModel(
profile_, locale_codes));
- accept_language_combobox_ = new views::ComboBox(
+ accept_language_combobox_ = new views::Combobox(
accept_language_combobox_model_.get());
accept_language_combobox_->SetSelectedItem(0);
- accept_language_combobox_->SetListener(this);
+ accept_language_combobox_->set_listener(this);
AddChildView(accept_language_combobox_);
}
@@ -619,8 +618,8 @@ void LanguagesPageView::InitControlLayout() {
ui_language_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
ui_language_model_.reset(new LanguageComboboxModel);
change_ui_language_combobox_ =
- new views::ComboBox(ui_language_model_.get());
- change_ui_language_combobox_->SetListener(this);
+ new views::Combobox(ui_language_model_.get());
+ change_ui_language_combobox_->set_listener(this);
dictionary_language_label_ = new views::Label(
l10n_util::GetString(IDS_OPTIONS_CHROME_DICTIONARY_LANGUAGE));
dictionary_language_label_->SetHorizontalAlignment(
@@ -636,8 +635,8 @@ void LanguagesPageView::InitControlLayout() {
dictionary_language_model_.reset(new LanguageComboboxModel(profile(),
spell_check_languages));
change_dictionary_language_combobox_ =
- new views::ComboBox(dictionary_language_model_.get());
- change_dictionary_language_combobox_->SetListener(this);
+ new views::Combobox(dictionary_language_model_.get());
+ change_dictionary_language_combobox_->set_listener(this);
// SpellCheck language settings.
layout->StartRow(0, single_column_view_set_id);
@@ -730,7 +729,7 @@ void LanguagesPageView::NotifyPrefChanged(const std::wstring* pref_name) {
}
}
-void LanguagesPageView::ItemChanged(views::ComboBox* sender,
+void LanguagesPageView::ItemChanged(views::Combobox* sender,
int prev_index,
int new_index) {
if (prev_index == new_index)
diff --git a/chrome/browser/views/options/languages_page_view.h b/chrome/browser/views/options/languages_page_view.h
index b0ad138..3f6522d 100644
--- a/chrome/browser/views/options/languages_page_view.h
+++ b/chrome/browser/views/options/languages_page_view.h
@@ -7,7 +7,7 @@
#include "chrome/browser/views/options/options_page_view.h"
#include "chrome/common/pref_member.h"
-#include "views/controls/combo_box.h"
+#include "views/controls/combobox/combobox.h"
#include "views/controls/button/button.h"
#include "views/controls/table/table_view_observer.h"
#include "views/view.h"
@@ -30,7 +30,7 @@ class AddLanguageView;
class LanguagesPageView : public OptionsPageView,
public views::ButtonListener,
public views::TableViewObserver,
- public views::ComboBox::Listener {
+ public views::Combobox::Listener {
public:
explicit LanguagesPageView(Profile* profile);
virtual ~LanguagesPageView();
@@ -53,8 +53,8 @@ class LanguagesPageView : public OptionsPageView,
virtual void InitControlLayout();
virtual void NotifyPrefChanged(const std::wstring* pref_name);
- // views::ComboBox::Listener implementation:
- virtual void ItemChanged(views::ComboBox* sender,
+ // views::Combobox::Listener implementation:
+ virtual void ItemChanged(views::Combobox* sender,
int prev_index,
int new_index);
@@ -76,8 +76,8 @@ class LanguagesPageView : public OptionsPageView,
views::NativeButton* remove_button_;
views::Label* language_info_label_;
views::Label* ui_language_label_;
- views::ComboBox* change_ui_language_combobox_;
- views::ComboBox* change_dictionary_language_combobox_;
+ views::Combobox* change_ui_language_combobox_;
+ views::Combobox* change_dictionary_language_combobox_;
views::Checkbox* enable_spellchecking_checkbox_;
views::Label* dictionary_language_label_;
diff --git a/chrome/browser/views/select_profile_dialog.cc b/chrome/browser/views/select_profile_dialog.cc
index 81ebbfb..6c4dead 100644
--- a/chrome/browser/views/select_profile_dialog.cc
+++ b/chrome/browser/views/select_profile_dialog.cc
@@ -14,7 +14,6 @@
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
-#include "views/controls/combo_box.h"
#include "views/controls/label.h"
#include "views/controls/message_box_view.h"
#include "views/grid_layout.h"
@@ -84,7 +83,7 @@ std::wstring SelectProfileDialog::GetWindowTitle() const {
}
bool SelectProfileDialog::Accept() {
- int index = profile_combobox_->GetSelectedItem();
+ int index = profile_combobox_->selected_item();
if (index < 0) {
NOTREACHED();
return true;
@@ -110,13 +109,13 @@ views::View* SelectProfileDialog::GetContentsView() {
return this;
}
-int SelectProfileDialog::GetItemCount(views::ComboBox* source) {
+int SelectProfileDialog::GetItemCount(views::Combobox* source) {
// Always show one more item in the combo box that allows the user to select
// <New Profile>.
return profiles_.size() + 1;
}
-std::wstring SelectProfileDialog::GetItemAt(views::ComboBox* source,
+std::wstring SelectProfileDialog::GetItemAt(views::Combobox* source,
int index) {
DCHECK(source == profile_combobox_);
DCHECK(index >= 0 && index <= static_cast<int>(profiles_.size()));
@@ -136,7 +135,7 @@ void SelectProfileDialog::SetupControls() {
// Adds all controls.
select_profile_label_ = new views::Label(
l10n_util::GetString(IDS_SELECT_PROFILE_DIALOG_LABEL_TEXT));
- profile_combobox_ = new views::ComboBox(this);
+ profile_combobox_ = new views::Combobox(this);
// Arranges controls by using GridLayout.
const int column_set_id = 0;
diff --git a/chrome/browser/views/select_profile_dialog.h b/chrome/browser/views/select_profile_dialog.h
index 2e2d328..22750b5 100644
--- a/chrome/browser/views/select_profile_dialog.h
+++ b/chrome/browser/views/select_profile_dialog.h
@@ -15,7 +15,7 @@
#include "base/ref_counted.h"
#include "chrome/browser/shell_dialogs.h"
#include "chrome/browser/user_data_manager.h"
-#include "views/controls/combo_box.h"
+#include "views/controls/combobox/combobox.h"
#include "views/window/dialog_delegate.h"
class SelectProfileDialogHelper;
@@ -28,7 +28,7 @@ class Window;
class SelectProfileDialog
: public views::DialogDelegate,
public views::View,
- public views::ComboBox::Model,
+ public views::Combobox::Model,
public GetProfilesHelper::Delegate {
public:
// Creates and runs the dialog.
@@ -54,9 +54,9 @@ class SelectProfileDialog
virtual std::wstring GetWindowTitle() const;
virtual bool IsModal() const { return false; }
- // views::ComboBox::Model methods.
- virtual int GetItemCount(views::ComboBox* source);
- virtual std::wstring GetItemAt(views::ComboBox* source, int index);
+ // views::Combobox::Model methods.
+ virtual int GetItemCount(views::Combobox* source);
+ virtual std::wstring GetItemAt(views::Combobox* source, int index);
// GetProfilesHelper::Delegate method.
virtual void OnGetProfilesDone(const std::vector<std::wstring>& profiles);
@@ -68,7 +68,7 @@ class SelectProfileDialog
void SetupControls();
// UI controls.
- views::ComboBox* profile_combobox_;
+ views::Combobox* profile_combobox_;
views::Label* select_profile_label_;
std::vector<std::wstring> profiles_;
diff --git a/views/controls/combo_box.cc b/views/controls/combo_box.cc
deleted file mode 100644
index 966509c..0000000
--- a/views/controls/combo_box.cc
+++ /dev/null
@@ -1,179 +0,0 @@
-// Copyright (c) 2006-2008 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/combo_box.h"
-
-#include "app/gfx/canvas.h"
-#include "app/gfx/font.h"
-#include "app/l10n_util.h"
-#include "app/resource_bundle.h"
-#include "base/gfx/native_theme.h"
-#include "base/gfx/rect.h"
-
-// Limit how small a combobox can be.
-static const int kMinComboboxWidth = 148;
-
-// Add a couple extra pixels to the widths of comboboxes and combobox
-// dropdowns so that text isn't too crowded.
-static const int kComboboxExtraPaddingX = 6;
-
-namespace views {
-
-ComboBox::ComboBox(Model* model)
- : model_(model), selected_item_(0), listener_(NULL), content_width_(0) {
-}
-
-ComboBox::~ComboBox() {
-}
-
-void ComboBox::SetListener(Listener* listener) {
- listener_ = listener;
-}
-
-gfx::Size ComboBox::GetPreferredSize() {
- HWND hwnd = GetNativeControlHWND();
- if (!hwnd)
- return gfx::Size();
-
- COMBOBOXINFO cbi;
- memset(reinterpret_cast<unsigned char*>(&cbi), 0, sizeof(cbi));
- cbi.cbSize = sizeof(cbi);
- // Note: Don't use CB_GETCOMBOBOXINFO since that crashes on WOW64 systems
- // when you have a global message hook installed.
- GetComboBoxInfo(hwnd, &cbi);
- gfx::Rect rect_item(cbi.rcItem);
- gfx::Rect rect_button(cbi.rcButton);
- gfx::Size border = gfx::NativeTheme::instance()->GetThemeBorderSize(
- gfx::NativeTheme::MENULIST);
-
- // The padding value of '3' is the xy offset from the corner of the control
- // to the corner of rcItem. It does not seem to be queryable from the theme.
- // It is consistent on all versions of Windows from 2K to Vista, and is
- // invariant with respect to the combobox border size. We could conceivably
- // get this number from rect_item.x, but it seems fragile to depend on
- // position here, inside of the layout code.
- const int kItemOffset = 3;
- int item_to_button_distance = std::max(kItemOffset - border.width(), 0);
-
- // The cx computation can be read as measuring from left to right.
- int pref_width = std::max(kItemOffset + content_width_ +
- kComboboxExtraPaddingX +
- item_to_button_distance + rect_button.width() +
- border.width(), kMinComboboxWidth);
- // The two arguments to ::max below should be typically be equal.
- int pref_height = std::max(rect_item.height() + 2 * kItemOffset,
- rect_button.height() + 2 * border.height());
- return gfx::Size(pref_width, pref_height);
-}
-
-// VK_ESCAPE should be handled by this view when the drop down list is active.
-// In other words, the list should be closed instead of the dialog.
-bool ComboBox::OverrideAccelerator(const Accelerator& accelerator) {
- if (accelerator != Accelerator(VK_ESCAPE, false, false, false))
- return false;
-
- HWND hwnd = GetNativeControlHWND();
- if (!hwnd)
- return false;
-
- return ::SendMessage(hwnd, CB_GETDROPPEDSTATE, 0, 0) != 0;
-}
-
-HWND ComboBox::CreateNativeControl(HWND parent_container) {
- HWND r = ::CreateWindowEx(GetAdditionalExStyle(), L"COMBOBOX", L"",
- WS_CHILD | WS_VSCROLL | CBS_DROPDOWNLIST,
- 0, 0, width(), height(),
- parent_container, NULL, NULL, NULL);
- HFONT font = ResourceBundle::GetSharedInstance().
- GetFont(ResourceBundle::BaseFont).hfont();
- SendMessage(r, WM_SETFONT, reinterpret_cast<WPARAM>(font), FALSE);
- UpdateComboBoxFromModel(r);
- return r;
-}
-
-LRESULT ComboBox::OnCommand(UINT code, int id, HWND source) {
- HWND hwnd = GetNativeControlHWND();
- if (!hwnd)
- return 0;
-
- if (code == CBN_SELCHANGE && source == hwnd) {
- LRESULT r = ::SendMessage(hwnd, CB_GETCURSEL, 0, 0);
- if (r != CB_ERR) {
- int prev_selected_item = selected_item_;
- selected_item_ = static_cast<int>(r);
- if (listener_)
- listener_->ItemChanged(this, prev_selected_item, selected_item_);
- }
- }
- return 0;
-}
-
-LRESULT ComboBox::OnNotify(int w_param, LPNMHDR l_param) {
- return 0;
-}
-
-void ComboBox::UpdateComboBoxFromModel(HWND hwnd) {
- ::SendMessage(hwnd, CB_RESETCONTENT, 0, 0);
- gfx::Font font = ResourceBundle::GetSharedInstance().GetFont(
- ResourceBundle::BaseFont);
- int max_width = 0;
- int num_items = model_->GetItemCount(this);
- for (int i = 0; i < num_items; ++i) {
- const std::wstring& text = model_->GetItemAt(this, i);
-
- // Inserting the Unicode formatting characters if necessary so that the
- // text is displayed correctly in right-to-left UIs.
- std::wstring localized_text;
- const wchar_t* text_ptr = text.c_str();
- if (l10n_util::AdjustStringForLocaleDirection(text, &localized_text))
- text_ptr = localized_text.c_str();
-
- ::SendMessage(hwnd, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(text_ptr));
- max_width = std::max(max_width, font.GetStringWidth(text));
-
- }
- content_width_ = max_width;
-
- if (num_items > 0) {
- ::SendMessage(hwnd, CB_SETCURSEL, selected_item_, 0);
-
- // Set the width for the drop down while accounting for the scrollbar and
- // borders.
- if (num_items > ComboBox_GetMinVisible(hwnd))
- max_width += ::GetSystemMetrics(SM_CXVSCROLL);
- // SM_CXEDGE would not be correct here, since the dropdown is flat, not 3D.
- int kComboboxDropdownBorderSize = 1;
- max_width += 2 * kComboboxDropdownBorderSize + kComboboxExtraPaddingX;
- ::SendMessage(hwnd, CB_SETDROPPEDWIDTH, max_width, 0);
- }
-}
-
-void ComboBox::ModelChanged() {
- HWND hwnd = GetNativeControlHWND();
- if (!hwnd)
- return;
- selected_item_ = std::min(0, model_->GetItemCount(this));
- UpdateComboBoxFromModel(hwnd);
-}
-
-void ComboBox::SetSelectedItem(int index) {
- selected_item_ = index;
- HWND hwnd = GetNativeControlHWND();
- if (!hwnd)
- return;
-
- // Note that we use CB_SETCURSEL and not CB_SELECTSTRING because on RTL
- // locales the strings we get from our ComboBox::Model might be augmented
- // with Unicode directionality marks before we insert them into the combo box
- // and therefore we can not assume that the string we get from
- // ComboBox::Model can be safely searched for and selected (which is what
- // CB_SELECTSTRING does).
- ::SendMessage(hwnd, CB_SETCURSEL, selected_item_, 0);
-}
-
-int ComboBox::GetSelectedItem() {
- return selected_item_;
-}
-
-} // namespace views
diff --git a/views/controls/combo_box.h b/views/controls/combo_box.h
deleted file mode 100644
index 3e8eeae..0000000
--- a/views/controls/combo_box.h
+++ /dev/null
@@ -1,80 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef VIEWS_CONTROLS_COMBO_BOX_H_
-#define VIEWS_CONTROLS_COMBO_BOX_H_
-
-#include "views/controls/native_control.h"
-
-namespace views {
-////////////////////////////////////////////////////////////////////////////////
-//
-// ComboBox is a basic non editable combo box. It is initialized from a simple
-// model.
-//
-////////////////////////////////////////////////////////////////////////////////
-class ComboBox : public NativeControl {
- public:
- class Model {
- public:
- // Return the number of items in the combo box.
- virtual int GetItemCount(ComboBox* source) = 0;
-
- // Return the string that should be used to represent a given item.
- virtual std::wstring GetItemAt(ComboBox* source, int index) = 0;
- };
-
- class Listener {
- public:
- // This is invoked once the selected item changed.
- virtual void ItemChanged(ComboBox* combo_box,
- int prev_index,
- int new_index) = 0;
- };
-
- // |model is not owned by the combo box.
- explicit ComboBox(Model* model);
- virtual ~ComboBox();
-
- // Register |listener| for item change events.
- void SetListener(Listener* listener);
-
- // Overridden from View.
- virtual gfx::Size GetPreferredSize();
- virtual bool OverrideAccelerator(const Accelerator& accelerator);
-
- // Overridden from NativeControl
- virtual HWND CreateNativeControl(HWND parent_container);
- virtual LRESULT OnCommand(UINT code, int id, HWND source);
- virtual LRESULT OnNotify(int w_param, LPNMHDR l_param);
-
- // Inform the combo box that its model changed.
- void ModelChanged();
-
- // Set / Get the selected item.
- void SetSelectedItem(int index);
- int GetSelectedItem();
-
- private:
- // Update a combo box from our model.
- void UpdateComboBoxFromModel(HWND hwnd);
-
- // Our model.
- Model* model_;
-
- // The current selection.
- int selected_item_;
-
- // Item change listener.
- Listener* listener_;
-
- // The min width, in pixels, for the text content.
- int content_width_;
-
- DISALLOW_EVIL_CONSTRUCTORS(ComboBox);
-};
-
-} // namespace views
-
-#endif // VIEWS_CONTROLS_COMBO_BOX_H_
diff --git a/views/controls/combobox/combobox.cc b/views/controls/combobox/combobox.cc
new file mode 100644
index 0000000..48adc00
--- /dev/null
+++ b/views/controls/combobox/combobox.cc
@@ -0,0 +1,104 @@
+// Copyright (c) 2006-2008 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/combobox/combobox.h"
+
+#include "views/controls/combobox/native_combobox_wrapper.h"
+
+namespace views {
+
+// static
+const char Combobox::kViewClassName[] = "views/Combobox";
+
+////////////////////////////////////////////////////////////////////////////////
+// Combobox, public:
+
+Combobox::Combobox(Model* model)
+ : native_wrapper_(NULL),
+ model_(model),
+ listener_(NULL),
+ selected_item_(0) {
+}
+
+Combobox::~Combobox() {
+}
+
+void Combobox::ModelChanged() {
+ selected_item_ = std::min(0, model_->GetItemCount(this));
+ if (native_wrapper_)
+ native_wrapper_->UpdateFromModel();
+}
+
+void Combobox::SetSelectedItem(int index) {
+ selected_item_ = index;
+ if (native_wrapper_)
+ native_wrapper_->UpdateSelectedItem();
+}
+
+void Combobox::SelectionChanged() {
+ int prev_selected_item = selected_item_;
+ selected_item_ = native_wrapper_->GetSelectedItem();
+ if (listener_)
+ listener_->ItemChanged(this, prev_selected_item, selected_item_);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Combobox, View overrides:
+
+gfx::Size Combobox::GetPreferredSize() {
+ if (native_wrapper_)
+ return native_wrapper_->GetPreferredSize();
+ return gfx::Size();
+}
+
+void Combobox::Layout() {
+ if (native_wrapper_) {
+ native_wrapper_->GetView()->SetBounds(0, 0, width(), height());
+ native_wrapper_->GetView()->Layout();
+ }
+}
+
+void Combobox::SetEnabled(bool flag) {
+ View::SetEnabled(flag);
+ if (native_wrapper_)
+ native_wrapper_->UpdateEnabled();
+}
+
+// VK_ESCAPE should be handled by this view when the drop down list is active.
+// In other words, the list should be closed instead of the dialog.
+bool Combobox::OverrideAccelerator(const Accelerator& accelerator) {
+#if defined(OS_WIN)
+ if (accelerator != Accelerator(VK_ESCAPE, false, false, false))
+ return false;
+#else
+ NOTIMPLEMENTED();
+ // TODO(port): figure out VK_keys
+#endif
+ return native_wrapper_ && native_wrapper_->IsDropdownOpen();
+}
+
+void Combobox::Focus() {
+ // Forward the focus to the wrapper.
+ if (native_wrapper_)
+ native_wrapper_->SetFocus();
+ else
+ View::Focus(); // Will focus the RootView window (so we still get
+ // keyboard messages).
+}
+
+void Combobox::ViewHierarchyChanged(bool is_add, View* parent,
+ View* child) {
+ if (is_add && !native_wrapper_ && GetWidget()) {
+ native_wrapper_ = NativeComboboxWrapper::CreateWrapper(this);
+ native_wrapper_->UpdateFromModel();
+ native_wrapper_->UpdateEnabled();
+ AddChildView(native_wrapper_->GetView());
+ }
+}
+
+std::string Combobox::GetClassName() const {
+ return kViewClassName;
+}
+
+} // namespace views
diff --git a/views/controls/combobox/combobox.h b/views/controls/combobox/combobox.h
new file mode 100644
index 0000000..2bb63d2
--- /dev/null
+++ b/views/controls/combobox/combobox.h
@@ -0,0 +1,89 @@
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_
+#define VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_
+
+#include "views/view.h"
+
+namespace views {
+
+class NativeComboboxWrapper;
+
+// A non-editable combo-box.
+class Combobox : public View {
+ public:
+ // The combobox's class name.
+ static const char kViewClassName[];
+
+ class Model {
+ public:
+ // Return the number of items in the combo box.
+ virtual int GetItemCount(Combobox* source) = 0;
+
+ // Return the string that should be used to represent a given item.
+ virtual std::wstring GetItemAt(Combobox* source, int index) = 0;
+ };
+
+ class Listener {
+ public:
+ // This is invoked once the selected item changed.
+ virtual void ItemChanged(Combobox* combo_box,
+ int prev_index,
+ int new_index) = 0;
+ };
+
+ // |model| is not owned by the combo box.
+ explicit Combobox(Model* model);
+ virtual ~Combobox();
+
+ // Register |listener| for item change events.
+ void set_listener(Listener* listener) {
+ listener_ = listener;
+ }
+
+ // Inform the combo box that its model changed.
+ void ModelChanged();
+
+ // Gets/Sets the selected item.
+ int selected_item() const { return selected_item_; };
+ void SetSelectedItem(int index);
+
+ // Called when the combo box's selection is changed by the user.
+ void SelectionChanged();
+
+ // Accessor for |model_|.
+ Model* model() const { return model_; }
+
+ // Overridden from View:
+ virtual gfx::Size GetPreferredSize();
+ virtual void Layout();
+ virtual void SetEnabled(bool enabled);
+ virtual bool OverrideAccelerator(const Accelerator& accelerator);
+
+ protected:
+ virtual void Focus();
+ virtual void ViewHierarchyChanged(bool is_add, View* parent,
+ View* child);
+ virtual std::string GetClassName() const;
+
+ private:
+ // The object that actually implements the native combobox.
+ NativeComboboxWrapper* native_wrapper_;
+
+ // Our model.
+ Model* model_;
+
+ // Item change listener.
+ Listener* listener_;
+
+ // The current selection.
+ int selected_item_;
+
+ DISALLOW_COPY_AND_ASSIGN(Combobox);
+};
+
+} // namespace views
+
+#endif // VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_
diff --git a/views/controls/combobox/native_combobox_gtk.cc b/views/controls/combobox/native_combobox_gtk.cc
new file mode 100644
index 0000000..b6d2674
--- /dev/null
+++ b/views/controls/combobox/native_combobox_gtk.cc
@@ -0,0 +1,78 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
+// source code is governed by a BSD-style license that can be found in the
+// LICENSE file.
+
+#include "views/controls/combobox/native_combobox_gtk.h"
+
+#include "views/controls/combobox/combobox.h"
+
+namespace views {
+
+////////////////////////////////////////////////////////////////////////////////
+// NativeComboboxGtk, public:
+
+NativeComboboxGtk::NativeComboboxGtk(Combobox* combobox)
+ : combobox_(combobox) {
+}
+
+NativeComboboxGtk::~NativeComboboxGtk() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// NativeComboboxGtk, NativeComboboxWrapper implementation:
+
+void NativeComboboxGtk::UpdateFromModel() {
+ NOTIMPLEMENTED();
+}
+
+void NativeComboboxGtk::UpdateSelectedItem() {
+ NOTIMPLEMENTED();
+}
+
+void NativeComboboxGtk::UpdateEnabled() {
+ NOTIMPLEMENTED();
+}
+
+int NativeComboboxGtk::GetSelectedItem() const {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+bool NativeComboboxGtk::IsDropdownOpen() const {
+ NOTIMPLEMENTED();
+ return false;
+}
+
+gfx::Size NativeComboboxGtk::GetPreferredSize() const {
+ NOTIMPLEMENTED();
+ return gfx::Size();
+}
+
+View* NativeComboboxGtk::GetView() {
+ return this;
+}
+
+void NativeComboboxGtk::SetFocus() {
+ Focus();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// NativeComboboxGtk, NativeControlGtk overrides:
+
+void NativeComboboxGtk::CreateNativeControl() {
+}
+
+void NativeComboboxGtk::NativeControlCreated(GtkWidget* native_control) {
+ NativeControlGtk::NativeControlCreated(native_control);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// NativeComboboxWrapper, public:
+
+// static
+NativeComboboxWrapper* NativeComboboxWrapper::CreateWrapper(
+ Combobox* combobox) {
+ return new NativeComboboxGtk(combobox);
+}
+
+} // namespace views
diff --git a/views/controls/combobox/native_combobox_gtk.h b/views/controls/combobox/native_combobox_gtk.h
new file mode 100644
index 0000000..2405697
--- /dev/null
+++ b/views/controls/combobox/native_combobox_gtk.h
@@ -0,0 +1,43 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
+// source code is governed by a BSD-style license that can be found in the
+// LICENSE file.
+
+#ifndef VIEWS_CONTROLS_COMBOBOX_NATIVE_COMBOBOX_GTK_H_
+#define VIEWS_CONTROLS_COMBOBOX_NATIVE_COMBOBOX_GTK_H_
+
+#include "views/controls/combobox/native_combobox_wrapper.h"
+#include "views/controls/native_control_gtk.h"
+
+namespace views {
+
+class NativeComboboxGtk : public NativeControlGtk,
+ public NativeComboboxWrapper {
+ public:
+ explicit NativeComboboxGtk(Combobox* combobox);
+ virtual ~NativeComboboxGtk();
+
+ // Overridden from NativeComboboxWrapper:
+ virtual void UpdateFromModel();
+ virtual void UpdateSelectedItem();
+ virtual void UpdateEnabled();
+ virtual int GetSelectedItem() const;
+ virtual bool IsDropdownOpen() const;
+ virtual gfx::Size GetPreferredSize() const;
+ virtual View* GetView();
+ virtual void SetFocus();
+
+ protected:
+ // Overridden from NativeControlGtk:
+ virtual void CreateNativeControl();
+ virtual void NativeControlCreated(GtkWidget* widget);
+
+ private:
+ // The combobox we are bound to.
+ Combobox* combobox_;
+
+ DISALLOW_COPY_AND_ASSIGN(NativeComboboxGtk);
+};
+
+} // namespace views
+
+#endif // VIEWS_CONTROLS_COMBOBOX_NATIVE_COMBOBOX_GTK_H_
diff --git a/views/controls/combobox/native_combobox_win.cc b/views/controls/combobox/native_combobox_win.cc
new file mode 100644
index 0000000..4562897
--- /dev/null
+++ b/views/controls/combobox/native_combobox_win.cc
@@ -0,0 +1,184 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
+// source code is governed by a BSD-style license that can be found in the
+// LICENSE file.
+
+#include "views/controls/combobox/native_combobox_win.h"
+
+#include "app/gfx/font.h"
+#include "app/l10n_util.h"
+#include "app/resource_bundle.h"
+#include "base/gfx/native_theme.h"
+#include "views/controls/combobox/combobox.h"
+#include "views/widget/widget.h"
+
+namespace views {
+
+// Limit how small a combobox can be.
+static const int kMinComboboxWidth = 148;
+
+// Add a couple extra pixels to the widths of comboboxes and combobox
+// dropdowns so that text isn't too crowded.
+static const int kComboboxExtraPaddingX = 6;
+
+////////////////////////////////////////////////////////////////////////////////
+// NativeComboboxWin, public:
+
+NativeComboboxWin::NativeComboboxWin(Combobox* combobox)
+ : combobox_(combobox),
+ content_width_(0) {
+}
+
+NativeComboboxWin::~NativeComboboxWin() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// NativeComboboxWin, NativeComboboxWrapper implementation:
+
+void NativeComboboxWin::UpdateFromModel() {
+ SendMessage(native_view(), CB_RESETCONTENT, 0, 0);
+ gfx::Font font = ResourceBundle::GetSharedInstance().GetFont(
+ ResourceBundle::BaseFont);
+ int max_width = 0;
+ int num_items = combobox_->model()->GetItemCount(combobox_);
+ for (int i = 0; i < num_items; ++i) {
+ const std::wstring& text = combobox_->model()->GetItemAt(combobox_, i);
+
+ // Inserting the Unicode formatting characters if necessary so that the
+ // text is displayed correctly in right-to-left UIs.
+ std::wstring localized_text;
+ const wchar_t* text_ptr = text.c_str();
+ if (l10n_util::AdjustStringForLocaleDirection(text, &localized_text))
+ text_ptr = localized_text.c_str();
+
+ SendMessage(native_view(), CB_ADDSTRING, 0,
+ reinterpret_cast<LPARAM>(text_ptr));
+ max_width = std::max(max_width, font.GetStringWidth(text));
+ }
+ content_width_ = max_width;
+
+ if (num_items > 0) {
+ SendMessage(native_view(), CB_SETCURSEL, combobox_->selected_item(), 0);
+
+ // Set the width for the drop down while accounting for the scrollbar and
+ // borders.
+ if (num_items > ComboBox_GetMinVisible(native_view()))
+ max_width += GetSystemMetrics(SM_CXVSCROLL);
+ // SM_CXEDGE would not be correct here, since the dropdown is flat, not 3D.
+ int kComboboxDropdownBorderSize = 1;
+ max_width += 2 * kComboboxDropdownBorderSize + kComboboxExtraPaddingX;
+ SendMessage(native_view(), CB_SETDROPPEDWIDTH, max_width, 0);
+ }
+}
+
+void NativeComboboxWin::UpdateSelectedItem() {
+ // Note that we use CB_SETCURSEL and not CB_SELECTSTRING because on RTL
+ // locales the strings we get from our ComboBox::Model might be augmented
+ // with Unicode directionality marks before we insert them into the combo box
+ // and therefore we can not assume that the string we get from
+ // ComboBox::Model can be safely searched for and selected (which is what
+ // CB_SELECTSTRING does).
+ SendMessage(native_view(), CB_SETCURSEL, combobox_->selected_item(), 0);
+}
+
+void NativeComboboxWin::UpdateEnabled() {
+ SetEnabled(combobox_->IsEnabled());
+}
+
+int NativeComboboxWin::GetSelectedItem() const {
+ LRESULT selected_item = SendMessage(native_view(), CB_GETCURSEL, 0, 0);
+ return selected_item != CB_ERR ? selected_item : -1;
+}
+
+bool NativeComboboxWin::IsDropdownOpen() const {
+ return SendMessage(native_view(), CB_GETDROPPEDSTATE, 0, 0) != 0;
+}
+
+gfx::Size NativeComboboxWin::GetPreferredSize() const {
+ COMBOBOXINFO cbi = { 0 };
+ cbi.cbSize = sizeof(cbi);
+ // Note: Don't use CB_GETCOMBOBOXINFO since that crashes on WOW64 systems
+ // when you have a global message hook installed.
+ GetComboBoxInfo(native_view(), &cbi);
+ gfx::Rect rect_item(cbi.rcItem);
+ gfx::Rect rect_button(cbi.rcButton);
+ gfx::Size border = gfx::NativeTheme::instance()->GetThemeBorderSize(
+ gfx::NativeTheme::MENULIST);
+
+ // The padding value of '3' is the xy offset from the corner of the control
+ // to the corner of rcItem. It does not seem to be queryable from the theme.
+ // It is consistent on all versions of Windows from 2K to Vista, and is
+ // invariant with respect to the combobox border size. We could conceivably
+ // get this number from rect_item.x, but it seems fragile to depend on
+ // position here, inside of the layout code.
+ const int kItemOffset = 3;
+ int item_to_button_distance = std::max(kItemOffset - border.width(), 0);
+
+ // The cx computation can be read as measuring from left to right.
+ int pref_width = std::max(kItemOffset + content_width_ +
+ kComboboxExtraPaddingX +
+ item_to_button_distance + rect_button.width() +
+ border.width(), kMinComboboxWidth);
+ // The two arguments to ::max below should be typically be equal.
+ int pref_height = std::max(rect_item.height() + 2 * kItemOffset,
+ rect_button.height() + 2 * border.height());
+ return gfx::Size(pref_width, pref_height);
+}
+
+View* NativeComboboxWin::GetView() {
+ return this;
+}
+
+void NativeComboboxWin::SetFocus() {
+ Focus();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// NativeComboboxWin, NativeControlWin overrides:
+
+bool NativeComboboxWin::ProcessMessage(UINT message,
+ WPARAM w_param,
+ LPARAM l_param,
+ LRESULT* result) {
+ if (message == WM_COMMAND && HIWORD(w_param) == CBN_SELCHANGE) {
+ combobox_->SelectionChanged();
+ *result = 0;
+ return true;
+ }
+ return NativeControlWin::ProcessMessage(message, w_param, l_param, result);
+}
+
+void NativeComboboxWin::CreateNativeControl() {
+ DWORD flags = WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBS_DROPDOWNLIST;
+ HWND control_hwnd = ::CreateWindowEx(GetAdditionalExStyle(), L"COMBOBOX", L"",
+ flags, 0, 0, 100, 20, //width(), height(),
+ GetWidget()->GetNativeView(), NULL, NULL,
+ NULL);
+ NativeControlCreated(control_hwnd);
+}
+
+void NativeComboboxWin::NativeControlCreated(HWND native_control) {
+ NativeControlWin::NativeControlCreated(native_control);
+
+ UpdateFont();
+ UpdateFromModel();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// NativeComboboxWin, private:
+
+void NativeComboboxWin::UpdateFont() {
+ HFONT font = ResourceBundle::GetSharedInstance().
+ GetFont(ResourceBundle::BaseFont).hfont();
+ SendMessage(native_view(), WM_SETFONT, reinterpret_cast<WPARAM>(font), FALSE);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// NativeComboboxWrapper, public:
+
+// static
+NativeComboboxWrapper* NativeComboboxWrapper::CreateWrapper(
+ Combobox* combobox) {
+ return new NativeComboboxWin(combobox);
+}
+
+} // namespace views
diff --git a/views/controls/combobox/native_combobox_win.h b/views/controls/combobox/native_combobox_win.h
new file mode 100644
index 0000000..627b551
--- /dev/null
+++ b/views/controls/combobox/native_combobox_win.h
@@ -0,0 +1,52 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
+// source code is governed by a BSD-style license that can be found in the
+// LICENSE file.
+
+#ifndef VIEWS_CONTROLS_COMBOBOX_NATIVE_COMBOBOX_WIN_H_
+#define VIEWS_CONTROLS_COMBOBOX_NATIVE_COMBOBOX_WIN_H_
+
+#include "views/controls/combobox/native_combobox_wrapper.h"
+#include "views/controls/native_control_win.h"
+
+namespace views {
+
+class NativeComboboxWin : public NativeControlWin,
+ public NativeComboboxWrapper {
+ public:
+ explicit NativeComboboxWin(Combobox* combobox);
+ virtual ~NativeComboboxWin();
+
+ // Overridden from NativeComboboxWrapper:
+ virtual void UpdateFromModel();
+ virtual void UpdateSelectedItem();
+ virtual void UpdateEnabled();
+ virtual int GetSelectedItem() const;
+ virtual bool IsDropdownOpen() const;
+ virtual gfx::Size GetPreferredSize() const;
+ virtual View* GetView();
+ virtual void SetFocus();
+
+ protected:
+ // Overridden from NativeControlWin:
+ virtual bool ProcessMessage(UINT message,
+ WPARAM w_param,
+ LPARAM l_param,
+ LRESULT* result);
+ virtual void CreateNativeControl();
+ virtual void NativeControlCreated(HWND native_control);
+
+ private:
+ void UpdateFont();
+
+ // The combobox we are bound to.
+ Combobox* combobox_;
+
+ // The min width, in pixels, for the text content.
+ int content_width_;
+
+ DISALLOW_COPY_AND_ASSIGN(NativeComboboxWin);
+};
+
+} // namespace views
+
+#endif // VIEWS_CONTROLS_COMBOBOX_NATIVE_COMBOBOX_WIN_H_
diff --git a/views/controls/combobox/native_combobox_wrapper.h b/views/controls/combobox/native_combobox_wrapper.h
new file mode 100644
index 0000000..27e1c8b
--- /dev/null
+++ b/views/controls/combobox/native_combobox_wrapper.h
@@ -0,0 +1,48 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
+// source code is governed by a BSD-style license that can be found in the
+// LICENSE file.
+
+#ifndef VIEWS_CONTROLS_COMBOBOX_NATIVE_COMBOBOX_WRAPPER_H_
+#define VIEWS_CONTROLS_COMBOBOX_NATIVE_COMBOBOX_WRAPPER_H_
+
+namespace gfx{
+class Size;
+}
+
+namespace views {
+
+class Combobox;
+class View;
+
+class NativeComboboxWrapper {
+ public:
+ // Updates the combobox's content from its model.
+ virtual void UpdateFromModel() = 0;
+
+ // Updates the displayed selected item from the associated Combobox.
+ virtual void UpdateSelectedItem() = 0;
+
+ // Updates the enabled state of the combobox from the associated view.
+ virtual void UpdateEnabled() = 0;
+
+ // Gets the selected index.
+ virtual int GetSelectedItem() const = 0;
+
+ // Returns true if the Combobox dropdown is open.
+ virtual bool IsDropdownOpen() const = 0;
+
+ // Returns the preferred size of the combobox.
+ virtual gfx::Size GetPreferredSize() const = 0;
+
+ // Retrieves the views::View that hosts the native control.
+ virtual View* GetView() = 0;
+
+ // Sets the focus to the button.
+ virtual void SetFocus() = 0;
+
+ static NativeComboboxWrapper* CreateWrapper(Combobox* combobox);
+};
+
+} // namespace views
+
+#endif // VIEWS_CONTROLS_COMBOBOX_NATIVE_COMBOBOX_WRAPPER_H_
diff --git a/views/controls/native/native_view_host_win.cc b/views/controls/native/native_view_host_win.cc
index 0cbaaa7..04c9edc 100644
--- a/views/controls/native/native_view_host_win.cc
+++ b/views/controls/native/native_view_host_win.cc
@@ -51,6 +51,8 @@ void NativeViewHostWin::NativeViewDetaching() {
}
void NativeViewHostWin::AddedToWidget() {
+ if (!IsWindow(host_->native_view()))
+ return;
HWND parent_hwnd = GetParent(host_->native_view());
HWND widget_hwnd = host_->GetWidget()->GetNativeView();
if (parent_hwnd != widget_hwnd)
@@ -63,6 +65,8 @@ void NativeViewHostWin::AddedToWidget() {
}
void NativeViewHostWin::RemovedFromWidget() {
+ if (!IsWindow(host_->native_view()))
+ return;
ShowWindow(host_->native_view(), SW_HIDE);
SetParent(host_->native_view(), NULL);
}
diff --git a/views/controls/native_control_win.cc b/views/controls/native_control_win.cc
index eb188af..2d53f28 100644
--- a/views/controls/native_control_win.cc
+++ b/views/controls/native_control_win.cc
@@ -114,13 +114,20 @@ void NativeControlWin::ShowContextMenu(const gfx::Point& location) {
void NativeControlWin::NativeControlCreated(HWND native_control) {
// Associate this object with the control's HWND so that WidgetWin can find
// this object when it receives messages from it.
+ // Note that we never unset this property. We don't have to.
SetProp(native_control, kNativeControlWinKey, this);
- // Subclass the window so we can monitor for key presses.
- original_wndproc_ =
- win_util::SetWindowProc(native_control,
- &NativeControlWin::NativeControlWndProc);
- SetProp(native_control, kNativeControlOriginalWndProcKey, original_wndproc_);
+ // Subclass the window so we can monitor for key presses. It's important that
+ // we *only* do this if the derived class wants to intercept keypresses,
+ // because otherwise the subclass can mysteriously interfere with certain
+ // other controls, like the combobox, and cause weird effects.
+ if (NotifyOnKeyDown()) {
+ original_wndproc_ =
+ win_util::SetWindowProc(native_control,
+ &NativeControlWin::NativeControlWndProc);
+ SetProp(native_control, kNativeControlOriginalWndProcKey,
+ original_wndproc_);
+ }
Attach(native_control);
// native_view() is now valid.
@@ -188,7 +195,6 @@ LRESULT NativeControlWin::NativeControlWndProc(HWND window,
return 0;
} else if (message == WM_DESTROY) {
win_util::SetWindowProc(window, native_control->original_wndproc_);
- RemoveProp(window, kNativeControlWinKey);
}
return CallWindowProc(native_control->original_wndproc_, window, message,
diff --git a/views/controls/native_control_win.h b/views/controls/native_control_win.h
index eee4ded8..4fb5244 100644
--- a/views/controls/native_control_win.h
+++ b/views/controls/native_control_win.h
@@ -24,9 +24,9 @@ class NativeControlWin : public NativeViewHost {
// Returns true if the message was handled, with a valid result in |result|.
// Returns false if the message was not handled.
virtual bool ProcessMessage(UINT message,
- WPARAM w_param,
- LPARAM l_param,
- LRESULT* result);
+ WPARAM w_param,
+ LPARAM l_param,
+ LRESULT* result);
// Called by our subclassed window procedure when a WM_KEYDOWN message is
// received by the HWND created by an object derived from NativeControlWin.
diff --git a/views/views.gyp b/views/views.gyp
index 750588a..97caf78 100644
--- a/views/views.gyp
+++ b/views/views.gyp
@@ -85,8 +85,13 @@
'controls/button/radio_button.h',
'controls/button/text_button.cc',
'controls/button/text_button.h',
- 'controls/combo_box.cc',
- 'controls/combo_box.h',
+ 'controls/combobox/combobox.cc',
+ 'controls/combobox/combobox.h',
+ 'controls/combobox/native_combobox_gtk.cc',
+ 'controls/combobox/native_combobox_gtk.h',
+ 'controls/combobox/native_combobox_win.cc',
+ 'controls/combobox/native_combobox_win.h',
+ 'controls/combobox/native_combobox_wrapper.h',
'controls/image_view.cc',
'controls/image_view.h',
'controls/label.cc',