Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

CHotkeyOptions.h

00001 /*
00002  * synergy -- mouse and keyboard sharing utility
00003  * Copyright (C) 2006 Chris Schoeneman
00004  * 
00005  * This package is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * found in the file COPYING that should have accompanied this file.
00008  * 
00009  * This package is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  */
00014 
00015 #ifndef CHOTKEYOPTIONS_H
00016 #define CHOTKEYOPTIONS_H
00017 
00018 #include "CString.h"
00019 #include "KeyTypes.h"
00020 #include "MouseTypes.h"
00021 #include "CInputFilter.h"
00022 
00023 #define WINDOWS_LEAN_AND_MEAN
00024 #include <windows.h>
00025 
00026 class CConfig;
00027 
00029 class CHotkeyOptions {
00030 public:
00031     CHotkeyOptions(HWND parent, CConfig*);
00032     ~CHotkeyOptions();
00033 
00035 
00036 
00038 
00041     void                doModal();
00042 
00044 
00045 
00046 
00048 
00049 private:
00050     void                doInit(HWND hwnd);
00051 
00052     void                fillHotkeys(HWND hwnd, UInt32 select = (UInt32)-1);
00053     void                updateHotkeysControls(HWND hwnd);
00054 
00055     void                addHotkey(HWND hwnd);
00056     void                removeHotkey(HWND hwnd);
00057     void                editHotkey(HWND hwnd);
00058 
00059     void                fillActions(HWND hwnd, UInt32 select = (UInt32)-1);
00060     void                updateActionsControls(HWND hwnd);
00061 
00062     void                addAction(HWND hwnd);
00063     void                removeAction(HWND hwnd);
00064     void                editAction(HWND hwnd);
00065 
00066     bool                editCondition(HWND hwnd, CInputFilter::CCondition*&);
00067     bool                editAction(HWND hwnd, CInputFilter::CAction*&,
00068                             bool& onActivate);
00069 
00070     void                openRule(HWND hwnd);
00071     void                closeRule(HWND hwnd);
00072     UInt32              findMatchingAction(
00073                             const CInputFilter::CKeystrokeAction*) const;
00074     UInt32              findMatchingAction(
00075                             const CInputFilter::CMouseButtonAction*) const;
00076 
00077     // message handling
00078     BOOL                doDlgProc(HWND, UINT, WPARAM, LPARAM);
00079     static BOOL CALLBACK dlgProc(HWND, UINT, WPARAM, LPARAM);
00080 
00081     // special actions we use to combine matching down/up actions into a
00082     // single action for the convenience of the user.
00083     class CKeystrokeDownUpAction : public CInputFilter::CKeystrokeAction {
00084     public:
00085         CKeystrokeDownUpAction(IPlatformScreen::CKeyInfo* adoptedInfo) :
00086             CInputFilter::CKeystrokeAction(adoptedInfo, true) { }
00087 
00088         // CAction overrides
00089         virtual CInputFilter::CAction*  clone() const
00090         {
00091             IKeyState::CKeyInfo* info = IKeyState::CKeyInfo::alloc(*getInfo());
00092             return new CKeystrokeDownUpAction(info);
00093         }
00094 
00095     protected:
00096         // CKeystrokeAction overrides
00097         virtual const char*     formatName() const { return "keystroke"; }
00098     };
00099     class CMouseButtonDownUpAction : public CInputFilter::CMouseButtonAction {
00100     public:
00101         CMouseButtonDownUpAction(IPrimaryScreen::CButtonInfo* adoptedInfo) :
00102             CInputFilter::CMouseButtonAction(adoptedInfo, true) { }
00103 
00104         // CAction overrides
00105         virtual CInputFilter::CAction*  clone() const
00106         {
00107             IPlatformScreen::CButtonInfo* info =
00108                 IPrimaryScreen::CButtonInfo::alloc(*getInfo());
00109             return new CMouseButtonDownUpAction(info);
00110         }
00111 
00112     protected:
00113         // CMouseButtonAction overrides
00114         virtual const char*     formatName() const { return "mousebutton"; }
00115     };
00116 
00117     class CConditionDialog {
00118     public:
00119         static bool     doModal(HWND parent, CInputFilter::CCondition*&);
00120 
00121     private:
00122         static void     doInit(HWND hwnd);
00123         static void     fillHotkey(HWND hwnd);
00124 
00125         static void     onButton(HWND hwnd, ButtonID button);
00126         static void     onKey(HWND hwnd, WPARAM wParam, LPARAM lParam);
00127         static KeyID    getChar(WPARAM wParam, LPARAM lParam);
00128         static KeyModifierMask
00129                         getModifiers();
00130 
00131         static bool     isGoodCondition();
00132 
00133         static BOOL CALLBACK    dlgProc(HWND, UINT, WPARAM, LPARAM);
00134         static LRESULT CALLBACK editProc(HWND hwnd, UINT, WPARAM, LPARAM);
00135 
00136     private:
00137         static CInputFilter::CCondition*
00138                                 s_condition;
00139         static CInputFilter::CCondition*
00140                                 s_lastGoodCondition;
00141         static WNDPROC          s_editWndProc;
00142     };
00143 
00144     class CActionDialog {
00145     public:
00146         static bool     doModal(HWND parent, CConfig* config,
00147                             CInputFilter::CAction*&, bool& onActivate);
00148 
00149     private:
00150         static void     doInit(HWND hwnd);
00151         static void     fillHotkey(HWND hwnd);
00152         static void     updateControls(HWND hwnd);
00153 
00154         static void     onButton(HWND hwnd, ButtonID button);
00155         static void     onKey(HWND hwnd, WPARAM wParam, LPARAM lParam);
00156         static void     onLockAction(HWND hwnd);
00157         static void     onSwitchToAction(HWND hwnd);
00158         static void     onSwitchInAction(HWND hwnd);
00159         static void     onKeyboardBroadcastAction(HWND hwnd);
00160 
00161         static KeyID    getChar(WPARAM wParam, LPARAM lParam);
00162         static KeyModifierMask
00163                         getModifiers();
00164 
00165         static bool     isGoodAction();
00166         static void     convertAction(HWND hwnd);
00167 
00168         static bool     isDownUpAction();
00169 
00170         static BOOL CALLBACK    dlgProc(HWND, UINT, WPARAM, LPARAM);
00171         static LRESULT CALLBACK editProc(HWND hwnd, UINT, WPARAM, LPARAM);
00172 
00173     private:
00174         static CConfig*         s_config;
00175         static bool             s_onActivate;
00176         static CInputFilter::CAction*
00177                                 s_action;
00178         static CInputFilter::CAction*
00179                                 s_lastGoodAction;
00180         static std::set<CString>    s_screens;
00181         static WNDPROC          s_editWndProc;
00182     };
00183 
00184 // public to allow CActionDialog to use it
00185 public:
00186     class CScreensDialog {
00187     public:
00188         static void     doModal(HWND parent, CConfig* config,
00189                             CInputFilter::CKeystrokeAction*);
00190 
00191         // public due to compiler brokenness
00192         typedef std::set<CString> CScreens;
00193 
00194     private:
00195 
00196         static void     doInit(HWND hwnd);
00197         static void     doFini(HWND hwnd);
00198         static void     fillScreens(HWND hwnd);
00199         static void     updateControls(HWND hwnd);
00200 
00201         static void     add(HWND hwnd);
00202         static void     remove(HWND hwnd);
00203 
00204         static void     getSelected(HWND hwnd, UINT id,
00205                             const CScreens& inScreens, CScreens& outScreens);
00206 
00207         static BOOL CALLBACK    dlgProc(HWND, UINT, WPARAM, LPARAM);
00208 
00209     private:
00210         static CConfig*                         s_config;
00211         static CInputFilter::CKeystrokeAction*  s_action;
00212         static CScreens                         s_nonTargets;
00213         static CScreens                         s_targets;
00214         static CString                          s_allScreens;
00215     };
00216 
00217 private:
00218     static CHotkeyOptions*  s_singleton;
00219 
00220     HWND                m_parent;
00221     CConfig*            m_config;
00222     CInputFilter*       m_inputFilter;
00223     CInputFilter::CRule m_activeRule;
00224     UInt32              m_activeRuleIndex;
00225 };
00226 
00227 #endif

Generated on Fri Nov 6 00:21:14 2009 for synergy-plus by  doxygen 1.3.9.1