📄 dateweek.c
字号:
} // end of WeekViewUpdateScrollers
/***********************************************************************
*
* FUNCTION: DrawTopDataMark
*
* DESCRIPTION: This routine draws a little mark above a given day's
* event bar.
*
* PARAMETERS: r - the bounds of the day
* scrool - true of the view can be scrolled winUp
* noTime - true of the day has untimed events.
*
* RETURNED: nothing
*
* REVISION HISTORY:
* Name Date Description
* ---- ---- -----------
* kcr 4/19/95 initial version
*
***********************************************************************/
static void DrawTopDataMark (RectanglePtr r, Boolean scroll, Boolean untimed)
{
Int16 x1, x2, y;
x1 = r->topLeft.x + dataMarkHMargin;
x2 = r->topLeft.x + r->extent.x - dataMarkHMargin;
y = r->topLeft.y + weekViewDayDisplayHeight +
weekViewDateDisplayHeight - dataMarkVMargin;
if (scroll)
{
// Draw the scroll indicators.
WinDrawLine (x1, y, x2, y);
if (untimed)
{
// Draw the no-time indicators.
WinDrawLine (x1, y-1, x1+1, y-1);
}
else
{
// Erase the no-time indicators.
WinEraseLine (x1, y-1, x1+1, y-1);
}
}
else
{
// Draw the no-time indicators and erase the scroll indicators.
if (untimed)
{
WinDrawLine (x1, y-1, x1+1, y-1);
WinDrawLine (x1, y, x1+1, y);
WinEraseLine (x1+2, y, x2, y);
}
// Erase both the scroll and no-time indicators.
else
{
WinEraseLine (x1, y-1, x1+1, y-1);
WinEraseLine (x1, y, x2, y);
}
}
} // end of DrawTopDataMark
#if 0
/***********************************************************************
*
* FUNCTION: DrawTopDataMark
*
* DESCRIPTION: This routine draws a little mark above a given day's
* event bar.
*
* PARAMETERS: RectanglePtr r - the bounds of the day
*
* RETURNED: nothing
*
* REVISION HISTORY:
* Name Date Description
* ---- ---- -----------
* kcr 10/3/95 initial version
*
***********************************************************************/
static void DrawTopDataMark (RectanglePtr r)
{
WinDrawLine (r->topLeft.x + dataMarkHMargin,
r->topLeft.y +
weekViewDayDisplayHeight +
weekViewDateDisplayHeight - dataMarkVMargin,
r->topLeft.x + r->extent.x - dataMarkHMargin,
r->topLeft.y +
weekViewDayDisplayHeight +
weekViewDateDisplayHeight - dataMarkVMargin);
} // end of DrawTopDataMark
/***********************************************************************
*
* FUNCTION: EraseTopDataMark
*
* DESCRIPTION: This routine erases a little mark above a given day's
* event bar.
*
* PARAMETERS: RectanglePtr r - the bounds of the day
*
* RETURNED: nothing
*
* REVISION HISTORY:
* Name Date Description
* ---- ---- -----------
* kcr 10/3/95 initial version
*
***********************************************************************/
static void EraseTopDataMark (RectanglePtr r)
{
WinEraseLine (r->topLeft.x + dataMarkHMargin,
r->topLeft.y +
weekViewDayDisplayHeight +
weekViewDateDisplayHeight - dataMarkVMargin,
r->topLeft.x + r->extent.x - dataMarkHMargin,
r->topLeft.y +
weekViewDayDisplayHeight +
weekViewDateDisplayHeight - dataMarkVMargin);
} // end of EraseTopDataMark
#endif
/***********************************************************************
*
* FUNCTION: DrawBottomDataMark
*
* DESCRIPTION: This routine draws a little mark below a given day's
* event bar.
*
* PARAMETERS: RectanglePtr r - the bounds of the day
*
* RETURNED: nothing
*
* REVISION HISTORY:
* Name Date Description
* ---- ---- -----------
* kcr 10/3/95 initial version
*
***********************************************************************/
static void DrawBottomDataMark (RectanglePtr r)
{
WinDrawLine (r->topLeft.x + dataMarkHMargin,
r->topLeft.y + r->extent.y + dataMarkVMargin,
r->topLeft.x + r->extent.x - dataMarkHMargin,
r->topLeft.y + r->extent.y + dataMarkVMargin);
} // end of DrawBottomDataMark
/***********************************************************************
*
* FUNCTION: EraseBottomDataMark
*
* DESCRIPTION: This routine erases a little mark below a given day's
* event bar.
*
* PARAMETERS: RectanglePtr r - the bounds of the day
*
* RETURNED: nothing
*
* REVISION HISTORY:
* Name Date Description
* ---- ---- -----------
* kcr 10/3/95 initial version
*
***********************************************************************/
static void EraseBottomDataMark (RectanglePtr r)
{
WinEraseLine (r->topLeft.x + dataMarkHMargin,
r->topLeft.y + r->extent.y + dataMarkVMargin,
r->topLeft.x + r->extent.x - dataMarkHMargin,
r->topLeft.y + r->extent.y + dataMarkVMargin);
} // end of EraseBottomDataMark
/***********************************************************************
*
* FUNCTION: WeekViewDrawDataMarks
*
* DESCRIPTION: This routine draws little marks above and below each
* day's event bar to show that there are more events
* in either direction for a given day.
*
* This routine must be broken out separately from the
* standard draw routine, because it must function even
* when a clip region is set for drawing while scrolling.
*
* PARAMETERS: nothing
*
* RETURNED: nothing
*
* REVISION HISTORY:
* Name Date Description
* ---- ---- -----------
* kcr 10/3/95 initial version
*
***********************************************************************/
static void WeekViewDrawDataMarks (void)
{
int i;
Boolean untimed;
WeekType *week;
ApptInfoPtr appts;
week = MemHandleLock (WeekObjectH);
for (i = 0; i < daysInWeek; i++)
{
// Check if the are any untimed apppoints. They'll be first in list
// of appointment if they exist.
untimed = false;
if (week->days[i].numAppts)
{
appts = MemHandleLock (week->days[i].apptsH);
untimed = (TimeToInt (appts[0].startTime) == apptNoTime);
MemPtrUnlock(appts);
}
DrawTopDataMark (&(week->days[i].bounds),
week->days[i].firstEventHour < week->startHour,
untimed);
// if (week->days[i].firstEventHour < week->startHour)
// DrawTopDataMark (&(week->days[i].bounds));
// else
// EraseTopDataMark (&(week->days[i].bounds));
if (week->days[i].lastEventHour > week->endHour)
DrawBottomDataMark (&(week->days[i].bounds));
else
EraseBottomDataMark (&(week->days[i].bounds));
}
MemPtrUnlock(week);
} // end of WeekViewDrawDataMarks
/***********************************************************************
*
* FUNCTION: WeekViewDrawDescription
*
* DESCRIPTION: This routine
*
* PARAMETERS:
*
* RETURNED: handle of a window that contains the bits obscured
* by the description.
*
* REVISION HISTORY:
* Name Date Description
* ---- ---- -----------
* kcr 3/28/96 Initial Revision
* kwk 07/07/99 Use WinDrawTruncChars.
* gap 10/25/00 Fix redraw problem in 24hour time.
*
***********************************************************************/
#define descWidthMax 20
static WinHandle WeekViewDrawDescription (TimePtr startTime, TimePtr endTime,
DatePtr date, Char * desc, Boolean saveBits)
{
UInt16 error;
UInt16 len;
UInt16 charsToDraw;
UInt16 charsToErase;
Char str [descWidthMax];
Int16 maxDescWidth;
Char * ptr;
Int16 x, y;
FontID curFont;
WinHandle winH = 0;
RectangleType r;
RectangleType eraseR;
curFont = FntSetFont (stdFont);
// Compute the bounds of the drawing region for the description.
WinGetWindowExtent (&r.extent.x, &r.extent.y);
r.topLeft.x = 0;
r.topLeft.y = 0;
r.extent.y = (FntLineHeight () * 2) + (weekDescMarginY * 3) + 3;
// Save the region that we're going to draw over.
if (saveBits)
{
AttnIndicatorEnable(false); // Get the indicator off before we save the bits
winH = WinSaveBits (&r, &error);
if (! winH) return (0);
// Erase and frame the drawing region with a 3D frame.
WinEraseRectangle (&r, 0);
r.topLeft.x++;
r.topLeft.y++;
r.extent.x -= 3;
r.extent.y -= 3;
WinDrawRectangleFrame (popupFrame , &r);
}
else
{
r.topLeft.x++;
r.topLeft.y++;
r.extent.x -= 3;
r.extent.y -= 3;
}
// Format and draw the appointments date.
if (date)
{
DateToDOWDMFormat (date->month, date->day, date->year + firstYear,
ShortDateFormat, str);
x = r.topLeft.x + weekDescMarginX;
y = r.topLeft.y + weekDescMarginY;
WinDrawChars (str, StrLen (str), x, y);
charsToErase = 0;
if (date->month >= 1 && date->month <= 9)
charsToErase++;
if (date->day >= 1 && date->day <= 9)
charsToErase++;
// I don't know how mush wider the old day-name was than
// day-name just drawn, so I'll erase the width of two chatacter
// just to be save.
eraseR.topLeft.x = x + FntCharsWidth (str, StrLen (str));
eraseR.topLeft.y = y;
eraseR.extent.x = FntAverageCharWidth () * 2 +
FntCharWidth ('1') * charsToErase;
eraseR.extent.y = FntLineHeight ();
WinEraseRectangle (&eraseR, 0);
}
// Format and draw the appointments start and end times
if (startTime && endTime)
{
TimeToAscii (startTime->hours, startTime->minutes,
TimeFormat, str);
len = StrLen (str);
str[len++] = spaceChr;
str[len++] = '-';
str[len++] = spaceChr;
TimeToAscii (endTime->hours, endTime->minutes,
TimeFormat, &str[len]);
x = r.topLeft.x + (r.extent.x - weekDescMarginX -
FntCharsWidth (str, StrLen (str)));
y = r.topLeft.y + weekDescMarginY;
charsToErase = 0;
if ((startTime->hours >= 0 && startTime->hours <= 9) ||
(startTime->hours >= 13 && startTime->hours <= 21))
charsToErase++;
if ((endTime->hours >= 0 && endTime->hours <= 9) ||
(endTime->hours >= 13 && endTime->hours <= 21))
charsToErase++;
if (charsToErase)
{
eraseR.topLeft.x = x - (FntCharWidth ('1') * charsToErase);
eraseR.topLeft.y = y;
eraseR.extent.x = x - eraseR.topLeft.x;
eraseR.extent.y = FntLineHeight ();
WinEraseRectangle (&eraseR, 0);
}
WinDrawChars (str, StrLen (str), x, y);
}
// Draw the appointment's desciption.
if (desc)
{
//DOLATER - peter: Add argument to this routine to specify
// whether record is masked, and use here to draw mask instead
// of description. Do this only if
// UNMASK_PRIVATE_RECORDS_IN_WEEK_VIEW is false.
x = r.topLeft.x + weekDescMarginX;
y = r.topLeft.y + (weekDescMarginY << 1) + FntLineHeight();
maxDescWidth = r.extent.x - x - weekDescMarginX;
ptr = StrChr (desc, linefeedChr);
charsToDraw = (ptr == NULL ? StrLen (desc) : ptr - desc);
WinDrawTruncChars(desc, charsToDraw, x, y, maxDescWidth);
}
FntSetFont (curFont);
return (winH);
}
/***********************************************************************
*
* FUNCTION: WeekViewScroll
*
* DESCRIPTION: This routine scrolls the Week View in the direction
* specified. It is assumed that there is room to scroll
* in the specified direction. If there is not, the
* scroll operation will just redraw the screen in place.
*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -