|
From: Ralph T. <ra...@us...> - 2005-04-05 05:46:13
|
Update of /cvsroot/adobe-source/sandbox/adobe-source/adobe/test/visual/headers/win In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1814/adobe-source/adobe/test/visual/headers/win Modified Files: ui_core_implementation.hpp Added Files: event_dispatcher.hpp Log Message: The event_dispatcher has moved out of the ui_core_implementation.cpp file. The main message pump now checks for modifier keys whenever an event is recieved. All modifier keys now work on Windows. Index: ui_core_implementation.hpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/test/visual/headers/win/ui_core_implementation.hpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ui_core_implementation.hpp 4 Apr 2005 23:32:24 -0000 1.7 --- ui_core_implementation.hpp 5 Apr 2005 05:46:04 -0000 1.8 *************** *** 16,19 **** --- 16,20 ---- #include "ui_core.hpp" + #include "event_dispatcher.hpp" #include <adobe/future/memory.hpp> *************** *** 126,130 **** int uxtheme_type_m; static HWND invisible_parent_m; // an invisible window used as the initial parent for all controls. ! class event_dispatcher& event_dispatcher_m; // event handling mechanism. HMENU child_id_m; // this control_m's child id. #ifndef NDEBUG --- 127,131 ---- int uxtheme_type_m; static HWND invisible_parent_m; // an invisible window used as the initial parent for all controls. ! event_dispatcher::reference event_dispatcher_m; // ref. to singleton event dispatcher. HMENU child_id_m; // this control_m's child id. #ifndef NDEBUG --- NEW FILE: event_dispatcher.hpp --- /* Copyright 2005 Ralph Thomas Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt or a copy at http://opensource.adobe.com/licenses.html) */ /****************************************************************************************************/ // /// This header defines the event_dispatcher, a class which is used to send events /// to the correct control_t. It works by knowing about all control_t's and the /// child IDs of thier windows. When an event comes in, it finds out which child ID /// generated it and forwards the event to the owning control_t. /// /// It is also able to handle keyboard modifier events, before they get translated /// and dispatched by the message pump. When the currently pressed combination of /// modifiers changes all of the controls are informed, in case they need to change /// their titles. // /****************************************************************************************************/ #ifndef ADOBE_EVENT_DISPATCHER_HPP #define ADOBE_EVENT_DISPATCHER_HPP /****************************************************************************************************/ #include <map> #include <string> #include <windows.h> /****************************************************************************************************/ namespace adobe { /****************************************************************************************************/ class control_t; /****************************************************************************************************/ // /// The event_dispatcher keeps track of all control_t's and the child ids which /// they use. All control_t objects should contain a event_dispatcher::reference /// inside them. // class event_dispatcher { typedef std::map<int, control_t*> control_map_t; control_map_t control_map_m; ///< Mapping Child ID -> control_t* int current_id_m; ///< Child ID to next issue // /// This private constructor maintains the singleton nature of /// this class. // event_dispatcher(); friend class reference; public: // /// This reference class contains a reference to the event_dispatcher, /// and should be used by controls to subscribe and unsubscribe -- all /// controls should have one of these as a member variable. // class reference { int child_id_m; ///< The child ID for the owning control_t. public: // /// This constructor initializes all values to zero, and acquires a /// reference to the event_dispatcher. // reference(); // /// Unsubscribe any control which subscribed to the event_dispatcher /// and release the reference to the event_dispatcher. // ~reference(); // /// Subscribe the given control_t to the event_dispatcher. The returned /// value should be used as the child Id for the window which the given /// control will create. /// /// \param control the control to subscribe to events. /// \return the child id for the control to use. // HMENU subscribe(control_t* control); // /// Return the child ID. /// /// \return the child id to use for windows belonging to the subscribed /// control, or NULL if no control has subscribed through this /// reference. // HMENU child_id() const; }; // /// Dispatch an event through to the control which needs to process it. /// /// \param message The Windows message type. /// \param wParam The pointer parameter of the message. /// \param lParam the long parameter of the message. /// \param handled this reference bool is set to true if the message /// was dispatched to a child, or to false if no child /// could be found. /// \return the result of the event. // static LRESULT event(UINT message, WPARAM wParam, LPARAM lParam, bool& handled); // /// Examine the given keyboard message and send any required modifier events /// to controls. /// /// \param message The Windows message type. /// \param wParam The WPARAM value from the Windows message. // static void keyboard(UINT message, WPARAM wParam); }; /****************************************************************************************************/ } /****************************************************************************************************/ #endif /****************************************************************************************************/ |