#include "precompiled.h" /* * wxJavaScript - point.cpp * * Copyright (c) 2002-2007 Franky Braem and the wxJavaScript project * * Project Info: http://www.wxjavascript.net or http://wxjs.sourceforge.net * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * $Id$ */ // point.cpp #include #include "../common/main.h" #include "point.h" using namespace wxjs; using namespace wxjs::ext; /*** * point * ext * * A wxPoint is a useful data structure for graphics operations. * It simply contains integer x and y members. * */ WXJS_INIT_CLASS(Point, "wxPoint", 0) /*** * * * The x-coordinate. * * * The y-coordinate. * * */ WXJS_BEGIN_PROPERTY_MAP(Point) WXJS_PROPERTY(P_X, "x") WXJS_PROPERTY(P_Y, "y") WXJS_END_PROPERTY_MAP() bool Point::GetProperty(wxPoint *p, JSContext *cx, JSObject *obj, int id, jsval *vp) { switch (id) { case P_X: *vp = ToJS(cx, p->x); break; case P_Y: *vp = ToJS(cx, p->y); break; } return true; } bool Point::SetProperty(wxPoint *p, JSContext *cx, JSObject *obj, int id, jsval *vp) { switch (id) { case P_X: FromJS(cx, *vp, p->x); break; case P_Y: FromJS(cx, *vp, p->y); break; } return true; } /*** * * * * The X-coordinate * * * The Y-coordinate. * * * * Creates a new wxPoint. When no arguments are given then wxPoint gets the same value * as wxDefaultPosition. * * */ wxPoint* Point::Construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, bool constructing) { if ( argc == 0 ) { return new wxPoint(); } else { int x = 0; int y = 0; if ( argc > 0 ) { FromJS(cx, argv[0], x); } if ( argc > 1 ) { FromJS(cx, argv[1], y); } return new wxPoint(x, y); } }