datecell.h

00001 /********************************************************************\
00002  * datecell.h -- Date entry/handling/display cell                   *
00003  *                                                                  *
00004  * This program is free software; you can redistribute it and/or    *
00005  * modify it under the terms of the GNU General Public License as   *
00006  * published by the Free Software Foundation; either version 2 of   *
00007  * the License, or (at your option) any later version.              *
00008  *                                                                  *
00009  * This program is distributed in the hope that it will be useful,  *
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
00012  * GNU General Public License for more details.                     *
00013  *                                                                  *
00014  * You should have received a copy of the GNU General Public License*
00015  * along with this program; if not, contact:                        *
00016  *                                                                  *
00017  * Free Software Foundation           Voice:  +1-617-542-5942       *
00018  * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
00019  * Boston, MA  02110-1301,  USA       gnu@gnu.org                   *
00020  *                                                                  *
00021 \********************************************************************/
00022 
00023 /*
00024  * FILE:
00025  * datecell.h
00026  *
00027  * FUNCTION:
00028  * The DateCell object implements a date handling cell.  It
00029  * is able to display dates in several formats, it is also 
00030  * able to accept date input, and also supports a number of accelerator
00031  * keys.
00032  *
00033  * On output, this cell will display a date as mm/dd/yy
00034  * The actual date formate is compile-time configurable.
00035  *
00036  * hack alert -- make the display format run-time configurable, and 
00037  * appropriately internationalized.
00038  *
00039  * One input, this cell is able to parse dates that are entered.
00040  * It rejects any input that is not in the form of a date.  Input
00041  * also includes a number of accelerators:  
00042  *
00043  *     '+':
00044  *     '=':    increment day 
00045  *
00046  *     '_':
00047  *     '-':    decrement day 
00048  *
00049  *     '}':
00050  *     ']':    increment month 
00051  *
00052  *     '{':
00053  *     '[':    decrment month 
00054  *
00055  *     'M':
00056  *     'm':    begining of month 
00057  *
00058  *     'H':
00059  *     'h':    end of month 
00060  *
00061  *     'Y':
00062  *     'y':    begining of year 
00063  *
00064  *     'R':
00065  *     'r':    end of year 
00066  *
00067  *     'T':
00068  *     't':    today 
00069  *
00070  * 
00071  * METHODS:
00072  * The xaccSetDateCellValue() method accepts a numeric date and
00073  *    sets the contents of the date cell to that value.  The
00074  *    value day, month, year should follow the regular written
00075  *    conventions, i.e. day==(1..31), mon==(1..12), year==4 digits
00076  *
00077  * The xaccCommitDateCell() method commits any pending changes to the 
00078  *    value of the cell.  That is, it will take the cells current string 
00079  *    value, and parse it into a month-day-year value.
00080  *
00081  *    Why is this needed? Basically, while the user is typing into the
00082  *    cell, we do not even try to parse the date, lest we confuse things
00083  *    royally.  Normally, when the user leaves this cell, and moves to  
00084  *    another, we parse the date and print it nicely and cleanly into 
00085  *    the cell.  But it can happen that we want to get the accurate contents 
00086  *    of the date cell before we've left it, e.g. if the user has clicked
00087  *    on the "commit" button.  This is the routine to call for that.
00088  *
00089  * HISTORY:
00090  * Copyright (c) 1998, 1999, 2000 Linas Vepstas <linas@linas.org>
00091  * Copyright (c) 2000 Dave Peticolas
00092  */
00093  
00094 #ifndef DATE_CELL_H
00095 #define DATE_CELL_H
00096 
00097 #include <time.h>
00098 
00099 #include "basiccell.h"
00100 #include "qof.h"
00101 
00102 
00103 typedef struct date_cell
00104 {
00105   BasicCell cell;
00106 } DateCell;
00107 
00108 /* installs a callback to handle date recording */
00109 BasicCell * gnc_date_cell_new (void);
00110 
00111 /* days are 1-31, mon is 1-12, year 1900 == 1900 */
00112 void        gnc_date_cell_set_value (DateCell *cell,
00113                                      int day, int mon, int year);  
00114 void        gnc_date_cell_set_value_secs (DateCell *cell, time_t secs);
00115 
00116 void        gnc_date_cell_commit (DateCell *cell);
00117 
00118 void        gnc_date_cell_get_date (DateCell *cell, Timespec *ts);
00119 
00120 #endif

Generated on Fri Oct 10 05:06:03 2008 for GnuCash by  doxygen 1.5.2