gstream-set_cursor_drawer man page



#include <gstream.h>

void set_cursor_drawer(void (*cd)(BITMAP *, int, int, int, int, int, bool));


This will set the function for drawing the cursor, which is useful if you want to customize it with your own favourite cursor (perhaps a BITMAP). Before you can actually use the cursor for inputting, you also have to call set_cursor_dimensions with the width and height of your cursor, in both insert and overwrite mode.

The parameters of the drawer function are: destination bitmap (the BITMAP you draw on); x-coordinate; y-coordinate; the width (if you passed gbuf::DYNAMIC_CURSOR_SIZE it is the width of the character under the cursor, else it is the width you specified); the height (ditto); the colour of the font (watch out for a -1!); whether in insert mode (true if so).

A simple example of a standard console cursor:

void cd_cons(BITMAP *bmp, int x, int y, int w, int h, int c, bool ins)
  int colour;

  // determine colour (defaults to black if no colour specified)
  if (c == -1)
    colour = makecol_depth(bitmap_color_depth(bmp), 0, 0, 0);
    colour = c;

  if (ins)  // if it is the insert cursor
    rectfill(bmp, x, y + h - 2, x + w - 1, y + h - 1, colour);
  else      // else overwrite cursor
    rectfill(bmp, x, y, x + w - 1, y + h - 1, colour);

You don't have to think about flashing the cursor or other pecularities - the gstream will take care of that, all you have to do is to construct a function that draws something on the specified BITMAP, at the specified position, not exceeding the specified width and height. You are of course free to ignore the color and the insert parameter, just make sure that you don't draw outside the given rectangle, or else the gstream can't recover the background and the result will be artifacts.

A typedef, 'cursor_drawer', in 'gbuf' makes it easy to declare pointers to this type of functions:

gbuf::cursor_drawer tmp_cd;


tmp_cd = gs1.get_cursor_drawer();

The default cursor drawer is 'cd_winconsole'.

See Also

gstream-set_cursor_dimensions(3), gstream-get_cursor_drawer(3), gstream-cd_winconsole(3)

Referenced By

gstream-cd_console(3), gstream-cd_winconsole(3), gstream-get_cursor_drawer(3), gstream-set_cursor_dimensions(3).

Explore man page connections for gstream-set_cursor_drawer(3).

gstream version 1.6 gstream manual