campo-sirio/xi/xilm.h
alex 18c8e52948 This commit was generated by cvs2svn to compensate for changes in r5757,
which included commits to RCS files with non-trunk default branches.

git-svn-id: svn://10.65.10.50/trunk@5758 c028cbd2-c16b-5b4b-a496-9718f37d4682
1997-12-17 10:43:31 +00:00

651 lines
19 KiB
C
Executable File

/*******************************************************************************
* Copyright 1991-1995 by ORCA Software, Inc. *
* *
* All rights reserved. May not be reproduced or distributed, in printed or *
* electronic form, without permission of ORCA Software, Inc. *
*******************************************************************************/
/******************************************************************
LM module
******************************************************************/
#define LM_ATR_ENABLED XI_ATR_ENABLED
#define LM_ATR_VISIBLE XI_ATR_VISIBLE
#define LM_ATR_NAVIGATE XI_ATR_NAVIGATE
#define LM_ATR_TABWRAP XI_ATR_TABWRAP
typedef enum _lm_cb_type
{
LM_CB_CHAR,
LM_CB_CHANGE,
LM_CB_DBL,
LM_CB_FOCUS,
LM_CB_TEXT,
LM_CB_SELECT,
LM_CB_CELL_BTN,
LM_CB_GET_FIRST,
LM_CB_GET_NEXT,
LM_CB_GET_PREV,
LM_CB_GET_LAST,
LM_CB_GET_PERCENT,
LM_CB_REC_ALLOCATE,
LM_CB_REC_FREE,
LM_CB_ROW_SIZE,
LM_CB_COL_DELETE,
LM_CB_COL_MOVE,
LM_CB_COL_SIZE
}
LM_CB_TYPE;
typedef struct _lm_cb_data
{
LM lm;
LM_CB_TYPE cb_type;
int cid;
WINDOW win;
int row;
int column;
long rec;
union
{
struct
{
long spec_rec;
long data_rec;
int percent;
unsigned long attrib;
COLOR color;
BOOLEAN refused;
int row_height;
BOOLEAN has_focus;
} rec_request;
struct
{
int new_row_height;
BOOLEAN refused;
} row_size;
struct
{
long record;
} rec_allocate;
struct
{
long record;
} rec_free;
struct
{
long record;
int percent;
} get_percent;
struct
{
char *text;
int len;
int icon_rid;
unsigned long attrib;
COLOR color;
COLOR back_color;
FONT *font;
XVT_FNTID font_id;
BOOLEAN button;
BOOLEAN button_on_left;
BOOLEAN button_on_focus;
int button_icon_rid;
} text;
BOOLEAN refused;
struct
{
int ch;
BOOLEAN shift;
BOOLEAN control;
BOOLEAN is_paste;
BOOLEAN refused;
} chr;
struct
{
BOOLEAN dbl_click;
BOOLEAN selected;
BOOLEAN refused;
BOOLEAN shift;
BOOLEAN control;
int column;
} select;
struct
{
BOOLEAN shift;
BOOLEAN control;
} cell_btn;
struct
{
int new_col_nbr;
BOOLEAN in_fixed;
int new_col_width;
int new_col_pixel_width;
BOOLEAN refused;
} column;
/* nothing for LM_CB_CHANGE */
} v;
} LM_CB_DATA;
typedef void (*LM_CB)(LM_CB_DATA *lm_cb_data);
#define LM_COL_ATR_ENABLED XI_ATR_ENABLED
#define LM_COL_ATR_EDITMENU XI_ATR_EDITMENU
#define LM_COL_ATR_AUTOSELECT XI_ATR_AUTOSELECT
#define LM_COL_ATR_AUTOSCROLL XI_ATR_AUTOSCROLL
#define LM_COL_ATR_RJUST XI_ATR_RJUST
#define LM_COL_ATR_READONLY XI_ATR_READONLY
#define LM_COL_ATR_PASSWORD XI_ATR_PASSWORD
#define LM_COL_ATR_SELECTED XI_ATR_SELECTED
#define LM_COL_ATR_SELECTABLE XI_ATR_SELECTABLE
#define LM_COL_ATR_COL_SELECTABLE XI_ATR_COL_SELECTABLE
#define LM_COL_ATR_VISIBLE XI_ATR_VISIBLE
#define LM_ROW_ATR_ENABLED XI_ATR_ENABLED
#define LM_ROW_ATR_SELECTED XI_ATR_SELECTED
#define LM_CELL_ATR_SELECTED XI_ATR_SELECTED
#define LM_CELL_ATR_RJUST XI_ATR_RJUST
#define LM_CELL_ATR_HCENTER XI_ATR_HCENTER
typedef struct _lm_column_data
{
unsigned long attrib;
short pix_width;
short x_pix_pos;
short text_offset; /* offset into row text buffer */
short text_size;
char *heading_text;
short width;
BOOLEAN center_heading;
BOOLEAN heading_well;
BOOLEAN heading_platform;
BOOLEAN column_well;
BOOLEAN column_platform;
FONT_OBJ *font;
int icon_rid;
short icon_x;
short icon_y;
BOOLEAN size_rows;
BOOLEAN suppress_update_heading;
BOOLEAN suppress_update_cells;
BOOLEAN vertical_align_center;
BOOLEAN vertical_align_bottom;
BOOLEAN wrap_text;
BOOLEAN auto_tab;
/* temporary variables - don't assume this is good */
RCT column_rct; /* used for caching column rectangles to speed drawing */
RCT prct; /* physical rect */
BOOLEAN needs_update;
} LM_COLUMN_DATA;
typedef struct _lm_column_def
{
unsigned long attrib;
short position;
short pix_width; /* pixels */
short text_size;
char *heading_text;
BOOLEAN center_heading;
BOOLEAN heading_well;
BOOLEAN heading_platform;
BOOLEAN column_well;
BOOLEAN column_platform;
FONT_OBJ *font;
int icon_rid;
short icon_x;
short icon_y;
BOOLEAN size_rows;
BOOLEAN suppress_update_heading;
BOOLEAN suppress_update_cells;
BOOLEAN vertical_align_center;
BOOLEAN vertical_align_bottom;
BOOLEAN wrap_text;
BOOLEAN auto_tab;
} LM_COLUMN_DEF;
typedef struct _lm_def
{
int cid;
XI_OBJ *list_obj;
XI_OBJ *itf_obj;
/* XI may specify this */
PNT pnt;
short pixel_height;
/* If absolute height is set, then the height of the list will be exactly height pixels high */
BOOLEAN absolute_height;
short pixel_width;
short pix_char_width;
unsigned long attrib;
LM_CB lm_cb;
FONT_OBJ *font;
COLOR back_color;
COLOR enabled_color; /* but inactive */
COLOR disabled_color;
COLOR active_color;
COLOR active_back_color;
COLOR disabled_back_color;
COLOR white_space_color;
COLOR rule_color;
char *parent;
BOOLEAN no_heading;
BOOLEAN one_row_list;
int nbr_rows;
int realized_rows_array_len;
BOOLEAN sizable_columns;
BOOLEAN movable_columns;
short fixed_columns;
short min_cell_height;
short min_heading_height;
BOOLEAN no_horz_lines;
BOOLEAN no_vert_lines;
int first_vis_column;
BOOLEAN drop_and_delete;
BOOLEAN select_cells;
BOOLEAN fixed_row_height;
BOOLEAN sizable_rows;
BOOLEAN get_all_records;
BOOLEAN keep_all_records;
BOOLEAN resize_with_window;
int horz_sync_list;
int vert_sync_list;
BOOLEAN row_focus_border;
COLOR row_focus_border_color;
int max_lines_in_cell;
BOOLEAN single_select;
BOOLEAN retain_back_color_on_select;
} LM_DEF;
#define LM_HEADING_TEXT 1001
typedef enum
{
LM_LIST,
LM_ROW,
LM_COLUMN,
LM_CELL
}
LM_PART;
typedef struct _lm_cell_data
{
unsigned long attrib;
FONT_OBJ *font;
COLOR color;
COLOR back_color;
int icon_rid;
BOOLEAN button;
BOOLEAN button_on_left;
BOOLEAN button_on_focus;
int button_icon_rid;
BOOLEAN valid_data;
/* multiline cell info */
char *string;
int pix_width;
int nbr_lines;
int *line_breaks;
int font_height;
} LM_CELL_DATA;
typedef struct _lm_data
{
int cid;
WINDOW win;
RCT rct;
short pix_top;
short pix_hdr_bottom;
short pix_row1_top;
short pix_char_width;
short pix_cell_height;
short pix_row_spacing;
unsigned long attrib;
short nbr_columns;
LM_COLUMN_DATA * *lm_column_data;
COLOR back_color;
COLOR enabled_color; /* but inactive */
COLOR disabled_color;
COLOR disabled_back_color;
COLOR active_color;
COLOR active_back_color;
COLOR white_space_color;
COLOR rule_color;
BOOLEAN no_heading;
BOOLEAN sizable_columns;
BOOLEAN movable_columns;
short fixed_columns;
short pixel_width;
short pixel_height;
BOOLEAN moving_column;
BOOLEAN sizing_column;
int column_being_sized;
short min_cell_height;
short min_heading_height;
BOOLEAN no_horz_lines;
BOOLEAN no_vert_lines;
BOOLEAN drop_and_delete;
BOOLEAN select_cells;
BOOLEAN selecting_text;
BOOLEAN sizing_row;
BOOLEAN resize_with_window;
int row_being_sized;
int horz_sync_list;
int vert_sync_list;
BOOLEAN row_focus_border;
COLOR row_focus_border_color;
int max_lines_in_cell;
BOOLEAN single_select;
BOOLEAN retain_back_color_on_select;
/*
The following fields contain state information about focus and the
list. If txt is not NULL, then editing is currently happening.
If txt_is_invisible is TRUE, then editing is suspended because the cell
with the focus is not visible, but could be at any point in time.
The fields after txt_is_invisible contain state information about
restarting editing if the focus becomes visible.
*/
TXT_DATA *txt;
BOOLEAN txt_is_invisible;
long focus_rec;
long saved_focus_rec;
BOOLEAN focus_rec_is_above;
COLOR focus_rec_color;
unsigned long focus_rec_attrib;
int focus_rec_height;
char *focus_cell_text;
int focus_cell_ip1;
int focus_cell_ip2;
/* run time data */
LM_CB lm_cb;
XI_OBJ *list_obj;
XI_OBJ *itf_obj;
FONT_OBJ *font;
short text_size;
BOOLEAN have_mouse;
int column_being_moved;
int last_x;
int last_y;
BOOLEAN down_in_hscrolling;
BOOLEAN in_hscrolling;
BOOLEAN last_in_hscrolling;
int org_x;
int org_y;
int ascent;
int descent;
int leading;
BOOLEAN selecting_cells;
int down_row;
int down_column;
int cur_row;
int cur_column;
BOOLEAN down_on_disabled;
int delta_x;
int first_vis;
int last_vis;
int vir_left;
int vir_right;
BOOLEAN btn_down; /* or up */
BOOLEAN down_in_btn;
int btn_down_row;
int btn_down_col;
int update_rows_at_top;
int update_rows_at_bottom;
BOOLEAN update_cells_only;
BOOLEAN text_scrolling;
int old_row_height;
BOOLEAN horizontally_scrolling_list;
/* vertical scrolling information */
RCT mlr;
int mlr_height;
int rrr_offset; /* offset of mlr */
int rrr_bottom; /* total number of vertical pixels in realized row rect */
int nbr_rows; /* visible, specified by XI */
int realized_rows_array_len; /* also specified by XI */
int nbr_realized_rows; /* number of rows actually used in realized row array */
int first_fully_vis;
int last_fully_vis;
BOOLEAN fixed_row_height;
BOOLEAN sizable_rows;
BOOLEAN get_all_records;
BOOLEAN keep_all_records;
/* the following arrays are all allocated to the length of realized_rows_array_len */
long *recs;
int *pix_offsets; /* pixel offsets of each row */
int *pix_heights; /* pixel heights of each row */
BOOLEAN *set_heights;
char **buffer;
unsigned long *row_attribs;
COLOR *row_colors;
LM_CELL_DATA * *cell_data;
} LM_DATA;
#define NULL_LM (LM)0
/*
There are several intrinsic functions having to do with focus.
1. Put focus on the list, start editing
Example: starting editing on the list when the focus moves to the list
from some other place in XI.
lm_start_edit
2. Move the focus from one cell on the list to another, make visible if not.
Example: tabing from one cell to another.
lm_make_invis
lm_force_vis
lm_make_vis
3. Possible transition of the focus from visible to invisible or from
invisible to visible.
Example: operating the horizontal or vertical scroll bar.
Example: resizing the list.
lm_make_invis
lm_make_vis
4. Stop editing, remove focus from the list altogether.
Example: stopping editing when the focus moves elsewhere in XI.
lm_stop_edit
*/
/*
Activities to test
1. Resize list
2. Resize column
3. Move columns around
4. Add columns
5. Delete columns
6. xi_cell_request
7. Tab around
8. Horizontal scroll
9. Vertical scroll
10. Drop horizontal thumb
11. Drop vertical thumb
12. Select range of cells
13. Set font on range of cells
14. Click on partially vis column
15. Size row
16. Change wrapping of text in cell
*/
typedef struct _lm_scroll_arg
{
LM lm;
int nbr_lines;
int percent;
BOOLEAN same_cell;
long rec;
BOOLEAN have_rec;
COLOR color;
unsigned long attrib;
int row_height;
BOOLEAN rec_at_top;
int pixels_scrolled; /* this is a return value from lm_scroll */
} LM_SCROLL_ARG;
void calculate_pix_offsets(LM_DATA *lmp, BOOLEAN draw_changes );
void calculate_visibles(LM_DATA *lmp);
void calc_x_pix_pos( LM lm, LM_COLUMN_DATA *lcdata, int position);
BOOLEAN do_lm_cb(LM lm, LM_CB_TYPE cb_reason, int row, int column,
EVENT *ep, int *percent, int pixels);
BOOLEAN do_lm_cb_get(LM lm, LM_CB_TYPE cb_reason, long *spec_rec,
long *data_rec, int percent, COLOR *color,
unsigned long *attrib, int *row_height);
void do_lm_cb_text(LM_DATA *lmp, int row, int col, BOOLEAN preserve_focus );
void do_scroll_bar(XI_LIST_DATA *listdata);
BOOLEAN lm_adj_h(LM_DATA *lmp, short *h);
void lm_allocate_rec_info(LM_DATA *lmp, int realized_rows_array_len);
void lm_calc_last_vis(LM_DATA *lmp);
int lm_calculate_row_height(LM_DATA *lmp, int row);
BOOLEAN lm_cell_has_focus( LM_DATA* lmp, int row, int column,
BOOLEAN is_vert_scrolled );
void lm_cell_request( LM lm, LM_PART lm_part, int idx1, int idx2);
void lm_column_set_pixel_width(LM lm, int idx, int width);
LM lm_create( WINDOW win, LM_DEF *lm_def, void *parent);
void lm_create_column( LM lm, LM_COLUMN_DEF *lm_column_def,
BOOLEAN do_cell_requests, BOOLEAN in_hscrolling);
void lm_delete(LM lm);
void lm_delete_column(LM lm, int column_nbr, BOOLEAN adjust_hscrolling);
BOOLEAN lm_delete_row(LM lm, int row);
void lm_draw_line(LM_DATA *lmp, PNT p, BOOLEAN adj_v, BOOLEAN adj_h);
int lm_event(LM lm, EVENT *ep);
void lm_focus_cb( long lm, int row, int column, BOOLEAN invisible,
BOOLEAN set);
void lm_force_vis(LM_DATA *lmp);
unsigned long lm_get_attrib( LM lm, LM_PART lm_part, int idx, int idx2,
BOOLEAN invisible );
int lm_get_buf_size(LM lm, LM_PART part, int idx);
int lm_get_cid(LM lm);
RCT * lm_get_cell_rect( RCT *rctp, LM lm, int row, int col, BOOLEAN inner,
BOOLEAN physical_rct);
int lm_get_col_spacing(void);
int lm_get_fixed_columns( LM lm );
void lm_get_focus_cell( LM_DATA *lmp, int *rowp, int *columnp,
BOOLEAN* is_vert_scrolled );
int lm_get_left_most_far_right_col(LM_DATA *lmp, int nbr_columns);
long* lm_get_list_info(LM lm, int *nbr_recs);
XI_OBJ* lm_get_list_obj(LM lm);
RCT* lm_get_list_rct(LM_DATA *lmp, RCT *r);
void lm_get_metrics( XI_OBJ_DEF *obj_def, int *hborder, int *column_div,
int *list_bottom);
RCT* lm_get_rect(LM lm, LM_PART part, int idx, RCT *rct);
RCT* lm_get_row_rect(RCT *rctp, LM lm, int row);
void lm_get_sel(LM lm, int *c1, int *c2);
char* lm_get_text( LM lm, char *s, int len, int row, int column,
BOOLEAN invisible );
void lm_get_vertical_metrics( XI_OBJ_DEF* obj_def, int* first_row_y,
int* row_spacing, int *client_height,
int* title_height );
void lm_get_visible_columns(LM lm, int *first_vis, int *last_vis);
int lm_get_visible_rows(LM lm, int *first_vis, int *last_vis);
void lm_hscroll(LM lm, int nbr_columns, int pos);
BOOLEAN lm_insert_row(LM lm, int row);
BOOLEAN lm_is_cell_visible(LM_DATA *lmp, int focus_row, int focus_column,
BOOLEAN use_txt_is_visible, BOOLEAN *is_hscrolled);
void lm_invalidate_rect(LM_DATA *lmp, RCT *rctp, BOOLEAN adj_h);
void lm_invalidate_rect2( LM_DATA *lmp, RCT *rct_to_invalidate,
BOOLEAN adj_left);
void lm_invalidate_rows( LM lm, int row_start, int row_end,
BOOLEAN invalidate);
void lm_invalidate_rows_internal(LM lm, int row_start, int row_end,
BOOLEAN redraw, int column,
BOOLEAN preserve_focus_text );
BOOLEAN lm_list_has_focus(LM_DATA *lmp);
void lm_local_hscroll(LM lm, int nbr_columns);
void lm_make_invis(LM_DATA *lmp);
void lm_make_vis(LM_DATA *lmp);
void lm_move_event(LM_DATA *lmp, EVENT *ep);
void lm_move_to(LM_DATA *lmp, PNT p, BOOLEAN adj_v, BOOLEAN adj_h);
void lm_recalc_metrics(LM lm);
void lm_redraw_row(LM_DATA *lmp, int row, BOOLEAN update );
void lm_remove_all_rows( LM_DATA far* lm, BOOLEAN delete_focus );
BOOLEAN lm_row_has_focus( LM_DATA *lmp, int row, BOOLEAN is_vert_scrolled);
int lm_scroll(LM_SCROLL_ARG *arg);
void lm_scroll_rect(LM_DATA *lmp, RCT *rctp, int dh, int dv);
void lm_set_fixed_columns( LM lm, int new_fixed_count );
void lm_set_focus_cell( LM_DATA *lmp, int row, int column,
BOOLEAN is_vert_scrolled );
void lm_set_attrib( LM lm, LM_PART lm_part, int idx, int idx2,
BOOLEAN invisible, unsigned long attrib,
int half_baked);
void lm_set_buf_size(LM lm, LM_PART part, int idx, int size);
void lm_set_column_width(LM lm, int idx, int width);
void lm_set_color( LM lm, LM_PART part, int row, int column,
BOOLEAN invisible, COLOR color, BOOLEAN half_baked);
void lm_set_fixed_columns( LM lm, int new_fixed_count );
void lm_set_hscroll_bar(LM lm);
void lm_set_hscroll_range(LM lm);
void lm_set_icon(LM lm, int icon_rid, int row, int column);
void lm_set_focus(LM lm, int row, int column);
void lm_set_focus_text( LM_DATA* lmp, const char* new_text );
void lm_set_font(LM lm, LM_PART part, int idx, int idx2, FONT_OBJ *font);
void lm_set_list_size(LM lm, int height, int width);
void lm_set_row_height(LM lm, int row, int height, BOOLEAN set_height,
int old_height, BOOLEAN only_update);
void lm_set_sel( LM lm, int row, int column, BOOLEAN invisible, int c1,
int c2 );
void lm_set_text(LM lm, char *s, int row, int column, BOOLEAN invisible);
void lm_size_event(LM_DATA *lmp, EVENT *ep);
void lm_text_scrolling(XI_OBJ *xi_obj);
void lm_wrap_text(LM_DATA *lmp, int row, int col, BOOLEAN set_font);
int lm_make_rrr_room_pix(LM_DATA *lmp, int pixels, BOOLEAN do_redraw );
BOOLEAN navigate_char_event(LM lm, EVENT *ep);
void redraw_cell(LM lm, int row, int col, BOOLEAN update );
void select_row( LM lm, int row, int column, BOOLEAN dbl_click );
void draw_cell_range( LM_DATA* lmp, int first_row, int last_row,
int first_col, int last_col,
BOOLEAN in_event_update );
#define LMP(l) ((LM_DATA *)(l))
#if XVT_OS == XVT_OS_CTOS
#define RULE_Y_OFFSET_TOP ((npctos_env == CHSERVICE) ? 0 : 1)
#define RULE_Y_OFFSET_BOTTOM ((npctos_env == CHSERVICE) ? 0 : 1)
#define BORDER_WIDTH ((npctos_env == CHSERVICE) ? 8 : 2)
#define RULE_WIDTH_V ((npctos_env == CHSERVICE) ? 8 : 1)
#define RULE_WIDTH_H ((npctos_env == CHSERVICE) ? 0 : 1)
#define HPIX_PER_CH 8
#define VPIX_PER_CH 8
#define WIDTHLOOP(idx, wid) for (idx = 0; idx < wid; idx++)
#else
#if XIWS == WMWS
#define RULE_Y_OFFSET_TOP 0
#define RULE_Y_OFFSET_BOTTOM 0
#define BORDER_WIDTH 8
#define RULE_WIDTH_V 8 /* width of vertical lines */
#define RULE_WIDTH_H 0 /* width of horz lines */
#define HPIX_PER_CH 8
#define VPIX_PER_CH 8
#else
#define RULE_Y_OFFSET_TOP 1
#define RULE_Y_OFFSET_BOTTOM 1
#define BORDER_WIDTH 2
#define RULE_WIDTH_V 1
#define RULE_WIDTH_H 1
#define WIDTHLOOP(idx, wid) for (idx = 0; idx < wid; idx++)
#endif
#endif
#if 0
#define ROW_IS_ENABLED(lm, row) (LMP(lm)->row_attribs[row] & LM_ROW_ATR_ENABLED)
#define CELL_IS_ENABLED(lm, row, col) (LIST_IS_ENABLED(lm) && ROW_IS_ENABLED(lm, row) && COLUMN_IS_ENABLED(lm, col))
#else
#define CELL_IS_ENABLED(lm, row, col) (LIST_IS_ENABLED(lm) && COLUMN_IS_ENABLED(lm, col))
#endif
#define CELL_IS_SELECTED(lm, row, col) ((LMP(lm)->row_attribs[row] & LM_ROW_ATR_SELECTED) || (LMP(lm)->lm_column_data[col]->attrib & LM_COL_ATR_SELECTED) || \
(LMP(lm)->cell_data[row][col].attrib & LM_CELL_ATR_SELECTED))
#define CELL_IS_SELECTABLE(lm, row, col) (LMP(lm)->lm_column_data[col]->attrib & LM_COL_ATR_SELECTABLE)
#define LIST_IS_ENABLED(lm) ((LMP(lm)->attrib & (LM_ATR_ENABLED | LM_ATR_VISIBLE)) == (LM_ATR_ENABLED | LM_ATR_VISIBLE))
#define COLUMN_IS_ENABLED(lm, col) (LMP(lm)->lm_column_data[col]->attrib & LM_COL_ATR_ENABLED)
#define COLUMN_IS_SELECTABLE(lm, col) (LMP(lm)->lm_column_data[col]->attrib & LM_COL_ATR_COL_SELECTABLE)
#define COLUMN_IS_SELECTED(lm, col) (LMP(lm)->lm_column_data[col]->attrib & LM_COL_ATR_SELECTED)