

#ifndef _monthcal_h_ /* Thu Dec 30 15:50:13 1993 */
#define _monthcal_h_





/*
 *
 *          Copyright (C) 1995, M. A. Sridhar
 *  
 *
 *     This software is Copyright M. A. Sridhar, 1995. You are free
 *     to copy, modify or distribute this software  as you see fit,
 *     and to use  it  for  any  purpose, provided   this copyright
 *     notice and the following   disclaimer are included  with all
 *     copies.
 *
 *                        DISCLAIMER
 *
 *     The author makes no warranties, either expressed or implied,
 *     with respect  to  this  software, its  quality, performance,
 *     merchantability, or fitness for any particular purpose. This
 *     software is distributed  AS IS.  The  user of this  software
 *     assumes all risks  as to its quality  and performance. In no
 *     event shall the author be liable for any direct, indirect or
 *     consequential damages, even if the  author has been  advised
 *     as to the possibility of such damages.
 *
 */





// This is a simple visual object that has a date as its model, and displays
// the month of that date in its view.


#if defined(__GNUC__)
#pragma interface
#endif

#include "base/date.h"
#include "ui/simple.h"

class YACL_UI UI_CompositeVObject;
class YACL_UI UI_DrawingSurface;
class YACL_UI UI_Bitmap;


class YACL_UI UI_MonthCalendar: public UI_SimpleVObject {

public:
    UI_MonthCalendar (UI_VisualObject* parent,
                      const UI_Rectangle& shape, UI_ViewID id);

    void AdvanceMonth ();

    void PreviousMonth();
    
  
    virtual UI_WindowClass WindowClass () const;

    const char* ClassName () const {return "UI_MonthCalendar";};
    
protected:
    ~UI_MonthCalendar ();
    
    bool ButtonDown (const UI_Point& curPos, UI_MouseButton btn,
                     bool shiftKey, bool ctrlKey); 

    bool Paint (const UI_Rectangle& invalidRect);

    void _PrivateInitialize ();
    // Override the inherited method. Under OS/2, the implementation
    // paints the display, because this object doesn't get an initial
    // paint event (don't know why). On other platforms, this method does
    // nothing.

    bool _ModelChanged ();
    // Override the inherited method.

    void _RebuildImage ();
    // Rebuild the in-memory image, because it has become invalid.

    void _Draw (UI_DrawingSurface&);
    // Draw the representation on the given drawing surface.
    
    // Virtual methods for child classes:
    
    virtual void ClickOnDay (short day);


    short _month;
    short _year;

private:
    short _cellWidth;
    short _cellHeight;
    short _charWidth;
    short _charHeight;
    short _dayOfFirst;  // What day of week is the first of the displayed
                        // month ?
    short _daysInMonth; // Number of days in the displayed month
    UI_Rectangle _displayRect;

    UI_Bitmap*  _image;
};

#endif /* _calendar_h_ */
