vdk 2.4.0
vdkcalendar.h
1 /*
2  * ===========================
3  * VDK Visual Development Kit
4  * Version 1.0
5  * Revision 7
6  * September 1999
7  * ===========================
8  *
9  * Copyright (C) 1998, Mario Motta
10  * Developed by Mario Motta <mmotta@guest.net>
11  *
12  * This library is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Library General Public
14  * License as published by the Free Software Foundation; either
15  * version 2 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  * Library General Public License for more details.
21  *
22  * You should have received a copy of the GNU Library General Public
23  * License along with this library; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25  * 02111-1307, USA.
26  */
27 /*
28 OVERVIEW
29 --------
30 This file has the aim to be a footstep that shows how to make a
31 gtk+ widget wrapper in vdk.
32 We choose here to wrap gtk_calendar() widget.
33 */
34 
35 #ifndef _VDKCALENDAR_H
36 #define _VDKCALENDAR_H
37 #include <vdk/vdk.h>
38 /*
39  defines for signals,
40  we use user_signal as base in order to avoid
41  possible conflicts with vdk internal signal system
42 */
43 #define day_select_signal user_signal + 1024
44 #define day_selected_double_click day_select_signal + 1
45 
46 class VDKCalendar: public VDKObject
47 {
48 
49 
50  public:
51  //
52  VDKCalendar(VDKForm* owner = NULL);
53  virtual ~VDKCalendar();
54  /*
55  note:
56  others gtk_calendar functions could be wrapped,
57  but since in most cases it will be a 1:1 wrapping we decide
58  to do not do it.
59  User have at their hand: VDKObject::Widget () to access
60  directly to gtk_calendar.
61  For instance to mark in bold face a day:
62  ....
63  VDKCalendar calendar = new VDKCalendar(this);
64  calendardate today;
65  gtk_calendar_mark_day ( GTK_CALENDAR(calendar->Widget()),today.Day());
66  ....
67  */
68  //------------------
69  // signal section
70  //------------------
71  protected:
72  /*
73  to wrap signals we use static class function that bind
74  a signal and propagates it into vdk hierarchy.
75  To decide which signal can be wrapped we take a look at
76  gtkcalendar.h in gtk+ distribution.
77  We see:
78  void (* month_changed) (GtkCalendar *calendar);
79  void (* day_selected) (GtkCalendar *calendar);
80  void (* day_selected_double_click) (GtkCalendar *calendar);
81  void (* prev_month) (GtkCalendar *calendar);
82  void (* next_month) (GtkCalendar *calendar);
83  void (* prev_year) (GtkCalendar *calendar);
84  void (* next_year) (GtkCalendar *calendar);
85  So we decide to wrap following signals;
86  - day_selected
87  - day_selected_double_click
88  for static tables, leaving others to be connected at user choice
89  using dynamics tables.
90  Now let's take a look to signal handlers to see how
91  should be the signature of the handlers.Since they all
92  have just the widget as parameter we know that the handler
93  will have the classic form:
94  -----------------------------------
95  void handler(GtkWidget*, gpointer);
96  -----------------------------------
97  (in many cases there is also an example how the widget
98  works, both in testgtk.c or in examples dir. In our case
99  there is a good one on example/calendar/gcalendar.c).
100  */
101  static void DaySelectedHandler(GtkWidget*, gpointer);
102  static void DaySelectedDoubleClickHandler(GtkWidget*, gpointer);
103 
104  //---------------------
105  // properties section
106  //---------------------
107  /*
108  To decide which properties are suitable to be wrapped,
109  we take a look to gtkcalendar.h in gtk+ distribution
110  to see wich gtk_set... or gtk_get... are available there.
111  We see :
112  void gtk_calendar_display_options (GtkCalendar * calendar,
113  GtkCalendarDisplayOptions options);
114  void gtk_calendar_get_date (GtkCalendar *,
115  guint *year,
116  guint *month,
117  guint *day);
118  gint gtk_calendar_select_month(GtkCalendar *calendar,
119  guint month,
120  guint year);
121  void gtk_calendar_select_day(GtkCalendar *calendar,
122  guint day);
123  So we decide to have following properties:
124  - GtkCalendarOptions DisplayOptions
125  - calendardate SelectedDate (read only)
126  - int SelectedDay
127  - VDKPoint SelectedMonth (where point.x is mont and point.y is day)
128  (note: gtk+ numbers months using base 0:
129  january = 0, february =1,...december = 11
130  Instead we decide to use base 1 for the wrapper).
131  */
132 
133  /* --------- DisplayOptions property ----------
134  This property sets/gets how calendar displays,
135  options can be one or more of the following:
136  (can be ored togheter)
137  GTK_CALENDAR_SHOW_HEADING
138  GTK_CALENDAR_SHOW_DAY_NAMES
139  GTK_CALENDAR_NO_MONTH_CHANGE
140  GTK_CALENDAR_SHOW_WEEK_NUMBERS
141  GTK_CALENDAR_WEEK_START_MONDAY
142  */
143  public:
144  __rwproperty(VDKCalendar, GtkCalendarDisplayOptions) DisplayOptions;
145  /* and setting/getting functions */
146  protected:
147  void SetDisplayOptions(GtkCalendarDisplayOptions options);
148  /*
149  getting function isn't necessary,
150  since we use raw property read
151  ( see vdk reference under "properties" section
152  for further informations)
153  */
154 
155  /* ------------- SelectedDate property --------
156  This (read only) property read selected date
157  in gtk_calendar widget.
158  We use here calendardate object in vdk stock
159  as property type.
160  */
161  public:
162  __rproperty(VDKCalendar,calendardate) SelectedDate;
163  /* and getting functions (since property is read-only */
164  protected:
165  calendardate GetSelectedDate();
166 
167  /* ------ SelectedDay property --------------
168  this property set/get selected day
169  */
170  public:
171  __rwproperty(VDKCalendar, int) SelectedDay;
172  protected:
173  void SetSelectedDay(int d);
174  /* getting function isn't necessary*/
175 
176 
177  /* -------- SelectedMonth property --------------
178  this property set/get selected month/year
179  */
180  public:
181  __rwproperty(VDKCalendar, VDKPoint) SelectedMonth;
182  protected:
183  void SetSelectedMonth(VDKPoint p);
184  /* getting function isn't necessary*/
185 
186 };
187 
188 #endif
189 
VDKForm widgets, generally the outermost widget container.
Definition: forms.h:69
Definition: vdkobj.h:141
Provides a simple point object.
Definition: vdkutils.h:94
provides a date object
Definition: vdkdate.h:53