/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


#include "nsISupports.idl"

interface calICalendar;
interface calIDateTime;
interface calICalendarViewController;
interface calIItemBase;
/**
 * calIDecoratedView is an interface for modifying/extending the standard
 * calICalendarView, typically to add specific navigation functions while
 * removing the unnecessary code duplication this would generally require.
 * Because it contains a calICalendarView as an anonymous node, not easily
 * accessible, it must therefore expose several of that interface's methods and
 * attributes, as well as its own.
 * 
 * @note Implementations of this interface are intended to be the home
 * for view preference handling.  The lower-level views (ie
 * implementers of calICalendarView) are intended to be pure widgetry,
 * and this sort of view should be pluggable, meaning that callers
 * shouldn't need to know about view-specific preferences.
 */

[scriptable, uuid(7ba617eb-f19b-400b-9a7d-4156b7c6f028)]
interface calIDecoratedView : nsISupports
{
  /**
   * Oftentimes other elements in the DOM in which a calIDecoratedView is
   * used want to be aware of whether or not the view is selected.  An element
   * whose ID is observerID can be included in that DOM, and will be set to be
   * enabled or disabled depending on whether the view is selected.
   */
  readonly attribute AUTF8String observerID;

  /**
   * Generally corresponds to whether or not the view has been previously shown.
   * Strictly speaking, it reports whether displayCalendar, startDay and endDay
   * are all non-null.
   */
  readonly attribute boolean initialized;

  /**
   * The displayCalendar of the embedded calICalendarView.  This *must* be set
   * prior to calling goToDay the first time.
   */
  attribute calICalendar displayCalendar;

  /**
   * The controller of the calICalendarView that is embedded
   */
  attribute calICalendarViewController controller;

  /**
   * If this is set to 'true', the view should not display days specified to be
   * non-workdays.  The implementor is responsible for obtaining what those
   * days are on its own.
   */
  attribute boolean workdaysOnly;

  /**
   * Whether or not tasks are to be displayed in the calICalendarView
   */
  attribute boolean tasksInView;

  /**
   * If set, the view will be rotated (i.e time on top, date at left)
   */
  attribute boolean rotated;

  /**
   * Whether or not completed tasks are shown in the calICalendarView
   */
  attribute boolean showCompleted;

  /**
   * See calICalendarView.idl for the description of these functions.
   */
  void getSelectedItems(out unsigned long aCount,
                        [array,size_is(aCount),retval] out calIItemBase aItems);
  void setSelectedItems(in unsigned long aCount,
                        [array,size_is(aCount)] in calIItemBase aItems,
                        in boolean aSuppressEvent);

  /**
   * The selectedDay in the embedded view.  Use the goToDay function to set a
   * particular day to be selected.
   */
  readonly attribute calIDateTime selectedDay;

  /**
   * The first day shown in the embedded view
   */
  readonly attribute calIDateTime startDay;

  /**
   * The last day shown in the embedded view
   */
  readonly attribute calIDateTime endDay;

  /**
   * Get or set the timezone that the view's elements should be displayed in.
   * Setting this does not refresh the view.
   */
  attribute AUTF8String timezone;

  /**
   * Ensures that the given date is visible, and that the view is centered
   * around this date.  aDate becomes the selectedDay of the view.  Calling
   * this function with the current selectedDay effectively refreshes the view
   *
   * @param aDate       the date that must be shown in the view and becomes 
   *                    the selected day
   */
  void goToDay(in calIDateTime aDate);

  /**
   * Moves the view a specific number of pages.  Negative numbers correspond to
   * moving the view backwards.  Note that it is up to the view to determine
   * how the selected day ought to move as well.
   *
   * @param aNumber       the number of pages to move the view 
   */
  void moveView(in long aNumber);

  /**
   * gets the description of the range displayed by the view
   */
  AString getRangeDescription();

  /**
   * The type of the view e.g "day", "week", "multiweek" or "month" that refers
   * to the displayed time period.
   */
  readonly attribute string type;

};
