mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Changes made to support actions -- merge from action branch
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@39 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
3b56e3d067
commit
d23eeab098
179
src/Action.c
Normal file
179
src/Action.c
Normal file
@ -0,0 +1,179 @@
|
||||
/********************************************************************\
|
||||
* action.c -- account actions for xacc (X-Accountant) *
|
||||
* Copyright (C) 1997 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. *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
#include <Xm/Xm.h>
|
||||
#include <ComboBox.h>
|
||||
#include <Xbae/Matrix.h>
|
||||
#include "Action.h"
|
||||
#include "util.h"
|
||||
|
||||
/** STRUCTS *********************************************************/
|
||||
typedef struct _ActionBox {
|
||||
Widget combobox;
|
||||
Widget reg; /* the parent register widget */
|
||||
int currow;
|
||||
int curcol;
|
||||
} ActionBox;
|
||||
|
||||
/** PROTOTYPES ******************************************************/
|
||||
|
||||
void selectCB (Widget w, XtPointer cd, XtPointer cb );
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
* actionBox *
|
||||
* creates the action widget *
|
||||
* *
|
||||
* Args: parent - the parent of this window *
|
||||
* Return: actionData - the action GUI structure *
|
||||
\********************************************************************/
|
||||
|
||||
#define ADD_MENU_ITEM(menustr) { \
|
||||
str = XmStringCreateLtoR (menustr, XmSTRING_DEFAULT_CHARSET); \
|
||||
XmComboBoxAddItem(combobox, str, 0); XmStringFree(str); \
|
||||
}
|
||||
|
||||
|
||||
ActionBox *
|
||||
actionBox (Widget parent)
|
||||
{
|
||||
Widget combobox;
|
||||
XmString str;
|
||||
ActionBox *actionData;
|
||||
|
||||
/* malloc the action GUI structure */
|
||||
actionData = (ActionBox *) _malloc (sizeof (ActionBox));
|
||||
actionData->currow = -1;
|
||||
actionData->curcol = -1;
|
||||
actionData->reg = parent;
|
||||
|
||||
/* create the action GUI */
|
||||
combobox = XtVaCreateManagedWidget("actionbox", xmComboBoxWidgetClass, parent,
|
||||
XmNshadowThickness, 0, /* don't draw a shadow, use bae shadows */
|
||||
XmNeditable, False, /* user can only pick from list */
|
||||
XmNsorted, False,
|
||||
XmNshowLabel, False,
|
||||
XmNmarginHeight, 0,
|
||||
XmNmarginWidth, 0,
|
||||
XmNselectionPolicy, XmSINGLE_SELECT,
|
||||
XmNvalue, "",
|
||||
|
||||
/* hack alert -- the width of the combobox should be relative to the font, should
|
||||
be relative to the size of the cell in which it will fit. */
|
||||
XmNwidth, 43,
|
||||
NULL);
|
||||
|
||||
actionData -> combobox = combobox;
|
||||
|
||||
/* build the action menu */
|
||||
ADD_MENU_ITEM("Buy");
|
||||
ADD_MENU_ITEM("Sell");
|
||||
ADD_MENU_ITEM("Price");
|
||||
ADD_MENU_ITEM("Div");
|
||||
ADD_MENU_ITEM("LTCG");
|
||||
ADD_MENU_ITEM("STCG");
|
||||
ADD_MENU_ITEM("Dist");
|
||||
ADD_MENU_ITEM("Split");
|
||||
|
||||
/* add callbacks to detect a selection */
|
||||
XtAddCallback (combobox, XmNselectionCallback, selectCB, (XtPointer)actionData);
|
||||
XtAddCallback (combobox, XmNunselectionCallback, selectCB, (XtPointer)actionData);
|
||||
|
||||
|
||||
return actionData;
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
void SetActionBox (ActionBox *ab, int row, int col)
|
||||
{
|
||||
String choice;
|
||||
XmString choosen;
|
||||
|
||||
/* if the drop-down menu is showing, hide it now */
|
||||
XmComboBoxHideList (ab->combobox);
|
||||
|
||||
/* if there is an old widget, remove it */
|
||||
if ((0 <= ab->currow) && (0 <= ab->curcol)) {
|
||||
XbaeMatrixSetCellWidget (ab->reg, ab->currow, ab->curcol, NULL);
|
||||
}
|
||||
ab->currow = row;
|
||||
ab->curcol = col;
|
||||
|
||||
/* if the new position is valid, go to it,
|
||||
* otherwise, unmanage the widget */
|
||||
if ((0 <= ab->currow) && (0 <= ab->curcol)) {
|
||||
|
||||
/* Get the current cell contents, and set the
|
||||
* combobox menu selction to match the contents */
|
||||
choice = XbaeMatrixGetCell (ab->reg, ab->currow, ab->curcol);
|
||||
|
||||
/* do a menu selection only if the cell ain't empty. */
|
||||
if (0x0 != choice[0]) {
|
||||
/* convert String to XmString ... arghhh */
|
||||
choosen = XmCvtCTToXmString (choice);
|
||||
XmComboBoxSelectItem (ab->combobox, choosen, False);
|
||||
XmStringFree (choosen);
|
||||
} else {
|
||||
XmComboBoxClearItemSelection (ab->combobox);
|
||||
}
|
||||
|
||||
/* set the cell widget */
|
||||
XbaeMatrixSetCellWidget (ab->reg, row, col, ab->combobox);
|
||||
|
||||
if (!XtIsManaged (ab->combobox)) {
|
||||
XtManageChild (ab->combobox);
|
||||
}
|
||||
|
||||
/* drop down the menu so that its ready to go. */
|
||||
XmComboBoxShowList (ab->combobox);
|
||||
} else {
|
||||
XtUnmanageChild (ab->combobox);
|
||||
}
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
* selectCB -- get the user's selection, put the string into the *
|
||||
* cell. *
|
||||
* *
|
||||
* Args: w - the widget that called us *
|
||||
* cd - actionData - the data struct for this combobox *
|
||||
* cb - *
|
||||
* Return: none *
|
||||
\********************************************************************/
|
||||
|
||||
void selectCB (Widget w, XtPointer cd, XtPointer cb )
|
||||
|
||||
{
|
||||
ActionBox *ab = (ActionBox *) cd;
|
||||
XmComboBoxSelectionCallbackStruct *selection =
|
||||
(XmComboBoxSelectionCallbackStruct *) cb;
|
||||
char * choice;
|
||||
|
||||
choice = XmCvtXmStringToCT (selection->value);
|
||||
if (0x0 == choice) choice = "";
|
||||
|
||||
XbaeMatrixSetCell (ab->reg, ab->currow, ab->curcol, choice);
|
||||
|
||||
/* a diffeent way of getting the user's selection ... */
|
||||
/* text = XmComboBoxGetString (ab->combobox); */
|
||||
}
|
||||
/************************* END OF FILE ******************************/
|
46
src/FileIO.c
46
src/FileIO.c
@ -28,9 +28,13 @@
|
||||
* position in the file, and so the order which these *
|
||||
* functions are called in important *
|
||||
* *
|
||||
* Version 1 is the original file format *
|
||||
* *
|
||||
* Version 2 of the file format supports reading and writing of *
|
||||
* double-entry transactions. *
|
||||
* *
|
||||
* Version 3 of the file format supports actions (Buy, Sell, etc.) *
|
||||
* *
|
||||
* *
|
||||
* the format of the data in the file: *
|
||||
* file ::== token numAccounts (Account)^numAccounts *
|
||||
@ -52,6 +56,7 @@
|
||||
* date ::== Date *
|
||||
* description ::== String *
|
||||
* memo ::== String *
|
||||
* action ::== String *
|
||||
* catagory ::== int *
|
||||
* reconciled ::== char *
|
||||
* amount ::== double *
|
||||
@ -76,7 +81,7 @@
|
||||
#define PERMS 0666
|
||||
#define WFLAGS (O_WRONLY | O_CREAT | O_TRUNC)
|
||||
#define RFLAGS O_RDONLY
|
||||
#define VERSION 2
|
||||
#define VERSION 3
|
||||
|
||||
/** GLOBALS *********************************************************/
|
||||
extern Widget toplevel;
|
||||
@ -184,7 +189,7 @@ readData( char *datafile )
|
||||
|
||||
/* If this is an old file, ask the user if the file
|
||||
* should be updated */
|
||||
if( token < VERSION )
|
||||
if( VERSION > token )
|
||||
{
|
||||
char msg[BUFSIZE];
|
||||
sprintf( (char *)&msg, FILE_TOO_OLD_MSG );
|
||||
@ -194,7 +199,7 @@ readData( char *datafile )
|
||||
|
||||
/* If this is a newer file than we know how to deal
|
||||
* with, warn the user */
|
||||
if( token > VERSION )
|
||||
if( VERSION < token )
|
||||
{
|
||||
char msg[BUFSIZE];
|
||||
sprintf( (char *)&msg, FILE_TOO_NEW_MSG );
|
||||
@ -390,13 +395,28 @@ readTransaction( int fd, Account *acc, int token )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* actin first introduced in version 3 of the file format */
|
||||
if (3 <= token) {
|
||||
trans->action = readString( fd, token );
|
||||
if( trans->action == NULL )
|
||||
{
|
||||
DEBUG ("Error: Premature end of Transaction at memo");
|
||||
XtFree(trans->description);
|
||||
XtFree(trans->num);
|
||||
XtFree(trans->memo);
|
||||
_free(trans);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
err = read( fd, &(trans->catagory), sizeof(int) );
|
||||
if( err != sizeof(int) )
|
||||
{
|
||||
DEBUG ("Error: Premature end of Transaction at category");
|
||||
XtFree(trans->memo);
|
||||
DEBUG ("Error: Premature end of Transaction at catagory");
|
||||
XtFree(trans->description);
|
||||
XtFree(trans->num);
|
||||
XtFree(trans->memo);
|
||||
XtFree(trans->action);
|
||||
_free(trans);
|
||||
return NULL;
|
||||
}
|
||||
@ -428,10 +448,12 @@ readTransaction( int fd, Account *acc, int token )
|
||||
if( (trans->reconciled != YREC) && (trans->reconciled != CREC) )
|
||||
trans->reconciled = NREC;
|
||||
|
||||
/* Version 1 files stored the amount as an integer,
|
||||
* with the amount recorded as pennies.
|
||||
* Version 2 and above store the share amounts and
|
||||
* prices as doubles. */
|
||||
if (1 == token) {
|
||||
int amount;
|
||||
/* version 1 files stored the amount as an integer,
|
||||
* with the amount recorded as pennies */
|
||||
err = read( fd, &amount, sizeof(int) );
|
||||
if( err != sizeof(int) )
|
||||
{
|
||||
@ -477,8 +499,8 @@ readTransaction( int fd, Account *acc, int token )
|
||||
}
|
||||
DEBUGCMD(printf ("Info: readTransaction(): amount %f \n", trans->damount));
|
||||
|
||||
/* read the account numbers for double-entry */
|
||||
/* these are first used in version 2 of the file format */
|
||||
/* Read the account numbers for double-entry */
|
||||
/* These are first used in Version 2 of the file format */
|
||||
if (1 < token) {
|
||||
Account *peer_acc;
|
||||
/* first, read the credit account number */
|
||||
@ -520,7 +542,7 @@ readTransaction( int fd, Account *acc, int token )
|
||||
if (peer_acc) insertTransaction( peer_acc, trans );
|
||||
} else {
|
||||
|
||||
/* version 1 files did not do double-entry */
|
||||
/* Version 1 files did not do double-entry */
|
||||
insertTransaction( acc, trans );
|
||||
}
|
||||
|
||||
@ -781,6 +803,10 @@ writeTransaction( int fd, Account * acc, Transaction *trans )
|
||||
if( err == -1 )
|
||||
return err;
|
||||
|
||||
err = writeString( fd, trans->action );
|
||||
if( err == -1 )
|
||||
return err;
|
||||
|
||||
tmp = trans->catagory;
|
||||
XACC_FLIP_INT (tmp);
|
||||
err = write( fd, &tmp, sizeof(int) );
|
||||
|
@ -498,7 +498,9 @@ fileMenubarCB( Widget mw, XtPointer cd, XtPointer cb )
|
||||
data->new = True; /* so we have to do a "SaveAs" when
|
||||
* the file is first saved */
|
||||
break;
|
||||
case FMB_OPEN:
|
||||
|
||||
case FMB_OPEN: {
|
||||
char * newfile;
|
||||
DEBUG("FMB_OPEN");
|
||||
if( (!(data->saved)) && (datafile != NULL) )
|
||||
{
|
||||
@ -506,32 +508,39 @@ fileMenubarCB( Widget mw, XtPointer cd, XtPointer cb )
|
||||
if( verifyBox(toplevel,msg) )
|
||||
fileMenubarCB( mw, (XtPointer)FMB_SAVE, cb );
|
||||
}
|
||||
freeData(data);
|
||||
while( (datafile = fileBox(toplevel,OPEN)) == NULL )
|
||||
printf("Bad File\n");
|
||||
newfile = fileBox(toplevel,OPEN);
|
||||
if (newfile) {
|
||||
datafile = newfile;
|
||||
freeData(data);
|
||||
|
||||
/* load the accounts from the users datafile */
|
||||
data = readData(datafile);
|
||||
/* load the accounts from the users datafile */
|
||||
data = readData(datafile);
|
||||
|
||||
if( data == NULL )
|
||||
{
|
||||
/* the file could not be found */
|
||||
data = mallocData();
|
||||
if( data == NULL ) {
|
||||
/* the file could not be found */
|
||||
data = mallocData();
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FMB_SAVE:
|
||||
DEBUG("FMB_SAVE");
|
||||
/* ??? Somehow make sure all in-progress edits get committed! */
|
||||
writeData( datafile, data );
|
||||
data->saved = True;
|
||||
break;
|
||||
case FMB_SAVEAS:
|
||||
|
||||
case FMB_SAVEAS: {
|
||||
char * newfile;
|
||||
DEBUG("FMB_SAVEAS");
|
||||
while( (datafile = fileBox(toplevel,OPEN)) == NULL )
|
||||
printf("Bad File\n");
|
||||
fileMenubarCB( mw, (XtPointer)FMB_SAVE, cb );
|
||||
|
||||
newfile = fileBox(toplevel,OPEN);
|
||||
if ( newfile ) {
|
||||
datafile = newfile;
|
||||
fileMenubarCB( mw, (XtPointer)FMB_SAVE, cb );
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FMB_QUIT:
|
||||
DEBUG("FMB_QUIT");
|
||||
{
|
||||
|
@ -26,7 +26,7 @@
|
||||
######################################################################
|
||||
# DO NOT EDIT THE STUFF BELOW THIS LINE! #
|
||||
|
||||
OBJS = Account.o AccWindow.o AdjBWindow.o BuildMenu.o Data.o date.o \
|
||||
OBJS = Account.o AccWindow.o Action.o AdjBWindow.o BuildMenu.o Data.o date.o \
|
||||
FileBox.o FileIO.o HelpWindow.o main.o MainWindow.o \
|
||||
QIFIO.o QuickFill.o RecnWindow.o RegWindow.o Reports.o \
|
||||
Transaction.o util.o XferWindow.o
|
||||
@ -37,9 +37,9 @@ TARGET = ../xacc
|
||||
|
||||
default: $(TARGET)
|
||||
|
||||
$(TARGET): $(OBJS) ../libhtmlw/libhtmlw.a ../Xbae-4.6.2-linas/src/libXbae.a
|
||||
$(TARGET): $(OBJS) ../lib/libhtmlw.a ../lib/libComboBox.a ../Xbae-4.6.2-linas/src/libXbae.a
|
||||
@echo "++++++"
|
||||
$(CC) $(OBJS) $(LFLAGS) ../libhtmlw/libhtmlw.a \
|
||||
$(CC) $(OBJS) $(LFLAGS) -lhtmlw -lComboBox \
|
||||
../Xbae-4.6.2-linas/src/libXbae.a $(LIBS) -o $@
|
||||
|
||||
.c.o: Makefile
|
||||
|
14
src/QIFIO.c
14
src/QIFIO.c
@ -44,9 +44,6 @@
|
||||
#define WFLAGS (O_WRONLY | O_CREAT | O_TRUNC)
|
||||
#define RFLAGS O_RDONLY
|
||||
|
||||
/** GLOBALS *********************************************************/
|
||||
extern Widget toplevel;
|
||||
|
||||
/********************************************************************\
|
||||
* xaccReadQIFLine *
|
||||
* reads in one line of ASCII, until cr-nl *
|
||||
@ -154,6 +151,9 @@ char * xaccReadQIFAccount (int fd, Account * acc)
|
||||
} else
|
||||
if ('T' == qifline [0]) {
|
||||
|
||||
if (!strcmp (&qifline[1], "Bank\r\n")) {
|
||||
acc -> type = BANK;
|
||||
} else
|
||||
if (!strcmp (&qifline[1], "Invst\r\n")) {
|
||||
acc -> type = PORTFOLIO;
|
||||
} else {
|
||||
@ -297,10 +297,14 @@ char * xaccReadQIFTransaction (int fd, Transaction *trans)
|
||||
if ('M' == qifline [0]) { /* M == memo field */
|
||||
XACC_PREP_STRING (trans->memo);
|
||||
} else
|
||||
if ('Y' == qifline [0]) { /* Y == ?? */
|
||||
if ('P' == qifline [0]) { /* P == Payee, for Bank accounts */
|
||||
XACC_PREP_STRING (trans->description);
|
||||
} else
|
||||
if ('N' == qifline [0]) { /* N == check number aka type of transfer */
|
||||
if ('Y' == qifline [0]) { /* Y == Name of Security */
|
||||
XACC_PREP_STRING (trans->description);
|
||||
} else
|
||||
/* N == check numbers for Banks, but Action for portfolios */
|
||||
if ('N' == qifline [0]) {
|
||||
XACC_PREP_STRING (trans->num);
|
||||
if (!strncmp (qifline, "NSell", 5)) isneg = 1;
|
||||
} else
|
||||
|
121
src/RegWindow.c
121
src/RegWindow.c
@ -24,26 +24,28 @@
|
||||
\********************************************************************/
|
||||
|
||||
#include <Xm/Xm.h>
|
||||
#include <Xm/Form.h>
|
||||
#include <Xm/Text.h>
|
||||
#include <Xm/DialogS.h>
|
||||
#include <Xm/PanedW.h>
|
||||
#include <Xm/Form.h>
|
||||
#include <Xm/Frame.h>
|
||||
#include <Xm/RowColumn.h>
|
||||
#include <Xm/PushB.h>
|
||||
#include <Xm/LabelGP.h>
|
||||
#include <Xm/PanedW.h>
|
||||
#include <Xm/PushB.h>
|
||||
#include <Xm/RowColumn.h>
|
||||
#include <Xm/Text.h>
|
||||
#include <Xbae/Matrix.h>
|
||||
#include "main.h"
|
||||
#include "util.h"
|
||||
#include "date.h"
|
||||
#include "Data.h"
|
||||
|
||||
#include "Account.h"
|
||||
#include "ActionBox.h"
|
||||
#include "AdjBWindow.h"
|
||||
#include "BuildMenu.h"
|
||||
#include "Data.h"
|
||||
#include "date.h"
|
||||
#include "main.h"
|
||||
#include "MainWindow.h"
|
||||
#include "QuickFill.h"
|
||||
#include "BuildMenu.h"
|
||||
#include "RecnWindow.h"
|
||||
#include "AdjBWindow.h"
|
||||
#include "Transaction.h"
|
||||
#include "util.h"
|
||||
|
||||
/** STRUCTS *********************************************************/
|
||||
/* The RegWindow struct contains info needed by an instance of an open
|
||||
@ -60,6 +62,7 @@ typedef struct _RegWindow {
|
||||
QuickFill *qf; /* keeps track of current quickfill node. *
|
||||
* Reset to Account->qfRoot when entering *
|
||||
* a new transaction */
|
||||
ActionBox *ab;
|
||||
} RegWindow;
|
||||
|
||||
|
||||
@ -138,9 +141,8 @@ extern Pixel negPixel;
|
||||
#define SHRS_CELL_C (acc->columnLocation[SHRS_COL_ID])
|
||||
#define ACTN_CELL_C (acc->columnLocation[ACTN_COL_ID])
|
||||
|
||||
/* these columns/rows are still hard coded ... should be switched over, I guess */
|
||||
#define MEMO_CELL_R 1
|
||||
#define MEMO_CELL_C 2
|
||||
#define MEMO_CELL_C DESC_CELL_C /* same cilumn as the description */
|
||||
|
||||
/** COOL MACROS *****************************************************/
|
||||
#define IN_DATE_CELL(R,C) (((R-1)%2==0) && (C==DATE_CELL_C)) /* Date cell */
|
||||
@ -151,9 +153,11 @@ extern Pixel negPixel;
|
||||
#define IN_DEP_CELL(R,C) (((R-1)%2==0) && (C==DEP_CELL_C)) /* Deposit cell */
|
||||
#define IN_BALN_CELL(R,C) (((R-1)%2==0) && (C==BALN_CELL_C)) /* Balance cell */
|
||||
#define IN_PRIC_CELL(R,C) (((R-1)%2==0) && (C==PRIC_CELL_C)) /* Price cell */
|
||||
#define IN_ACTN_CELL(R,C) (((R-1)%2==0) && (C==ACTN_CELL_C)) /* Action cell */
|
||||
|
||||
#define IN_YEAR_CELL(R,C) (((R-1)%2==1) && (C==DATE_CELL_C)) /* Year cell */
|
||||
#define IN_MEMO_CELL(R,C) (((R-1)%2==1) && (C==2)) /* Memo cell */
|
||||
#define IN_BAD_CELL(R,C) (((R-1)%2==1) && (C==3)) /* cell after memo */
|
||||
#define IN_MEMO_CELL(R,C) (((R-1)%2==1) && (C==MEMO_CELL_C)) /* Memo cell */
|
||||
#define IN_BAD_CELL(R,C) (((R-1)%2==1) && (C!=MEMO_CELL_C)) /* Not the memo cell*/
|
||||
|
||||
|
||||
/********************************************************************/
|
||||
@ -227,6 +231,7 @@ regRefresh( RegWindow *regData )
|
||||
|
||||
newData[row+1][NUM_CELL_C] = XtNewString("");
|
||||
|
||||
|
||||
sprintf( buf, "%s", trans->description );
|
||||
newData[row][DESC_CELL_C] = XtNewString(buf);
|
||||
|
||||
@ -302,10 +307,16 @@ regRefresh( RegWindow *regData )
|
||||
sprintf( buf, "%.2f ", trans->share_price );
|
||||
newData[row][PRIC_CELL_C] = XtNewString(buf);
|
||||
newData[row+1][PRIC_CELL_C] = XtNewString("");
|
||||
|
||||
/* don't set number of shares here -- this is computed later,
|
||||
* in recomputeBalance. */
|
||||
newData[row][SHRS_CELL_C] = XtNewString("");
|
||||
newData[row+1][SHRS_CELL_C] = XtNewString("");
|
||||
/* newData[row][ACTN_CELL_C] = XtNewString(""); */
|
||||
/* newData[row+1][ACTN_CELL_C] = XtNewString(""); */
|
||||
|
||||
sprintf( buf, "%s", trans->action );
|
||||
newData[row][ACTN_CELL_C] = XtNewString(buf);
|
||||
newData[row+1][ACTN_CELL_C] = XtNewString("");
|
||||
|
||||
break;
|
||||
default:
|
||||
fprintf( stderr, "Ineternal Error: Account type: %d is unknown!\n", acc->type);
|
||||
@ -549,6 +560,16 @@ regSaveTransaction( RegWindow *regData, int position )
|
||||
}
|
||||
}
|
||||
|
||||
if( regData->changed & MOD_ACTN )
|
||||
{
|
||||
String actn = NULL;
|
||||
DEBUG("MOD_ACTN");
|
||||
/* ... the action ... */
|
||||
XtFree( trans->action );
|
||||
actn = XbaeMatrixGetCell(regData->reg,row,ACTN_CELL_C);
|
||||
trans->action = XtNewString( actn );
|
||||
}
|
||||
|
||||
if( regData->changed & MOD_RECN )
|
||||
{
|
||||
DEBUG("MOD_RECN");
|
||||
@ -606,6 +627,7 @@ regSaveTransaction( RegWindow *regData, int position )
|
||||
float val=0.0; /* must be float for sscanf to work */
|
||||
|
||||
DEBUG("MOD_PRIC");
|
||||
/* ...the price flag ... */
|
||||
|
||||
price = XbaeMatrixGetCell(regData->reg,row,PRIC_CELL_C);
|
||||
sscanf( price, "%f", &val );
|
||||
@ -628,6 +650,7 @@ regSaveTransaction( RegWindow *regData, int position )
|
||||
if( (strcmp("",trans->num) == 0) &&
|
||||
(strcmp("",trans->description) == 0) &&
|
||||
(strcmp("",trans->memo) == 0) &&
|
||||
(strcmp("",trans->action) == 0) &&
|
||||
(0 == trans->catagory) &&
|
||||
(1.0 == trans->share_price) &&
|
||||
(0.0 == trans->damount) )
|
||||
@ -892,15 +915,15 @@ regWindow( Widget parent, Account *acc )
|
||||
case MUTUAL:
|
||||
acc->columnLocation [DATE_COL_ID] = 0;
|
||||
acc->columnLocation [NUM_COL_ID] = 1;
|
||||
/* acc->columnLocation [ACTN_COL_ID] = 2; */
|
||||
acc->columnLocation [DESC_COL_ID] = 2;
|
||||
acc->columnLocation [RECN_COL_ID] = 3;
|
||||
acc->columnLocation [PAY_COL_ID] = 4;
|
||||
acc->columnLocation [DEP_COL_ID] = 5;
|
||||
acc->columnLocation [PRIC_COL_ID] = 6;
|
||||
acc->columnLocation [SHRS_COL_ID] = 7;
|
||||
acc->columnLocation [BALN_COL_ID] = 8;
|
||||
acc -> numCols = 9;
|
||||
acc->columnLocation [ACTN_COL_ID] = 2;
|
||||
acc->columnLocation [DESC_COL_ID] = 3;
|
||||
acc->columnLocation [RECN_COL_ID] = 4;
|
||||
acc->columnLocation [PAY_COL_ID] = 5;
|
||||
acc->columnLocation [DEP_COL_ID] = 6;
|
||||
acc->columnLocation [PRIC_COL_ID] = 7;
|
||||
acc->columnLocation [SHRS_COL_ID] = 8;
|
||||
acc->columnLocation [BALN_COL_ID] = 9;
|
||||
acc -> numCols = 10;
|
||||
break;
|
||||
default:
|
||||
fprintf( stderr, "Ineternal Error: Account type: %d is unknown!\n", acc->type);
|
||||
@ -929,7 +952,7 @@ regWindow( Widget parent, Account *acc )
|
||||
case MUTUAL:
|
||||
acc -> colWidths[PRIC_CELL_C] = 8; /* price */
|
||||
acc -> colWidths[SHRS_CELL_C] = 8; /* share balance */
|
||||
/* acc -> colWidths[ACTN_CELL_C] = 6; /* action (Buy/Sell)*/
|
||||
acc -> colWidths[ACTN_CELL_C] = 6; /* action (Buy/Sell)*/
|
||||
break;
|
||||
}
|
||||
|
||||
@ -957,7 +980,7 @@ regWindow( Widget parent, Account *acc )
|
||||
case MUTUAL:
|
||||
acc -> alignments[PRIC_CELL_C] = XmALIGNMENT_END; /* price */
|
||||
acc -> alignments[SHRS_CELL_C] = XmALIGNMENT_END; /* share balance */
|
||||
/* acc -> alignments[ACTN_CELL_C] = XmALIGNMENT_BEGINNING; /* action */
|
||||
acc -> alignments[ACTN_CELL_C] = XmALIGNMENT_BEGINNING; /* action */
|
||||
break;
|
||||
}
|
||||
|
||||
@ -985,7 +1008,7 @@ regWindow( Widget parent, Account *acc )
|
||||
case MUTUAL:
|
||||
acc -> rows[0][PRIC_CELL_C] = "Price";
|
||||
acc -> rows[0][SHRS_CELL_C] = "Tot Shrs";
|
||||
/* acc -> rows[0][ACTN_CELL_C] = "Action"; /* action */
|
||||
acc -> rows[0][ACTN_CELL_C] = "Action"; /* action */
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1018,7 +1041,7 @@ regWindow( Widget parent, Account *acc )
|
||||
break;
|
||||
}
|
||||
|
||||
data = (String **)XtMalloc(2*sizeof(String *));
|
||||
data = (String **)XtMalloc(3*sizeof(String *));
|
||||
data[0] = &(acc -> rows[0][0]);
|
||||
data[1] = &(acc -> rows[1][0]);
|
||||
data[2] = &(acc -> rows[2][0]);
|
||||
@ -1053,6 +1076,11 @@ regWindow( Widget parent, Account *acc )
|
||||
XtManageChild(reg);
|
||||
XtManageChild(frame);
|
||||
|
||||
|
||||
/* create action box for the first time */
|
||||
regData->ab = actionBox (reg);
|
||||
|
||||
|
||||
/******************************************************************\
|
||||
* The button area... also contains balance fields *
|
||||
\******************************************************************/
|
||||
@ -1169,6 +1197,9 @@ regWindow( Widget parent, Account *acc )
|
||||
|
||||
XtPopup( regData->dialog, XtGrabNone );
|
||||
|
||||
/* unmanage the action box, until it is needed */
|
||||
SetActionBox (regData->ab, -1, -1);
|
||||
|
||||
unsetBusyCursor( parent );
|
||||
|
||||
return regData;
|
||||
@ -1355,7 +1386,7 @@ regCB( Widget mw, XtPointer cd, XtPointer cb )
|
||||
|
||||
switch( cbs->reason )
|
||||
{
|
||||
case XbaeEnterCellReason:
|
||||
case XbaeEnterCellReason: {
|
||||
DEBUG("XbaeEnterCellReason");
|
||||
DEBUGCMD(printf(" row = %d\n col = %d\n",row,col));
|
||||
/* figure out if we are editing a different transaction... if we
|
||||
@ -1380,6 +1411,8 @@ regCB( Widget mw, XtPointer cd, XtPointer cb )
|
||||
!IN_RECN_CELL(row,col) && !IN_DEP_CELL(row,col) &&
|
||||
!((PORTFOLIO == acc->type) && IN_PRIC_CELL(row,col)) &&
|
||||
!((MUTUAL == acc->type) && IN_PRIC_CELL(row,col)) &&
|
||||
!((PORTFOLIO == acc->type) && IN_ACTN_CELL(row,col)) &&
|
||||
!((MUTUAL == acc->type) && IN_ACTN_CELL(row,col)) &&
|
||||
!IN_MEMO_CELL(row,col) && !IN_YEAR_CELL(row,col))
|
||||
{
|
||||
((XbaeMatrixEnterCellCallbackStruct *)cbs)->doit = FALSE;
|
||||
@ -1406,7 +1439,17 @@ regCB( Widget mw, XtPointer cd, XtPointer cb )
|
||||
XtVaSetValues( mw, XmNcells, data, NULL );
|
||||
XbaeMatrixRefreshCell( mw, row, RECN_CELL_C);
|
||||
}
|
||||
|
||||
/* otherwise, move the ACTN widget */
|
||||
else if( ((PORTFOLIO == acc->type) && IN_ACTN_CELL(row,col)) ||
|
||||
((MUTUAL == acc->type) && IN_ACTN_CELL(row,col)) )
|
||||
{
|
||||
SetActionBox (regData->ab, row, col);
|
||||
regData->changed |= MOD_ACTN;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case XbaeModifyVerifyReason:
|
||||
DEBUG("XbaeModifyVerifyReason");
|
||||
{
|
||||
@ -1560,13 +1603,21 @@ regCB( Widget mw, XtPointer cd, XtPointer cb )
|
||||
if( IN_PAY_CELL(row,col) || IN_DEP_CELL(row,col) )
|
||||
regData->changed |= MOD_AMNT;
|
||||
|
||||
if( ((PORTFOLIO == acc->type) && IN_PRIC_CELL(row,col)) ||
|
||||
((MUTUAL == acc->type) && IN_PRIC_CELL(row,col)) )
|
||||
regData->changed |= MOD_PRIC;
|
||||
|
||||
if( IN_MEMO_CELL(row,col) )
|
||||
regData->changed |= MOD_MEMO;
|
||||
|
||||
if( ((PORTFOLIO == acc->type) && IN_PRIC_CELL(row,col)) ||
|
||||
((MUTUAL == acc->type) && IN_PRIC_CELL(row,col)) )
|
||||
regData->changed |= MOD_PRIC;
|
||||
|
||||
/* Note: for cell widgets, this callback will never
|
||||
* indicate a row,col with a cell widget in it.
|
||||
* Thus, the following if statment will never be true
|
||||
*/
|
||||
if( ((PORTFOLIO == acc->type) && IN_ACTN_CELL(row,col)) ||
|
||||
((MUTUAL == acc->type) && IN_ACTN_CELL(row,col)) ) {
|
||||
regData->changed |= MOD_ACTN;
|
||||
}
|
||||
break;
|
||||
case XbaeTraverseCellReason:
|
||||
DEBUG("XbaeTraverseCellReason");
|
||||
|
@ -34,6 +34,8 @@
|
||||
\********************************************************************/
|
||||
|
||||
/********************************************************************\
|
||||
* initTransaction
|
||||
* Initialize a transaction structure
|
||||
\********************************************************************/
|
||||
|
||||
void
|
||||
@ -47,6 +49,7 @@ initTransaction( Transaction * trans )
|
||||
trans->num = NULL;
|
||||
trans->description = NULL;
|
||||
trans->memo = NULL;
|
||||
trans->action = NULL;
|
||||
trans->catagory = 0;
|
||||
trans->reconciled = NREC;
|
||||
trans->damount = 0.0;
|
||||
|
@ -93,6 +93,8 @@ String fbRes[] = {
|
||||
"*recn*cellShadowType: SHADOW_ETCHED_IN",
|
||||
"*recn*cellMarginWidth: 0",
|
||||
"*recn*cellMarginHeight: 0",
|
||||
/* combobox -- don't want the cell to be outlined */
|
||||
"*reg*actionbox*shadowThickness: 0",
|
||||
NULL,
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user