ef54ac709a985277c7c7b474bdf85cb161fd7899
[lichviet] / qml / LichViet / TitleBar.qml
1 /*
2 Copyright (C) 2011  by Cuong Le <metacuong@gmail.com>
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program.  If not, see <http://www.gnu.org/licenses/>
16 */
17
18 import QtQuick 1.0
19
20 Item {
21
22     id:title_bar
23
24     height: 46
25     width: parent.width
26
27     opacity: 0.8
28
29     /*
30       Default value of properties
31       */
32
33     property int radius: 4
34     property string border_color: "#e28282"
35     property string background_color: "white"
36
37     property int shadow_height: 10
38     property string shadow_begin_color: "#000000"
39     property string shadow_end_color: "#fff7f7"
40
41     property string caption: ""
42     property string caption_color: "black"
43     property string caption_font: "Tahoma"
44     property int caption_font_size: 18
45     property bool caption_font_bold : true
46
47     /*
48       Signals
49       */
50
51     signal minimize
52     signal close
53
54     /*
55       Title Bar Init
56       */
57
58     Rectangle {
59         id:main_title
60
61         width: parent.width
62         height: parent.height
63
64         color: parent.background_color
65         radius: parent.radius
66         border.color: parent.border_color
67     }
68
69     Text {
70         id:title_bar_caption
71
72         text: parent.caption
73
74         font.bold: parent.caption_font_bold
75         font.pointSize: parent.caption_font_size
76         font.family: parent.caption_font
77
78         color: parent.caption_color
79
80         x:btn_minimize.width + 5*2
81         y:(main_title.height/2) - (height/2)
82     }
83
84     /*
85       Title Bar Buttons
86       */
87
88     /*
89       Minimize button
90       */
91
92     Rectangle {
93         id: btn_minimize
94
95         x:title_bar.x + 5
96         y:title_bar.y + 5
97
98         height: title_bar.height - 10
99         width: 45
100
101         color: "transparent"
102
103         border.color: "grey"
104         border.width: 1
105
106         radius: parent.radius
107
108         Rectangle {
109             x:parent.x
110             y:parent.y
111
112             width: parent.width - 15
113             height: parent.height - 15
114
115             border.color: "white"
116             color: "black"
117             border.width: 1
118         }
119
120         Rectangle {
121             x:parent.x + 5
122             y:parent.y + 5
123             width: parent.width - 15
124             height: parent.height - 15
125
126             border.color: "white"
127             color: "black"
128             border.width: 1
129         }
130
131         MouseArea {
132             anchors.fill: parent
133
134             onClicked: title_bar.minimize()
135
136             onPressed: {
137                 parent.color = "blue"
138             }
139
140             onReleased: {
141                 parent.color = "transparent"
142             }
143         }
144
145     }
146
147     /*
148       Close button
149       */
150
151     Rectangle {
152         id: btn_close
153
154         x:title_bar.width - 50
155         y:title_bar.y + 5
156
157         width: 45
158         height: title_bar.height - 10
159
160         color: "transparent"
161
162         border.color: "grey"
163         border.width: 1
164
165         radius: parent.radius
166
167         Text {
168             id: button1
169             color: "#000000"
170             anchors.centerIn: parent; font.bold: true
171             text: "X"; style: Text.Raised; styleColor: "black"
172             font.pixelSize: 26
173             font.family: "Tahoma"
174         }
175
176         MouseArea {
177             anchors.fill: parent
178
179             onClicked: title_bar.close()
180
181             onPressed: {
182                 parent.color = "blue"
183             }
184
185             onReleased: {
186                 parent.color = "transparent"
187             }
188         }
189     }
190
191 }