forked from tsupo/Chirrup
-
Notifications
You must be signed in to change notification settings - Fork 1
/
SettingHatena.cpp
151 lines (126 loc) · 3.87 KB
/
SettingHatena.cpp
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
/*
* SettingHatena.cpp : Twitter クライアント chirrup
* 設定ダイアログ(Hatena) インプリメンテーション ファイル
* written by H.Tsujimura 24 Aug 2007
*
* Copyright (c) 2007, 2008 by H.Tsujimura (tsupo@na.rim.or.jp)
* All Rights Reserved.
*
* $Log: /comm/chirrup/SettingHatena.cpp $
*
* 1 09/05/14 3:50 tsupo
* (1) ビルド環境のディレクトリ構造を整理
* (2) VSSサーバ拠点を変更
*
* 2 08/01/19 2:10 Tsujimura543
* はてなフォトライフ対応
*
* 1 07/08/25 0:14 Tsujimura543
* 最初の版
*/
#include "chirrup.h"
#include "chirrupDlg.h"
#include "SettingHatena.h"
#ifndef lint
static char *rcs_id =
"$Header: /comm/chirrup/SettingHatena.cpp 1 09/05/14 3:50 tsupo $";
#endif
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSettingHatena ダイアログ
CSettingHatena::CSettingHatena(CWnd* pParent /*=NULL*/)
: CTabDialog2(CSettingHatena::IDD, pParent)
{
//{{AFX_DATA_INIT(CSettingHatena)
m_useTwitStar = FALSE;
m_username = _T("");
m_password = _T("");
//}}AFX_DATA_INIT
}
// 「設定ダイアログ」での「適用」ボタン押下時処理
void CSettingHatena::Accept()
{
if ( m_initialized && m_chirrup ) {
m_chirrup->SetHatena( m_username, m_password,
m_useTwitStar, m_applied,
m_writeLogfile, m_logFilename );
}
}
// 現在の「設定」を取得
void CSettingHatena::LoadSetting()
{
if ( !m_initialized ) {
if ( m_chirrup ) {
m_chirrup->GetHatena( m_username, m_password,
m_useTwitStar, m_applied,
m_writeLogfile, m_logFilename );
}
}
}
void CSettingHatena::DoDataExchange(CDataExchange* pDX)
{
CTabDialog2::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSettingHatena)
DDX_Check(pDX, IDC_USE_TWITSTAR, m_useTwitStar);
DDX_Text(pDX, IDC_EDIT_USERNAME, m_username);
DDV_MaxChars(pDX, m_username, 64);
DDX_Text(pDX, IDC_EDIT_PASSWORD, m_password);
DDV_MaxChars(pDX, m_password, 64);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSettingHatena, CTabDialog2)
//{{AFX_MSG_MAP(CSettingHatena)
ON_WM_SHOWWINDOW()
ON_BN_CLICKED(IDC_USE_TWITSTAR, OnUseTwitstar)
ON_BN_CLICKED(IDC_APPLIED, OnApplied)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSettingHatena 追加メソッド
void CSettingHatena::SetCheckApplied()
{
CEdit *p = (CEdit *)GetDlgItem(IDC_EDIT_USERNAME);
p->EnableWindow( m_useTwitStar || m_applied );
p = (CEdit *)GetDlgItem(IDC_EDIT_PASSWORD);
p->EnableWindow( m_useTwitStar || m_applied );
CButton *bp = (CButton *)GetDlgItem(IDC_WRITE_LOGFILE);
bp->EnableWindow( m_applied );
SetCheckWriteLogfile();
}
/////////////////////////////////////////////////////////////////////////////
// CSettingHatena メッセージ ハンドラ
void CSettingHatena::OnShowWindow(BOOL bShow, UINT nStatus)
{
CTabDialog2::OnShowWindow(bShow, nStatus);
if ( bShow ) {
CEdit *p = (CEdit *)GetDlgItem(IDC_EDIT_USERNAME);
p->SetWindowText( m_username );
p = (CEdit *)GetDlgItem(IDC_EDIT_PASSWORD);
p->SetWindowText( m_password );
CButton *bp = (CButton *)GetDlgItem( IDC_USE_TWITSTAR );
bp->SetCheck( m_useTwitStar );
SetCheckApplied();
}
else {
CEdit *p = (CEdit *)GetDlgItem(IDC_EDIT_USERNAME);
p->GetWindowText( m_username );
p = (CEdit *)GetDlgItem(IDC_EDIT_PASSWORD);
p->GetWindowText( m_password );
}
}
void CSettingHatena::OnUseTwitstar()
{
CButton *bp = (CButton *)GetDlgItem( IDC_USE_TWITSTAR );
m_useTwitStar = bp->GetCheck();
SetCheckApplied();
}
void CSettingHatena::OnApplied()
{
CButton *bp = (CButton *)GetDlgItem( IDC_APPLIED );
m_applied = bp->GetCheck();
SetCheckApplied();
}