mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
add destroy method, minor doc updates
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@721 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
2361bccd9d
commit
0b9528673d
@ -49,12 +49,12 @@ typedef struct _PopBox {
|
||||
|
||||
static void selectCB (Widget w, XtPointer cd, XtPointer cb );
|
||||
static void dropDownCB (Widget w, XtPointer cd, XtPointer cb );
|
||||
static void realizeCombo (struct _BasicCell *bcell, void *w, int width);
|
||||
static void moveCombo (struct _BasicCell *bcell, int phys_row, int phys_col);
|
||||
static void destroyCombo (struct _BasicCell *bcell);
|
||||
static void setComboValue (struct _BasicCell *bcell, const char *value);
|
||||
static const char * enterCombo (struct _BasicCell *bcell, const char *value);
|
||||
static const char * leaveCombo (struct _BasicCell *bcell, const char *value);
|
||||
static void realizeCombo (BasicCell *bcell, void *w, int width);
|
||||
static void moveCombo (BasicCell *bcell, int phys_row, int phys_col);
|
||||
static void destroyCombo (BasicCell *bcell);
|
||||
static void setComboValue (BasicCell *bcell, const char *value);
|
||||
static const char * enterCombo (BasicCell *bcell, const char *value);
|
||||
static const char * leaveCombo (BasicCell *bcell, const char *value);
|
||||
|
||||
#define SET(cell,str) { \
|
||||
if ((cell)->value) free ((cell)->value); \
|
||||
@ -76,12 +76,71 @@ void xaccInitComboCell (ComboCell *cell)
|
||||
xaccInitBasicCell ( &(cell->cell));
|
||||
cell->cell.realize = realizeCombo;
|
||||
cell->cell.set_value = setComboValue;
|
||||
cell->cell.destroy = destroyCombo;
|
||||
cell->menuitems = (char **) malloc (sizeof (char *));
|
||||
cell->menuitems[0] = NULL;
|
||||
}
|
||||
|
||||
/* =============================================== */
|
||||
|
||||
static
|
||||
void destroyCombo (BasicCell *bcell)
|
||||
{
|
||||
ComboCell *cell;
|
||||
|
||||
cell = (ComboCell *) bcell;
|
||||
|
||||
/* the realize callback will be null if the cell
|
||||
* gui has been realized. Therefore, if its null,
|
||||
* destroy the gui
|
||||
*/
|
||||
if (!(cell->cell.realize)) {
|
||||
PopBox *box;
|
||||
|
||||
box = (PopBox *) (cell->cell.gui_private);
|
||||
|
||||
moveCombo (bcell, -1, -1);
|
||||
|
||||
XtDestroyWidget (box->combobox);
|
||||
free (box);
|
||||
|
||||
/* allow the widget to be created again */
|
||||
cell->cell.gui_private = NULL;
|
||||
cell->cell.realize = realizeCombo;
|
||||
cell->cell.move = NULL;
|
||||
cell->cell.enter_cell = NULL;
|
||||
cell->cell.leave_cell = NULL;
|
||||
cell->cell.destroy = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* =============================================== */
|
||||
|
||||
void xaccDestroyComboCell (ComboCell *cell)
|
||||
{
|
||||
int n = 0;
|
||||
char ** arr;
|
||||
|
||||
destroyCombo (&(cell->cell));
|
||||
|
||||
/* free malloced memory */
|
||||
arr = cell->menuitems;
|
||||
while (arr[n]) {
|
||||
free (arr[n]);
|
||||
n ++;
|
||||
}
|
||||
free (arr);
|
||||
cell->menuitems = NULL;
|
||||
|
||||
cell->cell.realize = NULL;
|
||||
cell->cell.set_value = NULL;
|
||||
|
||||
xaccDestroyBasicCell ( &(cell->cell));
|
||||
}
|
||||
|
||||
/* =============================================== */
|
||||
|
||||
void
|
||||
xaccAddComboCellMenuItem (ComboCell *cell, char * menustr)
|
||||
{
|
||||
@ -156,7 +215,7 @@ xaccSetComboCellValue (ComboCell *cell, const char * str)
|
||||
/* =============================================== */
|
||||
|
||||
static void
|
||||
setComboValue (struct _BasicCell *_cell, const char *str)
|
||||
setComboValue (BasicCell *_cell, const char *str)
|
||||
{
|
||||
ComboCell * cell = (ComboCell *) _cell;
|
||||
xaccSetComboCellValue (cell, str);
|
||||
@ -165,7 +224,7 @@ setComboValue (struct _BasicCell *_cell, const char *str)
|
||||
/* =============================================== */
|
||||
|
||||
static
|
||||
void realizeCombo (struct _BasicCell *bcell, void *w, int pixel_width)
|
||||
void realizeCombo (BasicCell *bcell, void *w, int pixel_width)
|
||||
{
|
||||
ComboCell *cell;
|
||||
PopBox *box;
|
||||
@ -246,7 +305,7 @@ void realizeCombo (struct _BasicCell *bcell, void *w, int pixel_width)
|
||||
/* =============================================== */
|
||||
|
||||
static
|
||||
void moveCombo (struct _BasicCell *bcell, int phys_row, int phys_col)
|
||||
void moveCombo (BasicCell *bcell, int phys_row, int phys_col)
|
||||
{
|
||||
ComboCell *cell;
|
||||
PopBox *box;
|
||||
@ -270,7 +329,7 @@ void moveCombo (struct _BasicCell *bcell, int phys_row, int phys_col)
|
||||
/* =============================================== */
|
||||
|
||||
static
|
||||
const char * enterCombo (struct _BasicCell *bcell, const char *value)
|
||||
const char * enterCombo (BasicCell *bcell, const char *value)
|
||||
{
|
||||
int phys_row, phys_col;
|
||||
String choice;
|
||||
@ -327,7 +386,7 @@ const char * enterCombo (struct _BasicCell *bcell, const char *value)
|
||||
/* =============================================== */
|
||||
|
||||
static
|
||||
const char * leaveCombo (struct _BasicCell *bcell, const char *value)
|
||||
const char * leaveCombo (BasicCell *bcell, const char *value)
|
||||
{
|
||||
ComboCell *cell;
|
||||
PopBox *box;
|
||||
@ -350,31 +409,6 @@ const char * leaveCombo (struct _BasicCell *bcell, const char *value)
|
||||
|
||||
/* =============================================== */
|
||||
|
||||
static
|
||||
void destroyCombo (struct _BasicCell *bcell)
|
||||
{
|
||||
ComboCell *cell;
|
||||
PopBox *box;
|
||||
|
||||
cell = (ComboCell *) bcell;
|
||||
box = (PopBox *) (cell->cell.gui_private);
|
||||
|
||||
moveCombo (bcell, -1, -1);
|
||||
|
||||
XtDestroyWidget (box->combobox);
|
||||
free (box);
|
||||
|
||||
/* allow the widget to be created again */
|
||||
cell->cell.gui_private = NULL;
|
||||
cell->cell.realize = realizeCombo;
|
||||
cell->cell.move = NULL;
|
||||
cell->cell.enter_cell = NULL;
|
||||
cell->cell.leave_cell = NULL;
|
||||
cell->cell.destroy = NULL;
|
||||
}
|
||||
|
||||
/* =============================================== */
|
||||
|
||||
static void selectCB (Widget w, XtPointer cd, XtPointer cb )
|
||||
|
||||
{
|
||||
|
@ -3,12 +3,38 @@
|
||||
* combocell.h
|
||||
*
|
||||
* FUNCTION:
|
||||
* Implements a combobox cell
|
||||
* The ComboCell object implements a cell handler with a
|
||||
* "combination-box" pull-down menu in it.
|
||||
*
|
||||
* On output, the currently selected menu item is displayed.
|
||||
* On input, the user can select from a list in the pull-down menu,
|
||||
* or use the keyboard to slect a menu entry by typing the first
|
||||
* few menu characters.
|
||||
*
|
||||
* METHODS:
|
||||
* The xaccAddComboCellMenuItem() method can be used to add a menu
|
||||
* item to the list.
|
||||
*
|
||||
*
|
||||
* HISTORY:
|
||||
* Created Jan 1998 Linas Vepstas
|
||||
* Copyright (c) 1998 Linas Vepstas
|
||||
*/
|
||||
/********************************************************************\
|
||||
* 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, write to the Free Software *
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
|
||||
\********************************************************************/
|
||||
|
||||
#ifndef __XACC_COMBO_CELL_C__
|
||||
#define __XACC_COMBO_CELL_C__
|
||||
@ -22,6 +48,8 @@ typedef struct _ComboCell {
|
||||
|
||||
ComboCell * xaccMallocComboCell (void);
|
||||
void xaccInitComboCell (ComboCell *);
|
||||
void xaccDestroyComboCell (ComboCell *);
|
||||
|
||||
void xaccSetComboCellValue (ComboCell *, const char *);
|
||||
|
||||
void xaccAddComboCellMenuItem (ComboCell *, char * menustr);
|
||||
|
Loading…
Reference in New Issue
Block a user