void Grid::OnCollectionItemChanged (Collection *col, DependencyObject *obj, PropertyChangedEventArgs *args) { if (PropertyHasValueNoAutoCreate (Panel::ChildrenProperty, col)) { if (args->GetId () == Grid::ColumnProperty || args->GetId () == Grid::RowProperty || args->GetId () == Grid::ColumnSpanProperty || args->GetId () == Grid::RowSpanProperty) { InvalidateMeasure (); // SL invalidates the measure on the child when these properties change. // Tested by MeasureAutoRows2 and ChangingGridPropertiesInvalidates ((UIElement *) obj)->InvalidateMeasure (); return; } } else if (col == GetColumnDefinitionsNoAutoCreate () || col == GetRowDefinitionsNoAutoCreate ()) { if (args->GetId() != ColumnDefinition::ActualWidthProperty && args->GetId() != RowDefinition::ActualHeightProperty) { InvalidateMeasure (); } return; } Panel::OnCollectionItemChanged (col, obj, args); }
void Border::OnPropertyChanged (PropertyChangedEventArgs *args, MoonError *error) { if (args->GetProperty ()->GetOwnerType() != Type::BORDER) { FrameworkElement::OnPropertyChanged (args, error); return; } if (args->GetId () == Border::ChildProperty){ if (args->GetOldValue() && args->GetOldValue()->AsUIElement()) { ElementRemoved (args->GetOldValue()->AsUIElement ()); SetSubtreeObject (NULL); if (args->GetOldValue()->Is(GetDeployment (), Type::FRAMEWORKELEMENT)) { args->GetOldValue()->AsFrameworkElement()->SetLogicalParent (NULL, error); if (error->number) return; } } if (args->GetNewValue() && args->GetNewValue()->AsUIElement()) { SetSubtreeObject (args->GetNewValue()->AsUIElement()); ElementAdded (args->GetNewValue()->AsUIElement ()); if (args->GetNewValue()->Is(GetDeployment (), Type::FRAMEWORKELEMENT)) { FrameworkElement *fwe = args->GetNewValue()->AsFrameworkElement (); if (fwe->GetLogicalParent() && fwe->GetLogicalParent() != this) { MoonError::FillIn (error, MoonError::ARGUMENT, "Content is already a child of another element"); return; } args->GetNewValue()->AsFrameworkElement()->SetLogicalParent (this, error); if (error->number) return; } } UpdateBounds (); InvalidateMeasure (); } else if (args->GetId () == Border::PaddingProperty || args->GetId () == Border::BorderThicknessProperty) { InvalidateMeasure (); } else if (args->GetId () == Border::BackgroundProperty) { Invalidate (); } else if (args->GetId () == Border::BorderBrushProperty) { Invalidate (); } NotifyListenersOfPropertyChange (args, error); }
void MediaBase::OnPropertyChanged (PropertyChangedEventArgs *args, MoonError *error) { if (args->GetProperty ()->GetOwnerType() != Type::MEDIABASE) { FrameworkElement::OnPropertyChanged (args, error); return; } if (args->GetId () == MediaBase::SourceProperty) { const char *uri = args->GetNewValue() ? args->GetNewValue()->AsString () : NULL; if (IsAttached () && AllowDownloads ()) { if (uri && *uri) { Downloader *dl; if ((dl = GetDeployment ()->CreateDownloader ())) { dl->Open ("GET", uri, GetDownloaderPolicy (uri)); SetSource (dl, ""); dl->unref (); } else { // we're shutting down } } else { SetSource (NULL, NULL); } } else { source_changed = true; } InvalidateMeasure (); } NotifyListenersOfPropertyChange (args, error); }
void ContentControl::OnPropertyChanged (PropertyChangedEventArgs *args, MoonError *error) { if (args->GetProperty ()->GetOwnerType () != Type::CONTENTCONTROL) { Control::OnPropertyChanged (args, error); return; } if (args->GetId () == ContentControl::ContentProperty) { if (args->GetOldValue() && args->GetOldValue()->Is(GetDeployment (), Type::FRAMEWORKELEMENT)) { if (GetContentSetsParent ()) { args->GetOldValue()->AsFrameworkElement()->SetLogicalParent (NULL, error); if (error->number) return; } } if (args->GetNewValue() && args->GetNewValue()->Is(GetDeployment (), Type::FRAMEWORKELEMENT)) { if (GetContentSetsParent ()) { args->GetNewValue()->AsFrameworkElement()->SetLogicalParent (this, error); if (error->number) return; } } if (HasHandlers (ContentControl::ContentControlChangedEvent)) Emit (ContentControl::ContentControlChangedEvent, new ContentControlChangedEventArgs (args->GetOldValue(), args->GetNewValue())); InvalidateMeasure (); } NotifyListenersOfPropertyChange (args, error); }
void Image::ImageFailed (ImageErrorEventArgs *args) { BitmapSource *source = (BitmapSource*) GetSource (); if (source->Is (Type::BITMAPIMAGE)) { source->RemoveHandler (BitmapImage::DownloadProgressEvent, download_progress, this); source->RemoveHandler (BitmapImage::ImageOpenedEvent, image_opened, this); source->RemoveHandler (BitmapImage::ImageFailedEvent, image_failed, this); } source->RemoveHandler (BitmapSource::PixelDataChangedEvent, source_pixel_data_changed, this); InvalidateArrange (); InvalidateMeasure (); UpdateBounds (); Invalidate (); args = new ImageErrorEventArgs (this, *(MoonError*)args->GetMoonError ()); if (HasHandlers (ImageFailedEvent)) { Emit (ImageFailedEvent, args); } else { GetDeployment ()->GetSurface ()->EmitError (args); } }
void Image::set_Source(IImageSource* pSource) { if (m_Source != pSource) { m_Source = pSource; InvalidateMeasure(); } }
void Grid::OnCollectionChanged (Collection *col, CollectionChangedEventArgs *args) { if (PropertyHasValueNoAutoCreate (Grid::ColumnDefinitionsProperty, col) || PropertyHasValueNoAutoCreate (Grid::RowDefinitionsProperty, col)) { InvalidateMeasure (); } else { Panel::OnCollectionChanged (col, args); } }
void Image::OnSubPropertyChanged (DependencyProperty *prop, DependencyObject *obj, PropertyChangedEventArgs *subobj_args) { if (prop && (prop->GetId () == Image::SourceProperty || prop->GetId () == MediaBase::SourceProperty)) { InvalidateMeasure (); Invalidate (); return; } MediaBase::OnSubPropertyChanged (prop, obj, subobj_args); }
void CXTPMarkupWindowContainer::SetChild(HWND hWnd) { m_hWndChild = hWnd; CRect rc; ::GetWindowRect(m_hWndChild, &rc); m_szChild = rc.Size(); InvalidateMeasure(); InvalidateVisual(); }
void DockPanel::RemoveChildren() { // ?? get_Children()->m_items.clear(); // ASSERT(0); #if 0 for (int i = get_rchildList()->get_Size()-1; i >= 0; i--) { RemoveRChild((*get_rchildList())[i]); } #endif InvalidateMeasure(); }
void Image::OnPropertyChanged (PropertyChangedEventArgs *args, MoonError *error) { if (args->GetProperty ()->GetOwnerType() != Type::IMAGE) { MediaBase::OnPropertyChanged (args, error); return; } if (args->GetId () == Image::SourceProperty) { ImageSource *source = args->GetNewValue () ? args->GetNewValue ()->AsImageSource () : NULL; ImageSource *old = args->GetOldValue () ? args->GetOldValue ()->AsImageSource () : NULL; if (old) { if (old->Is(Type::BITMAPSOURCE)) { old->RemoveHandler (BitmapSource::PixelDataChangedEvent, source_pixel_data_changed, this); } if (old->Is(Type::BITMAPIMAGE)) { old->RemoveHandler (BitmapImage::DownloadProgressEvent, download_progress, this); old->RemoveHandler (BitmapImage::ImageOpenedEvent, image_opened, this); old->RemoveHandler (BitmapImage::ImageFailedEvent, image_failed, this); } } if (source) { if (source->Is(Type::BITMAPSOURCE)) { source->AddHandler (BitmapSource::PixelDataChangedEvent, source_pixel_data_changed, this); } if (source->Is(Type::BITMAPIMAGE)) { source->AddHandler (BitmapImage::DownloadProgressEvent, download_progress, this); source->AddHandler (BitmapImage::ImageOpenedEvent, image_opened, this); source->AddHandler (BitmapImage::ImageFailedEvent, image_failed, this); } if (source->GetPixelWidth () > 0 && source->GetPixelHeight () > 0) { RoutedEventArgs *args = MoonUnmanagedFactory::CreateRoutedEventArgs (); ImageOpened (args); args->unref (); } } else { UpdateBounds (); Invalidate (); } InvalidateMeasure (); } // we need to notify attachees if our DownloadProgress changed. NotifyListenersOfPropertyChange (args, error); }
void Control::OnPropertyChanged (PropertyChangedEventArgs *args, MoonError *error) { if (args->GetProperty ()->GetOwnerType() != Type::CONTROL) { FrameworkElement::OnPropertyChanged (args, error); return; } if (args->GetId () == Control::TemplateProperty) { if (GetSubtreeObject ()) ElementRemoved ((UIElement *) GetSubtreeObject ()); InvalidateMeasure (); } else if (args->GetId () == Control::PaddingProperty || args->GetId () == Control::BorderThicknessProperty) { InvalidateMeasure (); } else if (args->GetId () == Control::IsEnabledProperty) { if (!args->GetNewValue ()->AsBool ()) { Surface *surface = Deployment::GetCurrent ()->GetSurface (); if (surface && surface->GetFocusedElement () == this) { // Ensure this element loses focus, then try to focus the next suitable element surface->FocusElement (NULL); TabNavigationWalker::Focus (this, true); } ReleaseMouseCapture (); } PropertyChangedEventArgs *pargs = new PropertyChangedEventArgs (args->GetProperty(), args->GetId (), args->GetOldValue(), args->GetNewValue()); EmitAsync (IsEnabledChangedEvent, pargs); } else if (args->GetId () == Control::HorizontalContentAlignmentProperty || args->GetId () == Control::VerticalContentAlignmentProperty) { InvalidateArrange (); } NotifyListenersOfPropertyChange (args, error); }
void TabControl::OnItemSelected(suic::ObjectPtr item, ItemSelectionEventArg& e) { __super::OnItemSelected(item, e); // // 设置测量大小脏区域标志,使布局管理器重新元素测量大小 // RaisedMeasureDirty(); // // 刷新布局和显示 // InvalidateMeasure(); InvalidateArrange(); InvalidateVisual(); }
void Grid::OnPropertyChanged (PropertyChangedEventArgs *args, MoonError *error) { if (args->GetProperty ()->GetOwnerType() != Type::GRID) { Panel::OnPropertyChanged (args, error); return; } if (args->GetId () == Grid::ShowGridLinesProperty){ Invalidate (); } InvalidateMeasure (); NotifyListenersOfPropertyChange (args, error); }
void TreeItem::OnLButtonDown(MouseButtonEventArgs* evt) { // m_ContentBorder->put_BackgroundBrush(new SolidColorBrush(new Color(80, 160, 220))); ASSERT(0); #if 0 if (dynamic_cast<UIElement*>(evt->get_target())->IsDescendantOf(m_ExpandButton)) { if (CanExpand()) { Event* evt2 = new Event; evt2->InitEvent(WSTR("ItemExpanding"), true, true); bool doDefault = dispatchEvent(evt2); if (doDefault) { bool m_expanded = m_Children->get_Visibility() != Collapsed; m_expanded = !m_expanded; if (m_expanded) dynamic_cast<Border*>(m_ExpandButton->get_Child())->set_Child(new TextString(WSTR("-"))); else dynamic_cast<Border*>(m_ExpandButton->get_Child())->set_Child(new TextString(WSTR("+"))); m_Children->set_Visibility(m_expanded? Visible: Collapsed); m_Children->InvalidateMeasure(); InvalidateMeasure(); } } /* else { InvalidateRender(); } */ } else { MouseEvent* evt2 = new MouseEvent; evt2->InitMouseEvent(WSTR("click"), evt->GetOwnerWindow(), evt->get_ScreenX(), evt->get_ScreenY(), evt->m_bShift, evt->m_bCtrl); bool doDefault = dispatchEvent(evt2); } #endif }
void Image::ImageOpened (RoutedEventArgs *args) { BitmapSource *source = (BitmapSource*)GetSource (); if (source->Is (Type::BITMAPIMAGE)) { source->RemoveHandler (BitmapImage::DownloadProgressEvent, download_progress, this); source->RemoveHandler (BitmapImage::ImageOpenedEvent, image_opened, this); source->RemoveHandler (BitmapImage::ImageFailedEvent, image_failed, this); } InvalidateArrange (); InvalidateMeasure (); UpdateBounds (); Invalidate (); if (HasHandlers (ImageOpenedEvent)) { args->ref (); // to counter the unref in Emit Emit (ImageOpenedEvent, args); } }
void UIElement::OnComputedPropertyValueChanged(PropertyValue* pPropertyVal, bool handled) { if (pPropertyVal->m_dp == get_CursorProperty()) { IRootVisual* root = GetRoot(); if (root) { root->ElementSetMouseCursor(this); } } else if (pPropertyVal->m_dp == get_ShadowTreeProperty()) { if (!handled) { UIElement* shadowTree = get_ShadowTree(); if (shadowTree) { shadowTree->SetRoot(GetRoot()); shadowTree->set_ParentWindow(get_ParentWindow()); shadowTree->set_Parent(this); shadowTree->set_TemplatedOwner(this); InvalidateMeasure(); } } } else if (pPropertyVal->m_dp == get_ParentProperty()) { UIElement* parent = get_Parent(); if (parent) { SetTreeLevel(parent->get_TreeLevel()+1); parent->InvalidateArrange(); } else { set_TreeLevel(0); } } else if (pPropertyVal->m_dp == get_ParentWindowProperty()) { Window* parentwindow = get_ParentWindow(); UIElement* shadowTree = get_ShadowTree(); if (shadowTree) { shadowTree->set_ParentWindow(parentwindow); } size_t nchildren = GetChildrenCount(); for (size_t i = 0; i < nchildren; ++i) { Visual* child = GetChild(i); ASSERT(child); child->set_ParentWindow(parentwindow); } } else if (pPropertyVal->m_dp == get_TemplatedOwnerProperty()) { UIElement* owner = get_TemplatedOwner(); size_t nchildren = GetChildrenCount(); for (size_t i = 0; i < nchildren; ++i) { Visual* child = GetChild(i); ASSERT(child); child->set_TemplatedOwner(owner); } } else if (pPropertyVal->m_dp == get_WidthProperty()) { InvalidateMeasure(); /* float minWidth = get_MinWidth(); float width = get_Width(); if (width < minWidth) width = minWidth; set_ActualWidth(width); */ } else if (pPropertyVal->m_dp == get_HeightProperty()) { InvalidateMeasure(); /* float minHeight = get_MinHeight(); float height = get_Height(); if (height < minHeight) height = minHeight; set_ActualHeight(height); */ } else if (pPropertyVal->m_dp == get_ActualWidthProperty() || pPropertyVal->m_dp == get_ActualHeightProperty()) { #if 0 m_visibleGeometryValid = false; get_Parent(); m_measureValid = false; WindowVisual* w = dynamic_cast<WindowVisual*>(GetRoot()); if (w) { w->AddArrange(this, get_TreeLevel()); // w->m_arrangeList.push_back(this); } /* // Not here for (size_t i = 0; i < GetChildrenCount(); ++i) { Visual* child = GetChild(i); child->DoLayoutSize(); } */ #endif } baseClass::OnComputedPropertyValueChanged(pPropertyVal, handled); }
void Window::OnComputedPropertyValueChanged(PropertyValue* pPropertyVal, bool handled) { if (pPropertyVal->m_dp == get_IsActiveProperty()) { if (m_platformWindow) { bool isActive = get_IsActive(); if (isActive) { SetForegroundWindow(m_platformWindow->get_Handle()); //::SetWindowPos(m_platformWindow->get_Handle(), HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE/* | SWP_NOZORDER*/); } } } else if (pPropertyVal->m_dp == get_OpacityProperty()) { if (m_platformWindow) { m_platformWindow->OnOpacityChanged(); } } else if (pPropertyVal->m_dp == get_ClipProperty()) { if (m_platformWindow) { m_platformWindow->OnClipChanged(); } } else if (pPropertyVal->m_dp == get_TitleTextProperty()) { if (m_platformWindow) { m_platformWindow->OnTitleTextChanged(); } } else if (pPropertyVal->m_dp == get_CanMinimizeProperty()) { if (m_platformWindow) { bool has = get_CanMaximize(); DWORD style = GetWindowLongW(m_platformWindow->get_Handle(), GWL_STYLE); if (has) style |= WS_MINIMIZEBOX; else style &= ~WS_MINIMIZEBOX; SetWindowLongW(m_platformWindow->get_Handle(), GWL_STYLE, style); } } else if (pPropertyVal->m_dp == get_CanMaximizeProperty()) { if (m_platformWindow) { bool has = get_CanMaximize(); DWORD style = GetWindowLongW(m_platformWindow->get_Handle(), GWL_STYLE); if (has) style |= WS_MAXIMIZEBOX; else style &= ~WS_MAXIMIZEBOX; SetWindowLongW(m_platformWindow->get_Handle(), GWL_STYLE, style); } } else if (pPropertyVal->m_dp == get_HasContextHelpProperty()) { if (m_platformWindow) { bool has = get_HasContextHelp(); DWORD exstyle = GetWindowLongW(m_platformWindow->get_Handle(), GWL_EXSTYLE); if (has) exstyle |= WS_EX_CONTEXTHELP; else exstyle &= ~WS_EX_CONTEXTHELP; SetWindowLongW(m_platformWindow->get_Handle(), GWL_EXSTYLE, exstyle); } } else if (pPropertyVal->m_dp == get_ShowInTaskbarProperty()) { if (m_platformWindow) { bool show = get_ShowInTaskbar(); /* DWORD exstyle = GetWindowLongW(m_platformWindow->get_Handle(), GWL_EXSTYLE); if (show) { exstyle |= WS_EX_APPWINDOW; exstyle &= ~WS_EX_TOOLWINDOW; } else { exstyle &= ~WS_EX_APPWINDOW; exstyle |= WS_EX_TOOLWINDOW; } SetWindowLongW(m_platformWindow->get_Handle(), GWL_EXSTYLE, exstyle); */ if (show) { MS::Windows::Shell::Private::pTaskbarList->AddTab(m_platformWindow->get_Handle()); } else { MS::Windows::Shell::Private::pTaskbarList->DeleteTab(m_platformWindow->get_Handle()); } } } else if (pPropertyVal->m_dp == get_FontFamilyProperty() || pPropertyVal->m_dp == get_FontSizeProperty() || pPropertyVal->m_dp == get_FontWeightProperty() || pPropertyVal->m_dp == get_FontStyleProperty()) { if (m_platformWindow) { LOGFONT lf = {0}; // TODO: Copy16 wcscpy_s(lf.lfFaceName, get_FontFamily().c_strw_flen<LF_FACESIZE>()); lf.lfHeight = -get_FontSize(); lf.lfWeight = get_FontWeight(); HFONT hFont = CreateFontIndirect(&lf); ASSERT(hFont); SendMessageW(m_platformWindow->get_Handle(), WM_SETFONT, (WPARAM)hFont, TRUE/*bRedraw*/); /* String titleText = get_TitleText(); SetWindowTextW(m_platformWindow->get_Handle(), CStringw(titleText).c_str()); */ } } else if (pPropertyVal->m_dp == get_TopmostProperty()) { if (m_platformWindow) { bool topmost = get_Topmost(); if (topmost) SetWindowPos(m_platformWindow->get_Handle(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); else SetWindowPos(m_platformWindow->get_Handle(), HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); } } else if (pPropertyVal->m_dp == get_StateProperty()) { if (m_platformWindow) { int state = GetPropertyValueInt(get_StateProperty()); switch (state) { case 0: ::ShowWindow(m_platformWindow->get_Handle(), SW_RESTORE); break; case 1: ::ShowWindow(m_platformWindow->get_Handle(), SW_MINIMIZE); break; case 2: ::ShowWindow(m_platformWindow->get_Handle(), SW_MAXIMIZE); break; } } } else if (pPropertyVal->m_dp == get_IsEnabledProperty()) { if (m_platformWindow) { bool isEnabled = get_IsEnabled(); ::EnableWindow(m_platformWindow->get_Handle(), isEnabled); } } else if (pPropertyVal->m_dp == get_CanCloseProperty()) { if (m_platformWindow) { if (get_CanClose()) { // SetWindowLongPtr(m_platformWindow->get_Handle(), } else { } /* ULONG_PTR classStyle = ::GetClassLongPtr(m_platformWindow->get_Handle(), GCL_STYLE); if (get_CanClose()) classStyle &= ~CS_NOCLOSE; else classStyle |= CS_NOCLOSE; ::SetClassLongPtr(m_platformWindow->get_Handle(), GCL_STYLE, classStyle); */ } } else if (pPropertyVal->m_dp == get_LeftProperty() || pPropertyVal->m_dp == get_TopProperty()) { if (m_platformWindow) { int x = int(get_Left()); int y = int(get_Top()); int cx = int(get_ActualWidth()); // ceil?? int cy = int(get_ActualHeight()); // ceil?? if (!get_InSizeMove() && !m_inSizeMove) { ::SetWindowPos(m_platformWindow->get_Handle(), nullptr, x, y, cx, cy, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE/* | SWP_ASYNCWINDOWPOS // ??*/ ); } } } else if (pPropertyVal->m_dp == get_ActualWidthProperty() || pPropertyVal->m_dp == get_ActualHeightProperty()) { if (m_platformWindow) { int x = int(get_Left()); int y = int(get_Top()); int cx = int(get_ActualWidth()); // ceil?? int cy = int(get_ActualHeight()); // ceil?? if (!get_InSizeMove() && !m_inSizeMove) { ::SetWindowPos(m_platformWindow->get_Handle(), nullptr, x, y, cx, cy, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE/* | SWP_ASYNCWINDOWPOS // ??*/ ); } } } else if (pPropertyVal->m_dp == get_RTProperty()) { if (m_platformWindow) { m_platformWindow->ChangeTech(); } } #if 0 else if (pPropertyVal->m_dp == get_ChildProperty()) { /* MessageBeep(-1); if (m_platformWindow) { } */ InvalidateVisual(); } #endif else if (pPropertyVal->m_dp == get_ShadowTreeProperty()) { UIElement* uielement = get_ShadowTree(); if (uielement) { uielement->SetRoot(this); // This is different from default UIElement implementation uielement->set_ParentWindow(this); // This is different from default UIElement implementation uielement->set_Parent(this); uielement->set_TemplatedOwner(this); // ?? InvalidateMeasure(); // // ?? // uielement->ArrangeCore(gm::SizeF(get_ActualWidth(), get_ActualHeight())); } handled = true; } else if (pPropertyVal->m_dp == get_OwnerProperty()) { Window* owner = get_Owner(); if (m_platformWindow && m_platformWindow->get_Handle()) { if (owner) { if (owner->m_platformWindow && owner->m_platformWindow->get_Handle()) { ::SetParent(m_platformWindow->get_Handle(), owner->m_platformWindow->get_Handle()); } } else { ::SetParent(m_platformWindow->get_Handle(), nullptr); } } } else if (pPropertyVal->m_dp == get_TaskbarItemInfoProperty()) { MS::Windows::Shell::TaskbarItemInfo* info = get_TaskbarItemInfo(); if (m_platformWindow) { HWND hWnd = m_platformWindow->get_Handle(); if (hWnd) { double progress = info->get_ProgressValue(); const ULONGLONG totalProgress = 1000000ULL; // TBPFLAG tbFlags; // MS::Windows::Shell::Private::pTaskbarList3->SetProgressState(hWnd, tbpFlags); MS::Windows::Shell::Private::pTaskbarList3->SetProgressValue(hWnd, progress*totalProgress, totalProgress); } } } baseClass::OnComputedPropertyValueChanged(pPropertyVal, handled); }