/***************************************************************************
                            QColor.java -  description
                             -------------------
    begin                : Wed Nov 21 17:05:56 2001
    copyright            : (C) 2000-2001 Lost Highway Ltd. All rights reserved.
    email                : Lost_Highway@tipitina.demon.co.uk
    generated by         : duke@tipitina on Wed Nov 21 17:05:56 2001, using kalyptus 0.9.
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
***************************************************************************/

package org.kde.qt;

import java.util.*;
import java.lang.Error;

/**

 $Id: QColor.java,v 1.5 2002/03/03 11:14:05 rdale Exp $

 Definition of Qt namespace (as class for compiler compatibility)

 Created : 980927

 Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.

 This file is part of the kernel module of the Qt GUI Toolkit.

 This file may be distributed under the terms of the Q Public License
 as defined by Trolltech AS of Norway and appearing in the file
 LICENSE.QPL included in the packaging of this file.

 This file may be distributed and/or modified under the terms of the
 GNU General Public License version 2 as published by the Free Software
 Foundation and appearing in the file LICENSE.GPL included in the
 packaging of this file.

 Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
 licenses may use this file in accordance with the Qt Commercial License
 Agreement provided with the Software.

 This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.

 See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
   information about Qt Commercial License Agreements.
 See http://www.trolltech.com/qpl/ for QPL licensing information.
 See http://www.trolltech.com/gpl/ for GPL licensing information.

 Contact info@trolltech.com if any conditions of this licensing are
 not clear to you.


 @short 
* $Id: QColor.java,v 1.5 2002/03/03 11:14:05 rdale Exp $
*
* Definition of Qt namespace (as class for compiler compatibility)
*
* Created : 980927
*
* Copyright (C) 1992-2000 Trolltech AS.
*/
public class  QColor implements QtSupport {
	private long _qt;
	private boolean _allocatedInJavaWorld = true;

	protected QColor(Class dummy){}

	private native void newQColor();
	public QColor() {
		newQColor();
	}
	private native void newQColor( int r, int g, int b);
	public QColor( int r, int g, int b) {
		newQColor( r, g, b);
	}
	private native void newQColor( int x, int y, int z, int arg1);
	public QColor( int x, int y, int z, int arg1) {
		newQColor( x, y, z, arg1);
	}
	private native void newQColor( int rgb, int pixel);
	public QColor( int rgb, int pixel) {
		newQColor( rgb, pixel);
	}
	private native void newQColor( int rgb);
	public QColor( int rgb) {
		newQColor( rgb);
	}
	private native void newQColor( String name);
	public QColor( String name) {
		newQColor( name);
	}
//	private native void newQColor( String name);
//	public QColor( String name) {
//		newQColor( name);
//	}
	private native void newQColor( QColor arg1);
	public QColor( QColor arg1) {
		newQColor( arg1);
	}
	public native boolean isValid();
	public native boolean isDirty();
	public native String name();
	public native void setNamedColor( String name);
	public native void rgb( int[] r, int[] g, int[] b);
	public native int rgb();
	public native void setRgb( int r, int g, int b);
	public native void setRgb( int rgb);
	public native int red();
	public native int green();
	public native int blue();
	public native void hsv( int[] h, int[] s, int[] v);
	public native void getHsv( int h, int s, int v);
	public native void setHsv( int h, int s, int v);
	public native QColor light( int f);
	public native QColor light();
	public native QColor dark( int f);
	public native QColor dark();
	public native int alloc();
	public native int pixel();
	public static native int maxColors();
	public static native int numBitPlanes();
	public static native int enterAllocContext();
	public static native void leaveAllocContext();
	public static native int currentAllocContext();
	public static native void destroyAllocContext( int arg1);
//	public static native int[] palette( int[] numEntries);
//	public static native int[] palette();
//	public static native int setPaletteEntries( int[] entries, int numEntries, int base);
//	public static native int setPaletteEntries( int[] entries, int numEntries);
//	public static native int hPal();
//	public static native int realizePal( QWidget arg1);
	public static native void initialize();
	public static native void cleanup();

	public static final int RGB_MASK    = 0x00ffffff;		// masks RGB values

	public static int qRed( int rgb )		// get red part of RGB
	{ return (int)((rgb >> 16) & 0xff); }

	public static int qGreen( int rgb )		// get green part of RGB
	{ return (int)((rgb >> 8) & 0xff); }

	public static int qBlue( int rgb )		// get blue part of RGB
	{ return (int)(rgb & 0xff); }

	public static int qAlpha( int rgb )		// get alpha part of RGBA
	{ return (int)((rgb >> 24) & 0xff); }

	public static int qRgb( int r, int g, int b )// set RGB value
	{ return (0xff << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff); }

	public static int qRgba( int r, int g, int b, int a )// set RGBA value
	{ return ((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff); }

	public static int qGray( int r, int g, int b )// convert R,G,B to gray 0..255
	{ return (r*11+g*16+b*5)/32; }

	public static int qGray( int rgb )		// convert RGB to gray 0..255
	{ return qGray( qRed(rgb), qGreen(rgb), qBlue(rgb) ); }

	public static final int Rgb = 0;
	public static final int Hsv = 1;
	public static final int Dirt = 0x44495254;
	public static final int Invalid = 0x49000000;
}
