| 1 | /*
|
|---|
| 2 | * synergy -- mouse and keyboard sharing utility
|
|---|
| 3 | * Copyright (C) 2003 Chris Schoeneman
|
|---|
| 4 | *
|
|---|
| 5 | * This package is free software; you can redistribute it and/or
|
|---|
| 6 | * modify it under the terms of the GNU General Public License
|
|---|
| 7 | * found in the file COPYING that should have accompanied this file.
|
|---|
| 8 | *
|
|---|
| 9 | * This package is distributed in the hope that it will be useful,
|
|---|
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 12 | * GNU General Public License for more details.
|
|---|
| 13 | */
|
|---|
| 14 |
|
|---|
| 15 | #ifndef CSCREENSLINKS_H
|
|---|
| 16 | #define CSCREENSLINKS_H
|
|---|
| 17 |
|
|---|
| 18 | #include "CConfig.h"
|
|---|
| 19 | #include "ProtocolTypes.h"
|
|---|
| 20 | #include "CString.h"
|
|---|
| 21 |
|
|---|
| 22 | #define WINDOWS_LEAN_AND_MEAN
|
|---|
| 23 | #include <windows.h>
|
|---|
| 24 |
|
|---|
| 25 | //! Screens and links dialog for Microsoft Windows launcher
|
|---|
| 26 | class CScreensLinks {
|
|---|
| 27 | public:
|
|---|
| 28 | CScreensLinks(HWND parent, CConfig*);
|
|---|
| 29 | ~CScreensLinks();
|
|---|
| 30 |
|
|---|
| 31 | //! @name manipulators
|
|---|
| 32 | //@{
|
|---|
| 33 |
|
|---|
| 34 | //! Run dialog
|
|---|
| 35 | /*!
|
|---|
| 36 | Display and handle the dialog until closed by the user.
|
|---|
| 37 | */
|
|---|
| 38 | void doModal();
|
|---|
| 39 |
|
|---|
| 40 | //@}
|
|---|
| 41 | //! @name accessors
|
|---|
| 42 | //@{
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 | //@}
|
|---|
| 46 |
|
|---|
| 47 | private:
|
|---|
| 48 | typedef std::pair<CConfig::CCellEdge, CConfig::CCellEdge> CConfigLink;
|
|---|
| 49 | struct CEdgeLink {
|
|---|
| 50 | public:
|
|---|
| 51 | CEdgeLink();
|
|---|
| 52 | CEdgeLink(const CString& name, const CConfigLink&);
|
|---|
| 53 |
|
|---|
| 54 | bool connect(CConfig*);
|
|---|
| 55 | bool disconnect(CConfig*);
|
|---|
| 56 | void rename(const CString& oldName, const CString& newName);
|
|---|
| 57 |
|
|---|
| 58 | bool overlaps(const CConfig* config) const;
|
|---|
| 59 | bool operator==(const CEdgeLink&) const;
|
|---|
| 60 |
|
|---|
| 61 | public:
|
|---|
| 62 | CString m_srcName;
|
|---|
| 63 | EDirection m_srcSide;
|
|---|
| 64 | CConfig::CInterval m_srcInterval;
|
|---|
| 65 | CString m_dstName;
|
|---|
| 66 | CConfig::CInterval m_dstInterval;
|
|---|
| 67 | };
|
|---|
| 68 | typedef std::vector<CEdgeLink> CEdgeLinkList;
|
|---|
| 69 |
|
|---|
| 70 | void init(HWND hwnd);
|
|---|
| 71 | bool save(HWND hwnd);
|
|---|
| 72 |
|
|---|
| 73 | CString getSelectedScreen(HWND hwnd) const;
|
|---|
| 74 | void addScreen(HWND hwnd);
|
|---|
| 75 | void editScreen(HWND hwnd);
|
|---|
| 76 | void removeScreen(HWND hwnd);
|
|---|
| 77 | void addLink(HWND hwnd);
|
|---|
| 78 | void editLink(HWND hwnd);
|
|---|
| 79 | void removeLink(HWND hwnd);
|
|---|
| 80 |
|
|---|
| 81 | void updateScreens(HWND hwnd, const CString& name);
|
|---|
| 82 | void updateScreensControls(HWND hwnd);
|
|---|
| 83 | void updateLinks(HWND hwnd);
|
|---|
| 84 | void updateLinksControls(HWND hwnd);
|
|---|
| 85 |
|
|---|
| 86 | void changeSrcSide(HWND hwnd);
|
|---|
| 87 | void changeSrcScreen(HWND hwnd);
|
|---|
| 88 | void changeDstScreen(HWND hwnd);
|
|---|
| 89 | void changeIntervalStart(HWND hwnd, int id,
|
|---|
| 90 | CConfig::CInterval&);
|
|---|
| 91 | void changeIntervalEnd(HWND hwnd, int id,
|
|---|
| 92 | CConfig::CInterval&);
|
|---|
| 93 |
|
|---|
| 94 | void selectScreen(HWND hwnd, int id, const CString& name);
|
|---|
| 95 | void updateLinkEditControls(HWND hwnd,
|
|---|
| 96 | const CEdgeLink& link);
|
|---|
| 97 | void updateLinkIntervalControls(HWND hwnd,
|
|---|
| 98 | const CEdgeLink& link);
|
|---|
| 99 | void updateLink(HWND hwnd);
|
|---|
| 100 | void updateLinkValid(HWND hwnd, const CEdgeLink& link);
|
|---|
| 101 |
|
|---|
| 102 | void updateLinkView(HWND hwnd);
|
|---|
| 103 |
|
|---|
| 104 | HWND createErrorBox(HWND parent);
|
|---|
| 105 | void resizeErrorBoxes();
|
|---|
| 106 | void resizeErrorBox(HWND box, HWND assoc);
|
|---|
| 107 |
|
|---|
| 108 | CString formatIntervalValue(float) const;
|
|---|
| 109 | CString formatInterval(const CConfig::CInterval&) const;
|
|---|
| 110 | CString formatLink(const CEdgeLink&) const;
|
|---|
| 111 |
|
|---|
| 112 | // message handling
|
|---|
| 113 | BOOL doDlgProc(HWND, UINT, WPARAM, LPARAM);
|
|---|
| 114 | static BOOL CALLBACK dlgProc(HWND, UINT, WPARAM, LPARAM);
|
|---|
| 115 |
|
|---|
| 116 | private:
|
|---|
| 117 | static CScreensLinks* s_singleton;
|
|---|
| 118 |
|
|---|
| 119 | HWND m_parent;
|
|---|
| 120 | CConfig* m_mainConfig;
|
|---|
| 121 | CConfig m_scratchConfig;
|
|---|
| 122 | CConfig* m_config;
|
|---|
| 123 |
|
|---|
| 124 | CString m_linkFormat;
|
|---|
| 125 | CString m_intervalFormat;
|
|---|
| 126 | CString m_newLinkLabel;
|
|---|
| 127 | CString m_sideLabel[kNumDirections];
|
|---|
| 128 | CEdgeLinkList m_edgeLinks;
|
|---|
| 129 | SInt32 m_selectedLink;
|
|---|
| 130 | CEdgeLink m_editedLink;
|
|---|
| 131 | bool m_editedLinkIsValid;
|
|---|
| 132 | HPEN m_redPen;
|
|---|
| 133 | HWND m_srcSideError;
|
|---|
| 134 | HWND m_srcScreenError;
|
|---|
| 135 | HWND m_dstScreenError;
|
|---|
| 136 | };
|
|---|
| 137 |
|
|---|
| 138 | #endif
|
|---|