-
Notifications
You must be signed in to change notification settings - Fork 1
/
OpenSaveDlg.h
185 lines (136 loc) · 4.13 KB
/
OpenSaveDlg.h
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#ifndef _GREENPAD_OPENSAVEDLG_H_
#define _GREENPAD_OPENSAVEDLG_H_
#include "kilib/ktlarray.h"
#include "kilib/ktlaptr.h"
#include "kilib/string.h"
#include "rsrc/resource.h"
//========================================================================
//@{ @pkg Gp.Dlg //@}
//@{
// 利用可能文字コードリスト
//@}
//========================================================================
class CharSetList
{
public:
struct CsInfo
{
int ID;
const TCHAR* longName;
const TCHAR* shortName;
int type;
};
public:
CharSetList();
const CsInfo& operator[](size_t i) const { return list_[i]; }
ulong size() const { return list_.size(); }
int defaultCs() const;
ulong defaultCsi() const;
ulong findCsi( int cs ) const;
private:
enum { SAVE=1, LOAD=2, BOTH=3 };
ki::storage<CsInfo> list_;
};
//========================================================================
//@{
// 「ファイルを開く」ダイアログ
//
// Windows共通のダイアログの下に、文字コードの選択欄を
// 付け加えたものを表示する。
//@}
//========================================================================
class OpenFileDlg
{
public:
explicit OpenFileDlg( const CharSetList& csl );
bool DoModal( HWND wnd, const TCHAR* filter, const TCHAR* fnm );
public:
const TCHAR* filename() const;
int csi() const;
public:
static ki::aarr<TCHAR> ConnectWithNull( ki::String lst[], int num );
private:
const CharSetList& csl_;
TCHAR filename_[MAX_PATH];
int csIndex_;
private:
static OpenFileDlg* pThis; // マルチスレッド禁止!
static UINT_PTR CALLBACK OfnHook( HWND, UINT, WPARAM, LPARAM );
};
//------------------------------------------------------------------------
#ifndef __ccdoc__
inline OpenFileDlg::OpenFileDlg( const CharSetList& csl )
: csl_(csl) {}
inline const TCHAR* OpenFileDlg::filename() const
{ return filename_; }
inline int OpenFileDlg::csi() const
{ return csIndex_; }
#endif // __ccdoc__
//========================================================================
//@{
// 「ファイルを保存」ダイアログ
//
// Windows共通のダイアログの下に、文字コードの選択欄と
// 改行コードの選択欄を付け加えたものを表示する。
//@}
//========================================================================
class SaveFileDlg
{
public:
explicit SaveFileDlg( const CharSetList& csl, int cs, int lb );
bool DoModal( HWND wnd, const TCHAR* filter, const TCHAR* fnm );
public:
const TCHAR* filename() const;
int csi() const;
int lb() const;
public:
static ki::aarr<TCHAR> ConnectWithNull( ki::String lst[], int num );
private:
const CharSetList& csl_;
TCHAR filename_[MAX_PATH];
int csIndex_;
int lb_;
private:
static SaveFileDlg* pThis; // マルチスレッド禁止!
static UINT_PTR CALLBACK OfnHook( HWND, UINT, WPARAM, LPARAM );
};
//------------------------------------------------------------------------
#ifndef __ccdoc__
inline SaveFileDlg::SaveFileDlg( const CharSetList& csl, int cs, int lb )
: csl_(csl), csIndex_(cs), lb_(lb) {}
inline const TCHAR* SaveFileDlg::filename() const
{ return filename_; }
inline int SaveFileDlg::csi() const
{ return csIndex_; }
inline int SaveFileDlg::lb() const
{ return lb_; }
inline ki::aarr<TCHAR> SaveFileDlg::ConnectWithNull
( ki::String lst[], int num )
{ return OpenFileDlg::ConnectWithNull( lst, num ); }
#endif // __ccdoc__
//========================================================================
//@{
// 「開き直す」ダイアログ
//
// 文字コード選択欄表示
//@}
//========================================================================
class ReopenDlg : public ki::DlgImpl
{
public:
ReopenDlg( const CharSetList& csl, int csi );
int csi() const;
private:
void on_init();
bool on_ok();
private:
const CharSetList& csl_;
int csIndex_;
};
//------------------------------------------------------------------------
#ifndef __ccdoc__
inline int ReopenDlg::csi() const
{ return csIndex_; }
//========================================================================
#endif // __ccdoc__
#endif // _GREENPAD_OPENSAVEDLG_H_