XTPCalendarOptions.cpp
上传用户:szled88
上传日期:2015-04-09
资源大小:43957k
文件大小:7k
源码类别:

对话框与窗口

开发平台:

Visual C++

  1. // XTPCalendarOptions.cpp: implementation of the CXTPCalendarOptions class.
  2. //
  3. // This file is a part of the XTREME CALENDAR MFC class library.
  4. // (c)1998-2008 Codejock Software, All Rights Reserved.
  5. //
  6. // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE
  7. // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN
  8. // CONSENT OF CODEJOCK SOFTWARE.
  9. //
  10. // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED
  11. // IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO
  12. // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A
  13. // SINGLE COMPUTER.
  14. //
  15. // CONTACT INFORMATION:
  16. // support@codejock.com
  17. // http://www.codejock.com
  18. //
  19. /////////////////////////////////////////////////////////////////////////////
  20. #include "stdafx.h"
  21. #include "Resource.h"
  22. #include "Common/XTPVC50Helpers.h"
  23. #include "Common/XTPPropExchange.h"
  24. #include "Common/XTPNotifyConnection.h"
  25. #include "Common/XTPResourceManager.h"
  26. #include "XTPCalendarOptions.h"
  27. #include "XTPCalendarNotifications.h"
  28. #include "XTPCalendarData.h"
  29. #include "XTPCalendarMemoryDataProvider.h"
  30. #include "XTPCalendarDatabaseDataProvider.h"
  31. #include "XTPCalendarViewPart.h"
  32. #ifdef _DEBUG
  33. #define new DEBUG_NEW
  34. #undef THIS_FILE
  35. static char THIS_FILE[] = __FILE__;
  36. #endif
  37. //////////////////////////////////////////////////////////////////////////
  38. // void CXTPCalendarOptions
  39. IMPLEMENT_DYNAMIC(CXTPCalendarOptions, CCmdTarget)
  40. CXTPCalendarOptions::CXTPCalendarOptions()
  41. {
  42. // default settings
  43. nWorkWeekMask = xtpCalendarDayMo_Fr;
  44. nFirstDayOfTheWeek = xtpCalendarDayMonday;
  45. dtWorkDayStartTime.SetTime(8, 0, 0);
  46. dtWorkDayEndTime.SetTime(17, 0, 0);
  47. bEnableInPlaceEditEventSubject_ByF2 = TRUE;
  48. bEnableInPlaceEditEventSubject_ByMouseClick = TRUE;
  49. bEnableInPlaceEditEventSubject_ByTab = TRUE;
  50. bEnableInPlaceEditEventSubject_AfterEventResize = TRUE;
  51. bEnableInPlaceCreateEvent = TRUE;
  52. bUseOutlookFontGlyphs = FALSE;
  53. nDayView_ScaleInterval = 30;
  54. bDayView_AutoResetBusyFlag = TRUE;
  55. bDayView_Scale2Visible = FALSE;
  56. //strDayView_ScaleLabel;
  57. //strDayView_Scale2Label;
  58. ::ZeroMemory(&tziDayView_Scale2TimeZone, sizeof(tziDayView_Scale2TimeZone));
  59. VERIFY( ::GetTimeZoneInformation(&tziDayView_Scale2TimeZone) != TIME_ZONE_ID_INVALID);
  60. nDayView_CurrentTimeMarkVisible = xtpCalendarCurrentTimeMarkVisibleForToday;
  61. bDayView_TimeScaleShowMinutes = FALSE;
  62. bMonthView_CompressWeekendDays = TRUE;
  63. bMonthView_ShowEndDate = FALSE;
  64. bMonthView_ShowTimeAsClocks = FALSE;
  65. bWeekView_ShowEndDate = FALSE;
  66. bWeekView_ShowTimeAsClocks = FALSE;
  67. dwAdditionalOptions = 0;
  68. bEnableAddNewTooltip = TRUE;
  69. strTooltipAddNewText = XTPResourceManager()->LoadString(XTP_IDS_CALENDAR_CLICKTOADD);
  70. m_pDataProvider = NULL;
  71. }
  72. CXTPCalendarOptions::~CXTPCalendarOptions()
  73. {
  74. //CMDTARGET_RELEASE(m_pDataProvider);
  75. }
  76. void CXTPCalendarOptions::DoPropExchange(CXTPPropExchange* pPX)
  77. {
  78. long nSchema = 5;
  79. PX_Long(pPX, _T("Version"), nSchema, 5);
  80. PX_Int(pPX, _T("WorkWeekMask"), nWorkWeekMask, xtpCalendarDayMo_Fr);
  81. PX_Int(pPX, _T("FirstDayOfTheWeek"), nFirstDayOfTheWeek, xtpCalendarDayMonday);
  82. PX_DateTime(pPX, _T("WorkDayStartTime"), dtWorkDayStartTime);
  83. PX_DateTime(pPX, _T("WorkDayEndTime"), dtWorkDayEndTime);
  84. PX_Bool(pPX, _T("EnableInPlaceEditEventSubject_ByF2"), bEnableInPlaceEditEventSubject_ByF2, TRUE);
  85. PX_Bool(pPX, _T("EnableInPlaceEditEventSubject_ByMouseClick"), bEnableInPlaceEditEventSubject_ByMouseClick, TRUE);
  86. PX_Bool(pPX, _T("EnableInPlaceEditEventSubject_ByTab"), bEnableInPlaceEditEventSubject_ByTab, TRUE);
  87. PX_Bool(pPX, _T("EnableInPlaceEditEventSubject_AfterEventResize"), bEnableInPlaceEditEventSubject_AfterEventResize, TRUE);
  88. PX_Bool(pPX, _T("EnableInPlaceCreateEvent"), bEnableInPlaceCreateEvent, TRUE);
  89. if (nSchema >= 2)
  90. {
  91. PX_Bool(pPX, _T("UseOutlookFontGlyphs"), bUseOutlookFontGlyphs, FALSE);
  92. }
  93. else if (pPX->IsLoading())
  94. {
  95. bUseOutlookFontGlyphs = FALSE;
  96. }
  97. PX_Bool(pPX, _T("DayView_AutoResetBusyFlag"), bDayView_AutoResetBusyFlag, TRUE);
  98. PX_Int(pPX, _T("DayView_ScaleInterval"), nDayView_ScaleInterval, 30);
  99. PX_String(pPX, _T("DayView_ScaleLabel"), strDayView_ScaleLabel, _T(""));
  100. PX_String(pPX, _T("DayView_Scale2Label"), strDayView_Scale2Label, _T(""));
  101. PX_Bool(pPX, _T("DayView_Scale2Visible"), bDayView_Scale2Visible, FALSE);
  102. if (nSchema >= 3)
  103. {
  104. PX_Int(pPX, _T("DayView_CurrentTimeMarkVisible"), nDayView_CurrentTimeMarkVisible, xtpCalendarCurrentTimeMarkVisibleForToday);
  105. }
  106. else if (pPX->IsLoading())
  107. {
  108. nDayView_CurrentTimeMarkVisible = xtpCalendarCurrentTimeMarkVisibleForToday;
  109. }
  110. PX_Bool(pPX, _T("DayView_TimeScaleShowMinutes"), bDayView_TimeScaleShowMinutes, FALSE);
  111. BYTE* pTZIdata = (BYTE*)&tziDayView_Scale2TimeZone;
  112. DWORD dwBytes = sizeof(tziDayView_Scale2TimeZone);
  113. PX_Blob(pPX, _T("DayView_Scale2TimeZone"), pTZIdata, dwBytes);
  114. PX_Bool(pPX, _T("MonthView_CompressWeekendDays"), bMonthView_CompressWeekendDays, TRUE);
  115. PX_Bool(pPX, _T("MonthView_ShowEndDate"), bMonthView_ShowEndDate, FALSE);
  116. PX_Bool(pPX, _T("MonthView_ShowTimeAsClocks"), bMonthView_ShowTimeAsClocks, FALSE);
  117. PX_Bool(pPX, _T("WeekView_ShowEndDate"), bWeekView_ShowEndDate, FALSE);
  118. PX_Bool(pPX, _T("WeekView_ShowTimeAsClocks"), bWeekView_ShowTimeAsClocks, FALSE);
  119. if (nSchema >= 4)
  120. {
  121. PX_ULong(pPX, _T("AdditionalOptions"), (ULONG&)dwAdditionalOptions, 0);
  122. }
  123. else if (pPX->IsLoading())
  124. {
  125. dwAdditionalOptions = 0;
  126. }
  127. if (nSchema >= 5)
  128. {
  129. PX_Bool(pPX, _T("EnableAddNewTooltip"), bEnableAddNewTooltip, TRUE);
  130. CString strTooltipAddNewTextDef = XTPResourceManager()->LoadString(XTP_IDS_CALENDAR_CLICKTOADD);
  131. PX_String(pPX, _T("TooltipAddNewText"), strTooltipAddNewText, strTooltipAddNewTextDef);
  132. }
  133. }
  134. CXTPCalendarTimeZonePtr CXTPCalendarOptions::GetCurrentTimeZoneInfo()
  135. {
  136. TIME_ZONE_INFORMATION tziCurrent;
  137. ::ZeroMemory(&tziCurrent, sizeof(tziCurrent));
  138. if (::GetTimeZoneInformation(&tziCurrent) == TIME_ZONE_ID_INVALID)
  139. {
  140. ASSERT(FALSE);
  141. return NULL;
  142. }
  143. return CXTPCalendarTimeZone::GetTimeZoneInfo(&tziCurrent);
  144. }
  145. void CXTPCalendarOptions::OnOptionsChanged()
  146. {
  147. XTP_SAFE_CALL2(m_pDataProvider, GetConnection(), SendEvent(XTP_NC_CALENDAROPTIONSWASCHANGED, (WPARAM)-1, 0));
  148. }
  149. ///////////////////////////////////////////////////////////////////////////
  150. // Data part
  151. //
  152. void CXTPCalendarOptions::SetDataProvider(CXTPCalendarData* pDataProvider)
  153. {
  154. // free old data provider
  155. if (m_pDataProvider)
  156. {
  157. m_pDataProvider->SetOptionsToUpdate(NULL);
  158. }
  159. // set a new one
  160. if (pDataProvider)
  161. {
  162. m_pDataProvider = pDataProvider;
  163. if (m_pDataProvider)
  164. {
  165. m_pDataProvider->SetOptionsToUpdate(this);
  166. }
  167. }
  168. }
  169. /////////////////////////////////////////////////////////////////////////////