summaryrefslogtreecommitdiffstats
path: root/examples/declarative/tic-tac-toe/content/Button.qml
blob: 56e5ecdcbc4e2143f321bf48b92a374cde87bda4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import Qt 4.7

Rectangle {
    id: container

    property string text: "Button"
    property bool down: false
    property string mainCol: "lightgray"
    property string darkCol: "darkgray"
    property string lightCol: "white"

    width: txtItem.width + 20; height: txtItem.height + 6
    border { width: 1; color: Qt.darker(mainCol) } 
    radius: 8;
    color: mainCol
    smooth: true

    gradient: Gradient {
        GradientStop {
            id: topGrad; position: 0.0
            color: if (container.down) { darkCol } else { lightCol }
        }
        GradientStop { position: 1.0; color: mainCol }
    }

    signal clicked

    MouseArea { id: mr; anchors.fill: parent; onClicked: container.clicked() }

    Text {
        id: txtItem

        anchors.centerIn: container
        text: container.text;
        color: "blue"
        style: Text.Outline; styleColor: "white"
        font.pixelSize: 14; font.bold: true
    }
}