Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

396 lines
14 KiB

  1. #define CAL_COLOR_TODAY 0x000000ff
  2. #define CALMONTHMAX 12
  3. #define CALROWMAX 6
  4. #define CALCOLMAX 7
  5. #define CAL_DEF_SELMAX 7
  6. // BUGBUG raymondc - these metrics do not scale with user settings
  7. #define CALBORDER 6
  8. // The formulas for DX_ARROWMARGIN and D[XY]_CALARROW are chosen so on most
  9. // systems they come out approximately equal to the values you got
  10. // in IE4. (The IE4 values were hard-coded and therefore incompatible
  11. // with accessibility.)
  12. #define DX_ARROWMARGIN (5 * g_cxBorder)
  13. #define DX_CALARROW (g_cyHScroll * 4 / 3)
  14. #define DY_CALARROW g_cyHScroll
  15. #define DXRING_SPIRAL 8
  16. #define DXEDGE_SPIRAL 8
  17. // BUGBUG raymondc - msecautospin should scale on doubleclicktime
  18. #define CAL_MSECAUTOSPIN 350
  19. #define CAL_SECTODAYTIMER (2 * 60)
  20. #define CAL_IDAUTOSPIN 1
  21. #define CAL_TODAYTIMER 2
  22. #define CCHMAXMONTH 42
  23. #define CCHMAXABBREVDAY 11
  24. #define CCHMAXMARK 10
  25. #define SEL_BEGIN 1
  26. #define SEL_END 2
  27. #define SEL_DOT 3
  28. #define SEL_MID 4
  29. //
  30. // For each month we display, we have to compute a bunch of metrics
  31. // to track the stuff we put into the header area.
  32. //
  33. // The five values represent the following points in the string:
  34. //
  35. // Mumble January Mumble 1999 Mumble
  36. // | | | | |
  37. // | | MonthEnd | YearEnd
  38. // Start MonthStart YearStart
  39. //
  40. // Note that it is possible for YearStart to be less than MonthStart if the
  41. // year comes before the month. (e.g., "1999 January")
  42. //
  43. // These values already take RTL mirroring into account.
  44. //
  45. // NOTE! IMM_MONTHSTART and IMM_YEARSTART are also used as flags,
  46. // so they both need to be powers of 2.
  47. //
  48. #define IMM_START 0
  49. #define IMM_DATEFIRST 1
  50. #define IMM_MONTHSTART 1
  51. #define IMM_YEARSTART 2
  52. #define IMM_MONTHEND 3
  53. #define IMM_YEAREND 4
  54. #define IMM_DATELAST 4
  55. #define DMM_STARTEND 2 // Difference between START and END
  56. #define CCH_MARKERS 4 // There are four markers
  57. typedef struct MONTHMETRICS {
  58. int rgi[5];
  59. } MONTHMETRICS, *PMONTHMETRICS;
  60. // This stuff used to be global
  61. typedef struct tagLOCALEINFO {
  62. TCHAR szToday[32]; // "Today:"
  63. TCHAR szGoToToday[64]; // "&Go to today"
  64. TCHAR szMonthFmt[8]; // "MMMM"
  65. TCHAR szMonthYearFmt[16+CCH_MARKERS]; // "\1MMMM\3 \2yyyy\4" -- see MCInsertMarkers
  66. TCHAR rgszMonth[12][CCHMAXMONTH];
  67. TCHAR rgszDay[7][CCHMAXABBREVDAY];
  68. int dowStartWeek; // LOCALE_IFIRSTDAYOFWEEK (0 = mon, 1 = tue, 6 = sat)
  69. int firstWeek; // LOCALE_IFIRSTWEEKOFYEAR
  70. TCHAR *rgpszMonth[12]; // pointers into rgszMonth
  71. TCHAR *rgpszDay[7]; // pointers into rgszDay
  72. } LOCALEINFO, *PLOCALEINFO, *LPLOCALEINFO;
  73. //
  74. // SUBEDITCONTROL stuff
  75. //
  76. //
  77. // Note: SECIncrFocus assumes that SUBEDIT_NONE is numerical value -1
  78. //
  79. #define SUBEDIT_NONE -1 // no field is being edited
  80. #define SUBEDIT_ALL -2 // all fields are being edited (DTS_APPCANPARSE)
  81. enum {
  82. SE_ERA = 1,
  83. SE_YEAR,
  84. SE_YEARALT, // see SEGetTimeDateFormat
  85. SE_MONTH,
  86. SE_MONTHALT, // see SEGetTimeDateFormat
  87. SE_DAY,
  88. SE_DATELAST = SE_DAY,
  89. SE_MARK, // "AM" or "PM" indicator
  90. SE_HOUR,
  91. SE_MINUTE,
  92. SE_SECOND,
  93. SE_STATIC,
  94. SE_APP,
  95. SE_MAX
  96. };
  97. #define SE_YEARLIKE(s) ((s) == SE_YEAR || (s) == SE_YEARALT)
  98. #define SE_DATELIKE(s) InRange(s, SE_ERA, SE_DATELAST)
  99. #include <pshpack8.h>
  100. typedef struct tagSUBEDIT {
  101. int id; // SE_ value above
  102. RECT rc; // bounding box for display
  103. LPWORD pval; // current value (in a SYSTEMTIME struct)
  104. UINT min; // min value
  105. UINT max; // max value
  106. int cIncrement; // increment value
  107. int cchMax; // max allowed chars
  108. int cchEdit; // current number chars entered so far
  109. UINT valEdit; // value entered so far
  110. UINT flDrawText; // flags for DrawText
  111. LPCTSTR pv; // formatting string
  112. BOOL fReadOnly; // can this subedit be edited (receive focus)?
  113. } SUBEDIT, * PSUBEDIT, *LPSUBEDIT;
  114. #include <poppack.h>
  115. //
  116. // There are three types of calendars we support
  117. //
  118. // - Gregorian (Western). Any calendar not otherwise supported is forced
  119. // into Gregorian mode.
  120. //
  121. // - Offset. The year is merely a fixed offset from the Gregorian year.
  122. // This is the style used by the Korean and Thai calendars.
  123. //
  124. // - Era. The calendar consists of multiple eras, and the year is
  125. // relative to the start of the enclosing era. This is the style
  126. // used by the Japan and Taiwan calendars. Eras are strangest because
  127. // an era need not start on January 1!
  128. //
  129. typedef struct tagCALENDARTYPE {
  130. CALID calid; // Calendar id number (CAL_GREGORIAN, etc.)
  131. LCID lcid; // Usually LOCALE_USER_DEFAULT, but forced to US for unsupported calendars
  132. int dyrOffset; // The calendar offset (0 for Gregorian and Era)
  133. HDPA hdpaYears; // If fEra, then array of year info
  134. HDPA hdpaEras; // If fEra, then array of era names
  135. } CALENDARTYPE, *PCALENDARTYPE;
  136. #define BUDDHIST_BIAS 543
  137. #define KOREAN_BIAS 2333
  138. #define ISERACALENDAR(pct) ((pct)->hdpaEras)
  139. #define GregorianToOther(pct, yr) ((yr) + (pct)->dyrOffset)
  140. #define OtherToGregorian(pct, yr) ((yr) - (pct)->dyrOffset)
  141. typedef struct tagSUBEDITCONTROL {
  142. LPCONTROLINFO pci; // looks like this guy needs access to the hwnd
  143. BOOL fNone; // allow scrolling into SUBEDIT_NONE
  144. HFONT hfont; // font to draw text with
  145. RECT rc; // rect for subedits
  146. int xScroll; // amount pse array is scrolled
  147. int iseCur; // subedit with current selection (SUBEDIT_NONE for no selection)
  148. int cse; // count of subedits in pse array
  149. SYSTEMTIME st; // current time pse represents (pse points into this)
  150. LPTSTR szFormat; // format string as parsed (pse points into this)
  151. PSUBEDIT pse; // subedit array
  152. TCHAR cDelimeter; // delimiter between subedits (parsed from fmt string)
  153. TCHAR szDelimeters[15]; // delimiters between date/time fields (from resfile)
  154. CALENDARTYPE ct; // information about the calendar
  155. BITBOOL fMirrorSEC:1; // Whether or not to mirror the SubEditControls
  156. BITBOOL fSwapTimeMarker:1; // Whether we need to swap the AM/PM symbol around or not
  157. } SUBEDITCONTROL, * PSUBEDITCONTROL, *LPSUBEDITCONTROL;
  158. #define SECYBORDER 2
  159. #define SECXBORDER 2
  160. /*
  161. * Multiple Month Calendar Control
  162. */
  163. typedef struct tagMONTHCAL {
  164. CONTROLINFO ci; // all controls start with this
  165. LOCALEINFO li; // stuff that used to be global
  166. HINSTANCE hinstance;
  167. HWND hwndEdit; // non-NULL iff dealing with user-click on year
  168. HWND hwndUD; // UpDown control associated with the hwndEdit
  169. HPEN hpen;
  170. HPEN hpenToday;
  171. HFONT hfont; // stock font, don't destroy
  172. HFONT hfontBold; // created font, so we need to destroy
  173. COLORREF clr[MCSC_COLORCOUNT];
  174. int dxCol; // font info, based on bold to insure that we get enough space
  175. int dyRow;
  176. int dxMonth;
  177. int dyMonth;
  178. int dxYearMax;
  179. int dyToday;
  180. int dxToday;
  181. int dxArrowMargin;
  182. int dxCalArrow;
  183. int dyCalArrow;
  184. HMENU hmenuCtxt;
  185. HMENU hmenuMonth;
  186. SYSTEMTIME stMin; // minimum selectable date
  187. SYSTEMTIME stMax; // maximum selectable date
  188. DWORD cSelMax;
  189. SYSTEMTIME stToday;
  190. SYSTEMTIME st; // the selection if not multiselect
  191. // the beginning of the selection if multiselect
  192. SYSTEMTIME stEndSel; // the end of the selection if multiselect
  193. SYSTEMTIME stStartPrev; // prev selection beginning (only in multiselect)
  194. SYSTEMTIME stEndPrev; // prev selection end (only in multiselect)
  195. SYSTEMTIME stAnchor; // anchor date in shift-click selection
  196. SYSTEMTIME stViewFirst; // first visible date (DAYSTATE - grayed out)
  197. SYSTEMTIME stViewLast; // last visible date (DAYSTATE - grayed out)
  198. SYSTEMTIME stMonthFirst; // first month (stMin adjusted)
  199. SYSTEMTIME stMonthLast; // last month (stMax adjusted)
  200. int nMonths; // number of months being shown (stMonthFirst..stMonthLast)
  201. UINT_PTR idTimer;
  202. UINT_PTR idTimerToday;
  203. int nViewRows; // number of rows of months shown
  204. int nViewCols; // number of columns of months shown
  205. RECT rcPrev; // rect for prev month button (in window coords)
  206. RECT rcNext; // rect for next month button (in window coords)
  207. RECT rcMonthName; // rect for the month name (in relative coords)
  208. // (actually, the rect for the titlebar area of
  209. // each month).
  210. RECT rcDow; // rect for days of week (in relative coords)
  211. RECT rcWeekNum; // rect for week numbers (in relative coords)
  212. RECT rcDayNum; // rect for day numbers (in relative coords)
  213. int iMonthToday;
  214. int iRowToday;
  215. int iColToday;
  216. RECT rcDayCur; // rect for the current selected day
  217. RECT rcDayOld;
  218. RECT rc; // window rc.
  219. RECT rcCentered; // rect containing the centered months
  220. // The following 4 ranges hold info about the displayed (DAYSTATE) months:
  221. // They are filled in from 0 to nMonths+1 by MCUpdateStartEndDates
  222. // NOTE: These are _one_ based indexed arrays of the displayed months
  223. int rgcDay[CALMONTHMAX + 2]; // # days in this month
  224. int rgnDayUL[CALMONTHMAX + 2]; // last day in this month NOT visible when viewing next month
  225. int dsMonth; // first month stored in rgdayState
  226. int dsYear; // first year stored in rgdayState
  227. int cds; // number of months stored in rgdayState
  228. MONTHDAYSTATE rgdayState[CALMONTHMAX + 2];
  229. int nMonthDelta; // the amount to move on button press
  230. BOOL fControl;
  231. BOOL fShift;
  232. CALENDARTYPE ct; // information about the calendar
  233. WORD fFocus:1;
  234. WORD fEnabled:1;
  235. WORD fCapture:1; // mouse captured
  236. WORD fSpinPrev:1;
  237. WORD fFocusDrawn:1; // is focus rect currently drawn?
  238. WORD fToday:1; // today's date currently visible in calendar
  239. WORD fNoNotify:1; // don't notify parent window
  240. WORD fMultiSelecting:1; // Are we actually in the process of selecting?
  241. WORD fForwardSelect:1;
  242. WORD fFirstDowSet:1;
  243. WORD fTodaySet:1;
  244. WORD fMinYrSet:1; // stMin has been set
  245. WORD fMaxYrSet:1; // stMax has been set
  246. WORD fMonthDelta:1; // nMonthDelta has been set
  247. WORD fHeaderRTL:1; // Is header string RTL ?
  248. //
  249. // Metrics for each month we display.
  250. //
  251. MONTHMETRICS rgmm[CALMONTHMAX];
  252. } MONTHCAL, * PMONTHCAL, *LPMONTHCAL;
  253. #define MonthCal_GetPtr(hwnd) (MONTHCAL*)GetWindowPtr(hwnd, 0)
  254. #define MonthCal_SetPtr(hwnd, p) (MONTHCAL*)SetWindowPtr(hwnd, 0, p)
  255. #define MonthCal_IsMultiSelect(pmc) ((pmc)->ci.style & MCS_MULTISELECT)
  256. #define MonthCal_IsDayState(pmc) ((pmc)->ci.style & MCS_DAYSTATE)
  257. #define MonthCal_ShowWeekNumbers(pmc) ((pmc)->ci.style & MCS_WEEKNUMBERS)
  258. #define MonthCal_ShowTodayCircle(pmc) (!((pmc)->ci.style & MCS_NOTODAYCIRCLE))
  259. #define MonthCal_ShowToday(pmc) (!((pmc)->ci.style & MCS_NOTODAY))
  260. //
  261. // DATEPICK stuff
  262. //
  263. #define DPYBORDER 2
  264. #define DPXBUFFER 2
  265. #define DP_DXBUTTON 15
  266. #define DP_DYBUTTON 15
  267. #define DP_IDAUTOSPIN 1
  268. #define DP_MSECAUTOSPIN 200
  269. #define DATEPICK_UPDOWN 1000
  270. #define DTP_FORMATLENGTH 128
  271. enum {
  272. DP_SEL_DOW = 0,
  273. DP_SEL_YEAR,
  274. DP_SEL_MONTH,
  275. DP_SEL_DAY,
  276. DP_SEL_SEP1,
  277. DP_SEL_SEP2,
  278. DP_SEL_NODATE,
  279. DP_SEL_MAX
  280. };
  281. typedef struct tagDATEPICK {
  282. CONTROLINFO ci; // all controls start with this
  283. HWND hwndUD;
  284. HWND hwndMC;
  285. HFONT hfontMC; // font for drop down cal
  286. COLORREF clr[MCSC_COLORCOUNT];
  287. // HACK! stMin and stMax must remain in order and adjacent
  288. SYSTEMTIME stMin; // minimum date we allow
  289. SYSTEMTIME stMax; // maximum date we allow
  290. SYSTEMTIME stPrev; // most recent date notified
  291. SUBEDITCONTROL sec; // current date
  292. RECT rcCheck; // location of checkbox iff fShowNone
  293. RECT rc; // size of SEC space
  294. RECT rcBtn; // location of dropdown or updown
  295. int iseLastActive; // which subedit was active when we were last active?
  296. WPARAM gdtr; // Did app set min and/or max? (GDTR_MIN|GDTR_MAX)
  297. BITBOOL fEnabled:1;
  298. BITBOOL fUseUpDown:1;
  299. BITBOOL fFocus:1;
  300. BITBOOL fNoNotify:1;
  301. BITBOOL fCapture:1;
  302. BITBOOL fShow:1; // TRUE iff we should continue to show MonthCal
  303. BITBOOL fCheck:1; // TRUE iff the checkbox is checked
  304. BITBOOL fCheckFocus:1; // TRUE iff the checkbox has focus
  305. BITBOOL fLocale:1; // TRUE iff the format string is LOCALE dependent
  306. BITBOOL fHasMark:1; // true iff has am/pm in current format
  307. BITBOOL fFreeEditing:1; // TRUE if in the middle of a free-format edit
  308. } DATEPICK, * PDATEPICK, *LPDATEPICK;
  309. #define DatePick_ShowCheck(pdp) ((pdp)->ci.style & DTS_SHOWNONE)
  310. #define DatePick_AppCanParse(pdp) ((pdp)->ci.style & DTS_APPCANPARSE)
  311. #define DatePick_RightAlign(pdp) ((pdp)->ci.style & DTS_RIGHTALIGN)
  312. #define DatePick_GetPtr(hwnd) (DATEPICK*)GetWindowPtr(hwnd, 0)
  313. #define DatePick_SetPtr(hwnd, p) (DATEPICK*)SetWindowPtr(hwnd, 0, p)
  314. #define CopyDate(stS, stD) ((stD).wYear = (stS).wYear,(stD).wMonth = (stS).wMonth,(stD).wDay = (stS).wDay)
  315. #define CopyTime(stS, stD) ((stD).wHour = (stS).wHour,(stD).wMinute = (stS).wMinute,(stD).wSecond = (stS).wSecond)