mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
* Implement a core CheckboxCell register type (note, still needs a
pretty Gnome implementation) git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7272 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
e9ce0bdc87
commit
6510d59d7b
@ -11,6 +11,9 @@
|
||||
* Check for gettext in -lintl for MacOS
|
||||
|
||||
* Peter O'Gorman's patch for fixing libtool on darwin
|
||||
|
||||
* Implement a core CheckboxCell register type (note, still needs a
|
||||
pretty Gnome implementation)
|
||||
|
||||
2002-10-03 Christian Stimming <stimming@tuhh.de>
|
||||
|
||||
|
@ -21,6 +21,7 @@ libgncmod_register_core_la_SOURCES = \
|
||||
pricecell.c \
|
||||
quickfillcell.c \
|
||||
recncell.c \
|
||||
checkboxcell.c \
|
||||
register-common.c \
|
||||
table-allgui.c \
|
||||
table-control.c \
|
||||
@ -41,6 +42,7 @@ gncinclude_HEADERS = \
|
||||
pricecell.h \
|
||||
quickfillcell.h \
|
||||
recncell.h \
|
||||
checkboxcell.h \
|
||||
register-common.h \
|
||||
table-allgui.h \
|
||||
table-control.h \
|
||||
|
118
src/register/register-core/checkboxcell.c
Normal file
118
src/register/register-core/checkboxcell.c
Normal file
@ -0,0 +1,118 @@
|
||||
/********************************************************************\
|
||||
* checkboxcell.c -- yes/no checkbox cell *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02111-1307, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
/*
|
||||
* FILE:
|
||||
* checkboxcell.c
|
||||
*
|
||||
* FUNCTION:
|
||||
* Implements a mouse-click cell that toggles a yes/no value.
|
||||
*
|
||||
* HISTORY:
|
||||
* Copyright (c) 1998 Linas Vepstas
|
||||
* Copyright (c) 2000 Dave Peticolas
|
||||
* Copyright (c) 2001 Derek Atkins
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "basiccell.h"
|
||||
#include "gnc-engine-util.h"
|
||||
#include "checkboxcell.h"
|
||||
|
||||
|
||||
/* assumes we are given the untranslated form */
|
||||
static void
|
||||
gnc_checkbox_cell_set_value (BasicCell *_cell, const char *value)
|
||||
{
|
||||
CheckboxCell *cell = (CheckboxCell *) _cell;
|
||||
gboolean flag = FALSE;
|
||||
|
||||
if (value && *value == 'X')
|
||||
flag = TRUE;
|
||||
|
||||
gnc_checkbox_cell_set_flag (cell, flag);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gnc_checkbox_cell_enter (BasicCell *_cell,
|
||||
int *cursor_position,
|
||||
int *start_selection,
|
||||
int *end_selection)
|
||||
{
|
||||
CheckboxCell *cell = (CheckboxCell *) _cell;
|
||||
gnc_checkbox_cell_set_flag (cell, !cell->flag);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_checkbox_cell_init (CheckboxCell *cell)
|
||||
{
|
||||
gnc_basic_cell_init (&cell->cell);
|
||||
|
||||
gnc_checkbox_cell_set_flag (cell, FALSE);
|
||||
cell->cell.enter_cell = gnc_checkbox_cell_enter;
|
||||
cell->cell.set_value = gnc_checkbox_cell_set_value;
|
||||
}
|
||||
|
||||
BasicCell *
|
||||
gnc_checkbox_cell_new (void)
|
||||
{
|
||||
CheckboxCell * cell;
|
||||
|
||||
cell = g_new0 (CheckboxCell, 1);
|
||||
|
||||
gnc_checkbox_cell_init (cell);
|
||||
|
||||
return &cell->cell;
|
||||
}
|
||||
|
||||
void
|
||||
gnc_checkbox_cell_set_flag (CheckboxCell *cell, gboolean flag)
|
||||
{
|
||||
const char *string;
|
||||
|
||||
g_return_if_fail (cell != NULL);
|
||||
|
||||
cell->flag = flag;
|
||||
string = gnc_checkbox_cell_get_string (flag);
|
||||
|
||||
gnc_basic_cell_set_value_internal (&cell->cell, string);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gnc_checkbox_cell_get_flag (CheckboxCell *cell)
|
||||
{
|
||||
g_return_val_if_fail (cell != NULL, '\0');
|
||||
|
||||
return cell->flag;
|
||||
}
|
||||
|
||||
const char *
|
||||
gnc_checkbox_cell_get_string (gboolean flag)
|
||||
{
|
||||
return (flag ? "X" : " ");
|
||||
}
|
56
src/register/register-core/checkboxcell.h
Normal file
56
src/register/register-core/checkboxcell.h
Normal file
@ -0,0 +1,56 @@
|
||||
/********************************************************************\
|
||||
* checkboxcell.h -- yes/no checkbox cell *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02111-1307, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
/*
|
||||
* FILE:
|
||||
* checkboxcell.h
|
||||
*
|
||||
* FUNCTION:
|
||||
* The CheckboxCell object implements a cell handler
|
||||
* that will toggle between yes and no values when clicked upon by the mouse.
|
||||
*
|
||||
* HISTORY:
|
||||
* Copyright (c) 2002 Derek Atkins
|
||||
*/
|
||||
|
||||
#ifndef CHECKBOX_CELL_H
|
||||
#define CHECKBOX_CELL_H
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "basiccell.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
BasicCell cell;
|
||||
|
||||
gboolean flag;
|
||||
|
||||
} CheckboxCell;
|
||||
|
||||
BasicCell * gnc_checkbox_cell_new (void);
|
||||
|
||||
void gnc_checkbox_cell_set_flag (CheckboxCell *cell, gboolean flag);
|
||||
gboolean gnc_checkbox_cell_get_flag (CheckboxCell *cell);
|
||||
const char* gnc_checkbox_cell_get_string (gboolean flag);
|
||||
|
||||
#endif
|
@ -30,6 +30,7 @@
|
||||
#include "numcell.h"
|
||||
#include "pricecell.h"
|
||||
#include "recncell.h"
|
||||
#include "checkboxcell.h"
|
||||
#include "register-common.h"
|
||||
#include "quickfillcell.h"
|
||||
|
||||
@ -57,6 +58,8 @@ gnc_register_init (void)
|
||||
|
||||
gnc_register_add_cell_type (QUICKFILL_CELL_TYPE_NAME,
|
||||
gnc_quickfill_cell_new);
|
||||
|
||||
gnc_register_add_cell_type (CHECKBOX_CELL_TYPE_NAME, gnc_checkbox_cell_new);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -35,6 +35,7 @@
|
||||
#define PRICE_CELL_TYPE_NAME "price-cell"
|
||||
#define RECN_CELL_TYPE_NAME "recn-cell"
|
||||
#define QUICKFILL_CELL_TYPE_NAME "quickfill-cell"
|
||||
#define CHECKBOX_CELL_TYPE_NAME "checkbox-cell"
|
||||
|
||||
void gnc_register_init (void);
|
||||
void gnc_register_shutdown (void);
|
||||
|
Loading…
Reference in New Issue
Block a user