1set_cursor_drawer(3)            gstream manual            set_cursor_drawer(3)
2
3
4

NAME

6       set_cursor_drawer
7

SYNOPSIS

9       #include <gstream.h>
10
11
12       void  set_cursor_drawer(void  (*cd)(BITMAP  *, int, int, int, int, int,
13       bool));
14

DESCRIPTION

16       This will set the function for drawing the cursor, which is  useful  if
17       you want to customize it with your own favourite cursor (perhaps a BIT‐
18       MAP). Before you can actually use the cursor for  inputting,  you  also
19       have  to  call  set_cursor_dimensions with the width and height of your
20       cursor, in both insert and overwrite mode.
21
22       The parameters of the drawer function are: destination bitmap (the BIT‐
23       MAP  you draw on); x-coordinate; y-coordinate; the width (if you passed
24       gbuf::DYNAMIC_CURSOR_SIZE it is the width of the  character  under  the
25       cursor,  else  it  is the width you specified); the height (ditto); the
26       colour of the font (watch out for a -1!); whether in insert mode  (true
27       if so).
28
29       A simple example of a standard console cursor:
30
31          void cd_cons(BITMAP *bmp, int x, int y, int w, int h, int c, bool ins)
32          {
33            int colour;
34
35            // determine colour (defaults to black if no colour specified)
36            if (c == -1)
37              colour = makecol_depth(bitmap_color_depth(bmp), 0, 0, 0);
38            else
39              colour = c;
40
41            if (ins)  // if it is the insert cursor
42              rectfill(bmp, x, y + h - 2, x + w - 1, y + h - 1, colour);
43            else      // else overwrite cursor
44              rectfill(bmp, x, y, x + w - 1, y + h - 1, colour);
45          }
46
47       You don't have to think about flashing the cursor or other pecularities
48       - the gstream will take care of that, all you have to  do  is  to  con‐
49       struct  a function that draws something on the specified BITMAP, at the
50       specified position, not exceeding the specified width and  height.  You
51       are  of  course free to ignore the color and the insert parameter, just
52       make sure that you don't draw outside the given rectangle, or else  the
53       gstream can't recover the background and the result will be artifacts.
54
55       A typedef, 'cursor_drawer', in 'gbuf' makes it easy to declare pointers
56       to this type of functions:
57
58          gbuf::cursor_drawer tmp_cd;
59
60          //...
61
62          tmp_cd = gs1.get_cursor_drawer();
63          gs1.set_cursor_drawer(gs2.get_cursor_drawer());
64          gs2.set_cursor_drawer(tmp_cd);
65
66       The default cursor drawer is 'cd_winconsole'.
67
68

SEE ALSO

70       gstream-set_cursor_dimensions(3),         gstream-get_cursor_drawer(3),
71       gstream-cd_winconsole(3)
72
73
74
75gstream                           version 1.6             set_cursor_drawer(3)
Impressum