-rw-r--r-- | GeneralPage.cpp | 168 |
1 files changed, 168 insertions, 0 deletions
diff --git a/GeneralPage.cpp b/GeneralPage.cpp new file mode 100644 index 0000000..58ebe74 --- a/dev/null +++ b/GeneralPage.cpp | |||
@@ -0,0 +1,168 @@ | |||
1 | // GeneralPage.cpp : implementation file | ||
2 | // | ||
3 | |||
4 | #include "stdafx.h" | ||
5 | #include "BigBrother.h" | ||
6 | #include "GeneralPage.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 | ||
14 | static char THIS_FILE[] = __FILE__; | ||
15 | #endif | ||
16 | |||
17 | ///////////////////////////////////////////////////////////////////////////// | ||
18 | // CGeneralPage property page | ||
19 | |||
20 | IMPLEMENT_DYNCREATE(CGeneralPage, CPropertyPage) | ||
21 | |||
22 | CGeneralPage::CGeneralPage() : CPropertyPage(CGeneralPage::IDD) | ||
23 | { | ||
24 | //{{AFX_DATA_INIT(CGeneralPage) | ||
25 | m_Desc = _T(""); | ||
26 | m_Host = _T(""); | ||
27 | m_LogActivity = FALSE; | ||
28 | //}}AFX_DATA_INIT | ||
29 | } | ||
30 | |||
31 | CGeneralPage::~CGeneralPage() | ||
32 | { | ||
33 | } | ||
34 | |||
35 | void CGeneralPage::DoDataExchange(CDataExchange* pDX) | ||
36 | { | ||
37 | CPropertyPage::DoDataExchange(pDX); | ||
38 | //{{AFX_DATA_MAP(CGeneralPage) | ||
39 | DDX_Control(pDX, IDC_LOG_ACTIVITY, m_LogActivityCtl); | ||
40 | DDX_Control(pDX, IDC_HOST, m_HostCtl); | ||
41 | DDX_Control(pDX, IDC_DESC, m_DescCtl); | ||
42 | DDX_Text(pDX, IDC_DESC, m_Desc); | ||
43 | DDX_Text(pDX, IDC_HOST, m_Host); | ||
44 | DDX_Check(pDX, IDC_LOG_ACTIVITY, m_LogActivity); | ||
45 | //}}AFX_DATA_MAP | ||
46 | } | ||
47 | |||
48 | |||
49 | BEGIN_MESSAGE_MAP(CGeneralPage, CPropertyPage) | ||
50 | //{{AFX_MSG_MAP(CGeneralPage) | ||
51 | ON_EN_CHANGE(IDC_HOST, OnChangeHost) | ||
52 | ON_BN_CLICKED(IDC_LOG_ACTIVITY, OnLogActivity) | ||
53 | //}}AFX_MSG_MAP | ||
54 | END_MESSAGE_MAP() | ||
55 | |||
56 | ///////////////////////////////////////////////////////////////////////////// | ||
57 | // CGeneralPage message handlers | ||
58 | |||
59 | void CGeneralPage::OnChangeHost() | ||
60 | { | ||
61 | CString h,d; | ||
62 | m_HostCtl.GetWindowText(h); | ||
63 | m_DescCtl.GetWindowText(d); | ||
64 | if(d==m_Host){ | ||
65 | m_Desc=h; | ||
66 | m_Host=h; | ||
67 | m_DescCtl.SetWindowText(m_Desc); | ||
68 | } | ||
69 | } | ||
70 | |||
71 | void CGeneralPage::OnLogActivity() | ||
72 | { | ||
73 | ASSERT(m_dad->m_Brother); | ||
74 | if(!m_dad->m_Brother->m_Daddy){ | ||
75 | int tmp = m_LogActivityCtl.GetCheck(); | ||
76 | if(tmp==2){ | ||
77 | if(m_LogActivity) | ||
78 | tmp=0; | ||
79 | else | ||
80 | tmp=1; | ||
81 | } | ||
82 | m_LogActivity=tmp; | ||
83 | }else | ||
84 | m_LogActivity=m_LogActivityCtl.GetCheck(); | ||
85 | m_LogActivityCtl.SetCheck(m_LogActivity); | ||
86 | SetupControls(); | ||
87 | } | ||
88 | |||
89 | void CGeneralPage::UpdatePage() | ||
90 | { | ||
91 | if(!m_dad->m_Brother) | ||
92 | return; | ||
93 | m_Host=m_dad->m_Brother->m_Host; | ||
94 | m_Desc=m_dad->m_Brother->m_Desc; | ||
95 | m_LogActivity=(m_dad->m_Brother->flags&CBrother::flagsOverrideLogging)?(m_dad->m_Brother->m_bLog?1:0):2; | ||
96 | if(::IsWindow(m_hWnd)){ | ||
97 | UpdateData(FALSE); | ||
98 | SetupControls(); | ||
99 | } | ||
100 | } | ||
101 | |||
102 | BOOL CGeneralPage::OnSetActive() | ||
103 | { | ||
104 | UpdatePage(); | ||
105 | |||
106 | return CPropertyPage::OnSetActive(); | ||
107 | } | ||
108 | |||
109 | void CGeneralPage::UpdateBrother() | ||
110 | { | ||
111 | if(!m_dad->m_Brother){ | ||
112 | TRACE0("No brother on update\n"); | ||
113 | return; | ||
114 | } | ||
115 | if(::IsWindow(m_hWnd)) | ||
116 | UpdateData(); | ||
117 | CBrother toCompare; | ||
118 | toCompare = *m_dad->m_Brother; | ||
119 | m_dad->m_Brother->m_Host=m_Host; | ||
120 | m_dad->m_Brother->m_Desc=m_Desc; | ||
121 | switch(m_LogActivity){ | ||
122 | case0: | ||
123 | m_dad->m_Brother->m_bLog=FALSE; | ||
124 | m_dad->m_Brother->flags|=CBrother::flagsOverrideLogging; | ||
125 | break; | ||
126 | case1: | ||
127 | m_dad->m_Brother->m_bLog=TRUE; | ||
128 | m_dad->m_Brother->flags|=CBrother::flagsOverrideLogging; | ||
129 | break; | ||
130 | default: | ||
131 | m_dad->m_Brother->flags&=~CBrother::flagsOverrideLogging; | ||
132 | break; | ||
133 | } | ||
134 | m_dad->m_Brother->ParentalAdjust(); | ||
135 | if(toCompare!=(*m_dad->m_Brother)){ | ||
136 | CDocument *pDoc = m_dad->m_Daddy->GetDocument(); | ||
137 | ASSERT(pDoc); | ||
138 | pDoc->SetModifiedFlag(); | ||
139 | } | ||
140 | if(::IsWindow(m_hWnd)){ | ||
141 | UpdateData(FALSE); | ||
142 | SetupControls(); | ||
143 | } | ||
144 | m_dad->m_Daddy->UpdateBrother(m_dad->m_Brother); | ||
145 | } | ||
146 | |||
147 | void CGeneralPage::SetupControls() | ||
148 | { | ||
149 | CString tmp; | ||
150 | switch(m_LogActivity){ | ||
151 | case 0: | ||
152 | tmp.LoadString(IDS_LOG_DONTLOG); | ||
153 | break; | ||
154 | case 1: | ||
155 | tmp.LoadString(IDS_LOG_DOLOG); | ||
156 | break; | ||
157 | default: | ||
158 | tmp.LoadString(IDS_LOG_ASKBIGBROTHER); | ||
159 | break; | ||
160 | } | ||
161 | m_LogActivityCtl.SetWindowText(tmp); | ||
162 | } | ||
163 | |||
164 | BOOL CGeneralPage::OnKillActive() | ||
165 | { | ||
166 | UpdateBrother(); | ||
167 | return CPropertyPage::OnKillActive(); | ||
168 | } | ||