00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef CSCREENSLINKS_H
00016 #define CSCREENSLINKS_H
00017
00018 #include "CConfig.h"
00019 #include "ProtocolTypes.h"
00020 #include "CString.h"
00021
00022 #define WINDOWS_LEAN_AND_MEAN
00023 #include <windows.h>
00024
00026 class CScreensLinks {
00027 public:
00028 CScreensLinks(HWND parent, CConfig*);
00029 ~CScreensLinks();
00030
00032
00033
00035
00038 void doModal();
00039
00041
00042
00043
00044
00046
00047 private:
00048 typedef std::pair<CConfig::CCellEdge, CConfig::CCellEdge> CConfigLink;
00049 struct CEdgeLink {
00050 public:
00051 CEdgeLink();
00052 CEdgeLink(const CString& name, const CConfigLink&);
00053
00054 bool connect(CConfig*);
00055 bool disconnect(CConfig*);
00056 void rename(const CString& oldName, const CString& newName);
00057
00058 bool overlaps(const CConfig* config) const;
00059 bool operator==(const CEdgeLink&) const;
00060
00061 public:
00062 CString m_srcName;
00063 EDirection m_srcSide;
00064 CConfig::CInterval m_srcInterval;
00065 CString m_dstName;
00066 CConfig::CInterval m_dstInterval;
00067 };
00068 typedef std::vector<CEdgeLink> CEdgeLinkList;
00069
00070 void init(HWND hwnd);
00071 bool save(HWND hwnd);
00072
00073 CString getSelectedScreen(HWND hwnd) const;
00074 void addScreen(HWND hwnd);
00075 void editScreen(HWND hwnd);
00076 void removeScreen(HWND hwnd);
00077 void addLink(HWND hwnd);
00078 void editLink(HWND hwnd);
00079 void removeLink(HWND hwnd);
00080
00081 void updateScreens(HWND hwnd, const CString& name);
00082 void updateScreensControls(HWND hwnd);
00083 void updateLinks(HWND hwnd);
00084 void updateLinksControls(HWND hwnd);
00085
00086 void changeSrcSide(HWND hwnd);
00087 void changeSrcScreen(HWND hwnd);
00088 void changeDstScreen(HWND hwnd);
00089 void changeIntervalStart(HWND hwnd, int id,
00090 CConfig::CInterval&);
00091 void changeIntervalEnd(HWND hwnd, int id,
00092 CConfig::CInterval&);
00093
00094 void selectScreen(HWND hwnd, int id, const CString& name);
00095 void updateLinkEditControls(HWND hwnd,
00096 const CEdgeLink& link);
00097 void updateLinkIntervalControls(HWND hwnd,
00098 const CEdgeLink& link);
00099 void updateLink(HWND hwnd);
00100 void updateLinkValid(HWND hwnd, const CEdgeLink& link);
00101
00102 void updateLinkView(HWND hwnd);
00103
00104 HWND createErrorBox(HWND parent);
00105 void resizeErrorBoxes();
00106 void resizeErrorBox(HWND box, HWND assoc);
00107
00108 CString formatIntervalValue(float) const;
00109 CString formatInterval(const CConfig::CInterval&) const;
00110 CString formatLink(const CEdgeLink&) const;
00111
00112
00113 BOOL doDlgProc(HWND, UINT, WPARAM, LPARAM);
00114 static BOOL CALLBACK dlgProc(HWND, UINT, WPARAM, LPARAM);
00115
00116 private:
00117 static CScreensLinks* s_singleton;
00118
00119 HWND m_parent;
00120 CConfig* m_mainConfig;
00121 CConfig m_scratchConfig;
00122 CConfig* m_config;
00123
00124 CString m_linkFormat;
00125 CString m_intervalFormat;
00126 CString m_newLinkLabel;
00127 CString m_sideLabel[kNumDirections];
00128 CEdgeLinkList m_edgeLinks;
00129 SInt32 m_selectedLink;
00130 CEdgeLink m_editedLink;
00131 bool m_editedLinkIsValid;
00132 HPEN m_redPen;
00133 HWND m_srcSideError;
00134 HWND m_srcScreenError;
00135 HWND m_dstScreenError;
00136 };
00137
00138 #endif