//////////////////////////////////////////////////////////////////////////////////////////////////// // NoesisGUI - http://www.noesisengine.com // Copyright (c) 2013 Noesis Technologies S.L. All Rights Reserved. //////////////////////////////////////////////////////////////////////////////////////////////////// #ifndef __GUI_COMMANDDATA_H__ #define __GUI_COMMANDDATA_H__ #include #include #include #include #include #include namespace Noesis { NS_INTERFACE ICommand; class RoutedCommand; class CommandBinding; class InputBinding; class InputGesture; template class UICollection; template class Delegate; struct CanExecuteRoutedEventArgs; struct ExecutedRoutedEventArgs; typedef UICollection CommandBindingCollection; typedef UICollection InputBindingCollection; typedef Delegate CanExecuteRoutedEventHandler; typedef Delegate ExecutedRoutedEventHandler; NS_WARNING_PUSH NS_MSVC_WARNING_DISABLE(4251 4275) //////////////////////////////////////////////////////////////////////////////////////////////////// /// Used to register UI commands. //////////////////////////////////////////////////////////////////////////////////////////////////// class NS_GUI_CORE_API CommandData: public TypeMetaData { public: CommandData(const TypeClass* ownerType); ~CommandData(); /// Registers a routed event for a type template const T* RegisterCommand(const Ptr& command); /// Finds a command for the owner type given its name const ICommand* FindCommand(Symbol name) const; /// Registers handlers for the specified command //@{ void RegisterCommandHandler(const ICommand* command, const ExecutedRoutedEventHandler& executedHandler); void RegisterCommandHandler(const ICommand* command, const ExecutedRoutedEventHandler& executedHandler, const Ptr& inputGesture); void RegisterCommandHandler(const ICommand* command, const ExecutedRoutedEventHandler& executedHandler, const Ptr& inputGesture1, const Ptr& inputGesture2); void RegisterCommandHandler(const ICommand* command, const CanExecuteRoutedEventHandler& canExecuteHandler, const ExecutedRoutedEventHandler& executedHandler); void RegisterCommandHandler(const ICommand* command, const CanExecuteRoutedEventHandler& canExecuteHandler, const ExecutedRoutedEventHandler& executedHandler, const Ptr& inputGesture); void RegisterCommandHandler(const ICommand* command, const CanExecuteRoutedEventHandler& canExecuteHandler, const ExecutedRoutedEventHandler& executedHandler, const Ptr& inputGesture1, const Ptr& inputGesture2); //@} /// Gets command bindings associated with the owner type /// Returned collection can be null const CommandBindingCollection* GetCommandBindings() const; /// Gets input bindings associated with the owner type /// Returned collection can be null const InputBindingCollection* GetInputBindings() const; private: static void DefaultCanExecute(BaseComponent* sender, const CanExecuteRoutedEventArgs& args); void InsertCommand(const RoutedCommand* command); void RegisterCommandBinding(const Ptr& binding); void RegisterInputBinding(const Ptr& binding); void EnsureCommandBindings(); void EnsureInputBindings(); private: const TypeClass* mOwnerType; struct Adapter; typedef HashMap> CommandMap; CommandMap mCommands; Ptr mCommandBindings; Ptr mInputBindings; NS_DECLARE_REFLECTION(CommandData, TypeMetaData) }; NS_WARNING_POP } #include #endif