1 | /* |
---|
2 | * libcaca Colour ASCII-Art library |
---|
3 | * Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org> |
---|
4 | * All Rights Reserved |
---|
5 | * |
---|
6 | * $Id: driver_cocoa.m 1396 2006-11-14 18:02:29Z sam $ |
---|
7 | * |
---|
8 | * This library is free software; you can redistribute it and/or |
---|
9 | * modify it under the terms of the Do What The Fuck You Want To |
---|
10 | * Public License, Version 2, as published by Sam Hocevar. See |
---|
11 | * http://sam.zoy.org/wtfpl/COPYING for more details. |
---|
12 | */ |
---|
13 | |
---|
14 | /* |
---|
15 | * This file contains the libcaca Cocoa input and output driver |
---|
16 | */ |
---|
17 | |
---|
18 | #include "config.h" |
---|
19 | #include "common.h" |
---|
20 | |
---|
21 | #if defined USE_COCOA |
---|
22 | |
---|
23 | #include <stdio.h> |
---|
24 | #include <stdlib.h> |
---|
25 | |
---|
26 | #include <Cocoa/Cocoa.h> |
---|
27 | |
---|
28 | #include "caca.h" |
---|
29 | #include "caca_internals.h" |
---|
30 | #include "cucul.h" |
---|
31 | #include "cucul_internals.h" |
---|
32 | |
---|
33 | struct driver_private |
---|
34 | { |
---|
35 | /* Just testing stuff */ |
---|
36 | NSAutoreleasePool *pool; |
---|
37 | }; |
---|
38 | |
---|
39 | static int cocoa_init_graphics(caca_display_t *dp) |
---|
40 | { |
---|
41 | dp->drv.p = malloc(sizeof(struct driver_private)); |
---|
42 | |
---|
43 | dp->drv.p->pool = [NSAutoreleasePool new]; |
---|
44 | |
---|
45 | return 0; |
---|
46 | } |
---|
47 | |
---|
48 | static int cocoa_end_graphics(caca_display_t *dp) |
---|
49 | { |
---|
50 | [dp->drv.p->pool release]; |
---|
51 | |
---|
52 | free(dp->drv.p); |
---|
53 | |
---|
54 | return 0; |
---|
55 | } |
---|
56 | |
---|
57 | static int cocoa_set_display_title(caca_display_t *dp, char const *title) |
---|
58 | { |
---|
59 | return -1; |
---|
60 | } |
---|
61 | |
---|
62 | static unsigned int cocoa_get_display_width(caca_display_t *dp) |
---|
63 | { |
---|
64 | return 0; |
---|
65 | } |
---|
66 | |
---|
67 | static unsigned int cocoa_get_display_height(caca_display_t *dp) |
---|
68 | { |
---|
69 | return 0; |
---|
70 | } |
---|
71 | |
---|
72 | static void cocoa_display(caca_display_t *dp) |
---|
73 | { |
---|
74 | ; |
---|
75 | } |
---|
76 | |
---|
77 | static void cocoa_handle_resize(caca_display_t *dp) |
---|
78 | { |
---|
79 | ; |
---|
80 | } |
---|
81 | |
---|
82 | static int cocoa_get_event(caca_display_t *dp, caca_event_t *ev) |
---|
83 | { |
---|
84 | ev->type = CACA_EVENT_NONE; |
---|
85 | return 0; |
---|
86 | } |
---|
87 | |
---|
88 | /* |
---|
89 | * Driver initialisation |
---|
90 | */ |
---|
91 | |
---|
92 | int cocoa_install(caca_display_t *dp) |
---|
93 | { |
---|
94 | dp->drv.driver = CACA_DRIVER_RAW; |
---|
95 | |
---|
96 | dp->drv.init_graphics = cocoa_init_graphics; |
---|
97 | dp->drv.end_graphics = cocoa_end_graphics; |
---|
98 | dp->drv.set_display_title = cocoa_set_display_title; |
---|
99 | dp->drv.get_display_width = cocoa_get_display_width; |
---|
100 | dp->drv.get_display_height = cocoa_get_display_height; |
---|
101 | dp->drv.display = cocoa_display; |
---|
102 | dp->drv.handle_resize = cocoa_handle_resize; |
---|
103 | dp->drv.get_event = cocoa_get_event; |
---|
104 | dp->drv.set_mouse = NULL; |
---|
105 | |
---|
106 | return 0; |
---|
107 | } |
---|
108 | |
---|
109 | #endif /* USE_COCOA */ |
---|