OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [libgui/] [src/] [tclcursor.c] - Blame information for rev 578

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
/* tclcursor.c - Tcl function to compute the size of a cursor.
2
   Copyright (C) 1997 Cygnus Solutions.
3
   Written by Tom Tromey <tromey@cygnus.com>.  */
4
 
5
/* Interestingly, there is no way to get the size of a cursor in X.
6
   We would have to change Tk to keep track of this information if we
7
   cared about it.  Luckily, we only care for Windows.  */
8
 
9
/* This makes a Tcl command with two subcommands:
10
 
11
   ide_cursor size  - Return size of cursor as list {WIDTH HEIGHT}
12
 
13
   ide_cursor position - Return position of cursor as list {X Y}
14
 
15
   */
16
 
17
#ifdef _WIN32
18
 
19
#include <windows.h>
20
 
21
#include <tcl.h>
22
#include <stdio.h>
23
 
24
#include "guitcl.h"
25
#include "subcommand.h"
26
 
27
static int
28
get_cursor_size (ClientData cd, Tcl_Interp *interp, int argc, char *argv[])
29
{
30
  char buf[30];
31
 
32
  sprintf (buf, "%d", GetSystemMetrics (SM_CXCURSOR));
33
  Tcl_AppendElement (interp, buf);
34
  sprintf (buf, "%d", GetSystemMetrics (SM_CYCURSOR));
35
  Tcl_AppendElement (interp, buf);
36
 
37
  return TCL_OK;
38
}
39
 
40
static int
41
get_cursor_position (ClientData cd, Tcl_Interp *interp, int argc, char *argv[])
42
{
43
  POINT where;
44
  char buf[30];
45
 
46
  if (! GetCursorPos (&where))
47
    {
48
      Tcl_AppendResult (interp, argv[0], ": couldn't get cursor position",
49
                        (char *) NULL);
50
      return TCL_ERROR;
51
    }
52
 
53
  sprintf (buf, "%ld", where.x);
54
  Tcl_AppendElement (interp, buf);
55
  sprintf (buf, "%ld", where.y);
56
  Tcl_AppendElement (interp, buf);
57
 
58
  return TCL_OK;
59
}
60
 
61
static const struct ide_subcommand_table cursor_commands[] =
62
{
63
  { "size", get_cursor_size, 2, 2 },
64
  { "position", get_cursor_position, 2, 2 },
65
  { NULL, NULL, 0, 0 }
66
};
67
 
68
int
69
ide_create_cursor_command (Tcl_Interp *interp)
70
{
71
  return ide_create_command_with_subcommands (interp, "ide_cursor",
72
                                              cursor_commands,
73
                                              (ClientData) NULL,
74
                                              NULL);
75
}
76
 
77
#endif /* _WIN32 */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.