123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- // OptionsTypes.cpp : implementation file
- //
- #include "stdafx.h"
- #include "CP_Main.h"
- #include "OptionsTypes.h"
- #include "Shared/ArrayEx.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // COptionsTypes property page
- IMPLEMENT_DYNCREATE(COptionsTypes, CPropertyPage)
- COptionsTypes::COptionsTypes() : CPropertyPage(COptionsTypes::IDD)
- {
- m_csTitle = theApp.m_Language.GetString("SupportedTypesTitle", "Supported Types");
- m_psp.pszTitle = m_csTitle;
- m_psp.dwFlags |= PSP_USETITLE;
- //{{AFX_DATA_INIT(COptionsTypes)
- //}}AFX_DATA_INIT
- m_bSave = false;
- }
- COptionsTypes::~COptionsTypes()
- {
- }
- void COptionsTypes::DoDataExchange(CDataExchange* pDX)
- {
- CPropertyPage::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(COptionsTypes)
- DDX_Control(pDX, IDC_LIST1, m_List);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(COptionsTypes, CPropertyPage)
- //{{AFX_MSG_MAP(COptionsTypes)
- ON_BN_CLICKED(IDC_DELETE, OnDelete)
- ON_BN_CLICKED(IDC_ADD, OnAdd)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // COptionsTypes message handlers
- BOOL COptionsTypes::OnApply()
- {
- if(m_bSave)
- {
- try
- {
- theApp.m_db.execDML(_T("DELETE FROM Types;"));
- CString csText;
- int nCount = m_List.GetCount();
- for(int i = 0; i < nCount; i++)
- {
- m_List.GetText(i, csText);
- theApp.m_db.execDMLEx(_T("INSERT INTO Types VALUES(NULL, '%s');"), csText);
- }
- }
- CATCH_SQLITE_EXCEPTION
- // refresh our local cache
- theApp.ReloadTypes();
- }
-
- return CPropertyPage::OnApply();
- }
- BOOL COptionsTypes::OnInitDialog()
- {
- CPropertyPage::OnInitDialog();
- try
- {
- CppSQLite3Query q = theApp.m_db.execQuery(_T("SELECT TypeText FROM Types"));
- if(q.eof())
- {
- m_List.AddString(_T("CF_TEXT"));
- m_List.AddString(GetFormatName(RegisterClipboardFormat(CF_RTF)));
- m_List.AddString(_T("CF_UNICODETEXT"));
- m_List.AddString(_T("CF_HDROP"));
- if(g_Opt.m_bU3 == false)
- {
- m_List.AddString(_T("CF_DIB"));
- }
- }
- while(q.eof() == false)
- {
- m_List.AddString(q.getStringField(0));
- q.nextRow();
- }
- }
- CATCH_SQLITE_EXCEPTION
-
- m_List.SetFocus();
- theApp.m_Language.UpdateOptionSupportedTypes(this);
-
- return FALSE;
- }
- void COptionsTypes::OnDelete()
- {
- int nCount = m_List.GetSelCount();
- if(nCount)
- {
- m_bSave = true;
- CArrayEx<int> items;
- items.SetSize(nCount);
- m_List.GetSelItems(nCount, items.GetData());
- items.SortDescending();
- for(int i = 0; i < nCount; i++)
- m_List.DeleteString(items[i]);
- }
- }
- #include "AddType.h"
- void COptionsTypes::OnAdd()
- {
- CAddType add(this);
- if(add.DoModal() == IDOK)
- {
- INT_PTR nCount = add.m_csSelectedTypes.GetSize();
- if(nCount)
- {
- m_bSave = true;
- for(int i = 0; i < nCount; i++)
- {
- if(TextAllReadyThere(add.m_csSelectedTypes[i]) == FALSE)
- m_List.AddString(add.m_csSelectedTypes[i]);
- }
- }
- }
- }
- BOOL COptionsTypes::TextAllReadyThere(const CString &cs)
- {
- CString csThere;
- int nCount = m_List.GetCount();
- for(int i = 0; i < nCount; i++)
- {
- m_List.GetText(i, csThere);
- if(cs == csThere)
- return TRUE;
- }
- return FALSE;
- }
|