CustomFrameView::CustomFrameView(Widget* frame) : close_button_(new ImageButton(this)), restore_button_(new ImageButton(this)), maximize_button_(new ImageButton(this)), minimize_button_(new ImageButton(this)), window_icon_(NULL), should_show_minmax_buttons_(false), should_show_client_edge_(false), frame_(frame) { InitClass(); ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); close_button_->SetAccessibleName( ui::GetStringUTF16(IDS_APP_ACCNAME_CLOSE)); // Close button images will be set in LayoutWindowControls(). AddChildView(close_button_); restore_button_->SetAccessibleName( ui::GetStringUTF16(IDS_APP_ACCNAME_RESTORE)); restore_button_->SetImage(CustomButton::BS_NORMAL, rb.GetBitmapNamed(IDR_RESTORE)); restore_button_->SetImage(CustomButton::BS_HOT, rb.GetBitmapNamed(IDR_RESTORE_H)); restore_button_->SetImage(CustomButton::BS_PUSHED, rb.GetBitmapNamed(IDR_RESTORE_P)); AddChildView(restore_button_); maximize_button_->SetAccessibleName( ui::GetStringUTF16(IDS_APP_ACCNAME_MAXIMIZE)); maximize_button_->SetImage(CustomButton::BS_NORMAL, rb.GetBitmapNamed(IDR_MAXIMIZE)); maximize_button_->SetImage(CustomButton::BS_HOT, rb.GetBitmapNamed(IDR_MAXIMIZE_H)); maximize_button_->SetImage(CustomButton::BS_PUSHED, rb.GetBitmapNamed(IDR_MAXIMIZE_P)); AddChildView(maximize_button_); minimize_button_->SetAccessibleName( ui::GetStringUTF16(IDS_APP_ACCNAME_MINIMIZE)); minimize_button_->SetImage(CustomButton::BS_NORMAL, rb.GetBitmapNamed(IDR_MINIMIZE)); minimize_button_->SetImage(CustomButton::BS_HOT, rb.GetBitmapNamed(IDR_MINIMIZE_H)); minimize_button_->SetImage(CustomButton::BS_PUSHED, rb.GetBitmapNamed(IDR_MINIMIZE_P)); AddChildView(minimize_button_); should_show_minmax_buttons_ = frame_->widget_delegate()->CanMaximize(); should_show_client_edge_ = frame_->widget_delegate()->ShouldShowClientEdge(); if(frame_->widget_delegate()->ShouldShowWindowIcon()) { window_icon_ = new ImageButton(this); AddChildView(window_icon_); } }
SingleSplitView::SingleSplitView(View* leading, View* trailing, Orientation orientation) : is_horizontal_(orientation==HORIZONTAL_SPLIT), divider_offset_(-1), resize_leading_on_bounds_change_(true) { AddChildView(leading); AddChildView(trailing); set_background(Background::CreateSolidBackground( gfx::Color(GetSysColor(COLOR_3DFACE)))); }
BaseTab::BaseTab(TabController* controller) : controller_(controller), closing_(false), dragging_(false), favicon_hiding_offset_(0), loading_animation_frame_(0), should_display_crashed_favicon_(false), throbber_disabled_(false), theme_provider_(NULL) { BaseTab::InitResources(); set_id(VIEW_ID_TAB); // Add the Close Button. close_button_ = new TabCloseButton(this); ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); close_button_->SetImage(view::CustomButton::BS_NORMAL, rb.GetBitmapNamed(IDR_TAB_CLOSE)); close_button_->SetImage(view::CustomButton::BS_HOT, rb.GetBitmapNamed(IDR_TAB_CLOSE_H)); close_button_->SetImage(view::CustomButton::BS_PUSHED, rb.GetBitmapNamed(IDR_TAB_CLOSE_P)); close_button_->SetTooltipText( UTF16ToWide(ui::GetStringUTF16(IDS_TOOLTIP_CLOSE_TAB))); close_button_->SetAccessibleName( ui::GetStringUTF16(IDS_ACCNAME_CLOSE)); // Disable animation so that the red danger sign shows up immediately // to help avoid mis-clicks. close_button_->SetAnimationDuration(0); AddChildView(close_button_); set_context_menu_controller(this); }
void Listbox::ViewHierarchyChanged(bool is_add, View* parent, View* child) { if(is_add && !native_wrapper_ && GetWidget()) { // The native wrapper's lifetime will be managed by the view hierarchy after // we call AddChildView. native_wrapper_ = NativeListboxWrapper::CreateNativeWrapper(this); AddChildView(native_wrapper_->GetView()); } }
void NativeScrollBar::ViewHierarchyChanged(bool is_add, View* parent, View* child) { Widget* widget; if(is_add && !native_wrapper_ && (widget=GetWidget())) { native_wrapper_ = NativeScrollBarWrapper::CreateWrapper(this); AddChildView(native_wrapper_->GetView()); } }
void NativeButton::ViewHierarchyChanged(bool is_add, View* parent, View* child) { if(is_add && !native_wrapper_ && GetWidget()) { // The native wrapper's lifetime will be managed by the view hierarchy // after we call AddChildView. native_wrapper_ = CreateWrapper(); AddChildView(native_wrapper_->GetView()); } }
AppContainer::AppContainer() : bounds_animator_(this), show_(true) { bounds_animator_.AddObserver(this); SetLayoutManager(new AppLayout(10, 10, 10)); for(int i=0; i<arraysize(app_infos); ++i) { AddChildView(new AppView(app_infos[i].icon_res_id, app_infos[i].app_name)); } }
void ClientView::ViewHierarchyChanged(bool is_add, View* parent, View* child) { if(is_add && child==this) { DCHECK(GetWidget()); DCHECK(contents_view_); // |contents_view_| must be valid now! // Insert |contents_view_| at index 0 so it is first in the focus chain. // (the OK/Cancel buttons are inserted before contents_view_) AddChildView(0, contents_view_); } }
void DialogClientView::CreateExtraView() { View* extra_view = GetDialogDelegate()->GetExtraView(); if(extra_view && !extra_view_) { extra_view_ = extra_view; extra_view_->SetGroup(kButtonGroup); AddChildView(extra_view_); size_extra_view_height_to_buttons_ = GetDialogDelegate()->GetSizeExtraViewHeightToButtons(); } }
void DialogClientView::SetBottomView(View* bottom_view) { if(bottom_view_) { RemoveChildView(bottom_view_); delete bottom_view_; } bottom_view_ = bottom_view; if(bottom_view_) { AddChildView(bottom_view_); } }
void BaseTabStrip::AddTabAt(int model_index, const TabRendererData& data) { BaseTab* tab = CreateTab(); tab->SetData(data); TabData d = { tab, gfx::Rect() }; tab_data_.insert(tab_data_.begin() + ModelIndexToTabIndex(model_index), d); AddChildView(tab); // Don't animate the first tab, it looks weird, and don't animate anything // if the containing window isn't visible yet. if(tab_count()>1 && GetWidget() && GetWidget()->IsVisible()) { StartInsertTabAnimation(model_index); } else { DoLayout(); } }
void TabContentsContainer::ChangeTabContents(TabContents* contents) { if(tab_contents_) { view::View *v = (tab_contents_->puttyView()); tab_contents_->WasHidden(); RemoveChildView(v); RemoveObservers(); } tab_contents_ = contents; // When detaching the last tab of the browser ChangeTabContents is invoked // with NULL. Don't attempt to do anything in that case. if(tab_contents_) { view::View *v = (contents->puttyView()); AddChildView(v); SetLayoutManager(new view::FillLayout()); Layout(); AddObservers(); tab_contents_->ShowContents(); } }
void DialogClientView::ShowDialogButtons() { DialogDelegate* dd = GetDialogDelegate(); int buttons = dd->GetDialogButtons(); if(buttons & ui::MessageBoxFlags::DIALOGBUTTON_OK && !ok_button_) { std::wstring label = dd->GetDialogButtonLabel( ui::MessageBoxFlags::DIALOGBUTTON_OK); if(label.empty()) { label = UTF16ToWide(ui::GetStringUTF16(IDS_APP_OK)); } bool is_default_button = (dd->GetDefaultDialogButton() & ui::MessageBoxFlags::DIALOGBUTTON_OK) != 0; ok_button_ = new DialogButton(this, GetWidget(), ui::MessageBoxFlags::DIALOGBUTTON_OK, label, is_default_button); ok_button_->SetGroup(kButtonGroup); if(is_default_button) { default_button_ = ok_button_; } if(!(buttons & ui::MessageBoxFlags::DIALOGBUTTON_CANCEL)) { ok_button_->AddAccelerator(Accelerator(ui::VKEY_ESCAPE, false, false, false)); } AddChildView(ok_button_); } if(buttons & ui::MessageBoxFlags::DIALOGBUTTON_CANCEL && !cancel_button_) { std::wstring label = dd->GetDialogButtonLabel( ui::MessageBoxFlags::DIALOGBUTTON_CANCEL); if(label.empty()) { if(buttons & ui::MessageBoxFlags::DIALOGBUTTON_OK) { label = UTF16ToWide(ui::GetStringUTF16(IDS_APP_CANCEL)); } else { label = UTF16ToWide(ui::GetStringUTF16(IDS_APP_CLOSE)); } } bool is_default_button = (dd->GetDefaultDialogButton() & ui::MessageBoxFlags::DIALOGBUTTON_CANCEL) != 0; cancel_button_ = new DialogButton(this, GetWidget(), ui::MessageBoxFlags::DIALOGBUTTON_CANCEL, label, is_default_button); cancel_button_->SetGroup(kButtonGroup); cancel_button_->AddAccelerator(Accelerator(ui::VKEY_ESCAPE, false, false, false)); if(is_default_button) { default_button_ = ok_button_; } AddChildView(cancel_button_); } if(!buttons) { // Register the escape key as an accelerator which will close the window // if there are no dialog buttons. AddAccelerator(Accelerator(ui::VKEY_ESCAPE, false, false, false)); } }