-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppDlg.hpp
153 lines (116 loc) · 3.06 KB
/
AppDlg.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
////////////////////////////////////////////////////////////////////////////////
//! \file AppDlg.hpp
//! \brief The AppDlg class declaration.
//! \author Chris Oldwood
// Check for previous inclusion
#ifndef APP_APPDLG_HPP
#define APP_APPDLG_HPP
#if _MSC_VER > 1000
#pragma once
#endif
#include <WCL/MainDlg.hpp>
#include <WCL/ListView.hpp>
#include "Host.hpp"
#include "Credentials.hpp"
// Forward declarations.
namespace WCL
{
class ICmdController;
}
class AppWnd;
class Model;
class Hosts;
class Tools;
////////////////////////////////////////////////////////////////////////////////
//! The application main dialog. This is the dialog that sits in the centre of
//! application window.
class AppDlg : public CMainDlg
{
public:
//! The column width collection type.
typedef std::vector<size_t> ColumnWidths;
public:
//! Constructor.
AppDlg(AppWnd& appWnd, WCL::ICmdController& appCmds, Model& model);
//! Destructor.
virtual ~AppDlg();
//
// Properties.
//
//! Is a host currently selected?
bool isHostSelected() const;
//! Get the index of the currently selected host, if available.
size_t getSelectedHostIndex() const;
//! Get the currently selected host, if available.
ConstHostPtr getSelectedHost() const;
//! Get the final widths of the main view columns.
const ColumnWidths& getFinalColumnWidths() const;
//! Set the widths of the main view columns.
void setColumnWidths(const ColumnWidths& widths);
//
// Methods.
//
//! Add a new host to be monitored.
void addHost(ConstHostPtr host);
//! Replace the currently selected host.
void replaceHost(ConstHostPtr host);
//! Swap two hosts in the view by index.
void swapHosts(size_t first, size_t second);
//! Remove the currently selected host.
void removeSelectedHost();
//! Rebuild the view.
void rebuildView();
//! Refresh the hosts view.
void refreshView();
private:
//
// Members.
//
AppWnd& m_appWnd; //!< The main window.
WCL::ICmdController& m_appCmds; //!< The command controller.
Model& m_model; //!< The data model.
ColumnWidths m_finalWidths; //!< The final width for each column.
Credentials m_logons; //!< The credential cache.
//
// Controls.
//
CListView m_hostView; //!< The main display.
//
// Message processors.
//
//! Handle dialog creation.
virtual void OnInitDialog();
//! Handle the dialog being destroyed.
virtual void OnDestroy();
//! Handle change in host selection.
LRESULT onHostSelectionChanged(NMHDR& header);
//! Handle a right-click on the hosts view.
LRESULT onRightClick(NMHDR& header);
//
// Internal methods.
//
//! Initialise the hosts view.
void initialiseHostView();
//! Add a host to the view.
void addHostToView(size_t index);
//! Refresh the view for a single host.
bool refreshHost(size_t index);
//! Clear the results for the host.
void clearHost(size_t index);
//! The hosts view columns.
enum Column
{
HOST_NAME,
ENVIRONMENT,
DESCRIPTION,
CUSTOM_BASE,
};
//! The host status.
enum HostStatus
{
STATUS_UNKNOWN = 0,
STATUS_BAD = 1,
STATUS_GOOD = 2,
};
};
#endif // APP_APPDLG_HPP