void UIElement::OnComputedPropertyValueChanging(PropertyValue* pPropertyVal, const Variant& oldValue, const Variant& newValue, bool handled) { if (pPropertyVal->m_dp == get_ShadowTreeProperty()) { // remove old UIElement* uielement = get_ShadowTree(); if (uielement) { uielement->SetRoot(nullptr); uielement->set_Parent(nullptr); uielement->set_ParentWindow(nullptr); } handled = true; } if (m_elementProvider) { PROPERTYID propertyId = 0; if (pPropertyVal->m_dp == Window::get_TitleTextProperty()) { propertyId = UIA_NamePropertyId; } HRESULT hr; if (propertyId) { hr = UiaRaiseAutomationPropertyChangedEvent(m_elementProvider, propertyId, oldValue, newValue); } } baseClass::OnComputedPropertyValueChanging(pPropertyVal, oldValue, newValue, handled); }
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); }