1 /* 2 * Copyright (c) 2009 Mat Sutcliffe (oktal@gmx.co.uk) 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 18 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 21 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 22 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 23 * USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26 #include "EXTERN.h" 27 #include "perl.h" 28 #include "XSUB.h" 29 30 #include <agar/core.h> 31 #include <agar/gui.h> 32 #include "perl_agar.h" 33 34 MODULE = Agar::Widget PACKAGE = Agar::Widget PREFIX = AG_ 35 PROTOTYPES: ENABLE 36 VERSIONCHECK: DISABLE 37 38 void 39 draw(self) 40 Agar::Widget self 41 CODE: 42 AG_WidgetDraw(self); 43 44 void 45 enable(self) 46 Agar::Widget self 47 CODE: 48 AG_WidgetEnable(self); 49 50 void 51 disable(self) 52 Agar::Widget self 53 CODE: 54 AG_WidgetDisable(self); 55 56 int 57 isEnabled(self) 58 Agar::Widget self 59 CODE: 60 RETVAL = AG_WidgetEnabled(self); 61 OUTPUT: 62 RETVAL 63 64 int 65 isDisabled(self) 66 Agar::Widget self 67 CODE: 68 RETVAL = AG_WidgetDisabled(self); 69 OUTPUT: 70 RETVAL 71 72 void 73 setFocusable(self, isFocusable) 74 Agar::Widget self 75 int isFocusable 76 CODE: 77 AG_WidgetSetFocusable(self, isFocusable); 78 79 int 80 isFocused(self) 81 Agar::Widget self 82 CODE: 83 RETVAL = AG_WidgetIsFocused(self); 84 OUTPUT: 85 RETVAL 86 87 int 88 isFocusedInWindow(self) 89 Agar::Widget self 90 CODE: 91 RETVAL = AG_WidgetIsFocusedInWindow(self); 92 OUTPUT: 93 RETVAL 94 95 void 96 focus(self) 97 Agar::Widget self 98 CODE: 99 AG_WidgetFocus(self); 100 101 void 102 unfocus(self) 103 Agar::Widget self 104 CODE: 105 AG_WidgetUnfocus(self); 106 107 Agar::Window 108 window(self) 109 Agar::Widget self 110 CODE: 111 RETVAL = AG_ParentWindow(self); 112 OUTPUT: 113 RETVAL 114 115 void 116 requestSize(self, w, h) 117 Agar::Widget self 118 int w 119 int h 120 PREINIT: 121 static AG_SizeReq sizereq; 122 CODE: 123 sizereq.w = w; 124 sizereq.h = h; 125 AG_WidgetSizeReq(self, &sizereq); 126 127 void 128 setSize(self, w, h) 129 Agar::Widget self 130 int w 131 int h 132 CODE: 133 AG_WidgetSetSize(self, w, h); 134 135 int 136 x(self) 137 Agar::Widget self 138 CODE: 139 RETVAL = self->x; 140 OUTPUT: 141 RETVAL 142 143 int 144 y(self) 145 Agar::Widget self 146 CODE: 147 RETVAL = self->y; 148 OUTPUT: 149 RETVAL 150 151 int 152 w(self) 153 Agar::Widget self 154 CODE: 155 RETVAL = self->w; 156 OUTPUT: 157 RETVAL 158 159 int 160 h(self) 161 Agar::Widget self 162 CODE: 163 RETVAL = self->h; 164 OUTPUT: 165 RETVAL 166 167 void 168 expandHoriz(self) 169 Agar::Widget self 170 CODE: 171 AG_ExpandHoriz(self); 172 173 void 174 expandVert(self) 175 Agar::Widget self 176 CODE: 177 AG_ExpandVert(self); 178 179 void 180 expand(self) 181 Agar::Widget self 182 CODE: 183 AG_Expand(self); 184 185 void 186 redraw(self) 187 Agar::Widget self 188 CODE: 189 AG_Redraw(self); 190 191 void 192 redrawOnChange(self, refresh_ms, name) 193 Agar::Widget self 194 int refresh_ms 195 const char *name 196 CODE: 197 AG_RedrawOnChange(self, refresh_ms, name); 198 199 void 200 redrawOnTick(self, refresh_ms) 201 Agar::Widget self 202 int refresh_ms 203 CODE: 204 AG_RedrawOnTick(self, refresh_ms); 205 206