void CXTPMarkupUIElement::InvalidateMeasureOverride(CXTPMarkupDrawingContext* pDC) { if (!m_bMeasureInProgress && !m_bNeverMeasured) { m_bMeasureDirty = TRUE; m_bArrangeDirty = TRUE; CSize sz = GetDesiredSize(); Measure(pDC, m_szPreviousAvailableSize); if (sz != GetDesiredSize()) { m_bMeasureDirty = TRUE; m_bArrangeDirty = TRUE; CXTPMarkupUIElement* pParent = MARKUP_DYNAMICCAST(CXTPMarkupUIElement, GetVisualParent()); if (pParent) { pParent->InvalidateMeasureOverride(pDC); } else if (m_pMarkupContext) { m_pMarkupContext->OnInvalidateArrange(this); } } else { Arrange(m_rcFinalRect); InvalidateVisual(); } } }
void Slider::OnValueChanged(double oldValue, double newValue) { InvalidateArrange(); InvalidateVisual(); __super::OnValueChanged(oldValue, newValue); }
void ScrollBar::SetScrollInfo(int iVisual, int iLogic, bool bRepaint) { UpdateScrollInfo(iVisual, iLogic, true); if (bRepaint) { InvalidateVisual(); } }
void HeaderedContentControl::OnPreviewMouseLeftButtonDown(suic::MouseEventArg& e) { if (GetHeader().get() == e.GetSource()) { Selector::SelectItem(e.GetSource(), true); InvalidateVisual(); } }
void CXTPMarkupUIElement::InvalidateArrange() { if (!m_bArrangeInProgress && !m_bNeverArranged) { m_bArrangeDirty = TRUE; Arrange(m_rcFinalRect); InvalidateVisual(); } }
void CXTPMarkupWindowContainer::SetChild(HWND hWnd) { m_hWndChild = hWnd; CRect rc; ::GetWindowRect(m_hWndChild, &rc); m_szChild = rc.Size(); InvalidateMeasure(); InvalidateVisual(); }
void ComboBoxItem::OnMouseLeftButtonDown(suic::MouseEventArg& e) { suic::Element::OnMouseLeftButtonDown(e); if (!e.IsHandled()) { Selector::SelectItem(this, true); InvalidateVisual(); e.SetHandled(true); } }
void ScrollBar::UpdateScrollVisual(int iVisual, bool bRepaint) { if (_iVisualSize != iVisual) { _iVisualSize = iVisual; } CalcScrollPos(); if (bRepaint) { InvalidateVisual(); } }
void ComboBox::OnMouseLeftButtonUp(suic::MouseEventArg& e) { __super::OnMouseLeftButtonUp(e); InvalidateVisual(); // // 下拉框已经打开并且已获取鼠标控制权,传递事件 // if (IsDropDown() && _list->IsMouseCaptured()) { _list->OnMouseLeftButtonUp(e); } }
void ScrollBar::UpdateScrollLogic(int iLogic, bool bRepaint) { if (_iLogicSize != iLogic) { _iLogicSize = iLogic; } CalcScrollPos(); if (bRepaint) { InvalidateVisual(); } }
void TabControl::OnItemSelected(suic::ObjectPtr item, ItemSelectionEventArg& e) { __super::OnItemSelected(item, e); // // 设置测量大小脏区域标志,使布局管理器重新元素测量大小 // RaisedMeasureDirty(); // // 刷新布局和显示 // InvalidateMeasure(); InvalidateArrange(); InvalidateVisual(); }
void ScrollBar::DoScroll(bool bUpdate) { bool bAutoDel = SetAutoDelete(false); suic::ElementPtr ePtr(this); if (Scroll) { ui::ScrollEventArg scrollEvt(_scroInfo.iVisualPos); Scroll(ePtr, scrollEvt); } if (bUpdate) { UpdateScrollBar(); } InvalidateVisual(); SetAutoDelete(bAutoDel); }
void ScrollBar::ScrollTo(int nNewPos, bool bRepaint) { int iMin = 0; int iMaxPos = max(0, (_scroInfo.iMax - iMin + 1 - _scroInfo.iPage)); if (nNewPos < iMin) { nNewPos = iMin; } int iOldPos = _scroInfo.iVisualPos; _scroInfo.iVisualPos = min(iMaxPos, nNewPos); if (iOldPos != _scroInfo.iVisualPos) { InvalidateArrange(); } if (bRepaint) { InvalidateVisual(); } }
void ScrollBar::ShowSecondScrollButton(bool bShow) { _increaseBtn.SetVisible(bShow); InvalidateArrange(); InvalidateVisual(); }
void ProgressBar::OnValueChanged(double oldValue, double newValue) { InvalidateVisual(); __super::OnValueChanged(oldValue, newValue); }
void AnimateBox::OnTimer(int id) { NextFrame(); _timerid = suic::SystemHelper::RestartTimer(_timerid, CurrentElapse()); InvalidateVisual(); }
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); }
void ScrollBar::ShowFirstScrollButton(bool bShow) { _decreaseBtn.SetVisible(bShow); InvalidateArrange(); InvalidateVisual(); }
//------------------------------------------------------------------------------------------------- // VisualPluginHandler //------------------------------------------------------------------------------------------------- // static OSStatus VisualPluginHandler(OSType message,VisualPluginMessageInfo *messageInfo,void *refCon) { OSStatus status; VisualPluginData * visualPluginData; visualPluginData = (VisualPluginData*) refCon; status = noErr; switch ( message ) { /* Sent when the visual plugin is registered. The plugin should do minimal memory allocations here. */ case kVisualPluginInitMessage: { visualPluginData = (VisualPluginData *)calloc( 1, sizeof(VisualPluginData) ); if ( visualPluginData == NULL ) { status = memFullErr; break; } visualPluginData->appCookie = messageInfo->u.initMessage.appCookie; visualPluginData->appProc = messageInfo->u.initMessage.appProc; messageInfo->u.initMessage.refCon = (void *)visualPluginData; break; } /* Sent when the visual plugin is unloaded. */ case kVisualPluginCleanupMessage: { if ( visualPluginData != NULL ) free( visualPluginData ); break; } /* Sent when the visual plugin is enabled/disabled. iTunes currently enables all loaded visual plugins at launch. The plugin should not do anything here. */ case kVisualPluginEnableMessage: case kVisualPluginDisableMessage: { break; } /* Sent if the plugin requests idle messages. Do this by setting the kVisualWantsIdleMessages option in the RegisterVisualMessage.options field. DO NOT DRAW in this routine. It is for updating internal state only. */ case kVisualPluginIdleMessage: { break; } /* Sent if the plugin requests the ability for the user to configure it. Do this by setting the kVisualWantsConfigure option in the RegisterVisualMessage.options field. */ case kVisualPluginConfigureMessage: { status = ConfigureVisual( visualPluginData ); break; } /* Sent when iTunes is going to show the visual plugin. At this point, the plugin should allocate any large buffers it needs. */ case kVisualPluginActivateMessage: { status = ActivateVisual( visualPluginData, messageInfo->u.activateMessage.view, messageInfo->u.activateMessage.options ); // note: do not draw here if you can avoid it, a draw message will be sent as soon as possible if ( status == noErr ) RequestArtwork( visualPluginData ); break; } /* Sent when this visual is no longer displayed. */ case kVisualPluginDeactivateMessage: { UpdateTrackInfo( visualPluginData, NULL, NULL ); status = DeactivateVisual( visualPluginData ); break; } /* Sent when iTunes is moving the destination view to a new parent window (e.g. to/from fullscreen). */ case kVisualPluginWindowChangedMessage: { status = MoveVisual( visualPluginData, messageInfo->u.windowChangedMessage.options ); break; } /* Sent when iTunes has changed the rectangle of the currently displayed visual. Note: for custom NSView subviews, the subview's frame is automatically resized. */ case kVisualPluginFrameChangedMessage: { status = ResizeVisual( visualPluginData ); break; } /* Sent for the visual plugin to update its internal animation state. Plugins are allowed to draw at this time but it is more efficient if they wait until the kVisualPluginDrawMessage is sent OR they simply invalidate their own subview. The pulse message can be sent faster than the system will allow drawing to support spectral analysis-type plugins but drawing will be limited to the system refresh rate. */ case kVisualPluginPulseMessage: { PulseVisual( visualPluginData, messageInfo->u.pulseMessage.timeStampID, messageInfo->u.pulseMessage.renderData, &messageInfo->u.pulseMessage.newPulseRateInHz ); InvalidateVisual( visualPluginData ); break; } /* It's time for the plugin to draw a new frame. For plugins using custom subviews, you should ignore this message and just draw in your view's draw method. It will never be called if your subview is set up properly. */ case kVisualPluginDrawMessage: { #if !USE_SUBVIEW DrawVisual( visualPluginData ); #endif break; } /* Sent when the player starts. */ case kVisualPluginPlayMessage: { visualPluginData->playing = true; UpdateTrackInfo( visualPluginData, messageInfo->u.playMessage.trackInfo, messageInfo->u.playMessage.streamInfo ); RequestArtwork( visualPluginData ); InvalidateVisual( visualPluginData ); break; } /* Sent when the player changes the current track information. This is used when the information about a track changes. */ case kVisualPluginChangeTrackMessage: { UpdateTrackInfo( visualPluginData, messageInfo->u.changeTrackMessage.trackInfo, messageInfo->u.changeTrackMessage.streamInfo ); RequestArtwork( visualPluginData ); InvalidateVisual( visualPluginData ); break; } /* Artwork for the currently playing song is being delivered per a previous request. Note that NULL for messageInfo->u.coverArtMessage.coverArt means the currently playing song has no artwork. */ case kVisualPluginCoverArtMessage: { UpdateArtwork( visualPluginData, messageInfo->u.coverArtMessage.coverArt, messageInfo->u.coverArtMessage.coverArtSize, messageInfo->u.coverArtMessage.coverArtFormat ); InvalidateVisual( visualPluginData ); break; } /* Sent when the player stops or pauses. */ case kVisualPluginStopMessage: { visualPluginData->playing = false; ResetRenderData( visualPluginData ); InvalidateVisual( visualPluginData ); break; } /* Sent when the player changes the playback position. */ case kVisualPluginSetPositionMessage: { break; } default: { status = unimpErr; break; } } return status; }