mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
fixes to traversal. It almost works.
I had it working but then broke it again before checking in, and can't emember how to fix it. Artghhh! git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@459 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
1ace564780
commit
80b10f7865
@ -450,10 +450,6 @@ regWindowLedger( Widget parent, Account **acclist, int ledger_type )
|
|||||||
XmNnavigationType, XmSTICKY_TAB_GROUP,
|
XmNnavigationType, XmSTICKY_TAB_GROUP,
|
||||||
NULL );
|
NULL );
|
||||||
|
|
||||||
/* traverse to the buttons, when leaving the table */
|
|
||||||
xaccNextTabGroup (regData->ledger->table, buttonform);
|
|
||||||
|
|
||||||
|
|
||||||
position = 0; /* puts the buttons in the right place */
|
position = 0; /* puts the buttons in the right place */
|
||||||
|
|
||||||
/* The "Record" button */
|
/* The "Record" button */
|
||||||
@ -466,13 +462,15 @@ regWindowLedger( Widget parent, Account **acclist, int ledger_type )
|
|||||||
XmNrightAttachment, XmATTACH_POSITION,
|
XmNrightAttachment, XmATTACH_POSITION,
|
||||||
XmNrightPosition, position+1,
|
XmNrightPosition, position+1,
|
||||||
XmNshowAsDefault, True,
|
XmNshowAsDefault, True,
|
||||||
XmNnavigationType, XmTAB_GROUP,
|
XmNnavigationType, XmEXCLUSIVE_TAB_GROUP,
|
||||||
NULL );
|
NULL );
|
||||||
|
|
||||||
XtAddCallback( widget, XmNactivateCallback,
|
XtAddCallback( widget, XmNactivateCallback,
|
||||||
recordCB, (XtPointer)regData );
|
recordCB, (XtPointer)regData );
|
||||||
regData->record = widget;
|
regData->record = widget;
|
||||||
|
|
||||||
|
/* traverse to the buttons, when leaving the table */
|
||||||
|
xaccNextTabGroup (regData->ledger->table, widget);
|
||||||
|
|
||||||
|
|
||||||
/* The "Cancel" button */
|
/* The "Cancel" button */
|
||||||
@ -486,7 +484,8 @@ regWindowLedger( Widget parent, Account **acclist, int ledger_type )
|
|||||||
XmNrightAttachment, XmATTACH_POSITION,
|
XmNrightAttachment, XmATTACH_POSITION,
|
||||||
XmNrightPosition, position+1,
|
XmNrightPosition, position+1,
|
||||||
XmNshowAsDefault, True,
|
XmNshowAsDefault, True,
|
||||||
XmNnavigationType, XmTAB_GROUP,
|
/* XmNnavigationType, XmTAB_GROUP, */
|
||||||
|
XmNnavigationType, XmEXCLUSIVE_TAB_GROUP,
|
||||||
NULL );
|
NULL );
|
||||||
|
|
||||||
XtAddCallback( widget, XmNactivateCallback,
|
XtAddCallback( widget, XmNactivateCallback,
|
||||||
@ -503,7 +502,8 @@ regWindowLedger( Widget parent, Account **acclist, int ledger_type )
|
|||||||
XmNrightAttachment, XmATTACH_POSITION,
|
XmNrightAttachment, XmATTACH_POSITION,
|
||||||
XmNrightPosition, position+1,
|
XmNrightPosition, position+1,
|
||||||
XmNshowAsDefault, True,
|
XmNshowAsDefault, True,
|
||||||
XmNnavigationType, XmTAB_GROUP,
|
/* XmNnavigationType, XmTAB_GROUP, */
|
||||||
|
XmNnavigationType, XmEXCLUSIVE_TAB_GROUP,
|
||||||
NULL );
|
NULL );
|
||||||
|
|
||||||
XtAddCallback( widget, XmNactivateCallback,
|
XtAddCallback( widget, XmNactivateCallback,
|
||||||
@ -554,7 +554,7 @@ regWindowLedger( Widget parent, Account **acclist, int ledger_type )
|
|||||||
XmNleftPosition, position,
|
XmNleftPosition, position,
|
||||||
XmNrightAttachment, XmATTACH_POSITION,
|
XmNrightAttachment, XmATTACH_POSITION,
|
||||||
XmNrightPosition, position+1,
|
XmNrightPosition, position+1,
|
||||||
XmNnavigationType, XmNONE, /* don't tab here! */
|
XmNnavigationType, XmTAB_GROUP, /* don't tab here! */
|
||||||
NULL );
|
NULL );
|
||||||
regData->balance = widget;
|
regData->balance = widget;
|
||||||
|
|
||||||
|
@ -12,6 +12,17 @@
|
|||||||
* when the user presses the tab key (and/or uses the arrow
|
* when the user presses the tab key (and/or uses the arrow
|
||||||
* keys).
|
* keys).
|
||||||
*
|
*
|
||||||
|
* The xaccNextRight() method can be used to declare the
|
||||||
|
* traversal order from cell to cell. If the indicated cell
|
||||||
|
* has the current input focus, then the next cell that will
|
||||||
|
* be traversed to will be the one indicated. Traversing
|
||||||
|
* to the rright is usally performed with the tab key.
|
||||||
|
* Special traversal order to the left, up or down are not
|
||||||
|
* currently implemented. To traverse out of the table entirely,
|
||||||
|
* the next_row&col should be set to negative values. If
|
||||||
|
* a traversal back into the table occurs, then the cell that
|
||||||
|
* will be entered will be the one with the negative values.
|
||||||
|
*
|
||||||
* MEMBERS:
|
* MEMBERS:
|
||||||
* The right_traverse array indicates which cell chould be
|
* The right_traverse array indicates which cell chould be
|
||||||
* traversed to when the tab key is pressed.
|
* traversed to when the tab key is pressed.
|
||||||
|
@ -301,7 +301,6 @@ static void dropDownCB (Widget w, XtPointer cd, XtPointer cb )
|
|||||||
XmComboBoxDropDownCallbackStruct *ddcb =
|
XmComboBoxDropDownCallbackStruct *ddcb =
|
||||||
(XmComboBoxDropDownCallbackStruct *) cb;
|
(XmComboBoxDropDownCallbackStruct *) cb;
|
||||||
|
|
||||||
|
|
||||||
if (XmCR_HIDE_LIST == ddcb->reason) {
|
if (XmCR_HIDE_LIST == ddcb->reason) {
|
||||||
XmProcessTraversal(ab->parent, XmTRAVERSE_CURRENT);
|
XmProcessTraversal(ab->parent, XmTRAVERSE_CURRENT);
|
||||||
}
|
}
|
||||||
|
@ -158,6 +158,7 @@ void xaccInitBasicRegister (BasicRegister *reg)
|
|||||||
|
|
||||||
/* -------------------------------- */
|
/* -------------------------------- */
|
||||||
/* define the traversal order */
|
/* define the traversal order */
|
||||||
|
/* negative cells mean "traverse out of table" */
|
||||||
xaccNextRight (curs, DATE_CELL_R, DATE_CELL_C, NUM_CELL_R, NUM_CELL_C);
|
xaccNextRight (curs, DATE_CELL_R, DATE_CELL_C, NUM_CELL_R, NUM_CELL_C);
|
||||||
xaccNextRight (curs, NUM_CELL_R, NUM_CELL_C, XFRM_CELL_R, XFRM_CELL_C);
|
xaccNextRight (curs, NUM_CELL_R, NUM_CELL_C, XFRM_CELL_R, XFRM_CELL_C);
|
||||||
xaccNextRight (curs, XFRM_CELL_R, XFRM_CELL_C, DESC_CELL_R, DESC_CELL_C);
|
xaccNextRight (curs, XFRM_CELL_R, XFRM_CELL_C, DESC_CELL_R, DESC_CELL_C);
|
||||||
@ -165,7 +166,7 @@ void xaccInitBasicRegister (BasicRegister *reg)
|
|||||||
xaccNextRight (curs, CRED_CELL_R, CRED_CELL_C, DEBT_CELL_R, DEBT_CELL_C);
|
xaccNextRight (curs, CRED_CELL_R, CRED_CELL_C, DEBT_CELL_R, DEBT_CELL_C);
|
||||||
xaccNextRight (curs, DEBT_CELL_R, DEBT_CELL_C, ACTN_CELL_R, ACTN_CELL_C);
|
xaccNextRight (curs, DEBT_CELL_R, DEBT_CELL_C, ACTN_CELL_R, ACTN_CELL_C);
|
||||||
xaccNextRight (curs, ACTN_CELL_R, ACTN_CELL_C, MEMO_CELL_R, MEMO_CELL_C);
|
xaccNextRight (curs, ACTN_CELL_R, ACTN_CELL_C, MEMO_CELL_R, MEMO_CELL_C);
|
||||||
xaccNextRight (curs, MEMO_CELL_R, MEMO_CELL_C, -1, -1);
|
xaccNextRight (curs, MEMO_CELL_R, MEMO_CELL_C, -DATE_CELL_R, -DATE_CELL_C);
|
||||||
|
|
||||||
|
|
||||||
/* -------------------------------- */
|
/* -------------------------------- */
|
||||||
|
@ -105,6 +105,10 @@ xaccInitTable (Table * table, int tile_rows, int tile_cols)
|
|||||||
table->entries[i][j] = strdup ("");
|
table->entries[i][j] = strdup ("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* invalidate the "previous" traversed cell */
|
||||||
|
table->prev_phys_traverse_row = -1;
|
||||||
|
table->prev_phys_traverse_col = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ==================================================== */
|
/* ==================================================== */
|
||||||
@ -343,11 +347,6 @@ cellCB (Widget mw, XtPointer cd, XtPointer cb)
|
|||||||
mvcbs->verify->doit = False;
|
mvcbs->verify->doit = False;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case XbaeTraverseCellReason: {
|
|
||||||
XbaeMatrixTraverseCellCallbackStruct *tcbs;
|
|
||||||
tcbs = (XbaeMatrixTraverseCellCallbackStruct *) cbs;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case XbaeLeaveCellReason: {
|
case XbaeLeaveCellReason: {
|
||||||
XbaeMatrixLeaveCellCallbackStruct *lcbs;
|
XbaeMatrixLeaveCellCallbackStruct *lcbs;
|
||||||
lcbs = (XbaeMatrixLeaveCellCallbackStruct *) cbs;
|
lcbs = (XbaeMatrixLeaveCellCallbackStruct *) cbs;
|
||||||
@ -375,11 +374,6 @@ cellCB (Widget mw, XtPointer cd, XtPointer cb)
|
|||||||
leaveCB (mw, cd, cb);
|
leaveCB (mw, cd, cb);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case XbaeTraverseCellReason: {
|
|
||||||
verifyCursorPosition (table, row, col);
|
|
||||||
traverseCB (mw, cd, cb);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -598,9 +592,37 @@ traverseCB (Widget mw, XtPointer cd, XtPointer cb)
|
|||||||
arr = table->cursor;
|
arr = table->cursor;
|
||||||
cbs = (XbaeMatrixTraverseCellCallbackStruct *) cb;
|
cbs = (XbaeMatrixTraverseCellCallbackStruct *) cb;
|
||||||
|
|
||||||
/* compute the cell location */
|
|
||||||
row = cbs->row;
|
row = cbs->row;
|
||||||
col = cbs->column;
|
col = cbs->column;
|
||||||
|
|
||||||
|
verifyCursorPosition (table, row, col);
|
||||||
|
|
||||||
|
/* If the quark is zero, then it is likely that we are
|
||||||
|
* here because we traversed out of a cell that had a
|
||||||
|
* ComboBox in it. The ComboCell is clever enough to put
|
||||||
|
* us back into the register after tabing out of it.
|
||||||
|
* However, its not (cannot be) clever enough to pretend
|
||||||
|
* that it was a tab group in the register. Thus,
|
||||||
|
* we will emulate that we left a tab group in the register
|
||||||
|
* to get here. To put it more simply, we just set the
|
||||||
|
* row and column to that of the ComboCell, which we had
|
||||||
|
* previously recorded, and continue on as if nothing
|
||||||
|
* happened.
|
||||||
|
* BTW -- note that we are emulating a normal, right-moving tab.
|
||||||
|
* Backwards tabs are broken.
|
||||||
|
*/
|
||||||
|
if (NULLQUARK == cbs->qparam) {
|
||||||
|
if ((0==row) && (0==col)) {
|
||||||
|
if ((0 <= table->prev_phys_traverse_row) &&
|
||||||
|
(0 <= table->prev_phys_traverse_col)) {
|
||||||
|
cbs->qparam = QRight;
|
||||||
|
row = table->prev_phys_traverse_row;
|
||||||
|
col = table->prev_phys_traverse_col;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* compute the cell location */
|
||||||
rel_row = row - table->num_header_rows;
|
rel_row = row - table->num_header_rows;
|
||||||
rel_col = col;
|
rel_col = col;
|
||||||
rel_row %= (arr->numRows);
|
rel_row %= (arr->numRows);
|
||||||
@ -614,20 +636,24 @@ traverseCB (Widget mw, XtPointer cd, XtPointer cb)
|
|||||||
/* if we are at the end of the traversal chain,
|
/* if we are at the end of the traversal chain,
|
||||||
* hop out of this tab group, and into the next.
|
* hop out of this tab group, and into the next.
|
||||||
*/
|
*/
|
||||||
if ((-1 == next_row) || (-1 == next_col)) {
|
if ((0 > next_row) || (0 > next_col)) {
|
||||||
cbs->next_row = 0;
|
/* reverse the sign of next_row, col to be positive. */
|
||||||
cbs->next_column = 0;
|
cbs->next_row = row - rel_row - next_row;
|
||||||
|
cbs->next_column = col - rel_col - next_col;
|
||||||
cbs->qparam = NULLQUARK;
|
cbs->qparam = NULLQUARK;
|
||||||
if (table->next_tab_group) {
|
if (table->next_tab_group) {
|
||||||
XmProcessTraversal (table->next_tab_group,
|
XmProcessTraversal (table->next_tab_group,
|
||||||
/* XmTRAVERSE_NEXT_TAB_GROUP); */
|
|
||||||
XmTRAVERSE_CURRENT);
|
XmTRAVERSE_CURRENT);
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cbs->next_row = row - rel_row + next_row;
|
cbs->next_row = row - rel_row + next_row;
|
||||||
cbs->next_column = col - rel_col + next_col;
|
cbs->next_column = col - rel_col + next_col;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
table->prev_phys_traverse_row = cbs->next_row;
|
||||||
|
table->prev_phys_traverse_col = cbs->next_column;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -681,13 +707,13 @@ xaccCreateTable (Table *table, Widget parent, char * name)
|
|||||||
XmNcolumns, table->num_phys_cols,
|
XmNcolumns, table->num_phys_cols,
|
||||||
XmNcolumnWidths, widths,
|
XmNcolumnWidths, widths,
|
||||||
XmNcolumnAlignments, alignments,
|
XmNcolumnAlignments, alignments,
|
||||||
XmNtraverseFixedCells, False,
|
|
||||||
XmNgridType, XmGRID_SHADOW_IN,
|
XmNgridType, XmGRID_SHADOW_IN,
|
||||||
XmNshadowType, XmSHADOW_ETCHED_IN,
|
XmNshadowType, XmSHADOW_ETCHED_IN,
|
||||||
XmNverticalScrollBarDisplayPolicy,XmDISPLAY_STATIC,
|
XmNverticalScrollBarDisplayPolicy,XmDISPLAY_STATIC,
|
||||||
XmNselectScrollVisible, True,
|
XmNselectScrollVisible, True,
|
||||||
/* XmNnavigationType, XmEXCLUSIVE_TAB_GROUP, */
|
XmNtraverseFixedCells, False,
|
||||||
XmNnavigationType, XmSTICKY_TAB_GROUP,
|
XmNnavigationType, XmEXCLUSIVE_TAB_GROUP,
|
||||||
|
/* XmNnavigationType, XmSTICKY_TAB_GROUP, */
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
XtManageChild (reg);
|
XtManageChild (reg);
|
||||||
@ -696,7 +722,7 @@ xaccCreateTable (Table *table, Widget parent, char * name)
|
|||||||
XtAddCallback (reg, XmNenterCellCallback, cellCB, (XtPointer)table);
|
XtAddCallback (reg, XmNenterCellCallback, cellCB, (XtPointer)table);
|
||||||
XtAddCallback (reg, XmNleaveCellCallback, cellCB, (XtPointer)table);
|
XtAddCallback (reg, XmNleaveCellCallback, cellCB, (XtPointer)table);
|
||||||
XtAddCallback (reg, XmNmodifyVerifyCallback, cellCB, (XtPointer)table);
|
XtAddCallback (reg, XmNmodifyVerifyCallback, cellCB, (XtPointer)table);
|
||||||
XtAddCallback (reg, XmNtraverseCellCallback, cellCB, (XtPointer)table);
|
XtAddCallback (reg, XmNtraverseCellCallback, traverseCB, (XtPointer)table);
|
||||||
|
|
||||||
table->table_widget = reg;
|
table->table_widget = reg;
|
||||||
|
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
/*
|
||||||
|
* FILE:
|
||||||
|
* table.h
|
||||||
|
*
|
||||||
|
* FUNCTION:
|
||||||
|
* The table is the complete, displayed table.
|
||||||
|
* It consists of a header, followed by a simple
|
||||||
|
* list of repeated entries.
|
||||||
|
*
|
||||||
|
* It provides the mechanism to handle tab-trversing.
|
||||||
|
*
|
||||||
|
* HISTORY:
|
||||||
|
* Copyright (c) 1998 Linas Vepstas
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef __XACC_TABLE_H__
|
#ifndef __XACC_TABLE_H__
|
||||||
#define __XACC_TABLE_H__
|
#define __XACC_TABLE_H__
|
||||||
@ -6,11 +20,6 @@
|
|||||||
#include "basiccell.h"
|
#include "basiccell.h"
|
||||||
#include "cellblock.h"
|
#include "cellblock.h"
|
||||||
|
|
||||||
/* the table is the complete, displayed table. */
|
|
||||||
/* It consists of a header, followed by a simple
|
|
||||||
* list of repeated entries
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct _Table {
|
typedef struct _Table {
|
||||||
|
|
||||||
/* num rows and cols are the number of times the
|
/* num rows and cols are the number of times the
|
||||||
@ -49,6 +58,16 @@ typedef struct _Table {
|
|||||||
int num_header_rows;
|
int num_header_rows;
|
||||||
int num_phys_rows;
|
int num_phys_rows;
|
||||||
int num_phys_cols;
|
int num_phys_cols;
|
||||||
|
|
||||||
|
/* This class implements tab-key and arrow key
|
||||||
|
* traversal through the cells of the table.
|
||||||
|
* To perform this traversal, the location
|
||||||
|
* of the "previous" cell having input focus
|
||||||
|
* is required.
|
||||||
|
*/
|
||||||
|
int prev_phys_traverse_row;
|
||||||
|
int prev_phys_traverse_col;
|
||||||
|
|
||||||
} Table;
|
} Table;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user