summaryrefslogtreecommitdiff
path: root/iup/srccontrols/matrix/iupmat_def.h
blob: dd414c850b4ca9a6b565eb589c84361332dec592 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/** \file
 * \brief iupmatrix. definitions.
 *
 * See Copyright Notice in "iup.h"
 */
 
#ifndef __IUPMAT_DEF_H 
#define __IUPMAT_DEF_H

#ifdef __cplusplus
extern "C" {
#endif


#define IMAT_PROCESS_COL 1  /* Process the columns */
#define IMAT_PROCESS_LIN 2  /* Process the lines */

/***************************************************************************/
/* Decoration size in pixels                                               */
/***************************************************************************/
#define IMAT_PADDING_W   6
#define IMAT_PADDING_H   6
#define IMAT_FRAME_W   2
#define IMAT_FRAME_H   2

/* Cell flags */
#define IUPMAT_FONT    1   /* Has FONTL:C attribute */
#define IUPMAT_FGCOLOR 2   /* Has FGCOLORL:C attribute */
#define IUPMAT_BGCOLOR 4   /* Has BGCOLORL:C attribute */
#define IUPMAT_MARK    8   /* Is marked */
#define IUPMAT_FRAMEHCOLOR 16   /* Has FRAMEHORIZCOLORL:C */
#define IUPMAT_FRAMEVCOLOR 32   /* Has FRAMEVERTCOLORL:C */

/***************************************************************************/
/* Structures stored in each matrix                                        */
/***************************************************************************/
typedef struct _ImatCell
{
  char *value;           /* Cell value                              */
  unsigned char flags;  
} ImatCell;


typedef struct _ImatLinColData
{
  int* sizes;         /* Width/height of the columns/lines  (allocated after map)   */
  unsigned char* flags;    /* Attribute flags for the columns/lines (allocated after map) */

  int num;         /* Number of columns/lines in the matrix, default/minimum=1, always includes the title */
  int num_alloc;   /* Number of columns/lines allocated, default=5 */

  int first_offset; /* scroll offset of the first visible column/line from right to left (or the invisible part of the first cell) */
  int first;       /* First visible column/line */
  int last;        /* Last visible column/line  */

  /* used to configure the scrollbar */
  int total_size;     /* Sum of the widths/heights of the columns/lines, not including the title */
  int visible_size;   /* Width/height of the visible window, not including the title */

  int focus_cell;  /* index of the current cell */
} ImatLinColData;

struct _IcontrolData
{
  iupCanvas canvas;  /* from IupCanvas (must reserve it) */

  ImatCell** cells;  /* Cell value, this will be NULL if in callback mode (allocated after map) */

  Ihandle* texth;     /* Text handle                    */
  Ihandle* droph;     /* Dropdown handle                */
  Ihandle* datah;     /* Current active edition element, may be equal to texth or droph */

  cdCanvas* cddbuffer;
  cdCanvas* cdcanvas;

  ImatLinColData lines;
  ImatLinColData columns;

  int has_focus;
  int w, h;             /* canvas size */
  int callback_mode;
  int use_title_size;   /* use title contents when calculating cell size */
  int need_calcsize;
  int first_redraw;
  int inside_markedit_cb;   /* avoid recursion */

  /* attributes */
  int mark_continuous, mark_mode, mark_multiple;
  int checkframecolor, hidden_text_marks;

  /* Mouse and Keyboard AUX */
  int leftpressed;  /* left mouse button is pressed */
  int homekeycount, endkeycount;  /* numbers of times that key was pressed */

  /* ColRes AUX */
  int colres_dragging,   /* indicates if it is being made a column resize  */
      colres_drag_col,   /* column being resized, handler is at right of the column */
      colres_drag_col_start_x, /* handler start position */
      colres_drag_col_last_x;  /* previous position */

  /* Mark AUX */
  int mark_lin1, mark_col1,  /* used to store the start cell when a block is being marked */
      mark_lin2, mark_col2,  /* used to store the end cell when a block was marked */
      mark_full1,            /* indicate if full lines or columns is being selected */
      mark_full2;

  /* Draw AUX, valid only after iupMatrixPrepareDrawData */
  sIFnii font_cb;
  IFniiIII fgcolor_cb;
  IFniiIII bgcolor_cb;
  char *bgcolor, *bgcolor_parent, *fgcolor, *font;  /* not need to free */

  int clip_x1, clip_x2, clip_y1, clip_y2;  /* aux for cell clipping */
};


int iupMatrixIsValid(Ihandle* ih, int check_cells);

#define iupMATRIX_INVERTYAXIS(_ih, _y) ((_ih)->data->h-1 - (_y))


#ifdef __cplusplus
}
#endif

#endif