Diffstat (limited to 'noncore/decorations/liquid/liquid.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/decorations/liquid/liquid.cpp | 136 |
1 files changed, 136 insertions, 0 deletions
diff --git a/noncore/decorations/liquid/liquid.cpp b/noncore/decorations/liquid/liquid.cpp new file mode 100644 index 0000000..75b1fc9 --- a/dev/null +++ b/noncore/decorations/liquid/liquid.cpp | |||
@@ -0,0 +1,136 @@ | |||
1 | #include "liquid.h" | ||
2 | |||
3 | #include <qapplication.h> | ||
4 | #include <qpainter.h> | ||
5 | #include <qpalette.h> | ||
6 | #include <qdrawutil.h> | ||
7 | |||
8 | |||
9 | LiquidDecoInterface::LiquidDecoInterface ( ) : ref ( 0 ) | ||
10 | { | ||
11 | } | ||
12 | |||
13 | LiquidDecoInterface::~LiquidDecoInterface ( ) | ||
14 | { | ||
15 | } | ||
16 | |||
17 | |||
18 | |||
19 | QString LiquidDecoInterface::name ( ) const | ||
20 | { | ||
21 | return qApp-> translate ( "Decoration", "Liquid" ); | ||
22 | } | ||
23 | |||
24 | |||
25 | QPixmap LiquidDecoInterface::icon ( ) const | ||
26 | { | ||
27 | return QPixmap ( ); | ||
28 | } | ||
29 | |||
30 | void LiquidDecoInterface::drawArea( Area a, QPainter *p, const WindowData *wd ) const | ||
31 | { | ||
32 | QRect r = wd-> rect; | ||
33 | int th = metric ( TitleHeight, wd ); | ||
34 | |||
35 | switch ( a ) { | ||
36 | case WindowDecorationInterface::Border: { | ||
37 | const QColorGroup &cg = wd-> palette. active ( ); | ||
38 | qDrawWinPanel ( p, r. x ( ) - metric ( LeftBorder, wd ), | ||
39 | r. y ( ) - th - metric ( TopBorder, wd ), | ||
40 | r. width ( ) + metric ( LeftBorder, wd ) + metric ( RightBorder, wd ), | ||
41 | r. height ( ) + th + metric ( TopBorder,wd) + metric ( BottomBorder, wd ), | ||
42 | cg, false, &cg. brush ( QColorGroup::Background )); | ||
43 | break; | ||
44 | } | ||
45 | case WindowDecorationInterface::Title: { | ||
46 | const QColorGroup &cg = wd-> palette. active ( ); | ||
47 | |||
48 | QBrush titleBrush; | ||
49 | QPen titleLines1, titleLines2; | ||
50 | |||
51 | titleBrush = cg. brush (( wd-> flags & WindowData::Active ) ? QColorGroup::Highlight : QColorGroup::Background ); | ||
52 | titleLines1 = titleBrush. color ( ). dark ( 105 ); | ||
53 | titleLines2 = titleBrush. color ( ). dark ( 103 ); | ||
54 | |||
55 | p-> fillRect ( r. x ( ), r. y ( ) - th, r. width ( ), th, titleBrush ); | ||
56 | for ( int i = r.y()-th; i < r.y(); i += 4 ) { | ||
57 | p-> setPen ( titleLines1 ); | ||
58 | p-> drawLine ( r. left ( ), i, r. right ( ), i ); | ||
59 | p-> setPen ( titleLines2 ); | ||
60 | p-> drawLine ( r. left ( ), i+1, r. right ( ), i+1 ); | ||
61 | } | ||
62 | break; | ||
63 | } | ||
64 | case WindowDecorationInterface::TitleText: { | ||
65 | QColor textcol = wd-> palette. active ( ). color (( wd-> flags & WindowData::Active ) ? QColorGroup::HighlightedText : QColorGroup::Text ); | ||
66 | QColor shadecol = ( qGray ( textcol. rgb ( ) ) > 128 ) ? textcol. dark ( 230 ) : textcol.light( 300 ); | ||
67 | if ( textcol == shadecol ) { | ||
68 | if ( qGray ( shadecol. rgb ( ) ) < 128 ) | ||
69 | shadecol = QColor ( 225, 225, 225 ); | ||
70 | else | ||
71 | shadecol = QColor ( 30, 30, 30 ); | ||
72 | } | ||
73 | QColor fillcol = wd-> palette. active ( ). color (( wd-> flags & WindowData::Active ) ? QColorGroup::Highlight : QColorGroup::Background ); | ||
74 | QColor bordercol = fillcol. dark ( 110 ); | ||
75 | fillcol = fillcol. light ( 110 ); | ||
76 | |||
77 | QRect tr ( r.x ( ) + 3 + metric ( HelpWidth, wd ), r. top ( ) - th, | ||
78 | r. width ( ) - metric ( OKWidth, wd ) - metric ( CloseWidth, wd ), th ); | ||
79 | |||
80 | QFont f = p-> font ( ); | ||
81 | f. setWeight ( QFont::Bold ); | ||
82 | p-> setFont ( f ); | ||
83 | |||
84 | QRect br = p-> boundingRect ( tr, QPainter::AlignCenter, wd-> caption ); | ||
85 | int trh2 = tr. height ( ) / 2; | ||
86 | |||
87 | int align = QPainter::AlignCenter; | ||
88 | |||
89 | if ( br. width ( ) + 2 * trh2 > tr. width ( ) ) { | ||
90 | br. setLeft ( tr. left ( ) + trh2 ); | ||
91 | br. setWidth ( tr. width ( ) - 2 * trh2 ); | ||
92 | |||
93 | align = QPainter::AlignLeft | QPainter::AlignVCenter; | ||
94 | } | ||
95 | |||
96 | p-> setBrush ( fillcol ); | ||
97 | p-> setPen ( bordercol /*Qt::NoPen*/ ); | ||
98 | p->drawChord ( br. left ( ) - trh2, tr. top ( ), 2 * trh2, tr. height ( ), 90*16, 180*16 ); | ||
99 | p->drawChord ( br. right ( ) + 1 - trh2, tr. top ( ), 2 * trh2, tr. height ( ), 90*16, -180*16 ); | ||
100 | |||
101 | p-> fillRect ( br.left() - 1, tr. top ( ), br. width ( ) + 2, tr. height ( ), fillcol); | ||
102 | |||
103 | p-> setPen ( shadecol ); | ||
104 | p-> drawText ( br, align, wd-> caption ); | ||
105 | p-> setPen ( textcol ); | ||
106 | br. moveBy ( -1, -1 ); | ||
107 | p-> drawText ( br, align, wd-> caption ); | ||
108 | break; | ||
109 | } | ||
110 | default: { | ||
111 | WindowDecorationInterface::drawArea ( a, p, wd ); | ||
112 | break; | ||
113 | } | ||
114 | } | ||
115 | } | ||
116 | |||
117 | QRESULT LiquidDecoInterface::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) | ||
118 | { | ||
119 | *iface = 0; | ||
120 | |||
121 | if ( uuid == IID_QUnknown ) | ||
122 | *iface = this; | ||
123 | else if ( uuid == IID_WindowDecoration ) | ||
124 | *iface = this; | ||
125 | |||
126 | if ( *iface ) | ||
127 | (*iface)-> addRef ( ); | ||
128 | |||
129 | return QS_OK; | ||
130 | } | ||
131 | |||
132 | Q_EXPORT_INTERFACE() | ||
133 | { | ||
134 | Q_CREATE_INSTANCE( LiquidDecoInterface ) | ||
135 | } | ||
136 | |||