summaryrefslogtreecommitdiff
path: root/iup/srccontrols/matrix/iupmat_focus.c
blob: 3c000f818228ccd36478f9904f8e9e3f32d17ac8 (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
/** \file
 * \brief iupmatrix focus control
 *
 * See Copyright Notice in "iup.h"
 */
 
#include <stdlib.h>

#include "iup.h"
#include "iupcbs.h"

#include <cd.h>

#include "iup_object.h"
#include "iup_attrib.h"
#include "iup_str.h"
#include "iup_stdcontrols.h"

#include "iupmat_def.h"
#include "iupmat_aux.h"
#include "iupmat_focus.h"
#include "iupmat_draw.h"


void iupMatrixFocusSet(Ihandle* ih, int lin, int col)
{
  ih->data->lines.focus_cell = lin;
  ih->data->columns.focus_cell = col;
}

int iupMatrixFocus_CB(Ihandle* ih, int focus)
{
  int rc = IUP_DEFAULT;

  if (!iupMatrixIsValid(ih, 1))
    return IUP_DEFAULT;

  if (iupStrEqualNoCase(IupGetGlobal("DRIVER"), "Motif"))
  {
    if (focus && iupAttribGet(ih, "_IUPMAT_DOUBLE_CLICK"))
    {
      iupAttribSetStr(ih, "_IUPMAT_DOUBLE_CLICK", NULL);
      return IUP_DEFAULT;
    }
  }

  ih->data->has_focus = focus;
  iupMatrixDrawUpdate(ih);

  if (focus)
    iupMatrixAuxCallEnterCellCb(ih);
  else
    iupMatrixAuxCallLeaveCellCb(ih);

  return rc;
}