home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 May / Chip_2002-05_cd1.bin / chplus / cpp / 5 / Komponety.exe / ccalendr.h < prev    next >
C/C++ Source or Header  |  1998-02-09  |  4KB  |  107 lines

  1. //---------------------------------------------------------------------------
  2. // Borland C++Builder
  3. // Copyright (c) 1987, 1998 Borland International Inc.  All Rights Reserved.
  4. //---------------------------------------------------------------------------
  5. #ifndef CcalendrH
  6. #define CcalendrH
  7. //---------------------------------------------------------------------------
  8.  
  9. #include <Menus.hpp>
  10. #include <SysUtils.hpp>
  11. #include <Grids.hpp>
  12. #include <StdCtrls.hpp>
  13. #include <Graphics.hpp>
  14. #include <Forms.hpp>
  15. #include <Windows.hpp>
  16. #include <Messages.hpp>
  17. #include <Controls.hpp>
  18. #include <Classes.hpp>
  19. #include <System.hpp>
  20.  
  21. typedef short TDayOfWeek;
  22.  
  23. class PACKAGE TCCalendar : public TCustomGrid
  24. {
  25. private:
  26.   TDateTime FDate;
  27.   Integer FMonthOffset;
  28.   TNotifyEvent FOnChange;
  29.   Boolean FReadOnly;
  30.   TDayOfWeek FStartOfWeek;
  31.   Boolean FUpdating;
  32.   Boolean FUseCurrentDate;
  33.   AnsiString __fastcall GetCellText(int ACol, int ARow);
  34.   Integer __fastcall GetDateElement(Integer Index);
  35.   void __fastcall SeTCCalendarDate(TDateTime Value);
  36.   void __fastcall SetDateElement(int Index, int Value);
  37.   void __fastcall SetStartOfWeek(TDayOfWeek Value);
  38.   void __fastcall SetUseCurrentDate(bool Value);
  39.   bool __fastcall StoreCalendarDate();
  40.  
  41. protected:
  42.   virtual void __fastcall Change();
  43.   void __fastcall ChangeMonth(Integer Delta);
  44.   DYNAMIC void __fastcall Click(void);
  45.   virtual int __fastcall DaysThisMonth();
  46.   virtual void __fastcall DrawCell(int ACol, int ARow, const TRect &ARect,
  47.     TGridDrawState AState);
  48.   virtual bool __fastcall IsLeapYear(int AYear);
  49.   virtual bool __fastcall SelectCell(int ACol, int ARow);
  50.   void __fastcall WMSize(TWMSize& Message);
  51.  
  52. public:
  53.   __fastcall virtual TCCalendar(TComponent *AOwner);
  54.   __fastcall TCCalendar(HWND Parent): TCustomGrid(Parent) {};
  55.   __property TDateTime CalendarDate = {read=FDate, write=SeTCCalendarDate, stored=StoreCalendarDate};
  56.   __property AnsiString CellText[Integer ACol][Integer ARow] = {read=GetCellText};
  57.   void __fastcall NextMonth();
  58.   void __fastcall NextYear();
  59.   void __fastcall PrevMonth();
  60.   void __fastcall PrevYear();
  61.   virtual void __fastcall UpdateCalendar();
  62.   virtual int __fastcall DaysPerMonth(int AYear, int AMonth);
  63.  
  64. __published:
  65.   __property Align ;
  66.   __property BorderStyle ;
  67.   __property Color ;
  68.   __property Ctl3D ;
  69.   __property Integer Day = {read=GetDateElement, write=SetDateElement, stored=false, index=3, nodefault
  70.     };
  71.   __property Enabled ;
  72.   __property Font ;
  73.   __property GridLineWidth ;
  74.   __property Integer Month = {read=GetDateElement, write=SetDateElement, stored=false, index=2, nodefault
  75.     };
  76.   __property ParentColor ;
  77.   __property ParentFont ;
  78.   __property ParentShowHint ;
  79.   __property PopupMenu ;
  80.   __property Boolean ReadOnly = {read=FReadOnly, write=FReadOnly, default=0};
  81.   __property ShowHint ;
  82.   __property TDayOfWeek StartOfWeek = {read=FStartOfWeek, write=SetStartOfWeek, default=1};
  83.   __property TabOrder ;
  84.   __property TabStop ;
  85.   __property Boolean UseCurrentDate = {read=FUseCurrentDate, write=SetUseCurrentDate, default=1};
  86.   __property Visible ;
  87.   __property Integer Year = {read=GetDateElement, write=SetDateElement, stored=false, index=1, nodefault
  88.     };
  89.   __property OnClick ;
  90.   __property TNotifyEvent OnChange = {read=FOnChange, write=FOnChange};
  91.   __property OnDblClick ;
  92.   __property OnDragDrop ;
  93.   __property OnDragOver ;
  94.   __property OnEndDrag ;
  95.   __property OnEnter ;
  96.   __property OnExit ;
  97.   __property OnKeyDown ;
  98.   __property OnKeyPress ;
  99.   __property OnKeyUp ;
  100.  
  101.   BEGIN_MESSAGE_MAP
  102.     VCL_MESSAGE_HANDLER(WM_SIZE, TWMSize, WMSize);
  103.   END_MESSAGE_MAP(TCustomGrid);
  104. };
  105.  
  106. #endif  // CalendarH
  107.