a0f4e262创建于 2025年1月23日历史提交
/*
 * Copyright (c) Cangjie Library Team 2022-2022. All rights resvered.
 */

/**
 * @filecj
 *
 */
package cjqt.gui


foreign func nativeBrushCreate(colorPtr: UInt32): Int64
foreign func nativeBrushCreateWithBrush(brushPtr: Int64): Int64
foreign func nativeBrushCreateWithPixmap(pixmapPtr: Int64): Int64
foreign func nativeBrushCreateWithGradient(gradientPtr: Int64): Int64
foreign func nativeBrushDelete(ptr: Int64): Unit

foreign func nativeBrushSetColor(ptr: Int64,colorPtr: UInt32): Unit
foreign func nativeBrushColor(ptr:Int64):UInt32
/**
 * The class is QBrush
 * @author wathinst
 */
public class QBrush {
    /** let member ptr type is Int64 */
    public let ptr: Int64

    /**
     * The Function is init constructor
     *
     * @param ptr of Int64
     */
    public init(ptr: Int64) {
        this.ptr = ptr
    }

    /**
     * The Function is init constructor
     *
     * @param color of QColor
     */
    public init(color: QColor) {
        ptr = unsafe {
            nativeBrushCreate(color.ptr)
        }
    }

    /**
     * The Function is init constructor
     *
     * @param color of QColor
     */
    public init(brush: QBrush) {
        ptr = unsafe {
            nativeBrushCreateWithBrush(brush.ptr)
        }
    }

    /**
     * The Function is init constructor
     *
     * @param pixmap of QPixmap
     */
    public init(pixmap: QPixmap) {
        ptr = unsafe {
            nativeBrushCreateWithPixmap(pixmap.ptr)
        }
    }
    public init(gradient:QGradient){
        ptr = unsafe {
            nativeBrushCreateWithGradient(gradient.ptr)
        }
    }

    /**
     * The Function is delete
     *
     */
    public func delete() {
        unsafe {
            nativeBrushDelete(ptr)
        }
    }

    
    public func setColor(color: QColor) {
        unsafe {
            nativeBrushSetColor(ptr,color.ptr)
        }
    }

    public func color():QColor{
       let color =unsafe{
           nativeBrushColor(ptr)
        }
        return QColor(color);
    }
}