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

vdkcalendar.h

00001 /*
00002  * ===========================
00003  * VDK Visual Development Kit
00004  * Version 1.0
00005  * Revision 7
00006  * September 1999
00007  * ===========================
00008  *
00009  * Copyright (C) 1998, Mario Motta
00010  * Developed by Mario Motta <mmotta@guest.net>
00011  *
00012  * This library is free software; you can redistribute it and/or
00013  * modify it under the terms of the GNU Library General Public
00014  * License as published by the Free Software Foundation; either
00015  * version 2 of the License, or (at your option) any later version.
00016  *
00017  * This library is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020  * Library General Public License for more details.
00021  *
00022  * You should have received a copy of the GNU Library General Public
00023  * License along with this library; if not, write to the Free Software
00024  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00025  * 02111-1307, USA.
00026  */
00027 /*
00028 OVERVIEW
00029 --------
00030 This file has the aim to be a footstep that shows how to make a 
00031 gtk+ widget wrapper in vdk.
00032 We choose here to wrap gtk_calendar() widget.
00033 */
00034 
00035 #ifndef _VDKCALENDAR_H
00036 #define _VDKCALENDAR_H
00037 #include <vdk/vdk.h>
00038 /*
00039   defines for signals,
00040   we use user_signal as base in order to avoid
00041   possible conflicts with vdk internal signal system
00042 */
00043 #define day_select_signal           user_signal + 1024
00044 #define day_selected_double_click   day_select_signal + 1
00045 
00046 class VDKCalendar: public VDKObject
00047 {
00048 
00049 
00050  public:
00051   // 
00052   VDKCalendar(VDKForm* owner = NULL);
00053   virtual ~VDKCalendar();
00054   /*
00055     note:
00056     others gtk_calendar functions could be wrapped,
00057     but since in most cases it will be a 1:1 wrapping we decide
00058     to do not do it.
00059     User have at their hand: VDKObject::Widget  () to access
00060     directly to gtk_calendar.
00061     For instance to mark in bold face a day:
00062     ....
00063     VDKCalendar calendar = new VDKCalendar(this);
00064     calendardate today;
00065     gtk_calendar_mark_day ( GTK_CALENDAR(calendar->Widget()),today.Day());
00066     ....
00067   */
00068   //------------------
00069   // signal section
00070   //------------------
00071  protected:
00072   /*
00073     to wrap signals we use static class function that bind
00074     a signal and propagates it into vdk hierarchy.
00075     To decide which signal can be wrapped we take a look at
00076     gtkcalendar.h in gtk+ distribution.
00077     We see:
00078     void (* month_changed)              (GtkCalendar *calendar);
00079     void (* day_selected)               (GtkCalendar *calendar);
00080     void (* day_selected_double_click)  (GtkCalendar *calendar);
00081     void (* prev_month)                 (GtkCalendar *calendar);
00082     void (* next_month)                 (GtkCalendar *calendar);
00083     void (* prev_year)                  (GtkCalendar *calendar);
00084     void (* next_year)                  (GtkCalendar *calendar);
00085     So we decide to wrap following signals;
00086     - day_selected
00087     - day_selected_double_click
00088     for static tables, leaving others to be connected at user choice
00089     using dynamics tables.
00090     Now let's take a look to signal handlers to see how 
00091     should be the signature of the handlers.Since they all
00092     have just the widget as parameter we know that the handler
00093     will have the classic form:
00094     -----------------------------------
00095     void handler(GtkWidget*, gpointer);
00096     -----------------------------------
00097     (in many cases there is also an example how the widget
00098     works, both in testgtk.c or in examples dir. In our case
00099     there is a good one on  example/calendar/gcalendar.c).
00100   */
00101   static void DaySelectedHandler(GtkWidget*, gpointer);
00102   static void DaySelectedDoubleClickHandler(GtkWidget*, gpointer);
00103 
00104   //---------------------
00105   // properties section
00106   //---------------------
00107   /*
00108     To decide which properties are suitable to be wrapped,
00109     we take a look to gtkcalendar.h in gtk+ distribution
00110     to see wich gtk_set... or gtk_get... are available there.
00111     We see :
00112     void  gtk_calendar_display_options (GtkCalendar * calendar,
00113               GtkCalendarDisplayOptions options);
00114     void  gtk_calendar_get_date (GtkCalendar *, 
00115                                  guint       *year,
00116                                  guint       *month,
00117                                  guint       *day);
00118     gint  gtk_calendar_select_month(GtkCalendar *calendar,
00119                                  guint        month,
00120                                  guint        year);
00121     void  gtk_calendar_select_day(GtkCalendar *calendar,
00122                                   guint       day);                              
00123     So we decide to have following properties:
00124     - GtkCalendarOptions DisplayOptions
00125     - calendardate SelectedDate (read only)
00126     - int SelectedDay
00127     - VDKPoint SelectedMonth (where point.x is mont and point.y is day)
00128     (note: gtk+ numbers months using base 0:
00129     january = 0, february =1,...december = 11
00130     Instead we decide to use base 1 for the wrapper).
00131   */
00132 
00133   /* --------- DisplayOptions property ----------
00134      This property sets/gets  how calendar displays,
00135      options can be one or more of the following:
00136      (can be ored togheter)
00137      GTK_CALENDAR_SHOW_HEADING
00138      GTK_CALENDAR_SHOW_DAY_NAMES
00139      GTK_CALENDAR_NO_MONTH_CHANGE
00140      GTK_CALENDAR_SHOW_WEEK_NUMBERS
00141      GTK_CALENDAR_WEEK_START_MONDAY
00142   */
00143  public:
00144   __rwproperty(VDKCalendar, GtkCalendarDisplayOptions) DisplayOptions;
00145   /* and setting/getting functions */
00146  protected:
00147   void SetDisplayOptions(GtkCalendarDisplayOptions options);
00148   /* 
00149      getting function isn't necessary,
00150      since we use raw property read
00151      ( see vdk reference under "properties" section
00152      for further informations)
00153   */
00154 
00155   /* ------------- SelectedDate property --------
00156     This (read only) property read selected date
00157     in gtk_calendar widget.
00158     We use here calendardate object in vdk stock
00159     as property type.
00160   */
00161  public:
00162   __rproperty(VDKCalendar,calendardate) SelectedDate;
00163   /* and getting functions (since property is read-only */
00164  protected:
00165   calendardate GetSelectedDate();
00166 
00167   /* ------ SelectedDay property --------------
00168     this property set/get selected day
00169   */
00170  public:
00171   __rwproperty(VDKCalendar, int) SelectedDay;
00172  protected:
00173  void SetSelectedDay(int d);
00174   /* getting function isn't necessary*/
00175  
00176 
00177  /* -------- SelectedMonth property --------------
00178    this property set/get selected month/year
00179  */
00180  public:
00181  __rwproperty(VDKCalendar, VDKPoint) SelectedMonth;
00182  protected:
00183  void SetSelectedMonth(VDKPoint p);
00184  /* getting function isn't necessary*/
00185 
00186 };
00187 
00188 #endif
00189 

Generated on Sat May 4 21:58:35 2002 for vdk 2.0.1 by doxygen1.2.15