/* Copyright (C) 2000 Free Software Foundation This file is part of libgcj. This software is copyrighted work licensed under the terms of the Libgcj License. Please consult the file "LIBGCJ_LICENSE" for details. */ // Needed to avoid linking in libstdc++ #ifndef __STL_USE_EXCEPTIONS # include # define __THROW_BAD_ALLOC throw new java::lang::OutOfMemoryError() #endif #include #include #include #include #include #include #include #include #include jlong gnu::gcj::xlib::Colormap::allocateColorPixel(XColor* color) { ::Display* dpy = (::Display*) (screen->getDisplay()->display); ::XColor* col = (::XColor*) (color->structure); Status result = XAllocColor(dpy, xid, col); if (result == 0) throw new ::java::lang::RuntimeException( JvNewStringLatin1("Unable to allocate color pixel.")); return col->pixel; } typedef JArray* xcolorarray; xcolorarray gnu::gcj::xlib::Colormap::getSharedColors() { ::Display* dpy = (::Display*) (screen->getDisplay()->display); unsigned int nCells = CellsOfScreen(ScreenOfDisplay(dpy, screen->screenNumber)); typedef ::XColor xcolor; std::vector colors(nCells); for (unsigned int i=0; i* shared = newXColorArray(nShared); int si=0; for (unsigned int i=0; istructure; ::XColor* colStruct = reinterpret_cast(colorData); *colStruct = colors[i]; } return shared; } xcolorarray gnu::gcj::xlib::Colormap::getXColors() { ::Display* dpy = (::Display*) (screen->getDisplay()->display); unsigned int nCells = CellsOfScreen(ScreenOfDisplay(dpy, screen->screenNumber)); typedef ::XColor xcolor; std::vector colors(nCells); JArray* colArray = newXColorArray(nCells); for (unsigned int i=0; istructure; ::XColor* colStruct = reinterpret_cast(colorData); *colStruct = colors[i]; colStruct->flags = flag; } return colArray; }