| 1 | /* |
|---|
| 2 | * libcaca++ C++ bindings for libcaca |
|---|
| 3 | * Copyright (c) 2006 Jean-Yves Lamoureux <jylam@lnxscene.org> |
|---|
| 4 | * All Rights Reserved |
|---|
| 5 | * |
|---|
| 6 | * $Id$ |
|---|
| 7 | * |
|---|
| 8 | * This library is free software. It comes without any warranty, to |
|---|
| 9 | * the extent permitted by applicable law. You can redistribute it |
|---|
| 10 | * and/or modify it under the terms of the Do What The Fuck You Want |
|---|
| 11 | * To Public License, Version 2, as published by Sam Hocevar. See |
|---|
| 12 | * http://sam.zoy.org/wtfpl/COPYING for more details. |
|---|
| 13 | */ |
|---|
| 14 | |
|---|
| 15 | /* |
|---|
| 16 | * This file contains the main functions used by \e libcaca++ applications to |
|---|
| 17 | * initialise the library, get the screen properties, set the framerate and |
|---|
| 18 | * so on. |
|---|
| 19 | */ |
|---|
| 20 | |
|---|
| 21 | #include <iostream> |
|---|
| 22 | |
|---|
| 23 | #include "caca++.h" |
|---|
| 24 | |
|---|
| 25 | Caca::Caca(Cucul *cv) |
|---|
| 26 | { |
|---|
| 27 | dp = caca_create_display(cv->get_cucul_canvas_t()); |
|---|
| 28 | if(!dp) |
|---|
| 29 | throw -1; |
|---|
| 30 | } |
|---|
| 31 | |
|---|
| 32 | Caca::~Caca() |
|---|
| 33 | { |
|---|
| 34 | caca_free_display(dp); |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | void Caca::Attach(Cucul *cv) |
|---|
| 38 | { |
|---|
| 39 | dp = caca_create_display(cv->get_cucul_canvas_t()); |
|---|
| 40 | if(!dp) |
|---|
| 41 | throw -1; |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | void Caca::Detach() |
|---|
| 45 | { |
|---|
| 46 | caca_free_display(dp); |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | void Caca::setDisplayTime(unsigned int d) |
|---|
| 50 | { |
|---|
| 51 | caca_set_display_time(dp, d); |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | void Caca::Display() |
|---|
| 55 | { |
|---|
| 56 | caca_refresh_display(dp); |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | unsigned int Caca::getDisplayTime() |
|---|
| 60 | { |
|---|
| 61 | return caca_get_display_time(dp); |
|---|
| 62 | } |
|---|
| 63 | |
|---|
| 64 | unsigned int Caca::getWidth() |
|---|
| 65 | { |
|---|
| 66 | return caca_get_display_width(dp); |
|---|
| 67 | } |
|---|
| 68 | |
|---|
| 69 | unsigned int Caca::getHeight() |
|---|
| 70 | { |
|---|
| 71 | return caca_get_display_height(dp); |
|---|
| 72 | } |
|---|
| 73 | |
|---|
| 74 | int Caca::setTitle(char const *s) |
|---|
| 75 | { |
|---|
| 76 | return caca_set_display_title(dp, s); |
|---|
| 77 | } |
|---|
| 78 | |
|---|
| 79 | int Caca::getEvent(unsigned int g, Event *n, int aa) |
|---|
| 80 | { |
|---|
| 81 | return caca_get_event(dp, g, n ? &n->e : NULL, aa); |
|---|
| 82 | } |
|---|
| 83 | |
|---|
| 84 | unsigned int Caca::getMouseX() |
|---|
| 85 | { |
|---|
| 86 | return caca_get_mouse_x(dp); |
|---|
| 87 | } |
|---|
| 88 | |
|---|
| 89 | unsigned int Caca::getMouseY() |
|---|
| 90 | { |
|---|
| 91 | return caca_get_mouse_x(dp); |
|---|
| 92 | } |
|---|
| 93 | |
|---|
| 94 | void Caca::setMouse(int v) |
|---|
| 95 | { |
|---|
| 96 | caca_set_mouse(dp, v); |
|---|
| 97 | } |
|---|
| 98 | |
|---|
| 99 | const char * Caca::getVersion() |
|---|
| 100 | { |
|---|
| 101 | return caca_get_version(); |
|---|
| 102 | } |
|---|
| 103 | |
|---|