Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXCalendarView.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                   B a s e   C a l e n d a r   W i d g e t                     *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 2006,2008 by Sander Jansen.   All Rights Reserved.              *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or modify          *
00009 * it under the terms of the GNU Lesser General Public License as published by   *
00010 * the Free Software Foundation; either version 3 of the License, or             *
00011 * (at your option) any later version.                                           *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                 *
00016 * GNU Lesser General Public License for more details.                           *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public License      *
00019 * along with this program.  If not, see <http://www.gnu.org/licenses/>          *
00020 *********************************************************************************
00021 * $Id: FXCalendarView.h,v 1.15 2008/01/04 15:18:14 fox Exp $                    *
00022 ********************************************************************************/
00023 #ifndef FXCALENDARVIEW_H
00024 #define FXCALENDARVIEW_H
00025 
00026 #ifndef FXWINDOW_H
00027 #include "FXWindow.h"
00028 #endif
00029 
00030 namespace FX {
00031 
00032 
00033 /// Calendar styles
00034 enum {
00035   CALENDAR_BROWSESELECT = 0x00000000,   /// Browse selection mode enforces one single item to be selected at all times
00036   CALENDAR_SINGLESELECT = 0x00100000,   /// Single selection mode allows up to one item to be selected
00037   CALENDAR_WEEKNUMBERS  = 0x00200000,   /// Show ISO8601 Week numbers
00038   CALENDAR_STATIC       = 0x00400000,   /// Disable navigation to prev/next month in display.
00039   CALENDAR_HIDEOTHER    = 0x00800000,   /// Do not show days of other months.
00040   };
00041 
00042 
00043 class FXFont;
00044 
00045 
00046 /**
00047 * The Basic Calendar Widget. Renders the base calendar and keeps track of selection.
00048 * Most usefull to widget developers. Use it if you need a calendar rendered in some component.
00049 */
00050 class FXAPI FXCalendarView : public FXWindow {
00051 FXDECLARE(FXCalendarView)
00052 protected:
00053   FXFont  *font;                // Font
00054   FXDate   current;             // Current Date
00055   FXDate   selected;            // Selected Date
00056   FXDate   ds;                  // First Day in Calendar
00057   FXint    month;               // Which month is being viewed.
00058   FXint    firstday;            // Which day of the week we display in the first column
00059   FXint    ws;                  // First week number in Calendar
00060   FXColor  todayColor;          // Today Color
00061   FXColor  titleColor;          // Title Color
00062   FXColor  titleBackColor;      // Title Back Color
00063   FXColor  dayColor;            // Normal Day Color
00064   FXColor  otherDayColor;       // Normal Day Color Disabled
00065   FXColor  weekendColor;        // Weekend Color
00066   FXColor  otherWeekendColor;   // Weekend Color Disabled
00067   FXbool   has_selection;       // If any date is selected
00068   FXbool   state;               // State
00069 protected:
00070   FXCalendarView();
00071   void moveFocus(FXDate);
00072   void markdirty(FXDate);
00073   void updateview(FXbool notify=true);
00074 private:
00075   FXCalendarView(const FXCalendarView&);
00076   FXCalendarView &operator=(const FXCalendarView&);
00077 public:
00078   long onPaint(FXObject*,FXSelector,void*);
00079   long onLeftBtnPress(FXObject*,FXSelector,void*);
00080   long onLeftBtnRelease(FXObject*,FXSelector,void*);
00081   long onKeyPress(FXObject*,FXSelector,void*);
00082   long onKeyRelease(FXObject*,FXSelector,void*);
00083   long onFocusIn(FXObject*,FXSelector,void*);
00084   long onFocusOut(FXObject*,FXSelector,void*);
00085   long onClicked(FXObject*,FXSelector,void*);
00086   long onDoubleClicked(FXObject*,FXSelector,void*);
00087   long onTripleClicked(FXObject*,FXSelector,void*);
00088   long onCommand(FXObject*,FXSelector,void*);
00089   long onCmdSetValue(FXObject*,FXSelector,void*);
00090   long onCmdSetIntValue(FXObject*,FXSelector,void*);
00091   long onCmdGetIntValue(FXObject*,FXSelector,void*);
00092 public:
00093 
00094   /// Construct a Calendar View
00095   FXCalendarView(FXComposite *p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=CALENDAR_BROWSESELECT,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
00096 
00097   /// Create X window
00098   virtual void create();
00099 
00100   /// Yes we can
00101   virtual FXbool canFocus() const;
00102 
00103   /// Set focus
00104   virtual void setFocus();
00105 
00106   /// Kill focus
00107   virtual void killFocus();
00108 
00109   /// Enable the window
00110   virtual void enable();
00111 
00112   /// Disable the window
00113   virtual void disable();
00114 
00115   /// Return the default width of this window
00116   virtual FXint getDefaultWidth();
00117 
00118   /// Return the default height of this window
00119   virtual FXint getDefaultHeight();
00120 
00121   /// Get date at x,y if any
00122   FXbool getDateAt(FXint x,FXint y,FXDate& date) const;
00123 
00124   /// Set date
00125   void setCurrentDate(FXDate date,FXbool notify=false);
00126 
00127   /// Get the current date
00128   FXDate getCurrentDate() const { return current; }
00129 
00130   /// Set the current month; current day will be properly updated for the choosen month
00131   void setCurrentMonth(FXint month,FXbool notify=false);
00132 
00133   /// Return the current month shown. The month may be different than the current
00134   /// date if a day in a sibling month is current.
00135   FXint getCurrentMonth() const { return month; }
00136 
00137   /// Select Date
00138   void selectDate(FXDate date,FXbool notify=false);
00139 
00140   /// Deselect Date
00141   void killSelection(FXbool notify=false);
00142 
00143   /// Get the selected date, if any
00144   FXbool getSelectedDate(FXDate& date) const;
00145 
00146   /// Set the first day of the week [0...6]
00147   void setFirstDay(FXint d);
00148 
00149   /// Get the first day of the week [0...6]
00150   FXint getFirstDay() const { return firstday; }
00151 
00152   /// Set the calendar style
00153   void setCalendarStyle(FXuint);
00154 
00155   /// Get the calendar style
00156   FXuint getCalendarStyle() const;
00157 
00158   /// Set the display color of titles
00159   void setTitleColor(FXColor c);
00160 
00161   /// Get the display color of titles
00162   FXColor getTitleColor() const { return titleColor; }
00163 
00164   /// Set the display background color of titles
00165   void setTitleBackColor(FXColor c);
00166 
00167   /// Get the display background color of titles
00168   FXColor getTitleBackColor() const { return titleBackColor; }
00169 
00170   /// Set the display color of non-weekend days
00171   void setDayColor(FXColor c);
00172 
00173   /// Get the display color of non-weekend days
00174   FXColor getDayColor() const { return dayColor; }
00175 
00176   /// Set the display color of non-weekend days not in the current month
00177   void setOtherDayColor(FXColor c);
00178 
00179   /// Get the display color of non-weekend days not in the current month
00180   FXColor getOtherDayColor() const { return otherDayColor; }
00181 
00182   /// Set the display color of today
00183   void setTodayColor(FXColor c);
00184 
00185   /// Get the display color of today
00186   FXColor getTodayColor() const { return todayColor; }
00187 
00188   /// Set the display color of days in the weekend
00189   void setWeekendColor(FXColor c);
00190 
00191   /// Get the display color of days in the weekend
00192   FXColor getWeekendColor() const { return weekendColor; }
00193 
00194   /// Set the display color of days in the weekend not in the current month
00195   void setOtherWeekendColor(FXColor c);
00196 
00197   /// Get the display color of days in the weekend not in the current month
00198   FXColor getOtherWeekendColor() const { return otherWeekendColor; }
00199 
00200   /// Destructor
00201   virtual ~FXCalendarView();
00202   };
00203 
00204 }
00205 
00206 #endif
00207 

Copyright © 1997-2007 Jeroen van der Zijp