| [784] | 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 | * |
|---|
| [1462] | 8 | * This library is free software. It comes without any warranty, to |
|---|
| [1452] | 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 |
|---|
| [784] | 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 | |
|---|
| [2050] | 21 | #include <iostream> |
|---|
| [784] | 22 | |
|---|
| [781] | 23 | #include "caca++.h" |
|---|
| 24 | |
|---|
| [897] | 25 | Caca::Caca(Cucul *cv) |
|---|
| [781] | 26 | { |
|---|
| [819] | 27 | dp = caca_create_display(cv->get_cucul_canvas_t()); |
|---|
| [827] | 28 | if(!dp) |
|---|
| 29 | throw -1; |
|---|
| [781] | 30 | } |
|---|
| [827] | 31 | |
|---|
| [897] | 32 | Caca::~Caca() |
|---|
| [781] | 33 | { |
|---|
| [819] | 34 | caca_free_display(dp); |
|---|
| [781] | 35 | } |
|---|
| [827] | 36 | |
|---|
| [897] | 37 | void Caca::Attach(Cucul *cv) |
|---|
| [781] | 38 | { |
|---|
| [819] | 39 | dp = caca_create_display(cv->get_cucul_canvas_t()); |
|---|
| [827] | 40 | if(!dp) |
|---|
| 41 | throw -1; |
|---|
| [781] | 42 | } |
|---|
| [827] | 43 | |
|---|
| [897] | 44 | void Caca::Detach() |
|---|
| [781] | 45 | { |
|---|
| [819] | 46 | caca_free_display(dp); |
|---|
| [781] | 47 | } |
|---|
| [827] | 48 | |
|---|
| [1002] | 49 | void Caca::setDisplayTime(unsigned int d) |
|---|
| [781] | 50 | { |
|---|
| [1002] | 51 | caca_set_display_time(dp, d); |
|---|
| [781] | 52 | } |
|---|
| [827] | 53 | |
|---|
| [897] | 54 | void Caca::Display() |
|---|
| [781] | 55 | { |
|---|
| [819] | 56 | caca_refresh_display(dp); |
|---|
| [781] | 57 | } |
|---|
| [827] | 58 | |
|---|
| [1002] | 59 | unsigned int Caca::getDisplayTime() |
|---|
| [781] | 60 | { |
|---|
| [1002] | 61 | return caca_get_display_time(dp); |
|---|
| [781] | 62 | } |
|---|
| [827] | 63 | |
|---|
| [897] | 64 | unsigned int Caca::getWidth() |
|---|
| [781] | 65 | { |
|---|
| [819] | 66 | return caca_get_display_width(dp); |
|---|
| [781] | 67 | } |
|---|
| [827] | 68 | |
|---|
| [897] | 69 | unsigned int Caca::getHeight() |
|---|
| [781] | 70 | { |
|---|
| [819] | 71 | return caca_get_display_height(dp); |
|---|
| [781] | 72 | } |
|---|
| [827] | 73 | |
|---|
| [897] | 74 | int Caca::setTitle(char const *s) |
|---|
| [781] | 75 | { |
|---|
| [819] | 76 | return caca_set_display_title(dp, s); |
|---|
| [781] | 77 | } |
|---|
| [827] | 78 | |
|---|
| [897] | 79 | int Caca::getEvent(unsigned int g, Event *n, int aa) |
|---|
| [781] | 80 | { |
|---|
| [2050] | 81 | return caca_get_event(dp, g, n ? &n->e : NULL, aa); |
|---|
| [781] | 82 | } |
|---|
| [827] | 83 | |
|---|
| [897] | 84 | unsigned int Caca::getMouseX() |
|---|
| [781] | 85 | { |
|---|
| [811] | 86 | return caca_get_mouse_x(dp); |
|---|
| [781] | 87 | } |
|---|
| [827] | 88 | |
|---|
| [897] | 89 | unsigned int Caca::getMouseY() |
|---|
| [781] | 90 | { |
|---|
| [811] | 91 | return caca_get_mouse_x(dp); |
|---|
| [781] | 92 | } |
|---|
| [827] | 93 | |
|---|
| [897] | 94 | void Caca::setMouse(int v) |
|---|
| [781] | 95 | { |
|---|
| [917] | 96 | caca_set_mouse(dp, v); |
|---|
| [781] | 97 | } |
|---|
| [827] | 98 | |
|---|
| [2074] | 99 | const char * Caca::getVersion() |
|---|
| 100 | { |
|---|
| 101 | return caca_get_version(); |
|---|
| 102 | } |
|---|
| 103 | |
|---|