OptionsQuickPaste.cpp 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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_HISTORY_START_TOP, m_btHistoryStartTop);
  47. DDX_Control(pDX, IDC_DESC_SHOW_LEADING_WHITESPACE, m_btDescShowLeadingWhiteSpace);
  48. //}}AFX_DATA_MAP
  49. DDX_Control(pDX, IDC_CHECK_PROMPT_DELETE_CLIP, m_PromptForDelete);
  50. DDX_Control(pDX, IDC_COMBO_THEME, m_cbTheme);
  51. }
  52. BEGIN_MESSAGE_MAP(COptionsQuickPaste, CPropertyPage)
  53. //{{AFX_MSG_MAP(COptionsQuickPaste)
  54. ON_BN_CLICKED(IDC_BUTTON_FONT, OnButtonFont)
  55. ON_BN_CLICKED(IDC_BUTTON_DEFAULT_FAULT, OnButtonDefaultFault)
  56. //}}AFX_MSG_MAP
  57. ON_BN_CLICKED(IDC_BUTTON_THEME, OnBnClickedButtonTheme)
  58. END_MESSAGE_MAP()
  59. /////////////////////////////////////////////////////////////////////////////
  60. // COptionsQuickPaste message handlers
  61. BOOL COptionsQuickPaste::OnInitDialog()
  62. {
  63. CPropertyPage::OnInitDialog();
  64. m_pParent = (COptionsSheet *)GetParent();
  65. m_btEnableTransparency.SetCheck(CGetSetOptions::GetEnableTransparency());
  66. m_eTransparencyPercent.SetNumber(CGetSetOptions::GetTransparencyPercent());
  67. m_eLinesPerRow.SetNumber(CGetSetOptions::GetLinesPerRow());
  68. m_btShowThumbnails.SetCheck(g_Opt.m_bDrawThumbnail);
  69. m_btDrawRTF.SetCheck(g_Opt.m_bDrawRTF);
  70. m_EnsureEntireWindowVisible.SetCheck(g_Opt.m_bEnsureEntireWindowCanBeSeen);
  71. m_ShowAllInMainList.SetCheck(g_Opt.m_bShowAllClipsInMainList);
  72. m_FindAsYouType.SetCheck(g_Opt.m_bFindAsYouType);
  73. if(CGetSetOptions::GetQuickPastePosition() == POS_AT_CARET)
  74. CheckDlgButton(IDC_AT_CARET, BST_CHECKED);
  75. else if(CGetSetOptions::GetQuickPastePosition() == POS_AT_CURSOR)
  76. CheckDlgButton(IDC_AT_CURSOR, BST_CHECKED);
  77. else if(CGetSetOptions::GetQuickPastePosition() == POS_AT_PREVIOUS)
  78. CheckDlgButton(IDC_AT_PREVIOUS, BST_CHECKED);
  79. m_btDescShowLeadingWhiteSpace.SetCheck(g_Opt.m_bDescShowLeadingWhiteSpace);
  80. m_btHistoryStartTop.SetCheck(g_Opt.m_bHistoryStartTop);
  81. m_btUseCtrlNum.SetCheck(CGetSetOptions::GetUseCtrlNumForFirstTenHotKeys());
  82. m_btShowText.SetCheck(CGetSetOptions::GetShowTextForFirstTenHotKeys());
  83. m_PromptForDelete.SetCheck(CGetSetOptions::GetPromptWhenDeletingClips());
  84. if(CGetSetOptions::GetFont(m_LogFont))
  85. {
  86. m_Font.CreateFontIndirect(&m_LogFont);
  87. m_btFont.SetFont(&m_Font);
  88. }
  89. else
  90. {
  91. CFont *ft = m_btFont.GetFont();
  92. ft->GetLogFont(&m_LogFont);
  93. }
  94. CString cs;
  95. cs.Format(_T("Font - %s"), m_LogFont.lfFaceName);
  96. m_btFont.SetWindowText(cs);
  97. FillThemes();
  98. theApp.m_Language.UpdateOptionQuickPaste(this);
  99. return FALSE;
  100. }
  101. BOOL COptionsQuickPaste::OnApply()
  102. {
  103. CGetSetOptions::SetEnableTransparency(m_btEnableTransparency.GetCheck());
  104. CGetSetOptions::SetTransparencyPercent(m_eTransparencyPercent.GetNumber());
  105. CGetSetOptions::SetLinesPerRow(m_eLinesPerRow.GetNumber());
  106. if(IsDlgButtonChecked(IDC_AT_CARET))
  107. CGetSetOptions::SetQuickPastePosition(POS_AT_CARET);
  108. else if(IsDlgButtonChecked(IDC_AT_CURSOR))
  109. CGetSetOptions::SetQuickPastePosition(POS_AT_CURSOR);
  110. else if(IsDlgButtonChecked(IDC_AT_PREVIOUS))
  111. CGetSetOptions::SetQuickPastePosition(POS_AT_PREVIOUS);
  112. g_Opt.SetDescShowLeadingWhiteSpace( m_btDescShowLeadingWhiteSpace.GetCheck() );
  113. g_Opt.SetHistoryStartTop( m_btHistoryStartTop.GetCheck() );
  114. CGetSetOptions::SetUseCtrlNumForFirstTenHotKeys(m_btUseCtrlNum.GetCheck());
  115. CGetSetOptions::SetShowTextForFirstTenHotKeys(m_btShowText.GetCheck());
  116. CGetSetOptions::SetDrawThumbnail(m_btShowThumbnails.GetCheck());
  117. CGetSetOptions::SetDrawRTF(m_btDrawRTF.GetCheck());
  118. CGetSetOptions::SetEnsureEntireWindowCanBeSeen(m_EnsureEntireWindowVisible.GetCheck());
  119. CGetSetOptions::SetShowAllClipsInMainList(m_ShowAllInMainList.GetCheck());
  120. CGetSetOptions::SetFindAsYouType(m_FindAsYouType.GetCheck());
  121. CGetSetOptions::SetPromptWhenDeletingClips(m_PromptForDelete.GetCheck());
  122. if(m_LogFont.lfWeight != 0)
  123. {
  124. CGetSetOptions::SetFont(m_LogFont);
  125. }
  126. CString csTheme;
  127. if(m_cbTheme.GetCurSel() >= 0)
  128. {
  129. m_cbTheme.GetLBText(m_cbTheme.GetCurSel(), csTheme);
  130. if(csTheme == DEFAULT_THEME)
  131. g_Opt.SetTheme("");
  132. else
  133. g_Opt.SetTheme(csTheme);
  134. }
  135. else
  136. {
  137. g_Opt.SetTheme("");
  138. }
  139. return CPropertyPage::OnApply();
  140. }
  141. void COptionsQuickPaste::OnButtonFont()
  142. {
  143. CFontDialog dlg(&m_LogFont);
  144. if(dlg.DoModal() == IDOK)
  145. {
  146. m_Font.DeleteObject();
  147. memcpy(&m_LogFont, dlg.m_cf.lpLogFont, sizeof(LOGFONT));
  148. m_Font.CreateFontIndirect(&m_LogFont);
  149. m_btFont.SetFont(&m_Font);
  150. CString cs;
  151. cs.Format(_T("Font - %s"), m_LogFont.lfFaceName);
  152. m_btFont.SetWindowText(cs);
  153. }
  154. }
  155. void COptionsQuickPaste::OnButtonDefaultFault()
  156. {
  157. CFont *ft = m_btDefaultButton.GetFont();
  158. ft->GetLogFont(&m_LogFont);
  159. memset(&m_LogFont, 0, sizeof(m_LogFont));
  160. m_LogFont.lfHeight = -11;
  161. m_LogFont.lfWeight = 400;
  162. m_LogFont.lfCharSet = 1;
  163. STRCPY(m_LogFont.lfFaceName, _T("@Arial Unicode MS"));
  164. m_Font.DeleteObject();
  165. m_Font.CreateFontIndirect(&m_LogFont);
  166. m_btFont.SetFont(&m_Font);
  167. CString cs;
  168. cs.Format(_T("Font - %s"), m_LogFont.lfFaceName);
  169. m_btFont.SetWindowText(cs);
  170. }
  171. void COptionsQuickPaste::FillThemes()
  172. {
  173. CString csFile = CGetSetOptions::GetPath(PATH_THEMES);
  174. csFile += "*.xml";
  175. CString csTheme = CGetSetOptions::GetTheme();
  176. CFileFind find;
  177. BOOL bCont = find.FindFile(csFile);
  178. bool bSetCurSel = false;
  179. while(bCont)
  180. {
  181. bCont = find.FindNextFile();
  182. int nIndex = m_cbTheme.AddString(find.GetFileTitle());
  183. if(find.GetFileTitle() == csTheme)
  184. {
  185. m_cbTheme.SetCurSel(nIndex);
  186. bSetCurSel = true;
  187. }
  188. }
  189. int nIndex = m_cbTheme.AddString(DEFAULT_THEME);
  190. if(bSetCurSel == false)
  191. {
  192. m_cbTheme.SetCurSel(nIndex);
  193. }
  194. }
  195. void COptionsQuickPaste::OnBnClickedButtonTheme()
  196. {
  197. CTheme theme;
  198. CString csTheme;
  199. m_cbTheme.GetLBText(m_cbTheme.GetCurSel(), csTheme);
  200. if(csTheme == DEFAULT_THEME)
  201. return;
  202. if(theme.Load(csTheme, true, false))
  203. {
  204. CString csMessage;
  205. csMessage.Format(_T("Theme - %s\n")
  206. _T("Version - %d\n")
  207. _T("Author - %s\n")
  208. _T("Notes - %s"), csTheme,
  209. theme.FileVersion(),
  210. theme.Author(),
  211. theme.Notes());
  212. MessageBox(csMessage, _T("Ditto"), MB_OK);
  213. }
  214. else
  215. {
  216. CString csError;
  217. csError.Format(_T("Error loading theme file - %s - reason = "), csTheme, theme.LastError());
  218. MessageBox(csError, _T("Ditto"), MB_OK);
  219. }
  220. }