diff --git a/src/Ledger.c b/src/Ledger.c index dcf8161582..7ad0772fff 100644 --- a/src/Ledger.c +++ b/src/Ledger.c @@ -35,7 +35,7 @@ xaccLoadRegister (BasicRegister *reg, Split **slist) xaccSetBasicCellValue (reg->dateCell, buff); xaccSetBasicCellValue (reg->numCell, trans->num); - xaccSetBasicCellValue (reg->actionCell, split->action); + xaccSetBasicCellValue (&(reg->actionCell->cell), split->action); xaccSetQuickFillCellValue (reg->descCell, trans->description); xaccSetBasicCellValue (reg->memoCell, split->memo); diff --git a/src/RegWindow.c b/src/RegWindow.c index 00ff6929c6..f5c1f9ba08 100644 --- a/src/RegWindow.c +++ b/src/RegWindow.c @@ -671,7 +671,6 @@ recordCB( Widget mw, XtPointer cd, XtPointer cb ) { RegWindow *regData = (RegWindow *)cd; - XbaeMatrixCommitEdit( regData->reg, False ); /* hack alert */ /* regSaveTransaction( regData, regData->currEntry ); */ regData->changed = MOD_NONE; @@ -733,7 +732,6 @@ static void cancelCB( Widget mw, XtPointer cd, XtPointer cb ) { RegWindow *regData = (RegWindow *)cd; - XbaeMatrixCancelEdit( regData->reg, False ); } /************************** END OF FILE *************************/ diff --git a/src/main.c b/src/main.c index 5829b90cb9..621ed425f4 100644 --- a/src/main.c +++ b/src/main.c @@ -105,11 +105,11 @@ String fbRes[] = { "*recn*cellMarginWidth: 0", "*recn*cellMarginHeight: 0", /* combobox -- don't want the cell to be outlined */ - "*reg*popbox*shadowThickness: 0", - "*reg*popbox*list*shadowThickness: 1", /* we *do* want the combobox scroll bar to show, thoguh */ - "*reg*popbox*list*thickness: 24", /* slider width ignored ... why ??? */ - "*reg*popbox*list*VertScrollBar*width: 24", /* slider width ignored ... why ??? */ - "*reg*popbox*list*troughColor: #9999aa", /* ignored -- why ???*/ + "*reg*combocell*shadowThickness: 0", + "*reg*combocell*list*shadowThickness: 1", /* we *do* want the combobox scroll bar to show, thoguh */ + "*reg*combocell*list*thickness: 24", /* slider width ignored ... why ??? */ + "*reg*combocell*list*VertScrollBar*width: 24", /* slider width ignored ... why ??? */ + "*reg*combocell*list*troughColor: #9999aa", /* ignored -- why ???*/ NULL, }; diff --git a/src/register/Makefile b/src/register/Makefile index 418a07f7ff..ae24f06631 100644 --- a/src/register/Makefile +++ b/src/register/Makefile @@ -26,7 +26,7 @@ LIBXBAE = ../../lib/Xbae-4.6.2-linas/libXbae.a LIBCOMBO = ../lib/ComboBox-1.33/libComboBox.a LIBTRANS = ../Account.o ../Data.o ../FileIO.o ../Transaction.o ../date.o ###################################################################### -SRCS = actioncell.c basiccell.c cellblock.c combocell.c \ +SRCS = basiccell.c cellblock.c combocell.c \ datecell.c pricecell.c QuickFill.c quickfillcell.c \ recncell.c register.c table.c textcell.c OBJS = ${SRCS:.c=.o} diff --git a/src/register/actioncell.c b/src/register/actioncell.c deleted file mode 100644 index 642fc96081..0000000000 --- a/src/register/actioncell.c +++ /dev/null @@ -1,75 +0,0 @@ - -#include "actioncell.h" -#include "messages.h" - -static void realizeAction (struct _BasicCell *bcell, void *w, int width); -static void destroyAction (struct _BasicCell *bcell); - -/* =============================================== */ - -ActionCell *xaccMallocActionCell (void) -{ - ActionCell * cell; - cell = (ActionCell *) malloc (sizeof (ActionCell)); - xaccInitActionCell (cell); - return cell; -} - -void xaccInitActionCell (ActionCell *cell) -{ - xaccInitComboCell ( &(cell->cell)); - cell->chain_realize = cell->cell.cell.realize; - cell->cell.cell.realize = realizeAction; -} - -/* =============================================== */ - -static -void realizeAction (struct _BasicCell *bcell, void *w, int width) -{ - ActionCell *cell = (ActionCell *) bcell; - - /* first, call the combobox realize */ - cell->cell.cell.realize = cell->chain_realize; - if (cell->chain_realize) { - (cell->chain_realize) (bcell, w, width); - } - - /* now, install our destroy */ - cell->chain_destroy = cell->cell.cell.destroy; - cell->cell.cell.destroy = destroyAction; - - /* finally, add menu items */ - xaccAddComboCellMenuItem ( &(cell->cell), BUY_STR); - xaccAddComboCellMenuItem ( &(cell->cell), SELL_STR); - xaccAddComboCellMenuItem ( &(cell->cell), PRICE_STR); - xaccAddComboCellMenuItem ( &(cell->cell), INT_STR); - xaccAddComboCellMenuItem ( &(cell->cell), DIV_STR); - xaccAddComboCellMenuItem ( &(cell->cell), LTCG_STR); - xaccAddComboCellMenuItem ( &(cell->cell), STCG_STR); - xaccAddComboCellMenuItem ( &(cell->cell), DIST_STR); - xaccAddComboCellMenuItem ( &(cell->cell), SPLIT_STR); - xaccAddComboCellMenuItem ( &(cell->cell), DEPOSIT_STR); - xaccAddComboCellMenuItem ( &(cell->cell), WITHDRAW_STR); - -} - -/* =============================================== */ - -static -void destroyAction (struct _BasicCell *bcell) -{ - ActionCell *cell = (ActionCell *) bcell; - - /* first, call the combobox destroy */ - cell->cell.cell.destroy = cell->chain_destroy; - if (cell->chain_destroy) { - (cell->chain_destroy) (bcell); - } - - /* now, install our realize */ - cell->chain_realize = cell->cell.cell.realize; - cell->cell.cell.realize = realizeAction; -} - -/* =============== end of file =================== */ diff --git a/src/register/actioncell.h b/src/register/actioncell.h deleted file mode 100644 index 7068eee81a..0000000000 --- a/src/register/actioncell.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * FILE: - * actioncell.h - * - * FUNCTION: - * Implements a actionbox cell - * - * HISTORY: - * Created Jan 1998 Linas Vepstas - * Copyright (c) 1998 Linas Vepstas - */ - -#ifndef __XACC_ACTION_CELL_C__ -#define __XACC_ACTION_CELL_C__ - -#include "combocell.h" - -typedef struct _ActionCell { - ComboCell cell; - void (* chain_realize) (struct _BasicCell *, - void *gui_handle, - int pixel_width); - void (* chain_destroy) (struct _BasicCell *); -} ActionCell; - -ActionCell * xaccMallocActionCell (void); -void xaccInitActionCell (ActionCell *); - -#endif /* __XACC_ACTION_CELL_C__ */ - -/* --------------- end of file ---------------------- */ diff --git a/src/register/combocell.c b/src/register/combocell.c index cfc712b597..b164431741 100644 --- a/src/register/combocell.c +++ b/src/register/combocell.c @@ -42,6 +42,8 @@ void xaccInitComboCell (ComboCell *cell) { xaccInitBasicCell ( &(cell->cell)); cell->cell.realize = realizeCombo; + cell->menuitems = (char **) malloc (sizeof (char *)); + cell->menuitems[0] = NULL; } /* =============================================== */ @@ -49,15 +51,26 @@ void xaccInitComboCell (ComboCell *cell) void xaccAddComboCellMenuItem (ComboCell *cell, char * menustr) { - PopBox *box; - XmString str; - box = (PopBox *) (cell->cell.gui_private); + int n = 0; + char ** oldarr; - if (!box) return; + if (!cell) return; + if (!menustr) return; - str = XmStringCreateLtoR (menustr, XmSTRING_DEFAULT_CHARSET); - XmComboBoxAddItem (box->combobox, str, 0); - XmStringFree (str); + oldarr = cell->menuitems; + while (oldarr[n]) n ++; + + cell->menuitems = (char **) malloc ((n+2) *sizeof (char *)); + + n = 0; + while (oldarr[n]) { + cell->menuitems[n] = oldarr[n]; + n++; + } + cell->menuitems[n] = strdup (menustr); + cell->menuitems[n+1] = NULL; + + free (oldarr); } /* =============================================== */ @@ -100,7 +113,7 @@ void realizeCombo (struct _BasicCell *bcell, void *w, int pixel_width) /* create the pop GUI */ combobox = XtVaCreateManagedWidget - ("popbox", xmComboBoxWidgetClass, parent, + ("combocell", xmComboBoxWidgetClass, parent, XmNshadowThickness, 0, /* don't draw a shadow, * use bae shadows */ XmNeditable, False, /* user can only pick from list */ @@ -121,7 +134,24 @@ void realizeCombo (struct _BasicCell *bcell, void *w, int pixel_width) XtAddCallback (combobox, XmNunselectionCallback, selectCB, (XtPointer)cell); XtAddCallback (combobox, XmNdropDownCallback, dropDownCB, (XtPointer)box); + /* unmap the widget by moving it to an invlid location */ moveCombo (bcell, -1, -1); + + /* add menu items */ + if (cell->menuitems) { + char * menustr; + int i=0; + + menustr = cell->menuitems[i]; + while (menustr) { + XmString str; + str = XmStringCreateLtoR (menustr, XmSTRING_DEFAULT_CHARSET); + XmComboBoxAddItem (box->combobox, str, 0); + XmStringFree (str); + i++; + menustr = cell->menuitems[i]; + } + } } /* =============================================== */ diff --git a/src/register/combocell.h b/src/register/combocell.h index cde13f78f4..7bc6d58921 100644 --- a/src/register/combocell.h +++ b/src/register/combocell.h @@ -17,6 +17,7 @@ typedef struct _ComboCell { BasicCell cell; + char ** menuitems; } ComboCell; ComboCell * xaccMallocComboCell (void); diff --git a/src/register/register.c b/src/register/register.c index 97a9a733a0..5d79cdfdb9 100644 --- a/src/register/register.c +++ b/src/register/register.c @@ -3,7 +3,7 @@ * register.c */ -#include "actioncell.h" +#include "messages.h" #include "register.h" #define DATE_CELL_C 0 @@ -67,22 +67,22 @@ void xaccInitBasicRegister (BasicRegister *reg) cell = (BasicCell *) xaccMallocDateCell(); cell->width = 11; xaccAddCell (header, cell, 0, DATE_CELL_C); - xaccSetBasicCellValue (cell, "Date"); + xaccSetBasicCellValue (cell, DATE_STR); cell = xaccMallocTextCell(); cell->width = 7; xaccAddCell (header, cell, 0, NUM_CELL_C); - xaccSetBasicCellValue (cell, "Num"); + xaccSetBasicCellValue (cell, NUM_STR); cell = xaccMallocTextCell(); cell->width = 11; xaccAddCell (header, cell, XFRM_CELL_R, XFRM_CELL_C); - xaccSetBasicCellValue (cell, "Transfer From"); + xaccSetBasicCellValue (cell, XFRM_STR); cell = xaccMallocTextCell(); cell->width = 29; xaccAddCell (header, cell, 0, DESC_CELL_C); - xaccSetBasicCellValue (cell, "Description"); + xaccSetBasicCellValue (cell, DESC_STR); cell = xaccMallocRecnCell(); cell->width = 1; @@ -92,17 +92,17 @@ void xaccInitBasicRegister (BasicRegister *reg) cell = (BasicCell *) xaccMallocPriceCell(); cell->width = 9; xaccAddCell (header, cell, 0, CRED_CELL_C); - xaccSetBasicCellValue (cell, "Credit"); + xaccSetBasicCellValue (cell, CREDIT_STR); cell = (BasicCell *) xaccMallocPriceCell(); cell->width = 9; xaccAddCell (header, cell, 0, DEBT_CELL_C); - xaccSetBasicCellValue (cell, "Debit"); + xaccSetBasicCellValue (cell, DEBIT_STR); cell = (BasicCell *) xaccMallocPriceCell(); cell->width = 9; xaccAddCell (header, cell, 0, BALN_CELL_C); - xaccSetBasicCellValue (cell, "Balance"); + xaccSetBasicCellValue (cell, BALN_STR); /* --------------------------- */ @@ -119,15 +119,13 @@ void xaccInitBasicRegister (BasicRegister *reg) xaccAddCell (curs, cell, NUM_CELL_R, NUM_CELL_C); reg->numCell = cell; - cell = (BasicCell *) xaccMallocActionCell(); - cell->width = 7; - xaccAddCell (curs, cell, ACTN_CELL_R, ACTN_CELL_C); - reg->actionCell = cell; + reg->actionCell = xaccMallocComboCell(); + reg->actionCell->cell.width = 7; + xaccAddCell (curs, &(reg->actionCell->cell), ACTN_CELL_R, ACTN_CELL_C); - cell = xaccMallocTextCell(); - cell->width = 11; - xaccAddCell (curs, cell, XFRM_CELL_R, XFRM_CELL_C); - reg->xferCell = cell; + reg->xfrmCell = xaccMallocComboCell(); + reg->xfrmCell->cell.width = 11; + xaccAddCell (curs, &(reg->xfrmCell->cell), XFRM_CELL_R, XFRM_CELL_C); reg->descCell = xaccMallocQuickFillCell(); reg->descCell->cell.width = 9; @@ -169,6 +167,21 @@ void xaccInitBasicRegister (BasicRegister *reg) xaccNextRight (curs, MEMO_CELL_R, MEMO_CELL_C, -1-DATE_CELL_R, -1-DATE_CELL_C); + /* -------------------------------- */ + /* add menu items for the action cell */ + + xaccAddComboCellMenuItem ( reg->actionCell, BUY_STR); + xaccAddComboCellMenuItem ( reg->actionCell, SELL_STR); + xaccAddComboCellMenuItem ( reg->actionCell, PRICE_STR); + xaccAddComboCellMenuItem ( reg->actionCell, INT_STR); + xaccAddComboCellMenuItem ( reg->actionCell, DIV_STR); + xaccAddComboCellMenuItem ( reg->actionCell, LTCG_STR); + xaccAddComboCellMenuItem ( reg->actionCell, STCG_STR); + xaccAddComboCellMenuItem ( reg->actionCell, DIST_STR); + xaccAddComboCellMenuItem ( reg->actionCell, SPLIT_STR); + xaccAddComboCellMenuItem ( reg->actionCell, DEPOSIT_STR); + xaccAddComboCellMenuItem ( reg->actionCell, WITHDRAW_STR); + /* -------------------------------- */ table = xaccMallocTable (0, 0); table -> header = header; diff --git a/src/register/register.h b/src/register/register.h index 78a8d6786e..7d33ee78e8 100644 --- a/src/register/register.h +++ b/src/register/register.h @@ -7,6 +7,7 @@ #define __XACC_REGISTER_H__ #include "basiccell.h" +#include "combocell.h" #include "datecell.h" #include "quickfillcell.h" #include "pricecell.h" @@ -20,8 +21,8 @@ typedef struct _BasicRegister { CellBlock * header; BasicCell * dateCell; BasicCell * numCell; - BasicCell * actionCell; - BasicCell * xferCell; + ComboCell * actionCell; + ComboCell * xfrmCell; QuickFillCell * descCell; BasicCell * memoCell; BasicCell * recnCell;