view qt/d1/qt/core/QSize.d @ 282:256ab6cb8e85

Signals look-up andNew syntax for connect. The old one will not work from now on. This will allow for the signals overload. Although changes are done for both D1 and D2 versions, D1 won't work because of compiler bugs. I am tired of waiting for fixes.
author eldar
date Fri, 16 Oct 2009 02:43:59 +0000
parents 99e74c8a22f8
children
line wrap: on
line source

module qt.core.QSize;

public import qt.QGlobal;
public import qt.core.Qt;


public struct QSize
{
/* ctors, reserved for D2
    public this()
    { wd = ht = -1; }

    public this(int w, int h)
    { wd = w; ht = h; }
*/

    public static QSize opCall() {
        QSize sz;
        sz.wd = sz.ht = -1;
        return sz;
    }

    public static QSize opCall(int w, int h) {
        QSize sz;
        sz.wd = w;
        sz.ht = h;
        return sz;
    }

    final bool isNull()
    { return wd==0 && ht==0; }
    
    final bool isEmpty()
    { return wd<1 || ht<1; }
    
    final bool isValid()
    { return wd>=0 && ht>=0; }

    final int width()
    { return wd; }
    
    final int height()
    { return ht; }
    
    final void width(int w)
    { wd = w; }
    
    final void height(int h)
    { ht = h; }
    
    final void setWidth(int w) // for convenience
    { wd = w; }
    
    final void setHeight(int h) // for convenience
    { ht = h; }
    
    void transpose() {
        int tmp = wd;
        wd = ht;
        ht = tmp;
    }

    void scale(int w, int h, Qt.AspectRatioMode mode) {
        scale(QSize(w, h), mode);
    }
    
    void scale(in QSize s, Qt.AspectRatioMode mode) {
        __qtd_QSize_scale_QSize_AspectRatioMode(this, &s, mode);
    }

    QSize expandedTo(in QSize otherSize) {
        return QSize(qMax(wd,otherSize.wd), qMax(ht,otherSize.ht));
    }

    QSize boundedTo(in QSize otherSize) {
        return QSize(qMin(wd,otherSize.wd), qMin(ht,otherSize.ht));
    }
/*
    public final void writeTo(QDataStream arg__1)    {
        __qtd_QSize_writeTo_QDataStream(this, arg__1 is null ? null : arg__1.nativeId);
    }

    public final void readFrom(QDataStream arg__1)    {
        __qtd_QSize_readFrom_QDataStream(this, arg__1 is null ? null : arg__1.nativeId);
    }
*/
    QSize opAddAssign(in QSize s)
    { wd+=s.wd; ht+=s.ht; return *this; }

    QSize opSubAssign(in QSize s)
    { wd-=s.wd; ht-=s.ht; return *this; }

    QSize opMulAssign(qreal c)
    { wd = qRound(wd*c); ht = qRound(ht*c); return *this; }

    bool opEquals(in QSize s)
    { return wd == s.wd && ht == s.ht; }

    QSize opAdd(in QSize s)
    { return QSize(this.wd+s.wd, this.ht+s.ht); }

    QSize opSub(in QSize s)
    { return QSize(this.wd-s.wd, this.ht-s.ht); }

    QSize opMul(qreal c)
    { return QSize(qRound(this.wd*c), qRound(this.ht*c)); }

    QSize opDivAssign(qreal c) {
        assert(!qFuzzyCompare(c + 1, 1.));
        wd = qRound(wd/c); ht = qRound(ht/c);
        return *this;
    }

    QSize opDiv(qreal c) {
        assert(!qFuzzyCompare(c + 1, 1.));
        return QSize(qRound(this.wd/c), qRound(this.ht/c));
    }

private:
    int wd;
    int ht;
}


public struct QSizeF
{
/* ctors, reserved for D2
    this()
    { wd = ht = -1.; }

    this(ref QSize sz)
    { wd = sz.width(); ht = sz.height(); }

    this(qreal w, qreal h)
    { wd = w; ht = h; }
*/
    public static QSizeF opCall() {
        QSizeF sz;
        sz.wd = sz.ht = -1.;
        return sz;
    }

    public static QSizeF opCall(in QSizeF s) {
        QSizeF sz;
        sz.wd = s.width(); sz.ht = s.height();
        return sz;
    }

    public static QSizeF opCall(qreal w, qreal h) {
        QSizeF sz;
        sz.wd = w; sz.ht = h;
        return sz;
    }

    bool isNull()
    { return qIsNull(wd) && qIsNull(ht); }

    bool isEmpty()
    { return wd <= 0. || ht <= 0.; }

    bool isValid()
    { return wd >= 0. && ht >= 0.; }

    qreal width()
    { return wd; }

    qreal height()
    { return ht; }

    void width(qreal w)
    { wd = w; }

    void height(qreal h)
    { ht = h; }

    void setWidth(qreal w)
    { wd = w; }

    void setHeight(qreal h)
    { ht = h; }

    void scale(qreal w, qreal h, Qt.AspectRatioMode mode)
    { scale(QSizeF(w, h), mode); }

    public final void scale(QSizeF s, Qt.AspectRatioMode mode)
    { __qtd_QSizeF_scale_QSizeF_AspectRatioMode(this, &s, mode); }

    void transpose() {
        qreal tmp = wd;
        wd = ht;
        ht = tmp;
    }

    QSizeF expandedTo(in QSizeF otherSize)
    { return QSizeF(qMax(wd,otherSize.wd), qMax(ht,otherSize.ht)); }

    QSizeF boundedTo(in QSizeF otherSize)
    { return QSizeF(qMin(wd,otherSize.wd), qMin(ht,otherSize.ht)); }

    QSize toSize()
    { return QSize(qRound(wd), qRound(ht));    }
/*
    public final void writeTo(QDataStream arg__1) {
        __qtd_QSizeF_writeTo_QDataStream(this, arg__1 is null ? null : arg__1.nativeId);
    }

    public final void readFrom(QDataStream arg__1) {
        __qtd_QSizeF_readFrom_QDataStream(this, arg__1 is null ? null : arg__1.nativeId);
*/
    QSizeF opAddAssign(in QSizeF s)
    { wd += s.wd; ht += s.ht; return *this; }

    QSizeF opSubAssign(in QSizeF s)
    { wd -= s.wd; ht -= s.ht; return *this; }

    QSizeF opMulAssign(qreal c)
    { wd *= c; ht *= c; return *this; }

    bool opEquals(in QSizeF s)
    { return qFuzzyCompare(wd, s.wd) && qFuzzyCompare(ht, s.ht); }

    QSizeF opAdd(in QSizeF s)
    { return QSizeF(this.wd+s.wd, this.ht+s.ht); }

    QSizeF opSub(in QSizeF s)
    { return QSizeF(this.wd-s.wd, this.ht-s.ht); }

    QSizeF opMul(qreal c)
    { return QSizeF(this.wd*c, this.ht*c); }

    QSizeF opDivAssign(qreal c)
    {
        assert(!qFuzzyCompare(c + 1, 1.));
        wd = wd/c; ht = ht/c;
        return *this;
    }

    QSizeF opDiv(qreal c)
    {
        assert(!qFuzzyCompare(c + 1, 1.));
        return QSizeF(this.wd/c, this.ht/c);
    }

private:
    qreal wd;
    qreal ht;
}

extern (C) void qtd_append_array_QSize(QSize[]* arr, QSize arg)
{
    *arr ~= arg;
}

extern (C) void qtd_append_array_QSizeF(QSizeF[]* arr, QSizeF arg)
{
    *arr ~= arg;
}

// C wrappers
// QSize
private extern(C) void  __qtd_QSize_scale_QSize_AspectRatioMode(void* __this_nativeId,
 void* s0,
 int mode1);
private extern(C) void  __qtd_QSize_writeTo_QDataStream(void* __this_nativeId,
 void* arg__1);
private extern(C) void  __qtd_QSize_readFrom_QDataStream(void* __this_nativeId,
 void* arg__1);

// QSizeF
private extern(C) void  __qtd_QSizeF_writeTo_QDataStream(void* __this_nativeId,
 void* arg__1);
private extern(C) void  __qtd_QSizeF_readFrom_QDataStream(void* __this_nativeId,
 void* arg__1);
private extern(C) void  __qtd_QSizeF_scale_QSizeF_AspectRatioMode(void* __this_nativeId,
 void* s0,
 int mode1);