int main()
{
    Date d(2008,Date::feb,23);
    bool b = next_Sunday(d) != next_weekday(d);
    Chrono::Date dd;
    return 0;
}
Example #2
0
ERRORCODE Calendar::build_monthly(CTextStyle* pTitleStyle)
{
	PBOX r;
	SHORT i;
	COLOR shadow_color = 0;
	SHORT shadow_pattern = 0;
	ALIGN_TYPE h_align;
	VERT_ALIGN_TYPE v_align;
	SHORT day, week;
//	WEEKDAY weekday;
	SHORT weekday;
	CHAR buffer[45];
	GroupObjectPtr skeleton_group, date_group, text_group, graphic_group;
	BOOL stop_looking;
	ERRORCODE error;
	CTextStyle text_style(database);
	FontServerPtr font_server = database->get_font_server();

/* Compute shadow parameter. */

	if (has_shadow)
	{
	/* Set the shadow color. */

		switch (get_info().style.shadow_style)
		{
			case CAL_SHADOW_BLACK:
			case CAL_SHADOW_GRAY:
			case CAL_SHADOW_LIGHT_GRAY:
			{
				shadow_color = COLOR_BLACK;
				break;
			}
			case CAL_SHADOW_100:
			case CAL_SHADOW_50:
			case CAL_SHADOW_25:
			{
				shadow_color = get_info().style.color;
				break;
			}
			default:
			{
				return ERRORCODE_IntError;
			}
		}

	/* Set the shadow pattern. */

		switch (get_info().style.shadow_style)
		{
			case CAL_SHADOW_BLACK:
			case CAL_SHADOW_100:
			{
				shadow_pattern = 0;
				break;
			}
			case CAL_SHADOW_GRAY:
			case CAL_SHADOW_50:
			{
				shadow_pattern = 50;
				break;
			}
			case CAL_SHADOW_LIGHT_GRAY:
			case CAL_SHADOW_25:
			{
				shadow_pattern = 75;
				break;
			}
			default:
			{
				return ERRORCODE_IntError;
			}
		}
	}

/* Create the groups. */

	if (!build_calendar_groups(&skeleton_group, &date_group,
								&graphic_group, &text_group))
	{
		return ERRORCODE_Memory;
	}

/* Add a default calendar title. */

	if ((error = add_title(skeleton_group->object_list(), pTitleStyle)) != ERRORCODE_None)
	{
		return error;
	}

/* Draw the label. */

	switch (get_info().style.label_style)
	{
		case CAL_LABEL_TEXT:
		{
			break;
		}
		case CAL_LABEL_BOXED:
		{
			if ((error = add_box(&label, 0, get_info().style.color, LABEL_PANEL, line_thickness, skeleton_group->object_list())) != ERRORCODE_None)
			{
				return error;
			}
			break;
		}
		case CAL_LABEL_INVERTED:
		{
			if ((error = add_line(&label, 0, get_info().style.color, LABEL_PANEL, skeleton_group->object_list())) != ERRORCODE_None)
			{
				return error;
			}
			break;
		}
		default:
		{
			break;
		}
	}

/* Draw the calendar frame. */

	if (has_border)
	{
	/*
	// Draw calendar with outline.
	*/

	/* Draw the outline. */

		if ((error = add_box(&bound, 0, get_info().style.color, SKELETON_PANEL, line_thickness, skeleton_group->object_list())) != ERRORCODE_None)
		{
			return error;
		}

	/* Draw the horizontal lines. */

		switch (get_info().style.line_style)
		{
			case CAL_LINES_ALL:
			{
			/* Draw vertical lines. */

				r.y0 = bound.y0;
				r.y1 = bound.y1;
				r.x0 = bound.x0 + cell_width;
				for (weekday = (WEEKDAY)1; weekday < days_in_week; weekday++)
				{
					r.x1 = r.x0 + line_thickness;
					if ((error = add_line(&r, 0, get_info().style.color, SKELETON_PANEL, skeleton_group->object_list())) != ERRORCODE_None)
					{
						return error;
					}
					r.x0 += cell_width;
				}

			/* Fall through to... */
			}
			case CAL_LINES_HORIZONTAL:
			{
			/* Draw horizontal lines. */

				r.x0 = bound.x0;
				r.x1 = bound.x1;
				r.y0 = bound.y0 + cell_height;
				for (week = 1; week < weeks_in_month; week++)
				{
					r.y1 = r.y0 + line_thickness;
					if ((error = add_line(&r, 0, get_info().style.color, SKELETON_PANEL, skeleton_group->object_list())) != ERRORCODE_None)
					{
						return error;
					}
					r.y0 += cell_height;
				}
				break;
			}
			default:
			{
				break;
			}
		}

		if (has_shadow)
		{
		/* Right piece. */

			r.x0 = bound.x1;
			r.x1 = r.x0 + shadow_thickness;
			r.y0 = (has_label ? label.y0 : bound.y0)+shadow_thickness;
			r.y1 = bound.y1+shadow_thickness;
			if ((error = add_line(&r, shadow_pattern, shadow_color, SHADOW_PANEL, skeleton_group->object_list())) != ERRORCODE_None)
			{
				return error;
			}

		/* Bottom piece. */

			r.x0 = bound.x0+shadow_thickness;
			r.x1 = bound.x1+shadow_thickness;
			r.y0 = bound.y1;
			r.y1 = r.y0 + shadow_thickness;
			if ((error = add_line(&r, shadow_pattern, shadow_color, SHADOW_PANEL, skeleton_group->object_list())) != ERRORCODE_None)
			{
				return error;
			}
		}
	}
	else
	{
	/*
	// Draw calendar without outline.
	*/

	/* Draw the horizontal lines. */

		switch (get_info().style.line_style)
		{
			case CAL_LINES_ALL:
			{
			/* Draw vertical lines. */

				r.x0 = bound.x0;

				for (weekday = (WEEKDAY)0; weekday <= days_in_week; weekday++)
				{
					r.y0 = bound.y0;
					r.y1 = bound.y1;

					if (weekday < skewed_first_day)
					{
						r.y0 += cell_height;
					}
					if (weekday > skewed_last_day+1)
					{
						r.y1 -= cell_height;
					}

					r.x1 = r.x0 + line_thickness;
					if ((error = add_line(&r, 0, get_info().style.color, SKELETON_PANEL, skeleton_group->object_list())) != ERRORCODE_None)
					{
						return error;
					}
					r.x0 += cell_width;
				}

			/* Fall through to... */
			}
			case CAL_LINES_HORIZONTAL:
			{
			/* Draw horizontal lines. */

				r.x0 = bound.x0;
				r.x1 = bound.x1;
				r.y0 = bound.y0;

				for (week = 0; week <= weeks_in_month; week++)
				{
					if (get_info().style.line_style == CAL_LINES_ALL)
					{
						r.x0 = bound.x0;
						r.x1 = bound.x1;

						if (week == 0)
						{
							r.x0 += skewed_first_day*cell_width;
						}
						if (week == weeks_in_month)
						{
							r.x1 -= (days_in_week-(skewed_last_day+1))*cell_width;
						}
					}

					r.y1 = r.y0 + line_thickness;
					if ((error = add_line(&r, 0, get_info().style.color, SKELETON_PANEL, skeleton_group->object_list())) != ERRORCODE_None)
					{
						return error;
					}
					r.y0 += cell_height;
				}
				break;
			}
			default:
			{
				break;
			}
		}

		if (has_shadow)
		{
			BOOL full_shadow = skewed_last_day+1 == days_in_week;

		/* Right piece. */

			r.x0 = bound.x1;
			r.x1 = r.x0 + shadow_thickness;
			r.y0 = (has_label ? label.y0 : bound.y0)+shadow_thickness;
			r.y1 = bound.y1+shadow_thickness;
			if (!full_shadow)
			{
				r.y1 -= cell_height;
			}
			if ((error = add_line(&r, shadow_pattern, shadow_color, SHADOW_PANEL, skeleton_group->object_list())) != ERRORCODE_None)
			{
				return error;
			}

			if (!full_shadow)
			{
			/* Mid horizontal piece. */

				r.y0 = r.y1 - shadow_thickness;
				r.x0 = bound.x1 - (days_in_week-(skewed_last_day+1))*cell_width;
				if ((error = add_line(&r, shadow_pattern, shadow_color, SHADOW_PANEL, skeleton_group->object_list())) != ERRORCODE_None)
				{
					return error;
				}

			/* Mid vertical piece. */

				r.x1 = r.x0 + shadow_thickness;
				r.y1 = bound.y1 + shadow_thickness;
				if ((error = add_line(&r, shadow_pattern, shadow_color, SHADOW_PANEL, skeleton_group->object_list())) != ERRORCODE_None)
				{
					return error;
				}
			}

		/* Bottom piece. */

			r.x0 = bound.x0+shadow_thickness;
			r.y0 = bound.y1;
			if ((error = add_line(&r, shadow_pattern, shadow_color, SHADOW_PANEL, skeleton_group->object_list())) != ERRORCODE_None)
			{
				return error;
			}

		/* Draw the label shadow if it has a label. */

			if (has_label)
			{
			/* Bottom of label where there is no calendar. */

				r.y0 = label.y1;
				r.x0 = label.x0 + shadow_thickness;
				r.x1 = label.x1 + shadow_thickness;

				r.y1 = r.y0 + shadow_thickness;
				if ((error = add_line(&r, shadow_pattern, shadow_color, SHADOW_PANEL, skeleton_group->object_list())) != ERRORCODE_None)
				{
					return error;
				}

			/* Little white gap in shadow on right. */

				r.x0 = label.x1;
				r.y0 = label.y1 + shadow_thickness;
				r.y1 = r.y0 + 3*shadow_thickness/2;
				/* 100 == white */
				if ((error = add_line(&r, 100, shadow_color, SHADOW_PANEL, skeleton_group->object_list())) != ERRORCODE_None)
				{
					return error;
				}
			}
		}
	}

/*
// Draw the calendar text.
*/

/* Draw the label text. */

	r.y0 = label.y0;
	r.x0 = label.x0;
	r.y1 = label.y1;

	m_LabelFontStyle.Size(MakeFixed(heading_size));
	m_LabelFontStyle.BaseSize(MakeFixed(heading_size));

/*
// Calculate the size of the text for these labels.
// If the text falls outside the frame, keep making it smaller.
*/

	for (stop_looking = FALSE; !stop_looking;)
	{
		BOOL too_big = FALSE;

		m_LabelFontStyle.UpdateFontMetrics();

		for (weekday = get_info().first_day_of_week, i = 0;
							i < days_in_week && !too_big;
	 						i++, weekday = next_weekday(weekday))
		{
			// CHAR *p;
			TCHAR *p;
			PCOORD size;

#ifdef LOCALIZE
			CurrentLocale.WeekDayName((WEEKDAY) weekday, buffer, sizeof(buffer));
#else
			// JRO strcpy(buffer, weekday_name[weekday]);
			strcpy(buffer, GET_PMWAPP()->GetResourceStringPointer (weekday_name_id[weekday]));
#endif


			switch (get_info().style.weekday_style)
			{
				case WEEKDAY_STYLE_INITIALS:
				{
					buffer[1] = '\0';
					break;
				}
				case WEEKDAY_STYLE_ABBREV:
				{
#ifdef LOCALIZE
					CurrentLocale.AbbrevWeekDayName((WEEKDAY)weekday, buffer, sizeof(buffer));
#else
					buffer[3] = '\0';
#endif
					break;
				}
				default:
				{
					break;
				}
			}

		/* Compute the size for the text. */

			for (size = 0, p = buffer; *p != '\0'; )
			{
				size += font_server->GetAdvanceWidth(&m_LabelFontStyle, (CHARACTER)*p);
				p = CharNext(p);
			}

		/* See if we are too big. */

			if (size > cell_width)
			{
				int nNewSize = (int)scale_pcoord(FixedInteger(m_LabelFontStyle.Size()), cell_width, size);
				CFixed lNewSize = MakeFixed(nNewSize);
				m_LabelFontStyle.Size(lNewSize);
				m_LabelFontStyle.BaseSize(lNewSize);
				too_big = TRUE;
				if (lNewSize < MINIMUM_LABEL_POINT_SIZE)
				{
					m_LabelFontStyle.Size(MakeFixed(MINIMUM_LABEL_POINT_SIZE));
					m_LabelFontStyle.BaseSize(MakeFixed(MINIMUM_LABEL_POINT_SIZE));
					m_LabelFontStyle.UpdateFontMetrics();

					stop_looking = TRUE;
				}
			}
		}
		if (!too_big)
		{
		/* All done! */
			stop_looking = TRUE;
		}
	}

	m_LabelFontStyle.Alignment(ALIGN_center);
	m_LabelFontStyle.UpdateFontMetrics();

	text_style = m_LabelFontStyle;

	if (get_info().style.label_style == CAL_LABEL_INVERTED)
	{
		if (text_style.FillForegroundColor() == get_info().style.color
					&& text_style.FillPattern() == 0)
		{
			text_style.FillForegroundColor(COLOR_WHITE);
		}
	}
	else
	{
		if (text_style.FillForegroundColor() == COLOR_WHITE)
		{
			text_style.FillForegroundColor(COLOR_BLACK);
		}
	}

	ObjectListPtr skeleton_list = skeleton_group->object_list();

	for (weekday = get_info().first_day_of_week, i = 0;
									i < days_in_week;
 									i++, weekday = next_weekday(weekday))
	{
#ifdef LOCALIZE
		CurrentLocale.WeekDayName((WEEKDAY)weekday, buffer, sizeof(buffer));
#else
		// JRO strcpy(buffer, weekday_name[weekday]);
      strcpy(buffer, GET_PMWAPP()->GetResourceStringPointer (weekday_name_id[weekday]));
#endif

		switch (get_info().style.weekday_style)
		{
			case WEEKDAY_STYLE_INITIALS:
			{
				buffer[1] = '\0';
				break;
			}
			case WEEKDAY_STYLE_ABBREV:
			{
#ifdef LOCALIZE
				CurrentLocale.AbbrevWeekDayName((WEEKDAY)weekday, buffer, sizeof(buffer));
#else
				buffer[3] = '\0';
#endif
				break;
			}
			default:
			{
				break;
			}
		}

	/* Add a frame for the next string. */

		r.x1 = r.x0 + cell_width;
		if ((error = add_frame(&r,
 							buffer,
 							ALIGN_center,
 							ALIGN_middle,
 							LABEL_FRAME_PANEL+i,
 							0,
							0,
 							skeleton_list,
							OBJECT_TYPE_Frame,
							&text_style)) != ERRORCODE_None)
		{
			return error;
		}
		PMGPageObjectPtr object = (PMGPageObjectPtr)skeleton_list->last_object();
		object->add_flags(OBJECT_FLAG_locked);
		r.x0 += cell_width;
	}

/* We want the point size to be 1/6 the height of a cell. */

	r.y0 = bound.y0;
	r.y1 = r.y0 + cell_height;
	r.x0 = bound.x0 + skewed_first_day*cell_width;
	r.x1 = r.x0 + cell_width;

	SHORT size;

	if (get_info().style.line_style == CAL_LINES_NONE)
	{
		h_align = ALIGN_center;
		v_align = ALIGN_middle;
	}
	else
	{
		h_align = ALIGN_right;
		v_align = ALIGN_top;
	}

	// font size needs to be larger to be legible on a yearly calendar
	short type = get_info().style.type;
	if (type == YEARLY)
	{
		PCOORD height = (bound.y1 - bound.y0 - line_thickness)/5;
		size = (SHORT)scale_pcoord(height, 72/4, PAGE_RESOLUTION);
	}
	else
		size = (SHORT)scale_pcoord(cell_height, 72/6, PAGE_RESOLUTION);

	m_NumberFontStyle.BaseSize(MakeFixed(size));
	m_NumberFontStyle.Size(MakeFixed(size));

	m_NumberFontStyle.Alignment(h_align);
	m_NumberFontStyle.UpdateFontMetrics();

	for (i = DATE_PANEL, weekday = skewed_first_day, day = first_day_of_month;
									i < last_day_of_month+DATE_PANEL;
									i++, day++)
	{
		itoa(day, buffer, 10);

		if ((error = add_frame(&r,
 					buffer,
 					h_align,
 					v_align,
 					i,
					0,
					SELECT_FLAG_boundary | SELECT_FLAG_drag_handle | SELECT_FLAG_solo_select,
 					date_group->object_list(),
					OBJECT_TYPE_CalendarDate,
					&m_NumberFontStyle)) != ERRORCODE_None)
		{
			return error;
		}

		if (++weekday == days_in_week)
		{
			weekday = (WEEKDAY)0;

#if 0
			r.x0 = bound.x0 + 1;
			r.x1 = r.x0 + cell_width - 2;
#else
			r.x0 = bound.x0;
			r.x1 = r.x0 + cell_width;
//			r.x0 += line_thickness + line_thickness;
#endif

			r.y0 += cell_height;
			r.y1 += cell_height;
			day += DAYS_IN_FULL_WEEK - days_in_week;
		}
		else
		{
			r.x0 += cell_width;
			r.x1 += cell_width;
		}

	/* If this is the unusual month, fix the day now. */

		if (get_info().year == 1752
					&& get_info().month == SEPTEMBER
					&& day == 2)
		{
			day = 13;
		}
	}
	skeleton_group->establish();
	date_group->establish();
	text_group->establish();
	graphic_group->establish();

//	printf("Objects created: %d\n", listlen(CurrentDocument->CurrentList));
	return ERRORCODE_None;
}
Example #3
0
ERRORCODE Calendar::build_weekly(CTextStyle* pTitleStyle)
{
	COLOR shadow_color = 0;
	SHORT shadow_pattern = 0;
	PBOX r;
	CHAR buffer[45];
//	WEEKDAY weekday;
	SHORT weekday;
	SHORT i, day;
	PCOORD label_width;
	BOOL stop_looking;
	GroupObjectPtr skeleton_group, date_group, text_group, graphic_group;
	ERRORCODE error;
	CTextStyle text_style(database);
	FontServerPtr font_server = database->get_font_server();

/* Compute shadow parameter. */

	if (has_shadow)
	{
	/* Set the shadow color. */

		switch (get_info().style.shadow_style)
		{
			case CAL_SHADOW_BLACK:
			case CAL_SHADOW_GRAY:
			case CAL_SHADOW_LIGHT_GRAY:
			{
				shadow_color = COLOR_BLACK;
				break;
			}
			case CAL_SHADOW_100:
			case CAL_SHADOW_50:
			case CAL_SHADOW_25:
			{
				shadow_color = get_info().style.color;
				break;
			}
			default:
			{
				return ERRORCODE_IntError;
			}
		}

	/* Set the shadow pattern. */

		switch (get_info().style.shadow_style)
		{
			case CAL_SHADOW_BLACK:
			case CAL_SHADOW_100:
			{
				shadow_pattern = 0;
				break;
			}
			case CAL_SHADOW_GRAY:
			case CAL_SHADOW_50:
			{
				shadow_pattern = 50;
				break;
			}
			case CAL_SHADOW_LIGHT_GRAY:
			case CAL_SHADOW_25:
			{
				shadow_pattern = 75;
				break;
			}
			default:
			{
				return ERRORCODE_IntError;
			}
		}
	}

/* Create the groups. */

	if (!build_calendar_groups(&skeleton_group, &date_group,
								&graphic_group, &text_group))
	{
		return ERRORCODE_Memory;
	}

/* Add a title to the calendar. */

	if ((error = add_title(skeleton_group->object_list(), pTitleStyle)) != ERRORCODE_None)
	{
		return error;
	}

	if (has_border)
	{
		if ((error = add_box(&bound, 0, get_info().style.color, SKELETON_PANEL, line_thickness, skeleton_group->object_list())) != ERRORCODE_None)
		{
			return error;
		}
	}

	switch (get_info().style.label_style)
	{
		case CAL_LABEL_TEXT:
		{
			break;
		}
		case CAL_LABEL_BOXED:
		{
			if ((error = add_box(&label, 0, get_info().style.color, LABEL_PANEL, line_thickness, skeleton_group->object_list())) != ERRORCODE_None)
			{
				return error;
			}
			break;
		}
		case CAL_LABEL_INVERTED:
		{
			if ((error = add_line(&label, 0, get_info().style.color, LABEL_PANEL, skeleton_group->object_list())) != ERRORCODE_None)
			{
				return error;
			}
			break;
		}
		default:
		{
			break;
		}
	}

/* Draw the horizontal lines. */

	switch (get_info().style.line_style)
	{
		case CAL_LINES_ALL:
		case CAL_LINES_HORIZONTAL:
		{
		/* Draw horizontal lines. */

			r.x0 = bound.x0;
			r.x1 = bound.x1;

			if (get_info().style.label_style == CAL_LABEL_INVERTED)
			{
				r.x0 = label.x1;
			}

			r.y0 = bound.y0;

			for (i = 0; i <= days_in_week; i++)
			{
				r.y1 = r.y0 + line_thickness;
				if ((error = add_line(&r, 0, get_info().style.color, SKELETON_PANEL, skeleton_group->object_list())) != ERRORCODE_None)
				{
					return error;
				}

				if (get_info().style.label_style == CAL_LABEL_INVERTED
						&& i != 0
						&& i != days_in_week)
				{
					PBOX r2;
					r2.y0 = r.y0;
					r2.y1 = r.y1;

					r2.x0 = label.x0;
 					if (has_border)
					{
						r2.x0 += line_thickness;
					}
					r2.x1 = label.x1;
					if ((error = add_line(&r2, 100, get_info().style.color, SKELETON_PANEL, skeleton_group->object_list())) != ERRORCODE_None)
					{
						return error;
					}
				}
				r.y0 += cell_height;
			}
			break;
		}
		default:
		{
			break;
		}
	}

	if (has_shadow)
	{
	/* Right piece. */

		r.x0 = bound.x1;
		r.x1 = r.x0+shadow_thickness;
		r.y0 = bound.y0+shadow_thickness;
		r.y1 = bound.y1+shadow_thickness;
		if ((error = add_line(&r, shadow_pattern, shadow_color, SHADOW_PANEL, skeleton_group->object_list())) != ERRORCODE_None)
		{
			return error;
		}

	/* Bottom piece. */

		r.x0 = bound.x0+shadow_thickness;
		r.x1 = bound.x1+shadow_thickness;
		r.y0 = bound.y1;
		r.y1 = r.y0+shadow_thickness;
		if ((error = add_line(&r, shadow_pattern, shadow_color, SHADOW_PANEL, skeleton_group->object_list())) != ERRORCODE_None)
		{
			return error;
		}
	}

/*
// Draw the calendar text.
*/

/* Draw the label text. */

	r.x0 = label.x0 + 2*line_thickness;
	r.y0 = label.y0 + 2*line_thickness;
	r.x1 = label.x1 + cell_width;
	r.y1 = label.y0 + cell_height;

	SHORT size= (SHORT)scale_pcoord(cell_height, 72/6, PAGE_RESOLUTION);

	m_LabelFontStyle.BaseSize(MakeFixed(size));
	m_LabelFontStyle.Size(MakeFixed(size));

/*
// Calculate the size of the text for these labels.
// If the text falls outside the frame, keep making it smaller.
*/

	label_width = label.x1 - r.x0
						- InchesToPage(m_LabelFontStyle.LeftMargin() + m_LabelFontStyle.RightMargin());

	for (stop_looking = FALSE; !stop_looking;)
	{
		BOOL too_big = FALSE;

		m_LabelFontStyle.UpdateFontMetrics();

		for (weekday = first_day, i = 0;
							i < days_in_week && !too_big;
	 						i++, weekday = next_weekday(weekday))
		{
//			CHAR *p;
			TCHAR *p;
			PCOORD size;

#ifdef LOCALIZE
			CurrentLocale.WeekDayName((WEEKDAY) weekday, buffer, sizeof(buffer));
#else
			// JRO strcpy(buffer, weekday_name[weekday]);
	         strcpy(buffer, GET_PMWAPP()->GetResourceStringPointer (weekday_name_id[weekday]));
#endif

			switch (get_info().style.weekday_style)
			{
				case WEEKDAY_STYLE_INITIALS:
				{
					buffer[1] = '\0';
					break;
				}
				case WEEKDAY_STYLE_ABBREV:
				{
#ifdef LOCALIZE
					CurrentLocale.AbbrevWeekDayName((WEEKDAY)weekday, buffer, sizeof(buffer));
#else
					buffer[3] = '\0';
#endif
					break;
				}
				default:
				{
					break;
				}
			}



		/* Compute the size for the text. */

			for (size = 0, p = buffer; *p != '\0'; )
			{
				size += font_server->GetAdvanceWidth(&m_LabelFontStyle, (CHARACTER)*p);
				p = CharNext(p);
			}

		/* See if we are too big. */

			if (size > label_width)
			{
				int nNewSize = (int)scale_pcoord(FixedInteger(m_LabelFontStyle.Size()), label_width, size);
				CFixed lNewSize = MakeFixed(nNewSize);
				m_LabelFontStyle.BaseSize(lNewSize);
				m_LabelFontStyle.Size(lNewSize);

				too_big = TRUE;

				if (nNewSize < MINIMUM_LABEL_POINT_SIZE)
				{
					m_LabelFontStyle.Size(MakeFixed(MINIMUM_LABEL_POINT_SIZE));
					m_LabelFontStyle.BaseSize(MakeFixed(MINIMUM_LABEL_POINT_SIZE));
					m_LabelFontStyle.UpdateFontMetrics();
					stop_looking = TRUE;
				}
			}
		}
		if (!too_big)
		{
		/* All done! */
			stop_looking = TRUE;
		}
	}

	m_LabelFontStyle.Alignment(ALIGN_left);

	text_style = m_LabelFontStyle;

	if (get_info().style.label_style == CAL_LABEL_INVERTED)
	{
		if (text_style.FillForegroundColor() == get_info().style.color
					&& text_style.FillPattern() == 0)
		{
			text_style.FillForegroundColor(COLOR_WHITE);
		}
	}
	else
	{
		if (text_style.FillForegroundColor() == COLOR_WHITE)
		{
			text_style.FillForegroundColor(COLOR_BLACK);
		}
	}

/*
// Run through the days now and add all the frames.
*/

	ObjectListPtr skeleton_list = skeleton_group->object_list();

	for (weekday = first_day, i = 0;
						i < days_in_week;
 						i++, weekday = next_weekday(weekday))
	{

#ifdef LOCALIZE
			CurrentLocale.WeekDayName((WEEKDAY)weekday, buffer, sizeof(buffer));
#else
			// JRO strcpy(buffer, weekday_name[weekday]);
	         strcpy(buffer, GET_PMWAPP()->GetResourceStringPointer (weekday_name_id[weekday]));

#endif

			switch (get_info().style.weekday_style)
			{
				case WEEKDAY_STYLE_INITIALS:
				{
					buffer[1] = '\0';
					break;
				}
				case WEEKDAY_STYLE_ABBREV:
				{
#ifdef LOCALIZE
					CurrentLocale.AbbrevWeekDayName((WEEKDAY)weekday, buffer, sizeof(buffer));
#else
					buffer[3] = '\0';
#endif
					break;
				}
				default:
				{
					break;
				}
			}


	/* Add the actual text. */

		if ((error = add_frame(&r,
 							buffer,
 							ALIGN_left,
 							ALIGN_top,
 							LABEL_FRAME_PANEL+i,
 							0,
							0,
 							skeleton_list,
							OBJECT_TYPE_Frame,
							&text_style)) != ERRORCODE_None)
		{
			return error;
		}

		PMGPageObjectPtr object = (PMGPageObjectPtr)skeleton_list->last_object();
		object->add_flags(OBJECT_FLAG_locked);

		r.y0 += cell_height;
		r.y1 += cell_height;
	}

/* Draw the numbers if this is a weekly calendar. */

	r.x0 = label.x0;
	r.y0 = label.y0;
	r.x1 = label.x1 + cell_width;
	r.y1 = label.y0 + cell_height;

	*buffer = '\0';					/* In case of GENERIC. */

	day = first_day_of_month;

	if (get_info().year == 1752 && get_info().month == SEPTEMBER)
	{
		if (day >= 3)
		{
			day += 14-3;
		}
	}

	m_NumberFontStyle.Alignment(ALIGN_center);

	for (i = 0; i < days_in_week; i++, day++)
	{
		short days_in_month = days_in_a_month(get_info().year, get_info().month);
		
		if (day > days_in_month)
			day = 1;

		if (get_info().style.type == WEEKLY)
		{
			itoa(day, buffer, 10);
		}

	/* Add the actual text. */

		if ((error = add_frame(&r,
							buffer,
							ALIGN_center,
							ALIGN_middle,
							i+DATE_PANEL,
							0,
							SELECT_FLAG_boundary | SELECT_FLAG_drag_handle | SELECT_FLAG_solo_select,
							date_group->object_list(),
							OBJECT_TYPE_CalendarDate,
							&m_NumberFontStyle)) != ERRORCODE_None)
		{
			return error;
		}

		r.y0 += cell_height;
		r.y1 += cell_height;

		if (get_info().year == 1752 && get_info().month == SEPTEMBER && day == 2)
		{
			day = 13;
		}
	}

	skeleton_group->establish();
	date_group->establish();
	text_group->establish();
	graphic_group->establish();

	return ERRORCODE_None;
}