OptionsQuickPaste.cpp 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. // OptionsQuickPaste.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "CP_Main.h"
  5. #include "OptionsQuickPaste.h"
  6. #include ".\optionsquickpaste.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. #define DEFAULT_THEME _T("(Default)")
  13. /////////////////////////////////////////////////////////////////////////////
  14. // COptionsQuickPaste property page
  15. IMPLEMENT_DYNCREATE(COptionsQuickPaste, CPropertyPage)
  16. COptionsQuickPaste::COptionsQuickPaste() : CPropertyPage(COptionsQuickPaste::IDD)
  17. {
  18. m_csTitle = theApp.m_Language.GetString("QuickPasteTitle", "Quick Paste");
  19. m_psp.pszTitle = m_csTitle;
  20. m_psp.dwFlags |= PSP_USETITLE;
  21. //{{AFX_DATA_INIT(COptionsQuickPaste)
  22. // NOTE: the ClassWizard will add member initialization here
  23. //}}AFX_DATA_INIT
  24. memset(&m_LogFont, 0, sizeof(LOGFONT));
  25. }
  26. COptionsQuickPaste::~COptionsQuickPaste()
  27. {
  28. m_Font.DeleteObject();
  29. }
  30. void COptionsQuickPaste::DoDataExchange(CDataExchange* pDX)
  31. {
  32. CPropertyPage::DoDataExchange(pDX);
  33. //{{AFX_DATA_MAP(COptionsQuickPaste)
  34. DDX_Control(pDX, IDC_CHECK_ENTIRE_WINDOW_IS_VISIBLE, m_EnsureEntireWindowVisible);
  35. DDX_Control(pDX, IDC_CHECK_SHOW_ALL_IN_MAIN_LIST, m_ShowAllInMainList);
  36. DDX_Control(pDX, IDC_CHECK_FIND_AS_YOU_TYPE, m_FindAsYouType);
  37. DDX_Control(pDX, IDC_DRAW_RTF, m_btDrawRTF);
  38. DDX_Control(pDX, IDC_SHOW_THUMBNAILS, m_btShowThumbnails);
  39. DDX_Control(pDX, IDC_BUTTON_DEFAULT_FAULT, m_btDefaultButton);
  40. DDX_Control(pDX, IDC_BUTTON_FONT, m_btFont);
  41. DDX_Control(pDX, IDC_SHOW_TEXT_FOR_FIRST_TEN_HOT_KEYS, m_btShowText);
  42. DDX_Control(pDX, IDC_LINES_ROW, m_eLinesPerRow);
  43. DDX_Control(pDX, IDC_TRANS_PERC, m_eTransparencyPercent);
  44. DDX_Control(pDX, IDC_TRANSPARENCY, m_btEnableTransparency);
  45. DDX_Control(pDX, IDC_CTRL_CLICK, m_btUseCtrlNum);
  46. DDX_Control(pDX, IDC_DESC_SHOW_LEADING_WHITESPACE, m_btDescShowLeadingWhiteSpace);
  47. //}}AFX_DATA_MAP
  48. DDX_Control(pDX, IDC_CHECK_PROMPT_DELETE_CLIP, m_PromptForDelete);
  49. DDX_Control(pDX, IDC_COMBO_THEME, m_cbTheme);
  50. }
  51. BEGIN_MESSAGE_MAP(COptionsQuickPaste, CPropertyPage)
  52. //{{AFX_MSG_MAP(COptionsQuickPaste)
  53. ON_BN_CLICKED(IDC_BUTTON_FONT, OnButtonFont)
  54. ON_BN_CLICKED(IDC_BUTTON_DEFAULT_FAULT, OnButtonDefaultFault)
  55. //}}AFX_MSG_MAP
  56. ON_BN_CLICKED(IDC_BUTTON_THEME, OnBnClickedButtonTheme)
  57. END_MESSAGE_MAP()
  58. /////////////////////////////////////////////////////////////////////////////
  59. // COptionsQuickPaste message handlers
  60. BOOL COptionsQuickPaste::OnInitDialog()
  61. {
  62. CPropertyPage::OnInitDialog();
  63. m_pParent = (COptionsSheet *)GetParent();
  64. m_btEnableTransparency.SetCheck(CGetSetOptions::GetEnableTransparency());
  65. m_eTransparencyPercent.SetNumber(CGetSetOptions::GetTransparencyPercent());
  66. m_eLinesPerRow.SetNumber(CGetSetOptions::GetLinesPerRow());
  67. m_btShowThumbnails.SetCheck(g_Opt.m_bDrawThumbnail);
  68. m_btDrawRTF.SetCheck(g_Opt.m_bDrawRTF);
  69. m_EnsureEntireWindowVisible.SetCheck(g_Opt.m_bEnsureEntireWindowCanBeSeen);
  70. m_ShowAllInMainList.SetCheck(g_Opt.m_bShowAllClipsInMainList);
  71. m_FindAsYouType.SetCheck(g_Opt.m_bFindAsYouType);
  72. if(CGetSetOptions::GetQuickPastePosition() == POS_AT_CARET)
  73. CheckDlgButton(IDC_AT_CARET, BST_CHECKED);
  74. else if(CGetSetOptions::GetQuickPastePosition() == POS_AT_CURSOR)
  75. CheckDlgButton(IDC_AT_CURSOR, BST_CHECKED);
  76. else if(CGetSetOptions::GetQuickPastePosition() == POS_AT_PREVIOUS)
  77. CheckDlgButton(IDC_AT_PREVIOUS, BST_CHECKED);
  78. m_btDescShowLeadingWhiteSpace.SetCheck(g_Opt.m_bDescShowLeadingWhiteSpace);
  79. m_btUseCtrlNum.SetCheck(CGetSetOptions::GetUseCtrlNumForFirstTenHotKeys());
  80. m_btShowText.SetCheck(CGetSetOptions::GetShowTextForFirstTenHotKeys());
  81. m_PromptForDelete.SetCheck(CGetSetOptions::GetPromptWhenDeletingClips());
  82. if(CGetSetOptions::GetFont(m_LogFont))
  83. {
  84. m_Font.CreateFontIndirect(&m_LogFont);
  85. m_btFont.SetFont(&m_Font);
  86. }
  87. else
  88. {
  89. CFont *ft = m_btFont.GetFont();
  90. ft->GetLogFont(&m_LogFont);
  91. }
  92. CString cs;
  93. cs.Format(_T("Font - %s"), m_LogFont.lfFaceName);
  94. m_btFont.SetWindowText(cs);
  95. FillThemes();
  96. theApp.m_Language.UpdateOptionQuickPaste(this);
  97. return FALSE;
  98. }
  99. BOOL COptionsQuickPaste::OnApply()
  100. {
  101. CGetSetOptions::SetEnableTransparency(m_btEnableTransparency.GetCheck());
  102. CGetSetOptions::SetTransparencyPercent(m_eTransparencyPercent.GetNumber());
  103. CGetSetOptions::SetLinesPerRow(m_eLinesPerRow.GetNumber());
  104. if(IsDlgButtonChecked(IDC_AT_CARET))
  105. CGetSetOptions::SetQuickPastePosition(POS_AT_CARET);
  106. else if(IsDlgButtonChecked(IDC_AT_CURSOR))
  107. CGetSetOptions::SetQuickPastePosition(POS_AT_CURSOR);
  108. else if(IsDlgButtonChecked(IDC_AT_PREVIOUS))
  109. CGetSetOptions::SetQuickPastePosition(POS_AT_PREVIOUS);
  110. g_Opt.SetDescShowLeadingWhiteSpace( m_btDescShowLeadingWhiteSpace.GetCheck() );
  111. CGetSetOptions::SetUseCtrlNumForFirstTenHotKeys(m_btUseCtrlNum.GetCheck());
  112. CGetSetOptions::SetShowTextForFirstTenHotKeys(m_btShowText.GetCheck());
  113. CGetSetOptions::SetDrawThumbnail(m_btShowThumbnails.GetCheck());
  114. CGetSetOptions::SetDrawRTF(m_btDrawRTF.GetCheck());
  115. CGetSetOptions::SetEnsureEntireWindowCanBeSeen(m_EnsureEntireWindowVisible.GetCheck());
  116. CGetSetOptions::SetShowAllClipsInMainList(m_ShowAllInMainList.GetCheck());
  117. CGetSetOptions::SetFindAsYouType(m_FindAsYouType.GetCheck());
  118. CGetSetOptions::SetPromptWhenDeletingClips(m_PromptForDelete.GetCheck());
  119. if(m_LogFont.lfWeight != 0)
  120. {
  121. CGetSetOptions::SetFont(m_LogFont);
  122. }
  123. CString csTheme;
  124. if(m_cbTheme.GetCurSel() >= 0)
  125. {
  126. m_cbTheme.GetLBText(m_cbTheme.GetCurSel(), csTheme);
  127. if(csTheme == DEFAULT_THEME)
  128. g_Opt.SetTheme("");
  129. else
  130. g_Opt.SetTheme(csTheme);
  131. }
  132. else
  133. {
  134. g_Opt.SetTheme("");
  135. }
  136. return CPropertyPage::OnApply();
  137. }
  138. void COptionsQuickPaste::OnButtonFont()
  139. {
  140. CFontDialog dlg(&m_LogFont);
  141. if(dlg.DoModal() == IDOK)
  142. {
  143. m_Font.DeleteObject();
  144. memcpy(&m_LogFont, dlg.m_cf.lpLogFont, sizeof(LOGFONT));
  145. m_Font.CreateFontIndirect(&m_LogFont);
  146. m_btFont.SetFont(&m_Font);
  147. CString cs;
  148. cs.Format(_T("Font - %s"), m_LogFont.lfFaceName);
  149. m_btFont.SetWindowText(cs);
  150. }
  151. }
  152. void COptionsQuickPaste::OnButtonDefaultFault()
  153. {
  154. CFont *ft = m_btDefaultButton.GetFont();
  155. ft->GetLogFont(&m_LogFont);
  156. memset(&m_LogFont, 0, sizeof(m_LogFont));
  157. m_LogFont.lfHeight = -11;
  158. m_LogFont.lfWeight = 400;
  159. m_LogFont.lfCharSet = 1;
  160. STRCPY(m_LogFont.lfFaceName, _T("Arial Unicode MS"));
  161. m_Font.DeleteObject();
  162. m_Font.CreateFontIndirect(&m_LogFont);
  163. m_btFont.SetFont(&m_Font);
  164. CString cs;
  165. cs.Format(_T("Font - %s"), m_LogFont.lfFaceName);
  166. m_btFont.SetWindowText(cs);
  167. }
  168. void COptionsQuickPaste::FillThemes()
  169. {
  170. CString csFile = CGetSetOptions::GetPath(PATH_THEMES);
  171. csFile += "*.xml";
  172. CString csTheme = CGetSetOptions::GetTheme();
  173. CFileFind find;
  174. BOOL bCont = find.FindFile(csFile);
  175. bool bSetCurSel = false;
  176. while(bCont)
  177. {
  178. bCont = find.FindNextFile();
  179. int nIndex = m_cbTheme.AddString(find.GetFileTitle());
  180. if(find.GetFileTitle() == csTheme)
  181. {
  182. m_cbTheme.SetCurSel(nIndex);
  183. bSetCurSel = true;
  184. }
  185. }
  186. int nIndex = m_cbTheme.AddString(DEFAULT_THEME);
  187. if(bSetCurSel == false)
  188. {
  189. m_cbTheme.SetCurSel(nIndex);
  190. }
  191. }
  192. void COptionsQuickPaste::OnBnClickedButtonTheme()
  193. {
  194. CTheme theme;
  195. CString csTheme;
  196. m_cbTheme.GetLBText(m_cbTheme.GetCurSel(), csTheme);
  197. if(csTheme == DEFAULT_THEME)
  198. return;
  199. if(theme.Load(csTheme, true, false))
  200. {
  201. CString csMessage;
  202. csMessage.Format(_T("Theme - %s\n")
  203. _T("Version - %d\n")
  204. _T("Author - %s\n")
  205. _T("Notes - %s"), csTheme,
  206. theme.FileVersion(),
  207. theme.Author(),
  208. theme.Notes());
  209. MessageBox(csMessage, _T("Ditto"), MB_OK);
  210. }
  211. else
  212. {
  213. CString csError;
  214. csError.Format(_T("Error loading theme file - %s - reason = "), csTheme, theme.LastError());
  215. MessageBox(csError, _T("Ditto"), MB_OK);
  216. }
  217. }