campo-sirio/xi/xilmst.c
guy f8c1ec663e Trasformata a catena funzione
da xi_set_text(XI_OBJ* obj, char* text)
a  xi_set_text(XI_OBJ* obj, const char* text)


git-svn-id: svn://10.65.10.50/branches/R_10_00@23125 c028cbd2-c16b-5b4b-a496-9718f37d4682
2015-07-10 14:56:20 +00:00

916 lines
26 KiB
C
Executable File

/*******************************************************************************
* Copyright 1991-1996 by ORCA Software, Inc. *
* *
* All rights reserved. May not be reproduced or distributed, in printed or *
* electronic form, without permission of ORCA Software, Inc. May not be *
* distributed as object code, separately or linked with other object modules, *
* without permission. *
*******************************************************************************/
#define XI_INTERNAL
#include "xi.h"
#include "xitext.h"
#include "xilm.h"
#include "xilmst.h"
#include "xiutils.h"
#include "xidisply.h"
#include <limits.h>
void
lm_focus_set( long lm, int row, int column, BOOLEAN v_scrolled, BOOLEAN set )
{
LM_DATA *lmp = ( LM_DATA * ) lm;
if ( set )
{
LM_FOCUS_CELL_VISIBLE_FORCE_ARGS args;
MEMCLEAR( args );
args.lmp = lmp;
args.row = row;
args.column = column;
args.vert_scrolled = v_scrolled;
lm_focus_cell_visible_force( &args );
}
else
{
lm_focus_remove( lmp, row, column, v_scrolled );
}
}
void
lm_focus_cell_visible_force( LM_FOCUS_CELL_VISIBLE_FORCE_ARGS * args )
{
/*
LM_DATA *lmp;
int row;
int column;
int vert_scrolled;
*/
LM_DATA *lmp = args->lmp;
LM_COLUMN_DATA *lmcdp;
unsigned long attrib,
cell_attrib;
int c;
XinRect mr;
int focus_row,
focus_column;
BOOLEAN v_scrolled;
lm_focus_cell_get( lmp, &focus_row, &focus_column, &v_scrolled );
if ( focus_row == args->row &&
focus_column == args->column &&
v_scrolled == FALSE &&
lm_focus_state_get( lmp ) == LM_FOCUS_VISIBLE )
return;
/* force a vertically scrolled row to be visible */
if ( lm_focus_state_get( lmp ) == LM_FOCUS_VERTICALLY_SCROLLED )
{
LM_SCROLL_ARG lm_scroll_arg;
int row;
BOOLEAN found = FALSE;
for ( row = 0; row < lmp->nbr_realized_rows; ++row )
{
if ( lmp->focus_state->focus_rec == lmp->recs[row] )
{
found = TRUE;
break;
}
}
if ( !found )
{
MEMCLEAR( lm_scroll_arg );
lm_scroll_arg.lm = ( LM ) lmp;
/* lm_scroll_arg.nbr_lines = 0; lm_scroll_arg.percent = 0;
* lm_scroll_arg.same_cell = 0; */
lm_scroll_arg.rec = lmp->focus_state->focus_rec;
lm_scroll_arg.have_rec = TRUE;
lm_scroll_arg.color = lmp->focus_state->focus_rec_color;
lm_scroll_arg.attrib = lmp->focus_state->focus_rec_attrib;
lm_scroll_arg.row_height = lmp->focus_state->focus_rec_height;
lm_scroll_arg.rec_at_top = lmp->focus_state->focus_rec_is_above;
lm_scroll( &lm_scroll_arg );
XinWindowPaintForce( lmp->win );
}
}
mr = lmp->mlr;
if ( lmp->pixel_width )
mr.right = mr.left + lmp->pixel_width + BORDER_WIDTH;
lm_focus_cell_get( lmp, &focus_row, &focus_column, &v_scrolled );
lmcdp = lmp->lm_column_data[focus_column];
attrib = lmcdp->attrib;
cell_attrib = lm_get_attrib( ( LM ) lmp, LM_CELL, focus_row, focus_column,
v_scrolled ) & ( XI_ATR_HCENTER | XI_ATR_RJUST );
if ( cell_attrib )
{
attrib &= ~( XI_ATR_HCENTER | XI_ATR_RJUST );
attrib |= cell_attrib;
}
/* force cell to be visible */
c = min( focus_column, lmp->nbr_columns - 1 );
if ( c >= lmp->fixed_columns && c < lmp->first_vis )
lm_local_hscroll( ( LM ) lmp, c - lmp->first_vis );
else
{
if ( c > lmp->last_vis )
{
int first_col;
c++;
c = min( c, lmp->nbr_columns );
first_col = lm_get_left_most_far_right_col( lmp, c );
lm_local_hscroll( ( LM ) lmp, first_col - lmp->first_vis );
}
}
#if 0
/* this should never get executed */
if ( focus_row < lmp->first_fully_vis )
{
int delta,
idx2,
pix2,
old_pix;
XinRect tmp_rct;
make_room_rows( lmp, focus_row - lmp->first_fully_vis, FALSE );
idx2 = focus_row;
pix2 = lmp->pix_offsets[idx2];
old_pix = -lmp->rrr_offset;
delta = old_pix - pix2;
lmp->rrr_offset += delta;
calculate_pix_offsets( lmp, FALSE );
if ( !lmp->itf_obj->v.itf->half_baked )
XinWindowPaintForce( lmp->win );
xi_set_update_obj( lmp->list_obj );
lm_get_scroll_rct( lmp, &tmp_rct );
xi_scroll_rect( lmp->win, &tmp_rct, 0, delta );
do_scroll_bar( lmp->list_obj->v.list );
}
#endif
if ( focus_row > lmp->last_fully_vis )
{
int pix,
delta;
XinRect tmp_rct;
delta = 0;
while ( TRUE )
{
if ( focus_row <= lmp->last_fully_vis )
break;
pix = lmp->pix_heights[0];
delta += pix;
lm_make_rrr_room_pix( lmp, pix, FALSE );
lmp->rrr_offset -= pix;
calculate_pix_offsets( lmp, FALSE );
calculate_visibles( lmp );
}
if ( !lmp->itf_obj->v.itf->half_baked )
XinWindowPaintForce( lmp->win );
xi_set_update_obj( lmp->list_obj );
lm_get_scroll_rct( lmp, &tmp_rct );
xi_scroll_rect( lmp->win, &tmp_rct, 0, -delta );
do_scroll_bar( lmp->list_obj->v.list );
if ( !lmp->get_all_records )
{
int nbr_to_free,
cnt,
i,
idx;
nbr_to_free = lmp->first_fully_vis;
if ( nbr_to_free > 0 )
{
for ( cnt = 0; cnt < nbr_to_free; cnt++ )
{
lmp->rrr_offset += lmp->pix_heights[cnt];
lm_do_rec_event( lmp, cnt, XIE_REC_FREE );
}
for ( idx = nbr_to_free; idx < lmp->nbr_realized_rows; ++idx )
lm_row_copy( lmp, idx, idx - nbr_to_free );
lm_adjust_rows( lmp, -nbr_to_free );
lmp->nbr_realized_rows -= cnt;
}
/* free any unnecessary records at the end of the list */
nbr_to_free = lmp->nbr_realized_rows - ( lmp->last_fully_vis + 2 );
if ( nbr_to_free > 0 )
{
for ( i = lmp->nbr_realized_rows - nbr_to_free, cnt = 0; cnt < nbr_to_free;
i++, cnt++ )
lm_do_rec_event( lmp, i, XIE_REC_FREE );
lmp->nbr_realized_rows -= cnt;
}
calculate_pix_offsets( lmp, TRUE );
}
}
if ( lm_focus_state_get( lmp ) != LM_FOCUS_VISIBLE )
lm_focus_cell_visible_attempt( lmp );
}
void
lm_focus_cell_text_set( LM_DATA * lmp, BOOLEAN preserve_focus_text, const char *s,
int row, int col, BOOLEAN v_scrolled )
{
int focus_row,
focus_column;
BOOLEAN focus_v_scrolled;
if ( lm_focus_list_has( lmp ) )
{
lm_focus_cell_get( lmp, &focus_row, &focus_column, &focus_v_scrolled );
if ( lm_focus_state_get( lmp ) != LM_FOCUS_VISIBLE &&
row == focus_row &&
col == focus_column &&
v_scrolled == focus_v_scrolled &&
preserve_focus_text != TRUE )
{
int len;
LM_COLUMN_DATA *lm_column_data;
int pix_spacing;
LM_CELL_DATA *cell_data;
len = strlen( s ) + 1;
if ( lmp->focus_state->focus_cell_text )
lmp->focus_state->focus_cell_text = ( char * ) xi_tree_realloc( lmp->focus_state->focus_cell_text, len );
else
lmp->focus_state->focus_cell_text = ( char * ) xi_tree_malloc( len, lmp );
strcpy( lmp->focus_state->focus_cell_text, s );
lm_column_data = lmp->lm_column_data[focus_column];
cell_data = &lmp->cell_data[focus_row][focus_column];
pix_spacing = lm_column_data->pix_width -
( cell_data->button ? lmp->pix_row_spacing : 0 );
xi_text_pix_width_and_text_set( cell_data->xi_text, lmp->focus_state->focus_cell_text,
pix_spacing, TRUE );
if ( lmp->lm_column_data[col]->attrib | XI_ATR_AUTOSELECT )
{
lmp->focus_state->focus_cell_ip1 = 0;
lmp->focus_state->focus_cell_ip2 = strlen( s );
}
else
{
lmp->focus_state->focus_cell_ip1 = 0;
lmp->focus_state->focus_cell_ip2 = 0;
}
lmp->focus_state->button = cell_data->button;
lmp->focus_state->button_full_cell = cell_data->button_full_cell;
}
}
}
long
lm_focus_rec_get( LM_DATA * lmp )
{
return lmp->focus_state->focus_rec;
}
BOOLEAN
lm_focus_cell_has( LM_DATA * lmp, int row, int column, BOOLEAN v_scrolled )
{
XI_ITF_DATA *itf;
XI_OBJ *focus_obj;
XI_CELL_DATA *cd;
if ( lm_focus_state_get( lmp ) != LM_FOCUS_VISIBLE )
return FALSE;
itf = lmp->itf_obj->v.itf;
focus_obj = itf->focus_obj;
if ( focus_obj != NULL && focus_obj->parent == lmp->list_obj &&
focus_obj->type == XIT_CELL )
{
cd = &focus_obj->v.cell;
return ( cd->row == row && cd->column == column
&& cd->is_vert_scrolled == v_scrolled );
}
return FALSE;
}
void
lm_focus_rec_color_set( LM_DATA * lmp, XinColor color )
{
lmp->focus_state->focus_rec_color = color;
}
void
lm_focus_cell_attrib_set( LM_DATA * lmp, unsigned long attrib )
{
lmp->focus_state->focus_cell_attrib = attrib;
}
void
lm_focus_selection_get( LM_DATA * lmp, int *c1, int *c2 )
{
if ( lm_focus_list_has( lmp ) )
{
XI_TEXT *text;
text = xi_text_focus_get( lmp->win );
if ( text )
xi_text_selection_get( text, c1, c2 );
}
else
*c1 = *c2 = 0;
}
char *
lm_focus_cell_text_get( LM_DATA * lmp )
{
return lmp->focus_state->focus_cell_text;
}
LM_FOCUS
lm_focus_state_get( LM_DATA * lmp )
{
return lmp->focus_state->where;
}
/*-------------------------------------------------------------------------
function: lm_stop_edit
lm: current lm
-------------------------------------------------------------------------*/
static void
lm_stop_edit( LM lm, BOOLEAN do_update, int row, int column, LM_FOCUS state_was )
{
LM_DATA *lmp = LMP( lm );
XI_TEXT *text;
LM_CELL_DATA *cell_data;
cell_data = &lmp->cell_data[row][column];
text = cell_data->xi_text;
if ( text && !cell_data->button_full_cell )
{
xi_text_editing_stop( text );
XinWindowPaintForce( lmp->win );
}
/* if lmp->row_focus_border is TRUE, don't redraw, because old focus row will
* be invalidated */
if ( ( do_update && state_was == LM_FOCUS_VISIBLE ) ||
(do_update && cell_data->button_full_cell))
redraw_cell( lm, row, column, FALSE );
}
/* ------------------------------------------------------------------- */
/* lm_focus_cell_is_visible */
/* ------------------------------------------------------------------- */
/*
TODO it is possible here that focus has been moved such that it is now
visible, but the state still indicates that it is not.
*/
BOOLEAN
lm_focus_cell_is_visible( LM_DATA * lmp, BOOLEAN * is_hscrolled )
{
if ( is_hscrolled )
*is_hscrolled = FALSE;
if ( lm_focus_state_get( lmp ) == LM_FOCUS_HORIZONTALLY_SCROLLED )
{
*is_hscrolled = TRUE;
return FALSE;
}
return ( lm_focus_state_get( lmp ) == LM_FOCUS_VISIBLE );
}
/*
Semantics: this function attempts to make the focus be visible.
It then sets the state as appropriate. If it succeeded, then
it sets state to LM_FOCUS_VISIBLE. If it failed, then it sets
focus to LM_FOCUS_VERTICALLY_SCROLLED or LM_FOCUS_HORIZONTALLY_SCROLLED.
*/
void
lm_focus_cell_visible_attempt( LM_DATA * lmp )
{
int focus_row,
focus_column;
BOOLEAN v_scrolled;
if ( !lm_focus_list_has( lmp ) )
return;
lm_focus_cell_get( lmp, &focus_row, &focus_column, &v_scrolled );
if ( focus_column < lmp->fixed_columns ||
( focus_column >= lmp->first_vis &&
focus_column <= lmp->last_vis ) )
{
LM_COLUMN_DATA *lm_column_data;
XinRect cell_r;
unsigned long attrib,
cell_attrib;
LM_CELL_DATA *cell_data;
XinRect mr;
BOOLEAN text_was_invisible;
LM_FOCUS focus;
int leading,
ascent,
descent;
int col_offset;
col_offset = ( int ) xi_get_pref( XI_PREF_COLUMN_OFFSET );
if ( lm_focus_state_get( lmp ) == LM_FOCUS_VERTICALLY_SCROLLED ||
lm_focus_state_get( lmp ) == LM_FOCUS_TEMP_INVISIBLE )
{
int cnt;
for ( cnt = 0; cnt < lmp->nbr_realized_rows; ++cnt )
{
if ( lmp->recs[cnt] == lmp->focus_state->focus_rec )
{
if ( cnt <= lmp->last_fully_vis )
{
lm_focus_cell_set( lmp, cnt, focus_column, FALSE );
focus_row = cnt;
}
break;
}
}
if ( cnt > lmp->last_fully_vis )
{
lmp->focus_state->where = LM_FOCUS_VERTICALLY_SCROLLED;
return;
}
}
focus = lm_focus_state_get( lmp );
text_was_invisible = FALSE;
if ( focus == LM_FOCUS_HORIZONTALLY_SCROLLED ||
focus == LM_FOCUS_VERTICALLY_SCROLLED ||
focus == LM_FOCUS_TEMP_INVISIBLE )
text_was_invisible = TRUE;
mr = lmp->mlr;
if ( lmp->pixel_width )
mr.right = mr.left + lmp->pixel_width;
lm_column_data = lmp->lm_column_data[focus_column];
attrib = lm_column_data->attrib;
cell_data = &lmp->cell_data[focus_row][focus_column];
if ( cell_data->xi_text != NULL )
xi_text_clip_set( cell_data->xi_text, &mr );
if ( text_was_invisible )
{
cell_data->attrib = lmp->focus_state->focus_cell_attrib;
if ( cell_data->font )
XinFontDestroy( cell_data->font );
if ( lmp->focus_state->focus_cell_font )
{
XinFontCopy( &cell_data->font, lmp->focus_state->focus_cell_font );
if ( cell_data->xi_text != NULL )
xi_text_font_set( cell_data->xi_text, cell_data->font );
} else
cell_data->font = NULL;
cell_data->color = lmp->focus_state->focus_cell_color;
cell_data->back_color = lmp->focus_state->focus_cell_back_color;
cell_data->button = lmp->focus_state->button;
cell_data->button_full_cell = lmp->focus_state->button_full_cell;
cell_data->button_on_left = lmp->focus_state->button_on_left;
cell_data->button_icon_rid = lmp->focus_state->button_icon_rid;
cell_data->button_bitmap = lmp->focus_state->button_bitmap;
}
cell_attrib = cell_data->attrib & ( XI_ATR_HCENTER | XI_ATR_RJUST );
if ( cell_attrib )
{
attrib &= ~( XI_ATR_HCENTER | XI_ATR_RJUST );
attrib |= cell_attrib;
}
/* Create the focus cell */
if ( cell_data->button_full_cell )
{
lmp->cur_font = lmp->font;
lmp->old_row_height = lmp->pix_heights[focus_row];
lmp->focus_state->focus_rec = 0L;
lmp->focus_state->where = LM_FOCUS_VISIBLE;
redraw_cell( ( LM ) lmp, focus_row, focus_column, FALSE );
}
else
{
lmp->cur_font = lmp->font;
XinFontMetricsGet( lmp->cur_font, &leading, &ascent, &descent );
lm_xi_text_prect_get( lmp, lm_column_data, cell_data, focus_row, focus_column,
col_offset, leading, ascent, descent, &cell_r );
if ( !lm_column_data->wrap_text )
xi_text_pix_width_set( cell_data->xi_text, lm_column_data->pix_width -
( cell_data->button ? lmp->pix_row_spacing : 0 ) );
xi_text_prect_set( cell_data->xi_text, &cell_r );
xi_text_color_fore_set( cell_data->xi_text, lmp->active_color );
xi_text_color_back_set( cell_data->xi_text, lmp->active_back_color );
if ( cell_data->back_color )
xi_text_color_back_set( cell_data->xi_text, cell_data->back_color );
if ( text_was_invisible )
{
xi_text_set( cell_data->xi_text, lmp->focus_state->focus_cell_text );
}
cell_data->valid_data = TRUE;
lmp->old_row_height = lmp->pix_heights[focus_row];
lmp->focus_state->focus_rec = 0L;
if ( text_was_invisible )
{
LM_COLUMN_DATA *lm_column_data;
int pix_spacing;
lm_column_data = lmp->lm_column_data[focus_column];
pix_spacing = lm_column_data->pix_width -
( cell_data->button ? lmp->pix_row_spacing : 0 );
xi_text_pix_width_and_text_set( cell_data->xi_text, lmp->focus_state->focus_cell_text,
pix_spacing, TRUE );
xi_text_selection_set_internal( cell_data->xi_text,
lmp->focus_state->focus_cell_ip1,
lmp->focus_state->focus_cell_ip2,
lmp->focus_state->focus_cell_start_ip, TRUE, TRUE );
}
else
{
if ( lmp->have_mouse )
{
if ( ( lm_column_data->attrib & ( LM_COL_ATR_AUTOSELECT | LM_COL_ATR_READONLY ) ) ==
( LM_COL_ATR_AUTOSELECT | LM_COL_ATR_READONLY ) )
xi_text_selection_set( cell_data->xi_text, 0, SHRT_MAX );
else if ( ( lm_column_data->attrib & LM_COL_ATR_AUTOSELECT ) && xi_get_pref( XI_PREF_AUTOSEL_ON_MOUSE ) )
xi_text_selection_set( cell_data->xi_text, 0, SHRT_MAX );
else
xi_text_selection_set( cell_data->xi_text, 0, 0 );
}
else
{
if ( lm_column_data->attrib & LM_COL_ATR_AUTOSELECT )
xi_text_selection_set( cell_data->xi_text, 0, SHRT_MAX );
else
xi_text_selection_set( cell_data->xi_text, 0, 0 );
}
}
xi_text_editing_start( cell_data->xi_text );
}
lmp->focus_state->where = LM_FOCUS_VISIBLE;
redraw_cell( ( LM ) lmp, focus_row, focus_column, FALSE );
}
else
{
if ( lm_focus_state_get( lmp ) != LM_FOCUS_VERTICALLY_SCROLLED )
{
lmp->focus_state->where = LM_FOCUS_HORIZONTALLY_SCROLLED;
if ( lmp->focus_state->focus_rec )
{
int cnt;
/* the following loop should *always* find a row, because the only
* reason the cell is not visible is because the list is horizontally
* scrolled. */
for ( cnt = 0; cnt < lmp->nbr_realized_rows; ++cnt )
{
if ( lmp->recs[cnt] == lmp->focus_state->focus_rec )
{
lm_focus_cell_set( lmp, cnt, focus_column, FALSE );
break;
}
}
if ( cnt == lmp->nbr_realized_rows )
lmp->focus_state->where = LM_FOCUS_VERTICALLY_SCROLLED;
}
}
}
}
unsigned long
lm_focus_rec_attrib_get( LM_DATA * lmp )
{
return lmp->focus_state->focus_rec_attrib;
}
unsigned long
lm_focus_cell_attrib_get( LM_DATA * lmp )
{
return lmp->focus_state->focus_cell_attrib;
}
void
lm_focus_cell_invis_make( LM_DATA * lmp )
{
XI_TEXT *text;
if ( !lm_focus_list_has( lmp ) )
return;
if ( lm_focus_state_get( lmp ) != LM_FOCUS_VISIBLE )
return;
text = xi_text_focus_get( lmp->win );
if ( text && xi_text_editing_is( text ) )
{
int focus_row,
focus_column;
int ip1,
ip2,
start_ip;
BOOLEAN v_scrolled;
LM_CELL_DATA *cell_data;
XI_TEXT *text;
lmp->focus_state->where = LM_FOCUS_TEMP_INVISIBLE;
lm_focus_cell_get( lmp, &focus_row, &focus_column, &v_scrolled );
lmp->focus_state->focus_rec = lmp->recs[focus_row];
lmp->focus_state->focus_rec_color = lmp->row_colors[focus_row];
lmp->focus_state->focus_rec_attrib = lmp->row_attribs[focus_row];
lmp->focus_state->focus_rec_height = lmp->pix_heights[focus_row];
cell_data = &lmp->cell_data[focus_row][focus_column];
if ( lmp->focus_state->focus_cell_font )
{
XinFontDestroy( lmp->focus_state->focus_cell_font );
lmp->focus_state->focus_cell_font = NULL;
}
if ( cell_data->font )
XinFontCopy( &lmp->focus_state->focus_cell_font, cell_data->font );
lmp->focus_state->focus_cell_color = cell_data->color;
lmp->focus_state->focus_cell_back_color = cell_data->back_color;
lmp->focus_state->focus_cell_attrib = cell_data->attrib;
xi_text_selection_get_internal( cell_data->xi_text, &ip1, &ip2, &start_ip );
lm_focus_cell_text_set( lmp, FALSE, xi_text_get( cell_data->xi_text ), focus_row,
focus_column, FALSE );
lmp->focus_state->focus_cell_ip1 = ip1;
lmp->focus_state->focus_cell_ip2 = ip2;
lmp->focus_state->focus_cell_start_ip = start_ip;
lmp->focus_state->button = cell_data->button;
lmp->focus_state->button_full_cell = cell_data->button_full_cell;
lmp->focus_state->button_on_left = cell_data->button_on_left;
lmp->focus_state->button_icon_rid = cell_data->button_icon_rid;
lmp->focus_state->button_bitmap = cell_data->button_bitmap;
if ( lmp->focus_state->focus_cell_ip1 != lmp->focus_state->focus_cell_ip2 )
redraw_cell( ( LM ) lmp, focus_row, focus_column, FALSE );
text = xi_text_focus_get( lmp->win );
xi_text_editing_stop( text );
}
}
BOOLEAN
lm_focus_list_has( LM_DATA * lmp )
{
XI_ITF_DATA *itf;
BOOLEAN retval;
itf = lmp->itf_obj->v.itf;
retval = ( itf->focus_obj != NULL && itf->focus_obj->parent == lmp->list_obj );
return retval;
}
BOOLEAN
lm_focus_cell_get( LM_DATA * lmp, int *rowp, int *columnp, BOOLEAN * is_vert_scrolled )
{
XI_ITF_DATA *itf;
XI_OBJ *focus_obj;
XI_CELL_DATA *cd;
itf = lmp->itf_obj->v.itf;
focus_obj = itf->focus_obj;
if ( focus_obj != NULL && focus_obj->parent == lmp->list_obj &&
focus_obj->type == XIT_CELL )
{
cd = &focus_obj->v.cell;
*rowp = cd->row;
*columnp = cd->column;
*is_vert_scrolled = cd->is_vert_scrolled;
return TRUE;
}
*rowp = 0;
*columnp = 0;
*is_vert_scrolled = FALSE;
return FALSE;
}
void
lm_focus_cell_set( LM_DATA * lmp, int row, int column, BOOLEAN is_vert_scrolled )
{
XI_ITF_DATA *itf;
XI_OBJ *focus_obj;
XI_CELL_DATA *cd;
itf = lmp->itf_obj->v.itf;
focus_obj = itf->focus_obj;
if ( focus_obj != NULL && focus_obj->parent == lmp->list_obj &&
focus_obj->type == XIT_CELL )
{
cd = &focus_obj->v.cell;
cd->row = row;
cd->column = column;
cd->is_vert_scrolled = ( unsigned char ) is_vert_scrolled;
return;
}
XinError( 20921, XinSeverityFatal, 0L );
return;
}
#if 0
/*-------------------------------------------------------------------------
function: lm_start_edit
lm: current lm
row: relevant row
column: relevant column
notes: create a text core edit field in the position of the
cell of interest, and copy in the necessary attributes
and text from the list
-------------------------------------------------------------------------*/
static void
lm_start_edit( LM lm, int row, int column )
{
LM_DATA *lmp = LMP( lm );
int focus_row,
focus_column;
BOOLEAN v_scrolled;
LM_FOCUS_CELL_VISIBLE_FORCE_ARGS args;
lm_focus_cell_get( lmp, &focus_row, &focus_column, &v_scrolled );
if ( !( focus_row == row && focus_column == column ) )
XinError( 30209, XinSeverityFatal, 0L );
MEMCLEAR( args );
args.lmp = lmp;
args.row = row;
args.column = column;
args.vert_scrolled = v_scrolled;
lm_focus_cell_visible_force( &args );
}
#endif
void
lm_focus_create_temp_row( LM_DATA * lmp )
{
int idx,
focus_row,
focus_column, i;
BOOLEAN v_scrolled;
LM_CELL_DATA *cell_data;
lm_allocate_rec_info( lmp, lmp->realized_rows_array_len + 1 );
++lmp->nbr_realized_rows;
idx = lmp->nbr_realized_rows - 1;
lmp->recs[idx] = lm_focus_rec_get( lmp );
/* cell_data_construct */
cell_data = lmp->cell_data[idx];
for ( i = 0; i < lmp->nbr_columns; ++i, ++cell_data )
{
memset( ( char * ) cell_data, '\0', sizeof( LM_CELL_DATA ) );
lm_xi_text_construct( lmp, idx, i );
}
lmp->focus_state->saved_focus_rec = lm_focus_rec_get( lmp );
lmp->focus_state->focus_rec = 0L;
lm_focus_cell_get( lmp, &focus_row, &focus_column, &v_scrolled );
focus_row = idx;
lm_focus_cell_set( lmp, focus_row, focus_column, TRUE );
lm_invalidate_rows_internal( ( LM ) lmp, focus_row, focus_row, FALSE,
focus_column, TRUE );
calculate_pix_offsets( lmp, FALSE );
calculate_visibles( lmp );
}
void
lm_focus_rec_free( LM_DATA * lmp )
{
LM_CB_DATA lm_cb_data;
lm_cb_data.lm = ( LM ) lmp;
lm_cb_data.cb_type = LM_CB_REC_FREE;
lm_cb_data.cid = lmp->cid;
lm_cb_data.win = lmp->win;
lm_cb_data.v.rec_free.record = lmp->focus_state->saved_focus_rec;
( *lmp->lm_cb ) ( &lm_cb_data );
lm_allocate_rec_info( lmp, lmp->nbr_realized_rows - 1 );
--lmp->nbr_realized_rows;
lmp->focus_state->focus_rec = 0L;
}
void
lm_focus_remove( LM_DATA * lmp, int row, int column, BOOLEAN v_scrolled )
{
int idx;
BOOLEAN found = FALSE;
LM_FOCUS where_focus_was;
where_focus_was = lmp->focus_state->where;
lmp->focus_state->where = LM_FOCUS_NOWHERE;
if ( where_focus_was != LM_FOCUS_NOWHERE &&
where_focus_was != LM_FOCUS_TEMP_INVISIBLE &&
!v_scrolled )
lm_stop_edit( ( LM ) lmp, TRUE, row, column, where_focus_was );
if ( lmp->focus_state->focus_rec )
{
for ( idx = 0; idx < lmp->nbr_realized_rows; ++idx )
{
if ( lmp->recs[idx] == lmp->focus_state->focus_rec )
{
found = TRUE;
break;
}
}
if ( found )
{
lmp->focus_state->focus_rec = 0L;
}
else
{
LM_CB_DATA lm_cb_data;
lm_cb_data.lm = ( LM ) lmp;
lm_cb_data.cb_type = LM_CB_REC_FREE;
lm_cb_data.cid = lmp->cid;
lm_cb_data.win = lmp->win;
lm_cb_data.v.rec_free.record = lmp->focus_state->focus_rec;
( *lmp->lm_cb ) ( &lm_cb_data );
lmp->focus_state->focus_rec = 0L;
}
}
}
void
lm_focus_cell_selection_get( LM_DATA * lmp, int *c1, int *c2 )
{
LM_FOCUS state;
state = lm_focus_state_get( lmp );
if ( state == LM_FOCUS_VISIBLE )
{
XI_TEXT *text;
text = xi_text_focus_get( lmp->win );
if ( text && xi_text_editing_is( text ) )
xi_text_selection_get( text, c1, c2 );
else
{
*c1 = 0;
*c2 = 0;
}
}
else
{
if ( state == LM_FOCUS_HORIZONTALLY_SCROLLED ||
state == LM_FOCUS_VERTICALLY_SCROLLED )
{
*c1 = lmp->focus_state->focus_cell_ip1;
*c2 = lmp->focus_state->focus_cell_ip2;
}
else
{
*c1 = 0;
*c2 = 0;
}
}
}
void
lm_focus_cell_selection_set( LM_DATA * lmp, int c1, int c2 )
{
LM_FOCUS state;
state = lm_focus_state_get( lmp );
if ( state == LM_FOCUS_VISIBLE )
{
XI_TEXT *text;
text = xi_text_focus_get( lmp->win );
if ( text )
xi_text_selection_set( text, c1, c2 );
}
else
{
if ( state == LM_FOCUS_HORIZONTALLY_SCROLLED ||
state == LM_FOCUS_VERTICALLY_SCROLLED )
{
lmp->focus_state->focus_cell_ip1 = c1;
lmp->focus_state->focus_cell_ip2 = c2;
}
}
}
void
lm_focus_rec_is_above_set( LM_DATA * lmp, BOOLEAN is_above )
{
lmp->focus_state->focus_rec_is_above = is_above;
}
BOOLEAN
lm_focus_rec_is_above_get( LM_DATA * lmp )
{
return lmp->focus_state->focus_rec_is_above;
}
void
lm_focus_rec_set( LM_DATA * lmp, long focus_rec )
{
lmp->focus_state->focus_rec = focus_rec;
}
long
lm_focus_rec_saved_get( LM_DATA * lmp )
{
return lmp->focus_state->saved_focus_rec;
}
BOOLEAN
lm_focus_cell_is_button_full_cell( LM_DATA * lmp )
{
return lmp->focus_state->button_full_cell;
}