AnchorBox.qml 4.85 KB
Newer Older
1
import Qt 4.7
2
import Bauhaus 1.0
3 4 5 6 7

QWidget {
    width:220;fixedWidth:  width
    height:220;fixedHeight: height
    styleSheetFile: "anchorbox.css"
8

9 10 11
    function isBorderAnchored() {
        return anchorBackend.leftAnchored || anchorBackend.topAnchored || anchorBackend.rightAnchored || anchorBackend.bottomAnchored;
    }
12

13 14 15
    function fill() {
        anchorBackend.fill();
    }
16

17 18
    function breakLayout() {
        anchorBackend.resetLayout()
19 20 21 22 23 24 25 26
    }

    QPushButton {
	text: "fill";
        height:20;fixedHeight: height;
        x: 0;
        y: 0;
        width:200;fixedWidth: width;
27
        id: qPushButton1;
28 29 30 31
	onReleased: fill();
    }

    QPushButton {
32
        text: "break";
33 34 35 36
	y: 200;
	height:20;fixedHeight: height;
	width:200;fixedWidth: width;
	x: 0;
37
	id: qPushButton3;
38 39 40 41 42 43 44 45 46 47 48
	onReleased: breakLayout();
    }

    QPushButton {
        height:100;fixedHeight: height;
	text: "left";
	font.bold: true;
        x: 16 ;
        y: 60;
        //styleSheet: "border-radius:5px; background-color: #ffda82";
        width:30;fixedWidth: width;
49
        id: qPushButton5;
50 51 52
	checkable: true;
	checked: anchorBackend.leftAnchored;
	onReleased: {
53
            if (checked) {
54 55
		anchorBackend.horizontalCentered = false;
		anchorBackend.leftAnchored = true;
56
            } else {
57
		anchorBackend.leftAnchored = false;
58
            }
59 60 61 62 63 64 65
	}
    }

    QPushButton {
	text: "top";
	font.bold: true;
        //styleSheet: "border-radius:5px; background-color: #ffda82";
66 67
        height:27;fixedHeight: 27;
        width:100;fixedWidth: 100;
68 69
        x: 49;
        y: 30;
70
        id: qPushButton6;
71 72 73
	checkable: true;
	checked: anchorBackend.topAnchored;
	onReleased: {
74
            if (checked) {
75 76
		anchorBackend.verticalCentered = false;
		anchorBackend.topAnchored = true;
77
            } else {
78
		anchorBackend.topAnchored = false;
79
            }
80 81 82 83 84 85 86 87 88 89 90
	}
    }

    QPushButton {
	text: "right";
	font.bold: true;
	x: 153;
	y: 60;
	//styleSheet: "border-radius:5px; background-color: #ffda82";
	width:30;fixedWidth: width;
	height:100;fixedHeight: height;
91
	id: qPushButton7;
92 93 94
	checkable: true;
	checked: anchorBackend.rightAnchored;
	onReleased: {
95
            if (checked) {
96 97
		anchorBackend.horizontalCentered = false;
		anchorBackend.rightAnchored = true;
98
            } else {
99
		anchorBackend.rightAnchored = false;
100
            }
101 102 103 104 105 106 107 108 109 110 111
	}
    }

    QPushButton {
	text: "bottom";
	font.bold: true;
        //styleSheet: "border-radius:5px; background-color: #ffda82";
        width:100;fixedWidth: width;
        x: 49;
        y: 164;
        height:27;fixedHeight: height;
112
        id: qPushButton8;
113 114 115
	checkable: true;
	checked: anchorBackend.bottomAnchored;
	onReleased: {
116
            if (checked) {
117 118
		anchorBackend.verticalCentered = false;
		anchorBackend.bottomAnchored = true;
119
            } else {
120
		anchorBackend.bottomAnchored = false;
121
            }
122 123 124 125 126 127 128 129 130
	}
    }

    QToolButton {
        width:100;fixedWidth: width;
        //styleSheet: "border-radius:50px;background-color: rgba(85, 170, 255, 255)";
        x: 49;
        y: 60;
        height:100;fixedHeight: height;
131
        id: qPushButton9;
132 133 134 135 136 137 138 139 140 141 142 143

	QPushButton {
	    width:24;fixedWidth: width;
	    //styleSheet: "border-radius:5px; background-color: #bf3f00;";
	    x: 38;
	    y: 2;
	    height:96;fixedHeight: height;
	    checkable: true;
	    id: horizontalCenterButton;
	    checked: anchorBackend.horizontalCentered;
	    onReleased: {
		if (checked) {
144 145 146
                    anchorBackend.rightAnchored = false;
                    anchorBackend.leftAnchored = false;
                    anchorBackend.horizontalCentered = true;
147
		} else {
148
                    anchorBackend.horizontalCentered = false;
149 150 151 152 153 154 155 156 157 158 159 160 161 162
		}
	    }
	}

	QPushButton {
	    height:24;fixedHeight: height;
	    x: 2;
	    y: 38;
	    width:96;fixedWidth: width;
	    id: verticalCenterButton;
	    checkable: true;
	    checked: anchorBackend.verticalCentered;
	    onReleased: {
		if (checked) {
163 164 165
                    anchorBackend.topAnchored = false;
                    anchorBackend.bottomAnchored = false;
                    anchorBackend.verticalCentered = true;
166
		} else {
167
                    anchorBackend.verticalCentered = false;
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
		}
	    }
	}

	QPushButton {
	    text: "center";
	    font.bold: true;
	    //styleSheet: "border-radius:20px; background-color: #ff5500";
	    width:40;fixedWidth: width;
	    height:40;fixedHeight: height;
	    x: 30;
	    y: 30;
	    id: centerButton;
	    checkable: true;
	    checked: anchorBackend.verticalCentered && anchorBackend.horizontalCentered;
	    onReleased: {
                if (checked) {
		    anchorBackend.leftAnchored = false;
		    anchorBackend.topAnchored = false;
		    anchorBackend.rightAnchored = false;
		    anchorBackend.bottomAnchored = false;
		    anchorBackend.verticalCentered = true;
		    anchorBackend.horizontalCentered = true;
                } else {
		    anchorBackend.verticalCentered = false;
		    anchorBackend.horizontalCentered = false;
                }
	    }
	}
    }
}