25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

106 lines
1.8 KiB

  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. * This file contains the main functions used by \e libcaca++ applications to
  16. * initialise the library, get the screen properties, set the framerate and
  17. * so on.
  18. */
  19. #include "config.h"
  20. #include <iostream>
  21. #include "caca++.h"
  22. Caca::Caca(Cucul *cv)
  23. {
  24. dp = caca_create_display(cv->get_cucul_canvas_t());
  25. if(!dp)
  26. throw -1;
  27. }
  28. Caca::~Caca()
  29. {
  30. caca_free_display(dp);
  31. }
  32. void Caca::Attach(Cucul *cv)
  33. {
  34. dp = caca_create_display(cv->get_cucul_canvas_t());
  35. if(!dp)
  36. throw -1;
  37. }
  38. void Caca::Detach()
  39. {
  40. caca_free_display(dp);
  41. }
  42. void Caca::setDisplayTime(unsigned int d)
  43. {
  44. caca_set_display_time(dp, d);
  45. }
  46. void Caca::Display()
  47. {
  48. caca_refresh_display(dp);
  49. }
  50. unsigned int Caca::getDisplayTime()
  51. {
  52. return caca_get_display_time(dp);
  53. }
  54. unsigned int Caca::getWidth()
  55. {
  56. return caca_get_display_width(dp);
  57. }
  58. unsigned int Caca::getHeight()
  59. {
  60. return caca_get_display_height(dp);
  61. }
  62. int Caca::setTitle(char const *s)
  63. {
  64. return caca_set_display_title(dp, s);
  65. }
  66. int Caca::getEvent(unsigned int g, Event *n, int aa)
  67. {
  68. return caca_get_event(dp, g, n ? &n->e : NULL, aa);
  69. }
  70. unsigned int Caca::getMouseX()
  71. {
  72. return caca_get_mouse_x(dp);
  73. }
  74. unsigned int Caca::getMouseY()
  75. {
  76. return caca_get_mouse_x(dp);
  77. }
  78. void Caca::setMouse(int v)
  79. {
  80. caca_set_mouse(dp, v);
  81. }
  82. const char * Caca::getVersion()
  83. {
  84. return caca_get_version();
  85. }