PageDateTimeDuration.cpp
上传用户:sesekoo
上传日期:2020-07-18
资源大小:21543k
文件大小:40k
源码类别:

界面编程

开发平台:

Visual C++

  1. // PageDateTimeDuration.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "profuis_controls.h"
  5. #include "PageDateTimeDuration.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. #if (!defined __EXT_MFC_NO_DURATIONWND && !defined __EXT_MFC_NO_DATETIMEWND )
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CPageDateTimeDuration dialog
  14. CPageDateTimeDuration::CPageDateTimeDuration(CWnd* pParent /*=NULL*/)
  15. : CPageBase(CPageDateTimeDuration::IDD, pParent)
  16. , m_bInitComplete( false )
  17. {
  18. //{{AFX_DATA_INIT(CPageDateTimeDuration)
  19. m_nTimeFormat = -1;
  20. m_nMode = -1;
  21. //}}AFX_DATA_INIT
  22. }
  23. void CPageDateTimeDuration::DoDataExchange(CDataExchange* pDX)
  24. {
  25. CPageBase::DoDataExchange(pDX);
  26. //{{AFX_DATA_MAP(CPageDateTimeDuration)
  27. DDX_Control(pDX, IDC_CHECK_READONLY_DURATION, m_wndReadOnlyDuration);
  28. DDX_Control(pDX, IDC_CHECK_READONLY_DATETIME, m_wndReadOnlyDateTime);
  29. DDX_Control(pDX, IDC_CHECK_DISABLED_DURATION, m_wndDisabledDuration);
  30. DDX_Control(pDX, IDC_CHECK_DISABLED_DATETIME, m_wndDisabledDateTime);
  31. DDX_Control(pDX, IDC_CHECK_MODE_SECONDS, m_wndModeSeconds);
  32. DDX_Control(pDX, IDC_CHECK_MODE_MINUTES, m_wndModeMinutes);
  33. DDX_Control(pDX, IDC_CHECK_MODE_HOURS, m_wndModeHours);
  34. DDX_Control(pDX, IDC_CHECK_MODE_DAYS, m_wndModeDays);
  35. DDX_Control(pDX, IDC_STATIC_NOTIFICATIONS, m_wndLabelNotifications);
  36. DDX_Control(pDX, IDC_CHECK_CONTINUOUS_DATETIME, m_wndContinuousDateTime);
  37. DDX_Control(pDX, IDC_CHECK_CONTINUOUS_DURATION, m_wndContinuousDuration);
  38. DDX_Control(pDX, IDC_STATIC_TIME_FORMAT, m_wndBoxTimeFormat);
  39. DDX_Control(pDX, IDC_STATIC_MODE_DATETIME, m_wndBoxModeDateTime);
  40. DDX_Control(pDX, IDC_STATIC_MODE_DURATION, m_wndBoxModeDuration);
  41. DDX_Control(pDX, IDC_CHECK_BTN_SPIN_DATETIME, m_wndBtnSpinDateTime);
  42. DDX_Control(pDX, IDC_CHECK_BTN_SPIN_DURATION, m_wndBtnSpinDuration);
  43. DDX_Control(pDX, IDC_CHECK_BTN_DROP_DOWN, m_wndBtnDropDown);
  44. DDX_Control(pDX, IDC_CHECK_BTN_SHOW_SELECTION_ALWAYS_DATETIME, m_wndBtnShowSelectionAlwaysDateTime);
  45. DDX_Control(pDX, IDC_CHECK_BTN_SHOW_SELECTION_ALWAYS_DURATION, m_wndBtnShowSelectionAlwaysDuration);
  46. DDX_Control(pDX, IDC_TEXT_COLOR_DATETIME, m_wndColorTextDateTime);
  47. DDX_Control(pDX, IDC_BACK_COLOR_DATETIME, m_wndColorBackDateTime);
  48. DDX_Control(pDX, IDC_ADJUST_SIZE_DATETIME, m_wndAdjustSizeDateTime);
  49. DDX_Control(pDX, IDC_TEXT_COLOR_DURATION, m_wndColorTextDuration);
  50. DDX_Control(pDX, IDC_BACK_COLOR_DURATION, m_wndColorBackDuration);
  51. DDX_Control(pDX, IDC_ADJUST_SIZE_DURATION, m_wndAdjustSizeDuration);
  52. DDX_Control(pDX, IDC_STATIC_DURATION, m_wndBoxDuration);
  53. DDX_Control(pDX, IDC_STATIC_DATE_TIME, m_wndBoxDateTime);
  54. DDX_Control(pDX, IDC_DURATION, m_wndDuration);
  55. DDX_Control(pDX, IDC_DATETIME, m_wndDateTime);
  56. DDX_Radio(pDX, IDC_TIME_FORMAT_AUTO, m_nTimeFormat);
  57. DDX_Radio(pDX, IDC_MODE_TIME, m_nMode);
  58. DDX_Control(pDX, IDC_TIME_FORMAT_AUTO, m_wndTimeFormatAuto);
  59. DDX_Control(pDX, IDC_TIME_FORMAT_H12, m_wndTimeFormatH12);
  60. DDX_Control(pDX, IDC_TIME_FORMAT_H24, m_wndTimeFormatH24);
  61. DDX_Control(pDX, IDC_MODE_TIME, m_wndModeTime);
  62. DDX_Control(pDX, IDC_MODE_DATE, m_wndModeDate);
  63. DDX_Control(pDX, IDC_MODE_DATE_TIME, m_wndModeDateTime);
  64. //}}AFX_DATA_MAP
  65. DDX_Control(pDX, IDC_NOTIFICATIONS, m_wndNotifications);
  66. }
  67. BEGIN_MESSAGE_MAP(CPageDateTimeDuration, CPageBase)
  68. //{{AFX_MSG_MAP(CPageDateTimeDuration)
  69. //}}AFX_MSG_MAP
  70. ON_REGISTERED_MESSAGE(
  71. CExtDurationWnd::g_nMsgChangingNotification,
  72. OnSelChangedDuration
  73. )
  74. ON_REGISTERED_MESSAGE(
  75. CExtDateTimeWnd::g_nMsgChangingNotification,
  76. OnSelChangedDateTime
  77. )
  78. ON_REGISTERED_MESSAGE(
  79. CExtPopupColorMenuWnd::g_nMsgNotifyColorChangedFinally,
  80. OnColorChanged
  81. )
  82. END_MESSAGE_MAP()
  83. /////////////////////////////////////////////////////////////////////////////
  84. // CPageDateTimeDuration message handlers
  85. BOOL CPageDateTimeDuration::OnInitDialog() 
  86. {
  87. CPageBase::OnInitDialog();
  88. AddAnchor( IDC_NOTIFICATIONS, __RDA_LT, __RDA_RB );
  89. m_wndBoxDuration.SetStyle( CExtGroupBox::STYLE_CAPTION );
  90. m_wndBoxDateTime.SetStyle( CExtGroupBox::STYLE_CAPTION );
  91. m_wndBoxDuration.SetTextAlign( CExtGroupBox::ALIGN_CENTER );
  92. m_wndBoxDateTime.SetTextAlign( CExtGroupBox::ALIGN_CENTER );
  93. m_wndBoxTimeFormat.SetStyle( CExtGroupBox::STYLE_FLAT );
  94. m_wndBoxModeDateTime.SetStyle( CExtGroupBox::STYLE_FLAT );
  95. m_wndBoxModeDuration.SetStyle( CExtGroupBox::STYLE_FLAT );
  96. m_wndColorTextDateTime.m_lParamCookie = LPARAM(IDC_TEXT_COLOR_DATETIME);
  97. m_wndColorBackDateTime.m_lParamCookie = LPARAM(IDC_BACK_COLOR_DATETIME);
  98. m_wndColorTextDateTime.m_clrDefault = 
  99. m_wndColorTextDateTime.m_clrSelected = m_wndDateTime.GetTextColor();
  100. m_wndColorBackDateTime.m_clrDefault = 
  101. m_wndColorBackDateTime.m_clrSelected = m_wndDateTime.GetBkColor();
  102. m_wndColorTextDuration.m_lParamCookie = LPARAM(IDC_TEXT_COLOR_DURATION);
  103. m_wndColorBackDuration.m_lParamCookie = LPARAM(IDC_BACK_COLOR_DURATION);
  104. m_wndColorTextDuration.m_clrDefault = 
  105. m_wndColorTextDuration.m_clrSelected = m_wndDuration.GetTextColor();
  106. m_wndColorBackDuration.m_clrDefault = 
  107. m_wndColorBackDuration.m_clrSelected = m_wndDuration.GetBkColor();
  108. m_wndDuration.m_lParamCookie = LPARAM(IDC_DURATION);
  109. m_wndDateTime.m_lParamCookie = LPARAM(IDC_DATETIME);
  110. m_wndDateTime.SetDateTime( COleDateTime::GetCurrentTime() );
  111. ::CheckDlgButton( 
  112. this->GetSafeHwnd(), 
  113. IDC_CHECK_DISABLED_DATETIME, 
  114. !m_wndDateTime.IsWindowEnabled()
  115. ? BST_CHECKED
  116. : BST_UNCHECKED
  117. );
  118. ::CheckDlgButton( 
  119. this->GetSafeHwnd(), 
  120. IDC_CHECK_DISABLED_DURATION, 
  121. !m_wndDuration.IsWindowEnabled()
  122. ? BST_CHECKED
  123. : BST_UNCHECKED
  124. );
  125. ::CheckDlgButton( 
  126. this->GetSafeHwnd(), 
  127. IDC_CHECK_READONLY_DATETIME, 
  128. m_wndDuration.IsReadOnly()
  129. ? BST_CHECKED
  130. : BST_UNCHECKED
  131. );
  132. ::CheckDlgButton( 
  133. this->GetSafeHwnd(), 
  134. IDC_CHECK_READONLY_DURATION, 
  135. m_wndDuration.IsReadOnly()
  136. ? BST_CHECKED
  137. : BST_UNCHECKED
  138. );
  139. ::CheckDlgButton( 
  140. this->GetSafeHwnd(), 
  141. IDC_CHECK_CONTINUOUS_DATETIME, 
  142. m_wndDateTime.GetContinuousScrolling()
  143. );
  144. ::CheckDlgButton( 
  145. this->GetSafeHwnd(), 
  146. IDC_CHECK_CONTINUOUS_DURATION, 
  147. m_wndDuration.GetContinuousScrolling()
  148. );
  149. ::CheckDlgButton( 
  150. this->GetSafeHwnd(), 
  151. IDC_CHECK_BTN_DROP_DOWN, 
  152. m_wndDateTime.IsDropDownButtonVisible()
  153. );
  154. ::CheckDlgButton( 
  155. this->GetSafeHwnd(), 
  156. IDC_CHECK_BTN_SPIN_DATETIME, 
  157. m_wndDateTime.IsSpinButtonVisible()
  158. );
  159. ::CheckDlgButton( 
  160. this->GetSafeHwnd(), 
  161. IDC_CHECK_BTN_SPIN_DURATION, 
  162. m_wndDuration.IsSpinButtonVisible()
  163. );
  164. ::CheckDlgButton( 
  165. this->GetSafeHwnd(), 
  166. IDC_CHECK_BTN_SHOW_SELECTION_ALWAYS_DURATION, 
  167. m_wndDateTime.NoHideSelectionGet()
  168. );
  169. ::CheckDlgButton( 
  170. this->GetSafeHwnd(), 
  171. IDC_CHECK_BTN_SHOW_SELECTION_ALWAYS_DATETIME, 
  172. m_wndDuration.NoHideSelectionGet()
  173. );
  174. ::CheckDlgButton( 
  175. this->GetSafeHwnd(), 
  176. IDC_CHECK_MODE_DAYS, 
  177. m_wndDuration.IsItemVisible( CExtDurationWnd::day )
  178. );
  179. ::CheckDlgButton( 
  180. this->GetSafeHwnd(), 
  181. IDC_CHECK_MODE_HOURS, 
  182. m_wndDuration.IsItemVisible( CExtDurationWnd::hour )
  183. );
  184. ::CheckDlgButton( 
  185. this->GetSafeHwnd(), 
  186. IDC_CHECK_MODE_MINUTES, 
  187. m_wndDuration.IsItemVisible( CExtDurationWnd::minute )
  188. );
  189. ::CheckDlgButton( 
  190. this->GetSafeHwnd(), 
  191. IDC_CHECK_MODE_SECONDS, 
  192. m_wndDuration.IsItemVisible( CExtDurationWnd::second )
  193. );
  194. CExtDateTimeWnd::eMode_t eMode = m_wndDateTime.GetMode();
  195. switch( eMode ) 
  196. {
  197. case CExtDateTimeWnd::time:
  198. m_nMode = 0;
  199. break;
  200. case CExtDateTimeWnd::date:
  201. m_nMode = 1;
  202. break;
  203. case CExtDateTimeWnd::all:
  204. m_nMode = 2;
  205. break;
  206. }
  207. CExtDateTimeWnd::eTimeFormat_t eTimeFormat = m_wndDateTime.GetTimeFormat();
  208. switch( eTimeFormat ) 
  209. {
  210. case CExtDateTimeWnd::automatic:
  211. m_nTimeFormat = 0;
  212. break;
  213. case CExtDateTimeWnd::h24:
  214. m_nTimeFormat = 1;
  215. break;
  216. case CExtDateTimeWnd::h12:
  217. m_nTimeFormat = 2;
  218. break;
  219. }
  220. UpdateData( 0 );
  221. m_bInitComplete = true;
  222. return TRUE;  // return TRUE unless you set the focus to a control
  223.               // EXCEPTION: OCX Property Pages should return FALSE
  224. }
  225. LRESULT CPageDateTimeDuration::OnSelChangedDuration( WPARAM wParam, LPARAM lParam )
  226. {
  227. ASSERT_VALID( this );
  228. lParam;
  229. const CExtDurationWnd::CHANGING_NOTIFICATION * pCN =
  230. CExtDurationWnd::CHANGING_NOTIFICATION::FromWPARAM( wParam );
  231. ASSERT( pCN != NULL );
  232. if( pCN->m_lParamCookie == LPARAM(IDC_DURATION) )
  233. {
  234. CString strMsg, strMsgAll;
  235. strMsg.Format(
  236. _T("Duration: %s (old - %d sec, new - %d sec)"),
  237. pCN->m_bChangedFinally ? _T("changed") : _T("changing"),
  238. (LONG) pCN->m_dtSpanOld.GetTotalSeconds(),
  239. (LONG) pCN->m_dtSpanNew.GetTotalSeconds()
  240. );
  241. strMsg += _T("rn");
  242. m_wndNotifications.GetWindowText( strMsgAll );
  243. m_wndNotifications.SetWindowText( strMsgAll + strMsg );
  244. int nCharCount = strMsgAll.GetLength() + strMsg.GetLength();
  245. m_wndNotifications.SetSel(nCharCount-1,nCharCount-1);
  246. }
  247. return 0L;
  248. }
  249. LRESULT CPageDateTimeDuration::OnSelChangedDateTime( WPARAM wParam, LPARAM lParam )
  250. {
  251. ASSERT_VALID( this );
  252. lParam;
  253. const CExtDateTimeWnd::CHANGING_NOTIFICATION * pCN =
  254. CExtDateTimeWnd::CHANGING_NOTIFICATION::FromWPARAM( wParam );
  255. ASSERT( pCN != NULL );
  256. if( pCN->m_lParamCookie == LPARAM(IDC_DATETIME) )
  257. {
  258. CString strMsg, strMsgAll;
  259. strMsg.Format(
  260. _T("DateTime: %s (old - %s, new - %s)"),
  261. pCN->m_bChangedFinally ? _T("changed") : _T("changing"),
  262. pCN->m_dtDateTimeOld.Format(),
  263. pCN->m_dtDateTimeNew.Format()
  264. );
  265. strMsg += _T("rn");
  266. m_wndNotifications.GetWindowText( strMsgAll );
  267. m_wndNotifications.SetWindowText( strMsgAll + strMsg );
  268. int nCharCount = strMsgAll.GetLength() + strMsg.GetLength();
  269. m_wndNotifications.SetSel(nCharCount-1,nCharCount-1);
  270. }
  271. return 0L;
  272. }
  273. LRESULT CPageDateTimeDuration::OnColorChanged(WPARAM wParam, LPARAM lParam)
  274. {
  275. COLORREF clrColor = COLORREF(wParam);
  276. switch( lParam )
  277. {
  278. case IDC_TEXT_COLOR_DATETIME:
  279. m_wndDateTime.SetTextColor( clrColor );
  280. break;
  281. case IDC_BACK_COLOR_DATETIME:
  282. m_wndDateTime.SetBkColor( clrColor );
  283. break;
  284. case IDC_TEXT_COLOR_DURATION:
  285. m_wndDuration.SetTextColor( clrColor );
  286. break;
  287. case IDC_BACK_COLOR_DURATION:
  288. m_wndDuration.SetBkColor( clrColor );
  289. break;
  290. default:
  291. break;
  292. } // switch( lParam )
  293. return 0;
  294. }
  295. BOOL CPageDateTimeDuration::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) 
  296. {
  297. if( !m_bInitComplete )
  298. return CPageBase::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
  299. if( nCode == CN_COMMAND )
  300. {
  301. bool bChecked = IsDlgButtonChecked( nID ) ? true : false;
  302. switch( nID )
  303. {
  304. case IDC_CHECK_DISABLED_DATETIME:
  305. m_wndDateTime.EnableWindow( !bChecked );
  306. break;
  307. case IDC_CHECK_DISABLED_DURATION:
  308. m_wndDuration.EnableWindow( !bChecked );
  309. break;
  310. case IDC_CHECK_READONLY_DATETIME:
  311. m_wndDateTime.SetReadOnly( bChecked );
  312. break;
  313. case IDC_CHECK_READONLY_DURATION:
  314. m_wndDuration.SetReadOnly( bChecked );
  315. break;
  316. case IDC_CHECK_CONTINUOUS_DATETIME:
  317. m_wndDateTime.SetContinuousScrolling( bChecked );
  318. break;
  319. case IDC_CHECK_CONTINUOUS_DURATION:
  320. m_wndDuration.SetContinuousScrolling( bChecked );
  321. break;
  322. case IDC_CHECK_BTN_DROP_DOWN:
  323. m_wndDateTime.ShowDropDownButton( bChecked );
  324. break;
  325. case IDC_CHECK_BTN_SPIN_DATETIME:
  326. m_wndDateTime.ShowSpinButton( bChecked );
  327. break;
  328. case IDC_CHECK_BTN_SPIN_DURATION:
  329. m_wndDuration.ShowSpinButton( bChecked );
  330. break;
  331. case IDC_CHECK_BTN_SHOW_SELECTION_ALWAYS_DATETIME:
  332. m_wndDateTime.NoHideSelectionSet( bChecked );
  333. break;
  334. case IDC_CHECK_BTN_SHOW_SELECTION_ALWAYS_DURATION:
  335. m_wndDuration.NoHideSelectionSet( bChecked );
  336. break;
  337. case IDC_ADJUST_SIZE_DATETIME:   
  338. m_wndDateTime.AdjustSize();
  339. m_wndBoxDateTime.Invalidate();
  340. break;
  341. case IDC_ADJUST_SIZE_DURATION:
  342. m_wndDuration.AdjustSize();
  343. m_wndBoxDuration.Invalidate();
  344. break;
  345. case IDC_TIME_FORMAT_AUTO:
  346. case IDC_TIME_FORMAT_H24:
  347. case IDC_TIME_FORMAT_H12:
  348. {
  349. UpdateData();
  350. CExtDateTimeWnd::eTimeFormat_t eTimeFormat = CExtDateTimeWnd::automatic;
  351. switch( m_nTimeFormat ) 
  352. {
  353. case 0:
  354. eTimeFormat = CExtDateTimeWnd::automatic;
  355. break;
  356. case 1:
  357. eTimeFormat = CExtDateTimeWnd::h24;
  358. break;
  359. case 2:
  360. eTimeFormat = CExtDateTimeWnd::h12;
  361. break;
  362. }
  363. m_wndDateTime.SetTimeFormat( eTimeFormat );
  364. }
  365. break;
  366. case IDC_MODE_TIME:
  367. case IDC_MODE_DATE:
  368. case IDC_MODE_DATE_TIME:
  369. {
  370. UpdateData();
  371. CExtDateTimeWnd::eMode_t eMode = CExtDateTimeWnd::all;
  372. switch( m_nMode ) 
  373. {
  374. case 0:
  375. eMode = CExtDateTimeWnd::time;
  376. break;
  377. case 1:
  378. eMode = CExtDateTimeWnd::date;
  379. break;
  380. case 2:
  381. eMode = CExtDateTimeWnd::all;
  382. break;
  383. }
  384. m_wndDateTime.SetMode( eMode );
  385. }
  386. break;
  387. case IDC_CHECK_MODE_DAYS:
  388. m_wndDuration.SetShowItem( CExtDurationWnd::day, bChecked );
  389. break;
  390. case IDC_CHECK_MODE_HOURS:
  391. m_wndDuration.SetShowItem( CExtDurationWnd::hour, bChecked );
  392. break;
  393. case IDC_CHECK_MODE_MINUTES:
  394. m_wndDuration.SetShowItem( CExtDurationWnd::minute, bChecked );
  395. break;
  396. case IDC_CHECK_MODE_SECONDS:
  397. m_wndDuration.SetShowItem( CExtDurationWnd::second, bChecked );
  398. break;
  399. default:
  400. return CPageBase::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
  401. }
  402. return TRUE;
  403. }
  404. return CPageBase::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
  405. }
  406. #endif // (!defined __EXT_MFC_NO_DURATIONWND && !defined __EXT_MFC_NO_DATETIMEWND )
  407. #if (!defined __EXT_MFC_NO_DATE_BROWSER )
  408. /////////////////////////////////////////////////////////////////////////////
  409. // CLogCtrl
  410. CLogCtrl::CLogCtrl()
  411. : m_dwHelperThreadID( ::GetCurrentThreadId() )
  412. , m_nLineCountMax( 32000 )
  413. {
  414. }
  415. CLogCtrl::~CLogCtrl()
  416. {
  417. }
  418. BEGIN_MESSAGE_MAP(CLogCtrl,CRichEditCtrl)
  419. //{{AFX_MSG_MAP(CLogCtrl)
  420. ON_WM_TIMER()
  421. ON_COMMAND(ID_EDIT_COPY, OnEditCopy)
  422. ON_UPDATE_COMMAND_UI(ID_EDIT_COPY, OnUpdateEditCopy)
  423. //}}AFX_MSG_MAP
  424. ON_MESSAGE( WM_USR_WRITE_LOG_TEXT, On_WM_USR_WRITE_LOG_TEXT )
  425. END_MESSAGE_MAP()
  426. /////////////////////////////////////////////////////////////////////////////
  427. // CLogCtrl message handlers
  428. BOOL CLogCtrl::PreCreateWindow(CREATESTRUCT& cs) 
  429. {
  430. if( ! CRichEditCtrl :: PreCreateWindow(cs) )
  431. return FALSE;
  432. cs.style &= ~WS_BORDER;
  433. return TRUE;
  434. }
  435. void CLogCtrl::PreSubclassWindow() 
  436. {
  437. CRichEditCtrl::PreSubclassWindow();
  438. _InitRichEditProps();
  439. }
  440. void CLogCtrl::OnTimer(__EXT_MFC_UINT_PTR nIDEvent) 
  441. {
  442. if( nIDEvent == ID_TIMER_DELAYED_UPDATE )
  443. {
  444. if( _CanUpdate() )
  445. {
  446. KillTimer( ID_TIMER_DELAYED_UPDATE );
  447. Invalidate();
  448. UpdateWindow();
  449. }
  450. return;
  451. } // if( nIDEvent == ID_TIMER_DELAYED_UPDATE )
  452. CRichEditCtrl::OnTimer(nIDEvent);
  453. }
  454. void CLogCtrl::OnEditCopy() 
  455. {
  456. CHARRANGE _cr;
  457. GetSel( _cr );
  458. if( _cr.cpMin != _cr.cpMax )
  459. CRichEditCtrl::Copy();
  460. }
  461. void CLogCtrl::OnUpdateEditCopy(CCmdUI* pCmdUI) 
  462. {
  463. CHARRANGE _cr;
  464. GetSel( _cr );
  465. pCmdUI->Enable(
  466. ( _cr.cpMin != _cr.cpMax ) ? TRUE : FALSE
  467. );
  468. }
  469. LRESULT CLogCtrl::On_WM_USR_WRITE_LOG_TEXT( WPARAM wParam, LPARAM lParam )
  470. {
  471. ASSERT_VALID( this );
  472. wParam;
  473. _MthMessageDataFor_WM_USR_WRITE_LOG_TEXT & _data =
  474. _MthMessageDataFor_WM_USR_WRITE_LOG_TEXT::FromLPARAM( lParam );
  475. WriteText(
  476. _data.m_bBold,
  477. _data.m_clrText,
  478. _data.m_sText
  479. );
  480. return 0L;
  481. }
  482. void CLogCtrl::_InitRichEditProps()
  483. {
  484. PARAFORMAT _pf;
  485. _pf.cbSize = sizeof(PARAFORMAT);
  486. _pf.dwMask = PFM_TABSTOPS ;
  487. _pf.cTabCount = MAX_TAB_STOPS;
  488. for( int nTabIdx = 0 ; nTabIdx < _pf.cTabCount; nTabIdx++ )
  489. _pf.rgxTabs[nTabIdx] = (nTabIdx + 1) * 1440/5;
  490. CRichEditCtrl::SetParaFormat( _pf );
  491. CHARFORMAT _cf;
  492. memset( &_cf, 0, sizeof(CHARFORMAT) );
  493. _cf.cbSize = sizeof(_cf);
  494. _cf.dwEffects = 0; // CFE_PROTECTED; 
  495. _cf.dwMask =
  496. CFM_FACE|CFM_BOLD|CFM_ITALIC|CFM_UNDERLINE|CFM_STRIKEOUT
  497. |CFM_SIZE|CFM_CHARSET|CFM_PROTECTED|CFM_COLOR;
  498. _cf.yHeight = 150;
  499. _cf.bCharSet = DEFAULT_CHARSET;
  500. #if _MFC_VER < 0x700
  501. strcpy( _cf.szFaceName, "Courier New" );
  502. #else
  503. __EXT_MFC_STRCPY( _cf.szFaceName, LF_FACESIZE, _T("Courier New") );
  504. #endif
  505. _cf.crTextColor = RGB(0,0,0);
  506. CRichEditCtrl::SetDefaultCharFormat( _cf );
  507. CRichEditCtrl::SetWordCharFormat( _cf );
  508. CRichEditCtrl::SetBackgroundColor( FALSE, RGB(255,255,255) );
  509. CRichEditCtrl::SetSel( -1, -1 );
  510. }
  511. bool CLogCtrl::_CanUpdate()
  512. {
  513. if( CExtControlBar::FindHwndNotSafeForMutualPaint(this) != NULL )
  514. return false;
  515. if( CExtPopupMenuWnd::g_bMenuWithShadows )
  516. {
  517. if( CExtPopupMenuWnd::IsMenuTracking() )
  518. {
  519. CExtPopupMenuWnd * pPopup = CExtPopupMenuSite::g_DefPopupMenuSite.GetInstance();
  520. ASSERT_VALID( pPopup );
  521. if( pPopup->_IsPopupWithShadows() )
  522. return false;
  523. }
  524. else if( CExtToolControlBar::g_bMenuTracking )
  525. return false;
  526. } // if( CExtPopupMenuWnd::g_bMenuWithShadows )
  527. CExtPopupMenuTipWnd & _ATTW = CExtPopupMenuSite::g_DefPopupMenuSite.GetTip();
  528. if( _ATTW.GetSafeHwnd() != NULL
  529. && (_ATTW.GetStyle()&WS_VISIBLE) != 0
  530. && _ATTW.m_ctrlShadow.GetSafeHwnd() == NULL
  531. && _ATTW.GetShadowSize() > 0
  532. )
  533. return false;
  534. return true;
  535. }
  536. void CLogCtrl::WriteText(
  537. bool bBold,
  538. COLORREF clrText,
  539. LPCTSTR sText
  540. )
  541. {
  542. ASSERT( this != NULL );
  543. if( m_dwHelperThreadID != ::GetCurrentThreadId() )
  544. {
  545. _MthMessageDataFor_WM_USR_WRITE_LOG_TEXT _data(
  546. bBold,
  547. clrText,
  548. sText
  549. );
  550. SendMessage(
  551. WM_USR_WRITE_LOG_TEXT,
  552. WPARAM(0),
  553. _data
  554. );
  555. return;
  556. }
  557. ASSERT_VALID( this );
  558. if( sText == NULL
  559. || _tcslen( sText ) == 0
  560. )
  561. return;
  562. CRichEditCtrl::LineScroll( CRichEditCtrl::GetLineCount() );
  563. bool bCanUpdate = _CanUpdate();
  564. SetRedraw( FALSE );
  565. int nFirstLine1 = CRichEditCtrl::GetFirstVisibleLine();
  566. CHARRANGE crOld1, crOld2;
  567. CRichEditCtrl::GetSel( crOld1 );
  568. CRichEditCtrl::SetSel( -1, -1 );
  569. CRichEditCtrl::GetSel( crOld2 );
  570. bool bResetSel = true;
  571. if( crOld1.cpMin == crOld2.cpMin
  572. && crOld1.cpMax == crOld2.cpMax
  573. )
  574. bResetSel = false;
  575. CRichEditCtrl::ReplaceSel( sText );
  576. CHARFORMAT _cf;
  577. _cf.cbSize = sizeof(CHARFORMAT);
  578. _cf.dwMask = CFM_COLOR|CFM_BOLD;
  579. _cf.dwEffects = bBold ? CFE_BOLD : 0;
  580. _cf.crTextColor = clrText;
  581. CRichEditCtrl::SetSel( crOld2.cpMax, -1 );
  582. CRichEditCtrl::SetSelectionCharFormat( _cf );
  583. if( bResetSel )
  584. {
  585. CRichEditCtrl::SetSel( crOld1 );
  586. int nFirstLine2 = CRichEditCtrl::GetFirstVisibleLine();
  587. if( nFirstLine1 != nFirstLine2 )
  588. LineScroll( nFirstLine1-nFirstLine2, 0) ;
  589. } // if( bResetSel )
  590. if( m_nLineCountMax > 0 )
  591. {
  592. int nLineCount = CRichEditCtrl::GetLineCount();
  593. if( nLineCount > m_nLineCountMax )
  594. {
  595. int nEndRemovePos =
  596. CRichEditCtrl::LineIndex(
  597. nLineCount > m_nLineCountMax 
  598. );
  599. CHARRANGE crRestore;
  600. CRichEditCtrl::GetSel( crRestore );
  601. crRestore.cpMin -= nEndRemovePos;
  602. crRestore.cpMax -= nEndRemovePos;
  603. CRichEditCtrl::SetSel( 0, nEndRemovePos );
  604. CRichEditCtrl::ReplaceSel( _T("") );
  605. CRichEditCtrl::SetSel( crRestore );
  606. }
  607. } // if( m_nLineCountMax > 0 )
  608. if( ! bResetSel )
  609. CRichEditCtrl::SetSel( -1, -1 );
  610. SetRedraw( TRUE );
  611. if( bCanUpdate )
  612. Invalidate();
  613. else
  614. SetTimer(
  615. ID_TIMER_DELAYED_UPDATE,
  616. ELAPSE_TIMER_DELAYED_UPDATE,
  617. NULL
  618. );
  619. }
  620. //////////////////////////////////////////////////////////////////////////
  621. // CLocalDateBrowser
  622. LPCTSTR CLocalDateBrowser::stat_ViewModeToText( CExtDateBrowserWnd::e_view_mode_t _eVM )
  623. {
  624. switch( _eVM )
  625. {
  626. case __EVM_CENTURY:
  627. return _T("century");
  628. case __EVM_YEAR_DECADE:
  629. return _T("year decade");
  630. case __EVM_ONE_YEAR:
  631. return _T("one year");
  632. case __EVM_MONTH:
  633. return _T("month");
  634. break;
  635. #ifdef _DEBUG
  636. default:
  637. ASSERT( FALSE );
  638. break;
  639. #endif // _DEBUG
  640. } // switch( _eVM )
  641. return _T("unknown");
  642. }
  643. void CLocalDateBrowser::WriteLog(
  644. LPCTSTR strHeaderText,
  645. LPCTSTR strDetailsText,
  646. COLORREF clr
  647. ) const
  648. {
  649. if( ( strHeaderText == NULL || _tcslen(strHeaderText) == 0 )
  650. && ( strDetailsText == NULL || _tcslen(strDetailsText) == 0 )
  651. )
  652. return;
  653. CPageDateBrowser * pDlg = DYNAMIC_DOWNCAST( CPageDateBrowser, GetParent() );
  654. if( pDlg == NULL
  655. || pDlg->m_wndNotifications.GetSafeHwnd() == NULL
  656. )
  657. return;
  658. WriteLog( pDlg->m_wndNotifications, strHeaderText, strDetailsText, clr );
  659. }
  660. void CLocalDateBrowser::WriteLog(
  661. CLogCtrl & wndLog,
  662. LPCTSTR strHeaderText,
  663. LPCTSTR strDetailsText,
  664. COLORREF clr
  665. ) const
  666. {
  667. if( ( strHeaderText == NULL || _tcslen(strHeaderText) == 0 )
  668. && ( strDetailsText == NULL || _tcslen(strDetailsText) == 0 )
  669. )
  670. return;
  671. COLORREF clrHeader      = CExtBitmap::stat_HLS_Adjust( clr, 0.0, -0.20, 0.0 );
  672. COLORREF clrDescription = CExtBitmap::stat_HLS_Adjust( clr, 0.0, +0.20, 0.0 );
  673. if( wndLog.GetWindowTextLength() > 0 )
  674. wndLog.WriteText( false, RGB(0,0,0), _T("rn") );
  675. wndLog.WriteText( true, clrHeader, strHeaderText );
  676. wndLog.WriteText( false, RGB(0,0,0), _T("rn") );
  677. wndLog.WriteText( false, clrDescription, strDetailsText );
  678. }
  679. CString CLocalDateBrowser::stat_FormatHitTestInfo(
  680. const CExtDateBrowserWnd::HITTESTINFO & _hitTest
  681. )
  682. {
  683. CString strHitTestDescription = _T("nowhere");
  684. switch( INT(_hitTest.m_nAreaFlags & __EHTIAF_INSIDE_CONTROL_MASK) )
  685. {
  686. case INT(__EHTIAF_ON_BUTTON_PREVIOUS):
  687. strHitTestDescription = _T("previous button");
  688. break;
  689. case INT(__EHTIAF_ON_BUTTON_NEXT):
  690. strHitTestDescription = _T("next button");
  691. break;
  692. case INT(__EHTIAF_ON_CAPTION):
  693. strHitTestDescription = _T("caption");
  694. break;
  695. case INT(__EHTIAF_ON_ITEM):
  696. strHitTestDescription = _T("palette item");
  697. if( ( _hitTest.m_nAreaFlags & __EHTIAF_ON_MONTH_HEADER_ITEM ) != 0 )
  698. strHitTestDescription += _T(" (header item)");
  699. if( _hitTest.m_time.GetStatus() == COleDateTime::valid )
  700. {
  701. strHitTestDescription += _T(", date is ");
  702. strHitTestDescription += _hitTest.m_time.Format( VAR_DATEVALUEONLY, LOCALE_USER_DEFAULT );
  703. }
  704. break;
  705. } // switch( INT(_hitTest.m_nAreaFlags & __EHTIAF_INSIDE_CONTROL_MASK) )
  706. if( ( _hitTest.m_nAreaFlags & __EHTIAF_OUTSIDE_AT_TOP ) != 0 )
  707. strHitTestDescription += _T(" (outside at top)");
  708. if( ( _hitTest.m_nAreaFlags & __EHTIAF_OUTSIDE_AT_BOTTOM ) != 0 )
  709. strHitTestDescription += _T(" (outside at bottom)");
  710. if( ( _hitTest.m_nAreaFlags & __EHTIAF_OUTSIDE_AT_LEFT ) != 0 )
  711. strHitTestDescription += _T(" (outside at left)");
  712. if( ( _hitTest.m_nAreaFlags & __EHTIAF_OUTSIDE_AT_RIGHT ) != 0 )
  713. strHitTestDescription += _T(" (outside at right)");
  714. return strHitTestDescription;
  715. }
  716. bool CLocalDateBrowser::OnDateBrowserHoverChanging(
  717. const CExtDateBrowserWnd::HITTESTINFO & _hitTestOld,
  718. const CExtDateBrowserWnd::HITTESTINFO & _hitTestNew
  719. )
  720. {
  721. ASSERT_VALID( this );
  722. bool bRetVal = CExtDateBrowserWnd::OnDateBrowserHoverChanging( _hitTestOld, _hitTestNew );
  723. if( m_bShowHoverEvents )
  724. {
  725. CString strDetalisText;
  726. CString strOldHitTest = stat_FormatHitTestInfo( _hitTestOld );
  727. CString strNewHitTest = stat_FormatHitTestInfo( _hitTestNew );
  728. strDetalisText.Format(
  729. _T("    old hit test = %srn    new hit test = %srn    return value = %s"),
  730. LPCTSTR(strOldHitTest),
  731. LPCTSTR(strNewHitTest),
  732. bRetVal ? _T("true") : _T("false")
  733. );
  734. WriteLog( _T("OnDateBrowserHoverChanging() query"), LPCTSTR(strDetalisText), RGB(172,172,172) );
  735. } // if( m_bShowHoverEvents )
  736. return bRetVal;
  737. }
  738. void CLocalDateBrowser::OnDateBrowserHoverChanged(
  739. const CExtDateBrowserWnd::HITTESTINFO & _hitTestOld,
  740. const CExtDateBrowserWnd::HITTESTINFO & _hitTestNew
  741. )
  742. {
  743. ASSERT_VALID( this );
  744. CExtDateBrowserWnd::OnDateBrowserHoverChanged( _hitTestOld, _hitTestNew );
  745. if( m_bShowHoverEvents )
  746. {
  747. CString strDetalisText;
  748. CString strOldHitTest = stat_FormatHitTestInfo( _hitTestOld );
  749. CString strNewHitTest = stat_FormatHitTestInfo( _hitTestNew );
  750. strDetalisText.Format(
  751. _T("    old hit test = %srn    new hit test = %s"),
  752. LPCTSTR(strOldHitTest),
  753. LPCTSTR(strNewHitTest)
  754. );
  755. WriteLog( _T("OnDateBrowserHoverChanged() notification"), LPCTSTR(strDetalisText), RGB(112,112,112) );
  756. } // if( m_bShowHoverEvents )
  757. }
  758. CSize CLocalDateBrowser::OnDateBrowserCalcSize(
  759. CDC & dcMeasure,
  760. const COleDateTime & _time
  761. ) const
  762. {
  763. ASSERT_VALID( this );
  764. CSize _size = CExtDateBrowserWnd::OnDateBrowserCalcSize( dcMeasure, _time );
  765. CString strDetalisText;
  766. CString strTime = _time.Format( VAR_DATEVALUEONLY, LOCALE_USER_DEFAULT );
  767. strDetalisText.Format(
  768. _T("    date = %srn    return value = CSize( cx = %d, cy = %d)"),
  769. LPCTSTR(strTime),
  770. INT(_size.cx),
  771. INT(_size.cy)
  772. );
  773. WriteLog( _T("OnCalcSize() query"), LPCTSTR(strDetalisText), RGB(192,0,0) );
  774. return _size;
  775. }
  776. bool CLocalDateBrowser::OnDateBrowserAnimateTimeChanging(
  777. const COleDateTime & _timeOld,
  778. const COleDateTime  & _timeNew
  779. ) const
  780. {
  781. ASSERT_VALID( this );
  782. bool bRetVal = CExtDateBrowserWnd::OnDateBrowserAnimateTimeChanging( _timeOld, _timeNew );
  783. CString strDetalisText;
  784. CString strTimeOld = _timeOld.Format( VAR_DATEVALUEONLY, LOCALE_USER_DEFAULT );
  785. CString strTimeNew = _timeNew.Format( VAR_DATEVALUEONLY, LOCALE_USER_DEFAULT );
  786. strDetalisText.Format(
  787. _T("    date old = %s    date new = %srn    return value = %s"),
  788. LPCTSTR(strTimeOld),
  789. LPCTSTR(strTimeNew),
  790. bRetVal ? _T("true") : _T("false")
  791. );
  792. WriteLog( _T("OnAnimateTimeChanging() query"), LPCTSTR(strDetalisText), RGB(0,144,144) );
  793. return bRetVal;
  794. }
  795. bool CLocalDateBrowser::OnDateBrowserAnimateViewModeChanging(
  796. e_view_mode_t eVM_old,
  797. e_view_mode_t eVM_new
  798. ) const
  799. {
  800. ASSERT_VALID( this );
  801. bool bRetVal = CExtDateBrowserWnd::OnDateBrowserAnimateViewModeChanging( eVM_old, eVM_new );
  802. CString strDetalisText;
  803. strDetalisText.Format(
  804. _T("    old mode = %s    new mode = %srn    return value = %s"),
  805. stat_ViewModeToText( eVM_old ),
  806. stat_ViewModeToText( eVM_new ),
  807. bRetVal ? _T("true") : _T("false")
  808. );
  809. WriteLog( _T("OnAnimateViewModeChanging() query"), LPCTSTR(strDetalisText), RGB(144,144,0) );
  810. return bRetVal;
  811. }
  812. bool CLocalDateBrowser::OnDateBrowserTimeChanging(
  813. const COleDateTime & _timeOld,
  814. const COleDateTime & _timeNew
  815. )
  816. {
  817. ASSERT_VALID( this );
  818. bool bRetVal = CExtDateBrowserWnd::OnDateBrowserTimeChanging( _timeOld, _timeNew );
  819. CString strDetalisText;
  820. CString strTimeOld = _timeOld.Format( VAR_DATEVALUEONLY, LOCALE_USER_DEFAULT );
  821. CString strTimeNew = _timeNew.Format( VAR_DATEVALUEONLY, LOCALE_USER_DEFAULT );
  822. strDetalisText.Format(
  823. _T("    date old = %s    date new = %srn    return value = %s"),
  824. LPCTSTR(strTimeOld),
  825. LPCTSTR(strTimeNew),
  826. bRetVal ? _T("true") : _T("false")
  827. );
  828. WriteLog( _T("OnTimeChanging() query"), LPCTSTR(strDetalisText), RGB(0,0,192) );
  829. return bRetVal;
  830. }
  831. void CLocalDateBrowser::OnDateBrowserTimeChanged(
  832. const COleDateTime & _timeOld,
  833. const COleDateTime & _timeNew
  834. )
  835. {
  836. ASSERT_VALID( this );
  837. CExtDateBrowserWnd::OnDateBrowserTimeChanged( _timeOld, _timeNew );
  838. CString strDetalisText;
  839. CString strTimeOld = _timeOld.Format( VAR_DATEVALUEONLY, LOCALE_USER_DEFAULT );
  840. CString strTimeNew = _timeNew.Format( VAR_DATEVALUEONLY, LOCALE_USER_DEFAULT );
  841. strDetalisText.Format(
  842. _T("    date old = %s    date new = %s"),
  843. LPCTSTR(strTimeOld),
  844. LPCTSTR(strTimeNew)
  845. );
  846. WriteLog( _T("OnTimeChanged() notification"), LPCTSTR(strDetalisText), RGB(0,0,144) );
  847. }
  848. bool CLocalDateBrowser::OnDateBrowserViewModeChanging(
  849. CExtDateBrowserWnd::e_view_mode_t eVM_old,
  850. CExtDateBrowserWnd::e_view_mode_t eVM_new
  851. )
  852. {
  853. ASSERT_VALID( this );
  854. bool bRetVal = CExtDateBrowserWnd::OnDateBrowserViewModeChanging( eVM_old, eVM_new );
  855. CString strDetalisText;
  856. strDetalisText.Format(
  857. _T("    old mode = %s    new mode = %srn    return value = %s"),
  858. stat_ViewModeToText( eVM_old ),
  859. stat_ViewModeToText( eVM_new ),
  860. bRetVal ? _T("true") : _T("false")
  861. );
  862. WriteLog( _T("OnViewModeChanging() query"), LPCTSTR(strDetalisText), RGB(0,192,0) );
  863. return bRetVal;
  864. }
  865. void CLocalDateBrowser::OnDateBrowserViewModeChanged(
  866. CExtDateBrowserWnd::e_view_mode_t eVM_old,
  867. CExtDateBrowserWnd::e_view_mode_t eVM_new
  868. )
  869. {
  870. ASSERT_VALID( this );
  871. CExtDateBrowserWnd::OnDateBrowserViewModeChanged( eVM_old, eVM_new );
  872. CString strDetalisText;
  873. strDetalisText.Format(
  874. _T("    old mode = %s    new mode = %s"),
  875. stat_ViewModeToText( eVM_old ),
  876. stat_ViewModeToText( eVM_new )
  877. );
  878. WriteLog( _T("OnViewModeChanged() notification"), LPCTSTR(strDetalisText), RGB(0,144,0) );
  879. }
  880. /////////////////////////////////////////////////////////////////////////////
  881. // CPageDateBrowser dialog
  882. IMPLEMENT_DYNAMIC( CPageDateBrowser, CPageBase );
  883. CPageDateBrowser::CPageDateBrowser(CWnd* pParent /*=NULL*/)
  884. : CPageBase(CPageDateBrowser::IDD, pParent)
  885. {
  886. //{{AFX_DATA_INIT(CPageDateBrowser)
  887. //}}AFX_DATA_INIT
  888. SetAutoSubclassChildControls();
  889. }
  890. void CPageDateBrowser::DoDataExchange(CDataExchange* pDX)
  891. {
  892. CPageBase::DoDataExchange(pDX);
  893. //{{AFX_DATA_MAP(CPageDateBrowser)
  894. DDX_Control(pDX, IDC_CHECK_SHOW_HOVER_EVENTS, m_wndCheckShowHoverEventsInLogView);
  895. DDX_Control(pDX, IDC_CHECK_SHOW_NON_YEAR_DECADE_ITEMS, m_checkShowNonYearDecadeItems);
  896. DDX_Control(pDX, IDC_CHECK_SHOW_NON_CENTURY_ITEMS, m_checkShowNonCenturyItems);
  897. DDX_Control(pDX, IDC_CHECK_SHOW_OUT_OF_RANGE_ITEMS, m_checkShowOutOfRangeItems);
  898. DDX_Control(pDX, IDC_CHECK_SHOW_NON_MONTH_DAYS, m_checkShowNonMonthDays);
  899. DDX_Control(pDX, IDC_COMBO_LAST_YEAR, m_comboLastYear);
  900. DDX_Control(pDX, IDC_COMBO_FIRST_YEAR, m_comboFirstYear);
  901. DDX_Control(pDX, IDC_COMBO_FIRST_DAY_OF_WEEK, m_comboFirstDayOfWeek);
  902. DDX_Control(pDX, IDC_COMBO_DATE_BROWSER_THEME, m_comboDateBrowserTheme);
  903. DDX_Control(pDX, IDC_GROUP_BOX_AP, m_gropBoxAnimationParameters);
  904. DDX_Control(pDX, IDC_EDIT_AP_ZOOM_STEP_TIME, m_editZoomStepTime);
  905. DDX_Control(pDX, IDC_EDIT_AP_ZOOM_STEP_COUNT, m_editZoomStepCount);
  906. DDX_Control(pDX, IDC_EDIT_AP_SCROLL_STEP_TIME, m_editScrollStepTime);
  907. DDX_Control(pDX, IDC_EDIT_AP_SCROLL_STEP_COUNT, m_editScrollStepCount);
  908. DDX_Control(pDX, IDC_SPIN_AP_ZOOM_STEP_TIME, m_spinZoomStepTime);
  909. DDX_Control(pDX, IDC_SPIN_AP_ZOOM_STEP_COUNT, m_spinZoomStepCount);
  910. DDX_Control(pDX, IDC_SPIN_AP_SCROLL_STEP_TIME, m_spinScrollStepTime);
  911. DDX_Control(pDX, IDC_SPIN_AP_SCROLL_STEP_COUNT, m_spinScrollStepCount);
  912. //}}AFX_DATA_MAP
  913. DDX_Control(pDX, IDC_NOTIFICATIONS, m_wndNotifications);
  914. DDX_Control( pDX, IDC_CUSTOM1, m_wndDateBrowser );
  915. }
  916. BEGIN_MESSAGE_MAP(CPageDateBrowser, CDialog)
  917. //{{AFX_MSG_MAP(CPageDateBrowser)
  918. ON_BN_CLICKED(IDC_BUTTON_CONTENT_TO_SIZE, OnButtonContentToSize)
  919. ON_BN_CLICKED(IDC_BUTTON_AP_ZOOM_RESET, OnButtonApZoomReset)
  920. ON_BN_CLICKED(IDC_BUTTON_AP_SCROLL_RESET, OnButtonApScrollReset)
  921. ON_CBN_SELENDOK(IDC_COMBO_DATE_BROWSER_THEME, OnSelendokComboDateBrowserTheme)
  922. ON_EN_CHANGE(IDC_EDIT_AP_SCROLL_STEP_COUNT, OnChangeEditApScrollStepCount)
  923. ON_EN_CHANGE(IDC_EDIT_AP_SCROLL_STEP_TIME, OnChangeEditApScrollStepTime)
  924. ON_EN_CHANGE(IDC_EDIT_AP_ZOOM_STEP_COUNT, OnChangeEditApZoomStepCount)
  925. ON_EN_CHANGE(IDC_EDIT_AP_ZOOM_STEP_TIME, OnChangeEditApZoomStepTime)
  926. ON_CBN_SELENDOK(IDC_COMBO_FIRST_DAY_OF_WEEK, OnSelendokComboFirstDayOfWeek)
  927. ON_CBN_SELENDOK(IDC_COMBO_FIRST_YEAR, OnSelendokComboFirstYear)
  928. ON_CBN_SELENDOK(IDC_COMBO_LAST_YEAR, OnSelendokComboLastYear)
  929. ON_BN_CLICKED(IDC_CHECK_SHOW_OUT_OF_RANGE_ITEMS, OnCheckShowOutOfRangeItems)
  930. ON_BN_CLICKED(IDC_CHECK_SHOW_NON_MONTH_DAYS, OnCheckShowNonMonthDays)
  931. ON_BN_CLICKED(IDC_CHECK_SHOW_NON_CENTURY_ITEMS, OnCheckShowNonCenturyItems)
  932. ON_BN_CLICKED(IDC_CHECK_SHOW_NON_YEAR_DECADE_ITEMS, OnCheckShowNonYearDecadeItems)
  933. ON_BN_CLICKED(IDC_CHECK_SHOW_HOVER_EVENTS, OnCheckShowHoverEvents)
  934. //}}AFX_MSG_MAP
  935. END_MESSAGE_MAP()
  936. /////////////////////////////////////////////////////////////////////////////
  937. // CPageDateBrowser message handlers
  938. BOOL CPageDateBrowser::OnInitDialog()
  939. {
  940. CPageBase::OnInitDialog();
  941. m_gropBoxAnimationParameters.SetStyle( CExtGroupBox::STYLE_CAPTION );
  942. OnButtonApZoomReset();
  943. OnButtonApScrollReset();
  944. m_comboFirstDayOfWeek.SetCurSel( 0 );
  945. m_comboFirstYear.SelectString( -1, _T("1900") );
  946. m_comboLastYear.SelectString( -1, _T("2099") );
  947. m_comboDateBrowserTheme.SetCurSel( 0 );
  948. //m_comboDateBrowserTheme.SetCurSel( 1 );
  949. //SetTheme( _T("Skin") );
  950. m_checkShowNonCenturyItems.SetCheck( 1 );
  951. m_checkShowNonYearDecadeItems.SetCheck( 1 );
  952. m_checkShowNonMonthDays.SetCheck( 1 );
  953. m_checkShowOutOfRangeItems.SetCheck( 0 );
  954. m_spinScrollStepCount.SetRange( 0, 50 );
  955. m_spinScrollStepTime.SetRange( 0, 50 );
  956. m_spinZoomStepCount.SetRange( 0, 50 );
  957. m_spinZoomStepTime.SetRange( 0, 50 );
  958. AddAnchor( IDC_NOTIFICATIONS, __RDA_LT, __RDA_RB );
  959. return TRUE; 
  960. }
  961. void CPageDateBrowser::OnButtonContentToSize() 
  962. {
  963. CSize _size = m_wndDateBrowser.CalcSize();
  964. CRect rc;
  965. m_wndDateBrowser.GetWindowRect( &rc );
  966. if( rc.Size() == _size )
  967. {
  968. ::AfxMessageBox( _T("Size is OK.") );
  969. return;
  970. }
  971. ScreenToClient( &rc );
  972. rc.right = rc.left + _size.cx;
  973. rc.bottom = rc.top + _size.cy;
  974. m_wndDateBrowser.MoveWindow( &rc );
  975. }
  976. void CPageDateBrowser::OnButtonApZoomReset() 
  977. {
  978. SetZoomAnimation( __EXT_DATE_BROWSER_ANIMATION_ZOOM_STEP_COUNT, __EXT_DATE_BROWSER_ANIMATION_ZOOM_STEP_TIME );
  979. }
  980. void CPageDateBrowser::OnButtonApScrollReset() 
  981. {
  982. SetScrollAnimation( __EXT_DATE_BROWSER_ANIMATION_SCROLL_STEP_COUNT, __EXT_DATE_BROWSER_ANIMATION_SCROLL_STEP_TIME );
  983. }
  984. void CPageDateBrowser::OnSelendokComboDateBrowserTheme() 
  985. {
  986. if( m_comboDateBrowserTheme.GetSafeHwnd() == NULL )
  987. return;
  988. CString s;
  989. m_comboDateBrowserTheme.GetWindowText( s );
  990. SetTheme( s );
  991. }
  992. void CPageDateBrowser::OnChangeEditApScrollStepCount() 
  993. {
  994. if( m_editScrollStepCount.GetSafeHwnd() == NULL )
  995. return;
  996. CString s;
  997. m_editScrollStepCount.GetWindowText( s );
  998. if( ! s.IsEmpty() )
  999. {
  1000. if( _ttol(s) > 50 )
  1001. s = _T("50");
  1002. SetScrollAnimation( _ttol(s), -1 );
  1003. }
  1004. }
  1005. void CPageDateBrowser::OnChangeEditApScrollStepTime() 
  1006. {
  1007. if( m_editScrollStepTime.GetSafeHwnd() == NULL )
  1008. return;
  1009. CString s;
  1010. m_editScrollStepTime.GetWindowText( s );
  1011. if( ! s.IsEmpty() )
  1012. {
  1013. if( _ttol(s) > 50 )
  1014. s = _T("50");
  1015. SetScrollAnimation( -1, _ttol(s) );
  1016. }
  1017. }
  1018. void CPageDateBrowser::OnChangeEditApZoomStepCount() 
  1019. {
  1020. if( m_editZoomStepCount.GetSafeHwnd() == NULL )
  1021. return;
  1022. CString s;
  1023. m_editZoomStepCount.GetWindowText( s );
  1024. if( ! s.IsEmpty() )
  1025. {
  1026. if( _ttol(s) > 50 )
  1027. s = _T("50");
  1028. SetZoomAnimation( _ttol(s), -1 );
  1029. }
  1030. }
  1031. void CPageDateBrowser::OnChangeEditApZoomStepTime() 
  1032. {
  1033. if( m_editZoomStepTime.GetSafeHwnd() == NULL )
  1034. return;
  1035. CString s;
  1036. m_editZoomStepTime.GetWindowText( s );
  1037. if( ! s.IsEmpty() )
  1038. {
  1039. if( _ttol(s) > 50 )
  1040. s = _T("50");
  1041. SetZoomAnimation( -1, _ttol(s) );
  1042. }
  1043. }
  1044. void CPageDateBrowser::SetZoomAnimation( INT _stepCount, INT _stepTime )
  1045. {
  1046. CString s;
  1047. if( _stepCount >= 0 )
  1048. {
  1049. s.Format( _T("%d"), _stepCount );
  1050. m_editZoomStepCount.SetWindowText( s );
  1051. }
  1052. if( _stepTime >= 0 )
  1053. {
  1054. s.Format( _T("%d"), _stepTime );
  1055. m_editZoomStepTime.SetWindowText( s );
  1056. }
  1057. if( _stepCount >= 0 )
  1058. m_wndDateBrowser.m_nAnimationStepCountZoom = _stepCount;
  1059. if( _stepTime >= 0 )
  1060. m_wndDateBrowser.m_nAnimationStepTimeZoom = _stepTime;
  1061. m_wndDateBrowser.Invalidate();
  1062. }
  1063. void CPageDateBrowser::SetScrollAnimation( INT _stepCount, INT _stepTime )
  1064. {
  1065. CString s;
  1066. if( _stepCount >= 0 )
  1067. {
  1068. s.Format( _T("%d"), _stepCount );
  1069. m_editScrollStepCount.SetWindowText( s );
  1070. }
  1071. if( _stepTime >= 0 )
  1072. {
  1073. s.Format( _T("%d"), _stepTime );
  1074. m_editScrollStepTime.SetWindowText( s );
  1075. }
  1076. if( _stepCount >= 0 )
  1077. m_wndDateBrowser.m_nAnimationStepCountScroll = _stepCount;
  1078. if( _stepTime >= 0 )
  1079. m_wndDateBrowser.m_nAnimationStepTimeScroll = _stepTime;
  1080. m_wndDateBrowser.Invalidate();
  1081. }
  1082. void CPageDateBrowser::SetTheme( LPCTSTR _theme )
  1083. {
  1084. if( _tcscmp( _theme, _T("Simple")) == 0 )
  1085. m_wndDateBrowser.PaintStyleSet( CExtDateBrowserWnd::__EPST_SIMPLE );
  1086. else if( _tcscmp( _theme, _T("Skin")) == 0 )
  1087. m_wndDateBrowser.PaintStyleSet( CExtDateBrowserWnd::__EPST_SKIN );
  1088. else if( _tcscmp( _theme, _T("PaintManager")) == 0 )
  1089. m_wndDateBrowser.PaintStyleSet( CExtDateBrowserWnd::__EPST_PAINT_MANAGER );
  1090. m_wndDateBrowser.Invalidate();
  1091. }
  1092. void CPageDateBrowser::OnSelendokComboFirstDayOfWeek() 
  1093. {
  1094. CString s;
  1095. m_comboFirstDayOfWeek.GetWindowText( s );
  1096. SetFirstDayOfWeek( s );
  1097. }
  1098. void CPageDateBrowser::OnSelendokComboFirstYear() 
  1099. {
  1100. INT nSelFirst = m_comboFirstYear.GetCurSel();
  1101. INT nSelLast = m_comboLastYear.GetCurSel();
  1102. if( nSelFirst > nSelLast )
  1103. {
  1104. // nSelFirst = nSelLast;
  1105. // m_comboFirstYear.SetCurSel( nSelFirst );
  1106. nSelLast = nSelFirst;
  1107. m_comboLastYear.SetCurSel( nSelLast );
  1108. }
  1109. CString sFirst, sLast;
  1110. m_comboFirstYear.GetLBText( nSelFirst, sFirst );
  1111. m_comboLastYear.GetLBText( nSelLast, sLast );
  1112. COleDateTime _firstYear, _lastYear, _curr = m_wndDateBrowser.TimeGet();
  1113. _firstYear.SetDateTime( _ttol(sFirst), 1, 1, 0, 0, 0 );
  1114. _lastYear.SetDateTime( _ttol(sLast), 12, 31, 23, 59, 59 );
  1115. m_wndDateBrowser.TimeSet( _firstYear, -1 );
  1116. m_wndDateBrowser.TimeSet( _lastYear, 1 );
  1117. if( _curr < _firstYear )
  1118. m_wndDateBrowser.TimeSet( _firstYear );
  1119. else if( _curr > _lastYear )
  1120. m_wndDateBrowser.TimeSet( _lastYear );
  1121. m_wndDateBrowser.Invalidate();
  1122. }
  1123. void CPageDateBrowser::OnSelendokComboLastYear() 
  1124. {
  1125. INT nSelFirst = m_comboFirstYear.GetCurSel();
  1126. INT nSelLast = m_comboLastYear.GetCurSel();
  1127. if( nSelFirst > nSelLast )
  1128. {
  1129. nSelFirst = nSelLast;
  1130. m_comboFirstYear.SetCurSel( nSelFirst );
  1131. // nSelLast = nSelFirst;
  1132. // m_comboLastYear.SetCurSel( nSelLast );
  1133. }
  1134. CString sFirst, sLast;
  1135. m_comboFirstYear.GetLBText( nSelFirst, sFirst );
  1136. m_comboLastYear.GetLBText( nSelLast, sLast );
  1137. COleDateTime _firstYear, _lastYear, _curr = m_wndDateBrowser.TimeGet();
  1138. _firstYear.SetDateTime( _ttol(sFirst), 1, 1, 0, 0, 0 );
  1139. _lastYear.SetDateTime( _ttol(sLast), 12, 31, 23, 59, 59 );
  1140. m_wndDateBrowser.TimeSet( _firstYear, -1 );
  1141. m_wndDateBrowser.TimeSet( _lastYear, 1 );
  1142. if( _curr < _firstYear )
  1143. m_wndDateBrowser.TimeSet( _firstYear );
  1144. else if( _curr > _lastYear )
  1145. m_wndDateBrowser.TimeSet( _lastYear );
  1146. m_wndDateBrowser.Invalidate();
  1147. }
  1148. void CPageDateBrowser::SetFirstDayOfWeek( LPCTSTR _day )
  1149. {
  1150. if( _tcscmp( _day, _T("Use Windows settings")) == 0 )
  1151. m_wndDateBrowser.m_nFirstDayOfWeek = -1;
  1152. else if( _tcscmp( _day, _T("Sunday")) == 0 )
  1153. m_wndDateBrowser.m_nFirstDayOfWeek = 0;
  1154. else if( _tcscmp( _day, _T("Monday")) == 0 )
  1155. m_wndDateBrowser.m_nFirstDayOfWeek = 1;
  1156. else if( _tcscmp( _day, _T("Tuesday")) == 0 )
  1157. m_wndDateBrowser.m_nFirstDayOfWeek = 2;
  1158. else if( _tcscmp( _day, _T("Wednesday")) == 0 )
  1159. m_wndDateBrowser.m_nFirstDayOfWeek = 3;
  1160. else if( _tcscmp( _day, _T("Thursday")) == 0 )
  1161. m_wndDateBrowser.m_nFirstDayOfWeek = 4;
  1162. else if( _tcscmp( _day, _T("Friday")) == 0 )
  1163. m_wndDateBrowser.m_nFirstDayOfWeek = 5;
  1164. else if( _tcscmp( _day, _T("Saturday")) == 0 )
  1165. m_wndDateBrowser.m_nFirstDayOfWeek = 6;
  1166. m_wndDateBrowser.Invalidate();
  1167. }
  1168. void CPageDateBrowser::OnCheckShowOutOfRangeItems() 
  1169. {
  1170. if( m_checkShowOutOfRangeItems.GetCheck() != 0 )
  1171. m_wndDateBrowser.m_bShowOutOfRangeItems = true;
  1172. else
  1173. m_wndDateBrowser.m_bShowOutOfRangeItems = false;
  1174. m_wndDateBrowser.Invalidate();
  1175. }
  1176. void CPageDateBrowser::OnCheckShowNonMonthDays()
  1177. {
  1178. if( m_checkShowNonMonthDays.GetCheck() != 0 )
  1179. {
  1180. m_wndDateBrowser.m_bShowDaysAfterMonth = true;
  1181. m_wndDateBrowser.m_bShowDaysBeforeMonth = true;
  1182. }
  1183. else
  1184. {
  1185. m_wndDateBrowser.m_bShowDaysAfterMonth = false;
  1186. m_wndDateBrowser.m_bShowDaysBeforeMonth = false;
  1187. }
  1188. m_wndDateBrowser.Invalidate();
  1189. }
  1190. void CPageDateBrowser::OnCheckShowNonCenturyItems() 
  1191. {
  1192. if( m_checkShowNonCenturyItems.GetCheck() != 0 )
  1193. {
  1194. m_wndDateBrowser.m_bShowItemsAfterCentury = true;
  1195. m_wndDateBrowser.m_bShowItemsBeforeCentury = true;
  1196. }
  1197. else
  1198. {
  1199. m_wndDateBrowser.m_bShowItemsAfterCentury = false;
  1200. m_wndDateBrowser.m_bShowItemsBeforeCentury = false;
  1201. }
  1202. m_wndDateBrowser.Invalidate();
  1203. }
  1204. void CPageDateBrowser::OnCheckShowNonYearDecadeItems() 
  1205. {
  1206. if( m_checkShowNonYearDecadeItems.GetCheck() != 0 )
  1207. {
  1208. m_wndDateBrowser.m_bShowItemsAfterYearDecade = true;
  1209. m_wndDateBrowser.m_bShowItemsBeforeYearDecade = true;
  1210. }
  1211. else
  1212. {
  1213. m_wndDateBrowser.m_bShowItemsAfterYearDecade = false;
  1214. m_wndDateBrowser.m_bShowItemsBeforeYearDecade = false;
  1215. }
  1216. m_wndDateBrowser.Invalidate();
  1217. }
  1218. void CPageDateBrowser::OnCheckShowHoverEvents() 
  1219. {
  1220. m_wndDateBrowser.m_bShowHoverEvents = m_wndCheckShowHoverEventsInLogView.GetCheck() ? true : false;
  1221. }
  1222. #endif  // (!defined __EXT_MFC_NO_DATE_BROWSER )