daysInWeek is defined in DateTime.h.
-----Original Message-----
From: mlv srinivas [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 20, 2002 11:37 AM
To: Palm Developer Forum
Subject: Accessing DateBook
Hello All,
I want to impelment the Datebook functionality in my application.I tried to work on it
using the example of Datebook from SDK4.0,I'm able to display the
look&feel of month view, while I'm trying to display the month name, today's
date in the form it is looking for the value of "daysInWeek", how can I get this
value,I tried the value by passing 7 , but it fails please any one
help.
Thanks in Advance
Srini
my code is as follows:
MonthViewFormInit (FormType *frm)
{
UInt16 objIndex;
Int16 width;
MonthPtr monthP;
Int16 drawX, drawY;
Int16 cellWidth, cellHeight;
Int16 charWidth;
Int16 lastDay;
Char dowTemplate[] = "^1s";
Char dayInAscii[3];
UInt16 dow;
UInt16 i;
Int16 x, y;
DateTimeType today;
RectangleType r;
UInt8 dayOfWeek;
Char * dayLabels;
UInt16 labelLength;
Char* label;
RGBColorType colorLine; //
Color to draw week and month view lines
in
WinPushDrawState();
WinSetBackColor(UIColorGetTableEntryIndex(UIFormFill));
WinSetForeColor(UIColorGetTableEntryIndex(UIObjectForeground));
WinSetTextColor(UIColorGetTableEntryIndex(UIObjectForeground));
FntSetFont (boldFont);
// Create a month object, initialize it, and store a pointer to it in the
// month gadget of the Month View.
monthP = MemPtrNew (sizeof (MonthType));
// DrawMonth (monthP, drawDaySelected);
// DrawMonth (monthP, true);
// Make sure the "unselectable" parts of the MonthView are
// drawn in the proper colors first.
WinEraseRectangle (&monthP->bounds, 0);
//cellWidth = monthP->bounds.extent.x / daysInWeek;
//cellHeight = monthP->bounds.extent.y / linesInMonthPlusTitle;
cellWidth =18;
cellHeight=12;
// Get the resource that contains the first letter of each day.
dayLabels = MemHandleLock (DmGetResource (strRsc,
DaysofweekinitialsString));
// Calculate length of one item in string */
labelLength = StrLen (dayLabels) / daysInWeek;
//labelLength = StrLen (dayLabels) / 5;
// Draw the days of the week labels right justified to the number
columns
// Be sure to draw the labels with respect to current setting of
StartDayOfWeek. Somes locales
// consider Monday the first day while others use Sunday. There is also a
user preference
// selection in Prefs app/Formats panelthat will allow the user to change
first day of week.
//drawY = monthP->bounds.topLeft.y + (cellHeight - FntLineHeight()) / 2;
drawY =20;
drawX=30; // for the text on the above SMTWTFS
for (i = 0; i <= daysInWeek; i++)
{
dayOfWeek = (i + StartDayOfWeek) % daysInWeek;
label = &dayLabels[labelLength * dayOfWeek];
//drawX = monthP->bounds.topLeft.x + (cellWidth * i) + ((cellWidth -
FntCharsWidth (label, labelLength)) / 2);
WinDrawChars (label, labelLength, drawX, drawY);
drawX =drawX+16;
}
// Unlock the day of week label resource now that we are done with it.
MemPtrUnlock (dayLabels);
// Set the background color behind the grid in control-style colors since
// the grid is selectable.
WinSetBackColor(UIColorGetTableEntryIndex(UIObjectFill));
RctCopyRectangle(&monthP->bounds, &r);
r.topLeft.y += cellHeight;
r.extent.y -= cellHeight;
WinEraseRectangle (&r, 0);
// Draw the grid. Change the foreground color temporarily to get the right
effect,
// and put it back when we're done.
WinSetForeColor(WinRGBToIndex(&colorLine));
//x = monthP->bounds.topLeft.x;
//y = monthP->bounds.topLeft.y + cellHeight;
// table moments
x=28;
y=40;
for (i = 0; i < daysInWeek + 1; i++)
{
WinDrawLine (x, y, x, y + (cellHeight * maxWeeksInMonth));
x += cellWidth;
}
x = monthP->bounds.topLeft.x;
for (i = 0; i < maxWeeksInMonth + 1; i++)
{
WinDrawLine (x, y, x + (cellWidth * daysInWeek) , y);
y += cellHeight;
}
WinSetForeColor(UIColorGetTableEntryIndex(UIObjectForeground));
// Draw the days of the month.
FntSetFont (stdFont);
charWidth = FntCharWidth('0');
dow = FirstDayOfMonth (monthP);
//drawX = monthP->bounds.topLeft.x + (dow * cellWidth) + textLeftMargin;
//drawY = monthP->bounds.topLeft.y + cellHeight + textTopMargin;
lastDay = DaysInMonth(monthP->month, monthP->year);
for (i=1; i <= lastDay; i++, dow++)
{
if (dow == daysInWeek)
{
drawX = monthP->bounds.topLeft.x + textLeftMargin;
drawY += cellHeight;
dow = 0;
}
StrIToA (dayInAscii, i);
WinDrawChars (dayInAscii,
(i < 10) ? 1 : 2,
// (i < 10) ? drawX + charWidth : drawX,
drawX,
drawY);
drawX += cellWidth;
}
// Display a rectangle around today's day if it's visible.
//TimSecondsToDateTime(TimGetSeconds(), &today);
/*
if (TodayIsVisible(monthP, today) && selectDay)
{
GetDaySelectionBounds(monthP, today.day, &r);
MonthDrawInversionEffect (&r, 0);
}
*/
// DrawAppointmentsInMonth (monthP);
WinPopDrawState ();
}
_________________________________________________________________
MSN 8 with e-mail virus protection service: 3 months FREE*.
http://join.msn.com/?page=features/virus&xAPID=42&PS=47575&PI=7324&DI=7474&SU=
http://www.hotmail.msn.com/cgi-bin/getmsg&HL=1216hotmailtaglines_eliminateviruses_3mf
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/
------------------------------------------
The information in this transmittal and any attachments is privileged and confidential
and is intended only for the recipient(s) listed above. You are hereby notified that
any unauthorized distribution or copying of this transmittal or its attachments is
prohibited. If you have received this transmittal in error, please notify Invivodata
immediately at (831) 438-9550.
------------------------------------------
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/