diff --git a/Import/GacUI.cpp b/Import/GacUI.cpp index 1ac4ca2c..ab982abf 100644 --- a/Import/GacUI.cpp +++ b/Import/GacUI.cpp @@ -199,24 +199,6 @@ GuiApplication } } - void GuiApplication::LeftButtonDown(NativePoint position) - { - OnMouseDown(position); - } - - void GuiApplication::LeftButtonUp(NativePoint position) - { - } - - void GuiApplication::RightButtonDown(NativePoint position) - { - OnMouseDown(position); - } - - void GuiApplication::RightButtonUp(NativePoint position) - { - } - void GuiApplication::ClipboardUpdated() { for(vint i=0;iInputService()->StartHookMouse(); - } } } @@ -275,22 +253,6 @@ GuiApplication { if(openingPopups.Remove(popup)) { - if(openingPopups.Count()==0) - { - GetCurrentController()->InputService()->StopHookMouse(); - } - } - } - - void GuiApplication::OnMouseDown(NativePoint location) - { - GuiWindow* window=GetWindow(location); - for(vint i=0;iMouseClickedOnOtherWindow(window); - } } } @@ -4291,6 +4253,10 @@ GuiWindow void GuiWindow::OnNativeWindowChanged() { SyncNativeWindowProperties(); + if (auto window = GetNativeWindow()) + { + window->SetWindowMode(windowMode); + } GuiControlHost::OnNativeWindowChanged(); } @@ -4299,10 +4265,6 @@ GuiWindow GuiControlHost::OnVisualStatusChanged(); } - void GuiWindow::MouseClickedOnOtherWindow(GuiWindow* window) - { - } - void GuiWindow::OnWindowActivated(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) { if (auto ct = GetControlTemplateObject(false)) @@ -4319,8 +4281,9 @@ GuiWindow } } - GuiWindow::GuiWindow(theme::ThemeName themeName) + GuiWindow::GuiWindow(theme::ThemeName themeName, INativeWindow::WindowMode mode) :GuiControlHost(themeName) + , windowMode(mode) { SetAltComposition(boundsComposition); SetAltControl(this, true); @@ -4334,6 +4297,11 @@ GuiWindow WindowDeactivated.AttachMethod(this, &GuiWindow::OnWindowDeactivated); } + GuiWindow::GuiWindow(theme::ThemeName themeName) + :GuiWindow(themeName, INativeWindow::Normal) + { + } + GuiWindow::~GuiWindow() { FinalizeAggregation(); @@ -4503,11 +4471,6 @@ GuiPopup } } - void GuiPopup::MouseClickedOnOtherWindow(GuiWindow* window) - { - Hide(); - } - void GuiPopup::PopupOpened(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) { GetApplication()->RegisterPopupOpened(this); @@ -4649,17 +4612,18 @@ GuiPopup if (controlWindow) { window->SetParent(controlWindow); - window->SetTopMost(controlWindow->GetTopMost()); + SetTopMost(controlWindow->GetTopMost()); } else { - window->SetTopMost(true); + SetTopMost(true); } + SetEnabledActivate(false); ShowDeactivated(); } - GuiPopup::GuiPopup(theme::ThemeName themeName) - :GuiWindow(themeName) + GuiPopup::GuiPopup(theme::ThemeName themeName, INativeWindow::WindowMode mode) + :GuiWindow(themeName, mode) { SetMinimizedBox(false); SetMaximizedBox(false); @@ -4672,6 +4636,11 @@ GuiPopup boundsComposition->GetEventReceiver()->keyDown.AttachMethod(this, &GuiPopup::OnKeyDown); } + GuiPopup::GuiPopup(theme::ThemeName themeName) + :GuiPopup(themeName, INativeWindow::Popup) + { + } + GuiPopup::~GuiPopup() { GetApplication()->RegisterPopupClosed(this); @@ -4768,8 +4737,7 @@ GuiPopup } GuiTooltip::GuiTooltip(theme::ThemeName themeName) - :GuiPopup(themeName) - ,temporaryContentControl(0) + : GuiPopup(themeName, INativeWindow::Tooltip) { containerComposition->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); containerComposition->SetPreferredMinSize(Size(20, 10)); @@ -6812,7 +6780,10 @@ GuiComboBoxListControl void GuiComboBoxListControl::AfterControlTemplateInstalled(bool initialize) { GuiComboBoxBase::AfterControlTemplateInstalled(initialize); - GetControlTemplateObject(true)->SetTextVisible(!itemStyleProperty); + if (auto ct = GetControlTemplateObject(true)) + { + ct->SetTextVisible(!itemStyleProperty); + } } void GuiComboBoxListControl::RemoveStyleController() @@ -6871,16 +6842,19 @@ GuiComboBoxListControl void GuiComboBoxListControl::AdoptSubMenuSize() { - Size expectedSize(0, GetDisplayFont().size * 20); - Size adoptedSize = containedListControl->GetAdoptedSize(expectedSize); - - Size clientSize = GetPreferredMenuClientSize(); - clientSize.y = adoptedSize.y + GetSubMenu()->GetClientSize().y - containedListControl->GetBoundsComposition()->GetBounds().Height(); - SetPreferredMenuClientSize(clientSize); - - if (GetSubMenuOpening()) + if (auto subMenu = GetSubMenu()) { - GetSubMenu()->SetClientSize(clientSize); + Size expectedSize(0, GetDisplayFont().size * 20); + Size adoptedSize = containedListControl->GetAdoptedSize(expectedSize); + + Size clientSize = GetPreferredMenuClientSize(); + clientSize.y = adoptedSize.y + subMenu->GetClientSize().y - containedListControl->GetBoundsComposition()->GetBounds().Height(); + SetPreferredMenuClientSize(clientSize); + + if (GetSubMenuOpening()) + { + subMenu->SetClientSize(clientSize); + } } } @@ -6912,8 +6886,6 @@ GuiComboBoxListControl void GuiComboBoxListControl::OnAfterSubMenuOpening(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) { containedListControl->SelectItemsByClick(selectedIndex, false, false, true); - GetSubMenu()->GetNativeWindow()->SetFocus(); - containedListControl->SetFocus(); } void GuiComboBoxListControl::OnListControlAdoptedSizeInvalidated(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) @@ -6939,7 +6911,7 @@ GuiComboBoxListControl GetSubMenu()->Hide(); } - void GuiComboBoxListControl::OnListControlKeyDown(compositions::GuiGraphicsComposition* sender, compositions::GuiKeyEventArgs& arguments) + void GuiComboBoxListControl::OnKeyDown(compositions::GuiGraphicsComposition* sender, compositions::GuiKeyEventArgs& arguments) { if (!arguments.autoRepeatKeyDown) { @@ -6952,7 +6924,8 @@ GuiComboBoxListControl GetSubMenu()->Hide(); arguments.handled = true; break; - default:; + default: + containedListControl->SelectItemsByKey(arguments.code, arguments.ctrl, arguments.shift); } } } @@ -6990,8 +6963,8 @@ GuiComboBoxListControl containedListControl->AdoptedSizeInvalidated.AttachMethod(this, &GuiComboBoxListControl::OnListControlAdoptedSizeInvalidated); containedListControl->ItemLeftButtonDown.AttachMethod(this, &GuiComboBoxListControl::OnListControlItemMouseDown); containedListControl->ItemRightButtonDown.AttachMethod(this, &GuiComboBoxListControl::OnListControlItemMouseDown); - containedListControl->GetFocusableComposition()->GetEventReceiver()->keyDown.AttachMethod(this, &GuiComboBoxListControl::OnListControlKeyDown); boundsChangedHandler = containedListControl->GetBoundsComposition()->BoundsChanged.AttachMethod(this, &GuiComboBoxListControl::OnListControlBoundsChanged); + boundsComposition->GetEventReceiver()->keyDown.AttachMethod(this, &GuiComboBoxListControl::OnKeyDown); auto itemProvider = containedListControl->GetItemProvider(); @@ -17472,19 +17445,26 @@ GuiSinglelineTextBox::DefaultTextElementOperatorCallback bool GuiSinglelineTextBox::TextElementOperatorCallback::BeforeModify(TextPos start, TextPos end, const WString& originalText, WString& inputText) { - vint length=inputText.Length(); - const wchar_t* input=inputText.Buffer(); - for(vint i=0;i(window); - if(!targetMenu) - { - Hide(); - } - } - void GuiMenu::OnWindowClosed(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) { if(parentMenuService) @@ -20563,11 +20534,9 @@ GuiMenu } GuiMenu::GuiMenu(theme::ThemeName themeName, GuiControl* _owner) - :GuiPopup(themeName) + :GuiPopup(themeName, INativeWindow::Menu) , owner(_owner) - , parentMenuService(0) { - GetNativeWindow()->SetAlwaysPassFocusToParent(true); UpdateMenuService(); WindowOpened.AttachMethod(this, &GuiMenu::OnWindowOpened); WindowClosed.AttachMethod(this, &GuiMenu::OnWindowClosed); @@ -20784,6 +20753,9 @@ GuiMenuButton { subMenu->WindowOpened.Detach(subMenuWindowOpenedHandler); subMenu->WindowClosed.Detach(subMenuWindowClosedHandler); + + subMenuWindowOpenedHandler = nullptr; + subMenuWindowClosedHandler = nullptr; if (ownedSubMenu) { delete subMenu; @@ -30564,42 +30536,29 @@ GuiGraphicsResourceManager { } - bool GuiGraphicsResourceManager::RegisterElementFactory(IGuiGraphicsElementFactory* factory) + vint GuiGraphicsResourceManager::RegisterElementType(const WString& elementTypeName) { - if(elementFactories.Keys().Contains(factory->GetElementTypeName())) + CHECK_ERROR(!elementTypes.Contains(elementTypeName), L"GuiGraphicsResourceManager::RegisterElementType(const WString&)#This element type has already been registered."); + return elementTypes.Add(elementTypeName); + } + + void GuiGraphicsResourceManager::RegisterRendererFactory(vint elementType, Ptr factory) + { + if (rendererFactories.Count() <= elementType) { - return false; + rendererFactories.Resize(elementType + 1); + rendererFactories[elementType] = factory; } else { - elementFactories.Add(factory->GetElementTypeName(), factory); - return true; + CHECK_ERROR(!rendererFactories[elementType], L"GuiGraphicsResourceManager::RegisterRendererFactory(vint, Ptr)#This element type has already been binded a renderer factory."); + rendererFactories[elementType] = factory; } } - bool GuiGraphicsResourceManager::RegisterRendererFactory(const WString& elementTypeName, IGuiGraphicsRendererFactory* factory) + IGuiGraphicsRendererFactory* GuiGraphicsResourceManager::GetRendererFactory(vint elementType) { - if(rendererFactories.Keys().Contains(elementTypeName)) - { - return false; - } - else - { - rendererFactories.Add(elementTypeName, factory); - return true; - } - } - - IGuiGraphicsElementFactory* GuiGraphicsResourceManager::GetElementFactory(const WString& elementTypeName) - { - vint index=elementFactories.Keys().IndexOf(elementTypeName); - return index==-1?0:elementFactories.Values().Get(index).Obj(); - } - - IGuiGraphicsRendererFactory* GuiGraphicsResourceManager::GetRendererFactory(const WString& elementTypeName) - { - vint index=rendererFactories.Keys().IndexOf(elementTypeName); - return index==-1?nullptr:rendererFactories.Values().Get(index).Obj(); + return rendererFactories.Count() > elementType ? rendererFactories[elementType].Obj() : nullptr; } GuiGraphicsResourceManager* guiGraphicsResourceManager=0; @@ -30613,21 +30572,6 @@ GuiGraphicsResourceManager { guiGraphicsResourceManager=resourceManager; } - - bool RegisterFactories(IGuiGraphicsElementFactory* elementFactory, IGuiGraphicsRendererFactory* rendererFactory) - { - if(guiGraphicsResourceManager && elementFactory && rendererFactory) - { - if(guiGraphicsResourceManager->RegisterElementFactory(elementFactory)) - { - if(guiGraphicsResourceManager->RegisterRendererFactory(elementFactory->GetElementTypeName(), rendererFactory)) - { - return true; - } - } - } - return false; - } } } } @@ -32312,8 +32256,8 @@ namespace vl using namespace theme; const wchar_t* const IGuiAltAction::Identifier = L"vl::presentation::compositions::IGuiAltAction"; - const wchar_t* const IGuiAltActionContainer::Identifier = L"vl::presentation::compositions::IGuiAltAction"; - const wchar_t* const IGuiAltActionHost::Identifier = L"vl::presentation::compositions::IGuiAltAction"; + const wchar_t* const IGuiAltActionContainer::Identifier = L"vl::presentation::compositions::IGuiAltActionContainer"; + const wchar_t* const IGuiAltActionHost::Identifier = L"vl::presentation::compositions::IGuiAltActionHost"; /*********************************************************************** IGuiAltAction @@ -33171,26 +33115,6 @@ INativeWindowListener INativeControllerListener ***********************************************************************/ - void INativeControllerListener::LeftButtonDown(NativePoint position) - { - } - - void INativeControllerListener::LeftButtonUp(NativePoint position) - { - } - - void INativeControllerListener::RightButtonDown(NativePoint position) - { - } - - void INativeControllerListener::RightButtonUp(NativePoint position) - { - } - - void INativeControllerListener::MouseMoving(NativePoint position) - { - } - void INativeControllerListener::GlobalTimer() { } diff --git a/Import/GacUI.h b/Import/GacUI.h index 4a1c20f8..9125d2e0 100644 --- a/Import/GacUI.h +++ b/Import/GacUI.h @@ -1179,7 +1179,6 @@ namespace vl namespace elements { class IGuiGraphicsElement; - class IGuiGraphicsElementFactory; class IGuiGraphicsRenderer; class IGuiGraphicsRendererFactory; class IGuiGraphicsRenderTarget; @@ -1200,11 +1199,6 @@ Basic Construction virtual void SetOwnerComposition(compositions::GuiGraphicsComposition* composition) = 0; public: - /// - /// Access the that is used to create this graphics elements. - /// - /// Returns the related factory. - virtual IGuiGraphicsElementFactory* GetFactory() = 0; /// /// Access the associated for this graphics element. /// @@ -1217,25 +1211,6 @@ Basic Construction virtual compositions::GuiGraphicsComposition* GetOwnerComposition() = 0; }; - /// - /// This is the interface for graphics element factories. - /// Graphics element factories should be registered using [M:vl.presentation.elements.GuiGraphicsResourceManager.RegisterElementFactory]. - /// - class IGuiGraphicsElementFactory : public Interface - { - public: - /// - /// Get the name representing the kind of graphics element to be created. - /// - /// Returns the name of graphics elements. - virtual WString GetElementTypeName()=0; - /// - /// Create a . - /// - /// Returns the created graphics elements. - virtual IGuiGraphicsElement* Create()=0; - }; - /// /// This is the interface for graphics renderers. /// @@ -2012,7 +1987,8 @@ Native Window virtual void SetCaretPoint(NativePoint point)=0; /// - /// Get the parent window. A parent window doesn't contain a child window. It always displayed below the child windows. When a parent window is minimized or restored, so as its child windows. + /// Get the parent window. + /// A parent window doesn't contain a child window. It always displayed below the child windows. When a parent window is minimized or restored, so as its child windows. /// /// The parent window. virtual INativeWindow* GetParent()=0; @@ -2021,16 +1997,49 @@ Native Window /// /// The parent window. virtual void SetParent(INativeWindow* parent)=0; + /// - /// Test is the window always pass the focus to its parent window. + /// Window mode /// - /// Returns true if the window always pass the focus to its parent window. - virtual bool GetAlwaysPassFocusToParent()=0; + enum WindowMode + { + /// + /// A normal window. + /// + Normal, + /// + /// A tooltip window. + /// Such window is expected to be disabled activation, [M:vl.presentation.INativeWindow.DisableActivate] must be called manually. + /// Such window is expected to have a parent window, [M:vl.presentation.INativeWindow.SetParent] must be called before [M:vl.presentation.INativeWindow.ShowDeactivated]. + /// This window is automatically closed when the top level window is deactivated or clicked. + /// + Tooltip, + /// + /// A popup window. + /// Such window is expected to be disabled activation, [M:vl.presentation.INativeWindow.DisableActivate] must be called manually. + /// Such window is expected to have a parent window, [M:vl.presentation.INativeWindow.SetParent] must be called before [M:vl.presentation.INativeWindow.ShowDeactivated]. + /// This window is automatically closed when the top level window is deactivated or clicked. + /// + Popup, + /// + /// A menu window. + /// Such window is expected to be disabled activation, [M:vl.presentation.INativeWindow.DisableActivate] must be called manually. + /// Such window is expected to have a parent window, [M:vl.presentation.INativeWindow.SetParent] must be called before [M:vl.presentation.INativeWindow.ShowDeactivated]. + /// This window is automatically closed when the top level window is deactivated or clicked. + /// + Menu, + }; + /// - /// Enable or disble always passing the focus to its parent window. + /// Get the window mode. /// - /// True to enable always passing the focus to its parent window. - virtual void SetAlwaysPassFocusToParent(bool value)=0; + /// The window mode. + virtual WindowMode GetWindowMode() = 0; + /// + /// Set the window mode + /// + /// The window mode. + virtual void SetWindowMode(WindowMode mode) = 0; /// /// Enable the window customized frame mode. @@ -2080,6 +2089,7 @@ Native Window virtual WindowSizeState GetSizeState()=0; /// /// Show the window. + /// If the window disabled activation, this function enables it again. /// virtual void Show()=0; /// @@ -2125,6 +2135,7 @@ Native Window /// /// Set focus to the window. + /// A window with activation disabled cannot receive focus. /// virtual void SetFocus()=0; /// @@ -2134,6 +2145,7 @@ Native Window virtual bool IsFocused()=0; /// /// Activate to the window. + /// If the window disabled activation, this function enables it again. /// virtual void SetActivate()=0; /// @@ -2162,6 +2174,8 @@ Native Window virtual void EnableActivate()=0; /// /// Disable activation to the window. + /// Clicking a window with activation disabled doesn't bring activation and focus. + /// Activation will be automatically enabled by calling or . /// virtual void DisableActivate()=0; /// @@ -2804,21 +2818,7 @@ Native Window Services /// class INativeInputService : public virtual IDescriptable, public Description { - public: - /// - /// Start to reveive global mouse message. - /// - virtual void StartHookMouse()=0; - /// - /// Stop to receive global mouse message. - /// - virtual void StopHookMouse()=0; - /// - /// Test is the global mouse message receiving enabled. - /// - /// Returns true if the global mouse message receiving is enabled. - virtual bool IsHookingMouse()=0; - + public: /// /// Start to reveive global timer message. /// @@ -3152,31 +3152,6 @@ Native Window Controller class INativeControllerListener : public Interface { public: - /// - /// Called when the left mouse button is pressed. To receive or not receive this message, use or . - /// - /// The mouse position in the screen space. - virtual void LeftButtonDown(NativePoint position); - /// - /// Called when the left mouse button is released. To receive or not receive this message, use or - /// - /// The mouse position in the screen space. - virtual void LeftButtonUp(NativePoint position); - /// - /// Called when the right mouse button is pressed. To receive or not receive this message, use or - /// - /// The mouse position in the screen space. - virtual void RightButtonDown(NativePoint position); - /// - /// Called when the right mouse button is released. To receive or not receive this message, use or - /// - /// The mouse position in the screen space. - virtual void RightButtonUp(NativePoint position); - /// - /// Called when the mouse is moving. To receive or not receive this message, use or - /// - /// The mouse position in the screen space. - virtual void MouseMoving(NativePoint position); /// /// Called when the global timer message raised. To receive or not receive this message, use or /// @@ -5550,11 +5525,9 @@ Resource Manager /// class GuiGraphicsResourceManager : public Object { - typedef collections::Dictionary> elementFactoryMap; - typedef collections::Dictionary> rendererFactoryMap; protected: - elementFactoryMap elementFactories; - rendererFactoryMap rendererFactories; + collections::List elementTypes; + collections::Array> rendererFactories; public: /// /// Create a graphics resource manager without any predefined factories @@ -5563,36 +5536,31 @@ Resource Manager ~GuiGraphicsResourceManager(); /// - /// Register a using the element type from . + /// Register a element type name. + /// This function crashes when an element type has already been registered. /// - /// The instance of the graphics element factory to register. - /// Returns true if this operation succeeded. - virtual bool RegisterElementFactory(IGuiGraphicsElementFactory* factory); + /// The element type. + /// A number identifies this element type. + vint RegisterElementType(const WString& elementTypeName); /// - /// Register a and bind it to a registered . + /// Register a and bind it to an registered element type from . + /// This function crashes when an element type has already been binded a renderer factory. /// - /// The element type to represent a graphics element factory. + /// The element type to represent a graphics element factory. /// The instance of the graphics renderer factory to register. - /// Returns true if this operation succeeded. - virtual bool RegisterRendererFactory(const WString& elementTypeName, IGuiGraphicsRendererFactory* factory); - /// - /// Get the instance of a registered that is binded to a specified element type. - /// - /// Returns the element factory. - /// The element type to get a corresponding graphics element factory. - virtual IGuiGraphicsElementFactory* GetElementFactory(const WString& elementTypeName); + void RegisterRendererFactory(vint elementType, Ptr factory); /// /// Get the instance of a registered that is binded to a specified element type. /// /// Returns the renderer factory. - /// The element type to get a corresponding graphics renderer factory. - virtual IGuiGraphicsRendererFactory* GetRendererFactory(const WString& elementTypeName); + /// The registered element type from to get a binded graphics renderer factory. + IGuiGraphicsRendererFactory* GetRendererFactory(vint elementType); /// /// Get the instance of a that is binded to an . /// /// The specified window. /// Returns the render target. - virtual IGuiGraphicsRenderTarget* GetRenderTarget(INativeWindow* window)=0; + virtual IGuiGraphicsRenderTarget* GetRenderTarget(INativeWindow* window) = 0; /// /// Recreate the render target for the specified window. /// @@ -5607,7 +5575,7 @@ Resource Manager /// Get the renderer awared rich text document layout engine provider object. /// /// Returns the layout provider. - virtual IGuiGraphicsLayoutProvider* GetLayoutProvider()=0; + virtual IGuiGraphicsLayoutProvider* GetLayoutProvider() = 0; }; /// @@ -5620,13 +5588,6 @@ Resource Manager /// /// The resource manager to set. extern void SetGuiGraphicsResourceManager(GuiGraphicsResourceManager* resourceManager); - /// - /// Helper function to register a with a and bind them together. - /// - /// Returns true if this operation succeeded. - /// The element factory to register. - /// The renderer factory to register. - extern bool RegisterFactories(IGuiGraphicsElementFactory* elementFactory, IGuiGraphicsRendererFactory* rendererFactory); /*********************************************************************** Helpers @@ -5635,29 +5596,7 @@ Helpers template class GuiElementBase : public Object, public IGuiGraphicsElement, public Description { - public: - class Factory : public Object, public IGuiGraphicsElementFactory - { - public: - WString GetElementTypeName() - { - return TElement::GetElementTypeName(); - } - IGuiGraphicsElement* Create() - { - auto element = new TElement; - element->factory = this; - IGuiGraphicsRendererFactory* rendererFactory = GetGuiGraphicsResourceManager()->GetRendererFactory(GetElementTypeName()); - if (rendererFactory) - { - element->renderer = rendererFactory->Create(); - element->renderer->Initialize(element); - } - return element; - } - }; protected: - IGuiGraphicsElementFactory* factory = nullptr; Ptr renderer; compositions::GuiGraphicsComposition* ownerComposition = nullptr; @@ -5685,9 +5624,13 @@ Helpers public: static TElement* Create() { - auto factory = GetGuiGraphicsResourceManager()->GetElementFactory(TElement::GetElementTypeName()); - CHECK_ERROR(factory != nullptr, L"This element is not supported by the selected renderer."); - return dynamic_cast(factory->Create()); + auto rendererFactory = GetGuiGraphicsResourceManager()->GetRendererFactory(TElement::GetElementType()); + CHECK_ERROR(rendererFactory != nullptr, L"This element is not supported by the selected renderer."); + + auto element = new TElement; + element->renderer = rendererFactory->Create(); + element->renderer->Initialize(element); + return element; } ~GuiElementBase() @@ -5698,11 +5641,6 @@ Helpers } } - IGuiGraphicsElementFactory* GetFactory()override - { - return factory; - } - IGuiGraphicsRenderer* GetRenderer()override { return renderer.Obj(); @@ -5717,9 +5655,16 @@ Helpers #define DEFINE_GUI_GRAPHICS_ELEMENT(TELEMENT, ELEMENT_TYPE_NAME)\ friend class GuiElementBase;\ public:\ - static WString GetElementTypeName()\ + static vint GetElementType()\ {\ - return ELEMENT_TYPE_NAME;\ + static vint elementType = -1;\ + if (elementType == -1)\ + {\ + auto manager = GetGuiGraphicsResourceManager();\ + CHECK_ERROR(manager != nullptr, L"SetGuiGraphicsResourceManager must be called before registering element types.");\ + elementType = manager->RegisterElementType(WString(ELEMENT_TYPE_NAME, false));\ + }\ + return elementType;\ }\ #define DEFINE_GUI_GRAPHICS_RENDERER(TELEMENT, TRENDERER, TTARGET)\ @@ -5744,7 +5689,9 @@ Helpers public:\ static void Register()\ {\ - RegisterFactories(new TELEMENT::Factory, new TRENDERER::Factory);\ + auto manager = GetGuiGraphicsResourceManager();\ + CHECK_ERROR(manager != nullptr, L"SetGuiGraphicsResourceManager must be called before registering element renderers.");\ + manager->RegisterRendererFactory(TELEMENT::GetElementType(), new TRENDERER::Factory);\ }\ IGuiGraphicsRendererFactory* GetFactory()override\ {\ @@ -10030,32 +9977,32 @@ Basic Construction GuiControl(theme::ThemeName themeName); ~GuiControl(); - /// Theme name changed event. This event will be raised when the theme name is changed. + /// Theme name changed event. This event raises when the theme name is changed. compositions::GuiNotifyEvent ControlThemeNameChanged; - /// Control template changed event. This event will be raised when the control template is changed. + /// Control template changed event. This event raises when the control template is changed. compositions::GuiNotifyEvent ControlTemplateChanged; - /// Control signal trigerred. This event will be raised because of multiple reason specified in the argument. + /// Control signal trigerred. This raises be raised because of multiple reason specified in the argument. compositions::GuiControlSignalEvent ControlSignalTrigerred; - /// Visible event. This event will be raised when the visibility state of the control is changed. + /// Visible event. This event raises when the visibility state of the control is changed. compositions::GuiNotifyEvent VisibleChanged; - /// Enabled event. This event will be raised when the enabling state of the control is changed. + /// Enabled event. This event raises when the enabling state of the control is changed. compositions::GuiNotifyEvent EnabledChanged; - /// Focused event. This event will be raised when the focusing state of the control is changed. + /// Focused event. This event raises when the focusing state of the control is changed. compositions::GuiNotifyEvent FocusedChanged; /// - /// Enabled event. This event will be raised when the visually enabling state of the control is changed. A visually enabling is combined by the enabling state and the parent's visually enabling state. + /// Enabled event. This event raises when the visually enabling state of the control is changed. A visually enabling is combined by the enabling state and the parent's visually enabling state. /// A control is rendered as disabled, not only when the control itself is disabled, but also when the parent control is rendered as disabled. /// compositions::GuiNotifyEvent VisuallyEnabledChanged; - /// Alt changed event. This event will be raised when the associated Alt-combined shortcut key of the control is changed. + /// Alt changed event. This event raises when the associated Alt-combined shortcut key of the control is changed. compositions::GuiNotifyEvent AltChanged; - /// Text changed event. This event will be raised when the text of the control is changed. + /// Text changed event. This event raises when the text of the control is changed. compositions::GuiNotifyEvent TextChanged; - /// Font changed event. This event will be raised when the font of the control is changed. + /// Font changed event. This event raises when the font of the control is changed. compositions::GuiNotifyEvent FontChanged; - /// Display font changed event. This event will be raised when the display font of the control is changed. + /// Display font changed event. This event raises when the display font of the control is changed. compositions::GuiNotifyEvent DisplayFontChanged; - /// Context changed event. This event will be raised when the font of the control is changed. + /// Context changed event. This event raises when the font of the control is changed. compositions::GuiNotifyEvent ContextChanged; void InvokeOrDelayIfRendering(Func proc); @@ -11320,12 +11267,12 @@ Control Host /// Test is the window focused. /// Returns true if the window is focused. bool GetFocused()override; - /// Focus the window. + /// Focus the window. A window with activation disabled cannot receive focus. void SetFocused(); /// Test is the window activated. /// Returns true if the window is activated. bool GetActivated(); - /// Activate the window. + /// Activate the window. If the window disabled activation, this function enables it again. void SetActivated(); /// Test is the window icon shown in the task bar. /// Returns true if the window is icon shown in the task bar. @@ -11336,7 +11283,11 @@ Control Host /// Test is the window allowed to be activated. /// Returns true if the window is allowed to be activated. bool GetEnabledActivate(); - /// Allow or forbid the window to be activated. + /// + /// Allow or forbid the window to be activated. + /// Clicking a window with activation disabled doesn't bring activation and focus. + /// Activation will be automatically enabled by calling or . + /// /// Set to true to allow the window to be activated. void SetEnabledActivate(bool value); /// @@ -11386,6 +11337,7 @@ Control Host INativeScreen* GetRelatedScreen(); /// /// Show the window. + /// If the window disabled activation, this function enables it again. /// void Show(); /// @@ -11429,6 +11381,7 @@ Window GUI_SPECIFY_CONTROL_TEMPLATE_TYPE(WindowTemplate, GuiControlHost) friend class GuiApplication; protected: + INativeWindow::WindowMode windowMode = INativeWindow::Normal; compositions::IGuiAltActionHost* previousAltHost = nullptr; bool hasMaximizedBox = true; bool hasMinimizedBox = true; @@ -11444,10 +11397,14 @@ Window void DpiChanged()override; void OnNativeWindowChanged()override; void OnVisualStatusChanged()override; - virtual void MouseClickedOnOtherWindow(GuiWindow* window); void OnWindowActivated(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); void OnWindowDeactivated(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + + /// Create a control with a specified default theme and a window mode. + /// The theme name for retriving a default control template. + /// The window mode. + GuiWindow(theme::ThemeName themeName, INativeWindow::WindowMode mode); public: /// Create a control with a specified default theme. /// The theme name for retriving a default control template. @@ -11580,7 +11537,6 @@ Window PopupInfo popupInfo; void UpdateClientSizeAfterRendering(Size clientSize)override; - void MouseClickedOnOtherWindow(GuiWindow* window)override; void PopupOpened(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); void PopupClosed(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); void OnKeyDown(compositions::GuiGraphicsComposition* sender, compositions::GuiKeyEventArgs& arguments); @@ -11593,6 +11549,11 @@ Window static NativePoint CalculatePopupPosition(NativeSize windowSize, vint popupType, const PopupInfo& popupInfo); void ShowPopupInternal(); + + /// Create a control with a specified default theme and a window mode. + /// The theme name for retriving a default control template. + /// The window mode. + GuiPopup(theme::ThemeName themeName, INativeWindow::WindowMode mode); public: /// Create a control with a specified default theme. /// The theme name for retriving a default control template. @@ -11626,11 +11587,12 @@ Window class GuiTooltip : public GuiPopup, private INativeControllerListener, public Description { protected: - GuiControl* temporaryContentControl; + GuiControl* temporaryContentControl = nullptr; void GlobalTimer()override; void TooltipOpened(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); void TooltipClosed(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); + public: /// Create a control with a specified default theme. /// The theme name for retriving a default control template. @@ -11693,10 +11655,6 @@ Application friend class Ptr; private: void InvokeClipboardNotify(compositions::GuiGraphicsComposition* composition, compositions::GuiEventArgs& arguments); - void LeftButtonDown(NativePoint position)override; - void LeftButtonUp(NativePoint position)override; - void RightButtonDown(NativePoint position)override; - void RightButtonUp(NativePoint position)override; void ClipboardUpdated()override; protected: Locale locale; @@ -11717,7 +11675,6 @@ Application void UnregisterWindow(GuiWindow* window); void RegisterPopupOpened(GuiPopup* popup); void RegisterPopupClosed(GuiPopup* popup); - void OnMouseDown(NativePoint location); void TooltipMouseEnter(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); void TooltipMouseLeave(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); public: @@ -15781,7 +15738,7 @@ Menu { GUI_SPECIFY_CONTROL_TEMPLATE_TYPE(MenuTemplate, GuiPopup) private: - IGuiMenuService* parentMenuService; + IGuiMenuService* parentMenuService = nullptr; bool hideOnDeactivateAltHost = true; IGuiMenuService* GetParentMenuService()override; @@ -15794,7 +15751,6 @@ Menu GuiControl* owner; void OnDeactivatedAltHost()override; - void MouseClickedOnOtherWindow(GuiWindow* window)override; void OnWindowOpened(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); void OnWindowClosed(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); public: @@ -16036,7 +15992,7 @@ ComboBox with GuiListControl void OnListControlAdoptedSizeInvalidated(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); void OnListControlBoundsChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); void OnListControlItemMouseDown(compositions::GuiGraphicsComposition* sender, compositions::GuiItemMouseEventArgs& arguments); - void OnListControlKeyDown(compositions::GuiGraphicsComposition* sender, compositions::GuiKeyEventArgs& arguments); + void OnKeyDown(compositions::GuiGraphicsComposition* sender, compositions::GuiKeyEventArgs& arguments); private: // ===================== GuiListControl::IItemProviderCallback ===================== diff --git a/Import/GacUICompiler.cpp b/Import/GacUICompiler.cpp index b8b53fb9..2a466f03 100644 --- a/Import/GacUICompiler.cpp +++ b/Import/GacUICompiler.cpp @@ -8259,13 +8259,6 @@ GuiControlInstanceLoader GuiPredefinedInstanceLoadersPlugin ***********************************************************************/ - Ptr CreateTrue(IGuiInstanceLoader::ArgumentMap&) - { - auto expr = MakePtr(); - expr->value = WfLiteralValue::True; - return expr; - } - void InitializeTrackerProgressBar(const WString& variableName, Ptr block) { auto refVariable = MakePtr(); diff --git a/Import/GacUIReflection.cpp b/Import/GacUIReflection.cpp index 62d9a54d..497fd02a 100644 --- a/Import/GacUIReflection.cpp +++ b/Import/GacUIReflection.cpp @@ -373,7 +373,7 @@ Type Declaration CLASS_MEMBER_PROPERTY_FAST(WindowCursor) CLASS_MEMBER_PROPERTY_FAST(CaretPoint) CLASS_MEMBER_PROPERTY_FAST(Parent) - CLASS_MEMBER_PROPERTY_FAST(AlwaysPassFocusToParent) + CLASS_MEMBER_PROPERTY_FAST(WindowMode) CLASS_MEMBER_PROPERTY_READONLY_FAST(CustomFramePadding) CLASS_MEMBER_PROPERTY_FAST(Icon) CLASS_MEMBER_PROPERTY_READONLY_FAST(SizeState) @@ -421,6 +421,14 @@ Type Declaration ENUM_NAMESPACE_ITEM(Maximized) END_ENUM_ITEM(INativeWindow::WindowSizeState) + BEGIN_ENUM_ITEM(INativeWindow::WindowMode) + ENUM_ITEM_NAMESPACE(INativeWindow) + ENUM_NAMESPACE_ITEM(Normal) + ENUM_NAMESPACE_ITEM(Tooltip) + ENUM_NAMESPACE_ITEM(Popup) + ENUM_NAMESPACE_ITEM(Menu) + END_ENUM_ITEM(INativeWindow::WindowMode) + BEGIN_INTERFACE_MEMBER_NOPROXY(INativeDelay) CLASS_MEMBER_PROPERTY_READONLY_FAST(Status) @@ -1242,6 +1250,8 @@ Type Declaration (Class) CLASS_MEMBER_PROPERTY_FAST(ColumnPadding) CLASS_MEMBER_PROPERTY_FAST(Axis) CLASS_MEMBER_PROPERTY_FAST(Alignment) + + CLASS_MEMBER_METHOD(InsertFlowItem, { L"index" _ L"item" }) END_CLASS_MEMBER(GuiFlowComposition) BEGIN_CLASS_MEMBER(GuiFlowItemComposition) @@ -1279,12 +1289,12 @@ Type Declaration (Class) CLASS_MEMBER_PROPERTY_FAST(Group) CLASS_MEMBER_PROPERTY_FAST(SharedWidth) CLASS_MEMBER_PROPERTY_FAST(SharedHeight) - END_CLASS_MEMBER(GuiSubComponentMeasurer) + END_CLASS_MEMBER(GuiSharedSizeItemComposition) BEGIN_CLASS_MEMBER(GuiSharedSizeRootComposition) CLASS_MEMBER_BASE(GuiBoundsComposition) CLASS_MEMBER_CONSTRUCTOR(GuiSharedSizeRootComposition*(), NO_PARAMETER) - END_CLASS_MEMBER(GuiSubComponentMeasurerSource) + END_CLASS_MEMBER(GuiSharedSizeRootComposition) BEGIN_CLASS_MEMBER(GuiRepeatCompositionBase) CLASS_MEMBER_GUIEVENT(ItemInserted) diff --git a/Import/GacUIReflection.h b/Import/GacUIReflection.h index f509fb58..1e4f0264 100644 --- a/Import/GacUIReflection.h +++ b/Import/GacUIReflection.h @@ -125,6 +125,7 @@ Type List (Basic) F(presentation::INativeCursor::SystemCursorType)\ F(presentation::INativeWindow)\ F(presentation::INativeWindow::WindowSizeState)\ + F(presentation::INativeWindow::WindowMode)\ F(presentation::INativeDelay)\ F(presentation::INativeDelay::ExecuteStatus)\ F(presentation::INativeScreen)\ diff --git a/Import/GacUIWindows.cpp b/Import/GacUIWindows.cpp index 5eae62df..95f8cfee 100644 --- a/Import/GacUIWindows.cpp +++ b/Import/GacUIWindows.cpp @@ -8136,45 +8136,59 @@ WindowsForm SetWindowPos(handle, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED); } + LONG_PTR InternalGetStyle() + { + return GetWindowLongPtr(handle, GWL_STYLE); + } + + void InternalSetStyle(LONG_PTR style) + { + SetWindowLongPtr(handle, GWL_STYLE, style); + SetWindowPos(handle, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED); + } + + LONG_PTR TurnOnStyle(LONG_PTR combination, LONG_PTR style) + { + return combination | style; + } + + LONG_PTR TurnOffStyle(LONG_PTR combination, LONG_PTR style) + { + return combination & (~style); + } + bool GetExStyle(LONG_PTR exStyle) { - LONG_PTR Long=InternalGetExStyle(); - return (Long & exStyle) != 0; + return (InternalGetExStyle() & exStyle) != 0; } void SetExStyle(LONG_PTR exStyle, bool available) { - LONG_PTR Long = InternalGetExStyle(); - if(available) + if (available) { - Long |= exStyle; + InternalSetExStyle(TurnOnStyle(InternalGetExStyle(), exStyle)); } else { - Long &= ~exStyle; + InternalSetExStyle(TurnOffStyle(InternalGetExStyle(), exStyle)); } - InternalSetExStyle(Long); } bool GetStyle(LONG_PTR style) { - LONG_PTR Long = GetWindowLongPtr(handle, GWL_STYLE); - return (Long & style) != 0; + return (InternalGetStyle() & style) != 0; } void SetStyle(LONG_PTR style, bool available) { - LONG_PTR Long = GetWindowLongPtr(handle, GWL_STYLE); - if(available) + if (available) { - Long |= style; + InternalSetStyle(TurnOnStyle(InternalGetStyle(), style)); } else { - Long &= ~style; + InternalSetStyle(TurnOffStyle(InternalGetStyle(), style)); } - SetWindowLongPtr(handle, GWL_STYLE, Long); - SetWindowPos(handle, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED); } #pragma push_macro("_CONTROL") #if defined _CONTROL @@ -8297,6 +8311,48 @@ WindowsForm bool transferFocusEvent = false; bool nonClient = false; + // handling popup windows + { + bool closeChildPopups = false; + switch (uMsg) + { + case WM_ACTIVATE: + if (wParam == WA_INACTIVE && windowMode == Normal) + { + closeChildPopups = true; + } + break; + case WM_LBUTTONDOWN: + case WM_MBUTTONDOWN: + case WM_RBUTTONDOWN: + closeChildPopups = true; + break; + } + + if (closeChildPopups) + { + List childPopups; + childPopups.Add(this); + for (vint i = 0; i < childPopups.Count(); i++) + { + auto popup = childPopups[i]; + for (vint j = 0; j < popup->childWindows.Count(); j++) + { + auto childPopup = popup->childWindows[j]; + if (childPopup->windowMode != Normal) + { + childPopups.Add(childPopup); + } + } + + if (popup != this && popup->IsVisible()) + { + popup->Hide(false); + } + } + } + } + switch(uMsg) { case WM_LBUTTONDOWN: @@ -8387,11 +8443,18 @@ WindowsForm } } break; + case WM_MOUSEACTIVATE: + if (!IsEnabledActivate()) + { + result = MA_NOACTIVATE; + return true; + } + break; case WM_ACTIVATE: { - for(vint i=0;iActivated(); } @@ -8792,22 +8855,7 @@ WindowsForm break; } - if(IsWindow(hwnd)!=0) - { - if(transferFocusEvent && IsFocused()) - { - WindowsForm* window=this; - while(window->parentWindow && window->alwaysPassFocusToParent) - { - window=window->parentWindow; - } - if(window!=this) - { - window->SetFocus(); - } - } - } - + // handling custom frame if (customFrameMode) { switch (uMsg) @@ -8859,7 +8907,8 @@ WindowsForm WindowsCursor* cursor = nullptr; NativePoint caretPoint; WindowsForm* parentWindow = nullptr; - bool alwaysPassFocusToParent = false; + List childWindows; + WindowMode windowMode = Normal; List listeners; vint mouseLastX = -1; vint mouseLastY = -1; @@ -8889,7 +8938,7 @@ WindowsForm WindowsForm(HWND parent, WString className, HINSTANCE hInstance) { DWORD exStyle = WS_EX_APPWINDOW | WS_EX_CONTROLPARENT; - DWORD style = WS_BORDER | WS_CAPTION | WS_SIZEBOX | WS_SYSMENU | WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_MAXIMIZEBOX | WS_MINIMIZEBOX; + DWORD style = WS_BORDER | WS_CAPTION | WS_SIZEBOX | WS_SYSMENU | WS_OVERLAPPED | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_MAXIMIZEBOX | WS_MINIMIZEBOX; handle = CreateWindowEx(exStyle, className.Buffer(), L"", style, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, parent, NULL, hInstance, NULL); UpdateDpiAwaredFields(true); @@ -8897,6 +8946,15 @@ WindowsForm ~WindowsForm() { + if (parentWindow) + { + parentWindow->childWindows.Remove(this); + } + for (vint i = childWindows.Count() - 1; i >= 0; i--) + { + childWindows[i]->SetParent(parentWindow); + } + *flagDisposed.Obj() = true; List copiedListeners; CopyFrom(copiedListeners, listeners); @@ -9125,25 +9183,44 @@ WindowsForm void SetParent(INativeWindow* parent)override { - parentWindow=dynamic_cast(parent); - if(parentWindow) + if (parentWindow) { + parentWindow->childWindows.Remove(this); + } + + if ((parentWindow = dynamic_cast(parent))) + { + parentWindow->childWindows.Add(this); + // ::SetParent(handle, parentWindow->handle); SetWindowLongPtr(handle, GWLP_HWNDPARENT, (LONG_PTR)parentWindow->handle); } else { + // ::SetParent(handle, NULL); SetWindowLongPtr(handle, GWLP_HWNDPARENT, NULL); } } - bool GetAlwaysPassFocusToParent()override + WindowMode GetWindowMode()override { - return alwaysPassFocusToParent; + return windowMode; } - void SetAlwaysPassFocusToParent(bool value)override + void SetWindowMode(WindowMode mode)override { - alwaysPassFocusToParent=value; + windowMode = mode; + auto style = InternalGetStyle(); + if (mode == Normal) + { + style = TurnOnStyle(style, WS_OVERLAPPED); + style = TurnOffStyle(style, WS_POPUP); + } + else + { + style = TurnOffStyle(style, WS_OVERLAPPED); + style = TurnOnStyle(style, WS_POPUP); + } + InternalSetStyle(style); } void EnableCustomFrameMode()override @@ -9563,7 +9640,7 @@ WindowsForm void SetTopMost(bool topmost)override { - SetWindowPos(handle, (topmost ? HWND_TOPMOST : HWND_NOTOPMOST), 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_FRAMECHANGED); + SetWindowPos(handle, (topmost ? HWND_TOPMOST : HWND_NOTOPMOST), 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_FRAMECHANGED); } void SupressAlt()override @@ -9617,7 +9694,6 @@ WindowsController LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK GodProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); - LRESULT CALLBACK MouseProc(int nCode , WPARAM wParam , LPARAM lParam); class WindowsController : public Object, public virtual INativeController, public virtual INativeWindowService { @@ -9647,7 +9723,6 @@ WindowsController ,mainWindow(0) ,mainWindowHandle(0) ,screenService(&GetHWNDFromNativeWindowHandle) - ,inputService(&MouseProc) ,dialogService(&GetHWNDFromNativeWindowHandle) { godWindow=CreateWindowEx(WS_EX_CONTROLPARENT, godClass.GetName().Buffer(), L"GodWindow", WS_OVERLAPPEDWINDOW, 0, 0, 0, 0, NULL, NULL, hInstance, NULL); @@ -9658,7 +9733,6 @@ WindowsController ~WindowsController() { inputService.StopTimer(); - inputService.StopHookMouse(); clipboardService.SetOwnerHandle(NULL); DestroyWindow(godWindow); } @@ -9700,17 +9774,32 @@ WindowsController { if (hwnd == mainWindowHandle && uMsg == WM_DESTROY) { - for (vint i = 0; i < windows.Count(); i++) + FOREACH(WindowsForm*, window, windows.Values()) { - if (windows.Values().Get(i)->IsVisible()) + if (window->IsVisible()) { - windows.Values().Get(i)->Hide(true); + window->Hide(true); } } - while (windows.Count()) + List normalWindows; + CopyFrom( + normalWindows, + From(windows.Values()) + .Where([](WindowsForm* window) + { + return window->GetWindowMode() == INativeWindow::Normal; + }) + ); + FOREACH(WindowsForm*, window, normalWindows) { - DestroyNativeWindow(windows.Values().Get(0)); + DestroyNativeWindow(window); } + for (vint i = windows.Count() - 1; i >= 0; i--) + { + auto window = windows.Values()[i]; + DestroyNativeWindow(window); + } + PostQuitMessage(0); } } @@ -9832,11 +9921,6 @@ WindowsController //======================================================================= - void InvokeMouseHook(WPARAM message, NativePoint location) - { - callbackService.InvokeMouseHook(message, location); - } - void InvokeGlobalTimer() { callbackService.InvokeGlobalTimer(); @@ -9884,18 +9968,6 @@ Windows Procedure return DefWindowProc(hwnd, uMsg, wParam, lParam); } - LRESULT CALLBACK MouseProc(int nCode , WPARAM wParam , LPARAM lParam) - { - WindowsController* controller=dynamic_cast(GetCurrentController()); - if(controller) - { - MSLLHOOKSTRUCT* mouseHookStruct=(MSLLHOOKSTRUCT*)lParam; - NativePoint location(mouseHookStruct->pt.x, mouseHookStruct->pt.y); - controller->InvokeMouseHook(wParam, location); - } - return CallNextHookEx(NULL,nCode,wParam,lParam); - } - /*********************************************************************** Windows Platform Native Controller ***********************************************************************/ @@ -10322,6 +10394,16 @@ ControllerListener } } + ~Direct2DWindowsNativeControllerListener() + { + for (vint i = 0; i < nativeWindowListeners.Count(); i++) + { + auto window = nativeWindowListeners.Keys()[i]; + auto listener = nativeWindowListeners.Values()[i]; + window->UninstallListener(listener.Obj()); + } + } + ComPtr CreateD3D11Device(D3D_DRIVER_TYPE driverType) { UINT flags = D3D11_CREATE_DEVICE_BGRA_SUPPORT; @@ -12633,6 +12715,16 @@ namespace vl public: Dictionary> nativeWindowListeners; + ~GdiWindowsNativeControllerListener() + { + for (vint i = 0; i < nativeWindowListeners.Count(); i++) + { + auto window = nativeWindowListeners.Keys()[i]; + auto listener = nativeWindowListeners.Values()[i]; + window->UninstallListener(listener.Obj()); + } + } + void NativeWindowCreated(INativeWindow* window) { Ptr listener=new GdiWindowsNativeWindowListener(window); @@ -13010,53 +13102,6 @@ WindowsCallbackService } } - void WindowsCallbackService::InvokeMouseHook(WPARAM message, NativePoint location) - { - switch(message) - { - case WM_LBUTTONDOWN: - { - for(vint i=0;iLeftButtonDown(location); - } - } - break; - case WM_LBUTTONUP: - { - for(vint i=0;iLeftButtonUp(location); - } - } - break; - case WM_RBUTTONDOWN: - { - for(vint i=0;iRightButtonDown(location); - } - } - break; - case WM_RBUTTONUP: - { - for(vint i=0;iRightButtonUp(location); - } - } - break; - case WM_MOUSEMOVE: - { - for(vint i=0;iMouseMoving(location); - } - } - break; - } - } - void WindowsCallbackService::InvokeGlobalTimer() { for(vint i=0;i keyNames; collections::Dictionary keys; @@ -2251,12 +2248,9 @@ namespace vl WString GetKeyNameInternal(VKEY code); void InitializeKeyNames(); public: - WindowsInputService(HOOKPROC _mouseProc); + WindowsInputService(); void SetOwnerHandle(HWND handle); - void StartHookMouse()override; - void StopHookMouse()override; - bool IsHookingMouse()override; void StartTimer()override; void StopTimer()override; bool IsTimerEnabled()override; diff --git a/Tools/CppMerge.exe b/Tools/CppMerge.exe index b867a12c..7cf6653b 100644 Binary files a/Tools/CppMerge.exe and b/Tools/CppMerge.exe differ diff --git a/Tools/GacGen32.exe b/Tools/GacGen32.exe index 73828dc2..71174274 100644 Binary files a/Tools/GacGen32.exe and b/Tools/GacGen32.exe differ diff --git a/Tools/GacGen64.exe b/Tools/GacGen64.exe index 14fba644..c5def4c9 100644 Binary files a/Tools/GacGen64.exe and b/Tools/GacGen64.exe differ diff --git a/Tools/ParserGen.exe b/Tools/ParserGen.exe index 6589efee..465f010c 100644 Binary files a/Tools/ParserGen.exe and b/Tools/ParserGen.exe differ diff --git a/Tutorial/GacUI_HelloWorlds/UIRes/Xml.bin.x64 b/Tutorial/GacUI_HelloWorlds/UIRes/Xml.bin.x64 index c54faab5..6dd0cb84 100644 Binary files a/Tutorial/GacUI_HelloWorlds/UIRes/Xml.bin.x64 and b/Tutorial/GacUI_HelloWorlds/UIRes/Xml.bin.x64 differ diff --git a/Tutorial/GacUI_HelloWorlds/UIRes/Xml.bin.x86 b/Tutorial/GacUI_HelloWorlds/UIRes/Xml.bin.x86 index 173cf12c..b8c887f1 100644 Binary files a/Tutorial/GacUI_HelloWorlds/UIRes/Xml.bin.x86 and b/Tutorial/GacUI_HelloWorlds/UIRes/Xml.bin.x86 differ