summaryrefslogtreecommitdiffabout
path: root/SettingsPage.cpp
Unidiff
Diffstat (limited to 'SettingsPage.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--SettingsPage.cpp186
1 files changed, 186 insertions, 0 deletions
diff --git a/SettingsPage.cpp b/SettingsPage.cpp
new file mode 100644
index 0000000..2fa42d0
--- a/dev/null
+++ b/SettingsPage.cpp
@@ -0,0 +1,186 @@
1// SettingsPage.cpp : implementation file
2//
3
4#include "stdafx.h"
5#include "BigBrother.h"
6#include "SettingsPage.h"
7#include "HostPropertyPages.h"
8#include "BigBrotherDoc.h"
9#include "BigBrotherView.h"
10
11#ifdef _DEBUG
12#define new DEBUG_NEW
13#undef THIS_FILE
14static char THIS_FILE[] = __FILE__;
15#endif
16
17/////////////////////////////////////////////////////////////////////////////
18// CSettingsPage property page
19
20IMPLEMENT_DYNCREATE(CSettingsPage, CPropertyPage)
21
22CSettingsPage::CSettingsPage() : CPropertyPage(CSettingsPage::IDD)
23{
24 //{{AFX_DATA_INIT(CSettingsPage)
25 m_OverrideIntervals = FALSE;
26 m_OverrideRetries = FALSE;
27 m_OverrideTimeout = FALSE;
28 m_IntervalBad = 0;
29 m_IntervalGood = 0;
30 m_TimeOut = 0;
31 m_Retries = 0;
32 //}}AFX_DATA_INIT
33}
34
35CSettingsPage::~CSettingsPage()
36{
37}
38
39void CSettingsPage::DoDataExchange(CDataExchange* pDX)
40{
41 CPropertyPage::DoDataExchange(pDX);
42 //{{AFX_DATA_MAP(CSettingsPage)
43 DDX_Control(pDX, IDC_RETRIES, m_RetriesCtl);
44 DDX_Control(pDX, IDC_PINGTIMEOUT, m_TimeOutCtl);
45 DDX_Control(pDX, IDC_PINGINTERVAL_GOOD, m_IntervalGoodCtl);
46 DDX_Control(pDX, IDC_PINGINTERVAL_BAD, m_IntervalBadCtl);
47 DDX_Control(pDX, IDC_OVERRIDE_TIMEOUT, m_OverrideTimeoutCtl);
48 DDX_Control(pDX, IDC_OVERRIDE_RETRIES, m_OverrideRetriesCtl);
49 DDX_Control(pDX, IDC_OVERRIDE_INTERVALS, m_OverrideIntervalsCtl);
50 DDX_Check(pDX, IDC_OVERRIDE_INTERVALS, m_OverrideIntervals);
51 DDX_Check(pDX, IDC_OVERRIDE_RETRIES, m_OverrideRetries);
52 DDX_Check(pDX, IDC_OVERRIDE_TIMEOUT, m_OverrideTimeout);
53 DDX_Text(pDX, IDC_PINGINTERVAL_BAD, m_IntervalBad);
54 DDX_Text(pDX, IDC_PINGINTERVAL_GOOD, m_IntervalGood);
55 DDX_Text(pDX, IDC_PINGTIMEOUT, m_TimeOut);
56 DDX_Text(pDX, IDC_RETRIES, m_Retries);
57 //}}AFX_DATA_MAP
58}
59
60
61BEGIN_MESSAGE_MAP(CSettingsPage, CPropertyPage)
62 //{{AFX_MSG_MAP(CSettingsPage)
63 ON_BN_CLICKED(IDC_OVERRIDE_INTERVALS, OnOverrideIntervals)
64 ON_BN_CLICKED(IDC_OVERRIDE_RETRIES, OnOverrideRetries)
65 ON_BN_CLICKED(IDC_OVERRIDE_TIMEOUT, OnOverrideTimeout)
66 //}}AFX_MSG_MAP
67END_MESSAGE_MAP()
68
69/////////////////////////////////////////////////////////////////////////////
70// CSettingsPage message handlers
71
72void CSettingsPage::SetupControls()
73{
74 m_IntervalBadCtl.EnableWindow(m_OverrideIntervals);
75 m_IntervalGoodCtl.EnableWindow(m_OverrideIntervals);
76 m_RetriesCtl.EnableWindow(m_OverrideRetries);
77 m_TimeOutCtl.EnableWindow(m_OverrideTimeout);
78}
79
80void CSettingsPage::UpdatePage()
81{
82 if(!m_dad->m_Brother)
83 return;
84 if(::IsWindow(m_hWnd)){
85 if(m_dad->m_Brother->m_Daddy){
86 m_OverrideIntervalsCtl.EnableWindow(TRUE);
87 m_OverrideRetriesCtl.EnableWindow(TRUE);
88 m_OverrideTimeoutCtl.EnableWindow(TRUE);
89 }else{
90 m_OverrideIntervalsCtl.EnableWindow(FALSE);
91 m_OverrideRetriesCtl.EnableWindow(FALSE);
92 m_OverrideTimeoutCtl.EnableWindow(FALSE);
93 }
94 }
95 if(m_dad->m_Brother->flags&CBrother::flagsOverrideIntervals)
96 m_OverrideIntervals=TRUE;
97 else
98 m_OverrideIntervals=FALSE;
99 if(m_dad->m_Brother->flags&CBrother::flagsOverrideTimeout)
100 m_OverrideTimeout=TRUE;
101 else
102 m_OverrideTimeout=FALSE;
103 if(m_dad->m_Brother->flags&CBrother::flagsOverrideRetries)
104 m_OverrideRetries=TRUE;
105 else
106 m_OverrideRetries=FALSE;
107 m_IntervalBad=m_dad->m_Brother->m_IntervalBad;
108 m_IntervalGood=m_dad->m_Brother->m_IntervalGood;
109 m_Retries=m_dad->m_Brother->m_Retries;
110 m_TimeOut=m_dad->m_Brother->m_TimeOut;
111 if(::IsWindow(m_hWnd)){
112 UpdateData(FALSE);
113 SetupControls();
114 }
115}
116
117BOOL CSettingsPage::OnSetActive()
118{
119 UpdatePage();
120 return CPropertyPage::OnSetActive();
121}
122
123void CSettingsPage::OnOverrideIntervals()
124{
125 UpdateBrother();
126 if(m_OverrideIntervals)
127 m_IntervalGoodCtl.SetFocus();
128}
129
130void CSettingsPage::OnOverrideRetries()
131{
132 UpdateBrother();
133 if(m_OverrideRetries)
134 m_RetriesCtl.SetFocus();
135}
136
137void CSettingsPage::OnOverrideTimeout()
138{
139 UpdateBrother();
140 if(m_OverrideTimeout)
141 m_TimeOutCtl.SetFocus();
142}
143
144void CSettingsPage::UpdateBrother()
145{
146 if(!m_dad->m_Brother){
147 TRACE0("No brother on update\n");
148 return;
149 }
150 if(::IsWindow(m_hWnd))
151 UpdateData();
152CBrother toCompare;
153 toCompare = *m_dad->m_Brother;
154 m_dad->m_Brother->m_IntervalBad=m_IntervalBad;
155 m_dad->m_Brother->m_IntervalGood=m_IntervalGood;
156 if(m_OverrideIntervals)
157 m_dad->m_Brother->flags|=CBrother::flagsOverrideIntervals;
158 else
159 m_dad->m_Brother->flags&=~CBrother::flagsOverrideIntervals;
160 m_dad->m_Brother->m_Retries=m_Retries;
161 if(m_OverrideRetries)
162 m_dad->m_Brother->flags|=CBrother::flagsOverrideRetries;
163 else
164 m_dad->m_Brother->flags&=~CBrother::flagsOverrideRetries;
165 m_dad->m_Brother->m_TimeOut=m_TimeOut;
166 if(m_OverrideTimeout)
167 m_dad->m_Brother->flags|=CBrother::flagsOverrideTimeout;
168 else
169 m_dad->m_Brother->flags&=~CBrother::flagsOverrideTimeout;
170 m_dad->m_Brother->ParentalAdjust();
171 if(toCompare!=(*m_dad->m_Brother)){
172 CDocument *pDoc = m_dad->m_Daddy->GetDocument();
173 ASSERT(pDoc);
174 pDoc->SetModifiedFlag();
175 }
176 if(::IsWindow(m_hWnd)){
177 UpdateData(FALSE);
178 SetupControls();
179 }
180}
181
182BOOL CSettingsPage::OnKillActive()
183{
184 UpdateBrother();
185 return CPropertyPage::OnKillActive();
186}