SaveTextFileDialog.cpp

00001 /* 
00002  *      Copyright (C) 2003-2005 Gabest
00003  *      http://www.gabest.org
00004  *
00005  *  This Program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2, or (at your option)
00008  *  any later version.
00009  *   
00010  *  This Program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013  *  GNU General Public License for more details.
00014  *   
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with GNU Make; see the file COPYING.  If not, write to
00017  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
00018  *  http://www.gnu.org/copyleft/gpl.html
00019  *
00020  */
00021 
00022 // SaveTextFileDialog.cpp : implementation file
00023 //
00024 
00025 #include "stdafx.h"
00026 #include "mplayerc.h"
00027 #include "SaveTextFileDialog.h"
00028 
00029 
00030 // CSaveTextFileDialog
00031 
00032 IMPLEMENT_DYNAMIC(CSaveTextFileDialog, CFileDialog)
00033 CSaveTextFileDialog::CSaveTextFileDialog(
00034         CTextFile::enc e,
00035         LPCTSTR lpszDefExt, LPCTSTR lpszFileName,
00036         LPCTSTR lpszFilter, CWnd* pParentWnd) :
00037                 CFileDialog(FALSE, lpszDefExt, lpszFileName, 
00038                         OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_PATHMUSTEXIST, 
00039                         lpszFilter, pParentWnd, 0),
00040                 m_e(e)
00041 {
00042         if(m_ofn.lStructSize == sizeof(OPENFILENAME))
00043         {
00044                 SetTemplate(0, IDD_SAVETEXTFILEDIALOGTEMPL);
00045         }
00046         else /*if(m_ofn.lStructSize == OPENFILENAME_SIZE_VERSION_400)*/
00047         {
00048                 SetTemplate(0, IDD_SAVETEXTFILEDIALOGTEMPL_400);
00049         }
00050 }
00051 
00052 CSaveTextFileDialog::~CSaveTextFileDialog()
00053 {
00054 }
00055 
00056 void CSaveTextFileDialog::DoDataExchange(CDataExchange* pDX)
00057 {
00058         DDX_Control(pDX, IDC_COMBO1, m_encoding);
00059         CFileDialog::DoDataExchange(pDX);
00060 }
00061 
00062 BOOL CSaveTextFileDialog::OnInitDialog()
00063 {
00064         CFileDialog::OnInitDialog();
00065 
00066         m_encoding.AddString(_T("ANSI"));
00067         m_encoding.AddString(_T("Unicode 16-LE"));
00068         m_encoding.AddString(_T("Unicode 16-BE"));
00069         m_encoding.AddString(_T("UTF-8"));
00070 
00071         switch(m_e)
00072         {
00073         default:
00074         case CTextFile::ASCII: m_encoding.SetCurSel(0); break;
00075         case CTextFile::LE16: m_encoding.SetCurSel(1); break;
00076         case CTextFile::BE16: m_encoding.SetCurSel(2); break;
00077         case CTextFile::UTF8: m_encoding.SetCurSel(3); break;
00078         }
00079 
00080         return TRUE;  // return TRUE unless you set the focus to a control
00081         // EXCEPTION: OCX Property Pages should return FALSE
00082 }
00083 
00084 BEGIN_MESSAGE_MAP(CSaveTextFileDialog, CFileDialog)
00085 END_MESSAGE_MAP()
00086 
00087 // CSaveTextFileDialog message handlers
00088 
00089 BOOL CSaveTextFileDialog::OnFileNameOK()
00090 {
00091         switch(m_encoding.GetCurSel())
00092         {
00093         case 0: m_e = CTextFile::ASCII; break;
00094         case 1: m_e = CTextFile::LE16; break;
00095         case 2: m_e = CTextFile::BE16; break;
00096         case 3: m_e = CTextFile::UTF8; break;
00097         default: break;
00098         }
00099 
00100         return CFileDialog::OnFileNameOK();
00101 }

Generated on Tue Dec 13 14:47:03 2005 for guliverkli by  doxygen 1.4.5